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

Side by Side Diff: media/renderers/video_renderer_impl_unittest.cc

Issue 1834303005: Refactor audio and video decoder status into common file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 4 years, 8 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 | « media/renderers/audio_renderer_impl_unittest.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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Examples: 165 // Examples:
166 // A clip that is four frames long: "0 10 20 30" 166 // A clip that is four frames long: "0 10 20 30"
167 // A clip that has a decode error: "60 70 error" 167 // A clip that has a decode error: "60 70 error"
168 void QueueFrames(const std::string& str) { 168 void QueueFrames(const std::string& str) {
169 for (const std::string& token : 169 for (const std::string& token :
170 base::SplitString(str, " ", base::TRIM_WHITESPACE, 170 base::SplitString(str, " ", base::TRIM_WHITESPACE,
171 base::SPLIT_WANT_ALL)) { 171 base::SPLIT_WANT_ALL)) {
172 if (token == "abort") { 172 if (token == "abort") {
173 scoped_refptr<VideoFrame> null_frame; 173 scoped_refptr<VideoFrame> null_frame;
174 decode_results_.push_back( 174 decode_results_.push_back(
175 std::make_pair(VideoDecoder::kAborted, null_frame)); 175 std::make_pair(DecodeStatus::ABORTED, null_frame));
176 continue; 176 continue;
177 } 177 }
178 178
179 if (token == "error") { 179 if (token == "error") {
180 scoped_refptr<VideoFrame> null_frame; 180 scoped_refptr<VideoFrame> null_frame;
181 decode_results_.push_back( 181 decode_results_.push_back(
182 std::make_pair(VideoDecoder::kDecodeError, null_frame)); 182 std::make_pair(DecodeStatus::DECODE_ERROR, null_frame));
183 continue; 183 continue;
184 } 184 }
185 185
186 int timestamp_in_ms = 0; 186 int timestamp_in_ms = 0;
187 if (base::StringToInt(token, &timestamp_in_ms)) { 187 if (base::StringToInt(token, &timestamp_in_ms)) {
188 gfx::Size natural_size = TestVideoConfig::NormalCodedSize(); 188 gfx::Size natural_size = TestVideoConfig::NormalCodedSize();
189 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( 189 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame(
190 PIXEL_FORMAT_YV12, natural_size, gfx::Rect(natural_size), 190 PIXEL_FORMAT_YV12, natural_size, gfx::Rect(natural_size),
191 natural_size, base::TimeDelta::FromMilliseconds(timestamp_in_ms)); 191 natural_size, base::TimeDelta::FromMilliseconds(timestamp_in_ms));
192 decode_results_.push_back(std::make_pair(VideoDecoder::kOk, frame)); 192 decode_results_.push_back(std::make_pair(DecodeStatus::OK, frame));
193 continue; 193 continue;
194 } 194 }
195 195
196 CHECK(false) << "Unrecognized decoder buffer token: " << token; 196 CHECK(false) << "Unrecognized decoder buffer token: " << token;
197 } 197 }
198 } 198 }
199 199
200 bool IsReadPending() { 200 bool IsReadPending() {
201 return !decode_cb_.is_null(); 201 return !decode_cb_.is_null();
202 } 202 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 DCHECK(!decode_cb_.is_null()); 244 DCHECK(!decode_cb_.is_null());
245 245
246 // Return EOS buffer to trigger EOS frame. 246 // Return EOS buffer to trigger EOS frame.
247 EXPECT_CALL(demuxer_stream_, Read(_)) 247 EXPECT_CALL(demuxer_stream_, Read(_))
248 .WillOnce(RunCallback<0>(DemuxerStream::kOk, 248 .WillOnce(RunCallback<0>(DemuxerStream::kOk,
249 DecoderBuffer::CreateEOSBuffer())); 249 DecoderBuffer::CreateEOSBuffer()));
250 250
251 // Satify pending |decode_cb_| to trigger a new DemuxerStream::Read(). 251 // Satify pending |decode_cb_| to trigger a new DemuxerStream::Read().
252 message_loop_.PostTask( 252 message_loop_.PostTask(
253 FROM_HERE, 253 FROM_HERE,
254 base::Bind(base::ResetAndReturn(&decode_cb_), VideoDecoder::kOk)); 254 base::Bind(base::ResetAndReturn(&decode_cb_), DecodeStatus::OK));
255 255
256 WaitForPendingRead(); 256 WaitForPendingRead();
257 257
258 message_loop_.PostTask( 258 message_loop_.PostTask(
259 FROM_HERE, 259 FROM_HERE,
260 base::Bind(base::ResetAndReturn(&decode_cb_), VideoDecoder::kOk)); 260 base::Bind(base::ResetAndReturn(&decode_cb_), DecodeStatus::OK));
261 } 261 }
262 262
263 void AdvanceWallclockTimeInMs(int time_ms) { 263 void AdvanceWallclockTimeInMs(int time_ms) {
264 DCHECK_EQ(&message_loop_, base::MessageLoop::current()); 264 DCHECK_EQ(&message_loop_, base::MessageLoop::current());
265 base::AutoLock l(lock_); 265 base::AutoLock l(lock_);
266 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(time_ms)); 266 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(time_ms));
267 } 267 }
268 268
269 void AdvanceTimeInMs(int time_ms) { 269 void AdvanceTimeInMs(int time_ms) {
270 DCHECK_EQ(&message_loop_, base::MessageLoop::current()); 270 DCHECK_EQ(&message_loop_, base::MessageLoop::current());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 VideoDecoder::OutputCB output_cb_; 345 VideoDecoder::OutputCB output_cb_;
346 VideoDecoder::DecodeCB decode_cb_; 346 VideoDecoder::DecodeCB decode_cb_;
347 base::TimeDelta next_frame_timestamp_; 347 base::TimeDelta next_frame_timestamp_;
348 348
349 WaitableMessageLoopEvent error_event_; 349 WaitableMessageLoopEvent error_event_;
350 WaitableMessageLoopEvent ended_event_; 350 WaitableMessageLoopEvent ended_event_;
351 351
352 // Run during DecodeRequested() to unblock WaitForPendingRead(). 352 // Run during DecodeRequested() to unblock WaitForPendingRead().
353 base::Closure wait_for_pending_decode_cb_; 353 base::Closure wait_for_pending_decode_cb_;
354 354
355 std::deque<std::pair< 355 std::deque<std::pair<DecodeStatus, scoped_refptr<VideoFrame>>>
356 VideoDecoder::Status, scoped_refptr<VideoFrame> > > decode_results_; 356 decode_results_;
357 357
358 DISALLOW_COPY_AND_ASSIGN(VideoRendererImplTest); 358 DISALLOW_COPY_AND_ASSIGN(VideoRendererImplTest);
359 }; 359 };
360 360
361 TEST_F(VideoRendererImplTest, DoNothing) { 361 TEST_F(VideoRendererImplTest, DoNothing) {
362 // Test that creation and deletion doesn't depend on calls to Initialize() 362 // Test that creation and deletion doesn't depend on calls to Initialize()
363 // and/or Destroy(). 363 // and/or Destroy().
364 } 364 }
365 365
366 TEST_F(VideoRendererImplTest, DestroyWithoutInitialize) { 366 TEST_F(VideoRendererImplTest, DestroyWithoutInitialize) {
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 QueueFrames("0 10 20 30"); 802 QueueFrames("0 10 20 30");
803 StartPlayingFrom(0); 803 StartPlayingFrom(0);
804 Flush(); 804 Flush();
805 ASSERT_EQ(1u, frame_ready_cbs_.size()); 805 ASSERT_EQ(1u, frame_ready_cbs_.size());
806 // This frame will be discarded. 806 // This frame will be discarded.
807 frame_ready_cbs_.front().Run(); 807 frame_ready_cbs_.front().Run();
808 Destroy(); 808 Destroy();
809 } 809 }
810 810
811 } // namespace media 811 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/audio_renderer_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698