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:
Wim Taymans 2009-08-31 12:57:32 +02:00
parent e254936e34
commit 4814d899c2

View file

@ -117,6 +117,24 @@ rtp_jitter_buffer_reset_skew (RTPJitterBuffer * jbuf)
GST_DEBUG ("reset skew correction"); 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 /* 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 * found in http://www.grame.fr/pub/TR-050601.pdf. The idea is that the jitter is
* composed of: * 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 /* elapsed time at sender, timestamps can go backwards and thus be smaller
* than our base time, take a new base time in that case. */ * than our base time, take a new base time in that case. */
GST_WARNING ("backward timestamps at server, taking new base time"); GST_WARNING ("backward timestamps at server, taking new base time");
jbuf->base_time = time; rtp_jitter_buffer_resync (jbuf, time, gstrtptime, ext_rtptime, FALSE);
jbuf->base_rtptime = gstrtptime;
jbuf->base_extrtp = ext_rtptime;
jbuf->prev_out_time = -1;
jbuf->prev_send_diff = -1;
send_diff = 0; send_diff = 0;
} }
@ -257,11 +271,7 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time,
if (ABS (delta - jbuf->skew) > GST_SECOND) { if (ABS (delta - jbuf->skew) > GST_SECOND) {
GST_WARNING ("delta %" GST_TIME_FORMAT " too big, reset skew", GST_WARNING ("delta %" GST_TIME_FORMAT " too big, reset skew",
GST_TIME_ARGS (delta - jbuf->skew)); GST_TIME_ARGS (delta - jbuf->skew));
jbuf->base_time = time; rtp_jitter_buffer_resync (jbuf, time, gstrtptime, ext_rtptime, TRUE);
jbuf->base_rtptime = gstrtptime;
jbuf->base_extrtp = ext_rtptime;
jbuf->prev_out_time = -1;
jbuf->prev_send_diff = -1;
send_diff = 0; send_diff = 0;
delta = 0; delta = 0;
} }