From 00672b1ddc4b3489b75e2dbba5b5601e9a5b17ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Tue, 11 Dec 2018 15:29:29 +0100 Subject: [PATCH] Don't trigger too many probes when max allocated bitrate changes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an issue which can happen if fec is used. The protection rate may fluctuate and each such change would trigger a new allocation limit to be signaled. For each such update, the probe controller could initiate a new probe. We work around this by both quantizing the protection fraction and by not sending a new probe unless the max allocated bitrate has increased significantly (or we are in ALR). Bug: webrtc:10070 Change-Id: I328963da23aedbcbedeb877aec46f5955cd2b88d Reviewed-on: https://webrtc-review.googlesource.com/c/113525 Reviewed-by: Sebastian Jansson Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/master@{#25971} --- call/bitrate_allocator.cc | 8 +++++--- call/bitrate_allocator_unittest.cc | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc index 842c3cc51b..a8b600f59d 100644 --- a/call/bitrate_allocator.cc +++ b/call/bitrate_allocator.cc @@ -228,9 +228,11 @@ void BitrateAllocator::UpdateAllocationLimits() { } total_requested_padding_bitrate += stream_padding; uint32_t max_bitrate_bps = config.max_bitrate_bps; - if (config.media_ratio > 0) { - max_bitrate_bps = - static_cast(max_bitrate_bps / config.media_ratio); + if (config.media_ratio < 1.0) { + // Account for protection overhead (eg FEC). Assumption is that overhead + // is never more than 100%. Don't adjust based exact value as that might + // trigger too frequent calls to OnAllocationLimitsChanged(). + max_bitrate_bps *= 2; } total_requested_max_bitrate += max_bitrate_bps; if (config.allocated_bitrate_bps > 0 && config.has_packet_feedback) diff --git a/call/bitrate_allocator_unittest.cc b/call/bitrate_allocator_unittest.cc index 61d5410540..db085f35ff 100644 --- a/call/bitrate_allocator_unittest.cc +++ b/call/bitrate_allocator_unittest.cc @@ -357,7 +357,7 @@ TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserverWithPacketLoss) { const double kProtectionRatio = 0.4; uint32_t target_bitrate_bps = 200000; const uint32_t kMaxBitrateWithProtectionBps = - static_cast(kMaxBitrateBps / (1 - kProtectionRatio)); + static_cast(kMaxBitrateBps * 2); uint8_t fraction_loss = kProtectionRatio * 256; bitrate_observer.SetBitrateProtectionRatio(kProtectionRatio); EXPECT_CALL(limit_observer_,