| Index: media/filters/decrypting_demuxer_stream.cc
|
| diff --git a/media/filters/decrypting_demuxer_stream.cc b/media/filters/decrypting_demuxer_stream.cc
|
| index 883d4c1a1b351286902dc31aaf6d3d3e05be6fa5..b19439fdf9deb463e24f1fdc4951245783f42f30 100644
|
| --- a/media/filters/decrypting_demuxer_stream.cc
|
| +++ b/media/filters/decrypting_demuxer_stream.cc
|
| @@ -43,7 +43,7 @@ std::string DecryptingDemuxerStream::GetDisplayName() const {
|
| }
|
|
|
| void DecryptingDemuxerStream::Initialize(DemuxerStream* stream,
|
| - const SetCdmReadyCB& set_cdm_ready_cb,
|
| + CdmContext* cdm_context,
|
| const PipelineStatusCB& status_cb) {
|
| DVLOG(2) << __FUNCTION__;
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
| @@ -52,14 +52,26 @@ void DecryptingDemuxerStream::Initialize(DemuxerStream* stream,
|
| DCHECK(!demuxer_stream_);
|
| weak_this_ = weak_factory_.GetWeakPtr();
|
| demuxer_stream_ = stream;
|
| - set_cdm_ready_cb_ = set_cdm_ready_cb;
|
| init_cb_ = BindToCurrentLoop(status_cb);
|
|
|
| InitializeDecoderConfig();
|
|
|
| - state_ = kDecryptorRequested;
|
| - set_cdm_ready_cb_.Run(BindToCurrentLoop(
|
| - base::Bind(&DecryptingDemuxerStream::SetCdm, weak_this_)));
|
| + DCHECK(cdm_context);
|
| + if (!cdm_context->GetDecryptor()) {
|
| + MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor";
|
| + base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
|
| + return;
|
| + }
|
| +
|
| + decryptor_ = cdm_context->GetDecryptor();
|
| +
|
| + decryptor_->RegisterNewKeyCB(
|
| + GetDecryptorStreamType(),
|
| + BindToCurrentLoop(
|
| + base::Bind(&DecryptingDemuxerStream::OnKeyAdded, weak_this_)));
|
| +
|
| + state_ = kIdle;
|
| + base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
|
| }
|
|
|
| void DecryptingDemuxerStream::Read(const ReadCB& read_cb) {
|
| @@ -83,16 +95,6 @@ void DecryptingDemuxerStream::Reset(const base::Closure& closure) {
|
|
|
| reset_cb_ = BindToCurrentLoop(closure);
|
|
|
| - // TODO(xhwang): This should not happen. Remove it, DCHECK against the
|
| - // condition and clean up related tests.
|
| - if (state_ == kDecryptorRequested) {
|
| - DCHECK(!init_cb_.is_null());
|
| - set_cdm_ready_cb_.Run(CdmReadyCB());
|
| - base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
|
| - DoReset();
|
| - return;
|
| - }
|
| -
|
| decryptor_->CancelDecrypt(GetDecryptorStreamType());
|
|
|
| // Reset() cannot complete if the read callback is still pending.
|
| @@ -115,24 +117,24 @@ void DecryptingDemuxerStream::Reset(const base::Closure& closure) {
|
| }
|
|
|
| AudioDecoderConfig DecryptingDemuxerStream::audio_decoder_config() {
|
| - DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_;
|
| + DCHECK(state_ != kUninitialized) << state_;
|
| CHECK_EQ(demuxer_stream_->type(), AUDIO);
|
| return audio_config_;
|
| }
|
|
|
| VideoDecoderConfig DecryptingDemuxerStream::video_decoder_config() {
|
| - DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_;
|
| + DCHECK(state_ != kUninitialized) << state_;
|
| CHECK_EQ(demuxer_stream_->type(), VIDEO);
|
| return video_config_;
|
| }
|
|
|
| DemuxerStream::Type DecryptingDemuxerStream::type() const {
|
| - DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_;
|
| + DCHECK(state_ != kUninitialized) << state_;
|
| return demuxer_stream_->type();
|
| }
|
|
|
| DemuxerStream::Liveness DecryptingDemuxerStream::liveness() const {
|
| - DCHECK(state_ != kUninitialized && state_ != kDecryptorRequested) << state_;
|
| + DCHECK(state_ != kUninitialized) << state_;
|
| return demuxer_stream_->liveness();
|
| }
|
|
|
| @@ -159,8 +161,6 @@ DecryptingDemuxerStream::~DecryptingDemuxerStream() {
|
| decryptor_->CancelDecrypt(GetDecryptorStreamType());
|
| decryptor_ = NULL;
|
| }
|
| - if (!set_cdm_ready_cb_.is_null())
|
| - base::ResetAndReturn(&set_cdm_ready_cb_).Run(CdmReadyCB());
|
| if (!init_cb_.is_null())
|
| base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT);
|
| if (!read_cb_.is_null())
|
| @@ -170,36 +170,6 @@ DecryptingDemuxerStream::~DecryptingDemuxerStream() {
|
| pending_buffer_to_decrypt_ = NULL;
|
| }
|
|
|
| -void DecryptingDemuxerStream::SetCdm(CdmContext* cdm_context,
|
| - const CdmAttachedCB& cdm_attached_cb) {
|
| - DVLOG(2) << __FUNCTION__;
|
| - DCHECK(task_runner_->BelongsToCurrentThread());
|
| - DCHECK_EQ(state_, kDecryptorRequested) << state_;
|
| - DCHECK(!init_cb_.is_null());
|
| - DCHECK(!set_cdm_ready_cb_.is_null());
|
| -
|
| - set_cdm_ready_cb_.Reset();
|
| -
|
| - if (!cdm_context || !cdm_context->GetDecryptor()) {
|
| - MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": decryptor not set";
|
| - state_ = kUninitialized;
|
| - base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED);
|
| - cdm_attached_cb.Run(false);
|
| - return;
|
| - }
|
| -
|
| - decryptor_ = cdm_context->GetDecryptor();
|
| -
|
| - decryptor_->RegisterNewKeyCB(
|
| - GetDecryptorStreamType(),
|
| - BindToCurrentLoop(
|
| - base::Bind(&DecryptingDemuxerStream::OnKeyAdded, weak_this_)));
|
| -
|
| - state_ = kIdle;
|
| - base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
|
| - cdm_attached_cb.Run(true);
|
| -}
|
| -
|
| void DecryptingDemuxerStream::DecryptBuffer(
|
| DemuxerStream::Status status,
|
| const scoped_refptr<DecoderBuffer>& buffer) {
|
| @@ -353,11 +323,7 @@ void DecryptingDemuxerStream::DoReset() {
|
| DCHECK(init_cb_.is_null());
|
| DCHECK(read_cb_.is_null());
|
|
|
| - if (state_ == kDecryptorRequested)
|
| - state_ = kUninitialized;
|
| - else
|
| - state_ = kIdle;
|
| -
|
| + state_ = kIdle;
|
| base::ResetAndReturn(&reset_cb_).Run();
|
| }
|
|
|
|
|