From b4caf090112fe95dedb0b5a6cf31d2b9d96c9632 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 3 Mar 2014 11:34:00 +0100 Subject: [PATCH] jitterbuffer: fix buffer level with invalid DTS It is possible that the DTS is invalid (when we receive RTP packets from TCP, for example). As a fallback, use the reconstructed PTS value to calculate the buffer level. --- gst/rtpmanager/rtpjitterbuffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gst/rtpmanager/rtpjitterbuffer.c b/gst/rtpmanager/rtpjitterbuffer.c index ef50b4f..1262f7d 100644 --- a/gst/rtpmanager/rtpjitterbuffer.c +++ b/gst/rtpmanager/rtpjitterbuffer.c @@ -253,7 +253,7 @@ get_buffer_level (RTPJitterBuffer * jbuf) /* first first buffer with timestamp */ high_buf = (RTPJitterBufferItem *) g_queue_peek_tail_link (jbuf->packets); while (high_buf) { - if (high_buf->dts != -1) + if (high_buf->dts != -1 || high_buf->pts != -1) break; high_buf = (RTPJitterBufferItem *) g_list_previous (high_buf); @@ -261,7 +261,7 @@ get_buffer_level (RTPJitterBuffer * jbuf) low_buf = (RTPJitterBufferItem *) g_queue_peek_head_link (jbuf->packets); while (low_buf) { - if (low_buf->dts != -1) + if (low_buf->dts != -1 || low_buf->pts != -1) break; low_buf = (RTPJitterBufferItem *) g_list_next (low_buf); @@ -272,8 +272,8 @@ get_buffer_level (RTPJitterBuffer * jbuf) } else { guint64 high_ts, low_ts; - high_ts = high_buf->dts; - low_ts = low_buf->dts; + high_ts = high_buf->dts != -1 ? high_buf->dts : high_buf->pts; + low_ts = low_buf->dts != -1 ? low_buf->dts : low_buf->pts; if (high_ts > low_ts) level = high_ts - low_ts; -- 2.7.4