theorapay: clear packet on flush-stop

This commit is contained in:
Wim Taymans 2010-12-21 13:55:40 +01:00
parent 2c6e198157
commit e47f4487b4

View file

@ -84,6 +84,9 @@ static GstStateChangeReturn gst_rtp_theora_pay_change_state (GstElement *
element, GstStateChange transition); element, GstStateChange transition);
static GstFlowReturn gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * pad, static GstFlowReturn gst_rtp_theora_pay_handle_buffer (GstBaseRTPPayload * pad,
GstBuffer * buffer); 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, static void gst_rtp_theora_pay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec); 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->set_caps = gst_rtp_theora_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_theora_pay_handle_buffer; 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->set_property = gst_rtp_theora_pay_set_property;
gobject_class->get_property = gst_rtp_theora_pay_get_property; gobject_class->get_property = gst_rtp_theora_pay_get_property;
@ -144,6 +148,14 @@ gst_rtp_theora_pay_init (GstRtpTheoraPay * rtptheorapay,
rtptheorapay->last_config = GST_CLOCK_TIME_NONE; rtptheorapay->last_config = GST_CLOCK_TIME_NONE;
} }
static void
gst_rtp_theora_pay_clear_packet (GstRtpTheoraPay * rtptheorapay)
{
if (rtptheorapay->packet)
gst_buffer_unref (rtptheorapay->packet);
rtptheorapay->packet = NULL;
}
static void static void
gst_rtp_theora_pay_cleanup (GstRtpTheoraPay * rtptheorapay) gst_rtp_theora_pay_cleanup (GstRtpTheoraPay * rtptheorapay)
{ {
@ -151,9 +163,7 @@ gst_rtp_theora_pay_cleanup (GstRtpTheoraPay * rtptheorapay)
g_list_free (rtptheorapay->headers); g_list_free (rtptheorapay->headers);
rtptheorapay->headers = NULL; rtptheorapay->headers = NULL;
if (rtptheorapay->packet) gst_rtp_theora_pay_clear_packet (rtptheorapay);
gst_buffer_unref (rtptheorapay->packet);
rtptheorapay->packet = NULL;
if (rtptheorapay->config_data) if (rtptheorapay->config_data)
g_free (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 static GstStateChangeReturn
gst_rtp_theora_pay_change_state (GstElement * element, gst_rtp_theora_pay_change_state (GstElement * element,
GstStateChange transition) GstStateChange transition)