summaryrefslogtreecommitdiffstats
path: root/gst/rtp/gstrtpvorbispay.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2008-02-12 23:38:19 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2008-02-12 23:38:19 +0000
commit4a7cbe84897d94309c860140d70940a9632d969b (patch)
treefecb57e4a8ab5d48d7a2be27306da169fd9df452 /gst/rtp/gstrtpvorbispay.c
parent4bb12df00792f09185b7e12704f045ee4ee653f9 (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/gstrtpvorbispay.c')
-rw-r--r--gst/rtp/gstrtpvorbispay.c48
1 files changed, 48 insertions, 0 deletions
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)
{