Fixes a bug where the render buffer size (and indirectly the non-continuous duration) was computed incorrectly.

BUG=1769
R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1473004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4026 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/video_coding/main/source/jitter_buffer.cc b/webrtc/modules/video_coding/main/source/jitter_buffer.cc
index ea26032..ebfd094 100644
--- a/webrtc/modules/video_coding/main/source/jitter_buffer.cc
+++ b/webrtc/modules/video_coding/main/source/jitter_buffer.cc
@@ -1000,15 +1000,10 @@
   // Search for a complete and continuous sequence (starting from the last
   // decoded state or current frame if in initial state).
   VCMDecodingState previous_state;
-  if (last_decoded_state_.in_initial_state()) {
-    previous_state.SetState(*start_it);
-  } else {
-    previous_state.CopyFrom(last_decoded_state_);
-  }
-  bool continuous_complete = true;
+  previous_state.SetState(*start_it);
   FrameList::iterator previous_it = start_it;
   ++start_it;
-  while (start_it != frame_list_.end() && continuous_complete) {
+  while (start_it != frame_list_.end()) {
     start_it = FindOldestCompleteContinuousFrame(start_it, &previous_state);
     if (start_it == frame_list_.end())
       break;
diff --git a/webrtc/modules/video_coding/main/source/receiver_unittest.cc b/webrtc/modules/video_coding/main/source/receiver_unittest.cc
index 40d0de1..62b7a99 100644
--- a/webrtc/modules/video_coding/main/source/receiver_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/receiver_unittest.cc
@@ -263,6 +263,41 @@
   EXPECT_EQ(kNackOk, ret);
 }
 
+TEST_F(TestVCMReceiver, NonDecodableDuration_NoTrigger2) {
+  // Enable NACK and with no RTT thresholds for disabling retransmission delay.
+  receiver_.SetNackMode(kNack, -1, -1);
+  const size_t kMaxNackListSize = 1000;
+  const int kMaxPacketAgeToNack = 1000;
+  const int kMaxNonDecodableDuration = 500;
+  const int kMaxNonDecodableDurationFrames = (kDefaultFrameRate *
+      kMaxNonDecodableDuration + 500) / 1000;
+  const int kMinDelayMs = 500;
+  receiver_.SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack,
+      kMaxNonDecodableDuration);
+  receiver_.SetMinReceiverDelay(kMinDelayMs);
+  int64_t key_frame_inserted = clock_->TimeInMilliseconds();
+  EXPECT_GE(InsertFrame(kVideoFrameKey, true), kNoError);
+  // Insert enough frames to have too long non-decodable sequence, except that
+  // we don't have any losses.
+  for (int i = 0; i < kMaxNonDecodableDurationFrames;
+       ++i) {
+    EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError);
+  }
+  // Insert an incomplete frame.
+  EXPECT_GE(InsertFrame(kVideoFrameDelta, false), kNoError);
+  // Advance time until it's time to decode the key frame.
+  clock_->AdvanceTimeMilliseconds(kMinDelayMs - clock_->TimeInMilliseconds() -
+      key_frame_inserted);
+  EXPECT_TRUE(DecodeNextFrame());
+  // Make sure we don't get a key frame request since the non-decodable duration
+  // is only one frame.
+  uint16_t nack_list[kMaxNackListSize];
+  uint16_t nack_list_length = 0;
+  VCMNackStatus ret = receiver_.NackList(nack_list, kMaxNackListSize,
+                                         &nack_list_length);
+  EXPECT_EQ(kNackOk, ret);
+}
+
 TEST_F(TestVCMReceiver, NonDecodableDuration_KeyFrameAfterIncompleteFrames) {
   // Enable NACK and with no RTT thresholds for disabling retransmission delay.
   receiver_.SetNackMode(kNack, -1, -1);