Reduce send rate to 50% if overusing before we have an acknowledged bitrate.

Check TimeToReducefurther to avoid reducing too often.

BUG=webrtc:7884

Review-Url: https://codereview.webrtc.org/2954923003
Cr-Commit-Position: refs/heads/master@{#18888}
This commit is contained in:
terelius 2017-07-04 04:52:58 -07:00 committed by Commit Bot
parent 2c3161c86e
commit a9521e248e
2 changed files with 49 additions and 0 deletions

View File

@ -201,6 +201,18 @@ DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate(
rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) {
result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing,
&result.target_bitrate_bps);
} else if (!acked_bitrate_bps && rate_control_.ValidEstimate() &&
rate_control_.TimeToReduceFurther(
now_ms, rate_control_.LatestEstimate() / 2 - 1)) {
// Overusing before we have a measured acknowledged bitrate. We check
// TimeToReduceFurther (with a fake acknowledged bitrate) to avoid
// reducing too often.
// TODO(tschumim): Improve this and/or the acknowledged bitrate estimator
// so that we (almost) always have a bitrate estimate.
rate_control_.SetEstimate(rate_control_.LatestEstimate() / 2, now_ms);
result.updated = true;
result.probe = false;
result.target_bitrate_bps = rate_control_.LatestEstimate();
}
} else {
if (probe_bitrate_bps) {

View File

@ -194,4 +194,41 @@ TEST_F(DelayBasedBweTest, TestLongTimeoutAndWrap) {
TestWrappingHelper(10 * 64);
}
TEST_F(DelayBasedBweTest, TestInitialOveruse) {
const uint32_t kStartBitrate = 300e3;
const uint32_t kInitialCapacityBps = 200e3;
const uint32_t kDummySsrc = 0;
// High FPS to ensure that we send a lot of packets in a short time.
const int kFps = 90;
stream_generator_->AddStream(new test::RtpStream(kFps, kStartBitrate));
stream_generator_->set_capacity_bps(kInitialCapacityBps);
// Needed to initialize the AimdRateControl.
bitrate_estimator_->SetStartBitrate(kStartBitrate);
// Produce 30 frames (in 1/3 second) and give them to the estimator.
uint32_t bitrate_bps = kStartBitrate;
bool seen_overuse = false;
for (int i = 0; i < 30; ++i) {
bool overuse = GenerateAndProcessFrame(kDummySsrc, bitrate_bps);
// The purpose of this test is to ensure that we back down even if we don't
// have any acknowledged bitrate estimate yet. Hence, if the test works
// as expected, we should not have a measured bitrate yet.
EXPECT_FALSE(acknowledged_bitrate_estimator_->bitrate_bps().has_value());
if (overuse) {
EXPECT_TRUE(bitrate_observer_.updated());
EXPECT_NEAR(bitrate_observer_.latest_bitrate(), kStartBitrate / 2, 15000);
bitrate_bps = bitrate_observer_.latest_bitrate();
seen_overuse = true;
break;
} else if (bitrate_observer_.updated()) {
bitrate_bps = bitrate_observer_.latest_bitrate();
bitrate_observer_.Reset();
}
}
EXPECT_TRUE(seen_overuse);
EXPECT_NEAR(bitrate_observer_.latest_bitrate(), kStartBitrate / 2, 15000);
}
} // namespace webrtc