OLD | NEW |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 TEST(AimdRateControlTest, GetLastBitrateDecrease) { | 82 TEST(AimdRateControlTest, GetLastBitrateDecrease) { |
83 auto states = CreateAimdRateControlStates(); | 83 auto states = CreateAimdRateControlStates(); |
84 constexpr int kBitrate = 300000; | 84 constexpr int kBitrate = 300000; |
85 InitBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds()); | 85 InitBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds()); |
86 UpdateRateControl(states, kBwOverusing, kBitrate - 2000, | 86 UpdateRateControl(states, kBwOverusing, kBitrate - 2000, |
87 states.simulated_clock->TimeInMilliseconds()); | 87 states.simulated_clock->TimeInMilliseconds()); |
88 EXPECT_EQ(rtc::Optional<int>(46700), | 88 EXPECT_EQ(rtc::Optional<int>(46700), |
89 states.aimd_rate_control->GetLastBitrateDecreaseBps()); | 89 states.aimd_rate_control->GetLastBitrateDecreaseBps()); |
90 } | 90 } |
91 | 91 |
92 TEST(AimdRateControlTest, BweLimitedByAckedBitrate) { | |
93 auto states = CreateAimdRateControlStates(); | |
94 constexpr int kAckedBitrate = 10000; | |
95 InitBitrate(states, kAckedBitrate, | |
96 states.simulated_clock->TimeInMilliseconds()); | |
97 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime < | |
98 20000) { | |
99 UpdateRateControl(states, kBwNormal, kAckedBitrate, | |
100 states.simulated_clock->TimeInMilliseconds()); | |
101 states.simulated_clock->AdvanceTimeMilliseconds(100); | |
102 } | |
103 ASSERT_TRUE(states.aimd_rate_control->ValidEstimate()); | |
104 EXPECT_EQ(static_cast<uint32_t>(1.5 * kAckedBitrate + 10000), | |
105 states.aimd_rate_control->LatestEstimate()); | |
106 } | |
107 | |
108 TEST(AimdRateControlTest, BweNotLimitedByDecreasingAckedBitrate) { | |
109 auto states = CreateAimdRateControlStates(); | |
110 constexpr int kAckedBitrate = 100000; | |
111 InitBitrate(states, kAckedBitrate, | |
112 states.simulated_clock->TimeInMilliseconds()); | |
113 while (states.simulated_clock->TimeInMilliseconds() - kClockInitialTime < | |
114 20000) { | |
115 UpdateRateControl(states, kBwNormal, kAckedBitrate, | |
116 states.simulated_clock->TimeInMilliseconds()); | |
117 states.simulated_clock->AdvanceTimeMilliseconds(100); | |
118 } | |
119 ASSERT_TRUE(states.aimd_rate_control->ValidEstimate()); | |
120 // If the acked bitrate decreases the BWE shouldn't be reduced to 1.5x | |
121 // what's being acked, but also shouldn't get to increase more. | |
122 uint32_t prev_estimate = states.aimd_rate_control->LatestEstimate(); | |
123 UpdateRateControl(states, kBwNormal, kAckedBitrate / 2, | |
124 states.simulated_clock->TimeInMilliseconds()); | |
125 uint32_t new_estimate = states.aimd_rate_control->LatestEstimate(); | |
126 EXPECT_NEAR(new_estimate, static_cast<uint32_t>(1.5 * kAckedBitrate + 10000), | |
127 2000); | |
128 EXPECT_EQ(new_estimate, prev_estimate); | |
129 } | |
130 } // namespace webrtc | 92 } // namespace webrtc |
OLD | NEW |