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_,