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

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

Issue 2302473002: FrameBuffer::NextFrame now return pair<frame, reason>. (Closed)
Patch Set: Comment fix 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
« no previous file with comments | « webrtc/modules/video_coding/frame_buffer2.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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 frames_.emplace_back(buffer_.NextFrame(0)); 138 std::unique_ptr<FrameObject> frame;
139 FrameBuffer::ReturnReason res = buffer_.NextFrame(0, &frame);
140 if (res != FrameBuffer::ReturnReason::kStopped)
141 frames_.emplace_back(std::move(frame));
139 crit_.Leave(); 142 crit_.Leave();
140 } else { 143 } else {
141 max_wait_time_ = max_wait_time; 144 max_wait_time_ = max_wait_time;
142 trigger_extract_event_.Set(); 145 trigger_extract_event_.Set();
143 crit_.Leave(); 146 crit_.Leave();
144 // Make sure |crit_| is aquired by |extract_thread_| before returning. 147 // Make sure |crit_| is aquired by |extract_thread_| before returning.
145 crit_acquired_event_.Wait(rtc::Event::kForever); 148 crit_acquired_event_.Wait(rtc::Event::kForever);
146 } 149 }
147 } 150 }
148 151
(...skipping 14 matching lines...) Expand all
163 static bool ExtractLoop(void* obj) { 166 static bool ExtractLoop(void* obj) {
164 TestFrameBuffer2* tfb = static_cast<TestFrameBuffer2*>(obj); 167 TestFrameBuffer2* tfb = static_cast<TestFrameBuffer2*>(obj);
165 while (true) { 168 while (true) {
166 tfb->trigger_extract_event_.Wait(rtc::Event::kForever); 169 tfb->trigger_extract_event_.Wait(rtc::Event::kForever);
167 { 170 {
168 rtc::CritScope lock(&tfb->crit_); 171 rtc::CritScope lock(&tfb->crit_);
169 tfb->crit_acquired_event_.Set(); 172 tfb->crit_acquired_event_.Set();
170 if (tfb->tear_down_) 173 if (tfb->tear_down_)
171 return false; 174 return false;
172 175
173 tfb->frames_.emplace_back(tfb->buffer_.NextFrame(tfb->max_wait_time_)); 176 std::unique_ptr<FrameObject> frame;
177 FrameBuffer::ReturnReason res =
178 tfb->buffer_.NextFrame(tfb->max_wait_time_, &frame);
179 if (res != FrameBuffer::ReturnReason::kStopped)
180 tfb->frames_.emplace_back(std::move(frame));
174 } 181 }
175 } 182 }
176 } 183 }
177 184
178 uint32_t Rand() { return rand_.Rand<uint32_t>(); } 185 uint32_t Rand() { return rand_.Rand<uint32_t>(); }
179 186
180 SimulatedClock clock_; 187 SimulatedClock clock_;
181 VCMTimingFake timing_; 188 VCMTimingFake timing_;
182 ::testing::NiceMock<VCMJitterEstimatorMock> jitter_estimator_; 189 ::testing::NiceMock<VCMJitterEstimatorMock> jitter_estimator_;
183 FrameBuffer buffer_; 190 FrameBuffer buffer_;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 ExtractFrame(); 353 ExtractFrame();
347 354
348 buffer_.SetProtectionMode(kProtectionNackFEC); 355 buffer_.SetProtectionMode(kProtectionNackFEC);
349 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0)); 356 EXPECT_CALL(jitter_estimator_, GetJitterEstimate(0.0));
350 InsertFrame(pid + 1, 0, ts, false); 357 InsertFrame(pid + 1, 0, ts, false);
351 ExtractFrame(); 358 ExtractFrame();
352 } 359 }
353 360
354 } // namespace video_coding 361 } // namespace video_coding
355 } // namespace webrtc 362 } // namespace webrtc
OLDNEW
« no previous file with comments | « 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