rtpjitterbuffer: Fix rtp_jitter_buffer_get_ts_diff() fill level calculation
authorSebastian Dröge <sebastian@centricular.com>
Tue, 12 Apr 2016 07:15:39 +0000 (10:15 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 12 Apr 2016 07:17:57 +0000 (10:17 +0300)
The head of the queue is the oldest packet (as in lowest seqnum), the tail is
the newest packet. To calculate the fill level, we should calculate tail-head
while considering wraparounds. Not the other way around.

Other code is already doing this in the correct order.

https://bugzilla.gnome.org/show_bug.cgi?id=764889

gst/rtpmanager/rtpjitterbuffer.c

index 41aa8e6..4c359d0 100644 (file)
@@ -1206,8 +1206,8 @@ rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer * jbuf)
 
   g_return_val_if_fail (jbuf != NULL, 0);
 
-  high_buf = (RTPJitterBufferItem *) g_queue_peek_head_link (jbuf->packets);
-  low_buf = (RTPJitterBufferItem *) g_queue_peek_tail_link (jbuf->packets);
+  high_buf = (RTPJitterBufferItem *) g_queue_peek_tail_link (jbuf->packets);
+  low_buf = (RTPJitterBufferItem *) g_queue_peek_head_link (jbuf->packets);
 
   if (!high_buf || !low_buf || high_buf == low_buf)
     return 0;