| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, sequence_number, | 129 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, sequence_number, |
| 130 capture_time_ms, retransmission, _)) | 130 capture_time_ms, retransmission, _)) |
| 131 .Times(1) | 131 .Times(1) |
| 132 .WillRepeatedly(Return(true)); | 132 .WillRepeatedly(Return(true)); |
| 133 } | 133 } |
| 134 SimulatedClock clock_; | 134 SimulatedClock clock_; |
| 135 MockPacedSenderCallback callback_; | 135 MockPacedSenderCallback callback_; |
| 136 std::unique_ptr<PacedSender> send_bucket_; | 136 std::unique_ptr<PacedSender> send_bucket_; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 TEST_F(PacedSenderTest, FirstSentPacketTimeIsSet) { |
| 140 uint16_t sequence_number = 1234; |
| 141 const uint32_t kSsrc = 12345; |
| 142 const size_t kSizeBytes = 250; |
| 143 const size_t kPacketToSend = 3; |
| 144 const int64_t kStartMs = clock_.TimeInMilliseconds(); |
| 145 |
| 146 // No packet sent. |
| 147 EXPECT_EQ(-1, send_bucket_->FirstSentPacketTimeMs()); |
| 148 |
| 149 for (size_t i = 0; i < kPacketToSend; ++i) { |
| 150 SendAndExpectPacket(PacedSender::kNormalPriority, kSsrc, sequence_number++, |
| 151 clock_.TimeInMilliseconds(), kSizeBytes, false); |
| 152 send_bucket_->Process(); |
| 153 clock_.AdvanceTimeMilliseconds(send_bucket_->TimeUntilNextProcess()); |
| 154 } |
| 155 EXPECT_EQ(kStartMs, send_bucket_->FirstSentPacketTimeMs()); |
| 156 } |
| 157 |
| 139 TEST_F(PacedSenderTest, QueuePacket) { | 158 TEST_F(PacedSenderTest, QueuePacket) { |
| 140 uint32_t ssrc = 12345; | 159 uint32_t ssrc = 12345; |
| 141 uint16_t sequence_number = 1234; | 160 uint16_t sequence_number = 1234; |
| 142 // Due to the multiplicative factor we can send 5 packets during a send | 161 // Due to the multiplicative factor we can send 5 packets during a send |
| 143 // interval. (network capacity * multiplier / (8 bits per byte * | 162 // interval. (network capacity * multiplier / (8 bits per byte * |
| 144 // (packet size * #send intervals per second) | 163 // (packet size * #send intervals per second) |
| 145 const size_t packets_to_send = | 164 const size_t packets_to_send = |
| 146 kTargetBitrateBps * PacedSender::kDefaultPaceMultiplier / (8 * 250 * 200); | 165 kTargetBitrateBps * PacedSender::kDefaultPaceMultiplier / (8 * 250 * 200); |
| 147 for (size_t i = 0; i < packets_to_send; ++i) { | 166 for (size_t i = 0; i < packets_to_send; ++i) { |
| 148 SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++, | 167 SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++, |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 .WillRepeatedly(Return(0)); | 1089 .WillRepeatedly(Return(0)); |
| 1071 send_bucket_->Process(); | 1090 send_bucket_->Process(); |
| 1072 EXPECT_EQ(1, send_bucket_->TimeUntilNextProcess()); | 1091 EXPECT_EQ(1, send_bucket_->TimeUntilNextProcess()); |
| 1073 clock_.AdvanceTimeMilliseconds(1); | 1092 clock_.AdvanceTimeMilliseconds(1); |
| 1074 send_bucket_->Process(); | 1093 send_bucket_->Process(); |
| 1075 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); | 1094 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); |
| 1076 } | 1095 } |
| 1077 | 1096 |
| 1078 } // namespace test | 1097 } // namespace test |
| 1079 } // namespace webrtc | 1098 } // namespace webrtc |
| OLD | NEW |