| Index: media/test/pipeline_integration_test_base.cc
|
| diff --git a/media/test/pipeline_integration_test_base.cc b/media/test/pipeline_integration_test_base.cc
|
| index b2fd6f608808f6a898df374bf93c36ccbcb7152d..4f5636fba3893f68193b5e15f02c357f50faef8a 100644
|
| --- a/media/test/pipeline_integration_test_base.cc
|
| +++ b/media/test/pipeline_integration_test_base.cc
|
| @@ -12,11 +12,9 @@
|
| #include "base/memory/scoped_vector.h"
|
| #include "base/run_loop.h"
|
| #include "base/single_thread_task_runner.h"
|
| -#include "media/base/cdm_context.h"
|
| #include "media/base/media_log.h"
|
| #include "media/base/media_tracks.h"
|
| #include "media/base/test_data_util.h"
|
| -#include "media/filters/chunk_demuxer.h"
|
| #if !defined(MEDIA_DISABLE_FFMPEG)
|
| #include "media/filters/ffmpeg_audio_decoder.h"
|
| #include "media/filters/ffmpeg_demuxer.h"
|
| @@ -26,6 +24,8 @@
|
| #include "media/filters/memory_data_source.h"
|
| #include "media/renderers/audio_renderer_impl.h"
|
| #include "media/renderers/renderer_impl.h"
|
| +#include "media/test/fake_encrypted_media.h"
|
| +#include "media/test/mock_media_source.h"
|
| #if !defined(MEDIA_DISABLE_LIBVPX)
|
| #include "media/filters/vpx_video_decoder.h"
|
| #endif
|
| @@ -83,6 +83,26 @@ static ScopedVector<AudioDecoder> CreateAudioDecodersForTest(
|
| const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e";
|
| const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,";
|
|
|
| +class RendererFactoryImpl final : public PipelineTestRendererFactory {
|
| + public:
|
| + explicit RendererFactoryImpl(PipelineIntegrationTestBase* integration_test)
|
| + : integration_test_(integration_test) {}
|
| + ~RendererFactoryImpl() override {}
|
| +
|
| + // PipelineTestRendererFactory implementation.
|
| + std::unique_ptr<Renderer> CreateRenderer(
|
| + CreateVideoDecodersCB prepend_video_decoders_cb,
|
| + CreateAudioDecodersCB prepend_audio_decoders_cb) override {
|
| + return integration_test_->CreateRenderer(prepend_video_decoders_cb,
|
| + prepend_audio_decoders_cb);
|
| + }
|
| +
|
| + private:
|
| + PipelineIntegrationTestBase* integration_test_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RendererFactoryImpl);
|
| +};
|
| +
|
| PipelineIntegrationTestBase::PipelineIntegrationTestBase()
|
| : hashing_enabled_(false),
|
| clockless_playback_(false),
|
| @@ -91,7 +111,8 @@ PipelineIntegrationTestBase::PipelineIntegrationTestBase()
|
| pipeline_status_(PIPELINE_OK),
|
| last_video_frame_format_(PIXEL_FORMAT_UNKNOWN),
|
| last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED),
|
| - current_duration_(kInfiniteDuration) {
|
| + current_duration_(kInfiniteDuration),
|
| + renderer_factory_(new RendererFactoryImpl(this)) {
|
| ResetVideoHash();
|
| EXPECT_CALL(*this, OnVideoAverageKeyframeDistanceUpdate()).Times(AnyNumber());
|
| }
|
| @@ -217,12 +238,12 @@ PipelineStatus PipelineIntegrationTestBase::StartInternal(
|
| // media files are provided in advance.
|
| EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
|
|
|
| - pipeline_->Start(
|
| - demuxer_.get(),
|
| - CreateRenderer(prepend_video_decoders_cb, prepend_audio_decoders_cb),
|
| - this,
|
| - base::Bind(&PipelineIntegrationTestBase::OnStatusCallback,
|
| - base::Unretained(this)));
|
| + pipeline_->Start(demuxer_.get(),
|
| + renderer_factory_->CreateRenderer(prepend_video_decoders_cb,
|
| + prepend_audio_decoders_cb),
|
| + this,
|
| + base::Bind(&PipelineIntegrationTestBase::OnStatusCallback,
|
| + base::Unretained(this)));
|
| base::RunLoop().Run();
|
| return pipeline_status_;
|
| }
|
| @@ -298,7 +319,9 @@ bool PipelineIntegrationTestBase::Resume(base::TimeDelta seek_time) {
|
|
|
| EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
|
| .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow));
|
| - pipeline_->Resume(CreateRenderer(), seek_time,
|
| + pipeline_->Resume(renderer_factory_->CreateRenderer(CreateVideoDecodersCB(),
|
| + CreateAudioDecodersCB()),
|
| + seek_time,
|
| base::Bind(&PipelineIntegrationTestBase::OnSeeked,
|
| base::Unretained(this), seek_time));
|
| base::RunLoop().Run();
|
| @@ -472,6 +495,73 @@ base::TimeDelta PipelineIntegrationTestBase::GetAudioTime() {
|
| return clockless_audio_sink_->render_time();
|
| }
|
|
|
| +PipelineStatus PipelineIntegrationTestBase::StartPipelineWithMediaSource(
|
| + MockMediaSource* source) {
|
| + return StartPipelineWithMediaSource(source, kNormal, nullptr);
|
| +}
|
| +
|
| +PipelineStatus PipelineIntegrationTestBase::StartPipelineWithEncryptedMedia(
|
| + MockMediaSource* source,
|
| + FakeEncryptedMedia* encrypted_media) {
|
| + return StartPipelineWithMediaSource(source, kNormal, encrypted_media);
|
| +}
|
| +
|
| +PipelineStatus PipelineIntegrationTestBase::StartPipelineWithMediaSource(
|
| + MockMediaSource* source,
|
| + uint8_t test_type,
|
| + FakeEncryptedMedia* encrypted_media) {
|
| + hashing_enabled_ = test_type & kHashed;
|
| + clockless_playback_ = test_type & kClockless;
|
| +
|
| + if (!(test_type & kExpectDemuxerFailure))
|
| + EXPECT_CALL(*source, InitSegmentReceivedMock(_)).Times(AtLeast(1));
|
| +
|
| + EXPECT_CALL(*this, OnMetadata(_))
|
| + .Times(AtMost(1))
|
| + .WillRepeatedly(SaveArg<0>(&metadata_));
|
| + EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
|
| + .Times(AnyNumber());
|
| + EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
|
| + .Times(AnyNumber());
|
| + EXPECT_CALL(*this, OnDurationChange()).Times(AnyNumber());
|
| + EXPECT_CALL(*this, OnVideoNaturalSizeChange(_)).Times(AtMost(1));
|
| + EXPECT_CALL(*this, OnVideoOpacityChange(_)).Times(AtMost(1));
|
| +
|
| + source->set_demuxer_failure_cb(base::Bind(
|
| + &PipelineIntegrationTestBase::OnStatusCallback, base::Unretained(this)));
|
| + demuxer_ = source->GetDemuxer();
|
| +
|
| + if (encrypted_media) {
|
| + EXPECT_CALL(*this, DecryptorAttached(true));
|
| +
|
| + // Encrypted content used but keys provided in advance, so this is
|
| + // never called.
|
| + EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
|
| + pipeline_->SetCdm(
|
| + encrypted_media->GetCdmContext(),
|
| + base::Bind(&PipelineIntegrationTestBase::DecryptorAttached,
|
| + base::Unretained(this)));
|
| + } else {
|
| + // Encrypted content not used, so this is never called.
|
| + EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
|
| + }
|
| +
|
| + pipeline_->Start(demuxer_.get(),
|
| + renderer_factory_->CreateRenderer(CreateVideoDecodersCB(),
|
| + CreateAudioDecodersCB()),
|
| + this,
|
| + base::Bind(&PipelineIntegrationTestBase::OnStatusCallback,
|
| + base::Unretained(this)));
|
| +
|
| + if (encrypted_media) {
|
| + source->set_encrypted_media_init_data_cb(
|
| + base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData,
|
| + base::Unretained(encrypted_media)));
|
| + }
|
| + base::RunLoop().Run();
|
| + return pipeline_status_;
|
| +}
|
| +
|
| base::TimeTicks DummyTickClock::NowTicks() {
|
| now_ += base::TimeDelta::FromSeconds(60);
|
| return now_;
|
|
|