gst_plugins_base/gst/gdp/gstgdppay.c
changeset 16 8e837d1bf446
parent 0 0e761a78d257
child 30 7e817e7e631c
--- a/gst_plugins_base/gst/gdp/gstgdppay.c	Wed Mar 24 17:58:42 2010 -0500
+++ b/gst_plugins_base/gst/gdp/gstgdppay.c	Wed Mar 24 18:04:17 2010 -0500
@@ -21,18 +21,14 @@
  * SECTION:element-gdppay
  * @see_also: gdpdepay
  *
- * <refsect2>
- * <para>
  * This element payloads GStreamer buffers and events using the
  * GStreamer Data Protocol.
- * </para>
- * <para>
- * <programlisting>
+ *
+ * <refsect2>
+ * |[
  * gst-launch -v -m videotestsrc num-buffers=50 ! gdppay ! filesink location=test.gdp
- * </programlisting>
- * This pipeline creates a serialized video stream that can be played back
+ * ]| This pipeline creates a serialized video stream that can be played back
  * with the example shown in gdpdepay.
- * </para>
  * </refsect2>
  */
 
@@ -86,9 +82,11 @@
     GST_TYPE_ELEMENT, _do_init);
 
 static void gst_gdp_pay_reset (GstGDPPay * this);
+
 static GstFlowReturn gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer);
 
 static gboolean gst_gdp_pay_src_event (GstPad * pad, GstEvent * event);
+
 static gboolean gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event);
 
 static GstStateChangeReturn gst_gdp_pay_change_state (GstElement *
@@ -118,6 +116,7 @@
 gst_gdp_pay_class_init (GstGDPPayClass * klass)
 {
   GObjectClass *gobject_class;
+
   GstElementClass *gstelement_class;
 
   gobject_class = (GObjectClass *) klass;
@@ -130,15 +129,16 @@
   g_object_class_install_property (gobject_class, PROP_CRC_HEADER,
       g_param_spec_boolean ("crc-header", "CRC Header",
           "Calculate and store a CRC checksum on the header",
-          DEFAULT_CRC_HEADER, G_PARAM_READWRITE));
+          DEFAULT_CRC_HEADER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_class, PROP_CRC_PAYLOAD,
       g_param_spec_boolean ("crc-payload", "CRC Payload",
           "Calculate and store a CRC checksum on the payload",
-          DEFAULT_CRC_PAYLOAD, G_PARAM_READWRITE));
+          DEFAULT_CRC_PAYLOAD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   g_object_class_install_property (gobject_class, PROP_VERSION,
       g_param_spec_enum ("version", "Version",
           "Version of the GStreamer Data Protocol",
-          GST_TYPE_DP_VERSION, DEFAULT_VERSION, G_PARAM_READWRITE));
+          GST_TYPE_DP_VERSION, DEFAULT_VERSION,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_gdp_pay_change_state);
 }
@@ -189,10 +189,11 @@
     GstBuffer *buffer;
 
     buffer = GST_BUFFER_CAST (this->queue->data);
-    GST_DEBUG_OBJECT (this, "Pushing queued GDP buffer %p", buffer);
 
     /* delete buffer from queue now */
     this->queue = g_list_delete_link (this->queue, this->queue);
+
+    gst_buffer_unref (buffer);
   }
   if (this->caps) {
     gst_caps_unref (this->caps);
@@ -227,8 +228,11 @@
 gst_gdp_buffer_from_caps (GstGDPPay * this, GstCaps * caps)
 {
   GstBuffer *headerbuf;
+
   GstBuffer *payloadbuf;
+
   guint8 *header, *payload;
+
   guint len;
 
   if (!this->packetizer->packet_from_caps (caps, this->header_flag, &len,
@@ -259,7 +263,9 @@
 gst_gdp_pay_buffer_from_buffer (GstGDPPay * this, GstBuffer * buffer)
 {
   GstBuffer *headerbuf;
+
   guint8 *header;
+
   guint len;
 
   if (!this->packetizer->header_from_buffer (buffer, this->header_flag, &len,
@@ -288,9 +294,13 @@
 gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
 {
   GstBuffer *headerbuf;
+
   GstBuffer *payloadbuf;
+
   guint8 *header, *payload;
+
   guint len;
+
   gboolean ret;
 
   ret =
@@ -330,8 +340,11 @@
 
   /* We use copies of these to avoid circular refcounts */
   GstBuffer *new_segment_buf, *caps_buf, *tag_buf;
+
   GstStructure *structure;
+
   GstFlowReturn r = GST_FLOW_OK;
+
   gboolean version_one_zero = TRUE;
 
   GValue array = { 0 };
@@ -364,6 +377,7 @@
     GST_DEBUG_OBJECT (this, "1.0, appending copy of new segment buffer %p",
         this->new_segment_buf);
     new_segment_buf = gst_buffer_copy (this->new_segment_buf);
+    gst_buffer_set_caps (new_segment_buf, NULL);
     g_value_init (&value, GST_TYPE_BUFFER);
     gst_value_set_buffer (&value, new_segment_buf);
     gst_value_array_append_value (&array, &value);
@@ -375,6 +389,7 @@
       GST_DEBUG_OBJECT (this, "1.0, appending copy of tag buffer %p",
           this->tag_buf);
       tag_buf = gst_buffer_copy (this->tag_buf);
+      gst_buffer_set_caps (tag_buf, NULL);
       g_value_init (&value, GST_TYPE_BUFFER);
       gst_value_set_buffer (&value, tag_buf);
       gst_value_array_append_value (&array, &value);
@@ -386,6 +401,7 @@
   gst_gdp_stamp_buffer (this, this->caps_buf);
   GST_DEBUG_OBJECT (this, "appending copy of caps buffer %p", this->caps_buf);
   caps_buf = gst_buffer_copy (this->caps_buf);
+  gst_buffer_set_caps (caps_buf, NULL);
   g_value_init (&value, GST_TYPE_BUFFER);
   gst_value_set_buffer (&value, caps_buf);
   gst_value_array_append_value (&array, &value);
@@ -397,8 +413,11 @@
   structure = gst_caps_get_structure (this->caps, 0);
   if (gst_structure_has_field (structure, "streamheader")) {
     const GValue *sh;
+
     GArray *buffers;
+
     GstBuffer *buffer;
+
     int i;
 
     sh = gst_structure_get_value (structure, "streamheader");
@@ -408,6 +427,7 @@
         buffers->len);
     for (i = 0; i < buffers->len; ++i) {
       GValue *bufval;
+
       GstBuffer *outbuffer;
 
       bufval = &g_array_index (buffers, GValue, i);
@@ -466,6 +486,7 @@
     goto done;
   }
   if (this->tag_buf) {
+    gst_buffer_set_caps (this->tag_buf, caps);
     GST_DEBUG_OBJECT (this, "Pushing GDP tag buffer %p", this->tag_buf);
     /* we stored these bufs with refcount 1, so make sure we keep a ref */
     r = gst_pad_push (this->srcpad, gst_buffer_ref (this->tag_buf));
@@ -523,6 +544,7 @@
   if (this->sent_streamheader) {
     GST_LOG_OBJECT (this, "Pushing GDP buffer %p, caps %" GST_PTR_FORMAT,
         buffer, this->caps);
+    gst_buffer_set_caps (buffer, GST_PAD_CAPS (this->srcpad));
     return gst_pad_push (this->srcpad, buffer);
   }
 
@@ -539,8 +561,11 @@
 gst_gdp_pay_chain (GstPad * pad, GstBuffer * buffer)
 {
   GstGDPPay *this;
+
   GstCaps *caps;
+
   GstBuffer *outbuffer;
+
   GstFlowReturn ret;
 
   this = GST_GDP_PAY (gst_pad_get_parent (pad));
@@ -586,6 +611,9 @@
     GST_BUFFER_TIMESTAMP (outbuffer) = GST_BUFFER_TIMESTAMP (buffer);
     GST_BUFFER_DURATION (outbuffer) = 0;
     GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS);
+
+    if (this->caps_buf)
+      gst_buffer_unref (this->caps_buf);
     this->caps_buf = outbuffer;
     gst_gdp_pay_reset_streamheader (this);
   }
@@ -652,8 +680,11 @@
 gst_gdp_pay_sink_event (GstPad * pad, GstEvent * event)
 {
   GstBuffer *outbuffer;
+
   GstGDPPay *this = GST_GDP_PAY (gst_pad_get_parent (pad));
+
   GstFlowReturn flowret;
+
   gboolean ret = TRUE;
 
   GST_DEBUG_OBJECT (this, "received event %p of type %s (%d)",
@@ -735,6 +766,7 @@
 gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
 {
   GstGDPPay *this;
+
   gboolean res = TRUE;
 
   this = GST_GDP_PAY (gst_pad_get_parent (pad));
@@ -815,6 +847,7 @@
 gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
 {
   GstStateChangeReturn ret;
+
   GstGDPPay *this = GST_GDP_PAY (element);
 
   switch (transition) {