summaryrefslogtreecommitdiffstats
path: root/gst/rtp
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2005-09-22 10:39:11 +0000
committerWim Taymans <wim.taymans@gmail.com>2005-09-22 10:39:11 +0000
commit9a478bd315749b084561547ce31745fd02c25723 (patch)
treef714f373fe8f4b38ca005eb5e6d818565d1b2908 /gst/rtp
parent001a51dba26823044b64aa50bed98fa11c0e90b3 (diff)
gst/rtp/: Remove g_print.
Original commit message from CVS: * gst/rtp/TODO: * gst/rtp/gstrtpmp4vdec.c: (gst_rtpmp4vdec_setcaps): * gst/rtp/gstrtpmp4venc.c: (gst_rtpmp4venc_class_init), (gst_rtpmp4venc_init), (gst_rtpmp4venc_parse_data), (gst_rtpmp4venc_handle_buffer), (gst_rtpmp4venc_set_property), (gst_rtpmp4venc_get_property): * gst/rtp/gstrtpmp4venc.h: Remove g_print. Update TODO Make payload encoder a bit smarter and more correct with timestamps. Added option in payloader to include config string in-band.
Diffstat (limited to 'gst/rtp')
-rw-r--r--gst/rtp/TODO16
-rw-r--r--gst/rtp/gstrtpmp4vdec.c4
-rw-r--r--gst/rtp/gstrtpmp4vdepay.c4
-rw-r--r--gst/rtp/gstrtpmp4venc.c109
-rw-r--r--gst/rtp/gstrtpmp4venc.h1
-rw-r--r--gst/rtp/gstrtpmp4vpay.c109
-rw-r--r--gst/rtp/gstrtpmp4vpay.h1
7 files changed, 210 insertions, 34 deletions
diff --git a/gst/rtp/TODO b/gst/rtp/TODO
index 1b2fcfd3..658e381f 100644
--- a/gst/rtp/TODO
+++ b/gst/rtp/TODO
@@ -9,3 +9,19 @@
* payload_t
* sequence number should not start at 0, but randomly
+
+* MPEG4 header
+ - ffmpeg mpeg4 decoder gives error message when sending only the config
+ string, parsing is OK, error just means no picture was found in the
+ stream.
+
+
+* compare H263 encoders and H263+
+
+* better RTP packetizing for h263
+
+* bitrate tuning in ffmpeg
+
+* make ffmpeg negotiate only with accepted framerates
+
+
diff --git a/gst/rtp/gstrtpmp4vdec.c b/gst/rtp/gstrtpmp4vdec.c
index 0b6ae403..60ee390d 100644
--- a/gst/rtp/gstrtpmp4vdec.c
+++ b/gst/rtp/gstrtpmp4vdec.c
@@ -179,8 +179,6 @@ gst_rtpmp4vdec_setcaps (GstPad * pad, GstCaps * caps)
if ((str = gst_structure_get_string (structure, "config"))) {
GValue v = { 0 };
- g_print ("config=%s\n", str);
-
g_value_init (&v, GST_TYPE_BUFFER);
if (gst_value_deserialize (&v, str)) {
GstBuffer *buffer;
@@ -189,8 +187,6 @@ gst_rtpmp4vdec_setcaps (GstPad * pad, GstCaps * caps)
gst_buffer_ref (buffer);
g_value_unset (&v);
- g_print ("buf=%p\n", buffer);
-
gst_buffer_set_caps (buffer, GST_PAD_CAPS (rtpmp4vdec->srcpad));
gst_pad_push (rtpmp4vdec->srcpad, buffer);
diff --git a/gst/rtp/gstrtpmp4vdepay.c b/gst/rtp/gstrtpmp4vdepay.c
index 0b6ae403..60ee390d 100644
--- a/gst/rtp/gstrtpmp4vdepay.c
+++ b/gst/rtp/gstrtpmp4vdepay.c
@@ -179,8 +179,6 @@ gst_rtpmp4vdec_setcaps (GstPad * pad, GstCaps * caps)
if ((str = gst_structure_get_string (structure, "config"))) {
GValue v = { 0 };
- g_print ("config=%s\n", str);
-
g_value_init (&v, GST_TYPE_BUFFER);
if (gst_value_deserialize (&v, str)) {
GstBuffer *buffer;
@@ -189,8 +187,6 @@ gst_rtpmp4vdec_setcaps (GstPad * pad, GstCaps * caps)
gst_buffer_ref (buffer);
g_value_unset (&v);
- g_print ("buf=%p\n", buffer);
-
gst_buffer_set_caps (buffer, GST_PAD_CAPS (rtpmp4vdec->srcpad));
gst_pad_push (rtpmp4vdec->srcpad, buffer);
diff --git a/gst/rtp/gstrtpmp4venc.c b/gst/rtp/gstrtpmp4venc.c
index 5a5de12a..59603f8e 100644
--- a/gst/rtp/gstrtpmp4venc.c
+++ b/gst/rtp/gstrtpmp4venc.c
@@ -54,12 +54,25 @@ GST_STATIC_PAD_TEMPLATE ("src",
)
);
+#define DEFAULT_SEND_CONFIG FALSE
+
+enum
+{
+ ARG_0,
+ ARG_SEND_CONFIG
+};
+
static void gst_rtpmp4venc_class_init (GstRtpMP4VEncClass * klass);
static void gst_rtpmp4venc_base_init (GstRtpMP4VEncClass * klass);
static void gst_rtpmp4venc_init (GstRtpMP4VEnc * rtpmp4venc);
static void gst_rtpmp4venc_finalize (GObject * object);
+static void gst_rtpmp4venc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_rtpmp4venc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
static gboolean gst_rtpmp4venc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps);
static GstFlowReturn gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * payload,
@@ -118,6 +131,14 @@ gst_rtpmp4venc_class_init (GstRtpMP4VEncClass * klass)
parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD);
+ gobject_class->set_property = gst_rtpmp4venc_set_property;
+ gobject_class->get_property = gst_rtpmp4venc_get_property;
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SEND_CONFIG,
+ g_param_spec_boolean ("send-config", "Send Config",
+ "Send the config parameters in RTP packets as well",
+ DEFAULT_SEND_CONFIG, G_PARAM_READWRITE));
+
gobject_class->finalize = gst_rtpmp4venc_finalize;
gstbasertppayload_class->set_caps = gst_rtpmp4venc_setcaps;
@@ -130,6 +151,7 @@ gst_rtpmp4venc_init (GstRtpMP4VEnc * rtpmp4venc)
rtpmp4venc->adapter = gst_adapter_new ();
rtpmp4venc->rate = 90000;
rtpmp4venc->profile = 1;
+ rtpmp4venc->send_config = DEFAULT_SEND_CONFIG;
}
static void
@@ -241,11 +263,14 @@ gst_rtpmp4venc_flush (GstRtpMP4VEnc * rtpmp4venc)
#define VOP_STARTCODE 0x000001B6
static gboolean
-gst_rtpmp4venc_parse_data (GstRtpMP4VEnc * enc, guint8 * data, guint size)
+gst_rtpmp4venc_parse_data (GstRtpMP4VEnc * enc, guint8 * data, guint size,
+ gint * strip)
{
guint32 code;
gboolean result;
+ *strip = 0;
+
if (size < 5)
return FALSE;
@@ -291,13 +316,17 @@ gst_rtpmp4venc_parse_data (GstRtpMP4VEnc * enc, guint8 * data, guint size)
memcpy (GST_BUFFER_DATA (enc->config), data, i);
gst_rtpmp4venc_new_caps (enc);
}
+ *strip = i;
+ /* we need to flush out the current packet. */
result = TRUE;
break;
}
case VOP_STARTCODE:
+ /* VOP startcode, we don't have to flush the packet */
result = FALSE;
break;
default:
+ /* all other startcodes need a flush */
result = TRUE;
break;
}
@@ -316,6 +345,9 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
guint packet_len;
guint8 *data;
gboolean flush;
+ gint strip;
+
+ ret = GST_FLOW_OK;
rtpmp4venc = GST_RTP_MP4V_ENC (basepayload);
@@ -323,32 +355,83 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
data = GST_BUFFER_DATA (buffer);
avail = gst_adapter_available (rtpmp4venc->adapter);
+ /* empty buffer, take timestamp */
+ if (avail == 0) {
+ rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
+ }
+
/* parse incomming data and see if we need to start a new RTP
* packet */
- flush = gst_rtpmp4venc_parse_data (rtpmp4venc, data, size);
-
- /* get packet length of previous data and this new data */
- packet_len = gst_rtpbuffer_calc_packet_len (avail + size, 0, 0);
+ flush = gst_rtpmp4venc_parse_data (rtpmp4venc, data, size, &strip);
+ if (strip) {
+ /* strip off config if requested */
+ if (!rtpmp4venc->send_config) {
+ GstBuffer *subbuf;
+
+ /* strip off header */
+ subbuf = gst_buffer_create_sub (buffer, strip, size - strip);
+ gst_buffer_unref (buffer);
+ buffer = subbuf;
+
+ size = GST_BUFFER_SIZE (buffer);
+ data = GST_BUFFER_DATA (buffer);
+ }
+ }
- /* if this buffer is going to overflow the packet, flush what we
- * have. */
- if (flush || packet_len > GST_BASE_RTP_PAYLOAD_MTU (rtpmp4venc)) {
+ /* if we need to flush, do so now */
+ if (flush) {
ret = gst_rtpmp4venc_flush (rtpmp4venc);
- avail = 0;
}
+ /* push new data */
gst_adapter_push (rtpmp4venc->adapter, buffer);
+ avail = gst_adapter_available (rtpmp4venc->adapter);
+
+ /* get packet length of data and see if we exceeded MTU. */
+ packet_len = gst_rtpbuffer_calc_packet_len (avail, 0, 0);
- if (avail == 0) {
- rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
+ if (packet_len > GST_BASE_RTP_PAYLOAD_MTU (rtpmp4venc)) {
+ ret = gst_rtpmp4venc_flush (rtpmp4venc);
}
- ret = GST_FLOW_OK;
-
return ret;
}
+static void
+gst_rtpmp4venc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstRtpMP4VEnc *rtpmp4venc;
+
+ rtpmp4venc = GST_RTP_MP4V_ENC (object);
+
+ switch (prop_id) {
+ case ARG_SEND_CONFIG:
+ rtpmp4venc->send_config = g_value_get_boolean (value);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+gst_rtpmp4venc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstRtpMP4VEnc *rtpmp4venc;
+
+ rtpmp4venc = GST_RTP_MP4V_ENC (object);
+
+ switch (prop_id) {
+ case ARG_SEND_CONFIG:
+ g_value_set_boolean (value, rtpmp4venc->send_config);
+ break;
+ default:
+ break;
+ }
+}
+
gboolean
gst_rtpmp4venc_plugin_init (GstPlugin * plugin)
{
diff --git a/gst/rtp/gstrtpmp4venc.h b/gst/rtp/gstrtpmp4venc.h
index 2edd0171..996b9a7b 100644
--- a/gst/rtp/gstrtpmp4venc.h
+++ b/gst/rtp/gstrtpmp4venc.h
@@ -50,6 +50,7 @@ struct _GstRtpMP4VEnc
gint rate;
gint profile;
GstBuffer *config;
+ gboolean send_config;
};
struct _GstRtpMP4VEncClass
diff --git a/gst/rtp/gstrtpmp4vpay.c b/gst/rtp/gstrtpmp4vpay.c
index 5a5de12a..59603f8e 100644
--- a/gst/rtp/gstrtpmp4vpay.c
+++ b/gst/rtp/gstrtpmp4vpay.c
@@ -54,12 +54,25 @@ GST_STATIC_PAD_TEMPLATE ("src",
)
);
+#define DEFAULT_SEND_CONFIG FALSE
+
+enum
+{
+ ARG_0,
+ ARG_SEND_CONFIG
+};
+
static void gst_rtpmp4venc_class_init (GstRtpMP4VEncClass * klass);
static void gst_rtpmp4venc_base_init (GstRtpMP4VEncClass * klass);
static void gst_rtpmp4venc_init (GstRtpMP4VEnc * rtpmp4venc);
static void gst_rtpmp4venc_finalize (GObject * object);
+static void gst_rtpmp4venc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_rtpmp4venc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
static gboolean gst_rtpmp4venc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps);
static GstFlowReturn gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * payload,
@@ -118,6 +131,14 @@ gst_rtpmp4venc_class_init (GstRtpMP4VEncClass * klass)
parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD);
+ gobject_class->set_property = gst_rtpmp4venc_set_property;
+ gobject_class->get_property = gst_rtpmp4venc_get_property;
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SEND_CONFIG,
+ g_param_spec_boolean ("send-config", "Send Config",
+ "Send the config parameters in RTP packets as well",
+ DEFAULT_SEND_CONFIG, G_PARAM_READWRITE));
+
gobject_class->finalize = gst_rtpmp4venc_finalize;
gstbasertppayload_class->set_caps = gst_rtpmp4venc_setcaps;
@@ -130,6 +151,7 @@ gst_rtpmp4venc_init (GstRtpMP4VEnc * rtpmp4venc)
rtpmp4venc->adapter = gst_adapter_new ();
rtpmp4venc->rate = 90000;
rtpmp4venc->profile = 1;
+ rtpmp4venc->send_config = DEFAULT_SEND_CONFIG;
}
static void
@@ -241,11 +263,14 @@ gst_rtpmp4venc_flush (GstRtpMP4VEnc * rtpmp4venc)
#define VOP_STARTCODE 0x000001B6
static gboolean
-gst_rtpmp4venc_parse_data (GstRtpMP4VEnc * enc, guint8 * data, guint size)
+gst_rtpmp4venc_parse_data (GstRtpMP4VEnc * enc, guint8 * data, guint size,
+ gint * strip)
{
guint32 code;
gboolean result;
+ *strip = 0;
+
if (size < 5)
return FALSE;
@@ -291,13 +316,17 @@ gst_rtpmp4venc_parse_data (GstRtpMP4VEnc * enc, guint8 * data, guint size)
memcpy (GST_BUFFER_DATA (enc->config), data, i);
gst_rtpmp4venc_new_caps (enc);
}
+ *strip = i;
+ /* we need to flush out the current packet. */
result = TRUE;
break;
}
case VOP_STARTCODE:
+ /* VOP startcode, we don't have to flush the packet */
result = FALSE;
break;
default:
+ /* all other startcodes need a flush */
result = TRUE;
break;
}
@@ -316,6 +345,9 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
guint packet_len;
guint8 *data;
gboolean flush;
+ gint strip;
+
+ ret = GST_FLOW_OK;
rtpmp4venc = GST_RTP_MP4V_ENC (basepayload);
@@ -323,32 +355,83 @@ gst_rtpmp4venc_handle_buffer (GstBaseRTPPayload * basepayload,
data = GST_BUFFER_DATA (buffer);
avail = gst_adapter_available (rtpmp4venc->adapter);
+ /* empty buffer, take timestamp */
+ if (avail == 0) {
+ rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
+ }
+
/* parse incomming data and see if we need to start a new RTP
* packet */
- flush = gst_rtpmp4venc_parse_data (rtpmp4venc, data, size);
-
- /* get packet length of previous data and this new data */
- packet_len = gst_rtpbuffer_calc_packet_len (avail + size, 0, 0);
+ flush = gst_rtpmp4venc_parse_data (rtpmp4venc, data, size, &strip);
+ if (strip) {
+ /* strip off config if requested */
+ if (!rtpmp4venc->send_config) {
+ GstBuffer *subbuf;
+
+ /* strip off header */
+ subbuf = gst_buffer_create_sub (buffer, strip, size - strip);
+ gst_buffer_unref (buffer);
+ buffer = subbuf;
+
+ size = GST_BUFFER_SIZE (buffer);
+ data = GST_BUFFER_DATA (buffer);
+ }
+ }
- /* if this buffer is going to overflow the packet, flush what we
- * have. */
- if (flush || packet_len > GST_BASE_RTP_PAYLOAD_MTU (rtpmp4venc)) {
+ /* if we need to flush, do so now */
+ if (flush) {
ret = gst_rtpmp4venc_flush (rtpmp4venc);
- avail = 0;
}
+ /* push new data */
gst_adapter_push (rtpmp4venc->adapter, buffer);
+ avail = gst_adapter_available (rtpmp4venc->adapter);
+
+ /* get packet length of data and see if we exceeded MTU. */
+ packet_len = gst_rtpbuffer_calc_packet_len (avail, 0, 0);
- if (avail == 0) {
- rtpmp4venc->first_ts = GST_BUFFER_TIMESTAMP (buffer);
+ if (packet_len > GST_BASE_RTP_PAYLOAD_MTU (rtpmp4venc)) {
+ ret = gst_rtpmp4venc_flush (rtpmp4venc);
}
- ret = GST_FLOW_OK;
-
return ret;
}
+static void
+gst_rtpmp4venc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstRtpMP4VEnc *rtpmp4venc;
+
+ rtpmp4venc = GST_RTP_MP4V_ENC (object);
+
+ switch (prop_id) {
+ case ARG_SEND_CONFIG:
+ rtpmp4venc->send_config = g_value_get_boolean (value);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+gst_rtpmp4venc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstRtpMP4VEnc *rtpmp4venc;
+
+ rtpmp4venc = GST_RTP_MP4V_ENC (object);
+
+ switch (prop_id) {
+ case ARG_SEND_CONFIG:
+ g_value_set_boolean (value, rtpmp4venc->send_config);
+ break;
+ default:
+ break;
+ }
+}
+
gboolean
gst_rtpmp4venc_plugin_init (GstPlugin * plugin)
{
diff --git a/gst/rtp/gstrtpmp4vpay.h b/gst/rtp/gstrtpmp4vpay.h
index 2edd0171..996b9a7b 100644
--- a/gst/rtp/gstrtpmp4vpay.h
+++ b/gst/rtp/gstrtpmp4vpay.h
@@ -50,6 +50,7 @@ struct _GstRtpMP4VEnc
gint rate;
gint profile;
GstBuffer *config;
+ gboolean send_config;
};
struct _GstRtpMP4VEncClass