mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
rtpjitterbuffer: reorganize jitterbuffer items
Keep the oldest item at the head and the newest items on the tail. This makes it easier to deal with -1 seqnums.
This commit is contained in:
parent
ea2a222cef
commit
4a2e0f4ff4
1 changed files with 12 additions and 13 deletions
|
@ -251,20 +251,20 @@ get_buffer_level (RTPJitterBuffer * jbuf)
|
||||||
guint64 level;
|
guint64 level;
|
||||||
|
|
||||||
/* first first buffer with timestamp */
|
/* first first buffer with timestamp */
|
||||||
high_buf = (RTPJitterBufferItem *) g_queue_peek_head_link (jbuf->packets);
|
high_buf = (RTPJitterBufferItem *) g_queue_peek_tail_link (jbuf->packets);
|
||||||
while (high_buf) {
|
while (high_buf) {
|
||||||
if (high_buf->dts != -1)
|
if (high_buf->dts != -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
high_buf = (RTPJitterBufferItem *) g_list_next (high_buf);
|
high_buf = (RTPJitterBufferItem *) g_list_previous (high_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
low_buf = (RTPJitterBufferItem *) g_queue_peek_tail_link (jbuf->packets);
|
low_buf = (RTPJitterBufferItem *) g_queue_peek_head_link (jbuf->packets);
|
||||||
while (low_buf) {
|
while (low_buf) {
|
||||||
if (low_buf->dts != -1)
|
if (low_buf->dts != -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
low_buf = (RTPJitterBufferItem *) g_list_previous (low_buf);
|
low_buf = (RTPJitterBufferItem *) g_list_next (low_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!high_buf || !low_buf || high_buf == low_buf) {
|
if (!high_buf || !low_buf || high_buf == low_buf) {
|
||||||
|
@ -655,7 +655,6 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, RTPJitterBufferItem * item,
|
||||||
|
|
||||||
/* no seqnum, simply append then */
|
/* no seqnum, simply append then */
|
||||||
if (item->seqnum == -1) {
|
if (item->seqnum == -1) {
|
||||||
list = jbuf->packets->head;
|
|
||||||
goto append;
|
goto append;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,8 +678,8 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, RTPJitterBufferItem * item,
|
||||||
if (G_UNLIKELY (gap == 0))
|
if (G_UNLIKELY (gap == 0))
|
||||||
goto duplicate;
|
goto duplicate;
|
||||||
|
|
||||||
/* seqnum > qseq, we can stop looking */
|
/* seqnum < qseq, we can stop looking */
|
||||||
if (G_LIKELY (gap < 0))
|
if (G_LIKELY (gap > 0))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,13 +780,13 @@ rtp_jitter_buffer_pop (RTPJitterBuffer * jbuf, gint * percent)
|
||||||
|
|
||||||
queue = jbuf->packets;
|
queue = jbuf->packets;
|
||||||
|
|
||||||
item = queue->tail;
|
item = queue->head;
|
||||||
if (item) {
|
if (item) {
|
||||||
queue->tail = item->prev;
|
queue->head = item->next;
|
||||||
if (queue->tail)
|
if (queue->head)
|
||||||
queue->tail->next = NULL;
|
queue->head->prev = NULL;
|
||||||
else
|
else
|
||||||
queue->head = NULL;
|
queue->tail = NULL;
|
||||||
queue->length--;
|
queue->length--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,7 +814,7 @@ rtp_jitter_buffer_peek (RTPJitterBuffer * jbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (jbuf != NULL, NULL);
|
g_return_val_if_fail (jbuf != NULL, NULL);
|
||||||
|
|
||||||
return (RTPJitterBufferItem *) jbuf->packets->tail;
|
return (RTPJitterBufferItem *) jbuf->packets->head;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue