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

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

Issue 2996823002: Reland of quest keyframes more frequently on stream start/decoding error. (Closed)
Patch Set: Fix Created 3 years, 4 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 frame->spatial_layer = spatial_layer; 160 frame->spatial_layer = spatial_layer;
161 frame->timestamp = ts_ms * 90; 161 frame->timestamp = ts_ms * 90;
162 frame->num_references = references.size(); 162 frame->num_references = references.size();
163 frame->inter_layer_predicted = inter_layer_predicted; 163 frame->inter_layer_predicted = inter_layer_predicted;
164 for (size_t r = 0; r < references.size(); ++r) 164 for (size_t r = 0; r < references.size(); ++r)
165 frame->references[r] = references[r]; 165 frame->references[r] = references[r];
166 166
167 return buffer_.InsertFrame(std::move(frame)); 167 return buffer_.InsertFrame(std::move(frame));
168 } 168 }
169 169
170 void ExtractFrame(int64_t max_wait_time = 0) { 170 void ExtractFrame(int64_t max_wait_time = 0, bool keyframe_required = false) {
171 crit_.Enter(); 171 crit_.Enter();
172 if (max_wait_time == 0) { 172 if (max_wait_time == 0) {
173 std::unique_ptr<FrameObject> frame; 173 std::unique_ptr<FrameObject> frame;
174 FrameBuffer::ReturnReason res = buffer_.NextFrame(0, &frame); 174 FrameBuffer::ReturnReason res =
175 buffer_.NextFrame(0, &frame, keyframe_required);
175 if (res != FrameBuffer::ReturnReason::kStopped) 176 if (res != FrameBuffer::ReturnReason::kStopped)
176 frames_.emplace_back(std::move(frame)); 177 frames_.emplace_back(std::move(frame));
177 crit_.Leave(); 178 crit_.Leave();
178 } else { 179 } else {
179 max_wait_time_ = max_wait_time; 180 max_wait_time_ = max_wait_time;
180 trigger_extract_event_.Set(); 181 trigger_extract_event_.Set();
181 crit_.Leave(); 182 crit_.Leave();
182 // Make sure |crit_| is aquired by |extract_thread_| before returning. 183 // Make sure |crit_| is aquired by |extract_thread_| before returning.
183 crit_acquired_event_.Wait(rtc::Event::kForever); 184 crit_acquired_event_.Wait(rtc::Event::kForever);
184 } 185 }
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } 534 }
534 535
535 // TODO(philipel): implement more unittests related to invalid references. 536 // TODO(philipel): implement more unittests related to invalid references.
536 TEST_F(TestFrameBuffer2, InvalidReferences) { 537 TEST_F(TestFrameBuffer2, InvalidReferences) {
537 EXPECT_EQ(-1, InsertFrame(0, 0, 1000, false, 2)); 538 EXPECT_EQ(-1, InsertFrame(0, 0, 1000, false, 2));
538 EXPECT_EQ(1, InsertFrame(1, 0, 2000, false)); 539 EXPECT_EQ(1, InsertFrame(1, 0, 2000, false));
539 ExtractFrame(); 540 ExtractFrame();
540 EXPECT_EQ(2, InsertFrame(2, 0, 3000, false, 1)); 541 EXPECT_EQ(2, InsertFrame(2, 0, 3000, false, 1));
541 } 542 }
542 543
544 TEST_F(TestFrameBuffer2, KeyframeRequired) {
545 EXPECT_EQ(1, InsertFrame(1, 0, 1000, false));
546 EXPECT_EQ(2, InsertFrame(2, 0, 2000, false, 1));
547 EXPECT_EQ(3, InsertFrame(3, 0, 3000, false));
548 ExtractFrame();
549 ExtractFrame(0, true);
550 ExtractFrame();
551
552 CheckFrame(0, 1, 0);
553 CheckFrame(1, 3, 0);
554 CheckNoFrame(2);
555 }
556
543 } // namespace video_coding 557 } // namespace video_coding
544 } // namespace webrtc 558 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698