OLD | NEW |
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 "webrtc/call/mock/mock_rtc_event_log.h" | 14 #include "webrtc/call/mock/mock_rtc_event_log.h" |
15 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 15 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 16 #include "webrtc/modules/congestion_controller/include/defines.h" |
16 #include "webrtc/modules/pacing/mock/mock_paced_sender.h" | 17 #include "webrtc/modules/pacing/mock/mock_paced_sender.h" |
17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | |
18 #include "webrtc/test/field_trial.h" | 18 #include "webrtc/test/field_trial.h" |
19 #include "webrtc/test/gtest.h" | 19 #include "webrtc/test/gtest.h" |
20 | 20 |
21 using ::testing::Exactly; | 21 using ::testing::Exactly; |
22 using ::testing::Return; | 22 using ::testing::Return; |
23 | 23 |
24 using webrtc::BitrateController; | 24 using webrtc::BitrateController; |
25 using webrtc::BitrateObserver; | 25 using webrtc::BitrateObserver; |
26 using webrtc::PacedSender; | 26 using webrtc::PacedSender; |
27 using webrtc::RtcpBandwidthObserver; | 27 using webrtc::RtcpBandwidthObserver; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 std::unique_ptr<BitrateController> controller_; | 91 std::unique_ptr<BitrateController> controller_; |
92 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; | 92 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; |
93 testing::NiceMock<webrtc::MockRtcEventLog> event_log_; | 93 testing::NiceMock<webrtc::MockRtcEventLog> event_log_; |
94 }; | 94 }; |
95 | 95 |
96 TEST_F(BitrateControllerTest, DefaultMinMaxBitrate) { | 96 TEST_F(BitrateControllerTest, DefaultMinMaxBitrate) { |
97 // Receive successively lower REMBs, verify the reserved bitrate is deducted. | 97 // Receive successively lower REMBs, verify the reserved bitrate is deducted. |
98 controller_->SetMinMaxBitrate(0, 0); | 98 controller_->SetMinMaxBitrate(0, 0); |
99 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); | 99 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); |
100 bandwidth_observer_->OnReceivedEstimatedBitrate(kDefaultMinBitrateBps / 2); | 100 bandwidth_observer_->OnReceivedEstimatedBitrate(kDefaultMinBitrateBps / 2); |
101 EXPECT_EQ(kDefaultMinBitrateBps, bitrate_observer_.last_bitrate_); | 101 EXPECT_EQ(webrtc::congestion_controller::kMinBitrateBps, |
| 102 bitrate_observer_.last_bitrate_); |
102 bandwidth_observer_->OnReceivedEstimatedBitrate(2 * kDefaultMaxBitrateBps); | 103 bandwidth_observer_->OnReceivedEstimatedBitrate(2 * kDefaultMaxBitrateBps); |
103 clock_.AdvanceTimeMilliseconds(1000); | 104 clock_.AdvanceTimeMilliseconds(1000); |
104 controller_->Process(); | 105 controller_->Process(); |
105 EXPECT_EQ(kDefaultMaxBitrateBps, bitrate_observer_.last_bitrate_); | 106 EXPECT_EQ(kDefaultMaxBitrateBps, bitrate_observer_.last_bitrate_); |
106 } | 107 } |
107 | 108 |
108 TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) { | 109 TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) { |
109 // First REMB applies immediately. | 110 // First REMB applies immediately. |
110 int64_t time_ms = 1001; | 111 int64_t time_ms = 1001; |
111 webrtc::ReportBlockList report_blocks; | 112 webrtc::ReportBlockList report_blocks; |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 clock_.AdvanceTimeMilliseconds(100); | 506 clock_.AdvanceTimeMilliseconds(100); |
506 | 507 |
507 // 15 packets reported as received since last, enough to increase. | 508 // 15 packets reported as received since last, enough to increase. |
508 report_blocks.push_back(CreateReportBlock(1, 2, 0, 41)); | 509 report_blocks.push_back(CreateReportBlock(1, 2, 0, 41)); |
509 bandwidth_observer_->OnReceivedRtcpReceiverReport( | 510 bandwidth_observer_->OnReceivedRtcpReceiverReport( |
510 report_blocks, 50, clock_.TimeInMilliseconds()); | 511 report_blocks, 50, clock_.TimeInMilliseconds()); |
511 expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000; | 512 expected_bitrate_bps = expected_bitrate_bps * 1.08 + 1000; |
512 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); | 513 EXPECT_EQ(expected_bitrate_bps, bitrate_observer_.last_bitrate_); |
513 clock_.AdvanceTimeMilliseconds(1000); | 514 clock_.AdvanceTimeMilliseconds(1000); |
514 } | 515 } |
OLD | NEW |