Commit 73bf69cf authored by Yuchen Liu's avatar Yuchen Liu Committed by Commit Bot

[Chromecast] Avoid backend decryptor for clear key

ClearKey is a software based key system, we should not ask backend to
handle decryption with this key system.

The patch delays the creation of StreamDecryptor until we know which key
system to use.

BUG=internal b/117273176
TEST=cast https://simpl.info/eme/clearkey/

Change-Id: I5de56f84c52b42f5440928406a36ae364e61c1fc
Reviewed-on: https://chromium-review.googlesource.com/c/1284950Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Commit-Queue: Yuchen Liu <yucliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600173}
parent 8c97247e
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "chromecast/media/cma/base/cma_logging.h" #include "chromecast/media/cma/base/cma_logging.h"
#include "chromecast/media/cma/base/coded_frame_provider.h" #include "chromecast/media/cma/base/coded_frame_provider.h"
#include "chromecast/media/cma/base/decoder_buffer_base.h" #include "chromecast/media/cma/base/decoder_buffer_base.h"
#include "chromecast/media/cma/pipeline/cdm_decryptor.h"
#include "chromecast/media/cma/pipeline/decrypt_util.h" #include "chromecast/media/cma/pipeline/decrypt_util.h"
#include "chromecast/public/media/cast_decrypt_config.h" #include "chromecast/public/media/cast_decrypt_config.h"
#include "media/base/audio_decoder_config.h" #include "media/base/audio_decoder_config.h"
...@@ -202,13 +203,6 @@ void AvPipelineImpl::OnNewFrame( ...@@ -202,13 +203,6 @@ void AvPipelineImpl::OnNewFrame(
if (audio_config.IsValidConfig() || video_config.IsValidConfig()) if (audio_config.IsValidConfig() || video_config.IsValidConfig())
OnUpdateConfig(buffer->stream_id(), audio_config, video_config); OnUpdateConfig(buffer->stream_id(), audio_config, video_config);
if (!decryptor_) {
decryptor_ = CreateDecryptor();
DCHECK(decryptor_);
decryptor_->Init(base::BindRepeating(&AvPipelineImpl::OnBufferDecrypted,
decrypt_weak_factory_.GetWeakPtr()));
}
pending_buffer_ = buffer; pending_buffer_ = buffer;
ProcessPendingBuffer(); ProcessPendingBuffer();
} }
...@@ -249,10 +243,24 @@ void AvPipelineImpl::ProcessPendingBuffer() { ...@@ -249,10 +243,24 @@ void AvPipelineImpl::ProcessPendingBuffer() {
} }
DCHECK_NE(decrypt_context->GetKeySystem(), KEY_SYSTEM_NONE); DCHECK_NE(decrypt_context->GetKeySystem(), KEY_SYSTEM_NONE);
if (!decryptor_) {
decryptor_ = CreateStreamDecryptor(decrypt_context->GetKeySystem());
DCHECK(decryptor_);
decryptor_->Init(base::BindRepeating(&AvPipelineImpl::OnBufferDecrypted,
decrypt_weak_factory_.GetWeakPtr()));
}
pending_buffer_->set_decrypt_context(std::move(decrypt_context)); pending_buffer_->set_decrypt_context(std::move(decrypt_context));
} }
decryptor_->Decrypt(std::move(pending_buffer_)); if (decryptor_) {
decryptor_->Decrypt(std::move(pending_buffer_));
return;
}
DCHECK(ready_buffers_.empty());
PushReadyBuffer(std::move(pending_buffer_));
} }
void AvPipelineImpl::PushAllReadyBuffers() { void AvPipelineImpl::PushAllReadyBuffers() {
...@@ -431,5 +439,15 @@ void AvPipelineImpl::UpdatePlayableFrames() { ...@@ -431,5 +439,15 @@ void AvPipelineImpl::UpdatePlayableFrames() {
} }
} }
std::unique_ptr<StreamDecryptor> AvPipelineImpl::CreateStreamDecryptor(
CastKeySystem key_system) {
if (key_system == KEY_SYSTEM_CLEAR_KEY) {
// Clear Key only supports clear output.
return std::make_unique<CdmDecryptor>(true /* clear_buffer_needed */);
}
return CreateDecryptor();
}
} // namespace media } // namespace media
} // namespace chromecast } // namespace chromecast
...@@ -132,6 +132,9 @@ class AvPipelineImpl : CmaBackend::Decoder::Delegate { ...@@ -132,6 +132,9 @@ class AvPipelineImpl : CmaBackend::Decoder::Delegate {
bool is_at_max_capacity); bool is_at_max_capacity);
void UpdatePlayableFrames(); void UpdatePlayableFrames();
std::unique_ptr<StreamDecryptor> CreateStreamDecryptor(
CastKeySystem key_system);
base::ThreadChecker thread_checker_; base::ThreadChecker thread_checker_;
CmaBackend::Decoder* const decoder_; CmaBackend::Decoder* const decoder_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment