From 5b91464edf51354dd3f4475b8e0bb23357bd8511 Mon Sep 17 00:00:00 2001 From: "stefan@webrtc.org" Date: Mon, 3 Oct 2011 10:26:12 +0000 Subject: [PATCH] Allow an aggregated partition to spill over to a new packet. Adds support for the case where the partition 0 and parts of partition 1 are transmitted in packet 1, and the end of partition 2 is transmitted in packet 2. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/181003 git-svn-id: http://webrtc.googlecode.com/svn/trunk@675 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../video_coding/main/source/session_info.cc | 3 +- .../main/source/session_info_unittest.cc | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/modules/video_coding/main/source/session_info.cc b/src/modules/video_coding/main/source/session_info.cc index ebe7f440e6..d7d0386b5d 100644 --- a/src/modules/video_coding/main/source/session_info.cc +++ b/src/modules/video_coding/main/source/session_info.cc @@ -389,7 +389,8 @@ int VCMSessionInfo::FindPartitionEnd(int packet_index) const { _packets[packet_index - 1].seqNum))); const int current_partition_id = _packets[packet_index].codecSpecificHeader. codecHeader.VP8.partitionId; - if (packet_loss_found || current_partition_id != partition_id) { + if (packet_loss_found || (beginning && + current_partition_id != partition_id)) { // Missing packet, the previous packet was the last in sequence. return packet_index - 1; } diff --git a/src/modules/video_coding/main/source/session_info_unittest.cc b/src/modules/video_coding/main/source/session_info_unittest.cc index 8e94827492..495b972fd7 100644 --- a/src/modules/video_coding/main/source/session_info_unittest.cc +++ b/src/modules/video_coding/main/source/session_info_unittest.cc @@ -413,3 +413,52 @@ TEST_F(TestVP8MakeDecodable, ThreePartitionsLossInSecond) { SCOPED_TRACE("Calling VerifyPartition"); EXPECT_TRUE(VerifyPartition(2, 2, 6)); } + +TEST_F(TestVP8MakeDecodable, AggregationOverTwoPackets) { + // Partition 0 | Partition 1 | Partition 2 + // [ 0 | ] [ 1 ] | [ 2 ] + packet_header_.type.Video.isFirstPacket = true; + vp8_header_->beginningOfPartition = true; + vp8_header_->partitionId = 0; + packet_header_.header.markerBit = false; + packet_header_.header.sequenceNumber = 0; + FillPacket(0); + VCMPacket* packet = new VCMPacket(packet_buffer_, kPacketBufferSize, + packet_header_); + session_.SetStartSeqNumber(packet_header_.header.sequenceNumber); + ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_), kPacketBufferSize); + delete packet; + + packet_header_.type.Video.isFirstPacket = false; + vp8_header_->partitionId = 1; + vp8_header_->beginningOfPartition = false; + packet_header_.header.markerBit = false; + packet_header_.header.sequenceNumber += 1; + FillPacket(1); + packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); + ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_), kPacketBufferSize); + delete packet; + + packet_header_.type.Video.isFirstPacket = false; + vp8_header_->partitionId = 2; + vp8_header_->beginningOfPartition = true; + packet_header_.header.markerBit = true; + packet_header_.header.sequenceNumber += 1; + FillPacket(2); + packet = new VCMPacket(packet_buffer_, kPacketBufferSize, packet_header_); + ASSERT_EQ(session_.InsertPacket(*packet, frame_buffer_), kPacketBufferSize); + delete packet; + + // One packet should be removed (end of partition 0). + ASSERT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_, + kFrameBufferSize, + &fragmentation_), + 3*kPacketBufferSize); + SCOPED_TRACE("Calling VerifyPartition"); + EXPECT_TRUE(VerifyPartition(0, 2, 0)); + // This partition is aggregated in partition 0 + SCOPED_TRACE("Calling VerifyPartition"); + EXPECT_TRUE(VerifyPartition(1, 0, 0)); + SCOPED_TRACE("Calling VerifyPartition"); + EXPECT_TRUE(VerifyPartition(2, 1, 2)); +}