gst/gdp/gstgdppay.c: Don't set caps on the buffers that contain a copy of the buffer including the caps of them resul...

Original commit message from CVS:
Patch by: Antoine Tremblay <hexa00 at gmail dot com>
* gst/gdp/gstgdppay.c: (gst_gdp_pay_reset_streamheader):
Don't set caps on the buffers that contain a copy of the buffer
including the caps of them resulting in an always increasing refcount
of the caps and insanely large caps. Instead include a buffer without
caps in the new caps. Fixes bug #536475.
This commit is contained in:
Antoine Tremblay 2008-06-04 05:58:38 +00:00 committed by Tim-Philipp Müller
parent c5520eea2a
commit ba89323790

View file

@ -86,9 +86,11 @@ GST_BOILERPLATE_FULL (GstGDPPay, gst_gdp_pay, GstElement,
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 +120,7 @@ static void
gst_gdp_pay_class_init (GstGDPPayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
@ -228,8 +231,11 @@ static GstBuffer *
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,
@ -260,7 +266,9 @@ static GstBuffer *
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,
@ -289,9 +297,13 @@ static GstBuffer *
gst_gdp_buffer_from_event (GstGDPPay * this, GstEvent * event)
{
GstBuffer *headerbuf;
GstBuffer *payloadbuf;
guint8 *header, *payload;
guint len;
gboolean ret;
ret =
@ -331,8 +343,11 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
/* 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 };
@ -365,6 +380,7 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
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);
@ -376,6 +392,7 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
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);
@ -387,6 +404,7 @@ 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);
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);
@ -398,8 +416,11 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
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");
@ -409,6 +430,7 @@ gst_gdp_pay_reset_streamheader (GstGDPPay * this)
buffers->len);
for (i = 0; i < buffers->len; ++i) {
GValue *bufval;
GstBuffer *outbuffer;
bufval = &g_array_index (buffers, GValue, i);
@ -540,8 +562,11 @@ static GstFlowReturn
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));
@ -656,8 +681,11 @@ static gboolean
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)",
@ -739,6 +767,7 @@ static gboolean
gst_gdp_pay_src_event (GstPad * pad, GstEvent * event)
{
GstGDPPay *this;
gboolean res = TRUE;
this = GST_GDP_PAY (gst_pad_get_parent (pad));
@ -819,6 +848,7 @@ static GstStateChangeReturn
gst_gdp_pay_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
GstGDPPay *this = GST_GDP_PAY (element);
switch (transition) {