summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2010-12-20 15:54:45 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2010-12-20 15:54:45 +0100
commitec05a7895fc93a29bd98dbbb4098b808aab55fb2 (patch)
tree26deadeef8d5e9bfb5097f84339cadc3b9faf01a
parenta5c1a25041bc190c8daefcfaf104618062910c36 (diff)
jitterbuffer: get better buffering leveloblong
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.
-rw-r--r--gst/rtpmanager/rtpjitterbuffer.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/gst/rtpmanager/rtpjitterbuffer.c b/gst/rtpmanager/rtpjitterbuffer.c
index 2dee30c07..59307df35 100644
--- a/gst/rtpmanager/rtpjitterbuffer.c
+++ b/gst/rtpmanager/rtpjitterbuffer.c
@@ -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 %"