diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc index 4a045d9d89..8857ee4b4a 100644 --- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc +++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc @@ -132,7 +132,8 @@ void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { { rtc::CritScope cs(&critsect_); - bandwidth_estimation_.UpdateReceiverEstimate(bitrate); + bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), + bitrate); } MaybeTriggerOnNetworkChanged(); } diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc index 247361df47..10deb28e1b 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc @@ -27,6 +27,7 @@ const int kLimitNumPackets = 20; const int kAvgPacketSizeBytes = 1000; const int kDefaultMinBitrateBps = 10000; const int kDefaultMaxBitrateBps = 1000000000; +const int64_t kLowBitrateLogPeriodMs = 10000; struct UmaRampUpMetric { const char* metric_name; @@ -71,6 +72,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation() bitrate_(0), min_bitrate_configured_(kDefaultMinBitrateBps), max_bitrate_configured_(kDefaultMaxBitrateBps), + last_low_bitrate_log_ms_(-1), time_last_receiver_block_ms_(0), last_fraction_loss_(0), last_round_trip_time_ms_(0), @@ -118,9 +120,10 @@ void SendSideBandwidthEstimation::CurrentEstimate(int* bitrate, *rtt = last_round_trip_time_ms_; } -void SendSideBandwidthEstimation::UpdateReceiverEstimate(uint32_t bandwidth) { +void SendSideBandwidthEstimation::UpdateReceiverEstimate( + int64_t now_ms, uint32_t bandwidth) { bwe_incoming_ = bandwidth; - bitrate_ = CapBitrateToThresholds(bitrate_); + bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); } void SendSideBandwidthEstimation::UpdateReceiverBlock(uint8_t fraction_loss, @@ -200,7 +203,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { // packet loss reported, to allow startup bitrate probing. if (last_fraction_loss_ == 0 && IsInStartPhase(now_ms) && bwe_incoming_ > bitrate_) { - bitrate_ = CapBitrateToThresholds(bwe_incoming_); + bitrate_ = CapBitrateToThresholds(now_ms, bwe_incoming_); min_bitrate_history_.clear(); min_bitrate_history_.push_back(std::make_pair(now_ms, bitrate_)); return; @@ -251,7 +254,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(int64_t now_ms) { } } } - bitrate_ = CapBitrateToThresholds(bitrate_); + bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); } bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const { @@ -279,7 +282,8 @@ void SendSideBandwidthEstimation::UpdateMinHistory(int64_t now_ms) { min_bitrate_history_.push_back(std::make_pair(now_ms, bitrate_)); } -uint32_t SendSideBandwidthEstimation::CapBitrateToThresholds(uint32_t bitrate) { +uint32_t SendSideBandwidthEstimation::CapBitrateToThresholds( + int64_t now_ms, uint32_t bitrate) { if (bwe_incoming_ > 0 && bitrate > bwe_incoming_) { bitrate = bwe_incoming_; } @@ -287,9 +291,13 @@ uint32_t SendSideBandwidthEstimation::CapBitrateToThresholds(uint32_t bitrate) { bitrate = max_bitrate_configured_; } if (bitrate < min_bitrate_configured_) { - LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 - << " kbps is below configured min bitrate " - << min_bitrate_configured_ / 1000 << " kbps."; + if (last_low_bitrate_log_ms_ == -1 || + now_ms - last_low_bitrate_log_ms_ > kLowBitrateLogPeriodMs) { + LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 + << " kbps is below configured min bitrate " + << min_bitrate_configured_ / 1000 << " kbps."; + last_low_bitrate_log_ms_ = now_ms; + } bitrate = min_bitrate_configured_; } return bitrate; diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h index fb8962ad50..f50ad5184a 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h @@ -30,7 +30,7 @@ class SendSideBandwidthEstimation { void UpdateEstimate(int64_t now_ms); // Call when we receive a RTCP message with TMMBR or REMB. - void UpdateReceiverEstimate(uint32_t bandwidth); + void UpdateReceiverEstimate(int64_t now_ms, uint32_t bandwidth); // Call when we receive a RTCP message with a ReceiveBlock. void UpdateReceiverBlock(uint8_t fraction_loss, @@ -51,7 +51,7 @@ class SendSideBandwidthEstimation { // Returns the input bitrate capped to the thresholds defined by the max, // min and incoming bandwidth. - uint32_t CapBitrateToThresholds(uint32_t bitrate); + uint32_t CapBitrateToThresholds(int64_t now_ms, uint32_t bitrate); // Updates history of min bitrates. // After this method returns min_bitrate_history_.front().second contains the @@ -67,6 +67,7 @@ class SendSideBandwidthEstimation { uint32_t bitrate_; uint32_t min_bitrate_configured_; uint32_t max_bitrate_configured_; + int64_t last_low_bitrate_log_ms_; int64_t time_last_receiver_block_ms_; uint8_t last_fraction_loss_; diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc index ab052b5244..75384ae284 100644 --- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc +++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc @@ -28,7 +28,7 @@ TEST(SendSideBweTest, InitialRembWithProbing) { bwe.UpdateReceiverBlock(0, 50, 1, now_ms); // Initial REMB applies immediately. - bwe.UpdateReceiverEstimate(kRembBps); + bwe.UpdateReceiverEstimate(now_ms, kRembBps); bwe.UpdateEstimate(now_ms); int bitrate; uint8_t fraction_loss; @@ -38,7 +38,7 @@ TEST(SendSideBweTest, InitialRembWithProbing) { // Second REMB doesn't apply immediately. now_ms += 2001; - bwe.UpdateReceiverEstimate(kSecondRembBps); + bwe.UpdateReceiverEstimate(now_ms, kSecondRembBps); bwe.UpdateEstimate(now_ms); bitrate = 0; bwe.CurrentEstimate(&bitrate, &fraction_loss, &rtt);