mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
jitterbuffer: reset skew when timestamps change
Refactor the jitterbuffer resync code. Reset the skew correction when we detect a big timestamp discont. See #593354
This commit is contained in:
parent
e254936e34
commit
4814d899c2
1 changed files with 20 additions and 10 deletions
|
@ -117,6 +117,24 @@ rtp_jitter_buffer_reset_skew (RTPJitterBuffer * jbuf)
|
|||
GST_DEBUG ("reset skew correction");
|
||||
}
|
||||
|
||||
static void
|
||||
rtp_jitter_buffer_resync (RTPJitterBuffer * jbuf, GstClockTime time,
|
||||
GstClockTime gstrtptime, guint64 ext_rtptime, gboolean reset_skew)
|
||||
{
|
||||
jbuf->base_time = time;
|
||||
jbuf->base_rtptime = gstrtptime;
|
||||
jbuf->base_extrtp = ext_rtptime;
|
||||
jbuf->prev_out_time = -1;
|
||||
jbuf->prev_send_diff = -1;
|
||||
if (reset_skew) {
|
||||
jbuf->window_filling = TRUE;
|
||||
jbuf->window_pos = 0;
|
||||
jbuf->window_min = 0;
|
||||
jbuf->window_size = 0;
|
||||
jbuf->skew = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* For the clock skew we use a windowed low point averaging algorithm as can be
|
||||
* found in http://www.grame.fr/pub/TR-050601.pdf. The idea is that the jitter is
|
||||
* composed of:
|
||||
|
@ -223,11 +241,7 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time,
|
|||
/* elapsed time at sender, timestamps can go backwards and thus be smaller
|
||||
* than our base time, take a new base time in that case. */
|
||||
GST_WARNING ("backward timestamps at server, taking new base time");
|
||||
jbuf->base_time = time;
|
||||
jbuf->base_rtptime = gstrtptime;
|
||||
jbuf->base_extrtp = ext_rtptime;
|
||||
jbuf->prev_out_time = -1;
|
||||
jbuf->prev_send_diff = -1;
|
||||
rtp_jitter_buffer_resync (jbuf, time, gstrtptime, ext_rtptime, FALSE);
|
||||
send_diff = 0;
|
||||
}
|
||||
|
||||
|
@ -257,11 +271,7 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time,
|
|||
if (ABS (delta - jbuf->skew) > GST_SECOND) {
|
||||
GST_WARNING ("delta %" GST_TIME_FORMAT " too big, reset skew",
|
||||
GST_TIME_ARGS (delta - jbuf->skew));
|
||||
jbuf->base_time = time;
|
||||
jbuf->base_rtptime = gstrtptime;
|
||||
jbuf->base_extrtp = ext_rtptime;
|
||||
jbuf->prev_out_time = -1;
|
||||
jbuf->prev_send_diff = -1;
|
||||
rtp_jitter_buffer_resync (jbuf, time, gstrtptime, ext_rtptime, TRUE);
|
||||
send_diff = 0;
|
||||
delta = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue