Commit 76792a5c authored by Andrew S's avatar Andrew S Committed by Sebastian Dröge

rtpjitterbuffer: Don't always reset PTS to 0 after a gap

In function rtp_jitter_buffer_calculate_pts: If gap in incoming RTP
timestamps is more than (3 * jbuf->clock_rate) we call
rtp_jitter_buffer_reset_skew which resets pts to 0. So components down
the pipeline (playes, mixers) just skip frames/samples until pts becomes
equal to pts before gap.

In version 1.10.2 and before this checking was bypassed for packets with
"estimated dts", and gaps were handled correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=778341
parent 16941255
......@@ -2929,8 +2929,9 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
GST_DEBUG_OBJECT (jitterbuffer, "First buffer #%d", seqnum);
/* calculate a pts based on rtptime and arrival time (dts) */
pts = rtp_jitter_buffer_calculate_pts (priv->jbuf, dts, rtptime,
gst_element_get_base_time (GST_ELEMENT_CAST (jitterbuffer)));
pts =
rtp_jitter_buffer_calculate_pts (priv->jbuf, dts, estimated_dts,
rtptime, gst_element_get_base_time (GST_ELEMENT_CAST (jitterbuffer)));
/* we don't know what the next_in_seqnum should be, wait for the last
* possible moment to push this buffer, maybe we get an earlier seqnum
......@@ -2981,8 +2982,10 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
g_queue_clear (&priv->gap_packets);
/* calculate a pts based on rtptime and arrival time (dts) */
pts = rtp_jitter_buffer_calculate_pts (priv->jbuf, dts, rtptime,
gst_element_get_base_time (GST_ELEMENT_CAST (jitterbuffer)));
/* If we estimated the DTS, don't consider it in the clock skew calculations */
pts =
rtp_jitter_buffer_calculate_pts (priv->jbuf, dts, estimated_dts,
rtptime, gst_element_get_base_time (GST_ELEMENT_CAST (jitterbuffer)));
if (G_LIKELY (gap == 0)) {
/* packet is expected */
......
......@@ -690,7 +690,7 @@ queue_do_insert (RTPJitterBuffer * jbuf, GList * list, GList * item)
GstClockTime
rtp_jitter_buffer_calculate_pts (RTPJitterBuffer * jbuf, GstClockTime dts,
guint32 rtptime, GstClockTime base_time)
gboolean estimated_dts, guint32 rtptime, GstClockTime base_time)
{
guint64 ext_rtptime;
GstClockTime gstrtptime, pts;
......@@ -703,7 +703,7 @@ rtp_jitter_buffer_calculate_pts (RTPJitterBuffer * jbuf, GstClockTime dts,
* Only reset if valid input time, which is likely for UDP input
* where we expect this might happen due to async thread effects
* (in seek and state change cycles), but not so much for TCP input */
if (GST_CLOCK_TIME_IS_VALID (dts) &&
if (GST_CLOCK_TIME_IS_VALID (dts) && !estimated_dts &&
jbuf->mode != RTP_JITTER_BUFFER_MODE_SLAVE &&
jbuf->base_time != -1 && jbuf->last_rtptime != -1) {
GstClockTime ext_rtptime = jbuf->ext_rtptime;
......
......@@ -189,7 +189,7 @@ void rtp_jitter_buffer_get_sync (RTPJitterBuffer *jbuf,
guint64 *timestamp, guint32 *clock_rate,
guint64 *last_rtptime);
GstClockTime rtp_jitter_buffer_calculate_pts (RTPJitterBuffer * jbuf, GstClockTime dts,
GstClockTime rtp_jitter_buffer_calculate_pts (RTPJitterBuffer * jbuf, GstClockTime dts, gboolean estimated_dts,
guint32 rtptime, GstClockTime base_time);
#endif /* __RTP_JITTER_BUFFER_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment