Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: webrtc/modules/video_coding/frame_buffer2_unittest.cc

Issue 2322263002: Frame continuity is now tested as soon as a frame is inserted into the FrameBuffer. (Closed)
Patch Set: Feedback Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 void SetUp() override { extract_thread_.Start(); } 105 void SetUp() override { extract_thread_.Start(); }
106 106
107 void TearDown() override { 107 void TearDown() override {
108 tear_down_ = true; 108 tear_down_ = true;
109 trigger_extract_event_.Set(); 109 trigger_extract_event_.Set();
110 extract_thread_.Stop(); 110 extract_thread_.Stop();
111 } 111 }
112 112
113 template <typename... T> 113 template <typename... T>
114 void InsertFrame(uint16_t picture_id, 114 int InsertFrame(uint16_t picture_id,
115 uint8_t spatial_layer, 115 uint8_t spatial_layer,
116 int64_t ts_ms, 116 int64_t ts_ms,
117 bool inter_layer_predicted, 117 bool inter_layer_predicted,
118 T... refs) { 118 T... refs) {
119 static_assert(sizeof...(refs) <= kMaxReferences, 119 static_assert(sizeof...(refs) <= kMaxReferences,
120 "To many references specified for FrameObject."); 120 "To many references specified for FrameObject.");
121 std::array<uint16_t, sizeof...(refs)> references = {{refs...}}; 121 std::array<uint16_t, sizeof...(refs)> references = {{refs...}};
122 122
123 std::unique_ptr<FrameObjectFake> frame(new FrameObjectFake()); 123 std::unique_ptr<FrameObjectFake> frame(new FrameObjectFake());
124 frame->picture_id = picture_id; 124 frame->picture_id = picture_id;
125 frame->spatial_layer = spatial_layer; 125 frame->spatial_layer = spatial_layer;
126 frame->timestamp = ts_ms * 90; 126 frame->timestamp = ts_ms * 90;
127 frame->num_references = references.size(); 127 frame->num_references = references.size();
128 frame->inter_layer_predicted = inter_layer_predicted; 128 frame->inter_layer_predicted = inter_layer_predicted;
129 for (size_t r = 0; r < references.size(); ++r) 129 for (size_t r = 0; r < references.size(); ++r)
130 frame->references[r] = references[r]; 130 frame->references[r] = references[r];
131 131
132 buffer_.InsertFrame(std::move(frame)); 132 return buffer_.InsertFrame(std::move(frame));
133 } 133 }
134 134
135 void ExtractFrame(int64_t max_wait_time = 0) { 135 void ExtractFrame(int64_t max_wait_time = 0) {
136 crit_.Enter(); 136 crit_.Enter();
137 if (max_wait_time == 0) { 137 if (max_wait_time == 0) {
138 std::unique_ptr<FrameObject> frame; 138 std::unique_ptr<FrameObject> frame;
139 FrameBuffer::ReturnReason res = buffer_.NextFrame(0, &frame); 139 FrameBuffer::ReturnReason res = buffer_.NextFrame(0, &frame);
140 if (res != FrameBuffer::ReturnReason::kStopped) 140 if (res != FrameBuffer::ReturnReason::kStopped)
141 frames_.emplace_back(std::move(frame)); 141 frames_.emplace_back(std::move(frame));
142 crit_.Leave(); 142 crit_.Leave();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 ExtractFrame(50); 210 ExtractFrame(50);
211 InsertFrame(pid, 0, ts, false); 211 InsertFrame(pid, 0, ts, false);
212 CheckFrame(0, pid, 0); 212 CheckFrame(0, pid, 0);
213 } 213 }
214 214
215 TEST_F(TestFrameBuffer2, OneSuperFrame) { 215 TEST_F(TestFrameBuffer2, OneSuperFrame) {
216 uint16_t pid = Rand(); 216 uint16_t pid = Rand();
217 uint32_t ts = Rand(); 217 uint32_t ts = Rand();
218 218
219 InsertFrame(pid, 0, ts, false);
220 ExtractFrame();
221 InsertFrame(pid, 1, ts, true);
222 ExtractFrame();
223
224 CheckFrame(0, pid, 0);
225 CheckFrame(1, pid, 1);
226 }
227
228 TEST_F(TestFrameBuffer2, OneUnorderedSuperFrame) {
229 uint16_t pid = Rand();
230 uint32_t ts = Rand();
231
219 ExtractFrame(50); 232 ExtractFrame(50);
220 InsertFrame(pid, 1, ts, true); 233 InsertFrame(pid, 1, ts, true);
221 InsertFrame(pid, 0, ts, false); 234 InsertFrame(pid, 0, ts, false);
222 ExtractFrame(); 235 ExtractFrame();
223 236
224 CheckFrame(0, pid, 0); 237 CheckFrame(0, pid, 0);
225 CheckFrame(1, pid, 1); 238 CheckFrame(1, pid, 1);
226 } 239 }
227 240
228 TEST_F(TestFrameBuffer2, DISABLED_OneLayerStreamReordered) { 241 TEST_F(TestFrameBuffer2, DISABLED_OneLayerStreamReordered) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(1.0)); 364 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(1.0));
352 InsertFrame(pid, 0, ts, false); 365 InsertFrame(pid, 0, ts, false);
353 ExtractFrame(); 366 ExtractFrame();
354 367
355 buffer_.SetProtectionMode(kProtectionNackFEC); 368 buffer_.SetProtectionMode(kProtectionNackFEC);
356 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0)); 369 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0));
357 InsertFrame(pid + 1, 0, ts, false); 370 InsertFrame(pid + 1, 0, ts, false);
358 ExtractFrame(); 371 ExtractFrame();
359 } 372 }
360 373
374 TEST_F(TestFrameBuffer2, NoContinuousFrame) {
375 uint16_t pid = Rand();
376 uint32_t ts = Rand();
377
378 EXPECT_EQ(-1, InsertFrame(pid + 1, 0, ts, false, pid));
379 }
380
381 TEST_F(TestFrameBuffer2, LastContinuousFrameSingleLayer) {
382 uint16_t pid = Rand();
383 uint32_t ts = Rand();
384
385 EXPECT_EQ(pid, InsertFrame(pid, 0, ts, false));
386 EXPECT_EQ(pid, InsertFrame(pid + 2, 0, ts, false, pid + 1));
387 EXPECT_EQ(pid + 2, InsertFrame(pid + 1, 0, ts, false, pid));
388 EXPECT_EQ(pid + 2, InsertFrame(pid + 4, 0, ts, false, pid + 3));
389 EXPECT_EQ(pid + 5, InsertFrame(pid + 5, 0, ts, false));
390 }
391
392 TEST_F(TestFrameBuffer2, LastContinuousFrameTwoLayers) {
393 uint16_t pid = Rand();
394 uint32_t ts = Rand();
395
396 EXPECT_EQ(pid, InsertFrame(pid, 0, ts, false));
397 EXPECT_EQ(pid, InsertFrame(pid, 1, ts, true));
398 EXPECT_EQ(pid, InsertFrame(pid + 1, 1, ts, true, pid));
399 EXPECT_EQ(pid, InsertFrame(pid + 2, 0, ts, false, pid + 1));
400 EXPECT_EQ(pid, InsertFrame(pid + 2, 1, ts, true, pid + 1));
401 EXPECT_EQ(pid, InsertFrame(pid + 3, 0, ts, false, pid + 2));
402 EXPECT_EQ(pid + 3, InsertFrame(pid + 1, 0, ts, false, pid));
403 EXPECT_EQ(pid + 3, InsertFrame(pid + 3, 1, ts, true, pid + 2));
404 }
405
361 } // namespace video_coding 406 } // namespace video_coding
362 } // namespace webrtc 407 } // namespace webrtc
OLDNEW
« webrtc/modules/video_coding/frame_buffer2.cc ('K') | « webrtc/modules/video_coding/frame_buffer2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698