Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc

Issue 2789233005: Move BWE period calculation from ProbingIntervalEstimator to AimdRateControl. (Closed)
Patch Set: Nits Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc
diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc
index d15418ff093a34fd25ba216a2e34b5fe18da4b20..e90c5500b356b7b593910fce23be167560dd7ce2 100644
--- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc
+++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc
@@ -18,6 +18,13 @@ namespace {
constexpr int64_t kClockInitialTime = 123456;
+constexpr int kMinBwePeriodMs = 2000;
+constexpr int kMaxBwePeriodMs = 50000;
+constexpr int kDefaultPeriodMs = 3000;
+
+// After an overuse, we back off to 85% to the received bitrate.
+constexpr double kFractionAfterOveruse = 0.85;
+
struct AimdRateControlStates {
std::unique_ptr<AimdRateControl> aimd_rate_control;
std::unique_ptr<SimulatedClock> simulated_clock;
@@ -66,21 +73,16 @@ TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn60kbpsAnd100msRtt) {
EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
}
-TEST(AimdRateControlTest, UnknownBitrateDecreaseBeforeFirstOveruse) {
- auto states = CreateAimdRateControlStates();
- EXPECT_EQ(rtc::Optional<int>(),
- states.aimd_rate_control->GetLastBitrateDecreaseBps());
-}
-
-TEST(AimdRateControlTest, GetLastBitrateDecrease) {
+TEST(AimdRateControlTest, GetIncreaseRateAndBandwidthPeriod) {
auto states = CreateAimdRateControlStates();
constexpr int kBitrate = 300000;
states.aimd_rate_control->SetEstimate(
kBitrate, states.simulated_clock->TimeInMilliseconds());
- UpdateRateControl(states, BandwidthUsage::kBwOverusing, kBitrate - 2000,
+ UpdateRateControl(states, BandwidthUsage::kBwOverusing, kBitrate,
states.simulated_clock->TimeInMilliseconds());
- EXPECT_EQ(rtc::Optional<int>(46700),
- states.aimd_rate_control->GetLastBitrateDecreaseBps());
+ EXPECT_NEAR(14000, states.aimd_rate_control->GetNearMaxIncreaseRateBps(),
+ 1000);
+ EXPECT_EQ(3000, states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
}
TEST(AimdRateControlTest, BweLimitedByAckedBitrate) {
@@ -121,4 +123,60 @@ TEST(AimdRateControlTest, BweNotLimitedByDecreasingAckedBitrate) {
2000);
EXPECT_EQ(new_estimate, prev_estimate);
}
+
+TEST(AimdRateControlTest, DefaultPeriodUntilFirstOveruse) {
+ auto states = CreateAimdRateControlStates();
+ states.aimd_rate_control->SetStartBitrate(300000);
+ EXPECT_EQ(kDefaultPeriodMs,
+ states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
+ states.simulated_clock->AdvanceTimeMilliseconds(100);
+ UpdateRateControl(states, BandwidthUsage::kBwOverusing, 100000,
+ states.simulated_clock->TimeInMilliseconds());
+ EXPECT_NE(kDefaultPeriodMs,
+ states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
+}
+
+TEST(AimdRateControlTest, ExpectedPeriodAfter20kbpsDropAnd5kbpsIncrease) {
+ auto states = CreateAimdRateControlStates();
+ constexpr int kInitialBitrate = 110000;
+ states.aimd_rate_control->SetEstimate(
+ kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
+ states.simulated_clock->AdvanceTimeMilliseconds(100);
+ // Make the bitrate drop by 20 kbps to get to 90 kbps.
+ // The rate increase at 90 kbps should be 5 kbps, so the period should be 4 s.
+ constexpr int kAckedBitrate =
+ (kInitialBitrate - 20000) / kFractionAfterOveruse;
+ UpdateRateControl(states, BandwidthUsage::kBwOverusing, kAckedBitrate,
+ states.simulated_clock->TimeInMilliseconds());
+ EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
+ EXPECT_EQ(4000, states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
+}
+
+TEST(AimdRateControlTest, BandwidthPeriodIsNotBelowMin) {
+ auto states = CreateAimdRateControlStates();
+ constexpr int kInitialBitrate = 10000;
+ states.aimd_rate_control->SetEstimate(
+ kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
+ states.simulated_clock->AdvanceTimeMilliseconds(100);
+ // Make a small (1.5 kbps) bitrate drop to 8.5 kbps.
+ UpdateRateControl(states, BandwidthUsage::kBwOverusing, kInitialBitrate - 1,
+ states.simulated_clock->TimeInMilliseconds());
+ EXPECT_EQ(kMinBwePeriodMs,
+ states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
+}
+
+TEST(AimdRateControlTest, BandwidthPeriodIsNotAboveMax) {
+ auto states = CreateAimdRateControlStates();
+ constexpr int kInitialBitrate = 10010000;
+ states.aimd_rate_control->SetEstimate(
+ kInitialBitrate, states.simulated_clock->TimeInMilliseconds());
+ states.simulated_clock->AdvanceTimeMilliseconds(100);
+ // Make a large (10 Mbps) bitrate drop to 10 kbps.
+ constexpr int kAckedBitrate = 10000 / kFractionAfterOveruse;
+ UpdateRateControl(states, BandwidthUsage::kBwOverusing, kAckedBitrate,
+ states.simulated_clock->TimeInMilliseconds());
+ EXPECT_EQ(kMaxBwePeriodMs,
+ states.aimd_rate_control->GetExpectedBandwidthPeriodMs());
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698