jitterbuffer: expected seqnum must increase

Only update the expected seqnum when it is bigger than the previous expected
seqnum.
This commit is contained in:
Wim Taymans 2013-08-19 14:56:49 +02:00
parent c5bf376bb5
commit 2f03b43b21

View file

@ -1568,7 +1568,7 @@ remove_all_timers (GstRtpJitterBuffer * jitterbuffer)
*/ */
static void static void
update_timers (GstRtpJitterBuffer * jitterbuffer, guint16 seqnum, update_timers (GstRtpJitterBuffer * jitterbuffer, guint16 seqnum,
GstClockTime dts) GstClockTime dts, gboolean do_next_seqnum)
{ {
GstRtpJitterBufferPrivate *priv = jitterbuffer->priv; GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
TimerData *timer = NULL; TimerData *timer = NULL;
@ -1603,7 +1603,7 @@ update_timers (GstRtpJitterBuffer * jitterbuffer, guint16 seqnum,
} }
} }
if (priv->packet_spacing > 0) { if (priv->packet_spacing > 0 && do_next_seqnum) {
GstClockTime expected; GstClockTime expected;
/* calculate expected arrival time of the next seqnum */ /* calculate expected arrival time of the next seqnum */
@ -1639,6 +1639,7 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
gint percent = -1; gint percent = -1;
guint8 pt; guint8 pt;
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT; GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
gboolean do_next_seqnum = FALSE;
jitterbuffer = GST_RTP_JITTER_BUFFER (parent); jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
@ -1728,6 +1729,8 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
reset = TRUE; reset = TRUE;
} else { } else {
GST_DEBUG_OBJECT (jitterbuffer, "tolerable gap"); GST_DEBUG_OBJECT (jitterbuffer, "tolerable gap");
if (gap > 0)
do_next_seqnum = TRUE;
} }
if (G_UNLIKELY (reset)) { if (G_UNLIKELY (reset)) {
GST_DEBUG_OBJECT (jitterbuffer, "flush and reset jitterbuffer"); GST_DEBUG_OBJECT (jitterbuffer, "flush and reset jitterbuffer");
@ -1736,6 +1739,7 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
remove_all_timers (jitterbuffer); remove_all_timers (jitterbuffer);
priv->last_popped_seqnum = -1; priv->last_popped_seqnum = -1;
priv->next_seqnum = seqnum; priv->next_seqnum = seqnum;
do_next_seqnum = TRUE;
} }
/* reset spacing estimation when gap */ /* reset spacing estimation when gap */
priv->last_in_rtptime = -1; priv->last_in_rtptime = -1;
@ -1754,9 +1758,14 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
priv->last_in_rtptime = rtptime; priv->last_in_rtptime = rtptime;
priv->last_in_dts = dts; priv->last_in_dts = dts;
} }
do_next_seqnum = TRUE;
} }
} else {
/* unknow first seqnum */
do_next_seqnum = TRUE;
} }
priv->next_in_seqnum = (seqnum + 1) & 0xffff; if (do_next_seqnum)
priv->next_in_seqnum = (seqnum + 1) & 0xffff;
/* let's check if this buffer is too late, we can only accept packets with /* let's check if this buffer is too late, we can only accept packets with
* bigger seqnum than the one we last pushed. */ * bigger seqnum than the one we last pushed. */
@ -1804,7 +1813,7 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
goto duplicate; goto duplicate;
/* update timers */ /* update timers */
update_timers (jitterbuffer, seqnum, dts); update_timers (jitterbuffer, seqnum, dts, do_next_seqnum);
/* we had an unhandled SR, handle it now */ /* we had an unhandled SR, handle it now */
if (priv->last_sr) if (priv->last_sr)
@ -2236,7 +2245,8 @@ do_lost_timeout (GstRtpJitterBuffer * jitterbuffer, TimerData * timer,
priv->last_out_time = apply_offset (jitterbuffer, timer->timeout); priv->last_out_time = apply_offset (jitterbuffer, timer->timeout);
priv->last_out_dts = timer->timeout; priv->last_out_dts = timer->timeout;
priv->last_out_pts = timer->timeout; priv->last_out_pts = timer->timeout;
priv->next_seqnum = (timer->seqnum + lost_packets) & 0xffff; if (timer->seqnum + lost_packets > priv->next_seqnum)
priv->next_seqnum = (timer->seqnum + lost_packets) & 0xffff;
/* remove timer now */ /* remove timer now */
remove_timer (jitterbuffer, timer); remove_timer (jitterbuffer, timer);