| 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/test/pipeline_integration_test_base.h" | 5 #include "media/test/pipeline_integration_test_base.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 void PipelineIntegrationTestBase::OnError(PipelineStatus status) { | 123 void PipelineIntegrationTestBase::OnError(PipelineStatus status) { |
| 124 DCHECK_NE(status, PIPELINE_OK); | 124 DCHECK_NE(status, PIPELINE_OK); |
| 125 pipeline_status_ = status; | 125 pipeline_status_ = status; |
| 126 message_loop_.task_runner()->PostTask( | 126 message_loop_.task_runner()->PostTask( |
| 127 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 127 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 PipelineStatus PipelineIntegrationTestBase::StartInternal( | 130 PipelineStatus PipelineIntegrationTestBase::StartInternal( |
| 131 std::unique_ptr<DataSource> data_source, | 131 std::unique_ptr<DataSource> data_source, |
| 132 CdmContext* cdm_context, | 132 CdmContext* cdm_context, |
| 133 uint8_t test_type) { | 133 uint8_t test_type, |
| 134 ScopedVector<VideoDecoder> prepend_video_decoders, |
| 135 ScopedVector<AudioDecoder> prepend_audio_decoders) { |
| 134 hashing_enabled_ = test_type & kHashed; | 136 hashing_enabled_ = test_type & kHashed; |
| 135 clockless_playback_ = test_type & kClockless; | 137 clockless_playback_ = test_type & kClockless; |
| 136 | 138 |
| 137 EXPECT_CALL(*this, OnMetadata(_)) | 139 EXPECT_CALL(*this, OnMetadata(_)) |
| 138 .Times(AtMost(1)) | 140 .Times(AtMost(1)) |
| 139 .WillRepeatedly(SaveArg<0>(&metadata_)); | 141 .WillRepeatedly(SaveArg<0>(&metadata_)); |
| 140 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 142 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 141 .Times(AnyNumber()); | 143 .Times(AnyNumber()); |
| 142 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) | 144 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 143 .Times(AnyNumber()); | 145 .Times(AnyNumber()); |
| 144 EXPECT_CALL(*this, OnDurationChange()).Times(AtMost(1)); | 146 EXPECT_CALL(*this, OnDurationChange()).Times(AtMost(1)); |
| 145 EXPECT_CALL(*this, OnVideoNaturalSizeChange(_)).Times(AtMost(1)); | 147 EXPECT_CALL(*this, OnVideoNaturalSizeChange(_)).Times(AtMost(1)); |
| 146 EXPECT_CALL(*this, OnVideoOpacityChange(_)).Times(AtMost(1)); | 148 EXPECT_CALL(*this, OnVideoOpacityChange(_)).Times(AtMost(1)); |
| 147 CreateDemuxer(std::move(data_source)); | 149 CreateDemuxer(std::move(data_source)); |
| 148 | 150 |
| 149 if (cdm_context) { | 151 if (cdm_context) { |
| 150 EXPECT_CALL(*this, DecryptorAttached(true)); | 152 EXPECT_CALL(*this, DecryptorAttached(true)); |
| 151 pipeline_->SetCdm( | 153 pipeline_->SetCdm( |
| 152 cdm_context, base::Bind(&PipelineIntegrationTestBase::DecryptorAttached, | 154 cdm_context, base::Bind(&PipelineIntegrationTestBase::DecryptorAttached, |
| 153 base::Unretained(this))); | 155 base::Unretained(this))); |
| 154 } | 156 } |
| 155 | 157 |
| 156 // Should never be called as the required decryption keys for the encrypted | 158 // Should never be called as the required decryption keys for the encrypted |
| 157 // media files are provided in advance. | 159 // media files are provided in advance. |
| 158 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 160 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
| 159 | 161 |
| 160 pipeline_->Start(demuxer_.get(), CreateRenderer(), this, | 162 pipeline_->Start( |
| 161 base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, | 163 demuxer_.get(), CreateRenderer(std::move(prepend_video_decoders), |
| 162 base::Unretained(this))); | 164 std::move(prepend_audio_decoders)), |
| 165 this, base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, |
| 166 base::Unretained(this))); |
| 163 base::RunLoop().Run(); | 167 base::RunLoop().Run(); |
| 164 return pipeline_status_; | 168 return pipeline_status_; |
| 165 } | 169 } |
| 166 | 170 |
| 167 PipelineStatus PipelineIntegrationTestBase::StartWithFile( | 171 PipelineStatus PipelineIntegrationTestBase::StartWithFile( |
| 168 const std::string& filename, | 172 const std::string& filename, |
| 169 CdmContext* cdm_context, | 173 CdmContext* cdm_context, |
| 170 uint8_t test_type) { | 174 uint8_t test_type, |
| 175 ScopedVector<VideoDecoder> prepend_video_decoders, |
| 176 ScopedVector<AudioDecoder> prepend_audio_decoders) { |
| 171 std::unique_ptr<FileDataSource> file_data_source(new FileDataSource()); | 177 std::unique_ptr<FileDataSource> file_data_source(new FileDataSource()); |
| 172 base::FilePath file_path(GetTestDataFilePath(filename)); | 178 base::FilePath file_path(GetTestDataFilePath(filename)); |
| 173 CHECK(file_data_source->Initialize(file_path)) << "Is " << file_path.value() | 179 CHECK(file_data_source->Initialize(file_path)) << "Is " << file_path.value() |
| 174 << " missing?"; | 180 << " missing?"; |
| 175 return StartInternal(std::move(file_data_source), cdm_context, test_type); | 181 return StartInternal(std::move(file_data_source), cdm_context, test_type, |
| 182 std::move(prepend_video_decoders), |
| 183 std::move(prepend_audio_decoders)); |
| 176 } | 184 } |
| 177 | 185 |
| 178 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename) { | 186 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename) { |
| 179 return StartWithFile(filename, nullptr, kNormal); | 187 return StartWithFile(filename, nullptr, kNormal); |
| 180 } | 188 } |
| 181 | 189 |
| 182 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename, | 190 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename, |
| 183 CdmContext* cdm_context) { | 191 CdmContext* cdm_context) { |
| 184 return StartWithFile(filename, cdm_context, kNormal); | 192 return StartWithFile(filename, cdm_context, kNormal); |
| 185 } | 193 } |
| 186 | 194 |
| 187 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename, | 195 PipelineStatus PipelineIntegrationTestBase::Start( |
| 188 uint8_t test_type) { | 196 const std::string& filename, |
| 189 return StartWithFile(filename, nullptr, test_type); | 197 uint8_t test_type, |
| 198 ScopedVector<VideoDecoder> prepend_video_decoders, |
| 199 ScopedVector<AudioDecoder> prepend_audio_decoders) { |
| 200 return StartWithFile(filename, nullptr, test_type, |
| 201 std::move(prepend_video_decoders), |
| 202 std::move(prepend_audio_decoders)); |
| 190 } | 203 } |
| 191 | 204 |
| 192 PipelineStatus PipelineIntegrationTestBase::Start(const uint8_t* data, | 205 PipelineStatus PipelineIntegrationTestBase::Start(const uint8_t* data, |
| 193 size_t size, | 206 size_t size, |
| 194 uint8_t test_type) { | 207 uint8_t test_type) { |
| 195 return StartInternal(base::MakeUnique<MemoryDataSource>(data, size), nullptr, | 208 return StartInternal(base::MakeUnique<MemoryDataSource>(data, size), nullptr, |
| 196 test_type); | 209 test_type); |
| 197 } | 210 } |
| 198 | 211 |
| 199 void PipelineIntegrationTestBase::Play() { | 212 void PipelineIntegrationTestBase::Play() { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 demuxer_ = std::unique_ptr<Demuxer>(new FFmpegDemuxer( | 297 demuxer_ = std::unique_ptr<Demuxer>(new FFmpegDemuxer( |
| 285 message_loop_.task_runner(), data_source_.get(), | 298 message_loop_.task_runner(), data_source_.get(), |
| 286 base::Bind(&PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB, | 299 base::Bind(&PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB, |
| 287 base::Unretained(this)), | 300 base::Unretained(this)), |
| 288 base::Bind(&PipelineIntegrationTestBase::DemuxerMediaTracksUpdatedCB, | 301 base::Bind(&PipelineIntegrationTestBase::DemuxerMediaTracksUpdatedCB, |
| 289 base::Unretained(this)), | 302 base::Unretained(this)), |
| 290 new MediaLog())); | 303 new MediaLog())); |
| 291 #endif | 304 #endif |
| 292 } | 305 } |
| 293 | 306 |
| 294 std::unique_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer() { | 307 std::unique_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer( |
| 295 ScopedVector<VideoDecoder> video_decoders; | 308 ScopedVector<VideoDecoder> prepend_video_decoders, |
| 309 ScopedVector<AudioDecoder> prepend_audio_decoders) { |
| 310 ScopedVector<VideoDecoder> video_decoders = std::move(prepend_video_decoders); |
| 296 #if !defined(MEDIA_DISABLE_LIBVPX) | 311 #if !defined(MEDIA_DISABLE_LIBVPX) |
| 297 video_decoders.push_back(new VpxVideoDecoder()); | 312 video_decoders.push_back(new VpxVideoDecoder()); |
| 298 #endif // !defined(MEDIA_DISABLE_LIBVPX) | 313 #endif // !defined(MEDIA_DISABLE_LIBVPX) |
| 299 | 314 |
| 300 // Android does not have an ffmpeg video decoder. | 315 // Android does not have an ffmpeg video decoder. |
| 301 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(OS_ANDROID) | 316 #if !defined(MEDIA_DISABLE_FFMPEG) && !defined(OS_ANDROID) |
| 302 video_decoders.push_back(new FFmpegVideoDecoder()); | 317 video_decoders.push_back(new FFmpegVideoDecoder()); |
| 303 #endif | 318 #endif |
| 304 | 319 |
| 305 // Simulate a 60Hz rendering sink. | 320 // Simulate a 60Hz rendering sink. |
| 306 video_sink_.reset(new NullVideoSink( | 321 video_sink_.reset(new NullVideoSink( |
| 307 clockless_playback_, base::TimeDelta::FromSecondsD(1.0 / 60), | 322 clockless_playback_, base::TimeDelta::FromSecondsD(1.0 / 60), |
| 308 base::Bind(&PipelineIntegrationTestBase::OnVideoFramePaint, | 323 base::Bind(&PipelineIntegrationTestBase::OnVideoFramePaint, |
| 309 base::Unretained(this)), | 324 base::Unretained(this)), |
| 310 message_loop_.task_runner())); | 325 message_loop_.task_runner())); |
| 311 | 326 |
| 312 // Disable frame dropping if hashing is enabled. | 327 // Disable frame dropping if hashing is enabled. |
| 313 std::unique_ptr<VideoRenderer> video_renderer(new VideoRendererImpl( | 328 std::unique_ptr<VideoRenderer> video_renderer(new VideoRendererImpl( |
| 314 message_loop_.task_runner(), message_loop_.task_runner().get(), | 329 message_loop_.task_runner(), message_loop_.task_runner().get(), |
| 315 video_sink_.get(), std::move(video_decoders), false, nullptr, | 330 video_sink_.get(), std::move(video_decoders), false, nullptr, |
| 316 new MediaLog())); | 331 new MediaLog())); |
| 317 | 332 |
| 318 ScopedVector<AudioDecoder> audio_decoders; | 333 ScopedVector<AudioDecoder> audio_decoders = std::move(prepend_audio_decoders); |
| 319 | 334 |
| 320 #if !defined(MEDIA_DISABLE_FFMPEG) | 335 #if !defined(MEDIA_DISABLE_FFMPEG) |
| 321 audio_decoders.push_back( | 336 audio_decoders.push_back( |
| 322 new FFmpegAudioDecoder(message_loop_.task_runner(), new MediaLog())); | 337 new FFmpegAudioDecoder(message_loop_.task_runner(), new MediaLog())); |
| 323 #endif | 338 #endif |
| 324 | 339 |
| 325 audio_decoders.push_back(new OpusAudioDecoder(message_loop_.task_runner())); | 340 audio_decoders.push_back(new OpusAudioDecoder(message_loop_.task_runner())); |
| 326 | 341 |
| 327 if (!clockless_playback_) { | 342 if (!clockless_playback_) { |
| 328 audio_sink_ = new NullAudioSink(message_loop_.task_runner()); | 343 audio_sink_ = new NullAudioSink(message_loop_.task_runner()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 DCHECK(clockless_playback_); | 416 DCHECK(clockless_playback_); |
| 402 return clockless_audio_sink_->render_time(); | 417 return clockless_audio_sink_->render_time(); |
| 403 } | 418 } |
| 404 | 419 |
| 405 base::TimeTicks DummyTickClock::NowTicks() { | 420 base::TimeTicks DummyTickClock::NowTicks() { |
| 406 now_ += base::TimeDelta::FromSeconds(60); | 421 now_ += base::TimeDelta::FromSeconds(60); |
| 407 return now_; | 422 return now_; |
| 408 } | 423 } |
| 409 | 424 |
| 410 } // namespace media | 425 } // namespace media |
| OLD | NEW |