| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 20 matching lines...) Expand all Loading... |
| 31 class PacketRouterTest : public ::testing::Test { | 31 class PacketRouterTest : public ::testing::Test { |
| 32 public: | 32 public: |
| 33 PacketRouterTest() : packet_router_(new PacketRouter()) {} | 33 PacketRouterTest() : packet_router_(new PacketRouter()) {} |
| 34 protected: | 34 protected: |
| 35 static const int kProbeMinProbes = 5; | 35 static const int kProbeMinProbes = 5; |
| 36 static const int kProbeMinBytes = 1000; | 36 static const int kProbeMinBytes = 1000; |
| 37 const std::unique_ptr<PacketRouter> packet_router_; | 37 const std::unique_ptr<PacketRouter> packet_router_; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 TEST_F(PacketRouterTest, TimeToSendPacket) { | 40 TEST_F(PacketRouterTest, TimeToSendPacket) { |
| 41 MockRtpRtcp rtp_1; | 41 NiceMock<MockRtpRtcp> rtp_1; |
| 42 MockRtpRtcp rtp_2; | 42 NiceMock<MockRtpRtcp> rtp_2; |
| 43 packet_router_->AddSendRtpModule(&rtp_1); | 43 packet_router_->AddSendRtpModule(&rtp_1); |
| 44 packet_router_->AddSendRtpModule(&rtp_2); | 44 packet_router_->AddSendRtpModule(&rtp_2); |
| 45 | 45 |
| 46 const uint16_t kSsrc1 = 1234; | 46 const uint16_t kSsrc1 = 1234; |
| 47 uint16_t sequence_number = 17; | 47 uint16_t sequence_number = 17; |
| 48 uint64_t timestamp = 7890; | 48 uint64_t timestamp = 7890; |
| 49 bool retransmission = false; | 49 bool retransmission = false; |
| 50 | 50 |
| 51 // Send on the first module by letting rtp_1 be sending with correct ssrc. | 51 // Send on the first module by letting rtp_1 be sending with correct ssrc. |
| 52 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true)); | 52 EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, | 111 PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, |
| 112 kProbeMinBytes))); | 112 kProbeMinBytes))); |
| 113 | 113 |
| 114 packet_router_->RemoveSendRtpModule(&rtp_2); | 114 packet_router_->RemoveSendRtpModule(&rtp_2); |
| 115 } | 115 } |
| 116 | 116 |
| 117 TEST_F(PacketRouterTest, TimeToSendPadding) { | 117 TEST_F(PacketRouterTest, TimeToSendPadding) { |
| 118 const uint16_t kSsrc1 = 1234; | 118 const uint16_t kSsrc1 = 1234; |
| 119 const uint16_t kSsrc2 = 4567; | 119 const uint16_t kSsrc2 = 4567; |
| 120 | 120 |
| 121 MockRtpRtcp rtp_1; | 121 NiceMock<MockRtpRtcp> rtp_1; |
| 122 EXPECT_CALL(rtp_1, RtxSendStatus()).WillOnce(Return(kRtxOff)); | 122 EXPECT_CALL(rtp_1, RtxSendStatus()).WillOnce(Return(kRtxOff)); |
| 123 EXPECT_CALL(rtp_1, SSRC()).WillRepeatedly(Return(kSsrc1)); | 123 EXPECT_CALL(rtp_1, SSRC()).WillRepeatedly(Return(kSsrc1)); |
| 124 MockRtpRtcp rtp_2; | 124 NiceMock<MockRtpRtcp> rtp_2; |
| 125 // rtp_2 will be prioritized for padding. | 125 // rtp_2 will be prioritized for padding. |
| 126 EXPECT_CALL(rtp_2, RtxSendStatus()).WillOnce(Return(kRtxRedundantPayloads)); | 126 EXPECT_CALL(rtp_2, RtxSendStatus()).WillOnce(Return(kRtxRedundantPayloads)); |
| 127 EXPECT_CALL(rtp_2, SSRC()).WillRepeatedly(Return(kSsrc2)); | 127 EXPECT_CALL(rtp_2, SSRC()).WillRepeatedly(Return(kSsrc2)); |
| 128 packet_router_->AddSendRtpModule(&rtp_1); | 128 packet_router_->AddSendRtpModule(&rtp_1); |
| 129 packet_router_->AddSendRtpModule(&rtp_2); | 129 packet_router_->AddSendRtpModule(&rtp_2); |
| 130 | 130 |
| 131 // Default configuration, sending padding on all modules sending media, | 131 // Default configuration, sending padding on all modules sending media, |
| 132 // ordered by priority (based on rtx mode). | 132 // ordered by priority (based on rtx mode). |
| 133 const size_t requested_padding_bytes = 1000; | 133 const size_t requested_padding_bytes = 1000; |
| 134 const size_t sent_padding_bytes = 890; | 134 const size_t sent_padding_bytes = 890; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 EXPECT_EQ(0u, | 202 EXPECT_EQ(0u, |
| 203 packet_router_->TimeToSendPadding( | 203 packet_router_->TimeToSendPadding( |
| 204 requested_padding_bytes, | 204 requested_padding_bytes, |
| 205 PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, | 205 PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes, |
| 206 kProbeMinBytes))); | 206 kProbeMinBytes))); |
| 207 | 207 |
| 208 packet_router_->RemoveSendRtpModule(&rtp_2); | 208 packet_router_->RemoveSendRtpModule(&rtp_2); |
| 209 } | 209 } |
| 210 | 210 |
| 211 TEST_F(PacketRouterTest, SenderOnlyFunctionsRespectSendingMedia) { | 211 TEST_F(PacketRouterTest, SenderOnlyFunctionsRespectSendingMedia) { |
| 212 MockRtpRtcp rtp; | 212 NiceMock<MockRtpRtcp> rtp; |
| 213 packet_router_->AddSendRtpModule(&rtp); | 213 packet_router_->AddSendRtpModule(&rtp); |
| 214 static const uint16_t kSsrc = 1234; | 214 static const uint16_t kSsrc = 1234; |
| 215 EXPECT_CALL(rtp, SSRC()).WillRepeatedly(Return(kSsrc)); | 215 EXPECT_CALL(rtp, SSRC()).WillRepeatedly(Return(kSsrc)); |
| 216 EXPECT_CALL(rtp, SendingMedia()).WillRepeatedly(Return(false)); | 216 EXPECT_CALL(rtp, SendingMedia()).WillRepeatedly(Return(false)); |
| 217 | 217 |
| 218 // Verify that TimeToSendPacket does not end up in a receiver. | 218 // Verify that TimeToSendPacket does not end up in a receiver. |
| 219 EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _, _)).Times(0); | 219 EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _, _)).Times(0); |
| 220 EXPECT_TRUE(packet_router_->TimeToSendPacket( | 220 EXPECT_TRUE(packet_router_->TimeToSendPacket( |
| 221 kSsrc, 1, 1, false, PacedPacketInfo(PacedPacketInfo::kNotAProbe, | 221 kSsrc, 1, 1, false, PacedPacketInfo(PacedPacketInfo::kNotAProbe, |
| 222 kProbeMinBytes, kProbeMinBytes))); | 222 kProbeMinBytes, kProbeMinBytes))); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 237 packet_router_->SetTransportWideSequenceNumber(kStartSeq - 1); | 237 packet_router_->SetTransportWideSequenceNumber(kStartSeq - 1); |
| 238 | 238 |
| 239 for (size_t i = 0; i < kNumPackets; ++i) { | 239 for (size_t i = 0; i < kNumPackets; ++i) { |
| 240 uint16_t seq = packet_router_->AllocateSequenceNumber(); | 240 uint16_t seq = packet_router_->AllocateSequenceNumber(); |
| 241 uint32_t expected_unwrapped_seq = static_cast<uint32_t>(kStartSeq) + i; | 241 uint32_t expected_unwrapped_seq = static_cast<uint32_t>(kStartSeq) + i; |
| 242 EXPECT_EQ(static_cast<uint16_t>(expected_unwrapped_seq & 0xFFFF), seq); | 242 EXPECT_EQ(static_cast<uint16_t>(expected_unwrapped_seq & 0xFFFF), seq); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 TEST_F(PacketRouterTest, SendTransportFeedback) { | 246 TEST_F(PacketRouterTest, SendTransportFeedback) { |
| 247 MockRtpRtcp rtp_1; | 247 NiceMock<MockRtpRtcp> rtp_1; |
| 248 MockRtpRtcp rtp_2; | 248 NiceMock<MockRtpRtcp> rtp_2; |
| 249 packet_router_->AddSendRtpModule(&rtp_1); | 249 packet_router_->AddSendRtpModule(&rtp_1); |
| 250 packet_router_->AddReceiveRtpModule(&rtp_2); | 250 packet_router_->AddReceiveRtpModule(&rtp_2); |
| 251 | 251 |
| 252 rtcp::TransportFeedback feedback; | 252 rtcp::TransportFeedback feedback; |
| 253 EXPECT_CALL(rtp_1, SendFeedbackPacket(_)).Times(1).WillOnce(Return(true)); | 253 EXPECT_CALL(rtp_1, SendFeedbackPacket(_)).Times(1).WillOnce(Return(true)); |
| 254 packet_router_->SendTransportFeedback(&feedback); | 254 packet_router_->SendTransportFeedback(&feedback); |
| 255 packet_router_->RemoveSendRtpModule(&rtp_1); | 255 packet_router_->RemoveSendRtpModule(&rtp_1); |
| 256 EXPECT_CALL(rtp_2, SendFeedbackPacket(_)).Times(1).WillOnce(Return(true)); | 256 EXPECT_CALL(rtp_2, SendFeedbackPacket(_)).Times(1).WillOnce(Return(true)); |
| 257 packet_router_->SendTransportFeedback(&feedback); | 257 packet_router_->SendTransportFeedback(&feedback); |
| 258 packet_router_->RemoveReceiveRtpModule(&rtp_2); | 258 packet_router_->RemoveReceiveRtpModule(&rtp_2); |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST(PacketRouterRembTest, PreferSendModuleOverReceiveModule) { | 261 TEST(PacketRouterRembTest, PreferSendModuleOverReceiveModule) { |
| 262 rtc::ScopedFakeClock clock; | 262 rtc::ScopedFakeClock clock; |
| 263 MockRtpRtcp rtp_recv; | 263 NiceMock<MockRtpRtcp> rtp_recv; |
| 264 MockRtpRtcp rtp_send; | 264 NiceMock<MockRtpRtcp> rtp_send; |
| 265 PacketRouter packet_router; | 265 PacketRouter packet_router; |
| 266 | 266 |
| 267 EXPECT_CALL(rtp_recv, SetREMBStatus(true)).Times(1); | 267 EXPECT_CALL(rtp_recv, SetREMBStatus(true)).Times(1); |
| 268 packet_router.AddReceiveRtpModule(&rtp_recv); | 268 packet_router.AddReceiveRtpModule(&rtp_recv); |
| 269 | 269 |
| 270 const uint32_t bitrate_estimate = 456; | 270 const uint32_t bitrate_estimate = 456; |
| 271 const std::vector<uint32_t> ssrcs = {1234}; | 271 const std::vector<uint32_t> ssrcs = {1234}; |
| 272 | 272 |
| 273 ON_CALL(rtp_recv, REMB()).WillByDefault(Return(true)); | 273 ON_CALL(rtp_recv, REMB()).WillByDefault(Return(true)); |
| 274 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 274 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 291 | 291 |
| 292 EXPECT_CALL(rtp_send, SetREMBStatus(false)).Times(1); | 292 EXPECT_CALL(rtp_send, SetREMBStatus(false)).Times(1); |
| 293 EXPECT_CALL(rtp_recv, SetREMBStatus(true)).Times(1); | 293 EXPECT_CALL(rtp_recv, SetREMBStatus(true)).Times(1); |
| 294 packet_router.RemoveSendRtpModule(&rtp_send); | 294 packet_router.RemoveSendRtpModule(&rtp_send); |
| 295 EXPECT_CALL(rtp_recv, SetREMBStatus(false)).Times(1); | 295 EXPECT_CALL(rtp_recv, SetREMBStatus(false)).Times(1); |
| 296 packet_router.RemoveReceiveRtpModule(&rtp_recv); | 296 packet_router.RemoveReceiveRtpModule(&rtp_recv); |
| 297 } | 297 } |
| 298 | 298 |
| 299 TEST(PacketRouterRembTest, LowerEstimateToSendRemb) { | 299 TEST(PacketRouterRembTest, LowerEstimateToSendRemb) { |
| 300 rtc::ScopedFakeClock clock; | 300 rtc::ScopedFakeClock clock; |
| 301 MockRtpRtcp rtp; | 301 NiceMock<MockRtpRtcp> rtp; |
| 302 PacketRouter packet_router; | 302 PacketRouter packet_router; |
| 303 | 303 |
| 304 EXPECT_CALL(rtp, SetREMBStatus(true)).Times(1); | 304 EXPECT_CALL(rtp, SetREMBStatus(true)).Times(1); |
| 305 packet_router.AddSendRtpModule(&rtp); | 305 packet_router.AddSendRtpModule(&rtp); |
| 306 | 306 |
| 307 uint32_t bitrate_estimate = 456; | 307 uint32_t bitrate_estimate = 456; |
| 308 const std::vector<uint32_t> ssrcs = {1234}; | 308 const std::vector<uint32_t> ssrcs = {1234}; |
| 309 | 309 |
| 310 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); | 310 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); |
| 311 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 311 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 312 | 312 |
| 313 // Call OnReceiveBitrateChanged twice to get a first estimate. | 313 // Call OnReceiveBitrateChanged twice to get a first estimate. |
| 314 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); | 314 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); |
| 315 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); | 315 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); |
| 316 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 316 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 317 | 317 |
| 318 // Lower the estimate with more than 3% to trigger a call to SetREMBData right | 318 // Lower the estimate with more than 3% to trigger a call to SetREMBData right |
| 319 // away. | 319 // away. |
| 320 bitrate_estimate = bitrate_estimate - 100; | 320 bitrate_estimate = bitrate_estimate - 100; |
| 321 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); | 321 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); |
| 322 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 322 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 323 | 323 |
| 324 EXPECT_CALL(rtp, SetREMBStatus(false)).Times(1); | 324 EXPECT_CALL(rtp, SetREMBStatus(false)).Times(1); |
| 325 packet_router.RemoveSendRtpModule(&rtp); | 325 packet_router.RemoveSendRtpModule(&rtp); |
| 326 } | 326 } |
| 327 | 327 |
| 328 TEST(PacketRouterRembTest, VerifyIncreasingAndDecreasing) { | 328 TEST(PacketRouterRembTest, VerifyIncreasingAndDecreasing) { |
| 329 rtc::ScopedFakeClock clock; | 329 rtc::ScopedFakeClock clock; |
| 330 MockRtpRtcp rtp; | 330 NiceMock<MockRtpRtcp> rtp; |
| 331 PacketRouter packet_router; | 331 PacketRouter packet_router; |
| 332 packet_router.AddSendRtpModule(&rtp); | 332 packet_router.AddSendRtpModule(&rtp); |
| 333 | 333 |
| 334 uint32_t bitrate_estimate[] = {456, 789}; | 334 uint32_t bitrate_estimate[] = {456, 789}; |
| 335 std::vector<uint32_t> ssrcs = {1234, 5678}; | 335 std::vector<uint32_t> ssrcs = {1234, 5678}; |
| 336 | 336 |
| 337 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); | 337 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); |
| 338 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate[0]); | 338 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate[0]); |
| 339 | 339 |
| 340 // Call OnReceiveBitrateChanged twice to get a first estimate. | 340 // Call OnReceiveBitrateChanged twice to get a first estimate. |
| 341 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate[0], ssrcs)).Times(1); | 341 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate[0], ssrcs)).Times(1); |
| 342 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); | 342 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); |
| 343 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate[0]); | 343 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate[0]); |
| 344 | 344 |
| 345 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate[1] + 100); | 345 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate[1] + 100); |
| 346 | 346 |
| 347 // Lower the estimate to trigger a callback. | 347 // Lower the estimate to trigger a callback. |
| 348 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate[1], ssrcs)).Times(1); | 348 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate[1], ssrcs)).Times(1); |
| 349 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate[1]); | 349 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate[1]); |
| 350 | 350 |
| 351 packet_router.RemoveSendRtpModule(&rtp); | 351 packet_router.RemoveSendRtpModule(&rtp); |
| 352 } | 352 } |
| 353 | 353 |
| 354 TEST(PacketRouterRembTest, NoRembForIncreasedBitrate) { | 354 TEST(PacketRouterRembTest, NoRembForIncreasedBitrate) { |
| 355 rtc::ScopedFakeClock clock; | 355 rtc::ScopedFakeClock clock; |
| 356 MockRtpRtcp rtp; | 356 NiceMock<MockRtpRtcp> rtp; |
| 357 PacketRouter packet_router; | 357 PacketRouter packet_router; |
| 358 packet_router.AddSendRtpModule(&rtp); | 358 packet_router.AddSendRtpModule(&rtp); |
| 359 | 359 |
| 360 uint32_t bitrate_estimate = 456; | 360 uint32_t bitrate_estimate = 456; |
| 361 std::vector<uint32_t> ssrcs = {1234, 5678}; | 361 std::vector<uint32_t> ssrcs = {1234, 5678}; |
| 362 | 362 |
| 363 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); | 363 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); |
| 364 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 364 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 365 | 365 |
| 366 // Call OnReceiveBitrateChanged twice to get a first estimate. | 366 // Call OnReceiveBitrateChanged twice to get a first estimate. |
| 367 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); | 367 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); |
| 368 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); | 368 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); |
| 369 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 369 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 370 | 370 |
| 371 // Increased estimate shouldn't trigger a callback right away. | 371 // Increased estimate shouldn't trigger a callback right away. |
| 372 EXPECT_CALL(rtp, SetREMBData(_, _)).Times(0); | 372 EXPECT_CALL(rtp, SetREMBData(_, _)).Times(0); |
| 373 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate + 1); | 373 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate + 1); |
| 374 | 374 |
| 375 // Decreasing the estimate less than 3% shouldn't trigger a new callback. | 375 // Decreasing the estimate less than 3% shouldn't trigger a new callback. |
| 376 EXPECT_CALL(rtp, SetREMBData(_, _)).Times(0); | 376 EXPECT_CALL(rtp, SetREMBData(_, _)).Times(0); |
| 377 int lower_estimate = bitrate_estimate * 98 / 100; | 377 int lower_estimate = bitrate_estimate * 98 / 100; |
| 378 packet_router.OnReceiveBitrateChanged(ssrcs, lower_estimate); | 378 packet_router.OnReceiveBitrateChanged(ssrcs, lower_estimate); |
| 379 | 379 |
| 380 packet_router.RemoveSendRtpModule(&rtp); | 380 packet_router.RemoveSendRtpModule(&rtp); |
| 381 } | 381 } |
| 382 | 382 |
| 383 TEST(PacketRouterRembTest, ChangeSendRtpModule) { | 383 TEST(PacketRouterRembTest, ChangeSendRtpModule) { |
| 384 rtc::ScopedFakeClock clock; | 384 rtc::ScopedFakeClock clock; |
| 385 MockRtpRtcp rtp_send; | 385 NiceMock<MockRtpRtcp> rtp_send; |
| 386 MockRtpRtcp rtp_recv; | 386 NiceMock<MockRtpRtcp> rtp_recv; |
| 387 PacketRouter packet_router; | 387 PacketRouter packet_router; |
| 388 packet_router.AddSendRtpModule(&rtp_send); | 388 packet_router.AddSendRtpModule(&rtp_send); |
| 389 packet_router.AddReceiveRtpModule(&rtp_recv); | 389 packet_router.AddReceiveRtpModule(&rtp_recv); |
| 390 | 390 |
| 391 uint32_t bitrate_estimate = 456; | 391 uint32_t bitrate_estimate = 456; |
| 392 std::vector<uint32_t> ssrcs = {1234, 5678}; | 392 std::vector<uint32_t> ssrcs = {1234, 5678}; |
| 393 | 393 |
| 394 ON_CALL(rtp_send, REMB()).WillByDefault(Return(true)); | 394 ON_CALL(rtp_send, REMB()).WillByDefault(Return(true)); |
| 395 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 395 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 396 | 396 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 414 | 414 |
| 415 bitrate_estimate = bitrate_estimate - 100; | 415 bitrate_estimate = bitrate_estimate - 100; |
| 416 EXPECT_CALL(rtp_recv, SetREMBData(bitrate_estimate, ssrcs)).Times(1); | 416 EXPECT_CALL(rtp_recv, SetREMBData(bitrate_estimate, ssrcs)).Times(1); |
| 417 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 417 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 418 | 418 |
| 419 packet_router.RemoveReceiveRtpModule(&rtp_recv); | 419 packet_router.RemoveReceiveRtpModule(&rtp_recv); |
| 420 } | 420 } |
| 421 | 421 |
| 422 TEST(PacketRouterRembTest, OnlyOneRembForRepeatedOnReceiveBitrateChanged) { | 422 TEST(PacketRouterRembTest, OnlyOneRembForRepeatedOnReceiveBitrateChanged) { |
| 423 rtc::ScopedFakeClock clock; | 423 rtc::ScopedFakeClock clock; |
| 424 MockRtpRtcp rtp; | 424 NiceMock<MockRtpRtcp> rtp; |
| 425 PacketRouter packet_router; | 425 PacketRouter packet_router; |
| 426 packet_router.AddSendRtpModule(&rtp); | 426 packet_router.AddSendRtpModule(&rtp); |
| 427 | 427 |
| 428 uint32_t bitrate_estimate = 456; | 428 uint32_t bitrate_estimate = 456; |
| 429 const std::vector<uint32_t> ssrcs = {1234}; | 429 const std::vector<uint32_t> ssrcs = {1234}; |
| 430 | 430 |
| 431 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); | 431 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); |
| 432 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 432 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 433 | 433 |
| 434 // Call OnReceiveBitrateChanged twice to get a first estimate. | 434 // Call OnReceiveBitrateChanged twice to get a first estimate. |
| 435 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); | 435 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); |
| 436 EXPECT_CALL(rtp, SetREMBData(_, _)).Times(1); | 436 EXPECT_CALL(rtp, SetREMBData(_, _)).Times(1); |
| 437 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 437 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 438 | 438 |
| 439 // Lower the estimate, should trigger a call to SetREMBData right away. | 439 // Lower the estimate, should trigger a call to SetREMBData right away. |
| 440 bitrate_estimate = bitrate_estimate - 100; | 440 bitrate_estimate = bitrate_estimate - 100; |
| 441 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); | 441 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); |
| 442 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 442 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 443 | 443 |
| 444 // Call OnReceiveBitrateChanged again, this should not trigger a new callback. | 444 // Call OnReceiveBitrateChanged again, this should not trigger a new callback. |
| 445 EXPECT_CALL(rtp, SetREMBData(_, _)).Times(0); | 445 EXPECT_CALL(rtp, SetREMBData(_, _)).Times(0); |
| 446 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 446 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 447 packet_router.RemoveSendRtpModule(&rtp); | 447 packet_router.RemoveSendRtpModule(&rtp); |
| 448 } | 448 } |
| 449 | 449 |
| 450 // Only register receiving modules and make sure we fallback to trigger a REMB | 450 // Only register receiving modules and make sure we fallback to trigger a REMB |
| 451 // packet on this one. | 451 // packet on this one. |
| 452 TEST(PacketRouterRembTest, NoSendingRtpModule) { | 452 TEST(PacketRouterRembTest, NoSendingRtpModule) { |
| 453 rtc::ScopedFakeClock clock; | 453 rtc::ScopedFakeClock clock; |
| 454 MockRtpRtcp rtp; | 454 NiceMock<MockRtpRtcp> rtp; |
| 455 PacketRouter packet_router; | 455 PacketRouter packet_router; |
| 456 | 456 |
| 457 EXPECT_CALL(rtp, SetREMBStatus(true)).Times(1); | 457 EXPECT_CALL(rtp, SetREMBStatus(true)).Times(1); |
| 458 packet_router.AddReceiveRtpModule(&rtp); | 458 packet_router.AddReceiveRtpModule(&rtp); |
| 459 | 459 |
| 460 uint32_t bitrate_estimate = 456; | 460 uint32_t bitrate_estimate = 456; |
| 461 const std::vector<uint32_t> ssrcs = {1234}; | 461 const std::vector<uint32_t> ssrcs = {1234}; |
| 462 | 462 |
| 463 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); | 463 ON_CALL(rtp, REMB()).WillByDefault(Return(true)); |
| 464 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 464 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 465 | 465 |
| 466 // Call OnReceiveBitrateChanged twice to get a first estimate. | 466 // Call OnReceiveBitrateChanged twice to get a first estimate. |
| 467 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); | 467 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1000)); |
| 468 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); | 468 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate, ssrcs)).Times(1); |
| 469 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); | 469 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate); |
| 470 | 470 |
| 471 // Lower the estimate to trigger a new packet REMB packet. | 471 // Lower the estimate to trigger a new packet REMB packet. |
| 472 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate - 100, ssrcs)).Times(1); | 472 EXPECT_CALL(rtp, SetREMBData(bitrate_estimate - 100, ssrcs)).Times(1); |
| 473 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate - 100); | 473 packet_router.OnReceiveBitrateChanged(ssrcs, bitrate_estimate - 100); |
| 474 | 474 |
| 475 EXPECT_CALL(rtp, SetREMBStatus(false)).Times(1); | 475 EXPECT_CALL(rtp, SetREMBStatus(false)).Times(1); |
| 476 packet_router.RemoveReceiveRtpModule(&rtp); | 476 packet_router.RemoveReceiveRtpModule(&rtp); |
| 477 } | 477 } |
| 478 | 478 |
| 479 } // namespace webrtc | 479 } // namespace webrtc |
| OLD | NEW |