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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 false); | 644 false); |
645 send_bucket_->InsertPacket(PacedSender::kHighPriority, ssrc_high_priority, | 645 send_bucket_->InsertPacket(PacedSender::kHighPriority, ssrc_high_priority, |
646 sequence_number++, second_capture_time_ms, 250, | 646 sequence_number++, second_capture_time_ms, 250, |
647 false); | 647 false); |
648 } | 648 } |
649 | 649 |
650 // Expect everything to be queued. | 650 // Expect everything to be queued. |
651 EXPECT_EQ(second_capture_time_ms - capture_time_ms, | 651 EXPECT_EQ(second_capture_time_ms - capture_time_ms, |
652 send_bucket_->QueueInMs()); | 652 send_bucket_->QueueInMs()); |
653 | 653 |
654 for (int i = 0; i < 10; ++i) { | 654 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
655 clock_.AdvanceTimeMilliseconds(5); | 655 EXPECT_CALL(callback_, TimeToSendPadding(1, _)).Times(1); |
| 656 send_bucket_->Process(); |
| 657 |
| 658 int64_t expected_time_until_send = 500; |
| 659 EXPECT_CALL(callback_, TimeToSendPadding(1, _)).Times(1); |
| 660 while (expected_time_until_send >= 0) { |
656 // TimeUntilNextProcess must not return 0 when paused. If it does, | 661 // TimeUntilNextProcess must not return 0 when paused. If it does, |
657 // we risk running a busy loop, so ideally it should return a large value. | 662 // we risk running a busy loop, so ideally it should return a large value. |
658 EXPECT_GE(send_bucket_->TimeUntilNextProcess(), 1000); | 663 EXPECT_EQ(expected_time_until_send, send_bucket_->TimeUntilNextProcess()); |
659 send_bucket_->Process(); | 664 if (expected_time_until_send == 0) |
| 665 send_bucket_->Process(); |
| 666 clock_.AdvanceTimeMilliseconds(5); |
| 667 expected_time_until_send -= 5; |
660 } | 668 } |
661 | 669 |
662 // Expect high prio packets to come out first followed by normal | 670 // Expect high prio packets to come out first followed by normal |
663 // prio packets and low prio packets (all in capture order). | 671 // prio packets and low prio packets (all in capture order). |
664 { | 672 { |
665 ::testing::InSequence sequence; | 673 ::testing::InSequence sequence; |
666 EXPECT_CALL(callback_, | 674 EXPECT_CALL(callback_, |
667 TimeToSendPacket(ssrc_high_priority, _, capture_time_ms, _, _)) | 675 TimeToSendPacket(ssrc_high_priority, _, capture_time_ms, _, _)) |
668 .Times(packets_to_send_per_interval) | 676 .Times(packets_to_send_per_interval) |
669 .WillRepeatedly(Return(true)); | 677 .WillRepeatedly(Return(true)); |
(...skipping 22 matching lines...) Expand all Loading... |
692 for (size_t i = 0; i < packets_to_send_per_interval; ++i) { | 700 for (size_t i = 0; i < packets_to_send_per_interval; ++i) { |
693 EXPECT_CALL(callback_, TimeToSendPacket(ssrc_low_priority, _, | 701 EXPECT_CALL(callback_, TimeToSendPacket(ssrc_low_priority, _, |
694 second_capture_time_ms, _, _)) | 702 second_capture_time_ms, _, _)) |
695 .Times(1) | 703 .Times(1) |
696 .WillRepeatedly(Return(true)); | 704 .WillRepeatedly(Return(true)); |
697 } | 705 } |
698 } | 706 } |
699 send_bucket_->Resume(); | 707 send_bucket_->Resume(); |
700 | 708 |
701 for (size_t i = 0; i < 4; i++) { | 709 for (size_t i = 0; i < 4; i++) { |
| 710 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 711 send_bucket_->Process(); |
702 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 712 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
703 clock_.AdvanceTimeMilliseconds(5); | 713 clock_.AdvanceTimeMilliseconds(5); |
704 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | |
705 send_bucket_->Process(); | |
706 } | 714 } |
707 | 715 |
708 EXPECT_EQ(0, send_bucket_->QueueInMs()); | 716 EXPECT_EQ(0, send_bucket_->QueueInMs()); |
709 } | 717 } |
710 | 718 |
711 TEST_F(PacedSenderTest, ResendPacket) { | 719 TEST_F(PacedSenderTest, ResendPacket) { |
712 uint32_t ssrc = 12346; | 720 uint32_t ssrc = 12346; |
713 uint16_t sequence_number = 1234; | 721 uint16_t sequence_number = 1234; |
714 int64_t capture_time_ms = clock_.TimeInMilliseconds(); | 722 int64_t capture_time_ms = clock_.TimeInMilliseconds(); |
715 EXPECT_EQ(0, send_bucket_->QueueInMs()); | 723 EXPECT_EQ(0, send_bucket_->QueueInMs()); |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 .WillRepeatedly(Return(0)); | 1097 .WillRepeatedly(Return(0)); |
1090 send_bucket_->Process(); | 1098 send_bucket_->Process(); |
1091 EXPECT_EQ(1, send_bucket_->TimeUntilNextProcess()); | 1099 EXPECT_EQ(1, send_bucket_->TimeUntilNextProcess()); |
1092 clock_.AdvanceTimeMilliseconds(1); | 1100 clock_.AdvanceTimeMilliseconds(1); |
1093 send_bucket_->Process(); | 1101 send_bucket_->Process(); |
1094 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 1102 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
1095 } | 1103 } |
1096 | 1104 |
1097 } // namespace test | 1105 } // namespace test |
1098 } // namespace webrtc | 1106 } // namespace webrtc |
OLD | NEW |