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,
......
This diff is collapsed.
......@@ -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,9 +381,8 @@ static void CopyDecryptResults(
*buffer_copy = buffer;
}
cdm::Status ClearKeyCdm::Decrypt(
const cdm::InputBuffer& encrypted_buffer,
cdm::DecryptedBlock* decrypted_block) {
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