From 59c321f25857b9bc81cb57670854ff9783a44970 Mon Sep 17 00:00:00 2001 From: xhwang Date: Fri, 5 Jun 2015 16:46:55 -0700 Subject: [PATCH] media: Reland "Simplify {Audio|Video}Decoder initialization callback." This reverts commit e51969862119f6a721ec5299e41f01cd3df5fd4a with fixes in media/cast/sender/h264_vt_encoder_unittest.cc TBR=dalecurtis@chromium.org,watk@chromium.org,bbudge@chromium.org BUG=126070,332204 TEST=Updated unittests. Review URL: https://codereview.chromium.org/1143223007 Cr-Commit-Position: refs/heads/master@{#333178} --- content/renderer/pepper/video_decoder_shim.cc | 20 +++----------- media/base/audio_decoder.h | 11 +++++--- media/base/mock_filters.h | 11 ++++---- media/base/test_helpers.cc | 7 +++++ media/base/test_helpers.h | 1 + media/base/video_decoder.h | 13 +++++---- media/cast/sender/h264_vt_encoder_unittest.cc | 10 +++---- media/filters/audio_decoder_selector_unittest.cc | 27 +++++++------------ media/filters/audio_decoder_unittest.cc | 13 +++++---- media/filters/decoder_selector.cc | 9 +++---- media/filters/decoder_selector.h | 4 +-- media/filters/decoder_stream.cc | 4 +-- media/filters/decoder_stream.h | 6 +++-- media/filters/decoder_stream_traits.cc | 8 +++--- media/filters/decoder_stream_traits.h | 8 +++--- media/filters/decrypting_audio_decoder.cc | 16 +++++------ media/filters/decrypting_audio_decoder.h | 4 +-- media/filters/decrypting_audio_decoder_unittest.cc | 18 ++++++------- media/filters/decrypting_video_decoder.cc | 12 ++++----- media/filters/decrypting_video_decoder.h | 4 +-- media/filters/decrypting_video_decoder_unittest.cc | 31 +++++++++------------- media/filters/fake_video_decoder.cc | 8 +++--- media/filters/fake_video_decoder.h | 4 +-- media/filters/fake_video_decoder_unittest.cc | 16 +++++------ media/filters/ffmpeg_audio_decoder.cc | 8 +++--- media/filters/ffmpeg_audio_decoder.h | 2 +- media/filters/ffmpeg_video_decoder.cc | 8 +++--- media/filters/ffmpeg_video_decoder.h | 2 +- media/filters/ffmpeg_video_decoder_unittest.cc | 30 ++++++++++----------- media/filters/gpu_video_decoder.cc | 26 +++++++++--------- media/filters/gpu_video_decoder.h | 2 +- media/filters/opus_audio_decoder.cc | 8 +++--- media/filters/opus_audio_decoder.h | 2 +- media/filters/video_decoder_selector_unittest.cc | 18 ++++++------- media/filters/vpx_video_decoder.cc | 8 +++--- media/filters/vpx_video_decoder.h | 2 +- media/renderers/audio_renderer_impl_unittest.cc | 13 ++++----- media/renderers/video_renderer_impl_unittest.cc | 18 +++++++------ 38 files changed, 200 insertions(+), 212 deletions(-) diff --git a/content/renderer/pepper/video_decoder_shim.cc b/content/renderer/pepper/video_decoder_shim.cc index ca5e551c8167..b7bd4cec50cd 100644 --- a/content/renderer/pepper/video_decoder_shim.cc +++ b/content/renderer/pepper/video_decoder_shim.cc @@ -633,7 +633,7 @@ class VideoDecoderShim::DecoderImpl { void Stop(); private: - void OnPipelineStatus(media::PipelineStatus status); + void OnInitDone(bool success); void DoDecode(); void OnDecodeComplete(media::VideoDecoder::Status status); void OnOutputComplete(const scoped_refptr& frame); @@ -692,7 +692,7 @@ void VideoDecoderShim::DecoderImpl::Initialize( decoder_->Initialize( config, true /* low_delay */, - base::Bind(&VideoDecoderShim::DecoderImpl::OnPipelineStatus, + base::Bind(&VideoDecoderShim::DecoderImpl::OnInitDone, weak_ptr_factory_.GetWeakPtr()), base::Bind(&VideoDecoderShim::DecoderImpl::OnOutputComplete, weak_ptr_factory_.GetWeakPtr())); @@ -731,20 +731,8 @@ void VideoDecoderShim::DecoderImpl::Stop() { // This instance is deleted once we exit this scope. } -void VideoDecoderShim::DecoderImpl::OnPipelineStatus( - media::PipelineStatus status) { - int32_t result; - switch (status) { - case media::PIPELINE_OK: - result = PP_OK; - break; - case media::DECODER_ERROR_NOT_SUPPORTED: - result = PP_ERROR_NOTSUPPORTED; - break; - default: - result = PP_ERROR_FAILED; - break; - } +void VideoDecoderShim::DecoderImpl::OnInitDone(bool success) { + int32_t result = success ? PP_OK : PP_ERROR_NOTSUPPORTED; // Calculate how many textures the shim should create. uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1; diff --git a/media/base/audio_decoder.h b/media/base/audio_decoder.h index cee0bbcaf526..3da8547c8ee9 100644 --- a/media/base/audio_decoder.h +++ b/media/base/audio_decoder.h @@ -26,11 +26,14 @@ class MEDIA_EXPORT AudioDecoder { // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums // match, break them into a decoder_status.h. enum Status { - kOk, // We're all good. - kAborted, // We aborted as a result of Reset() or destruction. + kOk, // We're all good. + kAborted, // We aborted as a result of Reset() or destruction. kDecodeError // A decoding error occurred. }; + // Callback for VideoDecoder initialization. + typedef base::Callback InitCB; + // Callback for AudioDecoder to return a decoded frame whenever it becomes // available. Only non-EOS frames should be returned via this callback. typedef base::Callback&)> OutputCB; @@ -53,10 +56,10 @@ class MEDIA_EXPORT AudioDecoder { // Initializes an AudioDecoder with the given DemuxerStream, executing the // callback upon completion. - // |statistics_cb| is used to update global pipeline statistics. + // |init_cb| is used to return initialization status. // |output_cb| is called for decoded audio buffers (see Decode()). virtual void Initialize(const AudioDecoderConfig& config, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) = 0; // Requests samples to be decoded. Only one decode may be in flight at any diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index 31358758079e..0f0b7ce70f00 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -82,10 +82,11 @@ class MockVideoDecoder : public VideoDecoder { // VideoDecoder implementation. virtual std::string GetDisplayName() const; - MOCK_METHOD4(Initialize, void(const VideoDecoderConfig& config, - bool low_delay, - const PipelineStatusCB& status_cb, - const OutputCB& output_cb)); + MOCK_METHOD4(Initialize, + void(const VideoDecoderConfig& config, + bool low_delay, + const InitCB& init_cb, + const OutputCB& output_cb)); MOCK_METHOD2(Decode, void(const scoped_refptr& buffer, const DecodeCB&)); MOCK_METHOD1(Reset, void(const base::Closure&)); @@ -104,7 +105,7 @@ class MockAudioDecoder : public AudioDecoder { virtual std::string GetDisplayName() const; MOCK_METHOD3(Initialize, void(const AudioDecoderConfig& config, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb)); MOCK_METHOD2(Decode, void(const scoped_refptr& buffer, diff --git a/media/base/test_helpers.cc b/media/base/test_helpers.cc index bbfbd64a5a90..f4ba9915007b 100644 --- a/media/base/test_helpers.cc +++ b/media/base/test_helpers.cc @@ -27,6 +27,7 @@ class MockCallback : public base::RefCountedThreadSafe { public: MockCallback(); MOCK_METHOD0(Run, void()); + MOCK_METHOD1(RunWithBool, void(bool)); MOCK_METHOD1(RunWithStatus, void(PipelineStatus)); protected: @@ -46,6 +47,12 @@ base::Closure NewExpectedClosure() { return base::Bind(&MockCallback::Run, callback); } +base::Callback NewExpectedBoolCB(bool success) { + StrictMock* callback = new StrictMock(); + EXPECT_CALL(*callback, RunWithBool(success)); + return base::Bind(&MockCallback::RunWithBool, callback); +} + PipelineStatusCB NewExpectedStatusCB(PipelineStatus status) { StrictMock* callback = new StrictMock(); EXPECT_CALL(*callback, RunWithStatus(status)); diff --git a/media/base/test_helpers.h b/media/base/test_helpers.h index 712812fc4f6b..05ba898994d6 100644 --- a/media/base/test_helpers.h +++ b/media/base/test_helpers.h @@ -28,6 +28,7 @@ class DecoderBuffer; // Return a callback that expects to be run once. base::Closure NewExpectedClosure(); +base::Callback NewExpectedBoolCB(bool success); PipelineStatusCB NewExpectedStatusCB(PipelineStatus status); // Helper class for running a message loop until a callback has run. Useful for diff --git a/media/base/video_decoder.h b/media/base/video_decoder.h index 85c08f3e375a..f7bae3cce463 100644 --- a/media/base/video_decoder.h +++ b/media/base/video_decoder.h @@ -25,11 +25,14 @@ class MEDIA_EXPORT VideoDecoder { // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums // match, break them into a decoder_status.h. enum Status { - kOk, // Everything went as planned. - kAborted, // Decode was aborted as a result of Reset() being called. + kOk, // Everything went as planned. + kAborted, // Decode was aborted as a result of Reset() being called. kDecodeError // Decoding error happened. }; + // Callback for VideoDecoder initialization. + typedef base::Callback InitCB; + // Callback for VideoDecoder to return a decoded frame whenever it becomes // available. Only non-EOS frames should be returned via this callback. typedef base::Callback&)> OutputCB; @@ -51,7 +54,7 @@ class MEDIA_EXPORT VideoDecoder { virtual std::string GetDisplayName() const = 0; // Initializes a VideoDecoder with the given |config|, executing the - // |status_cb| upon completion. |output_cb| is called for each output frame + // |init_cb| upon completion. |output_cb| is called for each output frame // decoded by Decode(). // // If |low_delay| is true then the decoder is not allowed to queue frames, @@ -64,10 +67,10 @@ class MEDIA_EXPORT VideoDecoder { // 1) The VideoDecoder will be reinitialized if it was initialized before. // Upon reinitialization, all internal buffered frames will be dropped. // 2) This method should not be called during pending decode or reset. - // 3) No VideoDecoder calls should be made before |status_cb| is executed. + // 3) No VideoDecoder calls should be made before |init_cb| is executed. virtual void Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) = 0; // Requests a |buffer| to be decoded. The status of the decoder and decoded diff --git a/media/cast/sender/h264_vt_encoder_unittest.cc b/media/cast/sender/h264_vt_encoder_unittest.cc index d9790a8f0d4f..89e7c54c0b47 100644 --- a/media/cast/sender/h264_vt_encoder_unittest.cc +++ b/media/cast/sender/h264_vt_encoder_unittest.cc @@ -65,8 +65,8 @@ namespace cast { // See comment in end2end_unittest.cc for details on this value. const double kVideoAcceptedPSNR = 38.0; -void SavePipelineStatus(PipelineStatus* out_status, PipelineStatus in_status) { - *out_status = in_status; +void SaveDecoderInitResult(bool* out_result, bool in_result) { + *out_result = in_result; } void SaveOperationalStatus(OperationalStatus* out_status, @@ -132,13 +132,13 @@ class EndToEndFrameChecker explicit EndToEndFrameChecker(const VideoDecoderConfig& config) : decoder_(base::MessageLoop::current()->task_runner()), count_frames_checked_(0) { - PipelineStatus pipeline_status; + bool decoder_init_result; decoder_.Initialize( - config, false, base::Bind(&SavePipelineStatus, &pipeline_status), + config, false, base::Bind(&SaveDecoderInitResult, &decoder_init_result), base::Bind(&EndToEndFrameChecker::CompareFrameWithExpected, base::Unretained(this))); base::MessageLoop::current()->RunUntilIdle(); - EXPECT_EQ(PIPELINE_OK, pipeline_status); + EXPECT_TRUE(decoder_init_result); } void PushExpectation(const scoped_refptr& frame) { diff --git a/media/filters/audio_decoder_selector_unittest.cc b/media/filters/audio_decoder_selector_unittest.cc index 2bb1f6d263e7..29570c97fbf2 100644 --- a/media/filters/audio_decoder_selector_unittest.cc +++ b/media/filters/audio_decoder_selector_unittest.cc @@ -196,8 +196,7 @@ TEST_F(AudioDecoderSelectorTest, ClearStream_NoDecryptor_OneClearDecoder) { UseClearStream(); InitializeDecoderSelector(kNoDecryptor, 1); - EXPECT_CALL(*decoder_1_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(PIPELINE_OK)); + EXPECT_CALL(*decoder_1_, Initialize(_, _, _)).WillOnce(RunCallback<1>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_1_, IsNull())); SelectDecoder(); @@ -219,10 +218,8 @@ TEST_F(AudioDecoderSelectorTest, ClearStream_NoDecryptor_MultipleClearDecoder) { UseClearStream(); InitializeDecoderSelector(kNoDecryptor, 2); - EXPECT_CALL(*decoder_1_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); - EXPECT_CALL(*decoder_2_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(PIPELINE_OK)); + EXPECT_CALL(*decoder_1_, Initialize(_, _, _)).WillOnce(RunCallback<1>(false)); + EXPECT_CALL(*decoder_2_, Initialize(_, _, _)).WillOnce(RunCallback<1>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_2_, IsNull())); SelectDecoder(); @@ -233,8 +230,7 @@ TEST_F(AudioDecoderSelectorTest, UseClearStream(); InitializeDecoderSelector(kNoDecryptor, 2); - EXPECT_CALL(*decoder_1_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); + EXPECT_CALL(*decoder_1_, Initialize(_, _, _)).WillOnce(RunCallback<1>(false)); EXPECT_CALL(*decoder_2_, Initialize(_, _, _)); SelectDecoderAndDestroy(); @@ -246,8 +242,7 @@ TEST_F(AudioDecoderSelectorTest, ClearStream_HasDecryptor) { UseClearStream(); InitializeDecoderSelector(kDecryptOnly, 1); - EXPECT_CALL(*decoder_1_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(PIPELINE_OK)); + EXPECT_CALL(*decoder_1_, Initialize(_, _, _)).WillOnce(RunCallback<1>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_1_, IsNull())); SelectDecoder(); @@ -297,8 +292,7 @@ TEST_F(AudioDecoderSelectorTest, EncryptedStream_DecryptOnly_OneClearDecoder) { UseEncryptedStream(); InitializeDecoderSelector(kDecryptOnly, 1); - EXPECT_CALL(*decoder_1_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(PIPELINE_OK)); + EXPECT_CALL(*decoder_1_, Initialize(_, _, _)).WillOnce(RunCallback<1>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_1_, NotNull())); SelectDecoder(); @@ -322,10 +316,8 @@ TEST_F(AudioDecoderSelectorTest, UseEncryptedStream(); InitializeDecoderSelector(kDecryptOnly, 2); - EXPECT_CALL(*decoder_1_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); - EXPECT_CALL(*decoder_2_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(PIPELINE_OK)); + EXPECT_CALL(*decoder_1_, Initialize(_, _, _)).WillOnce(RunCallback<1>(false)); + EXPECT_CALL(*decoder_2_, Initialize(_, _, _)).WillOnce(RunCallback<1>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_2_, NotNull())); SelectDecoder(); @@ -336,8 +328,7 @@ TEST_F(AudioDecoderSelectorTest, UseEncryptedStream(); InitializeDecoderSelector(kDecryptOnly, 2); - EXPECT_CALL(*decoder_1_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); + EXPECT_CALL(*decoder_1_, Initialize(_, _, _)).WillOnce(RunCallback<1>(false)); EXPECT_CALL(*decoder_2_, Initialize(_, _, _)); SelectDecoderAndDestroy(); diff --git a/media/filters/audio_decoder_unittest.cc b/media/filters/audio_decoder_unittest.cc index 42b00ee13b81..cd38e4201c37 100644 --- a/media/filters/audio_decoder_unittest.cc +++ b/media/filters/audio_decoder_unittest.cc @@ -161,14 +161,13 @@ class AudioDecoderTest : public testing::TestWithParam { } void InitializeDecoder(const AudioDecoderConfig& config) { - InitializeDecoderWithStatus(config, PIPELINE_OK); + InitializeDecoderWithResult(config, true); } - void InitializeDecoderWithStatus(const AudioDecoderConfig& config, - PipelineStatus status) { + void InitializeDecoderWithResult(const AudioDecoderConfig& config, + bool success) { decoder_->Initialize( - config, - NewExpectedStatusCB(status), + config, NewExpectedBoolCB(success), base::Bind(&AudioDecoderTest::OnDecoderOutput, base::Unretained(this))); base::RunLoop().RunUntilIdle(); } @@ -403,7 +402,7 @@ TEST_P(OpusAudioDecoderBehavioralTest, InitializeWithBadCodecDelay) { base::TimeDelta::FromMilliseconds(80), // Use a different codec delay than in the extradata. 100); - InitializeDecoderWithStatus(decoder_config, DECODER_ERROR_NOT_SUPPORTED); + InitializeDecoderWithResult(decoder_config, false); } TEST_P(FFmpegAudioDecoderBehavioralTest, InitializeWithBadConfig) { @@ -415,7 +414,7 @@ TEST_P(FFmpegAudioDecoderBehavioralTest, InitializeWithBadConfig) { NULL, 0, false); - InitializeDecoderWithStatus(decoder_config, DECODER_ERROR_NOT_SUPPORTED); + InitializeDecoderWithResult(decoder_config, false); } const DecodedBufferExpectations kSfxOpusExpectations[] = { diff --git a/media/filters/decoder_selector.cc b/media/filters/decoder_selector.cc index 555a411bd760..44630010669a 100644 --- a/media/filters/decoder_selector.cc +++ b/media/filters/decoder_selector.cc @@ -119,12 +119,11 @@ void DecoderSelector::SelectDecoder( } template -void DecoderSelector::DecryptingDecoderInitDone( - PipelineStatus status) { +void DecoderSelector::DecryptingDecoderInitDone(bool success) { DVLOG(2) << __FUNCTION__; DCHECK(task_runner_->BelongsToCurrentThread()); - if (status == PIPELINE_OK) { + if (success) { base::ResetAndReturn(&select_decoder_cb_) .Run(decoder_.Pass(), scoped_ptr()); return; @@ -179,11 +178,11 @@ void DecoderSelector::InitializeDecoder() { } template -void DecoderSelector::DecoderInitDone(PipelineStatus status) { +void DecoderSelector::DecoderInitDone(bool success) { DVLOG(2) << __FUNCTION__; DCHECK(task_runner_->BelongsToCurrentThread()); - if (status != PIPELINE_OK) { + if (!success) { decoder_.reset(); InitializeDecoder(); return; diff --git a/media/filters/decoder_selector.h b/media/filters/decoder_selector.h index 59c90f576449..9fa591e2b8f6 100644 --- a/media/filters/decoder_selector.h +++ b/media/filters/decoder_selector.h @@ -74,10 +74,10 @@ class MEDIA_EXPORT DecoderSelector { const base::Closure& waiting_for_decryption_key_cb); private: - void DecryptingDecoderInitDone(PipelineStatus status); + void DecryptingDecoderInitDone(bool success); void DecryptingDemuxerStreamInitDone(PipelineStatus status); void InitializeDecoder(); - void DecoderInitDone(PipelineStatus status); + void DecoderInitDone(bool success); void ReturnNullDecoder(); scoped_refptr task_runner_; diff --git a/media/filters/decoder_stream.cc b/media/filters/decoder_stream.cc index 757bd60987b8..bacba005ec74 100644 --- a/media/filters/decoder_stream.cc +++ b/media/filters/decoder_stream.cc @@ -506,7 +506,7 @@ void DecoderStream::ReinitializeDecoder() { } template -void DecoderStream::OnDecoderReinitialized(PipelineStatus status) { +void DecoderStream::OnDecoderReinitialized(bool success) { FUNCTION_DVLOG(2); DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER); @@ -517,7 +517,7 @@ void DecoderStream::OnDecoderReinitialized(PipelineStatus status) { // Also, Reset() can be called during pending ReinitializeDecoder(). // This function needs to handle them all! - if (status != PIPELINE_OK) { + if (!success) { // Reinitialization failed. Try to fall back to one of the remaining // decoders. This will consume at least one decoder so doing it more than // once is safe. diff --git a/media/filters/decoder_stream.h b/media/filters/decoder_stream.h index e5b0cfcea53f..ce29ac086da2 100644 --- a/media/filters/decoder_stream.h +++ b/media/filters/decoder_stream.h @@ -36,7 +36,6 @@ class MEDIA_EXPORT DecoderStream { typedef DecoderStreamTraits StreamTraits; typedef typename StreamTraits::DecoderType Decoder; typedef typename StreamTraits::OutputType Output; - typedef typename StreamTraits::StreamInitCB InitCB; typedef typename Decoder::Status DecoderStatus; enum Status { @@ -46,6 +45,9 @@ class MEDIA_EXPORT DecoderStream { DECODE_ERROR, // Decoder returned decode error. }; + // Indicates completion of a DecoderStream initialization. + typedef base::Callback InitCB; + // Indicates completion of a DecoderStream read. typedef base::Callback&)> ReadCB; @@ -155,7 +157,7 @@ class MEDIA_EXPORT DecoderStream { void ReinitializeDecoder(); // Callback for Decoder reinitialization. - void OnDecoderReinitialized(PipelineStatus status); + void OnDecoderReinitialized(bool success); void CompleteDecoderReinitialization(bool success); diff --git a/media/filters/decoder_stream_traits.cc b/media/filters/decoder_stream_traits.cc index de8f86009b7f..7583b172b27a 100644 --- a/media/filters/decoder_stream_traits.cc +++ b/media/filters/decoder_stream_traits.cc @@ -21,10 +21,10 @@ std::string DecoderStreamTraits::ToString() { void DecoderStreamTraits::InitializeDecoder( DecoderType* decoder, DemuxerStream* stream, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DCHECK(stream->audio_decoder_config().IsValidConfig()); - decoder->Initialize(stream->audio_decoder_config(), status_cb, output_cb); + decoder->Initialize(stream->audio_decoder_config(), init_cb, output_cb); } void DecoderStreamTraits::ReportStatistics( @@ -47,12 +47,12 @@ std::string DecoderStreamTraits::ToString() { void DecoderStreamTraits::InitializeDecoder( DecoderType* decoder, DemuxerStream* stream, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DCHECK(stream->video_decoder_config().IsValidConfig()); decoder->Initialize(stream->video_decoder_config(), stream->liveness() == DemuxerStream::LIVENESS_LIVE, - status_cb, output_cb); + init_cb, output_cb); } bool DecoderStreamTraits::NeedsBitstreamConversion( diff --git a/media/filters/decoder_stream_traits.h b/media/filters/decoder_stream_traits.h index 707ff1ca27fc..8caf2df193be 100644 --- a/media/filters/decoder_stream_traits.h +++ b/media/filters/decoder_stream_traits.h @@ -26,13 +26,13 @@ struct DecoderStreamTraits { typedef AudioBuffer OutputType; typedef AudioDecoder DecoderType; typedef DecryptingAudioDecoder DecryptingDecoderType; - typedef base::Callback StreamInitCB; + typedef base::Callback InitCB; typedef base::Callback&)> OutputCB; static std::string ToString(); static void InitializeDecoder(DecoderType* decoder, DemuxerStream* stream, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb); static bool NeedsBitstreamConversion(DecoderType* decoder) { return false; } static void ReportStatistics(const StatisticsCB& statistics_cb, @@ -45,13 +45,13 @@ struct DecoderStreamTraits { typedef VideoFrame OutputType; typedef VideoDecoder DecoderType; typedef DecryptingVideoDecoder DecryptingDecoderType; - typedef base::Callback StreamInitCB; + typedef base::Callback InitCB; typedef base::Callback&)> OutputCB; static std::string ToString(); static void InitializeDecoder(DecoderType* decoder, DemuxerStream* stream, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb); static bool NeedsBitstreamConversion(DecoderType* decoder); static void ReportStatistics(const StatisticsCB& statistics_cb, diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc index 7c8f4b20ec6e..7b3d27961617 100644 --- a/media/filters/decrypting_audio_decoder.cc +++ b/media/filters/decrypting_audio_decoder.cc @@ -48,7 +48,7 @@ std::string DecryptingAudioDecoder::GetDisplayName() const { } void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DVLOG(2) << "Initialize()"; DCHECK(task_runner_->BelongsToCurrentThread()); @@ -56,18 +56,18 @@ void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config, DCHECK(reset_cb_.is_null()); weak_this_ = weak_factory_.GetWeakPtr(); - init_cb_ = BindToCurrentLoop(status_cb); + init_cb_ = BindToCurrentLoop(init_cb); output_cb_ = BindToCurrentLoop(output_cb); if (!config.IsValidConfig()) { DLOG(ERROR) << "Invalid audio stream config."; - base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_DECODE); + base::ResetAndReturn(&init_cb_).Run(false); return; } // DecryptingAudioDecoder only accepts potentially encrypted stream. if (!config.is_encrypted()) { - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); + base::ResetAndReturn(&init_cb_).Run(false); return; } @@ -162,7 +162,7 @@ DecryptingAudioDecoder::~DecryptingAudioDecoder() { base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); pending_buffer_to_decode_ = NULL; if (!init_cb_.is_null()) - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); + base::ResetAndReturn(&init_cb_).Run(false); if (!decode_cb_.is_null()) base::ResetAndReturn(&decode_cb_).Run(kAborted); if (!reset_cb_.is_null()) @@ -181,7 +181,7 @@ void DecryptingAudioDecoder::SetDecryptor( set_decryptor_ready_cb_.Reset(); if (!decryptor) { - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); + base::ResetAndReturn(&init_cb_).Run(false); state_ = kError; decryptor_attached_cb.Run(false); return; @@ -210,7 +210,7 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) { DCHECK(decode_cb_.is_null()); // No Decode() before initialization finished. if (!success) { - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); + base::ResetAndReturn(&init_cb_).Run(false); decryptor_ = NULL; state_ = kError; return; @@ -226,7 +226,7 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) { base::Bind(&DecryptingAudioDecoder::OnKeyAdded, weak_this_))); state_ = kIdle; - base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); + base::ResetAndReturn(&init_cb_).Run(true); } void DecryptingAudioDecoder::DecodePendingBuffer() { diff --git a/media/filters/decrypting_audio_decoder.h b/media/filters/decrypting_audio_decoder.h index 30b0a63926d3..e1cc0487d83d 100644 --- a/media/filters/decrypting_audio_decoder.h +++ b/media/filters/decrypting_audio_decoder.h @@ -39,7 +39,7 @@ class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { // AudioDecoder implementation. std::string GetDisplayName() const override; void Initialize(const AudioDecoderConfig& config, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) override; void Decode(const scoped_refptr& buffer, const DecodeCB& decode_cb) override; @@ -93,7 +93,7 @@ class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { State state_; - PipelineStatusCB init_cb_; + InitCB init_cb_; OutputCB output_cb_; DecodeCB decode_cb_; base::Closure reset_cb_; diff --git a/media/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc index 1f8395bf53a7..bb82a4c484d2 100644 --- a/media/filters/decrypting_audio_decoder_unittest.cc +++ b/media/filters/decrypting_audio_decoder_unittest.cc @@ -79,8 +79,8 @@ class DecryptingAudioDecoderTest : public testing::Test { Destroy(); } - void InitializeAndExpectStatus(const AudioDecoderConfig& config, - PipelineStatus status) { + void InitializeAndExpectResult(const AudioDecoderConfig& config, + bool success) { // Initialize data now that the config is known. Since the code uses // invalid values (that CreateEmptyBuffer() doesn't support), tweak them // just for CreateEmptyBuffer(). @@ -94,7 +94,7 @@ class DecryptingAudioDecoderTest : public testing::Test { kNoTimestamp()); decoded_frame_list_.push_back(decoded_frame_); - decoder_->Initialize(config, NewExpectedStatusCB(status), + decoder_->Initialize(config, NewExpectedBoolCB(success), base::Bind(&DecryptingAudioDecoderTest::FrameReady, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -119,7 +119,7 @@ class DecryptingAudioDecoderTest : public testing::Test { config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32, CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true, true, base::TimeDelta(), 0); - InitializeAndExpectStatus(config_, PIPELINE_OK); + InitializeAndExpectResult(config_, true); } void Reinitialize() { @@ -132,7 +132,7 @@ class DecryptingAudioDecoderTest : public testing::Test { .WillOnce(RunCallback<1>(true)); EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _)) .WillOnce(SaveArg<1>(&key_added_cb_)); - decoder_->Initialize(new_config, NewExpectedStatusCB(PIPELINE_OK), + decoder_->Initialize(new_config, NewExpectedBoolCB(true), base::Bind(&DecryptingAudioDecoderTest::FrameReady, base::Unretained(this))); } @@ -288,7 +288,7 @@ TEST_F(DecryptingAudioDecoderTest, Initialize_UnencryptedAudioConfig) { AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32, CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, false); - InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeAndExpectResult(config, false); } // Ensure decoder handles invalid audio configs without crashing. @@ -296,7 +296,7 @@ TEST_F(DecryptingAudioDecoderTest, Initialize_InvalidAudioConfig) { AudioDecoderConfig config(kUnknownAudioCodec, kUnknownSampleFormat, CHANNEL_LAYOUT_STEREO, 0, NULL, 0, true); - InitializeAndExpectStatus(config, PIPELINE_ERROR_DECODE); + InitializeAndExpectResult(config, false); } // Ensure decoder handles unsupported audio configs without crashing. @@ -307,14 +307,14 @@ TEST_F(DecryptingAudioDecoderTest, Initialize_UnsupportedAudioConfig) { AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32, CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true); - InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeAndExpectResult(config, false); } TEST_F(DecryptingAudioDecoderTest, Initialize_NullDecryptor) { ExpectDecryptorNotification(NULL, false); AudioDecoderConfig config(kCodecVorbis, kSampleFormatPlanarF32, CHANNEL_LAYOUT_STEREO, kSampleRate, NULL, 0, true); - InitializeAndExpectStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeAndExpectResult(config, false); } // Test normal decrypt and decode case. diff --git a/media/filters/decrypting_video_decoder.cc b/media/filters/decrypting_video_decoder.cc index fdffe83e84c9..3627080a8653 100644 --- a/media/filters/decrypting_video_decoder.cc +++ b/media/filters/decrypting_video_decoder.cc @@ -39,7 +39,7 @@ std::string DecryptingVideoDecoder::GetDisplayName() const { void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config, bool /* low_delay */, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DVLOG(2) << "Initialize()"; DCHECK(task_runner_->BelongsToCurrentThread()); @@ -51,7 +51,7 @@ void DecryptingVideoDecoder::Initialize(const VideoDecoderConfig& config, DCHECK(config.IsValidConfig()); DCHECK(config.is_encrypted()); - init_cb_ = BindToCurrentLoop(status_cb); + init_cb_ = BindToCurrentLoop(init_cb); output_cb_ = BindToCurrentLoop(output_cb); weak_this_ = weak_factory_.GetWeakPtr(); config_ = config; @@ -146,7 +146,7 @@ DecryptingVideoDecoder::~DecryptingVideoDecoder() { base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); pending_buffer_to_decode_ = NULL; if (!init_cb_.is_null()) - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); + base::ResetAndReturn(&init_cb_).Run(false); if (!decode_cb_.is_null()) base::ResetAndReturn(&decode_cb_).Run(kAborted); if (!reset_cb_.is_null()) @@ -164,7 +164,7 @@ void DecryptingVideoDecoder::SetDecryptor( set_decryptor_ready_cb_.Reset(); if (!decryptor) { - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); + base::ResetAndReturn(&init_cb_).Run(false); state_ = kError; decryptor_attached_cb.Run(false); return; @@ -189,7 +189,7 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) { DCHECK(decode_cb_.is_null()); // No Decode() before initialization finished. if (!success) { - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); + base::ResetAndReturn(&init_cb_).Run(false); decryptor_ = NULL; state_ = kError; return; @@ -202,7 +202,7 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) { // Success! state_ = kIdle; - base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); + base::ResetAndReturn(&init_cb_).Run(true); } diff --git a/media/filters/decrypting_video_decoder.h b/media/filters/decrypting_video_decoder.h index a2a952844d95..fda546e8f763 100644 --- a/media/filters/decrypting_video_decoder.h +++ b/media/filters/decrypting_video_decoder.h @@ -36,7 +36,7 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { std::string GetDisplayName() const override; void Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) override; void Decode(const scoped_refptr& buffer, const DecodeCB& decode_cb) override; @@ -85,7 +85,7 @@ class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { State state_; - PipelineStatusCB init_cb_; + InitCB init_cb_; OutputCB output_cb_; DecodeCB decode_cb_; base::Closure reset_cb_; diff --git a/media/filters/decrypting_video_decoder_unittest.cc b/media/filters/decrypting_video_decoder_unittest.cc index 285bab67aa19..bc3f93aec958 100644 --- a/media/filters/decrypting_video_decoder_unittest.cc +++ b/media/filters/decrypting_video_decoder_unittest.cc @@ -81,11 +81,11 @@ class DecryptingVideoDecoderTest : public testing::Test { EXPECT_CALL(*this, DecryptorSet(expected_result)); } - // Initializes the |decoder_| and expects |status|. Note the initialization + // Initializes the |decoder_| and expects |success|. Note the initialization // can succeed or fail. - void InitializeAndExpectStatus(const VideoDecoderConfig& config, - PipelineStatus status) { - decoder_->Initialize(config, false, NewExpectedStatusCB(status), + void InitializeAndExpectResult(const VideoDecoderConfig& config, + bool success) { + decoder_->Initialize(config, false, NewExpectedBoolCB(success), base::Bind(&DecryptingVideoDecoderTest::FrameReady, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -99,7 +99,7 @@ class DecryptingVideoDecoderTest : public testing::Test { EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _)) .WillOnce(SaveArg<1>(&key_added_cb_)); - InitializeAndExpectStatus(TestVideoConfig::NormalEncrypted(), PIPELINE_OK); + InitializeAndExpectResult(TestVideoConfig::NormalEncrypted(), true); } // Reinitialize the |decoder_| and expects it to succeed. @@ -110,7 +110,7 @@ class DecryptingVideoDecoderTest : public testing::Test { EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kVideo, _)) .WillOnce(SaveArg<1>(&key_added_cb_)); - InitializeAndExpectStatus(TestVideoConfig::LargeEncrypted(), PIPELINE_OK); + InitializeAndExpectResult(TestVideoConfig::LargeEncrypted(), true); } // Decode |buffer| and expect DecodeDone to get called with |status|. @@ -259,8 +259,7 @@ TEST_F(DecryptingVideoDecoderTest, Initialize_Normal) { TEST_F(DecryptingVideoDecoderTest, Initialize_NullDecryptor) { ExpectDecryptorNotification(NULL, false); - InitializeAndExpectStatus(TestVideoConfig::NormalEncrypted(), - DECODER_ERROR_NOT_SUPPORTED); + InitializeAndExpectResult(TestVideoConfig::NormalEncrypted(), false); } TEST_F(DecryptingVideoDecoderTest, Initialize_Failure) { @@ -270,8 +269,7 @@ TEST_F(DecryptingVideoDecoderTest, Initialize_Failure) { .WillRepeatedly(SaveArg<1>(&key_added_cb_)); EXPECT_CALL(*this, RequestDecryptorNotification(_)).Times(2); - InitializeAndExpectStatus(TestVideoConfig::NormalEncrypted(), - DECODER_ERROR_NOT_SUPPORTED); + InitializeAndExpectResult(TestVideoConfig::NormalEncrypted(), false); } TEST_F(DecryptingVideoDecoderTest, Reinitialize_Normal) { @@ -289,9 +287,8 @@ TEST_F(DecryptingVideoDecoderTest, Reinitialize_Failure) { .WillOnce(RunCallback<1>(false)); // Reinitialize() expects the reinitialization to succeed. Call - // InitializeAndExpectStatus() directly to test the reinitialization failure. - InitializeAndExpectStatus(TestVideoConfig::NormalEncrypted(), - DECODER_ERROR_NOT_SUPPORTED); + // InitializeAndExpectResult() directly to test the reinitialization failure. + InitializeAndExpectResult(TestVideoConfig::NormalEncrypted(), false); } // Test normal decrypt and decode case. @@ -413,9 +410,8 @@ TEST_F(DecryptingVideoDecoderTest, Destroy_DuringDecryptorRequested) { DecryptorReadyCB decryptor_ready_cb; EXPECT_CALL(*this, RequestDecryptorNotification(_)) .WillOnce(SaveArg<0>(&decryptor_ready_cb)); - decoder_->Initialize(TestVideoConfig::NormalEncrypted(), - false, - NewExpectedStatusCB(DECODER_ERROR_NOT_SUPPORTED), + decoder_->Initialize(TestVideoConfig::NormalEncrypted(), false, + NewExpectedBoolCB(false), base::Bind(&DecryptingVideoDecoderTest::FrameReady, base::Unretained(this))); message_loop_.RunUntilIdle(); @@ -439,8 +435,7 @@ TEST_F(DecryptingVideoDecoderTest, Destroy_DuringPendingDecoderInit) { EXPECT_CALL(*decryptor_, InitializeVideoDecoder(_, _)) .WillOnce(SaveArg<1>(&pending_init_cb_)); - InitializeAndExpectStatus(TestVideoConfig::NormalEncrypted(), - DECODER_ERROR_NOT_SUPPORTED); + InitializeAndExpectResult(TestVideoConfig::NormalEncrypted(), false); EXPECT_FALSE(pending_init_cb_.is_null()); Destroy(); diff --git a/media/filters/fake_video_decoder.cc b/media/filters/fake_video_decoder.cc index 4c6fa9a7712b..276a5ac50644 100644 --- a/media/filters/fake_video_decoder.cc +++ b/media/filters/fake_video_decoder.cc @@ -47,7 +47,7 @@ std::string FakeVideoDecoder::GetDisplayName() const { void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(config.IsValidConfig()); @@ -56,7 +56,7 @@ void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config, DCHECK(reset_cb_.IsNull()) << "No reinitialization during pending reset."; current_config_ = config; - init_cb_.SetCallback(BindToCurrentLoop(status_cb)); + init_cb_.SetCallback(BindToCurrentLoop(init_cb)); // Don't need BindToCurrentLoop() because |output_cb_| is only called from // RunDecodeCallback() which is posted from Decode(). @@ -69,10 +69,10 @@ void FakeVideoDecoder::Initialize(const VideoDecoderConfig& config, if (fail_to_initialize_) { state_ = STATE_ERROR; - init_cb_.RunOrHold(DECODER_ERROR_NOT_SUPPORTED); + init_cb_.RunOrHold(false); } else { state_ = STATE_NORMAL; - init_cb_.RunOrHold(PIPELINE_OK); + init_cb_.RunOrHold(true); } } diff --git a/media/filters/fake_video_decoder.h b/media/filters/fake_video_decoder.h index bf407b995d0c..e784387bd6d4 100644 --- a/media/filters/fake_video_decoder.h +++ b/media/filters/fake_video_decoder.h @@ -44,7 +44,7 @@ class FakeVideoDecoder : public VideoDecoder { std::string GetDisplayName() const override; void Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) override; void Decode(const scoped_refptr& buffer, const DecodeCB& decode_cb) override; @@ -101,7 +101,7 @@ class FakeVideoDecoder : public VideoDecoder { State state_; - CallbackHolder init_cb_; + CallbackHolder init_cb_; CallbackHolder reset_cb_; OutputCB output_cb_; diff --git a/media/filters/fake_video_decoder_unittest.cc b/media/filters/fake_video_decoder_unittest.cc index 4bb9911a1237..f335c02654da 100644 --- a/media/filters/fake_video_decoder_unittest.cc +++ b/media/filters/fake_video_decoder_unittest.cc @@ -47,17 +47,17 @@ class FakeVideoDecoderTest Destroy(); } - void InitializeWithConfigAndExpectStatus(const VideoDecoderConfig& config, - PipelineStatus status) { + void InitializeWithConfigAndExpectResult(const VideoDecoderConfig& config, + bool success) { decoder_->Initialize( - config, false, NewExpectedStatusCB(status), + config, false, NewExpectedBoolCB(success), base::Bind(&FakeVideoDecoderTest::FrameReady, base::Unretained(this))); message_loop_.RunUntilIdle(); current_config_ = config; } void Initialize() { - InitializeWithConfigAndExpectStatus(TestVideoConfig::Normal(), PIPELINE_OK); + InitializeWithConfigAndExpectResult(TestVideoConfig::Normal(), true); } void EnterPendingInitState() { @@ -252,8 +252,7 @@ TEST_P(FakeVideoDecoderTest, Initialize) { TEST_P(FakeVideoDecoderTest, SimulateFailureToInitialize) { decoder_->SimulateFailureToInit(); - InitializeWithConfigAndExpectStatus(TestVideoConfig::Normal(), - DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigAndExpectResult(TestVideoConfig::Normal(), false); Decode(); EXPECT_EQ(last_decode_status_, VideoDecoder::kDecodeError); } @@ -345,7 +344,7 @@ TEST_P(FakeVideoDecoderTest, ReadWithHold_DecodingDelay) { TEST_P(FakeVideoDecoderTest, Reinitialize) { Initialize(); ReadOneFrame(); - InitializeWithConfigAndExpectStatus(TestVideoConfig::Large(), PIPELINE_OK); + InitializeWithConfigAndExpectResult(TestVideoConfig::Large(), true); ReadOneFrame(); } @@ -353,8 +352,7 @@ TEST_P(FakeVideoDecoderTest, SimulateFailureToReinitialize) { Initialize(); ReadOneFrame(); decoder_->SimulateFailureToInit(); - InitializeWithConfigAndExpectStatus(TestVideoConfig::Normal(), - DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigAndExpectResult(TestVideoConfig::Normal(), false); Decode(); EXPECT_EQ(last_decode_status_, VideoDecoder::kDecodeError); } diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc index 2f8bf1b87f79..22a907b621be 100644 --- a/media/filters/ffmpeg_audio_decoder.cc +++ b/media/filters/ffmpeg_audio_decoder.cc @@ -147,7 +147,7 @@ std::string FFmpegAudioDecoder::GetDisplayName() const { } void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(!config.is_encrypted()); @@ -155,17 +155,17 @@ void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, FFmpegGlue::InitializeFFmpeg(); config_ = config; - PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); + InitCB bound_init_cb = BindToCurrentLoop(init_cb); if (!config.IsValidConfig() || !ConfigureDecoder()) { - initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED); + bound_init_cb.Run(false); return; } // Success! output_cb_ = BindToCurrentLoop(output_cb); state_ = kNormal; - initialize_cb.Run(PIPELINE_OK); + bound_init_cb.Run(true); } void FFmpegAudioDecoder::Decode(const scoped_refptr& buffer, diff --git a/media/filters/ffmpeg_audio_decoder.h b/media/filters/ffmpeg_audio_decoder.h index c9429f989de9..2446ce59a481 100644 --- a/media/filters/ffmpeg_audio_decoder.h +++ b/media/filters/ffmpeg_audio_decoder.h @@ -38,7 +38,7 @@ class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { // AudioDecoder implementation. std::string GetDisplayName() const override; void Initialize(const AudioDecoderConfig& config, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) override; void Decode(const scoped_refptr& buffer, const DecodeCB& decode_cb) override; diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc index 5d03c808c6eb..43f72de51fcd 100644 --- a/media/filters/ffmpeg_video_decoder.cc +++ b/media/filters/ffmpeg_video_decoder.cc @@ -162,7 +162,7 @@ std::string FFmpegVideoDecoder::GetDisplayName() const { void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(!config.is_encrypted()); @@ -171,10 +171,10 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config, FFmpegGlue::InitializeFFmpeg(); config_ = config; - PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); + InitCB bound_init_cb = BindToCurrentLoop(init_cb); if (!config.IsValidConfig() || !ConfigureDecoder(low_delay)) { - initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED); + bound_init_cb.Run(false); return; } @@ -182,7 +182,7 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config, // Success! state_ = kNormal; - initialize_cb.Run(PIPELINE_OK); + bound_init_cb.Run(true); } void FFmpegVideoDecoder::Decode(const scoped_refptr& buffer, diff --git a/media/filters/ffmpeg_video_decoder.h b/media/filters/ffmpeg_video_decoder.h index 8acc4c8e02d4..6cd1a523b783 100644 --- a/media/filters/ffmpeg_video_decoder.h +++ b/media/filters/ffmpeg_video_decoder.h @@ -39,7 +39,7 @@ class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { std::string GetDisplayName() const override; void Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) override; void Decode(const scoped_refptr& buffer, const DecodeCB& decode_cb) override; diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc index e902bd04f1d7..160d18f24a5b 100644 --- a/media/filters/ffmpeg_video_decoder_unittest.cc +++ b/media/filters/ffmpeg_video_decoder_unittest.cc @@ -68,16 +68,16 @@ class FFmpegVideoDecoderTest : public testing::Test { InitializeWithConfig(TestVideoConfig::Normal()); } - void InitializeWithConfigAndStatus(const VideoDecoderConfig& config, - PipelineStatus status) { - decoder_->Initialize(config, false, NewExpectedStatusCB(status), + void InitializeWithConfigWithResult(const VideoDecoderConfig& config, + bool success) { + decoder_->Initialize(config, false, NewExpectedBoolCB(success), base::Bind(&FFmpegVideoDecoderTest::FrameReady, base::Unretained(this))); message_loop_.RunUntilIdle(); } void InitializeWithConfig(const VideoDecoderConfig& config) { - InitializeWithConfigAndStatus(config, PIPELINE_OK); + InitializeWithConfigWithResult(config, true); } void Reinitialize() { @@ -217,8 +217,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_Normal) { TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedDecoder) { // Test avcodec_find_decoder() returning NULL. - InitializeWithConfigAndStatus(TestVideoConfig::Invalid(), - DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(TestVideoConfig::Invalid(), false); } TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedPixelFormat) { @@ -227,7 +226,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_UnsupportedPixelFormat) { VideoFrame::UNKNOWN, kCodedSize, kVisibleRect, kNaturalSize, NULL, 0, false); - InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(config, false); } TEST_F(FFmpegVideoDecoderTest, Initialize_OpenDecoderFails) { @@ -236,7 +235,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_OpenDecoderFails) { kVideoFormat, kCodedSize, kVisibleRect, kNaturalSize, NULL, 0, false); - InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(config, false); } TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorZero) { @@ -250,7 +249,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorZero) { NULL, 0, false); - InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(config, false); } TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorZero) { @@ -264,7 +263,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorZero) { NULL, 0, false); - InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(config, false); } TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorNegative) { @@ -278,7 +277,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorNegative) { NULL, 0, false); - InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(config, false); } TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorNegative) { @@ -292,7 +291,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorNegative) { NULL, 0, false); - InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(config, false); } TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorTooLarge) { @@ -308,7 +307,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioNumeratorTooLarge) { NULL, 0, false); - InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(config, false); } TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorTooLarge) { @@ -323,7 +322,7 @@ TEST_F(FFmpegVideoDecoderTest, Initialize_AspectRatioDenominatorTooLarge) { NULL, 0, false); - InitializeWithConfigAndStatus(config, DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(config, false); } TEST_F(FFmpegVideoDecoderTest, Reinitialize_Normal) { @@ -333,8 +332,7 @@ TEST_F(FFmpegVideoDecoderTest, Reinitialize_Normal) { TEST_F(FFmpegVideoDecoderTest, Reinitialize_Failure) { Initialize(); - InitializeWithConfigAndStatus(TestVideoConfig::Invalid(), - DECODER_ERROR_NOT_SUPPORTED); + InitializeWithConfigWithResult(TestVideoConfig::Invalid(), false); } TEST_F(FFmpegVideoDecoderTest, Reinitialize_AfterDecodeFrame) { diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc index 7211655dfbd3..504ed847767b 100644 --- a/media/filters/gpu_video_decoder.cc +++ b/media/filters/gpu_video_decoder.cc @@ -105,15 +105,17 @@ static bool IsCodedSizeSupported(const gfx::Size& coded_size, coded_size.height() >= min_resolution.height()); } -// Report |status| to UMA and run |cb| with it. This is super-specific to the +// Report |success| to UMA and run |cb| with it. This is super-specific to the // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a // callsite to always be called with the same stat name (can't parameterize it). static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( - const PipelineStatusCB& cb, - PipelineStatus status) { + const VideoDecoder::InitCB& cb, + bool success) { + // TODO(xhwang): Report |success| directly. + PipelineStatus status = success ? PIPELINE_OK : DECODER_ERROR_NOT_SUPPORTED; UMA_HISTOGRAM_ENUMERATION( "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); - cb.Run(status); + cb.Run(success); } std::string GpuVideoDecoder::GetDisplayName() const { @@ -122,16 +124,16 @@ std::string GpuVideoDecoder::GetDisplayName() const { void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, bool /* low_delay */, - const PipelineStatusCB& orig_status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DVLOG(3) << "Initialize()"; DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); DCHECK(config.IsValidConfig()); DCHECK(!config.is_encrypted()); - PipelineStatusCB status_cb = + InitCB bound_init_cb = base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB, - BindToCurrentLoop(orig_status_cb)); + BindToCurrentLoop(init_cb)); bool previously_initialized = config_.IsValidConfig(); DVLOG(1) << "(Re)initializing GVD with config: " @@ -141,12 +143,12 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, // (http://crbug.com/260224). if (previously_initialized && (config_.profile() != config.profile())) { DVLOG(1) << "Codec or profile changed, cannot reinitialize."; - status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); + bound_init_cb.Run(false); return; } if (!IsProfileSupported(config.profile(), config.coded_size())) { - status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); + bound_init_cb.Run(false); return; } @@ -158,18 +160,18 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, // Reinitialization with a different config (but same codec and profile). // VDA should handle it by detecting this in-stream by itself, // no need to notify it. - status_cb.Run(PIPELINE_OK); + bound_init_cb.Run(true); return; } vda_ = factories_->CreateVideoDecodeAccelerator().Pass(); if (!vda_ || !vda_->Initialize(config.profile(), this)) { - status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); + bound_init_cb.Run(false); return; } DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded."; - status_cb.Run(PIPELINE_OK); + bound_init_cb.Run(true); } void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) { diff --git a/media/filters/gpu_video_decoder.h b/media/filters/gpu_video_decoder.h index 49ede615e2b8..28eceb34f256 100644 --- a/media/filters/gpu_video_decoder.h +++ b/media/filters/gpu_video_decoder.h @@ -44,7 +44,7 @@ class MEDIA_EXPORT GpuVideoDecoder std::string GetDisplayName() const override; void Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) override; void Decode(const scoped_refptr& buffer, const DecodeCB& decode_cb) override; diff --git a/media/filters/opus_audio_decoder.cc b/media/filters/opus_audio_decoder.cc index 51484eaa5513..181f34014da4 100644 --- a/media/filters/opus_audio_decoder.cc +++ b/media/filters/opus_audio_decoder.cc @@ -254,20 +254,20 @@ std::string OpusAudioDecoder::GetDisplayName() const { } void OpusAudioDecoder::Initialize(const AudioDecoderConfig& config, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DCHECK(task_runner_->BelongsToCurrentThread()); - PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); + InitCB bound_init_cb = BindToCurrentLoop(init_cb); config_ = config; output_cb_ = BindToCurrentLoop(output_cb); if (!ConfigureDecoder()) { - initialize_cb.Run(DECODER_ERROR_NOT_SUPPORTED); + bound_init_cb.Run(false); return; } - initialize_cb.Run(PIPELINE_OK); + bound_init_cb.Run(true); } void OpusAudioDecoder::Decode(const scoped_refptr& buffer, diff --git a/media/filters/opus_audio_decoder.h b/media/filters/opus_audio_decoder.h index b3fb188b6e6f..3b0cd7164ae6 100644 --- a/media/filters/opus_audio_decoder.h +++ b/media/filters/opus_audio_decoder.h @@ -33,7 +33,7 @@ class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder { // AudioDecoder implementation. std::string GetDisplayName() const override; void Initialize(const AudioDecoderConfig& config, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) override; void Decode(const scoped_refptr& buffer, const DecodeCB& decode_cb) override; diff --git a/media/filters/video_decoder_selector_unittest.cc b/media/filters/video_decoder_selector_unittest.cc index 86f4c0eca1c6..2471e76c908e 100644 --- a/media/filters/video_decoder_selector_unittest.cc +++ b/media/filters/video_decoder_selector_unittest.cc @@ -194,7 +194,7 @@ TEST_F(VideoDecoderSelectorTest, ClearStream_NoDecryptor_OneClearDecoder) { InitializeDecoderSelector(kNoDecryptor, 1); EXPECT_CALL(*decoder_1_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(PIPELINE_OK)); + .WillOnce(RunCallback<2>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_1_, IsNull())); SelectDecoder(); @@ -217,9 +217,9 @@ TEST_F(VideoDecoderSelectorTest, ClearStream_NoDecryptor_MultipleClearDecoder) { InitializeDecoderSelector(kNoDecryptor, 2); EXPECT_CALL(*decoder_1_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(DECODER_ERROR_NOT_SUPPORTED)); + .WillOnce(RunCallback<2>(false)); EXPECT_CALL(*decoder_2_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(PIPELINE_OK)); + .WillOnce(RunCallback<2>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_2_, IsNull())); SelectDecoder(); @@ -231,7 +231,7 @@ TEST_F(VideoDecoderSelectorTest, InitializeDecoderSelector(kNoDecryptor, 2); EXPECT_CALL(*decoder_1_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(DECODER_ERROR_NOT_SUPPORTED)); + .WillOnce(RunCallback<2>(false)); EXPECT_CALL(*decoder_2_, Initialize(_, _, _, _)); SelectDecoderAndDestroy(); @@ -244,7 +244,7 @@ TEST_F(VideoDecoderSelectorTest, ClearStream_HasDecryptor) { InitializeDecoderSelector(kDecryptOnly, 1); EXPECT_CALL(*decoder_1_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(PIPELINE_OK)); + .WillOnce(RunCallback<2>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_1_, IsNull())); SelectDecoder(); @@ -295,7 +295,7 @@ TEST_F(VideoDecoderSelectorTest, EncryptedStream_DecryptOnly_OneClearDecoder) { InitializeDecoderSelector(kDecryptOnly, 1); EXPECT_CALL(*decoder_1_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(PIPELINE_OK)); + .WillOnce(RunCallback<2>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_1_, NotNull())); SelectDecoder(); @@ -320,9 +320,9 @@ TEST_F(VideoDecoderSelectorTest, InitializeDecoderSelector(kDecryptOnly, 2); EXPECT_CALL(*decoder_1_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(DECODER_ERROR_NOT_SUPPORTED)); + .WillOnce(RunCallback<2>(false)); EXPECT_CALL(*decoder_2_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(PIPELINE_OK)); + .WillOnce(RunCallback<2>(true)); EXPECT_CALL(*this, OnDecoderSelected(decoder_2_, NotNull())); SelectDecoder(); @@ -334,7 +334,7 @@ TEST_F(VideoDecoderSelectorTest, InitializeDecoderSelector(kDecryptOnly, 2); EXPECT_CALL(*decoder_1_, Initialize(_, _, _, _)) - .WillOnce(RunCallback<2>(DECODER_ERROR_NOT_SUPPORTED)); + .WillOnce(RunCallback<2>(false)); EXPECT_CALL(*decoder_2_, Initialize(_, _, _, _)); SelectDecoderAndDestroy(); diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc index 01338c3820c4..26b60fa55d74 100644 --- a/media/filters/vpx_video_decoder.cc +++ b/media/filters/vpx_video_decoder.cc @@ -209,15 +209,17 @@ std::string VpxVideoDecoder::GetDisplayName() const { void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) { DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(config.IsValidConfig()); DCHECK(!config.is_encrypted()); DCHECK(decode_cb_.is_null()); + InitCB bound_init_cb = BindToCurrentLoop(init_cb); + if (!ConfigureDecoder(config)) { - status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); + bound_init_cb.Run(false); return; } @@ -225,7 +227,7 @@ void VpxVideoDecoder::Initialize(const VideoDecoderConfig& config, config_ = config; state_ = kNormal; output_cb_ = BindToCurrentLoop(output_cb); - status_cb.Run(PIPELINE_OK); + bound_init_cb.Run(true); } static vpx_codec_ctx* InitializeVpxContext(vpx_codec_ctx* context, diff --git a/media/filters/vpx_video_decoder.h b/media/filters/vpx_video_decoder.h index 72d7a2c963fe..bbf98950c0ac 100644 --- a/media/filters/vpx_video_decoder.h +++ b/media/filters/vpx_video_decoder.h @@ -35,7 +35,7 @@ class MEDIA_EXPORT VpxVideoDecoder : public VideoDecoder { std::string GetDisplayName() const override; void Initialize(const VideoDecoderConfig& config, bool low_delay, - const PipelineStatusCB& status_cb, + const InitCB& init_cb, const OutputCB& output_cb) override; void Decode(const scoped_refptr& buffer, const DecodeCB& decode_cb) override; diff --git a/media/renderers/audio_renderer_impl_unittest.cc b/media/renderers/audio_renderer_impl_unittest.cc index 119fb76b4649..e65dd4b0fc1d 100644 --- a/media/renderers/audio_renderer_impl_unittest.cc +++ b/media/renderers/audio_renderer_impl_unittest.cc @@ -106,8 +106,7 @@ class AudioRendererImplTest : public ::testing::Test { void ExpectUnsupportedAudioDecoder() { EXPECT_CALL(*decoder_, Initialize(_, _, _)) - .WillOnce(DoAll(SaveArg<2>(&output_cb_), - RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED))); + .WillOnce(DoAll(SaveArg<2>(&output_cb_), RunCallback<1>(false))); } MOCK_METHOD1(OnStatistics, void(const PipelineStatistics&)); @@ -131,8 +130,7 @@ class AudioRendererImplTest : public ::testing::Test { void Initialize() { EXPECT_CALL(*decoder_, Initialize(_, _, _)) - .WillOnce(DoAll(SaveArg<2>(&output_cb_), - RunCallback<1>(PIPELINE_OK))); + .WillOnce(DoAll(SaveArg<2>(&output_cb_), RunCallback<1>(true))); InitializeWithStatus(PIPELINE_OK); next_timestamp_.reset(new AudioTimestampHelper(kInputSamplesPerSecond)); @@ -150,8 +148,7 @@ class AudioRendererImplTest : public ::testing::Test { } void InitializeAndDestroy() { - EXPECT_CALL(*decoder_, Initialize(_, _, _)) - .WillOnce(RunCallback<1>(PIPELINE_OK)); + EXPECT_CALL(*decoder_, Initialize(_, _, _)).WillOnce(RunCallback<1>(true)); WaitableMessageLoopEvent event; InitializeRenderer(event.GetPipelineStatusCB()); @@ -176,7 +173,7 @@ class AudioRendererImplTest : public ::testing::Test { event.RunAndWaitForStatus(PIPELINE_ERROR_ABORT); } - void EnterPendingDecoderInitState(PipelineStatusCB cb) { + void EnterPendingDecoderInitState(const AudioDecoder::InitCB& cb) { init_decoder_cb_ = cb; } @@ -398,7 +395,7 @@ class AudioRendererImplTest : public ::testing::Test { // Run during DecodeDecoder() to unblock WaitForPendingRead(). base::Closure wait_for_pending_decode_cb_; - PipelineStatusCB init_decoder_cb_; + AudioDecoder::InitCB init_decoder_cb_; bool ended_; DISALLOW_COPY_AND_ASSIGN(AudioRendererImplTest); diff --git a/media/renderers/video_renderer_impl_unittest.cc b/media/renderers/video_renderer_impl_unittest.cc index aa494cb49ce7..75c599e3d6b8 100644 --- a/media/renderers/video_renderer_impl_unittest.cc +++ b/media/renderers/video_renderer_impl_unittest.cc @@ -97,24 +97,26 @@ class VideoRendererImplTest : public testing::TestWithParam { .WillRepeatedly(Invoke(this, &VideoRendererImplTest::FlushRequested)); // Initialize, we shouldn't have any reads. - InitializeRenderer(PIPELINE_OK, low_delay); + InitializeRenderer(low_delay, true); } - void InitializeRenderer(PipelineStatus expected, bool low_delay) { - SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected)); + void InitializeRenderer(bool low_delay, bool expect_to_success) { + SCOPED_TRACE( + base::StringPrintf("InitializeRenderer(%d)", expect_to_success)); WaitableMessageLoopEvent event; - CallInitialize(event.GetPipelineStatusCB(), low_delay, expected); - event.RunAndWaitForStatus(expected); + CallInitialize(event.GetPipelineStatusCB(), low_delay, expect_to_success); + event.RunAndWaitForStatus(expect_to_success ? PIPELINE_OK + : DECODER_ERROR_NOT_SUPPORTED); } void CallInitialize(const PipelineStatusCB& status_cb, bool low_delay, - PipelineStatus decoder_status) { + bool expect_to_success) { if (low_delay) demuxer_stream_.set_liveness(DemuxerStream::LIVENESS_LIVE); EXPECT_CALL(*decoder_, Initialize(_, _, _, _)) .WillOnce( - DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(decoder_status))); + DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(expect_to_success))); EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); renderer_->Initialize( &demuxer_stream_, status_cb, media::SetDecryptorReadyCB(), @@ -530,7 +532,7 @@ TEST_P(VideoRendererImplTest, DestroyDuringOutstandingRead) { } TEST_P(VideoRendererImplTest, VideoDecoder_InitFailure) { - InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED, false); + InitializeRenderer(false, false); Destroy(); } -- 2.11.4.GIT