From 933a17089853681d5316f56d82c37b06dd5139d0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 20 Dec 2010 16:51:47 +0100 Subject: [PATCH] mpapay: reset payloader on state change --- gst/rtp/gstrtpmpapay.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gst/rtp/gstrtpmpapay.c b/gst/rtp/gstrtpmpapay.c index ed0200391f..23efb670f6 100644 --- a/gst/rtp/gstrtpmpapay.c +++ b/gst/rtp/gstrtpmpapay.c @@ -50,6 +50,9 @@ static GstStaticPadTemplate gst_rtp_mpa_pay_src_template = static void gst_rtp_mpa_pay_finalize (GObject * object); +static GstStateChangeReturn gst_rtp_mpa_pay_change_state (GstElement * element, + GstStateChange transition); + static gboolean gst_rtp_mpa_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps); static gboolean gst_rtp_mpa_pay_handle_event (GstPad * pad, GstEvent * event); @@ -78,13 +81,17 @@ static void gst_rtp_mpa_pay_class_init (GstRtpMPAPayClass * klass) { GObjectClass *gobject_class; + GstElementClass *gstelement_class; GstBaseRTPPayloadClass *gstbasertppayload_class; gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass; gobject_class->finalize = gst_rtp_mpa_pay_finalize; + gstelement_class->change_state = gst_rtp_mpa_pay_change_state; + gstbasertppayload_class->set_caps = gst_rtp_mpa_pay_setcaps; gstbasertppayload_class->handle_event = gst_rtp_mpa_pay_handle_event; gstbasertppayload_class->handle_buffer = gst_rtp_mpa_pay_handle_buffer; @@ -273,6 +280,34 @@ gst_rtp_mpa_pay_handle_buffer (GstBaseRTPPayload * basepayload, return ret; } +static GstStateChangeReturn +gst_rtp_mpa_pay_change_state (GstElement * element, GstStateChange transition) +{ + GstRtpMPAPay *rtpmpapay; + GstStateChangeReturn ret; + + rtpmpapay = GST_RTP_MPA_PAY (element); + + switch (transition) { + case GST_STATE_CHANGE_READY_TO_PAUSED: + gst_rtp_mpa_pay_reset (rtpmpapay); + break; + default: + break; + } + + ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + + switch (transition) { + case GST_STATE_CHANGE_PAUSED_TO_READY: + gst_rtp_mpa_pay_reset (rtpmpapay); + break; + default: + break; + } + return ret; +} + gboolean gst_rtp_mpa_pay_plugin_init (GstPlugin * plugin) {