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 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 .Times(1) | 854 .Times(1) |
855 .WillRepeatedly(Return(true)); | 855 .WillRepeatedly(Return(true)); |
856 for (int i = 0; i < 3; ++i) { | 856 for (int i = 0; i < 3; ++i) { |
857 clock_.AdvanceTimeMilliseconds(30); // Max delta. | 857 clock_.AdvanceTimeMilliseconds(30); // Max delta. |
858 send_bucket_->Process(); | 858 send_bucket_->Process(); |
859 } | 859 } |
860 | 860 |
861 EXPECT_EQ(0, send_bucket_->AverageQueueTimeMs()); | 861 EXPECT_EQ(0, send_bucket_->AverageQueueTimeMs()); |
862 } | 862 } |
863 | 863 |
| 864 TEST_F(PacedSenderTest, CanSendMorePackets) { |
| 865 uint32_t ssrc = 12346; |
| 866 uint16_t sequence_number = 1234; |
| 867 EXPECT_TRUE(send_bucket_->CanSendMorePackets()); |
| 868 send_bucket_->Pause(); |
| 869 EXPECT_FALSE(send_bucket_->CanSendMorePackets()); |
| 870 send_bucket_->Resume(); |
| 871 EXPECT_TRUE(send_bucket_->CanSendMorePackets()); |
| 872 |
| 873 const size_t packets_to_fill_send_queue = |
| 874 kTargetBitrateBps * PacedSender::kDefaultPaceMultiplier * |
| 875 PacedSender::kMaxQueueLengthMs / (8 * 1000 * 1000); |
| 876 |
| 877 const size_t packets_to_send_per_interval = |
| 878 kTargetBitrateBps * PacedSender::kDefaultPaceMultiplier / |
| 879 (8 * 1000 * 200) + |
| 880 1; // One more than expected due to rounding. |
| 881 // Packets send during one interval. |
| 882 for (size_t i = 0; i < packets_to_send_per_interval; ++i) { |
| 883 SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++, |
| 884 clock_.TimeInMilliseconds(), 1000, false); |
| 885 } |
| 886 |
| 887 for (size_t i = 0; |
| 888 i < packets_to_fill_send_queue - packets_to_send_per_interval - 1; ++i) { |
| 889 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, |
| 890 sequence_number++, clock_.TimeInMilliseconds(), |
| 891 1000, false); |
| 892 } |
| 893 EXPECT_TRUE(send_bucket_->CanSendMorePackets()); |
| 894 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, |
| 895 sequence_number++, clock_.TimeInMilliseconds(), |
| 896 1000, false); |
| 897 EXPECT_FALSE(send_bucket_->CanSendMorePackets()); |
| 898 send_bucket_->Process(); |
| 899 EXPECT_TRUE(send_bucket_->CanSendMorePackets()); |
| 900 } |
| 901 |
864 } // namespace test | 902 } // namespace test |
865 } // namespace webrtc | 903 } // namespace webrtc |
OLD | NEW |