Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Unified Diff: media/filters/decrypting_audio_decoder.cc

Issue 1666653002: media: Remove SetCdmReadyCB and CdmReadyCB (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and fix compile errors Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/decrypting_audio_decoder.h ('k') | media/filters/decrypting_audio_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « media/filters/decrypting_audio_decoder.h ('k') | media/filters/decrypting_audio_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698