Index: webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc |
index 0e1a474e35a47b8af7988b77214651b6090546ee..1c59f8954e88418f2e642c5bf6631462f8eeb5c0 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc |
@@ -107,16 +107,15 @@ TEST_F(RtpPacketizerVp8Test, TestStrictMode) { |
hdr_info_.pictureId = 200; // > 0x7F should produce 2-byte PictureID. |
const size_t kMaxPayloadSize = 13; |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kStrict); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kStrict); |
packetizer.SetPayloadData(helper_->payload_data(), |
helper_->payload_size(), |
helper_->fragmentation()); |
// The expected sizes are obtained by running a verified good implementation. |
- const size_t kExpectedSizes[] = {9, 9, 12, 11, 11, 11, 10}; |
- const int kExpectedPart[] = {0, 0, 1, 2, 2, 2, 2}; |
- const bool kExpectedFragStart[] = {true, false, true, true, |
- false, false, false}; |
+ const size_t kExpectedSizes[] = {9, 9, 12, 13, 13, 13}; |
+ const int kExpectedPart[] = {0, 0, 1, 2, 2, 2}; |
+ const bool kExpectedFragStart[] = {true, false, true, true, false, false}; |
const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); |
CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); |
CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); |
@@ -138,7 +137,7 @@ TEST_F(RtpPacketizerVp8Test, DISABLED_TestStrictEqualTightPartitions) { |
hdr_info_.pictureId = 200; // > 0x7F should produce 2-byte PictureID. |
const int kMaxPayloadSize = 14; |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kStrict); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kStrict); |
packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), |
helper_->fragmentation()); |
@@ -161,7 +160,7 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateMode) { |
hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. |
const size_t kMaxPayloadSize = 25; |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kAggregate); |
packetizer.SetPayloadData(helper_->payload_data(), |
helper_->payload_size(), |
helper_->fragmentation()); |
@@ -181,6 +180,75 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateMode) { |
kExpectedNum); |
} |
+TEST_F(RtpPacketizerVp8Test, TestAggregateModeExtentionNotFits) { |
+ const size_t kSizeVector[] = {60, 10, 10}; |
+ const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); |
+ ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); |
+ |
+ hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. |
+ const size_t kMaxPayloadSize = 25; |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 5, kAggregate); |
+ packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), |
+ helper_->fragmentation()); |
+ |
+ // The expected sizes are obtained by running a verified good implementation. |
+ const size_t kExpectedSizes[] = {23, 23, 23, 13, 13}; |
+ const int kExpectedPart[] = {0, 0, 0, 1, 2}; |
+ const bool kExpectedFragStart[] = {true, false, false, true, true}; |
+ const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); |
+ CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); |
+ CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); |
+ |
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, |
+ kExpectedFragStart, kExpectedNum); |
+} |
+ |
+TEST_F(RtpPacketizerVp8Test, TestAggregateModeExtentionFits) { |
+ const size_t kSizeVector[] = {60, 10, 10}; |
+ const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); |
+ ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); |
+ |
+ hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. |
+ const size_t kMaxPayloadSize = 25; |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 1, kAggregate); |
+ packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), |
+ helper_->fragmentation()); |
+ |
+ // The expected sizes are obtained by running a verified good implementation. |
+ const size_t kExpectedSizes[] = {23, 23, 23, 23}; |
+ const int kExpectedPart[] = {0, 0, 0, 1}; |
+ const bool kExpectedFragStart[] = {true, false, false, true}; |
+ const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); |
+ CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); |
+ CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); |
+ |
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, |
+ kExpectedFragStart, kExpectedNum); |
+} |
+ |
+TEST_F(RtpPacketizerVp8Test, TestAggregateModeSmallPartitions) { |
+ const size_t kSizeVector[] = {3, 4, 2, 5, 2, 4}; |
+ const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); |
+ ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); |
+ |
+ hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. |
+ const size_t kMaxPayloadSize = 13; |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kAggregate); |
+ packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), |
+ helper_->fragmentation()); |
+ |
+ // The expected sizes are obtained by running a verified good implementation. |
+ const size_t kExpectedSizes[] = {10, 10, 9}; |
+ const int kExpectedPart[] = {0, 2, 4}; |
+ const bool kExpectedFragStart[] = {true, true, true}; |
+ const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); |
+ CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); |
+ CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); |
+ |
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, |
+ kExpectedFragStart, kExpectedNum); |
+} |
+ |
TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions1) { |
const size_t kSizeVector[] = {1600, 200, 200, 200, 200, 200, 200, 200, 200}; |
const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); |
@@ -188,7 +256,7 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions1) { |
hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. |
const size_t kMaxPayloadSize = 1000; |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kAggregate); |
packetizer.SetPayloadData(helper_->payload_data(), |
helper_->payload_size(), |
helper_->fragmentation()); |
@@ -215,7 +283,7 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions2) { |
hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. |
const size_t kMaxPayloadSize = 1000; |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kAggregate); |
packetizer.SetPayloadData(helper_->payload_data(), |
helper_->payload_size(), |
helper_->fragmentation()); |
@@ -242,7 +310,7 @@ TEST_F(RtpPacketizerVp8Test, TestAggregateModeTwoLargePartitions) { |
hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID. |
const size_t kMaxPayloadSize = 1460; |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kAggregate); |
packetizer.SetPayloadData(helper_->payload_data(), |
helper_->payload_size(), |
helper_->fragmentation()); |
@@ -270,12 +338,12 @@ TEST_F(RtpPacketizerVp8Test, TestEqualSizeModeFallback) { |
hdr_info_.pictureId = 200; // > 0x7F should produce 2-byte PictureID |
const size_t kMaxPayloadSize = 12; // Small enough to produce 4 packets. |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0); |
packetizer.SetPayloadData( |
helper_->payload_data(), helper_->payload_size(), NULL); |
// Expecting three full packets, and one with the remainder. |
- const size_t kExpectedSizes[] = {12, 11, 12, 11}; |
+ const size_t kExpectedSizes[] = {12, 12, 11, 11}; |
const int kExpectedPart[] = {0, 0, 0, 0}; // Always 0 for equal size mode. |
// Frag start only true for first packet in equal size mode. |
const bool kExpectedFragStart[] = {true, false, false, false}; |
@@ -291,6 +359,31 @@ TEST_F(RtpPacketizerVp8Test, TestEqualSizeModeFallback) { |
kExpectedNum); |
} |
+TEST_F(RtpPacketizerVp8Test, TestEqualSizeWithExtention) { |
+ const size_t kSizeVector[] = {30, 10, 3}; |
+ const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector); |
+ ASSERT_TRUE(Init(kSizeVector, kNumPartitions)); |
+ |
+ hdr_info_.pictureId = 200; // > 0x7F should produce 2-byte PictureID |
+ const size_t kMaxPayloadSize = 15; // Small enough to produce 5 packets. |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 5); |
+ packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(), |
+ NULL); |
+ |
+ // Expecting three full packets, and one with the remainder. |
+ const size_t kExpectedSizes[] = {14, 14, 14, 13, 8}; |
+ const int kExpectedPart[] = {0, 0, 0, 0, 0}; // Always 0 for equal size mode. |
+ // Frag start only true for first packet in equal size mode. |
+ const bool kExpectedFragStart[] = {true, false, false, false, false}; |
+ const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes); |
+ CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart); |
+ CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart); |
+ |
+ helper_->set_sloppy_partitioning(true); |
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart, |
+ kExpectedFragStart, kExpectedNum); |
+} |
+ |
// Verify that non-reference bit is set. EqualSize mode fallback is expected. |
TEST_F(RtpPacketizerVp8Test, TestNonReferenceBit) { |
const size_t kSizeVector[] = {10, 10, 10}; |
@@ -299,7 +392,7 @@ TEST_F(RtpPacketizerVp8Test, TestNonReferenceBit) { |
hdr_info_.nonReference = true; |
const size_t kMaxPayloadSize = 25; // Small enough to produce two packets. |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0); |
packetizer.SetPayloadData( |
helper_->payload_data(), helper_->payload_size(), NULL); |
@@ -331,7 +424,7 @@ TEST_F(RtpPacketizerVp8Test, TestTl0PicIdxAndTID) { |
hdr_info_.layerSync = true; |
// kMaxPayloadSize is only limited by allocated buffer size. |
const size_t kMaxPayloadSize = helper_->buffer_size(); |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kAggregate); |
packetizer.SetPayloadData(helper_->payload_data(), |
helper_->payload_size(), |
helper_->fragmentation()); |
@@ -360,7 +453,7 @@ TEST_F(RtpPacketizerVp8Test, TestKeyIdx) { |
hdr_info_.keyIdx = 17; |
// kMaxPayloadSize is only limited by allocated buffer size. |
const size_t kMaxPayloadSize = helper_->buffer_size(); |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kAggregate); |
packetizer.SetPayloadData(helper_->payload_data(), |
helper_->payload_size(), |
helper_->fragmentation()); |
@@ -390,7 +483,7 @@ TEST_F(RtpPacketizerVp8Test, TestTIDAndKeyIdx) { |
hdr_info_.keyIdx = 5; |
// kMaxPayloadSize is only limited by allocated buffer size. |
const size_t kMaxPayloadSize = helper_->buffer_size(); |
- RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate); |
+ RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, 0, kAggregate); |
packetizer.SetPayloadData(helper_->payload_data(), |
helper_->payload_size(), |
helper_->fragmentation()); |
@@ -579,11 +672,10 @@ TEST_F(RtpDepacketizerVp8Test, TestWithPacketizer) { |
input_header.layerSync = false; |
input_header.tl0PicIdx = kNoTl0PicIdx; // Disable. |
input_header.keyIdx = 31; |
- RtpPacketizerVp8 packetizer(input_header, 20); |
+ RtpPacketizerVp8 packetizer(input_header, 20, 0); |
packetizer.SetPayloadData(data, 10, NULL); |
- bool last; |
- ASSERT_TRUE(packetizer.NextPacket(&packet, &last)); |
- EXPECT_TRUE(last); |
+ EXPECT_EQ(packetizer.TotalPackets(), 1u); |
+ ASSERT_TRUE(packetizer.NextPacket(&packet)); |
EXPECT_TRUE(packet.Marker()); |
auto rtp_payload = packet.payload(); |