blob: 58b3f7a42b51d91536d9e00291bc701ec73c5a7c [file] [log] [blame]
philipelbe7a9e52016-05-19 12:19:35 +02001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "webrtc/modules/video_coding/frame_buffer2.h"
12
13#include <algorithm>
14#include <cstring>
15#include <limits>
16#include <vector>
17
Henrik Kjellanderdca1e092017-07-01 16:42:22 +020018#include "webrtc/base/platform_thread.h"
19#include "webrtc/base/random.h"
philipelbe7a9e52016-05-19 12:19:35 +020020#include "webrtc/modules/video_coding/frame_object.h"
21#include "webrtc/modules/video_coding/jitter_estimator.h"
22#include "webrtc/modules/video_coding/sequence_number_util.h"
23#include "webrtc/modules/video_coding/timing.h"
24#include "webrtc/system_wrappers/include/clock.h"
kwibergac9f8762016-09-30 22:29:43 -070025#include "webrtc/test/gmock.h"
26#include "webrtc/test/gtest.h"
philipelbe7a9e52016-05-19 12:19:35 +020027
philipela45102f2017-02-22 05:30:39 -080028using testing::_;
29using testing::Return;
30
philipelbe7a9e52016-05-19 12:19:35 +020031namespace webrtc {
32namespace video_coding {
33
34class VCMTimingFake : public VCMTiming {
35 public:
36 explicit VCMTimingFake(Clock* clock) : VCMTiming(clock) {}
37
38 int64_t RenderTimeMs(uint32_t frame_timestamp,
39 int64_t now_ms) const override {
40 if (last_ms_ == -1) {
41 last_ms_ = now_ms + kDelayMs;
42 last_timestamp_ = frame_timestamp;
43 }
44
45 uint32_t diff = MinDiff(frame_timestamp, last_timestamp_);
46 if (AheadOf(frame_timestamp, last_timestamp_))
47 last_ms_ += diff / 90;
48 else
49 last_ms_ -= diff / 90;
50
51 last_timestamp_ = frame_timestamp;
52 return last_ms_;
53 }
54
55 uint32_t MaxWaitingTime(int64_t render_time_ms,
56 int64_t now_ms) const override {
57 return std::max<int>(0, render_time_ms - now_ms - kDecodeTime);
58 }
59
philipela45102f2017-02-22 05:30:39 -080060 bool GetTimings(int* decode_ms,
61 int* max_decode_ms,
62 int* current_delay_ms,
63 int* target_delay_ms,
64 int* jitter_buffer_ms,
65 int* min_playout_delay_ms,
66 int* render_delay_ms) const override {
67 return true;
68 }
69
philipelbe7a9e52016-05-19 12:19:35 +020070 private:
71 static constexpr int kDelayMs = 50;
72 static constexpr int kDecodeTime = kDelayMs / 2;
73 mutable uint32_t last_timestamp_ = 0;
74 mutable int64_t last_ms_ = -1;
75};
76
77class VCMJitterEstimatorMock : public VCMJitterEstimator {
78 public:
79 explicit VCMJitterEstimatorMock(Clock* clock) : VCMJitterEstimator(clock) {}
80
81 MOCK_METHOD1(UpdateRtt, void(int64_t rttMs));
82 MOCK_METHOD3(UpdateEstimate,
83 void(int64_t frameDelayMs,
84 uint32_t frameSizeBytes,
85 bool incompleteFrame));
philipel4f6cd6a2016-08-03 10:59:32 +020086 MOCK_METHOD1(GetJitterEstimate, int(double rttMultiplier));
philipelbe7a9e52016-05-19 12:19:35 +020087};
88
philipelb4d31082016-07-11 08:46:29 -070089class FrameObjectFake : public FrameObject {
philipelbe7a9e52016-05-19 12:19:35 +020090 public:
philipelb4d31082016-07-11 08:46:29 -070091 bool GetBitstream(uint8_t* destination) const override { return true; }
92
93 uint32_t Timestamp() const override { return timestamp; }
94
95 int64_t ReceivedTime() const override { return 0; }
96
97 int64_t RenderTime() const override { return _renderTimeMs; }
philipela45102f2017-02-22 05:30:39 -080098
99 // In EncodedImage |_length| is used to descibe its size and |_size| to
100 // describe its capacity.
101 void SetSize(int size) { _length = size; }
102};
103
104class VCMReceiveStatisticsCallbackMock : public VCMReceiveStatisticsCallback {
105 public:
106 MOCK_METHOD2(OnReceiveRatesUpdated,
107 void(uint32_t bitRate, uint32_t frameRate));
108 MOCK_METHOD2(OnCompleteFrame, void(bool is_keyframe, size_t size_bytes));
109 MOCK_METHOD1(OnDiscardedPacketsUpdated, void(int discarded_packets));
110 MOCK_METHOD1(OnFrameCountsUpdated, void(const FrameCounts& frame_counts));
111 MOCK_METHOD7(OnFrameBufferTimingsUpdated,
112 void(int decode_ms,
113 int max_decode_ms,
114 int current_delay_ms,
115 int target_delay_ms,
116 int jitter_buffer_ms,
117 int min_playout_delay_ms,
118 int render_delay_ms));
philipelbe7a9e52016-05-19 12:19:35 +0200119};
120
121class TestFrameBuffer2 : public ::testing::Test {
122 protected:
123 static constexpr int kMaxReferences = 5;
124 static constexpr int kFps1 = 1000;
125 static constexpr int kFps10 = kFps1 / 10;
126 static constexpr int kFps20 = kFps1 / 20;
127
128 TestFrameBuffer2()
129 : clock_(0),
130 timing_(&clock_),
131 jitter_estimator_(&clock_),
philipela45102f2017-02-22 05:30:39 -0800132 buffer_(&clock_, &jitter_estimator_, &timing_, &stats_callback_),
philipelbe7a9e52016-05-19 12:19:35 +0200133 rand_(0x34678213),
134 tear_down_(false),
135 extract_thread_(&ExtractLoop, this, "Extract Thread"),
136 trigger_extract_event_(false, false),
137 crit_acquired_event_(false, false) {}
138
139 void SetUp() override { extract_thread_.Start(); }
140
141 void TearDown() override {
142 tear_down_ = true;
143 trigger_extract_event_.Set();
144 extract_thread_.Stop();
145 }
146
147 template <typename... T>
philipele0b2f152016-09-28 10:23:49 +0200148 int InsertFrame(uint16_t picture_id,
149 uint8_t spatial_layer,
150 int64_t ts_ms,
151 bool inter_layer_predicted,
152 T... refs) {
philipelbe7a9e52016-05-19 12:19:35 +0200153 static_assert(sizeof...(refs) <= kMaxReferences,
154 "To many references specified for FrameObject.");
155 std::array<uint16_t, sizeof...(refs)> references = {{refs...}};
156
philipelb4d31082016-07-11 08:46:29 -0700157 std::unique_ptr<FrameObjectFake> frame(new FrameObjectFake());
philipelbe7a9e52016-05-19 12:19:35 +0200158 frame->picture_id = picture_id;
159 frame->spatial_layer = spatial_layer;
160 frame->timestamp = ts_ms * 90;
161 frame->num_references = references.size();
162 frame->inter_layer_predicted = inter_layer_predicted;
163 for (size_t r = 0; r < references.size(); ++r)
164 frame->references[r] = references[r];
165
philipele0b2f152016-09-28 10:23:49 +0200166 return buffer_.InsertFrame(std::move(frame));
philipelbe7a9e52016-05-19 12:19:35 +0200167 }
168
169 void ExtractFrame(int64_t max_wait_time = 0) {
170 crit_.Enter();
171 if (max_wait_time == 0) {
philipel75562822016-09-05 10:57:41 +0200172 std::unique_ptr<FrameObject> frame;
173 FrameBuffer::ReturnReason res = buffer_.NextFrame(0, &frame);
174 if (res != FrameBuffer::ReturnReason::kStopped)
175 frames_.emplace_back(std::move(frame));
philipelbe7a9e52016-05-19 12:19:35 +0200176 crit_.Leave();
177 } else {
178 max_wait_time_ = max_wait_time;
179 trigger_extract_event_.Set();
180 crit_.Leave();
181 // Make sure |crit_| is aquired by |extract_thread_| before returning.
182 crit_acquired_event_.Wait(rtc::Event::kForever);
183 }
184 }
185
186 void CheckFrame(size_t index, int picture_id, int spatial_layer) {
187 rtc::CritScope lock(&crit_);
188 ASSERT_LT(index, frames_.size());
189 ASSERT_TRUE(frames_[index]);
190 ASSERT_EQ(picture_id, frames_[index]->picture_id);
191 ASSERT_EQ(spatial_layer, frames_[index]->spatial_layer);
192 }
193
194 void CheckNoFrame(size_t index) {
195 rtc::CritScope lock(&crit_);
196 ASSERT_LT(index, frames_.size());
197 ASSERT_FALSE(frames_[index]);
198 }
199
tommi0f8b4032017-02-22 11:22:05 -0800200 static void ExtractLoop(void* obj) {
philipelbe7a9e52016-05-19 12:19:35 +0200201 TestFrameBuffer2* tfb = static_cast<TestFrameBuffer2*>(obj);
202 while (true) {
203 tfb->trigger_extract_event_.Wait(rtc::Event::kForever);
204 {
205 rtc::CritScope lock(&tfb->crit_);
206 tfb->crit_acquired_event_.Set();
207 if (tfb->tear_down_)
tommi0f8b4032017-02-22 11:22:05 -0800208 return;
philipelbe7a9e52016-05-19 12:19:35 +0200209
philipel75562822016-09-05 10:57:41 +0200210 std::unique_ptr<FrameObject> frame;
211 FrameBuffer::ReturnReason res =
212 tfb->buffer_.NextFrame(tfb->max_wait_time_, &frame);
213 if (res != FrameBuffer::ReturnReason::kStopped)
214 tfb->frames_.emplace_back(std::move(frame));
philipelbe7a9e52016-05-19 12:19:35 +0200215 }
216 }
217 }
218
219 uint32_t Rand() { return rand_.Rand<uint32_t>(); }
220
221 SimulatedClock clock_;
222 VCMTimingFake timing_;
philipel4f6cd6a2016-08-03 10:59:32 +0200223 ::testing::NiceMock<VCMJitterEstimatorMock> jitter_estimator_;
philipelbe7a9e52016-05-19 12:19:35 +0200224 FrameBuffer buffer_;
225 std::vector<std::unique_ptr<FrameObject>> frames_;
226 Random rand_;
philipela45102f2017-02-22 05:30:39 -0800227 ::testing::NiceMock<VCMReceiveStatisticsCallbackMock> stats_callback_;
philipelbe7a9e52016-05-19 12:19:35 +0200228
229 int64_t max_wait_time_;
230 bool tear_down_;
231 rtc::PlatformThread extract_thread_;
232 rtc::Event trigger_extract_event_;
233 rtc::Event crit_acquired_event_;
234 rtc::CriticalSection crit_;
235};
236
philipel6e8224f2016-05-19 17:07:44 +0200237// Following tests are timing dependent. Either the timeouts have to
238// be increased by a large margin, which would slow down all trybots,
239// or we disable them for the very slow ones, like we do here.
240#if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER)
philipelbe7a9e52016-05-19 12:19:35 +0200241TEST_F(TestFrameBuffer2, WaitForFrame) {
242 uint16_t pid = Rand();
243 uint32_t ts = Rand();
244
philipel6e8224f2016-05-19 17:07:44 +0200245 ExtractFrame(50);
philipelbe7a9e52016-05-19 12:19:35 +0200246 InsertFrame(pid, 0, ts, false);
247 CheckFrame(0, pid, 0);
248}
249
250TEST_F(TestFrameBuffer2, OneSuperFrame) {
251 uint16_t pid = Rand();
252 uint32_t ts = Rand();
253
philipele0b2f152016-09-28 10:23:49 +0200254 InsertFrame(pid, 0, ts, false);
255 ExtractFrame();
256 InsertFrame(pid, 1, ts, true);
257 ExtractFrame();
258
259 CheckFrame(0, pid, 0);
260 CheckFrame(1, pid, 1);
261}
262
gnishb2a318b2017-05-10 09:21:33 -0700263TEST_F(TestFrameBuffer2, SetPlayoutDelay) {
264 const PlayoutDelay kPlayoutDelayMs = {123, 321};
265 std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
266 test_frame->SetPlayoutDelay(kPlayoutDelayMs);
267 buffer_.InsertFrame(std::move(test_frame));
268 EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_.min_playout_delay());
269 EXPECT_EQ(kPlayoutDelayMs.max_ms, timing_.max_playout_delay());
270}
271
aleloi3e005282017-01-26 05:38:00 -0800272// Flaky test, see bugs.webrtc.org/7068.
273TEST_F(TestFrameBuffer2, DISABLED_OneUnorderedSuperFrame) {
philipele0b2f152016-09-28 10:23:49 +0200274 uint16_t pid = Rand();
275 uint32_t ts = Rand();
276
philipel6e8224f2016-05-19 17:07:44 +0200277 ExtractFrame(50);
philipelbe7a9e52016-05-19 12:19:35 +0200278 InsertFrame(pid, 1, ts, true);
279 InsertFrame(pid, 0, ts, false);
280 ExtractFrame();
281
282 CheckFrame(0, pid, 0);
283 CheckFrame(1, pid, 1);
284}
285
philipel94616b32016-05-20 10:43:01 +0200286TEST_F(TestFrameBuffer2, DISABLED_OneLayerStreamReordered) {
philipel6e8224f2016-05-19 17:07:44 +0200287 uint16_t pid = Rand();
288 uint32_t ts = Rand();
289
290 InsertFrame(pid, 0, ts, false);
291 ExtractFrame();
292 CheckFrame(0, pid, 0);
293 for (int i = 1; i < 10; i += 2) {
294 ExtractFrame(50);
295 InsertFrame(pid + i + 1, 0, ts + (i + 1) * kFps10, false, pid + i);
296 clock_.AdvanceTimeMilliseconds(kFps10);
297 InsertFrame(pid + i, 0, ts + i * kFps10, false, pid + i - 1);
298 clock_.AdvanceTimeMilliseconds(kFps10);
299 ExtractFrame();
300 CheckFrame(i, pid + i, 0);
301 CheckFrame(i + 1, pid + i + 1, 0);
302 }
303}
304#endif // Timing dependent tests.
305
306TEST_F(TestFrameBuffer2, ExtractFromEmptyBuffer) {
307 ExtractFrame();
308 CheckNoFrame(0);
309}
310
philipel93e451b2016-10-06 12:25:13 +0200311TEST_F(TestFrameBuffer2, MissingFrame) {
312 uint16_t pid = Rand();
313 uint32_t ts = Rand();
314
315 InsertFrame(pid, 0, ts, false);
316 InsertFrame(pid + 2, 0, ts, false, pid);
317 InsertFrame(pid + 3, 0, ts, false, pid + 1, pid + 2);
318 ExtractFrame();
319 ExtractFrame();
320 ExtractFrame();
321
322 CheckFrame(0, pid, 0);
323 CheckFrame(1, pid + 2, 0);
324 CheckNoFrame(2);
325}
326
philipelbe7a9e52016-05-19 12:19:35 +0200327TEST_F(TestFrameBuffer2, OneLayerStream) {
328 uint16_t pid = Rand();
329 uint32_t ts = Rand();
330
331 InsertFrame(pid, 0, ts, false);
332 ExtractFrame();
333 CheckFrame(0, pid, 0);
334 for (int i = 1; i < 10; ++i) {
335 InsertFrame(pid + i, 0, ts + i * kFps10, false, pid + i - 1);
336 ExtractFrame();
337 clock_.AdvanceTimeMilliseconds(kFps10);
338 CheckFrame(i, pid + i, 0);
339 }
340}
341
philipelbe7a9e52016-05-19 12:19:35 +0200342TEST_F(TestFrameBuffer2, DropTemporalLayerSlowDecoder) {
343 uint16_t pid = Rand();
344 uint32_t ts = Rand();
345
346 InsertFrame(pid, 0, ts, false);
philipelfd5a20f2016-11-15 00:57:57 -0800347 InsertFrame(pid + 1, 0, ts + kFps20, false, pid);
philipelbe7a9e52016-05-19 12:19:35 +0200348 for (int i = 2; i < 10; i += 2) {
349 uint32_t ts_tl0 = ts + i / 2 * kFps10;
350 InsertFrame(pid + i, 0, ts_tl0, false, pid + i - 2);
351 InsertFrame(pid + i + 1, 0, ts_tl0 + kFps20, false, pid + i, pid + i - 1);
352 }
353
354 for (int i = 0; i < 10; ++i) {
355 ExtractFrame();
356 clock_.AdvanceTimeMilliseconds(60);
357 }
358
359 CheckFrame(0, pid, 0);
360 CheckFrame(1, pid + 1, 0);
361 CheckFrame(2, pid + 2, 0);
362 CheckFrame(3, pid + 4, 0);
363 CheckFrame(4, pid + 6, 0);
364 CheckFrame(5, pid + 8, 0);
365 CheckNoFrame(6);
366 CheckNoFrame(7);
367 CheckNoFrame(8);
368 CheckNoFrame(9);
369}
370
371TEST_F(TestFrameBuffer2, DropSpatialLayerSlowDecoder) {
372 uint16_t pid = Rand();
373 uint32_t ts = Rand();
374
375 InsertFrame(pid, 0, ts, false);
376 InsertFrame(pid, 1, ts, false);
377 for (int i = 1; i < 6; ++i) {
378 uint32_t ts_tl0 = ts + i * kFps10;
379 InsertFrame(pid + i, 0, ts_tl0, false, pid + i - 1);
380 InsertFrame(pid + i, 1, ts_tl0, false, pid + i - 1);
381 }
382
383 ExtractFrame();
384 ExtractFrame();
385 clock_.AdvanceTimeMilliseconds(55);
386 for (int i = 2; i < 12; ++i) {
387 ExtractFrame();
388 clock_.AdvanceTimeMilliseconds(55);
389 }
390
391 CheckFrame(0, pid, 0);
392 CheckFrame(1, pid, 1);
393 CheckFrame(2, pid + 1, 0);
394 CheckFrame(3, pid + 1, 1);
395 CheckFrame(4, pid + 2, 0);
396 CheckFrame(5, pid + 2, 1);
397 CheckFrame(6, pid + 3, 0);
398 CheckFrame(7, pid + 4, 0);
399 CheckFrame(8, pid + 5, 0);
400 CheckNoFrame(9);
401 CheckNoFrame(10);
402 CheckNoFrame(11);
403}
404
405TEST_F(TestFrameBuffer2, InsertLateFrame) {
406 uint16_t pid = Rand();
407 uint32_t ts = Rand();
408
409 InsertFrame(pid, 0, ts, false);
410 ExtractFrame();
411 InsertFrame(pid + 2, 0, ts, false);
412 ExtractFrame();
413 InsertFrame(pid + 1, 0, ts, false, pid);
414 ExtractFrame();
415
416 CheckFrame(0, pid, 0);
417 CheckFrame(1, pid + 2, 0);
418 CheckNoFrame(2);
419}
420
philipel4f6cd6a2016-08-03 10:59:32 +0200421TEST_F(TestFrameBuffer2, ProtectionMode) {
422 uint16_t pid = Rand();
423 uint32_t ts = Rand();
424
425 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(1.0));
426 InsertFrame(pid, 0, ts, false);
427 ExtractFrame();
428
429 buffer_.SetProtectionMode(kProtectionNackFEC);
430 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0));
431 InsertFrame(pid + 1, 0, ts, false);
432 ExtractFrame();
433}
434
philipele0b2f152016-09-28 10:23:49 +0200435TEST_F(TestFrameBuffer2, NoContinuousFrame) {
436 uint16_t pid = Rand();
437 uint32_t ts = Rand();
438
439 EXPECT_EQ(-1, InsertFrame(pid + 1, 0, ts, false, pid));
440}
441
442TEST_F(TestFrameBuffer2, LastContinuousFrameSingleLayer) {
443 uint16_t pid = Rand();
444 uint32_t ts = Rand();
445
446 EXPECT_EQ(pid, InsertFrame(pid, 0, ts, false));
447 EXPECT_EQ(pid, InsertFrame(pid + 2, 0, ts, false, pid + 1));
448 EXPECT_EQ(pid + 2, InsertFrame(pid + 1, 0, ts, false, pid));
449 EXPECT_EQ(pid + 2, InsertFrame(pid + 4, 0, ts, false, pid + 3));
450 EXPECT_EQ(pid + 5, InsertFrame(pid + 5, 0, ts, false));
451}
452
453TEST_F(TestFrameBuffer2, LastContinuousFrameTwoLayers) {
454 uint16_t pid = Rand();
455 uint32_t ts = Rand();
456
457 EXPECT_EQ(pid, InsertFrame(pid, 0, ts, false));
458 EXPECT_EQ(pid, InsertFrame(pid, 1, ts, true));
459 EXPECT_EQ(pid, InsertFrame(pid + 1, 1, ts, true, pid));
460 EXPECT_EQ(pid, InsertFrame(pid + 2, 0, ts, false, pid + 1));
461 EXPECT_EQ(pid, InsertFrame(pid + 2, 1, ts, true, pid + 1));
462 EXPECT_EQ(pid, InsertFrame(pid + 3, 0, ts, false, pid + 2));
463 EXPECT_EQ(pid + 3, InsertFrame(pid + 1, 0, ts, false, pid));
464 EXPECT_EQ(pid + 3, InsertFrame(pid + 3, 1, ts, true, pid + 2));
465}
466
philipelfcc60062017-01-18 05:35:20 -0800467TEST_F(TestFrameBuffer2, PictureIdJumpBack) {
468 uint16_t pid = Rand();
469 uint32_t ts = Rand();
470
471 EXPECT_EQ(pid, InsertFrame(pid, 0, ts, false));
472 EXPECT_EQ(pid + 1, InsertFrame(pid + 1, 0, ts + 1, false, pid));
473 ExtractFrame();
474 CheckFrame(0, pid, 0);
475
476 // Jump back in pid but increase ts.
477 EXPECT_EQ(pid - 1, InsertFrame(pid - 1, 0, ts + 2, false));
478 ExtractFrame();
479 ExtractFrame();
480 CheckFrame(1, pid - 1, 0);
481 CheckNoFrame(2);
482}
483
philipela45102f2017-02-22 05:30:39 -0800484TEST_F(TestFrameBuffer2, StatsCallback) {
485 uint16_t pid = Rand();
486 uint32_t ts = Rand();
487 const int kFrameSize = 5000;
488
489 EXPECT_CALL(stats_callback_, OnCompleteFrame(true, kFrameSize));
490 EXPECT_CALL(stats_callback_,
491 OnFrameBufferTimingsUpdated(_, _, _, _, _, _, _));
492
493 {
494 std::unique_ptr<FrameObjectFake> frame(new FrameObjectFake());
495 frame->SetSize(kFrameSize);
496 frame->picture_id = pid;
497 frame->spatial_layer = 0;
498 frame->timestamp = ts;
499 frame->num_references = 0;
500 frame->inter_layer_predicted = false;
501
502 EXPECT_EQ(buffer_.InsertFrame(std::move(frame)), pid);
503 }
504
505 ExtractFrame();
506 CheckFrame(0, pid, 0);
507}
508
philipel146a48b2017-04-20 04:04:38 -0700509TEST_F(TestFrameBuffer2, ForwardJumps) {
510 EXPECT_EQ(5453, InsertFrame(5453, 0, 1, false));
511 ExtractFrame();
512 EXPECT_EQ(5454, InsertFrame(5454, 0, 1, false, 5453));
513 ExtractFrame();
514 EXPECT_EQ(15670, InsertFrame(15670, 0, 1, false));
515 ExtractFrame();
516 EXPECT_EQ(29804, InsertFrame(29804, 0, 1, false));
517 ExtractFrame();
518 EXPECT_EQ(29805, InsertFrame(29805, 0, 1, false, 29804));
519 ExtractFrame();
520 EXPECT_EQ(29806, InsertFrame(29806, 0, 1, false, 29805));
521 ExtractFrame();
522 EXPECT_EQ(33819, InsertFrame(33819, 0, 1, false));
523 ExtractFrame();
524 EXPECT_EQ(41248, InsertFrame(41248, 0, 1, false));
525 ExtractFrame();
526}
527
philipelf6842692017-04-28 03:29:15 -0700528TEST_F(TestFrameBuffer2, DuplicateFrames) {
529 EXPECT_EQ(22256, InsertFrame(22256, 0, 1, false));
530 ExtractFrame();
531 EXPECT_EQ(22256, InsertFrame(22256, 0, 1, false));
532}
533
philipel112adf92017-06-15 09:06:21 -0700534// TODO(philipel): implement more unittests related to invalid references.
535TEST_F(TestFrameBuffer2, InvalidReferences) {
536 EXPECT_EQ(-1, InsertFrame(0, 0, 1000, false, 2));
537 EXPECT_EQ(1, InsertFrame(1, 0, 2000, false));
538 ExtractFrame();
539 EXPECT_EQ(2, InsertFrame(2, 0, 3000, false, 1));
540}
541
philipelbe7a9e52016-05-19 12:19:35 +0200542} // namespace video_coding
543} // namespace webrtc