mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 05:16:05 +00:00
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:
parent
6cb0efede4
commit
eb6d552353
1 changed files with 29 additions and 3 deletions
|
@ -212,11 +212,30 @@ rtp_jitter_buffer_resync (RTPJitterBuffer * jbuf, GstClockTime time,
|
||||||
static guint64
|
static guint64
|
||||||
get_buffer_level (RTPJitterBuffer * jbuf)
|
get_buffer_level (RTPJitterBuffer * jbuf)
|
||||||
{
|
{
|
||||||
GstBuffer *high_buf, *low_buf;
|
GstBuffer *high_buf = NULL, *low_buf = NULL;
|
||||||
guint64 level;
|
guint64 level;
|
||||||
|
GList *find;
|
||||||
|
|
||||||
high_buf = g_queue_peek_head (jbuf->packets);
|
/* first first buffer with timestamp */
|
||||||
low_buf = g_queue_peek_tail (jbuf->packets);
|
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) {
|
if (!high_buf || !low_buf || high_buf == low_buf) {
|
||||||
level = 0;
|
level = 0;
|
||||||
|
@ -230,6 +249,11 @@ get_buffer_level (RTPJitterBuffer * jbuf)
|
||||||
level = high_ts - low_ts;
|
level = high_ts - low_ts;
|
||||||
else
|
else
|
||||||
level = 0;
|
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;
|
return level;
|
||||||
}
|
}
|
||||||
|
@ -394,6 +418,8 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time,
|
||||||
} else {
|
} else {
|
||||||
GST_WARNING ("backward timestamps at server but no timestamps");
|
GST_WARNING ("backward timestamps at server but no timestamps");
|
||||||
send_diff = 0;
|
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 %"
|
GST_DEBUG ("extrtp %" G_GUINT64_FORMAT ", gstrtp %" GST_TIME_FORMAT ", base %"
|
||||||
|
|
Loading…
Reference in a new issue