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