mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
rtp: fix adapter flushing in sbc payloader
GstAdapter must be flushed in some cases (flush, new segment, state change) Without it, it may, for example, push some leftover buffer from old segment in new segment. This, in general, breaks timestamps. See GstAdapter documentation for more. Signed-off-by: Michal Dzik <michal.dzik@streamunlimited.com> Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/700>
This commit is contained in:
parent
769df2c5d1
commit
680722bbfa
1 changed files with 29 additions and 0 deletions
|
@ -109,6 +109,8 @@ static void gst_rtp_sbc_pay_set_property (GObject * object, guint prop_id,
|
|||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_rtp_sbc_pay_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static GstStateChangeReturn gst_rtp_sbc_pay_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
static gint
|
||||
gst_rtp_sbc_pay_get_frame_len (gint subbands, gint channels,
|
||||
|
@ -280,6 +282,12 @@ gst_rtp_sbc_pay_sink_event (GstRTPBasePayload * payload, GstEvent * event)
|
|||
case GST_EVENT_EOS:
|
||||
gst_rtp_sbc_pay_flush_buffers (sbcpay);
|
||||
break;
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
gst_adapter_clear (sbcpay->adapter);
|
||||
break;
|
||||
case GST_EVENT_SEGMENT:
|
||||
gst_rtp_sbc_pay_flush_buffers (sbcpay);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -287,6 +295,25 @@ gst_rtp_sbc_pay_sink_event (GstRTPBasePayload * payload, GstEvent * event)
|
|||
return GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload, event);
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_rtp_sbc_pay_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
GstRtpSBCPay *sbcpay = GST_RTP_SBC_PAY (element);
|
||||
|
||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
gst_adapter_clear (sbcpay->adapter);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_sbc_pay_finalize (GObject * object)
|
||||
{
|
||||
|
@ -313,6 +340,8 @@ gst_rtp_sbc_pay_class_init (GstRtpSBCPayClass * klass)
|
|||
GST_DEBUG_FUNCPTR (gst_rtp_sbc_pay_handle_buffer);
|
||||
payload_class->sink_event = GST_DEBUG_FUNCPTR (gst_rtp_sbc_pay_sink_event);
|
||||
|
||||
element_class->change_state = gst_rtp_sbc_pay_change_state;
|
||||
|
||||
/* properties */
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
||||
PROP_MIN_FRAMES,
|
||||
|
|
Loading…
Reference in a new issue