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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc

Issue 2800633004: Resolve dependency between rtc_event_log_api and remote_bitrate_estimator (Closed)
Patch Set: Rebased 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include <memory> 10 #include <memory>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 auto states = CreateAimdRateControlStates(); 70 auto states = CreateAimdRateControlStates();
71 EXPECT_EQ(rtc::Optional<int>(), 71 EXPECT_EQ(rtc::Optional<int>(),
72 states.aimd_rate_control->GetLastBitrateDecreaseBps()); 72 states.aimd_rate_control->GetLastBitrateDecreaseBps());
73 } 73 }
74 74
75 TEST(AimdRateControlTest, GetLastBitrateDecrease) { 75 TEST(AimdRateControlTest, GetLastBitrateDecrease) {
76 auto states = CreateAimdRateControlStates(); 76 auto states = CreateAimdRateControlStates();
77 constexpr int kBitrate = 300000; 77 constexpr int kBitrate = 300000;
78 states.aimd_rate_control->SetEstimate( 78 states.aimd_rate_control->SetEstimate(
79 kBitrate, states.simulated_clock->TimeInMilliseconds()); 79 kBitrate, states.simulated_clock->TimeInMilliseconds());
80 UpdateRateControl(states, kBwOverusing, kBitrate - 2000, 80 UpdateRateControl(states, BandwidthUsage::kBwOverusing, kBitrate - 2000,
81 states.simulated_clock->TimeInMilliseconds()); 81 states.simulated_clock->TimeInMilliseconds());
82 EXPECT_EQ(rtc::Optional<int>(46700), 82 EXPECT_EQ(rtc::Optional<int>(46700),
83 states.aimd_rate_control->GetLastBitrateDecreaseBps()); 83 states.aimd_rate_control->GetLastBitrateDecreaseBps());
84 } 84 }
85 85
86 TEST(AimdRateControlTest, BweLimitedByAckedBitrate) { 86 TEST(AimdRateControlTest, BweLimitedByAckedBitrate) {
87 auto states = CreateAimdRateControlStates(); 87 auto states = CreateAimdRateControlStates();
88 constexpr int kAckedBitrate = 10000; 88 constexpr int kAckedBitrate = 10000;
89 states.aimd_rate_control->SetEstimate( 89 states.aimd_rate_control->SetEstimate(
90 kAckedBitrate, states.simulated_clock->TimeInMilliseconds()); 90 kAckedBitrate, states.simulated_clock->TimeInMilliseconds());
91 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime < 91 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime <
92 20000) { 92 20000) {
93 UpdateRateControl(states, kBwNormal, kAckedBitrate, 93 UpdateRateControl(states, BandwidthUsage::kBwNormal, kAckedBitrate,
94 states.simulated_clock->TimeInMilliseconds()); 94 states.simulated_clock->TimeInMilliseconds());
95 states.simulated_clock->AdvanceTimeMilliseconds(100); 95 states.simulated_clock->AdvanceTimeMilliseconds(100);
96 } 96 }
97 ASSERT_TRUE(states.aimd_rate_control->ValidEstimate()); 97 ASSERT_TRUE(states.aimd_rate_control->ValidEstimate());
98 EXPECT_EQ(static_cast<uint32_t>(1.5 * kAckedBitrate + 10000), 98 EXPECT_EQ(static_cast<uint32_t>(1.5 * kAckedBitrate + 10000),
99 states.aimd_rate_control->LatestEstimate()); 99 states.aimd_rate_control->LatestEstimate());
100 } 100 }
101 101
102 TEST(AimdRateControlTest, BweNotLimitedByDecreasingAckedBitrate) { 102 TEST(AimdRateControlTest, BweNotLimitedByDecreasingAckedBitrate) {
103 auto states = CreateAimdRateControlStates(); 103 auto states = CreateAimdRateControlStates();
104 constexpr int kAckedBitrate = 100000; 104 constexpr int kAckedBitrate = 100000;
105 states.aimd_rate_control->SetEstimate( 105 states.aimd_rate_control->SetEstimate(
106 kAckedBitrate, states.simulated_clock->TimeInMilliseconds()); 106 kAckedBitrate, states.simulated_clock->TimeInMilliseconds());
107 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime < 107 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime <
108 20000) { 108 20000) {
109 UpdateRateControl(states, kBwNormal, kAckedBitrate, 109 UpdateRateControl(states, BandwidthUsage::kBwNormal, kAckedBitrate,
110 states.simulated_clock->TimeInMilliseconds()); 110 states.simulated_clock->TimeInMilliseconds());
111 states.simulated_clock->AdvanceTimeMilliseconds(100); 111 states.simulated_clock->AdvanceTimeMilliseconds(100);
112 } 112 }
113 ASSERT_TRUE(states.aimd_rate_control->ValidEstimate()); 113 ASSERT_TRUE(states.aimd_rate_control->ValidEstimate());
114 // If the acked bitrate decreases the BWE shouldn't be reduced to 1.5x 114 // If the acked bitrate decreases the BWE shouldn't be reduced to 1.5x
115 // what's being acked, but also shouldn't get to increase more. 115 // what's being acked, but also shouldn't get to increase more.
116 uint32_t prev_estimate = states.aimd_rate_control->LatestEstimate(); 116 uint32_t prev_estimate = states.aimd_rate_control->LatestEstimate();
117 UpdateRateControl(states, kBwNormal, kAckedBitrate / 2, 117 UpdateRateControl(states, BandwidthUsage::kBwNormal, kAckedBitrate / 2,
118 states.simulated_clock->TimeInMilliseconds()); 118 states.simulated_clock->TimeInMilliseconds());
119 uint32_t new_estimate = states.aimd_rate_control->LatestEstimate(); 119 uint32_t new_estimate = states.aimd_rate_control->LatestEstimate();
120 EXPECT_NEAR(new_estimate, static_cast<uint32_t>(1.5 * kAckedBitrate + 10000), 120 EXPECT_NEAR(new_estimate, static_cast<uint32_t>(1.5 * kAckedBitrate + 10000),
121 2000); 121 2000);
122 EXPECT_EQ(new_estimate, prev_estimate); 122 EXPECT_EQ(new_estimate, prev_estimate);
123 } 123 }
124 } // namespace webrtc 124 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698