| 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 22 matching lines...) Expand all Loading... |
| 33 using ::testing::AnyNumber; | 33 using ::testing::AnyNumber; |
| 34 using ::testing::AtLeast; | 34 using ::testing::AtLeast; |
| 35 using ::testing::AtMost; | 35 using ::testing::AtMost; |
| 36 using ::testing::Invoke; | 36 using ::testing::Invoke; |
| 37 using ::testing::InvokeWithoutArgs; | 37 using ::testing::InvokeWithoutArgs; |
| 38 using ::testing::Return; | 38 using ::testing::Return; |
| 39 using ::testing::SaveArg; | 39 using ::testing::SaveArg; |
| 40 | 40 |
| 41 namespace media { | 41 namespace media { |
| 42 | 42 |
| 43 namespace { |
| 44 |
| 45 class RendererFactoryImpl final : public PipelineTestRendererFactory { |
| 46 public: |
| 47 explicit RendererFactoryImpl(PipelineIntegrationTestBase* integration_test) |
| 48 : integration_test_(integration_test) {} |
| 49 ~RendererFactoryImpl() override {} |
| 50 |
| 51 // PipelineTestRendererFactory implementation. |
| 52 std::unique_ptr<Renderer> CreateRenderer( |
| 53 ScopedVector<VideoDecoder> prepend_video_decoders = |
| 54 ScopedVector<VideoDecoder>(), |
| 55 ScopedVector<AudioDecoder> prepend_audio_decoders = |
| 56 ScopedVector<AudioDecoder>()) override { |
| 57 return integration_test_->CreateRenderer(std::move(prepend_video_decoders), |
| 58 std::move(prepend_audio_decoders)); |
| 59 } |
| 60 |
| 61 private: |
| 62 PipelineIntegrationTestBase* integration_test_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(RendererFactoryImpl); |
| 65 }; |
| 66 |
| 67 } // namespace |
| 68 |
| 43 const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e"; | 69 const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e"; |
| 44 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,"; | 70 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,"; |
| 45 | 71 |
| 46 PipelineIntegrationTestBase::PipelineIntegrationTestBase() | 72 PipelineIntegrationTestBase::PipelineIntegrationTestBase() |
| 47 : hashing_enabled_(false), | 73 : hashing_enabled_(false), |
| 48 clockless_playback_(false), | 74 clockless_playback_(false), |
| 49 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())), | 75 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())), |
| 50 ended_(false), | 76 ended_(false), |
| 51 pipeline_status_(PIPELINE_OK), | 77 pipeline_status_(PIPELINE_OK), |
| 52 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN), | 78 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN), |
| 53 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED), | 79 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED), |
| 54 current_duration_(kInfiniteDuration) { | 80 current_duration_(kInfiniteDuration), |
| 81 renderer_factory_(new RendererFactoryImpl(this)) { |
| 55 ResetVideoHash(); | 82 ResetVideoHash(); |
| 56 } | 83 } |
| 57 | 84 |
| 58 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() { | 85 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() { |
| 59 if (pipeline_->IsRunning()) | 86 if (pipeline_->IsRunning()) |
| 60 Stop(); | 87 Stop(); |
| 61 | 88 |
| 62 pipeline_.reset(); | 89 pipeline_.reset(); |
| 63 base::RunLoop().RunUntilIdle(); | 90 base::RunLoop().RunUntilIdle(); |
| 64 } | 91 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 pipeline_->SetCdm( | 196 pipeline_->SetCdm( |
| 170 cdm_context, base::Bind(&PipelineIntegrationTestBase::DecryptorAttached, | 197 cdm_context, base::Bind(&PipelineIntegrationTestBase::DecryptorAttached, |
| 171 base::Unretained(this))); | 198 base::Unretained(this))); |
| 172 } | 199 } |
| 173 | 200 |
| 174 // Should never be called as the required decryption keys for the encrypted | 201 // Should never be called as the required decryption keys for the encrypted |
| 175 // media files are provided in advance. | 202 // media files are provided in advance. |
| 176 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 203 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
| 177 | 204 |
| 178 pipeline_->Start( | 205 pipeline_->Start( |
| 179 demuxer_.get(), CreateRenderer(std::move(prepend_video_decoders), | 206 demuxer_.get(), |
| 180 std::move(prepend_audio_decoders)), | 207 renderer_factory_->CreateRenderer(std::move(prepend_video_decoders), |
| 208 std::move(prepend_audio_decoders)), |
| 181 this, base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, | 209 this, base::Bind(&PipelineIntegrationTestBase::OnStatusCallback, |
| 182 base::Unretained(this))); | 210 base::Unretained(this))); |
| 183 base::RunLoop().Run(); | 211 base::RunLoop().Run(); |
| 184 return pipeline_status_; | 212 return pipeline_status_; |
| 185 } | 213 } |
| 186 | 214 |
| 187 PipelineStatus PipelineIntegrationTestBase::StartWithFile( | 215 PipelineStatus PipelineIntegrationTestBase::StartWithFile( |
| 188 const std::string& filename, | 216 const std::string& filename, |
| 189 CdmContext* cdm_context, | 217 CdmContext* cdm_context, |
| 190 uint8_t test_type, | 218 uint8_t test_type, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 base::Unretained(this))); | 278 base::Unretained(this))); |
| 251 base::RunLoop().Run(); | 279 base::RunLoop().Run(); |
| 252 return (pipeline_status_ == PIPELINE_OK); | 280 return (pipeline_status_ == PIPELINE_OK); |
| 253 } | 281 } |
| 254 | 282 |
| 255 bool PipelineIntegrationTestBase::Resume(base::TimeDelta seek_time) { | 283 bool PipelineIntegrationTestBase::Resume(base::TimeDelta seek_time) { |
| 256 ended_ = false; | 284 ended_ = false; |
| 257 | 285 |
| 258 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 286 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 259 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); | 287 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); |
| 260 pipeline_->Resume(CreateRenderer(), seek_time, | 288 pipeline_->Resume(renderer_factory_->CreateRenderer(), seek_time, |
| 261 base::Bind(&PipelineIntegrationTestBase::OnSeeked, | 289 base::Bind(&PipelineIntegrationTestBase::OnSeeked, |
| 262 base::Unretained(this), seek_time)); | 290 base::Unretained(this), seek_time)); |
| 263 base::RunLoop().Run(); | 291 base::RunLoop().Run(); |
| 264 return (pipeline_status_ == PIPELINE_OK); | 292 return (pipeline_status_ == PIPELINE_OK); |
| 265 } | 293 } |
| 266 | 294 |
| 267 void PipelineIntegrationTestBase::Stop() { | 295 void PipelineIntegrationTestBase::Stop() { |
| 268 DCHECK(pipeline_->IsRunning()); | 296 DCHECK(pipeline_->IsRunning()); |
| 269 pipeline_->Stop(); | 297 pipeline_->Stop(); |
| 270 base::RunLoop().RunUntilIdle(); | 298 base::RunLoop().RunUntilIdle(); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 DCHECK(clockless_playback_); | 470 DCHECK(clockless_playback_); |
| 443 return clockless_audio_sink_->render_time(); | 471 return clockless_audio_sink_->render_time(); |
| 444 } | 472 } |
| 445 | 473 |
| 446 base::TimeTicks DummyTickClock::NowTicks() { | 474 base::TimeTicks DummyTickClock::NowTicks() { |
| 447 now_ += base::TimeDelta::FromSeconds(60); | 475 now_ += base::TimeDelta::FromSeconds(60); |
| 448 return now_; | 476 return now_; |
| 449 } | 477 } |
| 450 | 478 |
| 451 } // namespace media | 479 } // namespace media |
| OLD | NEW |