summaryrefslogtreecommitdiff
path: root/chromium/media/cdm/library_cdm
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/media/cdm/library_cdm')
-rw-r--r--chromium/media/cdm/library_cdm/clear_key_cdm/BUILD.gn5
-rw-r--r--chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.cc (renamed from chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.cc)51
-rw-r--r--chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h (renamed from chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h)30
-rw-r--r--chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc80
-rw-r--r--chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h10
-rw-r--r--chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.cc54
-rw-r--r--chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.h2
-rw-r--r--chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_persistent_session_cdm.cc7
8 files changed, 144 insertions, 95 deletions
diff --git a/chromium/media/cdm/library_cdm/clear_key_cdm/BUILD.gn b/chromium/media/cdm/library_cdm/clear_key_cdm/BUILD.gn
index c6fe179fc73..932e2bd5a34 100644
--- a/chromium/media/cdm/library_cdm/clear_key_cdm/BUILD.gn
+++ b/chromium/media/cdm/library_cdm/clear_key_cdm/BUILD.gn
@@ -14,8 +14,8 @@ loadable_module("clear_key_cdm") {
"cdm_file_adapter.h",
"cdm_file_io_test.cc",
"cdm_file_io_test.h",
- "cdm_proxy_test.cc",
- "cdm_proxy_test.h",
+ "cdm_proxy_handler.cc",
+ "cdm_proxy_handler.h",
"cdm_video_decoder.cc",
"cdm_video_decoder.h",
"clear_key_cdm.cc",
@@ -32,7 +32,6 @@ loadable_module("clear_key_cdm") {
deps = [
":cdm_proxy_common",
"//base",
- "//build/config:exe_and_shlib_deps",
"//media", # For media::AudioTimestampHelper
"//media:shared_memory_support", # For media::AudioBus.
"//media/cdm:cdm_api", # For content_decryption_module.h
diff --git a/chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.cc b/chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.cc
index 152539f4bd6..ebcb163a7fa 100644
--- a/chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.cc
+++ b/chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h"
+#include "media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h"
#include <stdint.h>
#include <algorithm>
@@ -14,43 +14,48 @@
namespace media {
-CdmProxyTest::CdmProxyTest(CdmHostProxy* cdm_host_proxy)
+CdmProxyHandler::CdmProxyHandler(CdmHostProxy* cdm_host_proxy)
: cdm_host_proxy_(cdm_host_proxy) {}
-CdmProxyTest::~CdmProxyTest() {}
+CdmProxyHandler::~CdmProxyHandler() {}
-void CdmProxyTest::Run(CompletionCB completion_cb) {
+void CdmProxyHandler::Initialize(InitCB init_cb) {
DVLOG(1) << __func__;
- completion_cb_ = std::move(completion_cb);
+ init_cb_ = std::move(init_cb);
cdm_proxy_ = cdm_host_proxy_->RequestCdmProxy(this);
if (!cdm_proxy_) {
- OnTestComplete(false);
+ FinishInitialization(false);
return;
}
cdm_proxy_->Initialize();
}
-void CdmProxyTest::OnTestComplete(bool success) {
+void CdmProxyHandler::SetKey(const std::vector<uint8_t>& response) {
+ cdm_proxy_->SetKey(crypto_session_id_, nullptr, 0, response.data(),
+ response.size());
+}
+
+void CdmProxyHandler::FinishInitialization(bool success) {
DVLOG(1) << __func__ << ": success = " << success;
- std::move(completion_cb_).Run(success);
+ std::move(init_cb_).Run(success);
}
-void CdmProxyTest::OnInitialized(Status status,
- Protocol protocol,
- uint32_t crypto_session_id) {
+void CdmProxyHandler::OnInitialized(Status status,
+ Protocol protocol,
+ uint32_t crypto_session_id) {
DVLOG(1) << __func__ << ": status = " << status;
if (status != Status::kOk ||
crypto_session_id != kClearKeyCdmProxyCryptoSessionId) {
- OnTestComplete(false);
+ FinishInitialization(false);
return;
}
// Only one CdmProxy can be created during the lifetime of the CDM instance.
if (cdm_host_proxy_->RequestCdmProxy(this)) {
- OnTestComplete(false);
+ FinishInitialization(false);
return;
}
@@ -59,15 +64,15 @@ void CdmProxyTest::OnInitialized(Status status,
kClearKeyCdmProxyInputData.size(), 0);
}
-void CdmProxyTest::OnProcessed(Status status,
- const uint8_t* output_data,
- uint32_t output_data_size) {
+void CdmProxyHandler::OnProcessed(Status status,
+ const uint8_t* output_data,
+ uint32_t output_data_size) {
DVLOG(1) << __func__ << ": status = " << status;
if (status != Status::kOk ||
!std::equal(output_data, output_data + output_data_size,
kClearKeyCdmProxyOutputData.begin())) {
- OnTestComplete(false);
+ FinishInitialization(false);
return;
}
@@ -75,21 +80,21 @@ void CdmProxyTest::OnProcessed(Status status,
kClearKeyCdmProxyInputData.size());
}
-void CdmProxyTest::OnMediaCryptoSessionCreated(Status status,
- uint32_t crypto_session_id,
- uint64_t output_data) {
+void CdmProxyHandler::OnMediaCryptoSessionCreated(Status status,
+ uint32_t crypto_session_id,
+ uint64_t output_data) {
DVLOG(1) << __func__ << ": status = " << status;
if (status != Status::kOk ||
crypto_session_id != kClearKeyCdmProxyMediaCryptoSessionId) {
- OnTestComplete(false);
+ FinishInitialization(false);
return;
}
- OnTestComplete(true);
+ FinishInitialization(true);
}
-void CdmProxyTest::NotifyHardwareReset() {
+void CdmProxyHandler::NotifyHardwareReset() {
DVLOG(1) << __func__;
NOTREACHED();
}
diff --git a/chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h b/chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h
index 27237be66ec..dd5badb9952 100644
--- a/chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h
+++ b/chromium/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_TEST_H_
-#define MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_TEST_H_
+#ifndef MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_HANDLER_H_
+#define MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_HANDLER_H_
#include "base/callback.h"
#include "base/macros.h"
@@ -13,18 +13,23 @@ namespace media {
class CdmHostProxy;
-class CdmProxyTest : public cdm::CdmProxyClient {
+class CdmProxyHandler : public cdm::CdmProxyClient {
public:
- using CompletionCB = base::OnceCallback<void(bool success)>;
+ using InitCB = base::OnceCallback<void(bool success)>;
- explicit CdmProxyTest(CdmHostProxy* cdm_host_proxy);
- ~CdmProxyTest() override;
+ explicit CdmProxyHandler(CdmHostProxy* cdm_host_proxy);
+ ~CdmProxyHandler() override;
- // Runs the test and returns the test result through |completion_cb|.
- void Run(CompletionCB completion_cb);
+ // Initializes the CdmProxyHandler and returns the result through |init_cb|.
+ // This will request and initialize the CdmProxy, create media crypto session
+ // and do some trivial procesing for better test coverage.
+ void Initialize(InitCB init_cb);
+
+ // Push a response that contains a license to the CdmProxy.
+ void SetKey(const std::vector<uint8_t>& response);
private:
- void OnTestComplete(bool success);
+ void FinishInitialization(bool success);
// cdm::CdmProxyClient implementation.
void OnInitialized(Status status,
@@ -39,12 +44,13 @@ class CdmProxyTest : public cdm::CdmProxyClient {
void NotifyHardwareReset() final;
CdmHostProxy* const cdm_host_proxy_ = nullptr;
- CompletionCB completion_cb_;
+ InitCB init_cb_;
cdm::CdmProxy* cdm_proxy_ = nullptr;
+ uint32_t crypto_session_id_ = 0u;
- DISALLOW_COPY_AND_ASSIGN(CdmProxyTest);
+ DISALLOW_COPY_AND_ASSIGN(CdmProxyHandler);
};
} // namespace media
-#endif // MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_TEST_H_
+#endif // MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_HANDLER_H_
diff --git a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc
index 27c7940acc8..35f55902eff 100644
--- a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc
+++ b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc
@@ -27,7 +27,7 @@
#include "media/cdm/library_cdm/cdm_host_proxy.h"
#include "media/cdm/library_cdm/cdm_host_proxy_impl.h"
#include "media/cdm/library_cdm/clear_key_cdm/cdm_file_io_test.h"
-#include "media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h"
+#include "media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h"
#include "media/cdm/library_cdm/clear_key_cdm/cdm_video_decoder.h"
#include "media/media_buildflags.h"
@@ -65,8 +65,8 @@ const char kExternalClearKeyStorageIdTestKeySystem[] =
"org.chromium.externalclearkey.storageidtest";
const char kExternalClearKeyDifferentGuidTestKeySystem[] =
"org.chromium.externalclearkey.differentguid";
-const char kExternalClearKeyCdmProxyTestKeySystem[] =
- "org.chromium.externalclearkey.cdmproxytest";
+const char kExternalClearKeyCdmProxyKeySystem[] =
+ "org.chromium.externalclearkey.cdmproxy";
const int64_t kSecondsPerMinute = 60;
const int64_t kMsPerSecond = 1000;
@@ -151,14 +151,14 @@ static cdm::Exception ConvertException(
static media::CdmSessionType ConvertSessionType(cdm::SessionType session_type) {
switch (session_type) {
case cdm::kTemporary:
- return media::CdmSessionType::TEMPORARY_SESSION;
+ return media::CdmSessionType::kTemporary;
case cdm::kPersistentLicense:
- return media::CdmSessionType::PERSISTENT_LICENSE_SESSION;
- case cdm::kPersistentKeyRelease:
- return media::CdmSessionType::PERSISTENT_RELEASE_MESSAGE_SESSION;
+ return media::CdmSessionType::kPersistentLicense;
+ case cdm::kPersistentUsageRecord:
+ return media::CdmSessionType::kPersistentUsageRecord;
}
NOTREACHED();
- return media::CdmSessionType::TEMPORARY_SESSION;
+ return media::CdmSessionType::kTemporary;
}
static media::EmeInitDataType ConvertInitDataType(
@@ -264,7 +264,7 @@ void* CreateCdmInstance(int cdm_interface_version,
key_system_string != kExternalClearKeyVerifyCdmHostTestKeySystem &&
key_system_string != kExternalClearKeyStorageIdTestKeySystem &&
key_system_string != kExternalClearKeyDifferentGuidTestKeySystem &&
- key_system_string != kExternalClearKeyCdmProxyTestKeySystem) {
+ key_system_string != kExternalClearKeyCdmProxyKeySystem) {
DVLOG(1) << "Unsupported key system:" << key_system_string;
return nullptr;
}
@@ -416,9 +416,9 @@ void ClearKeyCdm::Initialize(bool allow_distinctive_identifier,
allow_persistent_state_ = allow_persistent_state;
// CdmProxy must be created during initialization time. OnInitialized() will
- // be called in OnCdmProxyTestComplete().
- if (key_system_ == kExternalClearKeyCdmProxyTestKeySystem) {
- StartCdmProxyTest();
+ // be called in OnCdmProxyHandlerInitialized().
+ if (key_system_ == kExternalClearKeyCdmProxyKeySystem) {
+ InitializeCdmProxyHandler();
return;
}
@@ -483,8 +483,6 @@ void ClearKeyCdm::CreateSessionAndGenerateRequest(
ReportVerifyCdmHostTestResult();
} else if (key_system_ == kExternalClearKeyStorageIdTestKeySystem) {
StartStorageIdTest();
- } else if (key_system_ == kExternalClearKeyCdmProxyTestKeySystem) {
- ReportCdmProxyTestResult();
}
}
@@ -514,6 +512,16 @@ void ClearKeyCdm::UpdateSession(uint32_t promise_id,
uint32_t response_size) {
DVLOG(1) << __func__;
std::string web_session_str(session_id, session_id_length);
+ std::vector<uint8_t> response_vector(response, response + response_size);
+
+ // Push the license to CdmProxy.
+ // TODO(xhwang): There's a potential race condition here where key status
+ // update is dispatched in the render process first, which triggers the
+ // resume-decryption-after-no-key logic, and by the time we try to decrypt
+ // again in the ClearKeyCdmProxy (GPU process), SetKey() hasn't been
+ // dispatched yet. To solve this, handle no-key in ClearKeyCdmProxy.
+ if (cdm_proxy_handler_)
+ cdm_proxy_handler_->SetKey(response_vector);
std::unique_ptr<media::SimpleCdmPromise> promise(
new media::CdmCallbackPromise<>(
@@ -521,9 +529,7 @@ void ClearKeyCdm::UpdateSession(uint32_t promise_id,
promise_id, web_session_str),
base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this),
promise_id)));
- cdm_->UpdateSession(web_session_str,
- std::vector<uint8_t>(response, response + response_size),
- std::move(promise));
+ cdm_->UpdateSession(web_session_str, response_vector, std::move(promise));
}
void ClearKeyCdm::OnUpdateSuccess(uint32_t promise_id,
@@ -649,6 +655,10 @@ cdm::Status ClearKeyCdm::Decrypt(const cdm::InputBuffer_2& encrypted_buffer,
DVLOG(1) << __func__;
DCHECK(encrypted_buffer.data);
+ // When CdmProxy is used, the CDM cannot do any decryption or decoding.
+ if (key_system_ == kExternalClearKeyCdmProxyKeySystem)
+ return cdm::kDecryptError;
+
scoped_refptr<DecoderBuffer> buffer;
cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
@@ -683,8 +693,10 @@ cdm::Status ClearKeyCdm::InitializeAudioDecoder(
cdm::Status ClearKeyCdm::InitializeAudioDecoder(
const cdm::AudioDecoderConfig_2& audio_decoder_config) {
- if (key_system_ == kExternalClearKeyDecryptOnlyKeySystem)
+ if (key_system_ == kExternalClearKeyDecryptOnlyKeySystem ||
+ key_system_ == kExternalClearKeyCdmProxyKeySystem) {
return cdm::kInitializationError;
+ }
#if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
if (!audio_decoder_)
@@ -696,8 +708,7 @@ cdm::Status ClearKeyCdm::InitializeAudioDecoder(
return cdm::kSuccess;
#else
- NOTIMPLEMENTED();
- return cdm::kSessionError;
+ return cdm::kInitializationError;
#endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
}
@@ -715,8 +726,10 @@ cdm::Status ClearKeyCdm::InitializeVideoDecoder(
cdm::Status ClearKeyCdm::InitializeVideoDecoder(
const cdm::VideoDecoderConfig_2& video_decoder_config) {
- if (key_system_ == kExternalClearKeyDecryptOnlyKeySystem)
+ if (key_system_ == kExternalClearKeyDecryptOnlyKeySystem ||
+ key_system_ == kExternalClearKeyCdmProxyKeySystem) {
return cdm::kInitializationError;
+ }
if (video_decoder_ && video_decoder_->is_initialized()) {
DCHECK(!video_decoder_->is_initialized());
@@ -1071,29 +1084,20 @@ void ClearKeyCdm::StartStorageIdTest() {
cdm_host_proxy_->RequestStorageId(0);
}
-void ClearKeyCdm::StartCdmProxyTest() {
+void ClearKeyCdm::InitializeCdmProxyHandler() {
DVLOG(1) << __func__;
- DCHECK(!cdm_proxy_test_);
+ DCHECK(!cdm_proxy_handler_);
- cdm_proxy_test_.reset(new CdmProxyTest(cdm_host_proxy_.get()));
- cdm_proxy_test_->Run(base::BindOnce(&ClearKeyCdm::OnCdmProxyTestComplete,
- base::Unretained(this)));
+ cdm_proxy_handler_ = std::make_unique<CdmProxyHandler>(cdm_host_proxy_.get());
+ cdm_proxy_handler_->Initialize(base::BindOnce(
+ &ClearKeyCdm::OnCdmProxyHandlerInitialized, base::Unretained(this)));
}
-void ClearKeyCdm::OnCdmProxyTestComplete(bool success) {
+void ClearKeyCdm::OnCdmProxyHandlerInitialized(bool success) {
DVLOG(1) << __func__;
- DCHECK(cdm_proxy_test_);
-
- cdm_proxy_test_.reset();
- has_cdm_proxy_test_passed_ = success;
-
- // Ignore test result here. It will be reported in ReportCdmProxyTestResult().
- cdm_host_proxy_->OnInitialized(true);
-}
+ DCHECK(cdm_proxy_handler_);
-void ClearKeyCdm::ReportCdmProxyTestResult() {
- // StartCdmProxyTest() should have already been called and finished.
- OnUnitTestComplete(has_cdm_proxy_test_passed_);
+ cdm_host_proxy_->OnInitialized(success);
}
} // namespace media
diff --git a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h
index b9c78fa9665..386f2b95d07 100644
--- a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h
+++ b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h
@@ -23,7 +23,7 @@
namespace media {
class CdmHostProxy;
-class CdmProxyTest;
+class CdmProxyHandler;
class CdmVideoDecoder;
class DecoderBuffer;
class FFmpegCdmAudioDecoder;
@@ -159,9 +159,8 @@ class ClearKeyCdm : public cdm::ContentDecryptionModule_9,
void ReportVerifyCdmHostTestResult();
void StartStorageIdTest();
- void StartCdmProxyTest();
- void OnCdmProxyTestComplete(bool success);
- void ReportCdmProxyTestResult();
+ void InitializeCdmProxyHandler();
+ void OnCdmProxyHandlerInitialized(bool success);
int host_interface_version_ = 0;
@@ -189,12 +188,11 @@ class ClearKeyCdm : public cdm::ContentDecryptionModule_9,
std::unique_ptr<CdmVideoDecoder> video_decoder_;
std::unique_ptr<FileIOTestRunner> file_io_test_runner_;
- std::unique_ptr<CdmProxyTest> cdm_proxy_test_;
+ std::unique_ptr<CdmProxyHandler> cdm_proxy_handler_;
bool is_running_output_protection_test_ = false;
bool is_running_platform_verification_test_ = false;
bool is_running_storage_id_test_ = false;
- bool has_cdm_proxy_test_passed_ = false;
DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm);
};
diff --git a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.cc b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.cc
index c251354b535..2a4b2c2e337 100644
--- a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.cc
+++ b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.cc
@@ -11,6 +11,26 @@
namespace media {
+namespace {
+
+constexpr char kDummySessionId[] = "dummy session id";
+
+class IgnoreResponsePromise : public SimpleCdmPromise {
+ public:
+ IgnoreResponsePromise() = default;
+ ~IgnoreResponsePromise() override = default;
+
+ // SimpleCdmPromise implementation.
+ void resolve() final { MarkPromiseSettled(); }
+ void reject(CdmPromise::Exception exception_code,
+ uint32_t system_code,
+ const std::string& error_message) final {
+ MarkPromiseSettled();
+ }
+};
+
+} // namespace
+
ClearKeyCdmProxy::ClearKeyCdmProxy() : weak_factory_(this) {}
ClearKeyCdmProxy::~ClearKeyCdmProxy() {}
@@ -23,9 +43,8 @@ base::WeakPtr<CdmContext> ClearKeyCdmProxy::GetCdmContext() {
void ClearKeyCdmProxy::Initialize(Client* client, InitializeCB init_cb) {
DVLOG(1) << __func__;
- std::move(init_cb).Run(
- Status::kOk, Protocol::kIntelConvergedSecurityAndManageabilityEngine,
- kClearKeyCdmProxyCryptoSessionId);
+ std::move(init_cb).Run(Status::kOk, Protocol::kIntel,
+ kClearKeyCdmProxyCryptoSessionId);
}
void ClearKeyCdmProxy::Process(Function function,
@@ -67,7 +86,15 @@ void ClearKeyCdmProxy::CreateMediaCryptoSession(
void ClearKeyCdmProxy::SetKey(uint32_t crypto_session_id,
const std::vector<uint8_t>& key_id,
- const std::vector<uint8_t>& key_blob) {}
+ const std::vector<uint8_t>& key_blob) {
+ DVLOG(1) << __func__;
+
+ if (!aes_decryptor_)
+ CreateDecryptor();
+
+ aes_decryptor_->UpdateSession(kDummySessionId, key_blob,
+ std::make_unique<IgnoreResponsePromise>());
+}
void ClearKeyCdmProxy::RemoveKey(uint32_t crypto_session_id,
const std::vector<uint8_t>& key_id) {}
@@ -75,13 +102,22 @@ void ClearKeyCdmProxy::RemoveKey(uint32_t crypto_session_id,
Decryptor* ClearKeyCdmProxy::GetDecryptor() {
DVLOG(1) << __func__;
- if (!aes_decryptor_) {
- aes_decryptor_ = base::MakeRefCounted<AesDecryptor>(
- base::DoNothing(), base::DoNothing(), base::DoNothing(),
- base::DoNothing());
- }
+ if (!aes_decryptor_)
+ CreateDecryptor();
return aes_decryptor_.get();
}
+void ClearKeyCdmProxy::CreateDecryptor() {
+ DVLOG(1) << __func__;
+ DCHECK(!aes_decryptor_);
+
+ aes_decryptor_ =
+ base::MakeRefCounted<AesDecryptor>(base::DoNothing(), base::DoNothing(),
+ base::DoNothing(), base::DoNothing());
+
+ // Also create a dummy session to be used for SetKey().
+ aes_decryptor_->CreateSession(kDummySessionId, CdmSessionType::kTemporary);
+}
+
} // namespace media
diff --git a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.h b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.h
index 20f3d99cb35..ac8dce769c9 100644
--- a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.h
+++ b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm_proxy.h
@@ -42,6 +42,8 @@ class ClearKeyCdmProxy : public CdmProxy, public CdmContext {
Decryptor* GetDecryptor() final;
private:
+ void CreateDecryptor();
+
scoped_refptr<AesDecryptor> aes_decryptor_;
base::WeakPtrFactory<ClearKeyCdmProxy> weak_factory_;
diff --git a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_persistent_session_cdm.cc b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_persistent_session_cdm.cc
index aade5d5d23e..f065633e075 100644
--- a/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_persistent_session_cdm.cc
+++ b/chromium/media/cdm/library_cdm/clear_key_cdm/clear_key_persistent_session_cdm.cc
@@ -117,7 +117,7 @@ void ClearKeyPersistentSessionCdm::CreateSessionAndGenerateRequest(
const std::vector<uint8_t>& init_data,
std::unique_ptr<NewSessionCdmPromise> promise) {
std::unique_ptr<NewSessionCdmPromise> new_promise;
- if (session_type != CdmSessionType::PERSISTENT_LICENSE_SESSION) {
+ if (session_type != CdmSessionType::kPersistentLicense) {
new_promise = std::move(promise);
} else {
// Since it's a persistent session, we need to save the session ID after
@@ -135,7 +135,7 @@ void ClearKeyPersistentSessionCdm::LoadSession(
CdmSessionType session_type,
const std::string& session_id,
std::unique_ptr<NewSessionCdmPromise> promise) {
- DCHECK_EQ(CdmSessionType::PERSISTENT_LICENSE_SESSION, session_type);
+ DCHECK_EQ(CdmSessionType::kPersistentLicense, session_type);
// Load the saved state for |session_id| and then create the session.
std::unique_ptr<CdmFileAdapter> file(new CdmFileAdapter(cdm_host_proxy_));
@@ -180,8 +180,7 @@ void ClearKeyPersistentSessionCdm::OnFileReadForLoadSession(
}
// Add the session to the list of active sessions.
- if (!cdm_->CreateSession(session_id,
- CdmSessionType::PERSISTENT_LICENSE_SESSION)) {
+ if (!cdm_->CreateSession(session_id, CdmSessionType::kPersistentLicense)) {
// If the session can't be created it's due to an already existing session
// with the same name.
promise->reject(CdmPromise::Exception::QUOTA_EXCEEDED_ERROR, 0,