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

Unified Diff: media/cdm/ppapi/cdm_adapter.cc

Issue 446693004: Add support for CDM_6. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
Index: media/cdm/ppapi/cdm_adapter.cc
diff --git a/media/cdm/ppapi/cdm_adapter.cc b/media/cdm/ppapi/cdm_adapter.cc
index 14aa23120b27b5ce8d3c08d3c7aae0d2f44db9a6..98edb5fb393d50aa7222531ffce9b973129aca09 100644
--- a/media/cdm/ppapi/cdm_adapter.cc
+++ b/media/cdm/ppapi/cdm_adapter.cc
@@ -383,12 +383,30 @@ void CdmAdapter::UpdateSession(uint32_t promise_id,
response_size);
}
+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 supported.");
ddorwin 2014/08/07 01:34:43 Maybe "Not implemented." "Not supported" is redund
jrummell 2014/08/07 20:44:30 This rejection happens for CDM_4 and CDM_5, which
ddorwin 2014/08/07 22:10:43 Yes, but the message goes to JS, so we want it to
+ }
+}
+
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 supported.");
ddorwin 2014/08/07 01:34:43 ditto
jrummell 2014/08/07 20:44:30 ditto
+ }
+}
+
// Note: In the following decryption/decoding related functions, errors are NOT
// reported via KeyError, but are reported via corresponding PPB calls.
@@ -670,12 +688,19 @@ void CdmAdapter::OnSessionError(uint32_t session_id,
// cdm::Host_5 methods
ddorwin 2014/08/07 01:34:43 and 6?
jrummell 2014/08/07 20:44:29 Done.
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));
+ std::string session_id;
ddorwin 2014/08/07 01:34:43 Although the Wrapper explains these are for 4 & 5,
jrummell 2014/08/07 20:44:29 Done.
+ if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
+ OnSessionKeysChange(session_id.data(), session_id.length(), true);
}
void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
@@ -685,6 +710,24 @@ void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
&CdmAdapter::SendPromiseResolvedWithSessionInternal,
promise_id,
std::string(web_session_id, web_session_id_length)));
+ 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 +767,28 @@ 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();
+ PostOnMain(callback_factory_.NewCallback(
ddorwin 2014/08/07 01:34:43 Just call OnSessionUsableKeysChange?
jrummell 2014/08/07 20:44:29 Done.
+ &CdmAdapter::SendSessionUsableKeysChangeInternal,
+ std::string(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 +836,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 +895,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 +1294,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 +1304,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 +1321,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;

Powered by Google App Engine
This is Rietveld 408576698