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

Side by Side Diff: webrtc/modules/congestion_controller/probe_controller_unittest.cc

Issue 2986563002: Add probing to recover faster from large bitrate drops. (Closed)
Patch Set: Created 3 years, 5 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 16 matching lines...) Expand all
27 namespace { 27 namespace {
28 28
29 constexpr int kMinBitrateBps = 100; 29 constexpr int kMinBitrateBps = 100;
30 constexpr int kStartBitrateBps = 300; 30 constexpr int kStartBitrateBps = 300;
31 constexpr int kMaxBitrateBps = 10000; 31 constexpr int kMaxBitrateBps = 10000;
32 32
33 constexpr int kExponentialProbingTimeoutMs = 5000; 33 constexpr int kExponentialProbingTimeoutMs = 5000;
34 34
35 constexpr int kAlrProbeInterval = 5000; 35 constexpr int kAlrProbeInterval = 5000;
36 36
37 constexpr int kAlrEndedTimeoutMs = 3000;
38
37 } // namespace 39 } // namespace
38 40
39 class ProbeControllerTest : public ::testing::Test { 41 class ProbeControllerTest : public ::testing::Test {
40 protected: 42 protected:
41 ProbeControllerTest() : clock_(100000000L) { 43 ProbeControllerTest() : clock_(100000000L) {
42 probe_controller_.reset(new ProbeController(&pacer_, &clock_)); 44 probe_controller_.reset(new ProbeController(&pacer_, &clock_));
43 } 45 }
44 ~ProbeControllerTest() override {} 46 ~ProbeControllerTest() override {}
45 47
46 SimulatedClock clock_; 48 SimulatedClock clock_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 kMaxBitrateBps); 115 kMaxBitrateBps);
114 116
115 // Advance far enough to cause a time out in waiting for probing result. 117 // Advance far enough to cause a time out in waiting for probing result.
116 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); 118 clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs);
117 probe_controller_->Process(); 119 probe_controller_->Process();
118 120
119 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0); 121 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0);
120 probe_controller_->SetEstimatedBitrate(1800); 122 probe_controller_->SetEstimatedBitrate(1800);
121 } 123 }
122 124
123 TEST_F(ProbeControllerTest, ProbeAfterEstimateDropInAlr) { 125 TEST_F(ProbeControllerTest, RequestProbeInAlr) {
124 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2); 126 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2);
125 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, 127 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
126 kMaxBitrateBps); 128 kMaxBitrateBps);
127 probe_controller_->SetEstimatedBitrate(500);
128 testing::Mock::VerifyAndClearExpectations(&pacer_); 129 testing::Mock::VerifyAndClearExpectations(&pacer_);
129
130 // When bandwidth estimate drops the controller should send a probe at the
131 // previous bitrate.
132 EXPECT_CALL(pacer_, CreateProbeCluster(500)).Times(1); 130 EXPECT_CALL(pacer_, CreateProbeCluster(500)).Times(1);
133 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime()) 131 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
134 .WillRepeatedly( 132 .WillRepeatedly(
135 Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds()))); 133 Return(rtc::Optional<int64_t>(clock_.TimeInMilliseconds())));
136 clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1); 134 clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1);
137 probe_controller_->Process(); 135 probe_controller_->Process();
138 probe_controller_->SetEstimatedBitrate(50); 136 probe_controller_->RequestProbe(500);
137 }
138
139 TEST_F(ProbeControllerTest, RequestProbeWhenAlrEndedRecently) {
140 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2);
141 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
142 kMaxBitrateBps);
143 testing::Mock::VerifyAndClearExpectations(&pacer_);
144 EXPECT_CALL(pacer_, CreateProbeCluster(500)).Times(1);
145 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
146 .WillRepeatedly(Return(rtc::Optional<int64_t>()));
147 clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1);
148 probe_controller_->Process();
149 probe_controller_->SetAlrEndedTimeMs(clock_.TimeInMilliseconds());
150 clock_.AdvanceTimeMilliseconds(kAlrEndedTimeoutMs - 1);
151 probe_controller_->RequestProbe(500);
152 }
153
154 TEST_F(ProbeControllerTest, RequestProbeWhenAlrNotEndedRecently) {
155 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2);
156 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
157 kMaxBitrateBps);
158 testing::Mock::VerifyAndClearExpectations(&pacer_);
159 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0);
160 EXPECT_CALL(pacer_, GetApplicationLimitedRegionStartTime())
161 .WillRepeatedly(Return(rtc::Optional<int64_t>()));
162 clock_.AdvanceTimeMilliseconds(kAlrProbeInterval + 1);
163 probe_controller_->Process();
164 probe_controller_->SetAlrEndedTimeMs(clock_.TimeInMilliseconds());
165 clock_.AdvanceTimeMilliseconds(kAlrEndedTimeoutMs + 1);
166 probe_controller_->RequestProbe(500);
139 } 167 }
140 168
141 TEST_F(ProbeControllerTest, PeriodicProbing) { 169 TEST_F(ProbeControllerTest, PeriodicProbing) {
142 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2); 170 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(2);
143 probe_controller_->EnablePeriodicAlrProbing(true); 171 probe_controller_->EnablePeriodicAlrProbing(true);
144 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, 172 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
145 kMaxBitrateBps); 173 kMaxBitrateBps);
146 probe_controller_->SetEstimatedBitrate(500); 174 probe_controller_->SetEstimatedBitrate(500);
147 testing::Mock::VerifyAndClearExpectations(&pacer_); 175 testing::Mock::VerifyAndClearExpectations(&pacer_);
148 176
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 probe_controller_->SetEstimatedBitrate(60 * kMbpsMultiplier); 241 probe_controller_->SetEstimatedBitrate(60 * kMbpsMultiplier);
214 testing::Mock::VerifyAndClearExpectations(&pacer_); 242 testing::Mock::VerifyAndClearExpectations(&pacer_);
215 243
216 // Verify that repeated probes aren't sent. 244 // Verify that repeated probes aren't sent.
217 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0); 245 EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(0);
218 probe_controller_->SetEstimatedBitrate(100 * kMbpsMultiplier); 246 probe_controller_->SetEstimatedBitrate(100 * kMbpsMultiplier);
219 } 247 }
220 248
221 } // namespace test 249 } // namespace test
222 } // namespace webrtc 250 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698