mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 07:28:53 +00:00
rtpjitterbuffer: Take a running average of the packet spacings instead of just the latest
https://bugzilla.gnome.org/show_bug.cgi?id=748041
This commit is contained in:
parent
f81c9a9568
commit
3fe8ceff14
1 changed files with 21 additions and 2 deletions
|
@ -2027,9 +2027,28 @@ calculate_packet_spacing (GstRtpJitterBuffer * jitterbuffer, guint32 rtptime,
|
||||||
if (priv->ips_rtptime != rtptime) {
|
if (priv->ips_rtptime != rtptime) {
|
||||||
/* rtptime changed, check dts diff */
|
/* rtptime changed, check dts diff */
|
||||||
if (priv->ips_dts != -1 && dts != -1 && dts > priv->ips_dts) {
|
if (priv->ips_dts != -1 && dts != -1 && dts > priv->ips_dts) {
|
||||||
priv->packet_spacing = dts - priv->ips_dts;
|
GstClockTime new_packet_spacing = dts - priv->ips_dts;
|
||||||
|
GstClockTime old_packet_spacing = priv->packet_spacing;
|
||||||
|
|
||||||
|
/* Biased towards bigger packet spacings to prevent
|
||||||
|
* too many unneeded retransmission requests for next
|
||||||
|
* packets that just arrive a little later than we would
|
||||||
|
* expect */
|
||||||
|
if (old_packet_spacing > new_packet_spacing)
|
||||||
|
priv->packet_spacing =
|
||||||
|
(new_packet_spacing + 3 * old_packet_spacing) / 4;
|
||||||
|
else if (old_packet_spacing > 0)
|
||||||
|
priv->packet_spacing =
|
||||||
|
(3 * new_packet_spacing + old_packet_spacing) / 4;
|
||||||
|
else
|
||||||
|
priv->packet_spacing = new_packet_spacing;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (jitterbuffer,
|
GST_DEBUG_OBJECT (jitterbuffer,
|
||||||
"new packet spacing %" GST_TIME_FORMAT,
|
"new packet spacing %" GST_TIME_FORMAT
|
||||||
|
" old packet spacing %" GST_TIME_FORMAT
|
||||||
|
" combined to %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (new_packet_spacing),
|
||||||
|
GST_TIME_ARGS (old_packet_spacing),
|
||||||
GST_TIME_ARGS (priv->packet_spacing));
|
GST_TIME_ARGS (priv->packet_spacing));
|
||||||
}
|
}
|
||||||
priv->ips_rtptime = rtptime;
|
priv->ips_rtptime = rtptime;
|
||||||
|
|
Loading…
Reference in a new issue