OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 ByteWriter<uint16_t>::WriteBigEndian( | 447 ByteWriter<uint16_t>::WriteBigEndian( |
448 &mod_buffer[2], ByteReader<uint16_t>::ReadBigEndian(&mod_buffer[2]) + | 448 &mod_buffer[2], ByteReader<uint16_t>::ReadBigEndian(&mod_buffer[2]) + |
449 ((kPaddingBytes + 3) / 4)); | 449 ((kPaddingBytes + 3) / 4)); |
450 | 450 |
451 rtc::scoped_ptr<TransportFeedback> parsed_packet( | 451 rtc::scoped_ptr<TransportFeedback> parsed_packet( |
452 TransportFeedback::ParseFrom(mod_buffer, kExpectedSizeWithPadding)); | 452 TransportFeedback::ParseFrom(mod_buffer, kExpectedSizeWithPadding)); |
453 ASSERT_TRUE(parsed_packet.get() != nullptr); | 453 ASSERT_TRUE(parsed_packet.get() != nullptr); |
454 EXPECT_EQ(kExpectedSizeWords * 4, packet->Length()); // Padding not included. | 454 EXPECT_EQ(kExpectedSizeWords * 4, packet->Length()); // Padding not included. |
455 } | 455 } |
456 | 456 |
| 457 TEST(RtcpPacketTest, TransportFeedback_CorrectlySplitsVectorChunks) { |
| 458 const int kOneBitVectorCapacity = 14; |
| 459 const int64_t kLargeTimeDelta = |
| 460 TransportFeedback::kDeltaScaleFactor * (1 << 8); |
| 461 |
| 462 // Test that a number of small deltas followed by a large delta results in a |
| 463 // correct split into multiple chunks, as needed. |
| 464 |
| 465 for (int deltas = 0; deltas <= kOneBitVectorCapacity + 1; ++deltas) { |
| 466 TransportFeedback feedback; |
| 467 feedback.WithBase(0, 0); |
| 468 for (int i = 0; i < deltas; ++i) |
| 469 feedback.WithReceivedPacket(i, i * 1000); |
| 470 feedback.WithReceivedPacket(deltas, deltas * 1000 + kLargeTimeDelta); |
| 471 |
| 472 rtc::scoped_ptr<rtcp::RawPacket> serialized_packet = feedback.Build(); |
| 473 EXPECT_TRUE(serialized_packet.get() != nullptr); |
| 474 rtc::scoped_ptr<TransportFeedback> deserialized_packet = |
| 475 TransportFeedback::ParseFrom(serialized_packet->Buffer(), |
| 476 serialized_packet->Length()); |
| 477 EXPECT_TRUE(deserialized_packet.get() != nullptr); |
| 478 } |
| 479 } |
| 480 |
457 } // namespace | 481 } // namespace |
458 } // namespace webrtc | 482 } // namespace webrtc |
OLD | NEW |