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, OneRTTWithoutBitrateChangeWhenOverUsing) { |
| 93 auto states = CreateAimdRateControlStates(); |
| 94 constexpr int kBitrate = 300000; |
| 95 constexpr int64_t kRtt = 150; |
| 96 InitBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds()); |
| 97 UpdateRateControl(states, kBwOverusing, kBitrate - 2000, |
| 98 states.simulated_clock->TimeInMilliseconds()); |
| 99 states.aimd_rate_control->SetRtt(kRtt); |
| 100 EXPECT_FALSE(states.aimd_rate_control->TimeToReduceFurther( |
| 101 states.simulated_clock->TimeInMilliseconds(), kBitrate)); |
| 102 states.simulated_clock->AdvanceTimeMilliseconds(kRtt); |
| 103 EXPECT_TRUE(states.aimd_rate_control->TimeToReduceFurther( |
| 104 states.simulated_clock->TimeInMilliseconds(), kBitrate)); |
| 105 } |
| 106 |
| 107 TEST(AimdRateControlTest, EstimatedAlreadyAchievedWhenOverUsing) { |
| 108 auto states = CreateAimdRateControlStates(); |
| 109 constexpr int kBitrate = 300000; |
| 110 constexpr int64_t kRtt = 150; |
| 111 uint32_t bitrate; |
| 112 InitBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds()); |
| 113 UpdateRateControl(states, kBwOverusing, kBitrate - 2000, |
| 114 states.simulated_clock->TimeInMilliseconds()); |
| 115 states.aimd_rate_control->SetRtt(kRtt); |
| 116 bitrate = states.aimd_rate_control->LatestEstimate(); |
| 117 EXPECT_FALSE(states.aimd_rate_control->TimeToReduceFurther( |
| 118 states.simulated_clock->TimeInMilliseconds(), bitrate)); |
| 119 bitrate = static_cast<uint32_t>(0.95 * bitrate); |
| 120 EXPECT_TRUE(states.aimd_rate_control->TimeToReduceFurther( |
| 121 states.simulated_clock->TimeInMilliseconds(), bitrate)); |
| 122 } |
| 123 |
92 } // namespace webrtc | 124 } // namespace webrtc |
OLD | NEW |