Cap probing bitrate to max total allocated bitrate

Bug: webrtc:10070
Change-Id: I3ba2656dff08e9ff054e263d78dcacba1ff77dd1
Reviewed-on: https://webrtc-review.googlesource.com/c/112384
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25845}
This commit is contained in:
Erik Språng
2018-11-29 17:32:48 +01:00
committed by Commit Bot
parent 5976bde2e6
commit cfe36ca3b3
3 changed files with 51 additions and 6 deletions

View File

@ -263,5 +263,40 @@ TEST_F(ProbeControllerTest, TestExponentialProbingOverflow) {
EXPECT_EQ(probes.size(), 0u);
}
TEST_F(ProbeControllerTest, TestAllocatedBitrateCap) {
const int64_t kMbpsMultiplier = 1000000;
auto probes = probe_controller_->SetBitrates(
kMinBitrateBps, 10 * kMbpsMultiplier, 100 * kMbpsMultiplier, NowMs());
// Configure ALR for periodic probing.
probe_controller_->EnablePeriodicAlrProbing(true);
int64_t alr_start_time = clock_.TimeInMilliseconds();
probe_controller_->SetAlrStartTimeMs(alr_start_time);
// Verify that probe bitrate is capped at the specified max bitrate.
probes =
probe_controller_->SetEstimatedBitrate(60 * kMbpsMultiplier, NowMs());
EXPECT_EQ(probes[0].target_data_rate.bps(), 100 * kMbpsMultiplier);
// Set a max allocated bitrate below the current max.
probes = probe_controller_->OnMaxTotalAllocatedBitrate(1 * kMbpsMultiplier,
NowMs());
EXPECT_TRUE(probes.empty()); // No probe since lower than current max.
// Other probes, such as ALR, such also be capped at the same limit.
clock_.AdvanceTimeMilliseconds(5000);
probes = probe_controller_->Process(NowMs());
EXPECT_EQ(probes[0].target_data_rate.bps(), 1 * kMbpsMultiplier);
// Advance time and configure remove allocated bitrate limit.
EXPECT_TRUE(
probe_controller_->OnMaxTotalAllocatedBitrate(0, NowMs()).empty());
// New ALR probes use previous limits.
clock_.AdvanceTimeMilliseconds(5000);
probes = probe_controller_->Process(NowMs());
EXPECT_EQ(probes[0].target_data_rate.bps(), 100 * kMbpsMultiplier);
}
} // namespace test
} // namespace webrtc