Rate limit the low bandwidth / min bitrate warning to once every 10 seconds.

R=terelius@webrtc.org

Review URL: https://codereview.webrtc.org/1320763003

Cr-Commit-Position: refs/heads/master@{#9855}
This commit is contained in:
stefan 2015-09-04 03:04:56 -07:00 committed by Commit bot
parent be9b7b6881
commit b6b0b9268e
4 changed files with 23 additions and 13 deletions

View File

@ -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();
}

View File

@ -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;

View File

@ -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_;

View File

@ -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);