Delete unused support for vp8 partitions.

This also makes it possible to drop the RTPFragmentationHeader from
the class VCMEncodedFrame.

BUG=None

Review-Url: https://codereview.webrtc.org/2380933003
Cr-Commit-Position: refs/heads/master@{#14455}
This commit is contained in:
nisse
2016-09-30 03:43:00 -07:00
committed by Commit bot
parent 3cc47ebd2d
commit 6f112cc136
8 changed files with 2 additions and 590 deletions

View File

@ -433,13 +433,7 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
// drop support for libvpx 9.6.0.
break;
case kResilientFrames:
#ifdef INDEPENDENT_PARTITIONS
configurations_[0] - g_error_resilient =
VPX_ERROR_RESILIENT_DEFAULT | VPX_ERROR_RESILIENT_PARTITIONS;
break;
#else
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; // Not supported
#endif
}
// rate control settings
@ -1090,9 +1084,6 @@ int VP8DecoderImpl::InitDecode(const VideoCodec* inst, int number_of_cores) {
#if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \
!defined(ANDROID)
flags = VPX_CODEC_USE_POSTPROC;
#ifdef INDEPENDENT_PARTITIONS
flags |= VPX_CODEC_USE_INPUT_PARTITION;
#endif
#endif
if (vpx_codec_dec_init(decoder_, vpx_codec_vp8_dx(), &cfg, flags)) {
@ -1129,12 +1120,6 @@ int VP8DecoderImpl::Decode(const EncodedImage& input_image,
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
#ifdef INDEPENDENT_PARTITIONS
if (fragmentation == NULL) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
#endif
#if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \
!defined(ANDROID)
vp8_postproc_cfg_t ppcfg;
@ -1194,15 +1179,6 @@ int VP8DecoderImpl::Decode(const EncodedImage& input_image,
iter = NULL;
}
#ifdef INDEPENDENT_PARTITIONS
if (DecodePartitions(inputImage, fragmentation)) {
// Reset to avoid requesting key frames too often.
if (propagation_cnt_ > 0) {
propagation_cnt_ = 0;
}
return WEBRTC_VIDEO_CODEC_ERROR;
}
#else
uint8_t* buffer = input_image._buffer;
if (input_image._length == 0) {
buffer = NULL; // Triggers full frame concealment.
@ -1215,7 +1191,6 @@ int VP8DecoderImpl::Decode(const EncodedImage& input_image,
}
return WEBRTC_VIDEO_CODEC_ERROR;
}
#endif
img = vpx_codec_get_frame(decoder_, &iter);
ret = ReturnFrame(img, input_image._timeStamp, input_image.ntp_time_ms_);
@ -1276,25 +1251,6 @@ int VP8DecoderImpl::Decode(const EncodedImage& input_image,
return WEBRTC_VIDEO_CODEC_OK;
}
int VP8DecoderImpl::DecodePartitions(
const EncodedImage& input_image,
const RTPFragmentationHeader* fragmentation) {
for (int i = 0; i < fragmentation->fragmentationVectorSize; ++i) {
const uint8_t* partition =
input_image._buffer + fragmentation->fragmentationOffset[i];
const uint32_t partition_length = fragmentation->fragmentationLength[i];
if (vpx_codec_decode(decoder_, partition, partition_length, 0,
VPX_DL_REALTIME)) {
return WEBRTC_VIDEO_CODEC_ERROR;
}
}
// Signal end of frame data. If there was no frame data this will trigger
// a full frame concealment.
if (vpx_codec_decode(decoder_, NULL, 0, 0, VPX_DL_REALTIME))
return WEBRTC_VIDEO_CODEC_ERROR;
return WEBRTC_VIDEO_CODEC_OK;
}
int VP8DecoderImpl::ReturnFrame(const vpx_image_t* img,
uint32_t timestamp,
int64_t ntp_time_ms) {

View File

@ -21,7 +21,6 @@ VCMEncodedFrame::VCMEncodedFrame()
_payloadType(0),
_missingFrame(false),
_codec(kVideoCodecUnknown),
_fragmentation(),
_rotation_set(false) {
_codecSpecificInfo.codecType = kVideoCodecUnknown;
}
@ -32,7 +31,6 @@ VCMEncodedFrame::VCMEncodedFrame(const webrtc::EncodedImage& rhs)
_payloadType(0),
_missingFrame(false),
_codec(kVideoCodecUnknown),
_fragmentation(),
_rotation_set(false) {
_codecSpecificInfo.codecType = kVideoCodecUnknown;
_buffer = NULL;
@ -52,7 +50,6 @@ VCMEncodedFrame::VCMEncodedFrame(const VCMEncodedFrame& rhs)
_missingFrame(rhs._missingFrame),
_codecSpecificInfo(rhs._codecSpecificInfo),
_codec(rhs._codec),
_fragmentation(),
_rotation_set(rhs._rotation_set) {
_buffer = NULL;
_size = 0;
@ -63,7 +60,6 @@ VCMEncodedFrame::VCMEncodedFrame(const VCMEncodedFrame& rhs)
memcpy(_buffer, rhs._buffer, rhs._length);
_length = rhs._length;
}
_fragmentation.CopyFrom(rhs._fragmentation);
}
VCMEncodedFrame::~VCMEncodedFrame() {
@ -203,10 +199,6 @@ void VCMEncodedFrame::CopyCodecSpecific(const RTPVideoHeader* header) {
}
}
const RTPFragmentationHeader* VCMEncodedFrame::FragmentationHeader() const {
return &_fragmentation;
}
void VCMEncodedFrame::VerifyAndAllocate(size_t minimumSize) {
if (minimumSize > _size) {
// create buffer of sufficient size

View File

@ -96,8 +96,6 @@ class VCMEncodedFrame : protected EncodedImage {
*/
const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; }
const RTPFragmentationHeader* FragmentationHeader() const;
protected:
/**
* Verifies that current allocated buffer size is larger than or equal to the
@ -118,7 +116,6 @@ class VCMEncodedFrame : protected EncodedImage {
bool _missingFrame;
CodecSpecificInfo _codecSpecificInfo;
webrtc::VideoCodecType _codec;
RTPFragmentationHeader _fragmentation;
// Video rotation is only set along with the last packet for each frame
// (same as marker bit). This |_rotation_set| is only for debugging purpose

View File

@ -253,18 +253,8 @@ bool VCMFrameBuffer::IsRetransmitted() const {
}
void VCMFrameBuffer::PrepareForDecode(bool continuous) {
#ifdef INDEPENDENT_PARTITIONS
if (_codec == kVideoCodecVP8) {
_length = _sessionInfo.BuildVP8FragmentationHeader(_buffer, _length,
&_fragmentation);
} else {
size_t bytes_removed = _sessionInfo.MakeDecodable();
_length -= bytes_removed;
}
#else
size_t bytes_removed = _sessionInfo.MakeDecodable();
_length -= bytes_removed;
#endif
// Transfer frame information to EncodedFrame and create any codec
// specific information.
_frameType = _sessionInfo.FrameType();

View File

@ -149,8 +149,9 @@ int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
_callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
_nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
const RTPFragmentationHeader dummy_header;
int32_t ret = _decoder->Decode(frame.EncodedImage(), frame.MissingFrame(),
frame.FragmentationHeader(),
&dummy_header,
frame.CodecSpecific(), frame.RenderTimeMs());
_callback->OnDecoderImplementationName(_decoder->ImplementationName());

View File

@ -326,53 +326,6 @@ size_t VCMSessionInfo::DeletePacketData(PacketIterator start,
return bytes_to_delete;
}
size_t VCMSessionInfo::BuildVP8FragmentationHeader(
uint8_t* frame_buffer,
size_t frame_buffer_length,
RTPFragmentationHeader* fragmentation) {
size_t new_length = 0;
// Allocate space for max number of partitions
fragmentation->VerifyAndAllocateFragmentationHeader(kMaxVP8Partitions);
fragmentation->fragmentationVectorSize = 0;
memset(fragmentation->fragmentationLength, 0,
kMaxVP8Partitions * sizeof(size_t));
if (packets_.empty())
return new_length;
PacketIterator it = FindNextPartitionBeginning(packets_.begin());
while (it != packets_.end()) {
const int partition_id = (*it).video_header.codecHeader.VP8.partitionId;
PacketIterator partition_end = FindPartitionEnd(it);
fragmentation->fragmentationOffset[partition_id] =
(*it).dataPtr - frame_buffer;
assert(fragmentation->fragmentationOffset[partition_id] <
frame_buffer_length);
fragmentation->fragmentationLength[partition_id] =
(*partition_end).dataPtr + (*partition_end).sizeBytes - (*it).dataPtr;
assert(fragmentation->fragmentationLength[partition_id] <=
frame_buffer_length);
new_length += fragmentation->fragmentationLength[partition_id];
++partition_end;
it = FindNextPartitionBeginning(partition_end);
if (partition_id + 1 > fragmentation->fragmentationVectorSize)
fragmentation->fragmentationVectorSize = partition_id + 1;
}
// Set all empty fragments to start where the previous fragment ends,
// and have zero length.
if (fragmentation->fragmentationLength[0] == 0)
fragmentation->fragmentationOffset[0] = 0;
for (int i = 1; i < fragmentation->fragmentationVectorSize; ++i) {
if (fragmentation->fragmentationLength[i] == 0)
fragmentation->fragmentationOffset[i] =
fragmentation->fragmentationOffset[i - 1] +
fragmentation->fragmentationLength[i - 1];
assert(i == 0 ||
fragmentation->fragmentationOffset[i] >=
fragmentation->fragmentationOffset[i - 1]);
}
assert(new_length <= frame_buffer_length);
return new_length;
}
VCMSessionInfo::PacketIterator VCMSessionInfo::FindNextPartitionBeginning(
PacketIterator it) const {
while (it != packets_.end()) {

View File

@ -53,13 +53,6 @@ class VCMSessionInfo {
bool complete() const;
bool decodable() const;
// Builds fragmentation headers for VP8, each fragment being a decodable
// VP8 partition. Returns the total number of bytes which are decodable. Is
// used instead of MakeDecodable for VP8.
size_t BuildVP8FragmentationHeader(uint8_t* frame_buffer,
size_t frame_buffer_length,
RTPFragmentationHeader* fragmentation);
// Makes the frame decodable. I.e., only contain decodable NALUs. All
// non-decodable NALUs will be deleted and packets will be moved to in
// memory to remove any empty space.

View File

@ -61,39 +61,6 @@ class TestSessionInfo : public ::testing::Test {
FrameData frame_data;
};
class TestVP8Partitions : public TestSessionInfo {
protected:
enum { kMaxVP8Partitions = 9 };
virtual void SetUp() {
TestSessionInfo::SetUp();
vp8_header_ = &packet_header_.type.Video.codecHeader.VP8;
packet_header_.frameType = kVideoFrameDelta;
packet_header_.type.Video.codec = kRtpVideoVp8;
vp8_header_->InitRTPVideoHeaderVP8();
fragmentation_.VerifyAndAllocateFragmentationHeader(kMaxVP8Partitions);
}
bool VerifyPartition(int partition_id,
int packets_expected,
int start_value) {
EXPECT_EQ(packets_expected * packet_buffer_size(),
fragmentation_.fragmentationLength[partition_id]);
for (int i = 0; i < packets_expected; ++i) {
size_t packet_index = fragmentation_.fragmentationOffset[partition_id] +
i * packet_buffer_size();
if (packet_index + packet_buffer_size() > frame_buffer_size())
return false;
VerifyPacket(frame_buffer_ + packet_index, start_value + i);
}
return true;
}
WebRtcRTPHeader packet_header_;
RTPVideoHeaderVP8* vp8_header_;
RTPFragmentationHeader fragmentation_;
};
class TestNalUnits : public TestSessionInfo {
protected:
virtual void SetUp() {
@ -416,443 +383,6 @@ TEST_F(TestSessionInfo, OutOfBoundsOutOfOrder) {
-3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data));
}
TEST_F(TestVP8Partitions, TwoPartitionsOneLoss) {
// Partition 0 | Partition 1
// [ 0 ] [ 2 ] | [ 3 ]
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_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 0;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 2;
FillPacket(2);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 1;
vp8_header_->beginningOfPartition = true;
packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1;
FillPacket(3);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
// One packet should be removed (end of partition 0).
EXPECT_EQ(2 * packet_buffer_size(),
session_.BuildVP8FragmentationHeader(
frame_buffer_, frame_buffer_size(), &fragmentation_));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 1, 0));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(1, 1, 3));
}
TEST_F(TestVP8Partitions, TwoPartitionsOneLoss2) {
// Partition 0 | Partition 1
// [ 1 ] [ 2 ] | [ 3 ] [ 5 ]
packet_header_.type.Video.isFirstPacket = true;
vp8_header_->beginningOfPartition = true;
vp8_header_->partitionId = 0;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 1;
FillPacket(1);
VCMPacket* packet =
new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 0;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(2);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 1;
vp8_header_->beginningOfPartition = true;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(3);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 1;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 2;
FillPacket(5);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
// One packet should be removed (end of partition 2), 3 left.
EXPECT_EQ(3 * packet_buffer_size(),
session_.BuildVP8FragmentationHeader(
frame_buffer_, frame_buffer_size(), &fragmentation_));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 1));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(1, 1, 3));
}
TEST_F(TestVP8Partitions, TwoPartitionsNoLossWrap) {
// Partition 0 | Partition 1
// [ fffd ] [ fffe ] | [ ffff ] [ 0 ]
packet_header_.type.Video.isFirstPacket = true;
vp8_header_->beginningOfPartition = true;
vp8_header_->partitionId = 0;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 0xfffd;
FillPacket(0);
VCMPacket* packet =
new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 0;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(1);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 1;
vp8_header_->beginningOfPartition = true;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(2);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 1;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1;
FillPacket(3);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
// No packet should be removed.
EXPECT_EQ(4 * packet_buffer_size(),
session_.BuildVP8FragmentationHeader(
frame_buffer_, frame_buffer_size(), &fragmentation_));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 0));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(1, 2, 2));
}
TEST_F(TestVP8Partitions, TwoPartitionsLossWrap) {
// Partition 0 | Partition 1
// [ fffd ] [ fffe ] | [ ffff ] [ 1 ]
packet_header_.type.Video.isFirstPacket = true;
vp8_header_->beginningOfPartition = true;
vp8_header_->partitionId = 0;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 0xfffd;
FillPacket(0);
VCMPacket* packet =
new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 0;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(1);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 1;
vp8_header_->beginningOfPartition = true;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(2);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 1;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 2;
FillPacket(3);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
// One packet should be removed from the last partition
EXPECT_EQ(3 * packet_buffer_size(),
session_.BuildVP8FragmentationHeader(
frame_buffer_, frame_buffer_size(), &fragmentation_));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 0));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(1, 1, 2));
}
TEST_F(TestVP8Partitions, ThreePartitionsOneMissing) {
// Partition 1 |Partition 2 | Partition 3
// [ 1 ] [ 2 ] | | [ 5 ] | [ 6 ]
packet_header_.type.Video.isFirstPacket = true;
vp8_header_->beginningOfPartition = true;
vp8_header_->partitionId = 0;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 1;
FillPacket(1);
VCMPacket* packet =
new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 0;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(2);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 2;
vp8_header_->beginningOfPartition = true;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 3;
FillPacket(5);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 2;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1;
FillPacket(6);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
// No packet should be removed.
EXPECT_EQ(4 * packet_buffer_size(),
session_.BuildVP8FragmentationHeader(
frame_buffer_, frame_buffer_size(), &fragmentation_));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 1));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(2, 2, 5));
}
TEST_F(TestVP8Partitions, ThreePartitionsLossInSecond) {
// Partition 0 |Partition 1 | Partition 2
// [ 1 ] [ 2 ] | [ 4 ] [ 5 ] | [ 6 ] [ 7 ]
packet_header_.type.Video.isFirstPacket = true;
vp8_header_->beginningOfPartition = true;
vp8_header_->partitionId = 0;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber = 1;
FillPacket(1);
VCMPacket* packet =
new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 0;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(2);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
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 += 2;
FillPacket(4);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
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(5);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 2;
vp8_header_->beginningOfPartition = true;
packet_header_.header.markerBit = false;
packet_header_.header.sequenceNumber += 1;
FillPacket(6);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
packet_header_.type.Video.isFirstPacket = false;
vp8_header_->partitionId = 2;
vp8_header_->beginningOfPartition = false;
packet_header_.header.markerBit = true;
packet_header_.header.sequenceNumber += 1;
FillPacket(7);
packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
// 2 partitions left. 2 packets removed from second partition
EXPECT_EQ(4 * packet_buffer_size(),
session_.BuildVP8FragmentationHeader(
frame_buffer_, frame_buffer_size(), &fragmentation_));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(0, 2, 1));
SCOPED_TRACE("Calling VerifyPartition");
EXPECT_TRUE(VerifyPartition(2, 2, 6));
}
TEST_F(TestVP8Partitions, 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_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
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_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
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_, packet_buffer_size(), packet_header_);
EXPECT_EQ(packet_buffer_size(),
static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
kNoErrors, frame_data)));
delete packet;
// No packets removed.
EXPECT_EQ(3 * packet_buffer_size(),
session_.BuildVP8FragmentationHeader(
frame_buffer_, frame_buffer_size(), &fragmentation_));
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));
}
TEST_F(TestNalUnits, OnlyReceivedEmptyPacket) {
packet_.isFirstPacket = false;
packet_.completeNALU = kNaluComplete;