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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // the minimum default bitrate kMinBitrateBps. | 228 // the minimum default bitrate kMinBitrateBps. |
229 EXPECT_CALL( | 229 EXPECT_CALL( |
230 observer_, | 230 observer_, |
231 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); | 231 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); |
232 EXPECT_CALL(*pacer_, | 232 EXPECT_CALL(*pacer_, |
233 SetEstimatedBitrate(congestion_controller::GetMinBitrateBps())); | 233 SetEstimatedBitrate(congestion_controller::GetMinBitrateBps())); |
234 route.local_network_id = 2; | 234 route.local_network_id = 2; |
235 controller_->OnNetworkRouteChanged(route, -1, -1, -1); | 235 controller_->OnNetworkRouteChanged(route, -1, -1, -1); |
236 } | 236 } |
237 | 237 |
| 238 TEST_F(CongestionControllerTest, OldFeedback) { |
| 239 int new_bitrate = 200000; |
| 240 testing::Mock::VerifyAndClearExpectations(pacer_); |
| 241 EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _)); |
| 242 EXPECT_CALL(*pacer_, SetEstimatedBitrate(new_bitrate)); |
| 243 |
| 244 // Send a few packets on the first network route. |
| 245 std::vector<PacketFeedback> packets; |
| 246 packets.push_back(PacketFeedback(0, 0, 0, 1500, kPacingInfo0)); |
| 247 packets.push_back(PacketFeedback(10, 10, 1, 1500, kPacingInfo0)); |
| 248 packets.push_back(PacketFeedback(20, 20, 2, 1500, kPacingInfo0)); |
| 249 packets.push_back(PacketFeedback(30, 30, 3, 1500, kPacingInfo1)); |
| 250 packets.push_back(PacketFeedback(40, 40, 4, 1500, kPacingInfo1)); |
| 251 |
| 252 for (const PacketFeedback& packet : packets) |
| 253 OnSentPacket(packet); |
| 254 |
| 255 // Change route and then insert a number of feedback packets. |
| 256 rtc::NetworkRoute route; |
| 257 route.local_network_id = 1; |
| 258 controller_->OnNetworkRouteChanged(route, new_bitrate, -1, -1); |
| 259 |
| 260 for (const PacketFeedback& packet : packets) { |
| 261 rtcp::TransportFeedback feedback; |
| 262 feedback.SetBase(packet.sequence_number, packet.arrival_time_ms * 1000); |
| 263 |
| 264 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
| 265 packet.arrival_time_ms * 1000)); |
| 266 feedback.Build(); |
| 267 controller_->OnTransportFeedback(feedback); |
| 268 } |
| 269 |
| 270 // If the bitrate is reset to -1, the new starting bitrate will be |
| 271 // the minimum default bitrate kMinBitrateBps. |
| 272 EXPECT_CALL( |
| 273 observer_, |
| 274 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); |
| 275 EXPECT_CALL(*pacer_, |
| 276 SetEstimatedBitrate(congestion_controller::GetMinBitrateBps())); |
| 277 route.local_network_id = 2; |
| 278 controller_->OnNetworkRouteChanged(route, -1, -1, -1); |
| 279 } |
| 280 |
238 TEST_F(CongestionControllerTest, | 281 TEST_F(CongestionControllerTest, |
239 SignalNetworkStateAndQueueIsFullAndEstimateChange) { | 282 SignalNetworkStateAndQueueIsFullAndEstimateChange) { |
240 // Send queue is full | 283 // Send queue is full |
241 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) | 284 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
242 .WillRepeatedly(Return(PacedSender::kMaxQueueLengthMs + 1)); | 285 .WillRepeatedly(Return(PacedSender::kMaxQueueLengthMs + 1)); |
243 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); | 286 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); |
244 controller_->Process(); | 287 controller_->Process(); |
245 | 288 |
246 // Queue is full and network is down. Expect no bitrate change. | 289 // Queue is full and network is down. Expect no bitrate change. |
247 controller_->SignalNetworkState(kNetworkDown); | 290 controller_->SignalNetworkState(kNetworkDown); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 ASSERT_TRUE(target_bitrate_bps_); | 479 ASSERT_TRUE(target_bitrate_bps_); |
437 | 480 |
438 // Repeat, but this time with a building delay, and make sure that the | 481 // Repeat, but this time with a building delay, and make sure that the |
439 // estimation is adjusted downwards. | 482 // estimation is adjusted downwards. |
440 uint32_t bitrate_before_delay = *target_bitrate_bps_; | 483 uint32_t bitrate_before_delay = *target_bitrate_bps_; |
441 PacketTransmissionAndFeedbackBlock(&seq_num, kRunTimeMs, 50); | 484 PacketTransmissionAndFeedbackBlock(&seq_num, kRunTimeMs, 50); |
442 EXPECT_LT(*target_bitrate_bps_, bitrate_before_delay); | 485 EXPECT_LT(*target_bitrate_bps_, bitrate_before_delay); |
443 } | 486 } |
444 } // namespace test | 487 } // namespace test |
445 } // namespace webrtc | 488 } // namespace webrtc |
OLD | NEW |