| Index: media/filters/decrypting_audio_decoder.cc
|
| diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc
|
| index 60586a819dc09ab20d9bfac4936b4ff00c21a715..3f8e7553688555b176517371c86a9cb5300b5e63 100644
|
| --- a/media/filters/decrypting_audio_decoder.cc
|
| +++ b/media/filters/decrypting_audio_decoder.cc
|
| @@ -17,6 +17,7 @@
|
| #include "media/base/audio_decoder_config.h"
|
| #include "media/base/audio_timestamp_helper.h"
|
| #include "media/base/bind_to_current_loop.h"
|
| +#include "media/base/cdm_context.h"
|
| #include "media/base/decoder_buffer.h"
|
| #include "media/base/media_log.h"
|
| #include "media/base/pipeline.h"
|
| @@ -50,7 +51,7 @@ std::string DecryptingAudioDecoder::GetDisplayName() const {
|
| }
|
|
|
| void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
|
| - const SetCdmReadyCB& set_cdm_ready_cb,
|
| + CdmContext* cdm_context,
|
| const InitCB& init_cb,
|
| const OutputCB& output_cb) {
|
| DVLOG(2) << "Initialize()";
|
| @@ -62,6 +63,8 @@ void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
|
| init_cb_ = BindToCurrentLoop(init_cb);
|
| output_cb_ = BindToCurrentLoop(output_cb);
|
|
|
| + // TODO(xhwang): We should be able to DCHECK config.IsValidConfig() and
|
| + // config.is_encrypted().
|
| if (!config.IsValidConfig()) {
|
| DLOG(ERROR) << "Invalid audio stream config.";
|
| base::ResetAndReturn(&init_cb_).Run(false);
|
| @@ -77,16 +80,19 @@ void DecryptingAudioDecoder::Initialize(const AudioDecoderConfig& config,
|
| config_ = config;
|
|
|
| if (state_ == kUninitialized) {
|
| - DCHECK(!set_cdm_ready_cb.is_null());
|
| - state_ = kDecryptorRequested;
|
| - set_cdm_ready_cb_ = set_cdm_ready_cb;
|
| - set_cdm_ready_cb_.Run(BindToCurrentLoop(
|
| - base::Bind(&DecryptingAudioDecoder::SetCdm, weak_this_)));
|
| - return;
|
| + DCHECK(cdm_context);
|
| + if (!cdm_context->GetDecryptor()) {
|
| + MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no decryptor";
|
| + base::ResetAndReturn(&init_cb_).Run(false);
|
| + return;
|
| + }
|
| +
|
| + decryptor_ = cdm_context->GetDecryptor();
|
| + } else {
|
| + // Reinitialization (i.e. upon a config change)
|
| + decryptor_->DeinitializeDecoder(Decryptor::kAudio);
|
| }
|
|
|
| - // Reinitialization (i.e. upon a config change)
|
| - decryptor_->DeinitializeDecoder(Decryptor::kAudio);
|
| InitializeDecoder();
|
| }
|
|
|
| @@ -163,8 +169,6 @@ DecryptingAudioDecoder::~DecryptingAudioDecoder() {
|
| decryptor_->DeinitializeDecoder(Decryptor::kAudio);
|
| decryptor_ = NULL;
|
| }
|
| - if (!set_cdm_ready_cb_.is_null())
|
| - base::ResetAndReturn(&set_cdm_ready_cb_).Run(CdmReadyCB());
|
| pending_buffer_to_decode_ = NULL;
|
| if (!init_cb_.is_null())
|
| base::ResetAndReturn(&init_cb_).Run(false);
|
| @@ -174,30 +178,6 @@ DecryptingAudioDecoder::~DecryptingAudioDecoder() {
|
| base::ResetAndReturn(&reset_cb_).Run();
|
| }
|
|
|
| -void DecryptingAudioDecoder::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() << ": no decryptor set";
|
| - base::ResetAndReturn(&init_cb_).Run(false);
|
| - state_ = kError;
|
| - cdm_attached_cb.Run(false);
|
| - return;
|
| - }
|
| -
|
| - decryptor_ = cdm_context->GetDecryptor();
|
| -
|
| - InitializeDecoder();
|
| - cdm_attached_cb.Run(true);
|
| -}
|
| -
|
| void DecryptingAudioDecoder::InitializeDecoder() {
|
| state_ = kPendingDecoderInit;
|
| decryptor_->InitializeAudioDecoder(
|
|
|