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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 fake_clock_.AdvanceTimeMilliseconds(100); | 214 fake_clock_.AdvanceTimeMilliseconds(100); |
215 | 215 |
216 // Retransmit all packets currently in buffer. | 216 // Retransmit all packets currently in buffer. |
217 for (size_t i = 1; i < RtpPacketHistory::kMaxCapacity + 1; ++i) { | 217 for (size_t i = 1; i < RtpPacketHistory::kMaxCapacity + 1; ++i) { |
218 EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kSeqNum + i, 100, false)); | 218 EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kSeqNum + i, 100, false)); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
| 222 TEST_F(RtpPacketHistoryTest, GetBestFittingPacket) { |
| 223 constexpr size_t kMinPacketRequestBytes = 50; |
| 224 |
| 225 hist_.SetStorePacketsStatus(true, 3); |
| 226 |
| 227 std::unique_ptr<RtpPacketToSend> packet = CreateRtpPacket(kSeqNum); |
| 228 const size_t header_size = packet->headers_size(); |
| 229 const int64_t start_time_ms = fake_clock_.TimeInMilliseconds(); |
| 230 |
| 231 packet->AllocatePayload(kMinPacketRequestBytes - header_size); |
| 232 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
| 233 |
| 234 fake_clock_.AdvanceTimeMilliseconds(1); |
| 235 |
| 236 packet = CreateRtpPacket(kSeqNum + 1); |
| 237 packet->AllocatePayload(kMinPacketRequestBytes); |
| 238 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
| 239 |
| 240 fake_clock_.AdvanceTimeMilliseconds(1); |
| 241 |
| 242 packet = CreateRtpPacket(kSeqNum + 2); |
| 243 packet->AllocatePayload(kMinPacketRequestBytes + header_size); |
| 244 hist_.PutRtpPacket(std::move(packet), kAllowRetransmission, false); |
| 245 |
| 246 constexpr bool kIncludeHeader = true; |
| 247 std::unique_ptr<RtpPacketToSend> fit = |
| 248 hist_.GetBestFittingPacket(kMinPacketRequestBytes, kIncludeHeader); |
| 249 ASSERT_TRUE(fit); |
| 250 EXPECT_EQ(start_time_ms, fit->capture_time_ms()); |
| 251 |
| 252 fit = hist_.GetBestFittingPacket(kMinPacketRequestBytes, !kIncludeHeader); |
| 253 ASSERT_TRUE(fit); |
| 254 EXPECT_EQ(start_time_ms + 1, fit->capture_time_ms()); |
| 255 } |
| 256 |
222 } // namespace webrtc | 257 } // namespace webrtc |
OLD | NEW |