mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
mp4gpay: reset state on flush-stop
This commit is contained in:
parent
1dd71cc63f
commit
e13340ccb5
1 changed files with 48 additions and 3 deletions
|
@ -82,6 +82,7 @@ static gboolean gst_rtp_mp4g_pay_setcaps (GstBaseRTPPayload * payload,
|
|||
GstCaps * caps);
|
||||
static GstFlowReturn gst_rtp_mp4g_pay_handle_buffer (GstBaseRTPPayload *
|
||||
payload, GstBuffer * buffer);
|
||||
static gboolean gst_rtp_mp4g_pay_handle_event (GstPad * pad, GstEvent * event);
|
||||
|
||||
GST_BOILERPLATE (GstRtpMP4GPay, gst_rtp_mp4g_pay, GstBaseRTPPayload,
|
||||
GST_TYPE_BASE_RTP_PAYLOAD)
|
||||
|
@ -118,6 +119,7 @@ gst_rtp_mp4g_pay_class_init (GstRtpMP4GPayClass * klass)
|
|||
|
||||
gstbasertppayload_class->set_caps = gst_rtp_mp4g_pay_setcaps;
|
||||
gstbasertppayload_class->handle_buffer = gst_rtp_mp4g_pay_handle_buffer;
|
||||
gstbasertppayload_class->handle_event = gst_rtp_mp4g_pay_handle_event;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpmp4gpay_debug, "rtpmp4gpay", 0,
|
||||
"MP4-generic RTP Payloader");
|
||||
|
@ -135,6 +137,13 @@ gst_rtp_mp4g_pay_reset (GstRtpMP4GPay * rtpmp4gpay)
|
|||
GST_DEBUG_OBJECT (rtpmp4gpay, "reset");
|
||||
|
||||
gst_adapter_clear (rtpmp4gpay->adapter);
|
||||
rtpmp4gpay->offset = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_mp4g_pay_cleanup (GstRtpMP4GPay * rtpmp4gpay)
|
||||
{
|
||||
gst_rtp_mp4g_pay_reset (rtpmp4gpay);
|
||||
|
||||
g_free (rtpmp4gpay->params);
|
||||
rtpmp4gpay->params = NULL;
|
||||
|
@ -150,7 +159,6 @@ gst_rtp_mp4g_pay_reset (GstRtpMP4GPay * rtpmp4gpay)
|
|||
rtpmp4gpay->mode = NULL;
|
||||
|
||||
rtpmp4gpay->frame_len = 0;
|
||||
rtpmp4gpay->offset = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -160,7 +168,7 @@ gst_rtp_mp4g_pay_finalize (GObject * object)
|
|||
|
||||
rtpmp4gpay = GST_RTP_MP4G_PAY (object);
|
||||
|
||||
gst_rtp_mp4g_pay_reset (rtpmp4gpay);
|
||||
gst_rtp_mp4g_pay_cleanup (rtpmp4gpay);
|
||||
|
||||
g_object_unref (rtpmp4gpay->adapter);
|
||||
rtpmp4gpay->adapter = NULL;
|
||||
|
@ -561,6 +569,35 @@ gst_rtp_mp4g_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
|||
return gst_rtp_mp4g_pay_flush (rtpmp4gpay);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_mp4g_pay_handle_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
GstRtpMP4GPay *rtpmp4gpay;
|
||||
|
||||
rtpmp4gpay = GST_RTP_MP4G_PAY (gst_pad_get_parent (pad));
|
||||
|
||||
GST_DEBUG ("Got event: %s", GST_EVENT_TYPE_NAME (event));
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_NEWSEGMENT:
|
||||
case GST_EVENT_EOS:
|
||||
/* This flush call makes sure that the last buffer is always pushed
|
||||
* to the base payloader */
|
||||
gst_rtp_mp4g_pay_flush (rtpmp4gpay);
|
||||
break;
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
gst_rtp_mp4g_pay_reset (rtpmp4gpay);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
g_object_unref (rtpmp4gpay);
|
||||
|
||||
/* let parent handle event too */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_rtp_mp4g_pay_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
|
@ -571,7 +608,7 @@ gst_rtp_mp4g_pay_change_state (GstElement * element, GstStateChange transition)
|
|||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
gst_rtp_mp4g_pay_reset (rtpmp4gpay);
|
||||
gst_rtp_mp4g_pay_cleanup (rtpmp4gpay);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -579,6 +616,14 @@ gst_rtp_mp4g_pay_change_state (GstElement * element, GstStateChange transition)
|
|||
|
||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
gst_rtp_mp4g_pay_cleanup (rtpmp4gpay);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue