| 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 for (int i = 0; i < 10; ++i) { | 553 for (int i = 0; i < 10; ++i) { |
| 554 clock_.AdvanceTimeMilliseconds(5); | 554 clock_.AdvanceTimeMilliseconds(5); |
| 555 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 555 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 556 EXPECT_EQ(0, send_bucket_->Process()); | 556 EXPECT_EQ(0, send_bucket_->Process()); |
| 557 } | 557 } |
| 558 // Expect high prio packets to come out first followed by all packets in the | 558 // Expect high prio packets to come out first followed by all packets in the |
| 559 // way they were added. | 559 // way they were added. |
| 560 EXPECT_CALL(callback_, TimeToSendPacket(_, _, capture_time_ms, false)) | 560 EXPECT_CALL(callback_, TimeToSendPacket(_, _, capture_time_ms, false)) |
| 561 .Times(3) | 561 .Times(3) |
| 562 .WillRepeatedly(Return(true)); | 562 .WillRepeatedly(Return(true)); |
| 563 EXPECT_CALL(callback_, TimeToSendPacket(_, _, second_capture_time_ms, false)) |
| 564 .Times(1) |
| 565 .WillRepeatedly(Return(true)); |
| 563 send_bucket_->Resume(); | 566 send_bucket_->Resume(); |
| 564 | 567 |
| 565 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 568 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 566 clock_.AdvanceTimeMilliseconds(5); | 569 clock_.AdvanceTimeMilliseconds(5); |
| 567 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 570 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 568 EXPECT_EQ(0, send_bucket_->Process()); | 571 EXPECT_EQ(0, send_bucket_->Process()); |
| 569 | 572 |
| 570 EXPECT_CALL(callback_, TimeToSendPacket(_, _, second_capture_time_ms, false)) | |
| 571 .Times(1) | |
| 572 .WillRepeatedly(Return(true)); | |
| 573 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | |
| 574 clock_.AdvanceTimeMilliseconds(5); | |
| 575 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | |
| 576 EXPECT_EQ(0, send_bucket_->Process()); | |
| 577 EXPECT_EQ(0, send_bucket_->QueueInMs()); | 573 EXPECT_EQ(0, send_bucket_->QueueInMs()); |
| 578 } | 574 } |
| 579 | 575 |
| 580 TEST_F(PacedSenderTest, ResendPacket) { | 576 TEST_F(PacedSenderTest, ResendPacket) { |
| 581 uint32_t ssrc = 12346; | 577 uint32_t ssrc = 12346; |
| 582 uint16_t sequence_number = 1234; | 578 uint16_t sequence_number = 1234; |
| 583 int64_t capture_time_ms = clock_.TimeInMilliseconds(); | 579 int64_t capture_time_ms = clock_.TimeInMilliseconds(); |
| 584 EXPECT_EQ(0, send_bucket_->QueueInMs()); | 580 EXPECT_EQ(0, send_bucket_->QueueInMs()); |
| 585 | 581 |
| 586 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, | 582 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 if (time_until_process <= 0) { | 653 if (time_until_process <= 0) { |
| 658 send_bucket_->Process(); | 654 send_bucket_->Process(); |
| 659 } else { | 655 } else { |
| 660 clock_.AdvanceTimeMilliseconds(time_until_process); | 656 clock_.AdvanceTimeMilliseconds(time_until_process); |
| 661 } | 657 } |
| 662 } | 658 } |
| 663 int64_t duration = clock_.TimeInMilliseconds() - time_start; | 659 int64_t duration = clock_.TimeInMilliseconds() - time_start; |
| 664 | 660 |
| 665 EXPECT_EQ(0, send_bucket_->ExpectedQueueTimeMs()); | 661 EXPECT_EQ(0, send_bucket_->ExpectedQueueTimeMs()); |
| 666 | 662 |
| 667 // Allow for aliasing, duration should be in [expected(n - 1), expected(n)]. | 663 // Allow for aliasing, duration should be within one pack of max time limit. |
| 668 EXPECT_LE(duration, queue_in_ms); | 664 EXPECT_NEAR(duration, PacedSender::kMaxQueueLengthMs, |
| 669 EXPECT_GE(duration, | 665 static_cast<int64_t>(kPacketSize * 8 / kMaxBitrate)); |
| 670 queue_in_ms - static_cast<int64_t>(kPacketSize * 8 / kMaxBitrate)); | |
| 671 } | 666 } |
| 672 | 667 |
| 673 TEST_F(PacedSenderTest, QueueTimeGrowsOverTime) { | 668 TEST_F(PacedSenderTest, QueueTimeGrowsOverTime) { |
| 674 uint32_t ssrc = 12346; | 669 uint32_t ssrc = 12346; |
| 675 uint16_t sequence_number = 1234; | 670 uint16_t sequence_number = 1234; |
| 676 EXPECT_EQ(0, send_bucket_->QueueInMs()); | 671 EXPECT_EQ(0, send_bucket_->QueueInMs()); |
| 677 | 672 |
| 678 send_bucket_->UpdateBitrate(30, kPaceMultiplier * 30, 0); | 673 send_bucket_->UpdateBitrate(30, kPaceMultiplier * 30, 0); |
| 679 SendAndExpectPacket(PacedSender::kNormalPriority, | 674 SendAndExpectPacket(PacedSender::kNormalPriority, |
| 680 ssrc, | 675 ssrc, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 sequence_number++, clock_.TimeInMilliseconds(), | 820 sequence_number++, clock_.TimeInMilliseconds(), |
| 826 kPacketSize, false); | 821 kPacketSize, false); |
| 827 | 822 |
| 828 // Don't send padding if queue is non-empty, even if padding budget > 0. | 823 // Don't send padding if queue is non-empty, even if padding budget > 0. |
| 829 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); | 824 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); |
| 830 send_bucket_->Process(); | 825 send_bucket_->Process(); |
| 831 } | 826 } |
| 832 | 827 |
| 833 } // namespace test | 828 } // namespace test |
| 834 } // namespace webrtc | 829 } // namespace webrtc |
| OLD | NEW |