From 1b157a20ab728a010eb85292177bcb62cef6a839 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 10 Nov 2021 23:12:19 +0100 Subject: Fix REMB calculation --- plugins/rtp/src/stream.vala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins/rtp') diff --git a/plugins/rtp/src/stream.vala b/plugins/rtp/src/stream.vala index 5d1cf6bf..17c955a5 100644 --- a/plugins/rtp/src/stream.vala +++ b/plugins/rtp/src/stream.vala @@ -201,12 +201,15 @@ public class Dino.Plugins.Rtp.Stream : Xmpp.Xep.JingleRtp.Stream { source_stat.get_uint64("packets-received", out packets_received); source_stat.get_uint64("octets-received", out octets_received); int new_lost = packets_lost - last_packets_lost; + if (new_lost < 0) new_lost = 0; uint64 new_received = packets_received - last_packets_received; + if (packets_received < last_packets_received) new_received = 0; uint64 new_octets = octets_received - last_octets_received; - if (new_received == 0) continue; + if (octets_received < last_octets_received) octets_received = 0; last_packets_lost = packets_lost; last_packets_received = packets_received; last_octets_received = octets_received; + if (new_received == 0) continue; double loss_rate = (double)new_lost / (double)(new_lost + new_received); if (new_lost <= 0 || loss_rate < 0.02) { remb = (uint)(1.08 * (double)remb); @@ -256,7 +259,7 @@ public class Dino.Plugins.Rtp.Stream : Xmpp.Xep.JingleRtp.Stream { uint8 br_exp = data[5] >> 2; uint32 br_mant = (((uint32)data[5] & 0x3) << 16) + ((uint32)data[6] << 8) + (uint32)data[7]; uint bitrate = (br_mant << br_exp) / 1000; - self.input_device.update_bitrate(self.payload_type, bitrate * 8); + self.input_device.update_bitrate(self.payload_type, bitrate); } } -- cgit v1.2.3-70-g09d2