OLD | NEW |
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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 base::Bind(&MockCB::FrameReceived, base::Unretained(&mock_cb_)), | 78 base::Bind(&MockCB::FrameReceived, base::Unretained(&mock_cb_)), |
79 message_loop_.task_runner())); | 79 message_loop_.task_runner())); |
80 | 80 |
81 renderer_.reset(new VideoRendererImpl( | 81 renderer_.reset(new VideoRendererImpl( |
82 message_loop_.task_runner(), message_loop_.task_runner().get(), | 82 message_loop_.task_runner(), message_loop_.task_runner().get(), |
83 null_video_sink_.get(), | 83 null_video_sink_.get(), |
84 base::Bind(&VideoRendererImplTest::CreateVideoDecodersForTest, | 84 base::Bind(&VideoRendererImplTest::CreateVideoDecodersForTest, |
85 base::Unretained(this)), | 85 base::Unretained(this)), |
86 true, | 86 true, |
87 nullptr, // gpu_factories | 87 nullptr, // gpu_factories |
88 new MediaLog())); | 88 &media_log_)); |
89 renderer_->SetTickClockForTesting( | 89 renderer_->SetTickClockForTesting( |
90 std::unique_ptr<base::TickClock>(tick_clock_)); | 90 std::unique_ptr<base::TickClock>(tick_clock_)); |
91 null_video_sink_->set_tick_clock_for_testing(tick_clock_); | 91 null_video_sink_->set_tick_clock_for_testing(tick_clock_); |
92 time_source_.set_tick_clock_for_testing(tick_clock_); | 92 time_source_.set_tick_clock_for_testing(tick_clock_); |
93 | 93 |
94 // Start wallclock time at a non-zero value. | 94 // Start wallclock time at a non-zero value. |
95 AdvanceWallclockTimeInMs(12345); | 95 AdvanceWallclockTimeInMs(12345); |
96 | 96 |
97 demuxer_stream_.set_video_decoder_config(TestVideoConfig::Normal()); | 97 demuxer_stream_.set_video_decoder_config(TestVideoConfig::Normal()); |
98 | 98 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 else | 432 else |
433 QueueFrames("40 60 80 90"); | 433 QueueFrames("40 60 80 90"); |
434 SatisfyPendingDecode(); | 434 SatisfyPendingDecode(); |
435 event.RunAndWait(); | 435 event.RunAndWait(); |
436 } | 436 } |
437 | 437 |
438 Destroy(); | 438 Destroy(); |
439 } | 439 } |
440 | 440 |
441 protected: | 441 protected: |
| 442 base::MessageLoop message_loop_; |
| 443 MediaLog media_log_; |
| 444 |
442 // Fixture members. | 445 // Fixture members. |
443 std::unique_ptr<VideoRendererImpl> renderer_; | 446 std::unique_ptr<VideoRendererImpl> renderer_; |
444 base::SimpleTestTickClock* tick_clock_; // Owned by |renderer_|. | 447 base::SimpleTestTickClock* tick_clock_; // Owned by |renderer_|. |
445 NiceMock<MockVideoDecoder>* decoder_; // Owned by |renderer_|. | 448 NiceMock<MockVideoDecoder>* decoder_; // Owned by |renderer_|. |
446 NiceMock<MockDemuxerStream> demuxer_stream_; | 449 NiceMock<MockDemuxerStream> demuxer_stream_; |
447 | 450 |
448 bool expect_init_success_; | 451 bool expect_init_success_; |
449 | 452 |
450 // Use StrictMock<T> to catch missing/extra callbacks. | 453 // Use StrictMock<T> to catch missing/extra callbacks. |
451 class MockCB : public MockRendererClient { | 454 class MockCB : public MockRendererClient { |
452 public: | 455 public: |
453 MOCK_METHOD1(FrameReceived, void(const scoped_refptr<VideoFrame>&)); | 456 MOCK_METHOD1(FrameReceived, void(const scoped_refptr<VideoFrame>&)); |
454 }; | 457 }; |
455 StrictMock<MockCB> mock_cb_; | 458 StrictMock<MockCB> mock_cb_; |
456 | 459 |
457 // Must be destroyed before |renderer_| since they share |tick_clock_|. | 460 // Must be destroyed before |renderer_| since they share |tick_clock_|. |
458 std::unique_ptr<NullVideoSink> null_video_sink_; | 461 std::unique_ptr<NullVideoSink> null_video_sink_; |
459 | 462 |
460 WallClockTimeSource time_source_; | 463 WallClockTimeSource time_source_; |
461 | 464 |
462 base::MessageLoop message_loop_; | |
463 | |
464 private: | 465 private: |
465 void DecodeRequested(const scoped_refptr<DecoderBuffer>& buffer, | 466 void DecodeRequested(const scoped_refptr<DecoderBuffer>& buffer, |
466 const VideoDecoder::DecodeCB& decode_cb) { | 467 const VideoDecoder::DecodeCB& decode_cb) { |
467 DCHECK_EQ(&message_loop_, base::MessageLoop::current()); | 468 DCHECK_EQ(&message_loop_, base::MessageLoop::current()); |
468 CHECK(decode_cb_.is_null()); | 469 CHECK(decode_cb_.is_null()); |
469 decode_cb_ = decode_cb; | 470 decode_cb_ = decode_cb; |
470 | 471 |
471 // Wake up WaitForPendingDecode() if needed. | 472 // Wake up WaitForPendingDecode() if needed. |
472 if (!wait_for_pending_decode_cb_.is_null()) | 473 if (!wait_for_pending_decode_cb_.is_null()) |
473 base::ResetAndReturn(&wait_for_pending_decode_cb_).Run(); | 474 base::ResetAndReturn(&wait_for_pending_decode_cb_).Run(); |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 QueueFrames("0 10 20 30"); | 1212 QueueFrames("0 10 20 30"); |
1212 StartPlayingFrom(0); | 1213 StartPlayingFrom(0); |
1213 Flush(); | 1214 Flush(); |
1214 ASSERT_EQ(1u, frame_ready_cbs_.size()); | 1215 ASSERT_EQ(1u, frame_ready_cbs_.size()); |
1215 // This frame will be discarded. | 1216 // This frame will be discarded. |
1216 frame_ready_cbs_.front().Run(); | 1217 frame_ready_cbs_.front().Run(); |
1217 Destroy(); | 1218 Destroy(); |
1218 } | 1219 } |
1219 | 1220 |
1220 } // namespace media | 1221 } // namespace media |
OLD | NEW |