video_coding: Checking/updating seq num for an old packet regardless of size.

Review URL: http://webrtc-codereview.appspot.com/330028

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1318 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2012-01-03 20:35:25 +00:00
parent c00f91d62d
commit 77c425b976
4 changed files with 30 additions and 15 deletions

View File

@ -94,10 +94,11 @@ void VCMDecodingState::SetStateOneBack(const VCMFrameBuffer* frame) {
init_ = false;
}
void VCMDecodingState::UpdateZeroSizePacket(const VCMPacket* packet) {
void VCMDecodingState::UpdateOldPacket(const VCMPacket* packet) {
assert(packet != NULL);
if (packet->sizeBytes == 0 && packet->timestamp == time_stamp_) {
// Zero size packet - make sure we update the last decoded sequence number.
if (packet->timestamp == time_stamp_) {
// Late packet belonging to the last decoded frame - make sure we update the
// last decoded sequence number.
sequence_num_ = LatestSequenceNumber(packet->seqNum, sequence_num_, NULL);
}
}

View File

@ -34,8 +34,9 @@ class VCMDecodingState {
// Set the decoding state one frame back.
void SetStateOneBack(const VCMFrameBuffer* frame);
// Update the sequence number if the timestamp matches current state and the
// packet is of zero size.
void UpdateZeroSizePacket(const VCMPacket* packet);
// sequence number is higher than the current one. This accounts for packets
// arriving late.
void UpdateOldPacket(const VCMPacket* packet);
void SetSeqNum(uint16_t new_seq_num);
void Reset();
uint32_t time_stamp() const;

View File

@ -194,7 +194,7 @@ TEST(TestDecodingState, SetStateOneBack) {
delete packet;
}
TEST(TestDecodingState, UpdateZeroSizePacket) {
TEST(TestDecodingState, UpdateOldPacket) {
VCMDecodingState dec_state;
// Update only if zero size and newer than previous.
// Should only update if the timeStamp match.
@ -210,15 +210,30 @@ TEST(TestDecodingState, UpdateZeroSizePacket) {
// Insert an empty packet that does not belong to the same frame.
// => Sequence num should be the same.
packet->timestamp = 2;
dec_state.UpdateZeroSizePacket(packet);
dec_state.UpdateOldPacket(packet);
EXPECT_EQ(dec_state.sequence_num(), 1);
// Now insert empty packet belonging to the same frame.
packet->timestamp = 1;
packet->seqNum = 2;
packet->frameType = kFrameEmpty;
packet->sizeBytes = 0;
dec_state.UpdateZeroSizePacket(packet);
dec_state.UpdateOldPacket(packet);
EXPECT_EQ(dec_state.sequence_num(), 2);
// Now insert delta packet belonging to the same frame.
packet->timestamp = 1;
packet->seqNum = 3;
packet->frameType = kVideoFrameDelta;
packet->sizeBytes = 1400;
dec_state.UpdateOldPacket(packet);
EXPECT_EQ(dec_state.sequence_num(), 3);
// Insert a packet belonging to an older timestamp - should not update the
// sequence number.
packet->timestamp = 0;
packet->seqNum = 4;
packet->frameType = kFrameEmpty;
packet->sizeBytes = 0;
dec_state.UpdateOldPacket(packet);
EXPECT_EQ(dec_state.sequence_num(), 3);
delete packet;
}

View File

@ -445,12 +445,10 @@ VCMJitterBuffer::GetFrame(const VCMPacket& packet, VCMEncodedFrame*& frame)
_discardedPackets++;
_numConsecutiveOldPackets++;
}
else
{
// Update last decoded sequence number if packet belongs to a zero
// size frame with a timestamp equal to the last decoded timestamp.
_lastDecodedState.UpdateZeroSizePacket(&packet);
}
// Update last decoded sequence number if the packet arrived late and
// belongs to a frame with a timestamp equal to the last decoded
// timestamp.
_lastDecodedState.UpdateOldPacket(&packet);
if (_numConsecutiveOldPackets > kMaxConsecutiveOldPackets)
{
@ -1570,7 +1568,7 @@ VCMJitterBuffer::InsertPacket(VCMEncodedFrame* buffer, const VCMPacket& packet)
if (frame != NULL)
{
VCMFrameBufferStateEnum state = frame->GetState();
_lastDecodedState.UpdateZeroSizePacket(&packet);
_lastDecodedState.UpdateOldPacket(&packet);
// Insert packet
// Check for first packet
// High sequence number will be -1 if neither an empty packet nor