| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 void SendAndExpectPacket(PacedSender::Priority priority, | 122 void SendAndExpectPacket(PacedSender::Priority priority, |
| 123 uint32_t ssrc, | 123 uint32_t ssrc, |
| 124 uint16_t sequence_number, | 124 uint16_t sequence_number, |
| 125 int64_t capture_time_ms, | 125 int64_t capture_time_ms, |
| 126 size_t size, | 126 size_t size, |
| 127 bool retransmission) { | 127 bool retransmission) { |
| 128 send_bucket_->InsertPacket(priority, ssrc, sequence_number, capture_time_ms, | 128 send_bucket_->InsertPacket(priority, ssrc, sequence_number, capture_time_ms, |
| 129 size, retransmission); | 129 size, retransmission); |
| 130 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, sequence_number, | 130 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, sequence_number, |
| 131 capture_time_ms, false, _)) | 131 capture_time_ms, retransmission, _)) |
| 132 .Times(1) | 132 .Times(1) |
| 133 .WillRepeatedly(Return(true)); | 133 .WillRepeatedly(Return(true)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 SimulatedClock clock_; | 136 SimulatedClock clock_; |
| 137 MockPacedSenderCallback callback_; | 137 MockPacedSenderCallback callback_; |
| 138 std::unique_ptr<PacedSender> send_bucket_; | 138 std::unique_ptr<PacedSender> send_bucket_; |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 TEST_F(PacedSenderTest, QueuePacket) { | 141 TEST_F(PacedSenderTest, QueuePacket) { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 capture_time_ms_low_priority, false, _)) | 486 capture_time_ms_low_priority, false, _)) |
| 487 .Times(1) | 487 .Times(1) |
| 488 .WillRepeatedly(Return(true)); | 488 .WillRepeatedly(Return(true)); |
| 489 | 489 |
| 490 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 490 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 491 clock_.AdvanceTimeMilliseconds(5); | 491 clock_.AdvanceTimeMilliseconds(5); |
| 492 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); | 492 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 493 send_bucket_->Process(); | 493 send_bucket_->Process(); |
| 494 } | 494 } |
| 495 | 495 |
| 496 TEST_F(PacedSenderTest, RetransmissionPriority) { |
| 497 uint32_t ssrc = 12345; |
| 498 uint16_t sequence_number = 1234; |
| 499 int64_t capture_time_ms = 45678; |
| 500 int64_t capture_time_ms_retransmission = 56789; |
| 501 |
| 502 // Due to the multiplicative factor we can send 5 packets during a send |
| 503 // interval. (network capacity * multiplier / (8 bits per byte * |
| 504 // (packet size * #send intervals per second) |
| 505 const size_t packets_to_send_per_interval = |
| 506 kTargetBitrateBps * PacedSender::kDefaultPaceMultiplier / (8 * 250 * 200); |
| 507 send_bucket_->Process(); |
| 508 EXPECT_EQ(0u, send_bucket_->QueueSizePackets()); |
| 509 |
| 510 // Alternate retransmissions and normal packets. |
| 511 for (size_t i = 0; i < packets_to_send_per_interval; ++i) { |
| 512 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, |
| 513 sequence_number++, |
| 514 capture_time_ms_retransmission, 250, true); |
| 515 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, |
| 516 sequence_number++, capture_time_ms, 250, false); |
| 517 } |
| 518 EXPECT_EQ(2 * packets_to_send_per_interval, send_bucket_->QueueSizePackets()); |
| 519 |
| 520 // Expect all retransmissions to be sent out first despite having a later |
| 521 // capture time. |
| 522 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0); |
| 523 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, false, _)).Times(0); |
| 524 EXPECT_CALL(callback_, TimeToSendPacket( |
| 525 ssrc, _, capture_time_ms_retransmission, true, _)) |
| 526 .Times(packets_to_send_per_interval) |
| 527 .WillRepeatedly(Return(true)); |
| 528 |
| 529 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 530 clock_.AdvanceTimeMilliseconds(5); |
| 531 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 532 send_bucket_->Process(); |
| 533 EXPECT_EQ(packets_to_send_per_interval, send_bucket_->QueueSizePackets()); |
| 534 |
| 535 // Expect the remaining (non-retransmission) packets to be sent. |
| 536 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0); |
| 537 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, true, _)).Times(0); |
| 538 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, capture_time_ms, false, _)) |
| 539 .Times(packets_to_send_per_interval) |
| 540 .WillRepeatedly(Return(true)); |
| 541 |
| 542 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 543 clock_.AdvanceTimeMilliseconds(5); |
| 544 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); |
| 545 send_bucket_->Process(); |
| 546 |
| 547 EXPECT_EQ(0u, send_bucket_->QueueSizePackets()); |
| 548 } |
| 549 |
| 496 TEST_F(PacedSenderTest, HighPrioDoesntAffectBudget) { | 550 TEST_F(PacedSenderTest, HighPrioDoesntAffectBudget) { |
| 497 uint32_t ssrc = 12346; | 551 uint32_t ssrc = 12346; |
| 498 uint16_t sequence_number = 1234; | 552 uint16_t sequence_number = 1234; |
| 499 int64_t capture_time_ms = 56789; | 553 int64_t capture_time_ms = 56789; |
| 500 | 554 |
| 501 // As high prio packets doesn't affect the budget, we should be able to send | 555 // As high prio packets doesn't affect the budget, we should be able to send |
| 502 // a high number of them at once. | 556 // a high number of them at once. |
| 503 for (int i = 0; i < 25; ++i) { | 557 for (int i = 0; i < 25; ++i) { |
| 504 SendAndExpectPacket(PacedSender::kHighPriority, ssrc, sequence_number++, | 558 SendAndExpectPacket(PacedSender::kHighPriority, ssrc, sequence_number++, |
| 505 capture_time_ms, 250, false); | 559 capture_time_ms, 250, false); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 | 983 |
| 930 // No more probing packets. | 984 // No more probing packets. |
| 931 EXPECT_CALL(callback_, TimeToSendPadding(_, PacketInfo::kNotAProbe)) | 985 EXPECT_CALL(callback_, TimeToSendPadding(_, PacketInfo::kNotAProbe)) |
| 932 .Times(1) | 986 .Times(1) |
| 933 .WillRepeatedly(Return(500)); | 987 .WillRepeatedly(Return(500)); |
| 934 send_bucket_->Process(); | 988 send_bucket_->Process(); |
| 935 } | 989 } |
| 936 | 990 |
| 937 } // namespace test | 991 } // namespace test |
| 938 } // namespace webrtc | 992 } // namespace webrtc |
| OLD | NEW |