From 4a7cbe84897d94309c860140d70940a9632d969b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 12 Feb 2008 23:38:19 +0000 Subject: fixes: #514889 Original commit message from CVS: patch by: Wim Taymans fixes: #514889 * gst/rtp/gstrtph264pay.c: * gst/rtp/gstrtpmp4gdepay.c: * gst/rtp/gstrtpmp4gpay.c: * gst/rtp/gstrtpmp4gpay.h: * gst/rtp/gstrtptheorapay.c: * gst/rtp/gstrtpvorbispay.c: Fix various leaks shown up in valgrind - free sprops and buffer in error cases in H264 payloader - fix leak in mp4g depayloader when construction the caps - don't leak config string in the mp4g payloader - don't leak buffers and headers in theora and vorbis payloaders * tests/check/elements/rtp-payloading.c: Fix the RTP data test - Actually send valid amr data to the payloader instead of 20 zero-bytes - The mp4g payloader expects codec_data on the caps --- gst/rtp/gstrtpvorbispay.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'gst/rtp/gstrtpvorbispay.c') diff --git a/gst/rtp/gstrtpvorbispay.c b/gst/rtp/gstrtpvorbispay.c index 30f484b2..f9fa15b2 100644 --- a/gst/rtp/gstrtpvorbispay.c +++ b/gst/rtp/gstrtpvorbispay.c @@ -75,6 +75,8 @@ GST_BOILERPLATE (GstRtpVorbisPay, gst_rtp_vorbis_pay, GstBaseRTPPayload, static gboolean gst_rtp_vorbis_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps); +static GstStateChangeReturn gst_rtp_vorbis_pay_change_state (GstElement * + element, GstStateChange transition); static GstFlowReturn gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * pad, GstBuffer * buffer); @@ -104,6 +106,8 @@ gst_rtp_vorbis_pay_class_init (GstRtpVorbisPayClass * klass) parent_class = g_type_class_peek_parent (klass); + gstelement_class->change_state = gst_rtp_vorbis_pay_change_state; + gstbasertppayload_class->set_caps = gst_rtp_vorbis_pay_setcaps; gstbasertppayload_class->handle_buffer = gst_rtp_vorbis_pay_handle_buffer; @@ -118,6 +122,18 @@ gst_rtp_vorbis_pay_init (GstRtpVorbisPay * rtpvorbispay, /* needed because of GST_BOILERPLATE */ } +static void +gst_rtp_vorbis_pay_cleanup (GstRtpVorbisPay * rtpvorbispay) +{ + g_list_foreach (rtpvorbispay->headers, (GFunc) gst_mini_object_unref, NULL); + g_list_free (rtpvorbispay->headers); + rtpvorbispay->headers = NULL; + + if (rtpvorbispay->packet) + gst_buffer_unref (rtpvorbispay->packet); + rtpvorbispay->packet = NULL; +} + static gboolean gst_rtp_vorbis_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps) { @@ -623,6 +639,8 @@ gst_rtp_vorbis_pay_handle_buffer (GstBaseRTPPayload * basepayload, rtpvorbispay->payload_duration += duration; } } + gst_buffer_unref (buffer); + done: return ret; @@ -631,26 +649,56 @@ wrong_size: { GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE, ("Invalid packet size (1 < %d <= 0xffff)", size), (NULL)); + gst_buffer_unref (buffer); return GST_FLOW_OK; } parse_id_failed: { + gst_buffer_unref (buffer); return GST_FLOW_ERROR; } unknown_header: { GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE, (NULL), ("Ignoring unknown header received")); + gst_buffer_unref (buffer); return GST_FLOW_OK; } header_error: { GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE, (NULL), ("Error initializing header config")); + gst_buffer_unref (buffer); return GST_FLOW_OK; } } +static GstStateChangeReturn +gst_rtp_vorbis_pay_change_state (GstElement * element, + GstStateChange transition) +{ + GstRtpVorbisPay *rtpvorbispay; + GstStateChangeReturn ret; + + rtpvorbispay = GST_RTP_VORBIS_PAY (element); + + switch (transition) { + default: + break; + } + + ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + + switch (transition) { + case GST_STATE_CHANGE_PAUSED_TO_READY: + gst_rtp_vorbis_pay_cleanup (rtpvorbispay); + break; + default: + break; + } + return ret; +} + gboolean gst_rtp_vorbis_pay_plugin_init (GstPlugin * plugin) { -- cgit