diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2008-02-12 23:38:19 +0000 |
---|---|---|
committer | Jan Schmidt <thaytan@mad.scientist.com> | 2008-02-12 23:38:19 +0000 |
commit | 4a7cbe84897d94309c860140d70940a9632d969b (patch) | |
tree | fecb57e4a8ab5d48d7a2be27306da169fd9df452 /gst/rtp/gstrtptheorapay.c | |
parent | 4bb12df00792f09185b7e12704f045ee4ee653f9 (diff) |
fixes: #514889
Original commit message from CVS:
patch by: Wim Taymans <wim.taymans@collabora.co.uk>
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
Diffstat (limited to 'gst/rtp/gstrtptheorapay.c')
-rw-r--r-- | gst/rtp/gstrtptheorapay.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gst/rtp/gstrtptheorapay.c b/gst/rtp/gstrtptheorapay.c index a6c22d9d..23485caa 100644 --- a/gst/rtp/gstrtptheorapay.c +++ b/gst/rtp/gstrtptheorapay.c @@ -79,6 +79,8 @@ GST_BOILERPLATE (GstRtpTheoraPay, gst_rtp_theora_pay, GstBaseRTPPayload, static gboolean gst_rtp_theora_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps); +static GstStateChangeReturn gst_rtp_theora_pay_change_state (GstElement * + element, GstStateChange transition); static GstFlowReturn gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * pad, GstBuffer * buffer); @@ -108,6 +110,8 @@ gst_rtp_theora_pay_class_init (GstRtpTheoraPayClass * klass) parent_class = g_type_class_peek_parent (klass); + gstelement_class->change_state = gst_rtp_theora_pay_change_state; + gstbasertppayload_class->set_caps = gst_rtp_theora_pay_setcaps; gstbasertppayload_class->handle_buffer = gst_rtp_theora_pay_handle_buffer; @@ -122,6 +126,18 @@ gst_rtp_theora_pay_init (GstRtpTheoraPay * rtptheorapay, /* needed because of GST_BOILERPLATE */ } +static void +gst_rtp_theora_pay_cleanup (GstRtpTheoraPay * rtptheorapay) +{ + g_list_foreach (rtptheorapay->headers, (GFunc) gst_mini_object_unref, NULL); + g_list_free (rtptheorapay->headers); + rtptheorapay->headers = NULL; + + if (rtptheorapay->packet) + gst_buffer_unref (rtptheorapay->packet); + rtptheorapay->packet = NULL; +} + static gboolean gst_rtp_theora_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps) { @@ -624,6 +640,8 @@ gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * basepayload, rtptheorapay->payload_duration += duration; } } + gst_buffer_unref (buffer); + done: return ret; @@ -632,26 +650,56 @@ wrong_size: { GST_ELEMENT_WARNING (rtptheorapay, 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 (rtptheorapay, STREAM, DECODE, (NULL), ("Ignoring unknown header received")); + gst_buffer_unref (buffer); return GST_FLOW_OK; } header_error: { GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE, (NULL), ("Error initializing header config")); + gst_buffer_unref (buffer); return GST_FLOW_OK; } } +static GstStateChangeReturn +gst_rtp_theora_pay_change_state (GstElement * element, + GstStateChange transition) +{ + GstRtpTheoraPay *rtptheorapay; + GstStateChangeReturn ret; + + rtptheorapay = GST_RTP_THEORA_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_theora_pay_cleanup (rtptheorapay); + break; + default: + break; + } + return ret; +} + gboolean gst_rtp_theora_pay_plugin_init (GstPlugin * plugin) { |