mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-12 06:42:00 +00:00
jitterbuffer: expected seqnum must increase
Only update the expected seqnum when it is bigger than the previous expected seqnum.
This commit is contained in:
parent
c5bf376bb5
commit
2f03b43b21
1 changed files with 15 additions and 5 deletions
|
@ -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,8 +1758,13 @@ 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;
|
||||||
}
|
}
|
||||||
|
if (do_next_seqnum)
|
||||||
priv->next_in_seqnum = (seqnum + 1) & 0xffff;
|
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
|
||||||
|
@ -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,6 +2245,7 @@ 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;
|
||||||
|
if (timer->seqnum + lost_packets > priv->next_seqnum)
|
||||||
priv->next_seqnum = (timer->seqnum + lost_packets) & 0xffff;
|
priv->next_seqnum = (timer->seqnum + lost_packets) & 0xffff;
|
||||||
/* remove timer now */
|
/* remove timer now */
|
||||||
remove_timer (jitterbuffer, timer);
|
remove_timer (jitterbuffer, timer);
|
||||||
|
|
Loading…
Reference in a new issue