| 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 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 send_bucket_->Process(); | 216 send_bucket_->Process(); |
| 217 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); | 217 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); |
| 218 for (int k = 0; k < 10; ++k) { | 218 for (int k = 0; k < 10; ++k) { |
| 219 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 219 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 220 clock_.AdvanceTimeMilliseconds(5); | 220 clock_.AdvanceTimeMilliseconds(5); |
| 221 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, _, false)) | 221 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, _, false)) |
| 222 .Times(3) | 222 .Times(3) |
| 223 .WillRepeatedly(Return(true)); | 223 .WillRepeatedly(Return(true)); |
| 224 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 224 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 225 send_bucket_->Process(); | 225 EXPECT_EQ(0, send_bucket_->Process()); |
| 226 } | 226 } |
| 227 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 227 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 228 clock_.AdvanceTimeMilliseconds(5); | 228 clock_.AdvanceTimeMilliseconds(5); |
| 229 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 229 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 230 send_bucket_->Process(); | 230 EXPECT_EQ(0, send_bucket_->Process()); |
| 231 SendAndExpectPacket(PacedSender::kNormalPriority, | 231 SendAndExpectPacket(PacedSender::kNormalPriority, |
| 232 ssrc, | 232 ssrc, |
| 233 sequence_number++, | 233 sequence_number++, |
| 234 clock_.TimeInMilliseconds(), | 234 clock_.TimeInMilliseconds(), |
| 235 250, | 235 250, |
| 236 false); | 236 false); |
| 237 SendAndExpectPacket(PacedSender::kNormalPriority, | 237 SendAndExpectPacket(PacedSender::kNormalPriority, |
| 238 ssrc, | 238 ssrc, |
| 239 sequence_number++, | 239 sequence_number++, |
| 240 clock_.TimeInMilliseconds(), | 240 clock_.TimeInMilliseconds(), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 283 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 284 clock_.AdvanceTimeMilliseconds(5); | 284 clock_.AdvanceTimeMilliseconds(5); |
| 285 | 285 |
| 286 for (int i = 0; i < 3; ++i) { | 286 for (int i = 0; i < 3; ++i) { |
| 287 EXPECT_CALL(callback_, | 287 EXPECT_CALL(callback_, |
| 288 TimeToSendPacket(ssrc, queued_sequence_number++, _, false)) | 288 TimeToSendPacket(ssrc, queued_sequence_number++, _, false)) |
| 289 .Times(1) | 289 .Times(1) |
| 290 .WillRepeatedly(Return(true)); | 290 .WillRepeatedly(Return(true)); |
| 291 } | 291 } |
| 292 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 292 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 293 send_bucket_->Process(); | 293 EXPECT_EQ(0, send_bucket_->Process()); |
| 294 } | 294 } |
| 295 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 295 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 296 clock_.AdvanceTimeMilliseconds(5); | 296 clock_.AdvanceTimeMilliseconds(5); |
| 297 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 297 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 298 send_bucket_->Process(); | 298 EXPECT_EQ(0, send_bucket_->Process()); |
| 299 SendAndExpectPacket(PacedSender::kNormalPriority, | 299 SendAndExpectPacket(PacedSender::kNormalPriority, |
| 300 ssrc, | 300 ssrc, |
| 301 sequence_number++, | 301 sequence_number++, |
| 302 clock_.TimeInMilliseconds(), | 302 clock_.TimeInMilliseconds(), |
| 303 250, | 303 250, |
| 304 false); | 304 false); |
| 305 SendAndExpectPacket(PacedSender::kNormalPriority, | 305 SendAndExpectPacket(PacedSender::kNormalPriority, |
| 306 ssrc, | 306 ssrc, |
| 307 sequence_number++, | 307 sequence_number++, |
| 308 clock_.TimeInMilliseconds(), | 308 clock_.TimeInMilliseconds(), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 ssrc, | 366 ssrc, |
| 367 sequence_number++, | 367 sequence_number++, |
| 368 clock_.TimeInMilliseconds(), | 368 clock_.TimeInMilliseconds(), |
| 369 250, | 369 250, |
| 370 false); | 370 false); |
| 371 // No padding is expected since we have sent too much already. | 371 // No padding is expected since we have sent too much already. |
| 372 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); | 372 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); |
| 373 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 373 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 374 clock_.AdvanceTimeMilliseconds(5); | 374 clock_.AdvanceTimeMilliseconds(5); |
| 375 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 375 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 376 send_bucket_->Process(); | 376 EXPECT_EQ(0, send_bucket_->Process()); |
| 377 | 377 |
| 378 // 5 milliseconds later we have enough budget to send some padding. | 378 // 5 milliseconds later we have enough budget to send some padding. |
| 379 EXPECT_CALL(callback_, TimeToSendPadding(250)).Times(1). | 379 EXPECT_CALL(callback_, TimeToSendPadding(250)).Times(1). |
| 380 WillOnce(Return(250)); | 380 WillOnce(Return(250)); |
| 381 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 381 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 382 clock_.AdvanceTimeMilliseconds(5); | 382 clock_.AdvanceTimeMilliseconds(5); |
| 383 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 383 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 384 send_bucket_->Process(); | 384 EXPECT_EQ(0, send_bucket_->Process()); |
| 385 } | 385 } |
| 386 | 386 |
| 387 TEST_F(PacedSenderTest, VerifyPaddingUpToBitrate) { | 387 TEST_F(PacedSenderTest, VerifyPaddingUpToBitrate) { |
| 388 uint32_t ssrc = 12345; | 388 uint32_t ssrc = 12345; |
| 389 uint16_t sequence_number = 1234; | 389 uint16_t sequence_number = 1234; |
| 390 int64_t capture_time_ms = 56789; | 390 int64_t capture_time_ms = 56789; |
| 391 const int kTimeStep = 5; | 391 const int kTimeStep = 5; |
| 392 const int64_t kBitrateWindow = 100; | 392 const int64_t kBitrateWindow = 100; |
| 393 send_bucket_->UpdateBitrate( | 393 send_bucket_->UpdateBitrate( |
| 394 kTargetBitrate, kPaceMultiplier * kTargetBitrate, kTargetBitrate); | 394 kTargetBitrate, kPaceMultiplier * kTargetBitrate, kTargetBitrate); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 479 |
| 480 // Expect all high and normal priority to be sent out first. | 480 // Expect all high and normal priority to be sent out first. |
| 481 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); | 481 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); |
| 482 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, capture_time_ms, false)) | 482 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, capture_time_ms, false)) |
| 483 .Times(4) | 483 .Times(4) |
| 484 .WillRepeatedly(Return(true)); | 484 .WillRepeatedly(Return(true)); |
| 485 | 485 |
| 486 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 486 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 487 clock_.AdvanceTimeMilliseconds(5); | 487 clock_.AdvanceTimeMilliseconds(5); |
| 488 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 488 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 489 send_bucket_->Process(); | 489 EXPECT_EQ(0, send_bucket_->Process()); |
| 490 | 490 |
| 491 EXPECT_CALL(callback_, | 491 EXPECT_CALL(callback_, |
| 492 TimeToSendPacket( | 492 TimeToSendPacket( |
| 493 ssrc_low_priority, _, capture_time_ms_low_priority, false)) | 493 ssrc_low_priority, _, capture_time_ms_low_priority, false)) |
| 494 .Times(1) | 494 .Times(1) |
| 495 .WillRepeatedly(Return(true)); | 495 .WillRepeatedly(Return(true)); |
| 496 | 496 |
| 497 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 497 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 498 clock_.AdvanceTimeMilliseconds(5); | 498 clock_.AdvanceTimeMilliseconds(5); |
| 499 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 499 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 500 send_bucket_->Process(); | 500 EXPECT_EQ(0, send_bucket_->Process()); |
| 501 } | 501 } |
| 502 | 502 |
| 503 TEST_F(PacedSenderTest, HighPrioDoesntAffectBudget) { | 503 TEST_F(PacedSenderTest, HighPrioDoesntAffectBudget) { |
| 504 uint32_t ssrc = 12346; | 504 uint32_t ssrc = 12346; |
| 505 uint16_t sequence_number = 1234; | 505 uint16_t sequence_number = 1234; |
| 506 int64_t capture_time_ms = 56789; | 506 int64_t capture_time_ms = 56789; |
| 507 | 507 |
| 508 // As high prio packets doesn't affect the budget, we should be able to send | 508 // As high prio packets doesn't affect the budget, we should be able to send |
| 509 // a high number of them at once. | 509 // a high number of them at once. |
| 510 for (int i = 0; i < 25; ++i) { | 510 for (int i = 0; i < 25; ++i) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 EXPECT_EQ(clock_.TimeInMilliseconds() - capture_time_ms, | 580 EXPECT_EQ(clock_.TimeInMilliseconds() - capture_time_ms, |
| 581 send_bucket_->QueueInMs()); | 581 send_bucket_->QueueInMs()); |
| 582 | 582 |
| 583 // Expect no packet to come out while paused. | 583 // Expect no packet to come out while paused. |
| 584 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); | 584 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); |
| 585 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, _)).Times(0); | 585 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, _)).Times(0); |
| 586 | 586 |
| 587 for (int i = 0; i < 10; ++i) { | 587 for (int i = 0; i < 10; ++i) { |
| 588 clock_.AdvanceTimeMilliseconds(5); | 588 clock_.AdvanceTimeMilliseconds(5); |
| 589 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 589 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 590 send_bucket_->Process(); | 590 EXPECT_EQ(0, send_bucket_->Process()); |
| 591 } | 591 } |
| 592 // Expect high prio packets to come out first followed by all packets in the | 592 // Expect high prio packets to come out first followed by all packets in the |
| 593 // way they were added. | 593 // way they were added. |
| 594 EXPECT_CALL(callback_, TimeToSendPacket(_, _, capture_time_ms, false)) | 594 EXPECT_CALL(callback_, TimeToSendPacket(_, _, capture_time_ms, false)) |
| 595 .Times(3) | 595 .Times(3) |
| 596 .WillRepeatedly(Return(true)); | 596 .WillRepeatedly(Return(true)); |
| 597 EXPECT_CALL(callback_, TimeToSendPacket(_, _, second_capture_time_ms, false)) | 597 EXPECT_CALL(callback_, TimeToSendPacket(_, _, second_capture_time_ms, false)) |
| 598 .Times(1) | 598 .Times(1) |
| 599 .WillRepeatedly(Return(true)); | 599 .WillRepeatedly(Return(true)); |
| 600 send_bucket_->Resume(); | 600 send_bucket_->Resume(); |
| 601 | 601 |
| 602 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 602 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 603 clock_.AdvanceTimeMilliseconds(5); | 603 clock_.AdvanceTimeMilliseconds(5); |
| 604 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 604 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 605 send_bucket_->Process(); | 605 EXPECT_EQ(0, send_bucket_->Process()); |
| 606 | 606 |
| 607 EXPECT_EQ(0, send_bucket_->QueueInMs()); | 607 EXPECT_EQ(0, send_bucket_->QueueInMs()); |
| 608 } | 608 } |
| 609 | 609 |
| 610 TEST_F(PacedSenderTest, ResendPacket) { | 610 TEST_F(PacedSenderTest, ResendPacket) { |
| 611 uint32_t ssrc = 12346; | 611 uint32_t ssrc = 12346; |
| 612 uint16_t sequence_number = 1234; | 612 uint16_t sequence_number = 1234; |
| 613 int64_t capture_time_ms = clock_.TimeInMilliseconds(); | 613 int64_t capture_time_ms = clock_.TimeInMilliseconds(); |
| 614 EXPECT_EQ(0, send_bucket_->QueueInMs()); | 614 EXPECT_EQ(0, send_bucket_->QueueInMs()); |
| 615 | 615 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 for (int i = 0; i < 3; ++i) { | 899 for (int i = 0; i < 3; ++i) { |
| 900 clock_.AdvanceTimeMilliseconds(30); // Max delta. | 900 clock_.AdvanceTimeMilliseconds(30); // Max delta. |
| 901 send_bucket_->Process(); | 901 send_bucket_->Process(); |
| 902 } | 902 } |
| 903 | 903 |
| 904 EXPECT_EQ(0, send_bucket_->AverageQueueTimeMs()); | 904 EXPECT_EQ(0, send_bucket_->AverageQueueTimeMs()); |
| 905 } | 905 } |
| 906 | 906 |
| 907 } // namespace test | 907 } // namespace test |
| 908 } // namespace webrtc | 908 } // namespace webrtc |
| OLD | NEW |