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

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 fixes 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(1.0)); 351 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(1.0));
352 InsertFrame(pid, 0, ts, false); 352 InsertFrame(pid, 0, ts, false);
353 ExtractFrame(); 353 ExtractFrame();
354 354
355 buffer_.SetProtectionMode(kProtectionNackFEC); 355 buffer_.SetProtectionMode(kProtectionNackFEC);
356 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0)); 356 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0));
357 InsertFrame(pid + 1, 0, ts, false); 357 InsertFrame(pid + 1, 0, ts, false);
358 ExtractFrame(); 358 ExtractFrame();
359 } 359 }
360 360
361 TEST_F(TestFrameBuffer2, NoContinuousFrame) {
362 uint16_t pid = Rand();
363 uint32_t ts = Rand();
364
365 EXPECT_EQ(-1, InsertFrame(pid + 1, 0, ts, false, pid));
366 }
367
368 TEST_F(TestFrameBuffer2, LastContinuousFrameSingleStream) {
369 uint16_t pid = Rand();
370 uint32_t ts = Rand();
371
372 EXPECT_EQ(pid, InsertFrame(pid, 0, ts, false));
373 EXPECT_EQ(pid, InsertFrame(pid + 2, 0, ts, false, pid + 1));
374 EXPECT_EQ(pid + 2, InsertFrame(pid + 1, 0, ts, false, pid));
375 EXPECT_EQ(pid + 2, InsertFrame(pid + 4, 0, ts, false, pid + 3));
376 EXPECT_EQ(pid + 5, InsertFrame(pid + 5, 0, ts, false));
377 }
378
danilchap 2016/09/19 12:21:51 Likely need a test or few with inter_layer_predict
philipel 2016/09/19 15:36:58 Done.
361 } // namespace video_coding 379 } // namespace video_coding
362 } // namespace webrtc 380 } // 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