Skip non-continuous FrameInfos when finding the next frame to return from FrameBuffer::NextFrame.

Also added DCHECKS to make sure that FrameInfos are not incorrectly updated.

BUG=webrtc:5514
R=stefan@webrtc.org

Review URL: https://codereview.webrtc.org/2394823002 .

Cr-Commit-Position: refs/heads/master@{#14549}
diff --git a/webrtc/modules/video_coding/frame_buffer2_unittest.cc b/webrtc/modules/video_coding/frame_buffer2_unittest.cc
index 7f8ac67..ebcbeb0 100644
--- a/webrtc/modules/video_coding/frame_buffer2_unittest.cc
+++ b/webrtc/modules/video_coding/frame_buffer2_unittest.cc
@@ -263,6 +263,22 @@
   CheckNoFrame(0);
 }
 
+TEST_F(TestFrameBuffer2, MissingFrame) {
+  uint16_t pid = Rand();
+  uint32_t ts = Rand();
+
+  InsertFrame(pid, 0, ts, false);
+  InsertFrame(pid + 2, 0, ts, false, pid);
+  InsertFrame(pid + 3, 0, ts, false, pid + 1, pid + 2);
+  ExtractFrame();
+  ExtractFrame();
+  ExtractFrame();
+
+  CheckFrame(0, pid, 0);
+  CheckFrame(1, pid + 2, 0);
+  CheckNoFrame(2);
+}
+
 TEST_F(TestFrameBuffer2, OneLayerStream) {
   uint16_t pid = Rand();
   uint32_t ts = Rand();