From e47f4487b40c8b7139887cf66365a2edf033b3ac Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 21 Dec 2010 13:55:40 +0100 Subject: [PATCH] theorapay: clear packet on flush-stop --- gst/rtp/gstrtptheorapay.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/gst/rtp/gstrtptheorapay.c b/gst/rtp/gstrtptheorapay.c index 82651ec..47a1561 100644 --- a/gst/rtp/gstrtptheorapay.c +++ b/gst/rtp/gstrtptheorapay.c @@ -84,6 +84,9 @@ static GstStateChangeReturn gst_rtp_theora_pay_change_state (GstElement * element, GstStateChange transition); static GstFlowReturn gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * pad, GstBuffer * buffer); +static gboolean gst_rtp_theora_pay_handle_event (GstPad * pad, + GstEvent * event); + static void gst_rtp_theora_pay_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -121,6 +124,7 @@ gst_rtp_theora_pay_class_init (GstRtpTheoraPayClass * klass) gstbasertppayload_class->set_caps = gst_rtp_theora_pay_setcaps; gstbasertppayload_class->handle_buffer = gst_rtp_theora_pay_handle_buffer; + gstbasertppayload_class->handle_event = gst_rtp_theora_pay_handle_event; gobject_class->set_property = gst_rtp_theora_pay_set_property; gobject_class->get_property = gst_rtp_theora_pay_get_property; @@ -145,15 +149,21 @@ gst_rtp_theora_pay_init (GstRtpTheoraPay * rtptheorapay, } static void +gst_rtp_theora_pay_clear_packet (GstRtpTheoraPay * rtptheorapay) +{ + if (rtptheorapay->packet) + gst_buffer_unref (rtptheorapay->packet); + rtptheorapay->packet = NULL; +} + +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; + gst_rtp_theora_pay_clear_packet (rtptheorapay); if (rtptheorapay->config_data) g_free (rtptheorapay->config_data); @@ -758,6 +768,22 @@ header_error: } } +static gboolean +gst_rtp_theora_pay_handle_event (GstPad * pad, GstEvent * event) +{ + GstRtpTheoraPay *rtptheorapay = GST_RTP_THEORA_PAY (GST_PAD_PARENT (pad)); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_FLUSH_STOP: + gst_rtp_theora_pay_clear_packet (rtptheorapay); + break; + default: + break; + } + /* false to let parent handle event as well */ + return FALSE; +} + static GstStateChangeReturn gst_rtp_theora_pay_change_state (GstElement * element, GstStateChange transition) -- 2.7.4