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 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 controller_.reset(new CongestionController( | 52 controller_.reset(new CongestionController( |
53 &clock_, &observer_, &remote_bitrate_observer_, &event_log_, | 53 &clock_, &observer_, &remote_bitrate_observer_, &event_log_, |
54 &packet_router_, std::move(pacer))); | 54 &packet_router_, std::move(pacer))); |
55 bandwidth_observer_.reset( | 55 bandwidth_observer_.reset( |
56 controller_->GetBitrateController()->CreateRtcpBandwidthObserver()); | 56 controller_->GetBitrateController()->CreateRtcpBandwidthObserver()); |
57 | 57 |
58 // Set the initial bitrate estimate and expect the |observer| and |pacer_| | 58 // Set the initial bitrate estimate and expect the |observer| and |pacer_| |
59 // to be updated. | 59 // to be updated. |
60 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); | 60 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); |
61 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps)); | 61 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps)); |
| 62 EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 3)); |
| 63 EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 5)); |
62 controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps); | 64 controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps); |
63 } | 65 } |
64 | 66 |
65 SimulatedClock clock_; | 67 SimulatedClock clock_; |
66 StrictMock<MockCongestionObserver> observer_; | 68 StrictMock<MockCongestionObserver> observer_; |
67 NiceMock<MockPacedSender>* pacer_; | 69 NiceMock<MockPacedSender>* pacer_; |
68 NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; | 70 NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; |
69 NiceMock<MockRtcEventLog> event_log_; | 71 NiceMock<MockRtcEventLog> event_log_; |
70 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; | 72 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; |
71 PacketRouter packet_router_; | 73 PacketRouter packet_router_; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 138 |
137 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); | 139 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); |
138 controller_->SignalNetworkState(kNetworkUp); | 140 controller_->SignalNetworkState(kNetworkUp); |
139 | 141 |
140 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); | 142 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); |
141 controller_->SignalNetworkState(kNetworkDown); | 143 controller_->SignalNetworkState(kNetworkDown); |
142 } | 144 } |
143 | 145 |
144 TEST_F(CongestionControllerTest, ResetBweAndBitrates) { | 146 TEST_F(CongestionControllerTest, ResetBweAndBitrates) { |
145 int new_bitrate = 200000; | 147 int new_bitrate = 200000; |
| 148 testing::Mock::VerifyAndClearExpectations(pacer_); |
146 EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _)); | 149 EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _)); |
147 EXPECT_CALL(*pacer_, SetEstimatedBitrate(new_bitrate)); | 150 EXPECT_CALL(*pacer_, SetEstimatedBitrate(new_bitrate)); |
148 controller_->ResetBweAndBitrates(new_bitrate, -1, -1); | 151 controller_->ResetBweAndBitrates(new_bitrate, -1, -1); |
149 | 152 |
150 // If the bitrate is reset to -1, the new starting bitrate will be | 153 // If the bitrate is reset to -1, the new starting bitrate will be |
151 // the minimum default bitrate kMinBitrateBps. | 154 // the minimum default bitrate kMinBitrateBps. |
152 EXPECT_CALL( | 155 EXPECT_CALL( |
153 observer_, | 156 observer_, |
154 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); | 157 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); |
155 EXPECT_CALL(*pacer_, | 158 EXPECT_CALL(*pacer_, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 for (int i = 0; i < 10; ++i) { | 236 for (int i = 0; i < 10; ++i) { |
234 clock_.AdvanceTimeMilliseconds((1000 * payload_size) / kInitialBitrateBps); | 237 clock_.AdvanceTimeMilliseconds((1000 * payload_size) / kInitialBitrateBps); |
235 int64_t now_ms = clock_.TimeInMilliseconds(); | 238 int64_t now_ms = clock_.TimeInMilliseconds(); |
236 header.extension.absoluteSendTime = AbsSendTime(now_ms, 1000); | 239 header.extension.absoluteSendTime = AbsSendTime(now_ms, 1000); |
237 controller_->OnReceivedPacket(now_ms, payload_size, header); | 240 controller_->OnReceivedPacket(now_ms, payload_size, header); |
238 } | 241 } |
239 | 242 |
240 ASSERT_EQ(1u, ssrcs.size()); | 243 ASSERT_EQ(1u, ssrcs.size()); |
241 EXPECT_EQ(header.ssrc, ssrcs[0]); | 244 EXPECT_EQ(header.ssrc, ssrcs[0]); |
242 } | 245 } |
| 246 |
| 247 TEST_F(CongestionControllerTest, ProbeOnBweReset) { |
| 248 testing::Mock::VerifyAndClearExpectations(pacer_); |
| 249 EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 6)); |
| 250 EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 12)); |
| 251 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); |
| 252 controller_->ResetBweAndBitrates(2 * kInitialBitrateBps, 0, |
| 253 20 * kInitialBitrateBps); |
| 254 } |
| 255 |
243 } // namespace test | 256 } // namespace test |
244 } // namespace webrtc | 257 } // namespace webrtc |
OLD | NEW |