Frame continuity is now tested as soon as a frame is inserted into the FrameBuffer.
Since we want to stop sending NACKS for frames not needed to keep the stream
decodable we must know which frames that are continuous or not.
BUG=webrtc:5514
R=danilchap@webrtc.org, stefan@webrtc.org
Review URL: https://codereview.webrtc.org/2322263002 .
Cr-Commit-Position: refs/heads/master@{#14412}
diff --git a/webrtc/modules/video_coding/frame_buffer2_unittest.cc b/webrtc/modules/video_coding/frame_buffer2_unittest.cc
index ad776df..46cccad 100644
--- a/webrtc/modules/video_coding/frame_buffer2_unittest.cc
+++ b/webrtc/modules/video_coding/frame_buffer2_unittest.cc
@@ -111,11 +111,11 @@
}
template <typename... T>
- void InsertFrame(uint16_t picture_id,
- uint8_t spatial_layer,
- int64_t ts_ms,
- bool inter_layer_predicted,
- T... refs) {
+ int InsertFrame(uint16_t picture_id,
+ uint8_t spatial_layer,
+ int64_t ts_ms,
+ bool inter_layer_predicted,
+ T... refs) {
static_assert(sizeof...(refs) <= kMaxReferences,
"To many references specified for FrameObject.");
std::array<uint16_t, sizeof...(refs)> references = {{refs...}};
@@ -129,7 +129,7 @@
for (size_t r = 0; r < references.size(); ++r)
frame->references[r] = references[r];
- buffer_.InsertFrame(std::move(frame));
+ return buffer_.InsertFrame(std::move(frame));
}
void ExtractFrame(int64_t max_wait_time = 0) {
@@ -216,6 +216,19 @@
uint16_t pid = Rand();
uint32_t ts = Rand();
+ InsertFrame(pid, 0, ts, false);
+ ExtractFrame();
+ InsertFrame(pid, 1, ts, true);
+ ExtractFrame();
+
+ CheckFrame(0, pid, 0);
+ CheckFrame(1, pid, 1);
+}
+
+TEST_F(TestFrameBuffer2, OneUnorderedSuperFrame) {
+ uint16_t pid = Rand();
+ uint32_t ts = Rand();
+
ExtractFrame(50);
InsertFrame(pid, 1, ts, true);
InsertFrame(pid, 0, ts, false);
@@ -358,5 +371,37 @@
ExtractFrame();
}
+TEST_F(TestFrameBuffer2, NoContinuousFrame) {
+ uint16_t pid = Rand();
+ uint32_t ts = Rand();
+
+ EXPECT_EQ(-1, InsertFrame(pid + 1, 0, ts, false, pid));
+}
+
+TEST_F(TestFrameBuffer2, LastContinuousFrameSingleLayer) {
+ uint16_t pid = Rand();
+ uint32_t ts = Rand();
+
+ EXPECT_EQ(pid, InsertFrame(pid, 0, ts, false));
+ EXPECT_EQ(pid, InsertFrame(pid + 2, 0, ts, false, pid + 1));
+ EXPECT_EQ(pid + 2, InsertFrame(pid + 1, 0, ts, false, pid));
+ EXPECT_EQ(pid + 2, InsertFrame(pid + 4, 0, ts, false, pid + 3));
+ EXPECT_EQ(pid + 5, InsertFrame(pid + 5, 0, ts, false));
+}
+
+TEST_F(TestFrameBuffer2, LastContinuousFrameTwoLayers) {
+ uint16_t pid = Rand();
+ uint32_t ts = Rand();
+
+ EXPECT_EQ(pid, InsertFrame(pid, 0, ts, false));
+ EXPECT_EQ(pid, InsertFrame(pid, 1, ts, true));
+ EXPECT_EQ(pid, InsertFrame(pid + 1, 1, ts, true, pid));
+ EXPECT_EQ(pid, InsertFrame(pid + 2, 0, ts, false, pid + 1));
+ EXPECT_EQ(pid, InsertFrame(pid + 2, 1, ts, true, pid + 1));
+ EXPECT_EQ(pid, InsertFrame(pid + 3, 0, ts, false, pid + 2));
+ EXPECT_EQ(pid + 3, InsertFrame(pid + 1, 0, ts, false, pid));
+ EXPECT_EQ(pid + 3, InsertFrame(pid + 3, 1, ts, true, pid + 2));
+}
+
} // namespace video_coding
} // namespace webrtc