| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/filters/pipeline_integration_test_base.h" | 5 #include "media/filters/pipeline_integration_test_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "media/base/clock.h" | |
| 10 #include "media/base/media_log.h" | 9 #include "media/base/media_log.h" |
| 11 #include "media/filters/audio_renderer_impl.h" | 10 #include "media/filters/audio_renderer_impl.h" |
| 12 #include "media/filters/chunk_demuxer.h" | 11 #include "media/filters/chunk_demuxer.h" |
| 12 #include "media/filters/clockless_video_frame_scheduler.h" |
| 13 #include "media/filters/ffmpeg_audio_decoder.h" | 13 #include "media/filters/ffmpeg_audio_decoder.h" |
| 14 #include "media/filters/ffmpeg_demuxer.h" | 14 #include "media/filters/ffmpeg_demuxer.h" |
| 15 #include "media/filters/ffmpeg_video_decoder.h" | 15 #include "media/filters/ffmpeg_video_decoder.h" |
| 16 #include "media/filters/file_data_source.h" | 16 #include "media/filters/file_data_source.h" |
| 17 #include "media/filters/opus_audio_decoder.h" | 17 #include "media/filters/opus_audio_decoder.h" |
| 18 #include "media/filters/video_frame_scheduler_impl.h" |
| 18 #include "media/filters/vpx_video_decoder.h" | 19 #include "media/filters/vpx_video_decoder.h" |
| 19 | 20 |
| 20 using ::testing::_; | 21 using ::testing::_; |
| 21 using ::testing::AnyNumber; | 22 using ::testing::AnyNumber; |
| 22 using ::testing::AtMost; | 23 using ::testing::AtMost; |
| 23 using ::testing::SaveArg; | 24 using ::testing::SaveArg; |
| 24 | 25 |
| 25 namespace media { | 26 namespace media { |
| 26 | 27 |
| 27 const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e"; | 28 const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e"; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 base::Closure()); | 120 base::Closure()); |
| 120 message_loop_.Run(); | 121 message_loop_.Run(); |
| 121 return (pipeline_status_ == PIPELINE_OK); | 122 return (pipeline_status_ == PIPELINE_OK); |
| 122 } | 123 } |
| 123 | 124 |
| 124 bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path, | 125 bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path, |
| 125 PipelineStatus expected_status, | 126 PipelineStatus expected_status, |
| 126 kTestType test_type) { | 127 kTestType test_type) { |
| 127 hashing_enabled_ = test_type == kHashed; | 128 hashing_enabled_ = test_type == kHashed; |
| 128 clockless_playback_ = test_type == kClockless; | 129 clockless_playback_ = test_type == kClockless; |
| 129 if (clockless_playback_) { | |
| 130 pipeline_->SetClockForTesting(new Clock(&dummy_clock_)); | |
| 131 } | |
| 132 return Start(file_path, expected_status); | 130 return Start(file_path, expected_status); |
| 133 } | 131 } |
| 134 | 132 |
| 135 bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path) { | 133 bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path) { |
| 136 return Start(file_path, NULL); | 134 return Start(file_path, NULL); |
| 137 } | 135 } |
| 138 | 136 |
| 139 bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path, | 137 bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path, |
| 140 Decryptor* decryptor) { | 138 Decryptor* decryptor) { |
| 141 EXPECT_CALL(*this, OnMetadata(_)).Times(AtMost(1)) | 139 EXPECT_CALL(*this, OnMetadata(_)).Times(AtMost(1)) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 234 |
| 237 scoped_ptr<FilterCollection> collection(new FilterCollection()); | 235 scoped_ptr<FilterCollection> collection(new FilterCollection()); |
| 238 collection->SetDemuxer(demuxer_.get()); | 236 collection->SetDemuxer(demuxer_.get()); |
| 239 | 237 |
| 240 ScopedVector<VideoDecoder> video_decoders; | 238 ScopedVector<VideoDecoder> video_decoders; |
| 241 video_decoders.push_back( | 239 video_decoders.push_back( |
| 242 new VpxVideoDecoder(message_loop_.message_loop_proxy())); | 240 new VpxVideoDecoder(message_loop_.message_loop_proxy())); |
| 243 video_decoders.push_back( | 241 video_decoders.push_back( |
| 244 new FFmpegVideoDecoder(message_loop_.message_loop_proxy())); | 242 new FFmpegVideoDecoder(message_loop_.message_loop_proxy())); |
| 245 | 243 |
| 246 // Disable frame dropping if hashing is enabled. | 244 scoped_ptr<VideoFrameScheduler> scheduler; |
| 245 if (!clockless_playback_) { |
| 246 scheduler.reset(new VideoFrameSchedulerImpl( |
| 247 message_loop_.message_loop_proxy(), |
| 248 base::Bind(&PipelineIntegrationTestBase::OnVideoRendererPaint, |
| 249 base::Unretained(this)))); |
| 250 } else { |
| 251 scheduler.reset(new ClocklessVideoFrameScheduler( |
| 252 base::Bind(&PipelineIntegrationTestBase::OnVideoRendererPaint, |
| 253 base::Unretained(this)))); |
| 254 } |
| 255 |
| 247 scoped_ptr<VideoRenderer> renderer(new VideoRendererImpl( | 256 scoped_ptr<VideoRenderer> renderer(new VideoRendererImpl( |
| 248 message_loop_.message_loop_proxy(), | 257 message_loop_.message_loop_proxy(), |
| 258 scheduler.Pass(), |
| 249 video_decoders.Pass(), | 259 video_decoders.Pass(), |
| 250 base::Bind(&PipelineIntegrationTestBase::SetDecryptor, | 260 base::Bind(&PipelineIntegrationTestBase::SetDecryptor, |
| 251 base::Unretained(this), | 261 base::Unretained(this), |
| 252 decryptor), | 262 decryptor))); |
| 253 base::Bind(&PipelineIntegrationTestBase::OnVideoRendererPaint, | |
| 254 base::Unretained(this)), | |
| 255 false)); | |
| 256 collection->SetVideoRenderer(renderer.Pass()); | 263 collection->SetVideoRenderer(renderer.Pass()); |
| 257 | 264 |
| 258 if (!clockless_playback_) { | 265 if (!clockless_playback_) { |
| 259 audio_sink_ = new NullAudioSink(message_loop_.message_loop_proxy()); | 266 audio_sink_ = new NullAudioSink(message_loop_.message_loop_proxy()); |
| 260 } else { | 267 } else { |
| 261 clockless_audio_sink_ = new ClocklessAudioSink(); | 268 clockless_audio_sink_ = new ClocklessAudioSink(); |
| 262 } | 269 } |
| 263 | 270 |
| 264 ScopedVector<AudioDecoder> audio_decoders; | 271 ScopedVector<AudioDecoder> audio_decoders; |
| 265 audio_decoders.push_back( | 272 audio_decoders.push_back( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 std::string PipelineIntegrationTestBase::GetAudioHash() { | 326 std::string PipelineIntegrationTestBase::GetAudioHash() { |
| 320 DCHECK(hashing_enabled_); | 327 DCHECK(hashing_enabled_); |
| 321 return audio_sink_->GetAudioHashForTesting(); | 328 return audio_sink_->GetAudioHashForTesting(); |
| 322 } | 329 } |
| 323 | 330 |
| 324 base::TimeDelta PipelineIntegrationTestBase::GetAudioTime() { | 331 base::TimeDelta PipelineIntegrationTestBase::GetAudioTime() { |
| 325 DCHECK(clockless_playback_); | 332 DCHECK(clockless_playback_); |
| 326 return clockless_audio_sink_->render_time(); | 333 return clockless_audio_sink_->render_time(); |
| 327 } | 334 } |
| 328 | 335 |
| 329 base::TimeTicks DummyTickClock::NowTicks() { | |
| 330 now_ += base::TimeDelta::FromSeconds(60); | |
| 331 return now_; | |
| 332 } | |
| 333 | |
| 334 } // namespace media | 336 } // namespace media |
| OLD | NEW |