jitterbuffer: get better buffering level

When the jitterbuffer contains -1 timestamps, make sure we still calculate the
buffer fill level by skipping the -1 buffers.
Try to be more resilient to weird input timestamps.
This commit is contained in:
Wim Taymans 2010-12-20 15:54:45 +01:00
parent 6cb0efede4
commit eb6d552353

View file

@ -212,11 +212,30 @@ rtp_jitter_buffer_resync (RTPJitterBuffer * jbuf, GstClockTime time,
static guint64
get_buffer_level (RTPJitterBuffer * jbuf)
{
GstBuffer *high_buf, *low_buf;
GstBuffer *high_buf = NULL, *low_buf = NULL;
guint64 level;
GList *find;
high_buf = g_queue_peek_head (jbuf->packets);
low_buf = g_queue_peek_tail (jbuf->packets);
/* first first buffer with timestamp */
find = g_queue_peek_head_link (jbuf->packets);
while (find) {
high_buf = find->data;
if (GST_BUFFER_TIMESTAMP (high_buf) != -1)
break;
high_buf = NULL;
find = g_list_next (find);
}
find = g_queue_peek_tail_link (jbuf->packets);
while (find) {
low_buf = find->data;
if (GST_BUFFER_TIMESTAMP (low_buf) != -1)
break;
low_buf = NULL;
find = g_list_previous (find);
}
if (!high_buf || !low_buf || high_buf == low_buf) {
level = 0;
@ -230,6 +249,11 @@ get_buffer_level (RTPJitterBuffer * jbuf)
level = high_ts - low_ts;
else
level = 0;
GST_LOG_OBJECT (jbuf,
"low %" GST_TIME_FORMAT " high %" GST_TIME_FORMAT " level %"
G_GUINT64_FORMAT, GST_TIME_ARGS (low_ts), GST_TIME_ARGS (high_ts),
level);
}
return level;
}
@ -394,6 +418,8 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time,
} else {
GST_WARNING ("backward timestamps at server but no timestamps");
send_diff = 0;
/* at least try to get a new timestamp.. */
jbuf->base_time = -1;
}
GST_DEBUG ("extrtp %" G_GUINT64_FORMAT ", gstrtp %" GST_TIME_FORMAT ", base %"