diff options
author | Thiago Santos <ts.santos@sisa.samsung.com> | 2014-01-31 12:15:49 -0300 |
---|---|---|
committer | Thiago Santos <ts.santos@sisa.samsung.com> | 2014-01-31 23:44:11 -0300 |
commit | a029a3503657c909e144ea527cc8cd7b8b0a9c13 (patch) | |
tree | 012aa037cb8998db6b3e9c0fb95fe4bd45e6b123 /gst/gdp | |
parent | c8eb403e383d4b306fdd24c2bba637c001dd0c1e (diff) | |
download | gstreamer-plugins-bad-a029a3503657c909e144ea527cc8cd7b8b0a9c13.tar.gz |
gdppay: update to 1.x reality
* stream-start-id is mandatory at the beginning, so add that to the
gdp headers
* caps must be sent before new segment, invert the order from legacy
0.10 code
And fix the tests as a ref is now kept for those buffers that compose
the header
Diffstat (limited to 'gst/gdp')
-rw-r--r-- | gst/gdp/gstgdppay.c | 72 | ||||
-rw-r--r-- | gst/gdp/gstgdppay.h | 1 |
2 files changed, 55 insertions, 18 deletions
diff --git a/gst/gdp/gstgdppay.c b/gst/gdp/gstgdppay.c index 4464495b1..d8bc818dc 100644 --- a/gst/gdp/gstgdppay.c +++ b/gst/gdp/gstgdppay.c @@ -200,6 +200,10 @@ gst_gdp_pay_reset (GstGDPPay * this) gst_buffer_unref (this->new_segment_buf); this->new_segment_buf = NULL; } + if (this->streamstartid_buf) { + gst_buffer_unref (this->streamstartid_buf); + this->streamstartid_buf = NULL; + } this->sent_streamheader = FALSE; this->offset = 0; } @@ -312,7 +316,7 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this) { GstCaps *caps; /* We use copies of these to avoid circular refcounts */ - GstBuffer *new_segment_buf, *caps_buf, *tag_buf; + GstBuffer *new_segment_buf, *caps_buf, *tag_buf, *streamstartid_buf; GstStructure *structure; GstFlowReturn r = GST_FLOW_OK; gboolean version_one_zero = TRUE; @@ -326,8 +330,9 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this) version_one_zero = FALSE; if (version_one_zero) { - if (!this->new_segment_buf || !this->caps_buf) { - GST_DEBUG_OBJECT (this, "1.0, missing new_segment or caps, returning"); + if (!this->new_segment_buf || !this->caps_buf || !this->streamstartid_buf) { + GST_DEBUG_OBJECT (this, "1.0, missing new_segment or caps or stream " + "start id, returning"); return GST_FLOW_OK; } } else { @@ -343,6 +348,27 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this) g_value_init (&array, GST_TYPE_ARRAY); if (version_one_zero) { + gst_gdp_stamp_buffer (this, this->streamstartid_buf); + GST_DEBUG_OBJECT (this, "appending copy of stream start id buffer %p", + this->streamstartid_buf); + streamstartid_buf = gst_buffer_copy (this->streamstartid_buf); + g_value_init (&value, GST_TYPE_BUFFER); + gst_value_set_buffer (&value, streamstartid_buf); + gst_value_array_append_value (&array, &value); + g_value_unset (&value); + gst_buffer_unref (streamstartid_buf); + } + + 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); + g_value_init (&value, GST_TYPE_BUFFER); + gst_value_set_buffer (&value, caps_buf); + gst_value_array_append_value (&array, &value); + g_value_unset (&value); + gst_buffer_unref (caps_buf); + + if (version_one_zero) { gst_gdp_stamp_buffer (this, this->new_segment_buf); GST_DEBUG_OBJECT (this, "1.0, appending copy of new segment buffer %p", this->new_segment_buf); @@ -368,15 +394,6 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this) } } - 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); - g_value_init (&value, GST_TYPE_BUFFER); - gst_value_set_buffer (&value, caps_buf); - gst_value_array_append_value (&array, &value); - g_value_unset (&value); - gst_buffer_unref (caps_buf); - /* we also need to add GDP serializations of the streamheaders of the * incoming caps */ structure = gst_caps_get_structure (this->caps, 0); @@ -462,6 +479,20 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this) } /* push out these streamheader buffers, then flush our internal queue */ + GST_DEBUG_OBJECT (this, "Pushing GDP stream-start-id buffer %p", + this->streamstartid_buf); + r = gst_pad_push (this->srcpad, gst_buffer_ref (this->streamstartid_buf)); + if (r != GST_FLOW_OK) { + GST_WARNING_OBJECT (this, "pushing GDP stream-start-id buffer returned %d", + r); + goto done; + } + GST_DEBUG_OBJECT (this, "Pushing GDP caps buffer %p", this->caps_buf); + r = gst_pad_push (this->srcpad, gst_buffer_ref (this->caps_buf)); + if (r != GST_FLOW_OK) { + GST_WARNING_OBJECT (this, "pushing GDP caps buffer returned %d", r); + goto done; + } GST_DEBUG_OBJECT (this, "Pushing GDP new_segment buffer %p with offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT, this->new_segment_buf, GST_BUFFER_OFFSET (this->new_segment_buf), @@ -481,12 +512,6 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this) goto done; } } - GST_DEBUG_OBJECT (this, "Pushing GDP caps buffer %p", this->caps_buf); - r = gst_pad_push (this->srcpad, gst_buffer_ref (this->caps_buf)); - if (r != GST_FLOW_OK) { - GST_WARNING_OBJECT (this, "pushing GDP caps buffer returned %d", r); - goto done; - } this->sent_streamheader = TRUE; GST_DEBUG_OBJECT (this, "need to push %d queued buffers", g_list_length (this->queue)); @@ -663,6 +688,17 @@ gst_gdp_pay_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) /* if we got a new segment or tag event, we should put it on our streamheader, * and not send it on */ switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_STREAM_START: + GST_DEBUG_OBJECT (this, "Storing stream start id in buffer %p", + outbuffer); + + if (this->streamstartid_buf) + gst_buffer_unref (this->streamstartid_buf); + this->streamstartid_buf = outbuffer; + + GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_HEADER); + gst_gdp_pay_reset_streamheader (this); + break; case GST_EVENT_SEGMENT: GST_DEBUG_OBJECT (this, "Storing in caps buffer %p as new_segment_buf", outbuffer); diff --git a/gst/gdp/gstgdppay.h b/gst/gdp/gstgdppay.h index 2ecd12449..d4433ef77 100644 --- a/gst/gdp/gstgdppay.h +++ b/gst/gdp/gstgdppay.h @@ -52,6 +52,7 @@ struct _GstGDPPay GstCaps *caps; /* incoming caps */ + GstBuffer *streamstartid_buf; GstBuffer *caps_buf; GstBuffer *new_segment_buf; GstBuffer *tag_buf; |