summaryrefslogtreecommitdiffstats
path: root/gst/rtpmanager/rtpjitterbuffer.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-09-26 20:08:28 +0000
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2009-08-11 02:30:30 +0100
commitfa00695a390e507a049bca04446ed65c69c6641b (patch)
tree0fec9e4ba9479aa3002d621ba1b10bbadf40cf3b /gst/rtpmanager/rtpjitterbuffer.c
parent949f1685ce1c3ddf04873825f1bdc1c0bb7f284e (diff)
gst/rtpmanager/gstrtpbin.c: Fix cleanup crasher.
Original commit message from CVS: * gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_dispose), (gst_rtp_bin_finalize): Fix cleanup crasher. * gst/rtpmanager/rtpjitterbuffer.c: (rtp_jitter_buffer_init), (calculate_skew): * gst/rtpmanager/rtpjitterbuffer.h: Dynamically adjust the skew calculation window so that we calculate it over a period of around 2 seconds.
Diffstat (limited to 'gst/rtpmanager/rtpjitterbuffer.c')
-rw-r--r--gst/rtpmanager/rtpjitterbuffer.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/gst/rtpmanager/rtpjitterbuffer.c b/gst/rtpmanager/rtpjitterbuffer.c
index 7260e9ee..3285c879 100644
--- a/gst/rtpmanager/rtpjitterbuffer.c
+++ b/gst/rtpmanager/rtpjitterbuffer.c
@@ -72,6 +72,7 @@ rtp_jitter_buffer_init (RTPJitterBuffer * jbuf)
jbuf->window[i] = 0;
}
jbuf->window_pos = 0;
+ jbuf->window_size = 100;
jbuf->window_filling = TRUE;
jbuf->window_min = 0;
jbuf->skew = 0;
@@ -217,21 +218,26 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time)
if (jbuf->window_filling) {
/* we are filling the window */
- GST_DEBUG ("filling %d %" G_GINT64_FORMAT, pos, delta);
+ GST_DEBUG ("filling %d %" G_GINT64_FORMAT ", diff %" G_GUINT64_FORMAT, pos,
+ delta, send_diff);
jbuf->window[pos++] = delta;
/* calc the min delta we observed */
if (pos == 1 || delta < jbuf->window_min)
jbuf->window_min = delta;
- if (pos >= 100) {
+ if (send_diff >= 2 * GST_SECOND || pos >= 100) {
+ jbuf->window_size = pos;
+
/* window filled, fill window with min */
GST_DEBUG ("min %" G_GINT64_FORMAT, jbuf->window_min);
- for (i = 0; i < 100; i++)
+ for (i = 0; i < jbuf->window_size; i++)
jbuf->window[i] = jbuf->window_min;
/* the skew is initially the min */
jbuf->skew = jbuf->window_min;
jbuf->window_filling = FALSE;
+ } else {
+ jbuf->window_size = pos + 1;
}
} else {
/* pick old value and store new value. We keep the previous value in order
@@ -247,7 +253,7 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time)
gint64 min = G_MAXINT64;
/* if we removed the old min, we have to find a new min */
- for (i = 0; i < 100; i++) {
+ for (i = 0; i < jbuf->window_size; i++) {
/* we found another value equal to the old min, we can stop searching now */
if (jbuf->window[i] == old) {
min = old;
@@ -264,7 +270,7 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time)
jbuf->window_min, jbuf->skew);
}
/* wrap around in the window */
- if (pos >= 100)
+ if (pos >= jbuf->window_size)
pos = 0;
jbuf->window_pos = pos;
}