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

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

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

Powered by Google App Engine
This is Rietveld 408576698