rtpjitterbuffer: don't stop looping if event found in the queue

If we are inserting a packet into the jitter queue we need to keep
looping through the items until the right position is found. Currently,
the code stops as soon as an event is found in the queue.

Regarding events, we should only move packets before an event if there
is another packet before the event that has a larger seqnum.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=730078
This commit is contained in:
Aleix Conchillo Flaqué 2014-05-13 12:25:04 -07:00 committed by Wim Taymans
parent 8ac30d4c26
commit bcd469ff31

View file

@ -664,7 +664,7 @@ gboolean
rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, RTPJitterBufferItem * item,
gboolean * head, gint * percent)
{
GList *list;
GList *list, *event = NULL;
guint32 rtptime;
guint16 seqnum;
GstClockTime dts;
@ -686,8 +686,14 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, RTPJitterBufferItem * item,
gint gap;
RTPJitterBufferItem *qitem = (RTPJitterBufferItem *) list;
if (qitem->seqnum == -1)
break;
if (qitem->seqnum == -1) {
/* keep a pointer to the first consecutive event if not already
* set. we will insert the packet after the event if we can't find
* a packet with lower sequence number before the event. */
if (event == NULL)
event = list;
continue;
}
qseq = qitem->seqnum;
@ -701,8 +707,17 @@ rtp_jitter_buffer_insert (RTPJitterBuffer * jbuf, RTPJitterBufferItem * item,
/* seqnum > qseq, we can stop looking */
if (G_LIKELY (gap < 0))
break;
/* if we've found a packet with greater sequence number, cleanup the
* event pointer as the packet will be inserted before the event */
event = NULL;
}
/* if event is set it means that packets before the event had smaller
* sequence number, so we will insert our packet after the event */
if (event)
list = event;
dts = item->dts;
if (item->rtptime == -1)
goto append;