Don't trigger too many probes when max allocated bitrate changes.

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 <srte@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25971}
diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc
index 842c3cc..a8b600f 100644
--- a/call/bitrate_allocator.cc
+++ b/call/bitrate_allocator.cc
@@ -228,9 +228,11 @@
     }
     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<uint32_t>(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 61d5410..db085f3 100644
--- a/call/bitrate_allocator_unittest.cc
+++ b/call/bitrate_allocator_unittest.cc
@@ -357,7 +357,7 @@
   const double kProtectionRatio = 0.4;
   uint32_t target_bitrate_bps = 200000;
   const uint32_t kMaxBitrateWithProtectionBps =
-      static_cast<uint32_t>(kMaxBitrateBps / (1 - kProtectionRatio));
+      static_cast<uint32_t>(kMaxBitrateBps * 2);
   uint8_t fraction_loss = kProtectionRatio * 256;
   bitrate_observer.SetBitrateProtectionRatio(kProtectionRatio);
   EXPECT_CALL(limit_observer_,