From e203de7ba2631d50dc880a137444f1d5c134a033 Mon Sep 17 00:00:00 2001 From: "mikhal@webrtc.org" Date: Thu, 3 Nov 2011 00:42:52 +0000 Subject: [PATCH] jitter_buffer updates: 1. Determining continuity based on pictureId and not seq. numbers when available. 2. Hybrid bug fix: Don't set to decodable when the nack list is empty. Review URL: http://webrtc-codereview.appspot.com/255001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@878 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../video_coding/main/source/jitter_buffer.cc | 44 +++++++++++-------- .../video_coding/main/source/session_info.cc | 9 +--- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/modules/video_coding/main/source/jitter_buffer.cc b/src/modules/video_coding/main/source/jitter_buffer.cc index aa894a70f..156c0d3cb 100644 --- a/src/modules/video_coding/main/source/jitter_buffer.cc +++ b/src/modules/video_coding/main/source/jitter_buffer.cc @@ -614,26 +614,33 @@ VCMJitterBuffer::FindOldestCompleteContinuousFrame() // we have a complete frame // check if it's continuous, otherwise we are missing a full frame - // Use seqNum not timestamp since a full frame might be lost - if (_lastDecodedSeqNum != -1 && !_waitingForKeyFrame) - { - // it's not enough that we have complete frame we need the layers to - // be continuous too - currentLow = oldestFrame->GetLowSeqNum(); - WebRtc_UWord16 lastDecodedSeqNum = (WebRtc_UWord16)_lastDecodedSeqNum; - - // We could have received the first packet of the last frame before a - // long period if drop, that case is handled by GetNackList - if (((WebRtc_UWord16)(lastDecodedSeqNum + 1)) != currentLow) - { - // Wait since we want a complete continuous frame - return NULL; - } + // Use pictureId if available. Otherwise use seqNum and not timestamps, as + // a complete frame might be lost + // First determine if we are waiting for a key frame. + if (_waitingForKeyFrame && oldestFrame->FrameType() != kVideoFrameKey) { + return NULL; } - else if (oldestFrame->FrameType() != kVideoFrameKey) - { + // Is this the first frame to be decoded? + // Otherwise, verify continuity - use PictureId when available. + if (_lastDecodedSeqNum == -1) { + return oldestFrameItem; + } else if (oldestFrame->PictureId() == kNoPictureId) { + // It's not enough that we have a complete frame we need the layers to + // be continuous too. + currentLow = oldestFrame->GetLowSeqNum(); + WebRtc_UWord16 lastDecodedSeqNum = (WebRtc_UWord16)_lastDecodedSeqNum; + + // We could have received the first packet of the last frame before a + // long period if drop, that case is handled by GetNackList + if (((WebRtc_UWord16)(lastDecodedSeqNum + 1)) != currentLow) { + // Wait since we want a complete continuous frame return NULL; + } + } + else if (!ContinuousPictureId(oldestFrame->PictureId())) { + // We don't have a continuous frame + return NULL; } return oldestFrameItem; } @@ -1460,10 +1467,11 @@ VCMJitterBuffer::CreateNackList(WebRtc_UWord16& nackSize, bool& listExtended) { // build external rttScore based on RTT value float rttScore = 1.0f; + int ret = _frameBuffers[i]->ZeroOutSeqNumHybrid(_NACKSeqNumInternal, numberOfSeqNum, rttScore); - if (_frameBuffers[i]->IsRetransmitted() == false) + if (_frameBuffers[i]->IsRetransmitted() == false && ret != -1) { // If no retransmission required,set the state to decodable // meaning that we will not wait for NACK. diff --git a/src/modules/video_coding/main/source/session_info.cc b/src/modules/video_coding/main/source/session_info.cc index cbfcf2273..799a5d3e7 100644 --- a/src/modules/video_coding/main/source/session_info.cc +++ b/src/modules/video_coding/main/source/session_info.cc @@ -491,7 +491,7 @@ WebRtc_Word32 VCMSessionInfo::ZeroOutSeqNum(WebRtc_Word32* list, WebRtc_Word32 numberOfSeqNum) { - if ((NULL == list) || (numberOfSeqNum < 1)) + if (NULL == list || numberOfSeqNum < 1) { return -1; } @@ -539,15 +539,10 @@ VCMSessionInfo::ZeroOutSeqNumHybrid(WebRtc_Word32* list, WebRtc_Word32 numberOfSeqNum, float rttScore) { - if ((NULL == list) || (numberOfSeqNum < 1)) + if (NULL == list || numberOfSeqNum < 1) { return -1; } - if (_lowSeqNum == -1) - { - // no media packets in this frame - return 0; - } WebRtc_Word32 index = 0; // Find end point (index of entry that equals _lowSeqNum)