summaryrefslogtreecommitdiffstats
path: root/gst/rtpmanager/gstrtpjitterbuffer.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2008-05-26 10:09:29 +0000
committerWim Taymans <wim.taymans@gmail.com>2008-05-26 10:09:29 +0000
commit987a903d893d8e5408262717e14319dd56f81cce (patch)
tree84c33ea3bbc5c4d973698a7582d42515a231a488 /gst/rtpmanager/gstrtpjitterbuffer.c
parentff79f31297d201afe8e74c11f6e65fad26fbf12d (diff)
downloadgst-plugins-bad-987a903d893d8e5408262717e14319dd56f81cce.tar.gz
gst-plugins-bad-987a903d893d8e5408262717e14319dd56f81cce.tar.bz2
gst-plugins-bad-987a903d893d8e5408262717e14319dd56f81cce.zip
gst/rtpmanager/gstrtpjitterbuffer.c: When checking the seqnum, reset the jitterbuffer if the gap is too big, we need ...
Original commit message from CVS: * gst/rtpmanager/gstrtpjitterbuffer.c: (gst_rtp_jitter_buffer_chain), (gst_rtp_jitter_buffer_loop): When checking the seqnum, reset the jitterbuffer if the gap is too big, we need to do this so that we can better handle a restarted source. Fix some comments. * gst/rtpmanager/rtpjitterbuffer.c: (calculate_skew), (rtp_jitter_buffer_insert): Tweak the skew resync diff. Use our working seqnum compare function in -base. Rework the jitterbuffer insert code to make it clearer and more performant by only retrieving the seqnum of the input buffer once and by adding some G_LIKELY compiler hints. Improve debugging for duplicate packets. * gst/rtpmanager/rtpsource.c: (rtp_source_process_rtp): Fix a comment, we don't do skew correction here..
Diffstat (limited to 'gst/rtpmanager/gstrtpjitterbuffer.c')
-rw-r--r--gst/rtpmanager/gstrtpjitterbuffer.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c
index 46439dc1..17dd4a90 100644
--- a/gst/rtpmanager/gstrtpjitterbuffer.c
+++ b/gst/rtpmanager/gstrtpjitterbuffer.c
@@ -885,12 +885,32 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstBuffer * buffer)
if (priv->eos)
goto have_eos;
- /* let's check if this buffer is too late, we cannot accept packets with
- * bigger seqnum than the one we already pushed. */
+ /* let's check if this buffer is too late, we can only accept packets with
+ * bigger seqnum than the one we last pushed. */
if (priv->last_popped_seqnum != -1) {
- /* FIXME. isn't this supposed to be <= ? */
- if (gst_rtp_buffer_compare_seqnum (priv->last_popped_seqnum, seqnum) < 0)
- goto too_late;
+ gint gap;
+
+ gap = gst_rtp_buffer_compare_seqnum (priv->last_popped_seqnum, seqnum);
+
+ if (gap <= 0) {
+ /* priv->last_popped_seqnum >= seqnum, this packet is too late or the
+ * sender might have been restarted with different seqnum. */
+ if (gap < -100) {
+ GST_DEBUG_OBJECT (jitterbuffer, "reset: buffer too old %d", gap);
+ priv->last_popped_seqnum = -1;
+ priv->next_seqnum = -1;
+ } else {
+ goto too_late;
+ }
+ } else {
+ /* priv->last_popped_seqnum < seqnum, this is a new packet */
+ if (gap > 3000) {
+ GST_DEBUG_OBJECT (jitterbuffer, "reset: too many dropped packets %d",
+ gap);
+ priv->last_popped_seqnum = -1;
+ priv->next_seqnum = -1;
+ }
+ }
}
/* let's drop oldest packet if the queue is already full and drop-on-latency
@@ -1041,7 +1061,7 @@ again:
if (priv->eos)
goto do_eos;
}
- /* wait for packets or flushing now */
+ /* underrun, wait for packets or flushing now */
priv->waiting = TRUE;
JBUF_WAIT_CHECK (priv, flushing);
priv->waiting = FALSE;
@@ -1187,7 +1207,7 @@ again:
if (gap > 0) {
GstEvent *event;
- /* we had a gap and thus we lost a packet. Creat an event for this. */
+ /* we had a gap and thus we lost a packet. Create an event for this. */
GST_DEBUG_OBJECT (jitterbuffer, "Packet #%d lost", next_seqnum);
priv->num_late++;
discont = TRUE;