summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authorjrummell <jrummell@chromium.org>2014-09-07 17:38:31 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-08 00:40:15 +0000
commit1e9a7b144e268ac9310474352d8f54b0b03fe82a (patch)
treee02e7c3abea648e8fa46af7fe8f76fe38cf72c18 /ppapi/cpp
parentcd7694afb928b265e64be5448bb281ad86771f34 (diff)
downloadchromium_src-1e9a7b144e268ac9310474352d8f54b0b03fe82a.zip
chromium_src-1e9a7b144e268ac9310474352d8f54b0b03fe82a.tar.gz
chromium_src-1e9a7b144e268ac9310474352d8f54b0b03fe82a.tar.bz2
Update Pepper interface for EME
To support CDM_6, make the following changes: - add SetServerCertificate - add GetUsableKeyIds - rename ReleaseSession to CloseSession - add RemoveSession - add SessionKeysChange event - add SessionExpirationChange event Includes changes to cdm_adapter for the new functionality. Changes to use these new interfaces in blink in a future CL. BUG=358271 TEST=existing EME tests still pass + manual testing Review URL: https://codereview.chromium.org/496143002 Cr-Commit-Position: refs/heads/master@{#293672}
Diffstat (limited to 'ppapi/cpp')
-rw-r--r--ppapi/cpp/private/content_decryptor_private.cc125
-rw-r--r--ppapi/cpp/private/content_decryptor_private.h18
2 files changed, 125 insertions, 18 deletions
diff --git a/ppapi/cpp/private/content_decryptor_private.cc b/ppapi/cpp/private/content_decryptor_private.cc
index 3142511..65f822c 100644
--- a/ppapi/cpp/private/content_decryptor_private.cc
+++ b/ppapi/cpp/private/content_decryptor_private.cc
@@ -15,6 +15,7 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/var.h"
+#include "ppapi/cpp/var_array.h"
namespace pp {
@@ -38,6 +39,23 @@ void Initialize(PP_Instance instance,
key_system_var.AsString());
}
+void SetServerCertificate(PP_Instance instance,
+ uint32_t promise_id,
+ PP_Var server_certificate_arg) {
+ void* object =
+ Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
+ if (!object)
+ return;
+
+ pp::Var server_certificate_var(server_certificate_arg);
+ if (!server_certificate_var.is_array_buffer())
+ return;
+ pp::VarArrayBuffer server_certificate(server_certificate_var);
+
+ static_cast<ContentDecryptor_Private*>(object)
+ ->SetServerCertificate(promise_id, server_certificate);
+}
+
void CreateSession(PP_Instance instance,
uint32_t promise_id,
PP_Var init_data_type_arg,
@@ -102,9 +120,41 @@ void UpdateSession(PP_Instance instance,
->UpdateSession(promise_id, web_session_id_var.AsString(), response);
}
-void ReleaseSession(PP_Instance instance,
- uint32_t promise_id,
- PP_Var web_session_id_arg) {
+void CloseSession(PP_Instance instance,
+ uint32_t promise_id,
+ PP_Var web_session_id_arg) {
+ void* object =
+ Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
+ if (!object)
+ return;
+
+ pp::Var web_session_id_var(web_session_id_arg);
+ if (!web_session_id_var.is_string())
+ return;
+
+ static_cast<ContentDecryptor_Private*>(object)
+ ->CloseSession(promise_id, web_session_id_var.AsString());
+}
+
+void RemoveSession(PP_Instance instance,
+ uint32_t promise_id,
+ PP_Var web_session_id_arg) {
+ void* object =
+ Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
+ if (!object)
+ return;
+
+ pp::Var web_session_id_var(web_session_id_arg);
+ if (!web_session_id_var.is_string())
+ return;
+
+ static_cast<ContentDecryptor_Private*>(object)
+ ->RemoveSession(promise_id, web_session_id_var.AsString());
+}
+
+void GetUsableKeyIds(PP_Instance instance,
+ uint32_t promise_id,
+ PP_Var web_session_id_arg) {
void* object =
Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
if (!object)
@@ -115,7 +165,7 @@ void ReleaseSession(PP_Instance instance,
return;
static_cast<ContentDecryptor_Private*>(object)
- ->ReleaseSession(promise_id, web_session_id_var.AsString());
+ ->GetUsableKeyIds(promise_id, web_session_id_var.AsString());
}
void Decrypt(PP_Instance instance,
@@ -206,18 +256,20 @@ void DecryptAndDecode(PP_Instance instance,
}
const PPP_ContentDecryptor_Private ppp_content_decryptor = {
- &Initialize,
- &CreateSession,
- &LoadSession,
- &UpdateSession,
- &ReleaseSession,
- &Decrypt,
- &InitializeAudioDecoder,
- &InitializeVideoDecoder,
- &DeinitializeDecoder,
- &ResetDecoder,
- &DecryptAndDecode
-};
+ &Initialize,
+ &SetServerCertificate,
+ &CreateSession,
+ &LoadSession,
+ &UpdateSession,
+ &CloseSession,
+ &RemoveSession,
+ &GetUsableKeyIds,
+ &Decrypt,
+ &InitializeAudioDecoder,
+ &InitializeVideoDecoder,
+ &DeinitializeDecoder,
+ &ResetDecoder,
+ &DecryptAndDecode};
template <> const char* interface_name<PPB_ContentDecryptor_Private>() {
return PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE;
@@ -257,6 +309,23 @@ void ContentDecryptor_Private::PromiseResolvedWithSession(
}
}
+void ContentDecryptor_Private::PromiseResolvedWithKeyIds(
+ uint32_t promise_id,
+ const std::vector<std::vector<uint8_t> >& key_ids) {
+ if (has_interface<PPB_ContentDecryptor_Private>()) {
+ pp::VarArray key_ids_array = pp::VarArray();
+ key_ids_array.SetLength(key_ids.size());
+ for (size_t i = 0; i < key_ids.size(); ++i) {
+ const std::vector<uint8_t>& entry = key_ids[i];
+ pp::VarArrayBuffer array_buffer(entry.size());
+ memcpy(array_buffer.Map(), &entry[0], entry.size());
+ key_ids_array.Set(i, array_buffer);
+ }
+ get_interface<PPB_ContentDecryptor_Private>()->PromiseResolvedWithKeyIds(
+ associated_instance_.pp_instance(), promise_id, key_ids_array.pp_var());
+ }
+}
+
void ContentDecryptor_Private::PromiseRejected(
uint32_t promise_id,
PP_CdmExceptionCode exception_code,
@@ -288,6 +357,30 @@ void ContentDecryptor_Private::SessionMessage(
}
}
+void ContentDecryptor_Private::SessionKeysChange(
+ const std::string& web_session_id,
+ bool has_additional_usable_key) {
+ if (has_interface<PPB_ContentDecryptor_Private>()) {
+ pp::Var web_session_id_var(web_session_id);
+ get_interface<PPB_ContentDecryptor_Private>()->SessionKeysChange(
+ associated_instance_.pp_instance(),
+ web_session_id_var.pp_var(),
+ PP_FromBool(has_additional_usable_key));
+ }
+}
+
+void ContentDecryptor_Private::SessionExpirationChange(
+ const std::string& web_session_id,
+ PP_Time new_expiry_time) {
+ if (has_interface<PPB_ContentDecryptor_Private>()) {
+ pp::Var web_session_id_var(web_session_id);
+ get_interface<PPB_ContentDecryptor_Private>()->SessionExpirationChange(
+ associated_instance_.pp_instance(),
+ web_session_id_var.pp_var(),
+ new_expiry_time);
+ }
+}
+
void ContentDecryptor_Private::SessionReady(const std::string& web_session_id) {
if (has_interface<PPB_ContentDecryptor_Private>()) {
pp::Var web_session_id_var(web_session_id);
diff --git a/ppapi/cpp/private/content_decryptor_private.h b/ppapi/cpp/private/content_decryptor_private.h
index 674bd38..25aba52 100644
--- a/ppapi/cpp/private/content_decryptor_private.h
+++ b/ppapi/cpp/private/content_decryptor_private.h
@@ -6,6 +6,7 @@
#define PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_
#include <string>
+#include <vector>
#include "ppapi/c/private/pp_content_decryptor.h"
#include "ppapi/c/private/ppb_content_decryptor_private.h"
@@ -34,6 +35,8 @@ class ContentDecryptor_Private {
// strings. The change would allow the CDM wrapper to reuse vars when
// replying to the browser.
virtual void Initialize(const std::string& key_system) = 0;
+ virtual void SetServerCertificate(uint32_t promise_id,
+ pp::VarArrayBuffer server_certificate) = 0;
virtual void CreateSession(uint32_t promise_id,
const std::string& init_data_type,
pp::VarArrayBuffer init_data,
@@ -43,8 +46,12 @@ class ContentDecryptor_Private {
virtual void UpdateSession(uint32_t promise_id,
const std::string& web_session_id,
pp::VarArrayBuffer response) = 0;
- virtual void ReleaseSession(uint32_t promise_id,
- const std::string& web_session_id) = 0;
+ virtual void CloseSession(uint32_t promise_id,
+ const std::string& web_session_id) = 0;
+ virtual void RemoveSession(uint32_t promise_id,
+ const std::string& web_session_id) = 0;
+ virtual void GetUsableKeyIds(uint32_t promise_id,
+ const std::string& web_session_id) = 0;
virtual void Decrypt(pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) = 0;
virtual void InitializeAudioDecoder(
@@ -68,6 +75,9 @@ class ContentDecryptor_Private {
void PromiseResolved(uint32_t promise_id);
void PromiseResolvedWithSession(uint32_t promise_id,
const std::string& web_session_id);
+ void PromiseResolvedWithKeyIds(
+ uint32_t promise_id,
+ const std::vector<std::vector<uint8_t> >& key_ids);
void PromiseRejected(uint32_t promise_id,
PP_CdmExceptionCode exception_code,
uint32_t system_code,
@@ -75,6 +85,10 @@ class ContentDecryptor_Private {
void SessionMessage(const std::string& web_session_id,
pp::VarArrayBuffer message,
const std::string& destination_url);
+ void SessionKeysChange(const std::string& web_session_id,
+ bool has_additional_usable_key);
+ void SessionExpirationChange(const std::string& web_session_id,
+ PP_Time new_expiry_time);
void SessionReady(const std::string& web_session_id);
void SessionClosed(const std::string& web_session_id);
void SessionError(const std::string& web_session_id,