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

Side by Side Diff: webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc

Issue 2262213002: Stop increasing loss-based BWE if no feedback is received. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 3 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
« no previous file with comments | « webrtc/call/call.cc ('k') | webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <vector> 12 #include <vector>
13 13
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 #include "webrtc/call/mock/mock_rtc_event_log.h" 16 #include "webrtc/call/mock/mock_rtc_event_log.h"
17 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 17 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
18 #include "webrtc/modules/pacing/mock/mock_paced_sender.h" 18 #include "webrtc/modules/pacing/mock/mock_paced_sender.h"
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
20 #include "webrtc/test/field_trial.h"
20 21
21 using ::testing::Exactly; 22 using ::testing::Exactly;
22 using ::testing::Return; 23 using ::testing::Return;
23 24
24 using webrtc::BitrateController; 25 using webrtc::BitrateController;
25 using webrtc::BitrateObserver; 26 using webrtc::BitrateObserver;
26 using webrtc::PacedSender; 27 using webrtc::PacedSender;
27 using webrtc::RtcpBandwidthObserver; 28 using webrtc::RtcpBandwidthObserver;
28 29
29 uint8_t WeightedLoss(int num_packets1, uint8_t fraction_loss1, 30 uint8_t WeightedLoss(int num_packets1, uint8_t fraction_loss1,
(...skipping 30 matching lines...) Expand all
60 uint8_t last_fraction_loss_; 61 uint8_t last_fraction_loss_;
61 int64_t last_rtt_; 62 int64_t last_rtt_;
62 }; 63 };
63 64
64 class BitrateControllerTest : public ::testing::Test { 65 class BitrateControllerTest : public ::testing::Test {
65 protected: 66 protected:
66 BitrateControllerTest() : clock_(0) {} 67 BitrateControllerTest() : clock_(0) {}
67 ~BitrateControllerTest() {} 68 ~BitrateControllerTest() {}
68 69
69 virtual void SetUp() { 70 virtual void SetUp() {
70 controller_ = BitrateController::CreateBitrateController( 71 controller_.reset(BitrateController::CreateBitrateController(
71 &clock_, &bitrate_observer_, &event_log_); 72 &clock_, &bitrate_observer_, &event_log_));
72 controller_->SetStartBitrate(kStartBitrateBps); 73 controller_->SetStartBitrate(kStartBitrateBps);
73 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); 74 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_);
74 controller_->SetMinMaxBitrate(kMinBitrateBps, kMaxBitrateBps); 75 controller_->SetMinMaxBitrate(kMinBitrateBps, kMaxBitrateBps);
75 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); 76 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_);
76 bandwidth_observer_ = controller_->CreateRtcpBandwidthObserver(); 77 bandwidth_observer_.reset(controller_->CreateRtcpBandwidthObserver());
77 } 78 }
78 79
79 virtual void TearDown() { 80 virtual void TearDown() {
80 delete bandwidth_observer_;
81 delete controller_;
82 } 81 }
83 82
84 const int kMinBitrateBps = 100000; 83 const int kMinBitrateBps = 100000;
85 const int kStartBitrateBps = 200000; 84 const int kStartBitrateBps = 200000;
86 const int kMaxBitrateBps = 300000; 85 const int kMaxBitrateBps = 300000;
87 86
88 const int kDefaultMinBitrateBps = 10000; 87 const int kDefaultMinBitrateBps = 10000;
89 const int kDefaultMaxBitrateBps = 1000000000; 88 const int kDefaultMaxBitrateBps = 1000000000;
90 89
91 webrtc::SimulatedClock clock_; 90 webrtc::SimulatedClock clock_;
92 TestBitrateObserver bitrate_observer_; 91 TestBitrateObserver bitrate_observer_;
93 BitrateController* controller_; 92 std::unique_ptr<BitrateController> controller_;
94 RtcpBandwidthObserver* bandwidth_observer_; 93 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_;
95 testing::NiceMock<webrtc::MockRtcEventLog> event_log_; 94 testing::NiceMock<webrtc::MockRtcEventLog> event_log_;
96 }; 95 };
97 96
98 TEST_F(BitrateControllerTest, DefaultMinMaxBitrate) { 97 TEST_F(BitrateControllerTest, DefaultMinMaxBitrate) {
99 // Receive successively lower REMBs, verify the reserved bitrate is deducted. 98 // Receive successively lower REMBs, verify the reserved bitrate is deducted.
100 controller_->SetMinMaxBitrate(0, 0); 99 controller_->SetMinMaxBitrate(0, 0);
101 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); 100 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_);
102 bandwidth_observer_->OnReceivedEstimatedBitrate(kDefaultMinBitrateBps / 2); 101 bandwidth_observer_->OnReceivedEstimatedBitrate(kDefaultMinBitrateBps / 2);
103 EXPECT_EQ(kDefaultMinBitrateBps, bitrate_observer_.last_bitrate_); 102 EXPECT_EQ(kDefaultMinBitrateBps, bitrate_observer_.last_bitrate_);
104 bandwidth_observer_->OnReceivedEstimatedBitrate(2 * kDefaultMaxBitrateBps); 103 bandwidth_observer_->OnReceivedEstimatedBitrate(2 * kDefaultMaxBitrateBps);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 bandwidth_observer_->OnReceivedEstimatedBitrate(250000); 176 bandwidth_observer_->OnReceivedEstimatedBitrate(250000);
178 EXPECT_EQ(250000, bitrate_observer_.last_bitrate_); 177 EXPECT_EQ(250000, bitrate_observer_.last_bitrate_);
179 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_); 178 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_);
180 EXPECT_EQ(50, bitrate_observer_.last_rtt_); 179 EXPECT_EQ(50, bitrate_observer_.last_rtt_);
181 180
182 bandwidth_observer_->OnReceivedEstimatedBitrate(1000); 181 bandwidth_observer_->OnReceivedEstimatedBitrate(1000);
183 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); 182 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_);
184 } 183 }
185 184
186 TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) { 185 TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) {
186 const uint32_t kSsrc1 = 1;
187 const uint32_t kSsrc2 = 2;
187 // REMBs during the first 2 seconds apply immediately. 188 // REMBs during the first 2 seconds apply immediately.
188 int64_t time_ms = 1; 189 int64_t time_ms = 1;
189 webrtc::ReportBlockList report_blocks; 190 webrtc::ReportBlockList report_blocks;
190 report_blocks.push_back(CreateReportBlock(1, 2, 0, 1)); 191 report_blocks.push_back(CreateReportBlock(kSsrc1, 2, 0, 1));
191 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); 192 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms);
192 report_blocks.clear(); 193 report_blocks.clear();
193 time_ms += 500; 194 time_ms += 500;
194 195
195 RtcpBandwidthObserver* second_bandwidth_observer = 196 RtcpBandwidthObserver* second_bandwidth_observer =
196 controller_->CreateRtcpBandwidthObserver(); 197 controller_->CreateRtcpBandwidthObserver();
197 198
198 // Test start bitrate. 199 // Test start bitrate.
199 report_blocks.push_back(CreateReportBlock(1, 2, 0, 21)); 200 report_blocks.push_back(CreateReportBlock(2, 2, 0, 21));
200 second_bandwidth_observer->OnReceivedRtcpReceiverReport( 201 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
201 report_blocks, 100, 1); 202 report_blocks, 100, 1);
202 EXPECT_EQ(217000, bitrate_observer_.last_bitrate_); 203 EXPECT_EQ(200000, bitrate_observer_.last_bitrate_);
203 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_); 204 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_);
204 EXPECT_EQ(100, bitrate_observer_.last_rtt_); 205 EXPECT_EQ(100, bitrate_observer_.last_rtt_);
205 time_ms += 500; 206 time_ms += 500;
206 207
207 // Test bitrate increase 8% per second. 208 // Test bitrate increase 8% per second.
208 report_blocks.clear(); 209 report_blocks.clear();
209 report_blocks.push_back(CreateReportBlock(1, 2, 0, 21)); 210 report_blocks.push_back(CreateReportBlock(kSsrc1, 2, 0, 21));
210 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); 211 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms);
211 time_ms += 500; 212 time_ms += 500;
213 report_blocks.front().remoteSSRC = kSsrc2;
212 second_bandwidth_observer->OnReceivedRtcpReceiverReport( 214 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
213 report_blocks, 100, time_ms); 215 report_blocks, 100, time_ms);
214 EXPECT_EQ(235360, bitrate_observer_.last_bitrate_); 216 EXPECT_EQ(217000, bitrate_observer_.last_bitrate_);
215 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_); 217 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_);
216 EXPECT_EQ(100, bitrate_observer_.last_rtt_); 218 EXPECT_EQ(100, bitrate_observer_.last_rtt_);
217 time_ms += 500; 219 time_ms += 500;
218 220
219 // Extra report should not change estimate. 221 // Extra report should not change estimate.
220 report_blocks.clear(); 222 report_blocks.clear();
221 report_blocks.push_back(CreateReportBlock(1, 2, 0, 31)); 223 report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 31));
224 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
225 report_blocks, 100, time_ms);
226 EXPECT_EQ(217000, bitrate_observer_.last_bitrate_);
227 time_ms += 500;
228
229 report_blocks.clear();
230 report_blocks.push_back(CreateReportBlock(kSsrc1, 2, 0, 41));
231 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms);
232 EXPECT_EQ(235360, bitrate_observer_.last_bitrate_);
233
234 // Second report should not change estimate.
235 report_blocks.clear();
236 report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 41));
222 second_bandwidth_observer->OnReceivedRtcpReceiverReport( 237 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
223 report_blocks, 100, time_ms); 238 report_blocks, 100, time_ms);
224 EXPECT_EQ(235360, bitrate_observer_.last_bitrate_); 239 EXPECT_EQ(235360, bitrate_observer_.last_bitrate_);
225 time_ms += 500;
226
227 report_blocks.clear();
228 report_blocks.push_back(CreateReportBlock(1, 2, 0, 41));
229 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms);
230 EXPECT_EQ(255189, bitrate_observer_.last_bitrate_);
231
232 // Second report should not change estimate.
233 report_blocks.clear();
234 report_blocks.push_back(CreateReportBlock(1, 2, 0, 41));
235 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
236 report_blocks, 100, time_ms);
237 EXPECT_EQ(255189, bitrate_observer_.last_bitrate_);
238 time_ms += 1000; 240 time_ms += 1000;
239 241
240 // Reports from only one bandwidth observer is ok. 242 // Reports from only one bandwidth observer is ok.
241 report_blocks.clear(); 243 report_blocks.clear();
242 report_blocks.push_back(CreateReportBlock(1, 2, 0, 61)); 244 report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 61));
245 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
246 report_blocks, 50, time_ms);
247 EXPECT_EQ(255189, bitrate_observer_.last_bitrate_);
248 time_ms += 1000;
249
250 report_blocks.clear();
251 report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 81));
243 second_bandwidth_observer->OnReceivedRtcpReceiverReport( 252 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
244 report_blocks, 50, time_ms); 253 report_blocks, 50, time_ms);
245 EXPECT_EQ(276604, bitrate_observer_.last_bitrate_); 254 EXPECT_EQ(276604, bitrate_observer_.last_bitrate_);
246 time_ms += 1000; 255 time_ms += 1000;
247 256
248 report_blocks.clear(); 257 report_blocks.clear();
249 report_blocks.push_back(CreateReportBlock(1, 2, 0, 81)); 258 report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 121));
250 second_bandwidth_observer->OnReceivedRtcpReceiverReport( 259 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
251 report_blocks, 50, time_ms); 260 report_blocks, 50, time_ms);
252 EXPECT_EQ(299732, bitrate_observer_.last_bitrate_); 261 EXPECT_EQ(299732, bitrate_observer_.last_bitrate_);
253 time_ms += 1000; 262 time_ms += 1000;
254 263
255 // Reach max cap. 264 // Reach max cap.
256 report_blocks.clear(); 265 report_blocks.clear();
257 report_blocks.push_back(CreateReportBlock(1, 2, 0, 121)); 266 report_blocks.push_back(CreateReportBlock(kSsrc2, 2, 0, 141));
258 second_bandwidth_observer->OnReceivedRtcpReceiverReport( 267 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
259 report_blocks, 50, time_ms); 268 report_blocks, 50, time_ms);
260 EXPECT_EQ(300000, bitrate_observer_.last_bitrate_); 269 EXPECT_EQ(300000, bitrate_observer_.last_bitrate_);
261 time_ms += 1000;
262
263 report_blocks.clear();
264 report_blocks.push_back(CreateReportBlock(1, 2, 0, 141));
265 second_bandwidth_observer->OnReceivedRtcpReceiverReport(
266 report_blocks, 50, time_ms);
267 EXPECT_EQ(300000, bitrate_observer_.last_bitrate_);
268 270
269 // Test that a low REMB trigger immediately. 271 // Test that a low REMB trigger immediately.
270 // We don't care which bandwidth observer that delivers the REMB. 272 // We don't care which bandwidth observer that delivers the REMB.
271 second_bandwidth_observer->OnReceivedEstimatedBitrate(250000); 273 second_bandwidth_observer->OnReceivedEstimatedBitrate(250000);
272 EXPECT_EQ(250000, bitrate_observer_.last_bitrate_); 274 EXPECT_EQ(250000, bitrate_observer_.last_bitrate_);
273 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_); 275 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_);
274 EXPECT_EQ(50, bitrate_observer_.last_rtt_); 276 EXPECT_EQ(50, bitrate_observer_.last_rtt_);
275 277
276 // Min cap. 278 // Min cap.
277 bandwidth_observer_->OnReceivedEstimatedBitrate(1000); 279 bandwidth_observer_->OnReceivedEstimatedBitrate(1000);
(...skipping 16 matching lines...) Expand all
294 bandwidth_observer_->OnReceivedEstimatedBitrate(kStartBitrate); 296 bandwidth_observer_->OnReceivedEstimatedBitrate(kStartBitrate);
295 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms); 297 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, time_ms);
296 report_blocks.clear(); 298 report_blocks.clear();
297 time_ms += 2000; 299 time_ms += 2000;
298 300
299 // Receive a high REMB, test bitrate increase. 301 // Receive a high REMB, test bitrate increase.
300 bandwidth_observer_->OnReceivedEstimatedBitrate(400000); 302 bandwidth_observer_->OnReceivedEstimatedBitrate(400000);
301 303
302 int last_bitrate = 0; 304 int last_bitrate = 0;
303 // Ramp up to max bitrate. 305 // Ramp up to max bitrate.
304 for (int i = 0; i < 6; ++i) { 306 for (int i = 0; i < 7; ++i) {
305 report_blocks.push_back(CreateReportBlock(1, 2, 0, sequence_number[0])); 307 report_blocks.push_back(CreateReportBlock(1, 2, 0, sequence_number[0]));
306 report_blocks.push_back(CreateReportBlock(1, 3, 0, sequence_number[1])); 308 report_blocks.push_back(CreateReportBlock(1, 3, 0, sequence_number[1]));
307 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50, 309 bandwidth_observer_->OnReceivedRtcpReceiverReport(report_blocks, 50,
308 time_ms); 310 time_ms);
309 EXPECT_GT(bitrate_observer_.last_bitrate_, last_bitrate); 311 EXPECT_GT(bitrate_observer_.last_bitrate_, last_bitrate);
310 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_); 312 EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_);
311 EXPECT_EQ(50, bitrate_observer_.last_rtt_); 313 EXPECT_EQ(50, bitrate_observer_.last_rtt_);
312 last_bitrate = bitrate_observer_.last_bitrate_; 314 last_bitrate = bitrate_observer_.last_bitrate_;
313 time_ms += 1000; 315 time_ms += 1000;
314 sequence_number[0] += 20; 316 sequence_number[0] += 20;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 EXPECT_EQ(120000, bitrate_observer_.last_bitrate_); 401 EXPECT_EQ(120000, bitrate_observer_.last_bitrate_);
400 controller_->SetReservedBitrate(50000); 402 controller_->SetReservedBitrate(50000);
401 bandwidth_observer_->OnReceivedEstimatedBitrate(120000); 403 bandwidth_observer_->OnReceivedEstimatedBitrate(120000);
402 // Limited by min bitrate. 404 // Limited by min bitrate.
403 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); 405 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_);
404 406
405 controller_->SetReservedBitrate(10000); 407 controller_->SetReservedBitrate(10000);
406 bandwidth_observer_->OnReceivedEstimatedBitrate(1); 408 bandwidth_observer_->OnReceivedEstimatedBitrate(1);
407 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); 409 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_);
408 } 410 }
411
412 TEST_F(BitrateControllerTest, TimeoutsWithoutFeedback) {
413 {
414 webrtc::test::ScopedFieldTrials override_field_trials(
415 "WebRTC-SendSideBwe/Enabled/");
416 SetUp();
417 int expected_bitrate_bps = 300000;
418 controller_->SetBitrates(300000, kDefaultMinBitrateBps,
419 kDefaultMaxBitrateBps);
420
421 webrtc::ReportBlockList report_blocks;
422 report_blocks.push_back(CreateReportBlock(1, 2, 0, 1));
423 bandwidth_observer_->OnReceivedRtcpReceiverReport(
424 report_blocks, 50, clock_.TimeInMilliseconds());
425 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
426 clock_.AdvanceTimeMilliseconds(500);
427
428 report_blocks.push_back(CreateReportBlock(1, 2, 0, 21));
429 bandwidth_observer_->OnReceivedRtcpReceiverReport(
430 report_blocks, 50, clock_.TimeInMilliseconds());
431 report_blocks.clear();
432 expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000;
433 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
434 clock_.AdvanceTimeMilliseconds(1500);
435
436 report_blocks.push_back(CreateReportBlock(1, 2, 0, 41));
437 bandwidth_observer_->OnReceivedRtcpReceiverReport(
438 report_blocks, 50, clock_.TimeInMilliseconds());
439 expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000;
440 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
441 clock_.AdvanceTimeMilliseconds(1000);
442
443 // 1 seconds since feedback, expect increase.
444 controller_->Process();
445 expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000;
446 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
447 clock_.AdvanceTimeMilliseconds(800);
448
449 // 1.8 seconds since feedback, expect no increase.
450 controller_->Process();
451 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
452 clock_.AdvanceTimeMilliseconds(3701);
453
454 // More than 4.5 seconds since feedback, expect decrease.
455 controller_->Process();
456 expected_bitrate_bps *= 0.8;
457 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
458 clock_.AdvanceTimeMilliseconds(500);
459
460 // Only one timeout every second.
461 controller_->Process();
462 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
463 clock_.AdvanceTimeMilliseconds(501);
464
465 // New timeout allowed.
466 controller_->Process();
467 expected_bitrate_bps *= 0.8;
468 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
469 }
470 }
471
472 TEST_F(BitrateControllerTest, StopIncreaseWithoutPacketReports) {
473 int expected_bitrate_bps = 300000;
474 controller_->SetBitrates(300000, kDefaultMinBitrateBps,
475 kDefaultMaxBitrateBps);
476
477 webrtc::ReportBlockList report_blocks;
478 report_blocks.push_back(CreateReportBlock(1, 2, 0, 1));
479 bandwidth_observer_->OnReceivedRtcpReceiverReport(
480 report_blocks, 50, clock_.TimeInMilliseconds());
481 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
482 clock_.AdvanceTimeMilliseconds(500);
483
484 report_blocks.push_back(CreateReportBlock(1, 2, 0, 21));
485 bandwidth_observer_->OnReceivedRtcpReceiverReport(
486 report_blocks, 50, clock_.TimeInMilliseconds());
487 report_blocks.clear();
488 expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000;
489 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
490 clock_.AdvanceTimeMilliseconds(1500);
491
492 // 1.2 seconds without packets reported as received, no increase.
493 report_blocks.push_back(CreateReportBlock(1, 2, 0, 21));
494 bandwidth_observer_->OnReceivedRtcpReceiverReport(
495 report_blocks, 50, clock_.TimeInMilliseconds());
496 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
497 clock_.AdvanceTimeMilliseconds(1000);
498
499 // 5 packets reported as received since last, too few, no increase.
500 report_blocks.push_back(CreateReportBlock(1, 2, 0, 26));
501 bandwidth_observer_->OnReceivedRtcpReceiverReport(
502 report_blocks, 50, clock_.TimeInMilliseconds());
503 report_blocks.clear();
504 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
505 clock_.AdvanceTimeMilliseconds(100);
506
507 // 15 packets reported as received since last, enough to increase.
508 report_blocks.push_back(CreateReportBlock(1, 2, 0, 41));
509 bandwidth_observer_->OnReceivedRtcpReceiverReport(
510 report_blocks, 50, clock_.TimeInMilliseconds());
511 expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000;
512 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_);
513 clock_.AdvanceTimeMilliseconds(1000);
514 }
OLDNEW
« no previous file with comments | « webrtc/call/call.cc ('k') | webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698