Commit 673d6e5f authored by jrummell@chromium.org's avatar jrummell@chromium.org

Add support for CDM_6.

Changes for CDM_6:
- ReleaseSession() becomes CloseSession()
- add RemoveSession()
- add GetUsableKeyIds()
- simulate UsableKeysChanged event for older CDMs

BUG=358271,351139
TEST=encrypted-media layout tests and browser_tests for encrypted media pass

Review URL: https://codereview.chromium.org/446693004

Cr-Commit-Position: refs/heads/master@{#288295}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288295 0039d316-1c4b-4281-b951-d872f2087c98
parent fe36633c
......@@ -302,7 +302,7 @@ deps = {
"/trunk/deps/third_party/opus@256783",
"src/media/cdm/ppapi/api":
"/trunk/deps/cdm@273356",
"/trunk/deps/cdm@288172",
"src/third_party/mesa/src":
"/trunk/deps/third_party/mesa@265279",
......
......@@ -385,10 +385,28 @@ void CdmAdapter::UpdateSession(uint32_t promise_id,
void CdmAdapter::ReleaseSession(uint32_t promise_id,
const std::string& web_session_id) {
cdm_->ReleaseSession(
cdm_->CloseSession(
promise_id, web_session_id.data(), web_session_id.length());
}
void CdmAdapter::RemoveSession(uint32_t promise_id,
const std::string& web_session_id) {
if (!cdm_->RemoveSession(
promise_id, web_session_id.data(), web_session_id.length())) {
// CDM_4 and CDM_5 don't support this method, so reject the promise.
RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
}
}
void CdmAdapter::GetUsableKeyIds(uint32_t promise_id,
const std::string& web_session_id) {
if (!cdm_->GetUsableKeyIds(
promise_id, web_session_id.data(), web_session_id.length())) {
// CDM_4 and CDM_5 don't support this method, so reject the promise.
RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
}
}
// Note: In the following decryption/decoding related functions, errors are NOT
// reported via KeyError, but are reported via corresponding PPB calls.
......@@ -667,15 +685,25 @@ void CdmAdapter::OnSessionError(uint32_t session_id,
}
}
// cdm::Host_5 methods
// cdm::Host_5 and cdm::Host_6 methods
cdm::Time CdmAdapter::GetCurrentTime() {
return GetCurrentWallTime();
}
cdm::Time CdmAdapter::GetCurrentWallTime() {
return pp::Module::Get()->core()->GetTime();
}
void CdmAdapter::OnResolvePromise(uint32_t promise_id) {
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendPromiseResolvedInternal, promise_id));
// CDM_5 doesn't support OnSessionKeysChange(), so simulate one if requested.
// Passing "true" which may result in false positives for retrying.
std::string session_id;
if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
OnSessionKeysChange(session_id.data(), session_id.length(), true);
}
void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
......@@ -685,6 +713,27 @@ void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
&CdmAdapter::SendPromiseResolvedWithSessionInternal,
promise_id,
std::string(web_session_id, web_session_id_length)));
// CDM_5 doesn't support OnSessionKeysChange(), so simulate one if requested.
// Passing "true" which may result in false positives for retrying.
std::string session_id;
if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
OnSessionKeysChange(web_session_id, web_session_id_length, true);
}
void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id,
const cdm::BinaryData* usable_key_ids,
uint32_t usable_key_ids_length) {
std::vector<std::vector<uint8> > key_ids;
for (uint32_t i = 0; i < usable_key_ids_length; ++i) {
key_ids.push_back(
std::vector<uint8>(usable_key_ids[i].data,
usable_key_ids[i].data + usable_key_ids[i].length));
}
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal,
promise_id,
key_ids));
}
void CdmAdapter::OnRejectPromise(uint32_t promise_id,
......@@ -724,17 +773,26 @@ void CdmAdapter::OnSessionMessage(const char* web_session_id,
void CdmAdapter::OnSessionKeysChange(const char* web_session_id,
uint32_t web_session_id_length,
bool has_additional_usable_key) {
// TODO(jrummell): Implement this event in subsequent CL
// (http://crbug.com/370251).
PP_NOTREACHED();
OnSessionUsableKeysChange(
web_session_id, web_session_id_length, has_additional_usable_key);
}
void CdmAdapter::OnSessionUsableKeysChange(const char* web_session_id,
uint32_t web_session_id_length,
bool has_additional_usable_key) {
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendSessionUsableKeysChangeInternal,
std::string(web_session_id, web_session_id_length),
has_additional_usable_key));
}
void CdmAdapter::OnExpirationChange(const char* web_session_id,
uint32_t web_session_id_length,
cdm::Time new_expiry_time) {
// TODO(jrummell): Implement this event in subsequent CL
// (http://crbug.com/370251).
PP_NOTREACHED();
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendExpirationChangeInternal,
std::string(web_session_id, web_session_id_length),
new_expiry_time));
}
void CdmAdapter::OnSessionReady(const char* web_session_id,
......@@ -782,6 +840,15 @@ void CdmAdapter::SendPromiseResolvedWithSessionInternal(
web_session_id);
}
void CdmAdapter::SendPromiseResolvedWithUsableKeyIdsInternal(
int32_t result,
uint32_t promise_id,
std::vector<std::vector<uint8> > key_ids) {
PP_DCHECK(result == PP_OK);
// TODO(jrummell): Implement this event in subsequent CL.
// (http://crbug.com/358271).
}
void CdmAdapter::SendPromiseRejectedInternal(int32_t result,
uint32_t promise_id,
const SessionError& error) {
......@@ -832,6 +899,23 @@ void CdmAdapter::SendSessionErrorInternal(int32_t result,
error.error_description);
}
void CdmAdapter::SendSessionUsableKeysChangeInternal(
int32_t result,
const std::string& web_session_id,
bool has_additional_usable_key) {
PP_DCHECK(result == PP_OK);
// TODO(jrummell): Implement this event in subsequent CL.
// (http://crbug.com/358271).
}
void CdmAdapter::SendExpirationChangeInternal(int32_t result,
const std::string& web_session_id,
cdm::Time new_expiry_time) {
PP_DCHECK(result == PP_OK);
// TODO(jrummell): Implement this event in subsequent CL.
// (http://crbug.com/358271).
}
void CdmAdapter::DeliverBlock(int32_t result,
const cdm::Status& status,
const LinkedDecryptedBlock& decrypted_block,
......@@ -1214,7 +1298,7 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
return NULL;
COMPILE_ASSERT(
cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_5::kVersion,
cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_6::kVersion,
update_code_below);
// Ensure IsSupportedCdmHostVersion matches implementation of this function.
......@@ -1224,10 +1308,11 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
PP_DCHECK(
// Future version is not supported.
!IsSupportedCdmHostVersion(cdm::Host_5::kVersion + 1) &&
!IsSupportedCdmHostVersion(cdm::Host_6::kVersion + 1) &&
// Current version is supported.
IsSupportedCdmHostVersion(cdm::Host_5::kVersion) &&
IsSupportedCdmHostVersion(cdm::Host_6::kVersion) &&
// Include all previous supported versions (if any) here.
IsSupportedCdmHostVersion(cdm::Host_5::kVersion) &&
IsSupportedCdmHostVersion(cdm::Host_4::kVersion) &&
// One older than the oldest supported version is not supported.
!IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1));
......@@ -1240,6 +1325,8 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
return static_cast<cdm::Host_4*>(cdm_adapter);
case cdm::Host_5::kVersion:
return static_cast<cdm::Host_5*>(cdm_adapter);
case cdm::Host_6::kVersion:
return static_cast<cdm::Host_6*>(cdm_adapter);
default:
PP_NOTREACHED();
return NULL;
......
......@@ -43,7 +43,8 @@ void* GetCdmHost(int host_interface_version, void* user_data);
class CdmAdapter : public pp::Instance,
public pp::ContentDecryptor_Private,
public cdm::Host_4,
public cdm::Host_5 {
public cdm::Host_5,
public cdm::Host_6 {
public:
CdmAdapter(PP_Instance instance, pp::Module* module);
virtual ~CdmAdapter();
......@@ -66,8 +67,14 @@ class CdmAdapter : public pp::Instance,
virtual void UpdateSession(uint32_t promise_id,
const std::string& web_session_id,
pp::VarArrayBuffer response) OVERRIDE;
// TODO(jrummell): Rename to CloseSession().
virtual void ReleaseSession(uint32_t promise_id,
const std::string& web_session_id) OVERRIDE;
// TODO(jrummell): Pass these 2 functions through Pepper and add OVERRIDE.
virtual void RemoveSession(uint32_t promise_id,
const std::string& web_session_id);
virtual void GetUsableKeyIds(uint32_t promise_id,
const std::string& web_session_id);
virtual void Decrypt(
pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
......@@ -86,7 +93,7 @@ class CdmAdapter : public pp::Instance,
pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
// cdm::Host_4 and cdm::Host_5 implementation.
// cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation.
virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE;
virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE;
......@@ -126,10 +133,10 @@ class CdmAdapter : public pp::Instance,
uint32_t destination_url_length) OVERRIDE;
virtual void OnSessionKeysChange(const char* web_session_id,
uint32_t web_session_id_length,
bool has_additional_usable_key);
bool has_additional_usable_key) OVERRIDE;
virtual void OnExpirationChange(const char* web_session_id,
uint32_t web_session_id_length,
cdm::Time new_expiry_time);
cdm::Time new_expiry_time) OVERRIDE;
virtual void OnSessionReady(const char* web_session_id,
uint32_t web_session_id_length) OVERRIDE;
virtual void OnSessionClosed(const char* web_session_id,
......@@ -141,7 +148,17 @@ class CdmAdapter : public pp::Instance,
const char* error_message,
uint32_t error_message_length) OVERRIDE;
// cdm::Host_4 and cdm::Host_5 implementation.
// cdm::Host_6 implementation.
virtual cdm::Time GetCurrentWallTime() OVERRIDE;
virtual void OnResolveKeyIdsPromise(uint32_t promise_id,
const cdm::BinaryData* usable_key_ids,
uint32_t usable_key_ids_length) OVERRIDE;
virtual void OnSessionUsableKeysChange(
const char* web_session_id,
uint32_t web_session_id_length,
bool has_additional_usable_key) OVERRIDE;
// cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation.
virtual void SendPlatformChallenge(const char* service_id,
uint32_t service_id_length,
const char* challenge,
......@@ -186,6 +203,10 @@ class CdmAdapter : public pp::Instance,
int32_t result,
uint32_t promise_id,
const std::string& web_session_id);
void SendPromiseResolvedWithUsableKeyIdsInternal(
int32_t result,
uint32_t promise_id,
std::vector<std::vector<uint8> > key_ids);
void SendPromiseRejectedInternal(int32_t result,
uint32_t promise_id,
const SessionError& error);
......@@ -200,6 +221,12 @@ class CdmAdapter : public pp::Instance,
void SendSessionErrorInternal(int32_t result,
const std::string& web_session_id,
const SessionError& error);
void SendSessionUsableKeysChangeInternal(int32_t result,
const std::string& web_session_id,
bool has_additional_usable_key);
void SendExpirationChangeInternal(int32_t result,
const std::string& web_session_id,
cdm::Time new_expiry_time);
void RejectPromise(uint32_t promise_id,
cdm::Error error,
uint32_t system_code,
......
......@@ -56,7 +56,13 @@ class CdmWrapper {
uint32_t web_session_id_size,
const uint8_t* response,
uint32_t response_size) = 0;
virtual void ReleaseSession(uint32_t promise_id,
virtual void CloseSession(uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) = 0;
virtual bool RemoveSession(uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) = 0;
virtual bool GetUsableKeyIds(uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) = 0;
virtual void TimerExpired(void* context) = 0;
......@@ -95,6 +101,32 @@ class CdmWrapper {
virtual std::string LookupWebSessionId(uint32_t session_id) = 0;
virtual void DropWebSessionId(std::string web_session_id) = 0;
// Helper functions for the cdm::Host_4 and cdm::Host_5 methods.
// CDMs using cdm::Host_6 will call OnSessionUsableKeys() as necessary when
// resolving LoadSession() and UpdateSession(). This needs to be simulated
// for the older CDMs. These must not be called for cdm::Host_6 and later.
// TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed.
// Query whether a SessionUsableKeys event is necessary for the specified
// |promise_id|. Returns true if needed and |web_session_id| is updated,
// otherwise returns false.
virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id,
std::string* web_session_id) = 0;
// Used to indicate that a SessionUsableKeys event is required for the
// specified |promise_id| and associated |web_session_id|.
virtual void SetSessionUsableKeysEventNeeded(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) = 0;
// cdm::Host_6 introduces InputBuffer_2 (aka InputBuffer). cdm::Host_4 and
// cdm::Host_5 methods still use InputBuffer_1, so this helper function
// converts InputBuffer_2 to InputBuffer_1.
// TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed.
virtual void ConvertInputBuffer(const cdm::InputBuffer& v2,
cdm::InputBuffer_1* v1) = 0;
protected:
CdmWrapper() {}
......@@ -158,10 +190,24 @@ class CdmWrapperImpl : public CdmWrapper {
response_size);
}
virtual void ReleaseSession(uint32_t promise_id,
virtual bool GetUsableKeyIds(uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) OVERRIDE {
cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size);
cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size);
return true;
}
virtual void CloseSession(uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) OVERRIDE {
cdm_->CloseSession(promise_id, web_session_id, web_session_id_size);
}
virtual bool RemoveSession(uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) OVERRIDE {
cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size);
return true;
}
virtual void TimerExpired(void* context) OVERRIDE {
......@@ -261,6 +307,38 @@ class CdmWrapperImpl : public CdmWrapper {
web_session_to_session_id_map_.erase(web_session_id);
}
virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id,
std::string* web_session_id) {
std::map<uint32_t, std::string>::iterator it =
promises_needing_usable_keys_event_.find(promise_id);
if (it == promises_needing_usable_keys_event_.end())
return false;
web_session_id->swap(it->second);
promises_needing_usable_keys_event_.erase(it);
return true;
}
virtual void SetSessionUsableKeysEventNeeded(uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
promises_needing_usable_keys_event_.insert(std::make_pair(
promise_id, std::string(web_session_id, web_session_id_size)));
}
virtual void ConvertInputBuffer(const cdm::InputBuffer& v2,
cdm::InputBuffer_1* v1) {
v1->data = v2.data;
v1->data_size = v2.data_size;
v1->data_offset = 0;
v1->key_id = v2.key_id;
v1->key_id_size = v2.key_id_size;
v1->iv = v2.iv;
v1->iv_size = v2.iv_size;
v1->subsamples = v2.subsamples;
v1->num_subsamples = v2.num_subsamples;
v1->timestamp = v2.timestamp;
}
private:
CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm), next_session_id_(100) {
PP_DCHECK(cdm_);
......@@ -272,6 +350,8 @@ class CdmWrapperImpl : public CdmWrapper {
uint32_t next_session_id_;
std::map<std::string, uint32_t> web_session_to_session_id_map_;
std::map<uint32_t, std::string> promises_needing_usable_keys_event_;
DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl);
};
......@@ -308,6 +388,10 @@ void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::LoadSession(
uint32_t web_session_id_size) {
uint32_t session_id = CreateSessionId();
RegisterPromise(session_id, promise_id);
// As CDM_4 doesn't support OnSessionUsableKeysChange(), make sure to generate
// one when the promise is resolved. This may be overly aggressive.
SetSessionUsableKeysEventNeeded(
promise_id, web_session_id, web_session_id_size);
cdm_->LoadSession(session_id, web_session_id, web_session_id_size);
}
......@@ -321,11 +405,15 @@ void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::UpdateSession(
std::string web_session_str(web_session_id, web_session_id_size);
uint32_t session_id = LookupSessionId(web_session_str);
RegisterPromise(session_id, promise_id);
// As CDM_4 doesn't support OnSessionUsableKeysChange(), make sure to generate
// one when the promise is resolved. This may be overly aggressive.
SetSessionUsableKeysEventNeeded(
promise_id, web_session_id, web_session_id_size);
cdm_->UpdateSession(session_id, response, response_size);
}
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::ReleaseSession(
void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CloseSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
......@@ -335,12 +423,140 @@ void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::ReleaseSession(
cdm_->ReleaseSession(session_id);
}
template <>
bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::RemoveSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
return false;
}
template <>
bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::GetUsableKeyIds(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
return false;
}
template <>
cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Decrypt(
const cdm::InputBuffer& encrypted_buffer,
cdm::DecryptedBlock* decrypted_buffer) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->Decrypt(buffer, decrypted_buffer);
}
template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeFrame(
const cdm::InputBuffer& encrypted_buffer,
cdm::VideoFrame* video_frame) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->DecryptAndDecodeFrame(buffer, video_frame);
}
template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeSamples(
const cdm::InputBuffer& encrypted_buffer,
cdm::AudioFrames* audio_frames) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
}
// Overrides for the cdm::Host_5 methods.
// TODO(jrummell): Remove these once Host_5 interface is removed.
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::LoadSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
// As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate
// one when the promise is resolved. This may be overly aggressive.
SetSessionUsableKeysEventNeeded(
promise_id, web_session_id, web_session_id_size);
cdm_->LoadSession(promise_id, web_session_id, web_session_id_size);
}
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::UpdateSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size,
const uint8_t* response,
uint32_t response_size) {
// As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate
// one when the promise is resolved. This may be overly aggressive.
SetSessionUsableKeysEventNeeded(
promise_id, web_session_id, web_session_id_size);
cdm_->UpdateSession(
promise_id, web_session_id, web_session_id_size, response, response_size);
}
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CloseSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size);
}
template <>
bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::RemoveSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
return false;
}
template <>
bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::GetUsableKeyIds(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
return false;
}
template <>
cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Decrypt(
const cdm::InputBuffer& encrypted_buffer,
cdm::DecryptedBlock* decrypted_buffer) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->Decrypt(buffer, decrypted_buffer);
}
template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeFrame(
const cdm::InputBuffer& encrypted_buffer,
cdm::VideoFrame* video_frame) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->DecryptAndDecodeFrame(buffer, video_frame);
}
template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeSamples(
const cdm::InputBuffer& encrypted_buffer,
cdm::AudioFrames* audio_frames) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
}
CdmWrapper* CdmWrapper::Create(const char* key_system,
uint32_t key_system_size,
GetCdmHostFunc get_cdm_host_func,
void* user_data) {
COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
cdm::ContentDecryptionModule_5::kVersion,
cdm::ContentDecryptionModule_6::kVersion,
update_code_below);
// Ensure IsSupportedCdmInterfaceVersion() matches this implementation.
......@@ -365,6 +581,11 @@ CdmWrapper* CdmWrapper::Create(const char* key_system,
// If |cdm_wrapper| is NULL, try to create the CDM using older supported
// versions of the CDM interface.
cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Create(
key_system, key_system_size, get_cdm_host_func, user_data);
if (cdm_wrapper)
return cdm_wrapper;
cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create(
key_system, key_system_size, get_cdm_host_func, user_data);
return cdm_wrapper;
......@@ -375,7 +596,7 @@ CdmWrapper* CdmWrapper::Create(const char* key_system,
// does not have.
// Also update supported_cdm_versions.h.
COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
cdm::ContentDecryptionModule_5::kVersion,
cdm::ContentDecryptionModule_6::kVersion,
ensure_cdm_wrapper_templates_have_old_version_support);
} // namespace media
......
......@@ -95,7 +95,7 @@ const char kFileIOTestResultHeader[] = "FILEIOTESTRESULT";
// Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is
// empty, an empty (end-of-stream) media::DecoderBuffer is returned.
static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom(
const cdm::InputBuffer& input_buffer) {
const cdm::InputBuffer_1& input_buffer) {
if (!input_buffer.data) {
DCHECK(!input_buffer.data_size);
return media::DecoderBuffer::CreateEOSBuffer();
......@@ -381,8 +381,7 @@ static void CopyDecryptResults(
*buffer_copy = buffer;
}
cdm::Status ClearKeyCdm::Decrypt(
const cdm::InputBuffer& encrypted_buffer,
cdm::Status ClearKeyCdm::Decrypt(const cdm::InputBuffer_1& encrypted_buffer,
cdm::DecryptedBlock* decrypted_block) {
DVLOG(1) << "Decrypt()";
DCHECK(encrypted_buffer.data);
......@@ -488,7 +487,7 @@ void ClearKeyCdm::DeinitializeDecoder(cdm::StreamType decoder_type) {
}
cdm::Status ClearKeyCdm::DecryptAndDecodeFrame(
const cdm::InputBuffer& encrypted_buffer,
const cdm::InputBuffer_1& encrypted_buffer,
cdm::VideoFrame* decoded_frame) {
DVLOG(1) << "DecryptAndDecodeFrame()";
TRACE_EVENT0("media", "ClearKeyCdm::DecryptAndDecodeFrame");
......@@ -512,7 +511,7 @@ cdm::Status ClearKeyCdm::DecryptAndDecodeFrame(
}
cdm::Status ClearKeyCdm::DecryptAndDecodeSamples(
const cdm::InputBuffer& encrypted_buffer,
const cdm::InputBuffer_1& encrypted_buffer,
cdm::AudioFrames* audio_frames) {
DVLOG(1) << "DecryptAndDecodeSamples()";
......@@ -570,7 +569,7 @@ void ClearKeyCdm::ScheduleNextHeartBeat() {
}
cdm::Status ClearKeyCdm::DecryptToMediaDecoderBuffer(
const cdm::InputBuffer& encrypted_buffer,
const cdm::InputBuffer_1& encrypted_buffer,
scoped_refptr<media::DecoderBuffer>* decrypted_buffer) {
DCHECK(decrypted_buffer);
scoped_refptr<media::DecoderBuffer> buffer =
......
......@@ -57,7 +57,7 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
const uint8_t* server_certificate_data,
uint32_t server_certificate_data_size) OVERRIDE;
virtual void TimerExpired(void* context) OVERRIDE;
virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
virtual cdm::Status Decrypt(const cdm::InputBuffer_1& encrypted_buffer,
cdm::DecryptedBlock* decrypted_block) OVERRIDE;
virtual cdm::Status InitializeAudioDecoder(
const cdm::AudioDecoderConfig& audio_decoder_config) OVERRIDE;
......@@ -66,10 +66,10 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE;
virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE;
virtual cdm::Status DecryptAndDecodeFrame(
const cdm::InputBuffer& encrypted_buffer,
const cdm::InputBuffer_1& encrypted_buffer,
cdm::VideoFrame* video_frame) OVERRIDE;
virtual cdm::Status DecryptAndDecodeSamples(
const cdm::InputBuffer& encrypted_buffer,
const cdm::InputBuffer_1& encrypted_buffer,
cdm::AudioFrames* audio_frames) OVERRIDE;
virtual void Destroy() OVERRIDE;
virtual void OnPlatformChallengeResponse(
......@@ -111,7 +111,7 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
// Returns cdm::kDecryptError if any decryption error occurred. In this case
// |decrypted_buffer| should be ignored by the caller.
cdm::Status DecryptToMediaDecoderBuffer(
const cdm::InputBuffer& encrypted_buffer,
const cdm::InputBuffer_1& encrypted_buffer,
scoped_refptr<DecoderBuffer>* decrypted_buffer);
#if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
......
......@@ -21,10 +21,11 @@ bool IsSupportedCdmModuleVersion(int version) {
bool IsSupportedCdmInterfaceVersion(int version) {
COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
cdm::ContentDecryptionModule_5::kVersion,
cdm::ContentDecryptionModule_6::kVersion,
update_code_below);
switch(version) {
// Supported versions in decreasing order.
case cdm::ContentDecryptionModule_6::kVersion:
case cdm::ContentDecryptionModule_5::kVersion:
case cdm::ContentDecryptionModule_4::kVersion:
return true;
......@@ -35,10 +36,11 @@ bool IsSupportedCdmInterfaceVersion(int version) {
bool IsSupportedCdmHostVersion(int version) {
COMPILE_ASSERT(cdm::ContentDecryptionModule::Host::kVersion ==
cdm::ContentDecryptionModule_5::Host::kVersion,
cdm::ContentDecryptionModule_6::Host::kVersion,
update_code_below);
switch(version) {
// Supported versions in decreasing order.
case cdm::Host_6::kVersion:
case cdm::Host_5::kVersion:
case cdm::Host_4::kVersion:
return true;
......
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