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

Unified Diff: ppapi/cpp/dev/content_decryptor_dev.cc

Issue 10545036: Add PPAPI decryptor interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CPP interface migration complete Created 8 years, 5 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: ppapi/cpp/dev/content_decryptor_dev.cc
diff --git a/ppapi/cpp/dev/content_decryptor_dev.cc b/ppapi/cpp/dev/content_decryptor_dev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6946ac2b1e4b0b53dcc1a5db2143aca55937ca22
--- /dev/null
+++ b/ppapi/cpp/dev/content_decryptor_dev.cc
@@ -0,0 +1,183 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/dev/content_decryptor_dev.h"
+
+#include "ppapi/c/dev/ppb_content_decryptor_dev.h"
+#include "ppapi/c/dev/ppp_content_decryptor_dev.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+static const char kPPPContentDecryptorInterface[] =
+ PPP_CONTENTDECRYPTOR_DEV_INTERFACE;
+
+PP_Bool GenerateKeyRequest(PP_Instance instance,
+ PP_Var key_system,
+ PP_Resource init_data) {
+ void* object =
+ Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
+ if (!object)
+ return PP_FALSE;
+ return PP_FromBool(
+ static_cast<ContentDecryptor_Dev*>(object)->GenerateKeyRequest(
+ key_system,
+ init_data));
+}
+
+PP_Bool AddKey(PP_Instance instance,
+ PP_Var session_id,
+ PP_Resource key) {
+ void* object =
+ Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
+ if (!object)
+ return PP_FALSE;
+ return PP_FromBool(
+ static_cast<ContentDecryptor_Dev*>(object)->AddKey(session_id, key));
+}
+
+PP_Bool CancelKeyRequest(PP_Instance instance,
+ PP_Var session_id) {
+ void* object =
+ Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
+ if (!object)
+ return PP_FALSE;
+ return PP_FromBool(
+ static_cast<ContentDecryptor_Dev*>(object)->CancelKeyRequest(session_id));
+}
+
+
+PP_Bool Decrypt(PP_Instance instance,
+ PP_Resource encrypted_block,
+ PP_CompletionCallback callback) {
+ void* object =
+ Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
+ if (!object)
+ return PP_FALSE;
+ return PP_FromBool(
+ static_cast<ContentDecryptor_Dev*>(object)->Decrypt(encrypted_block,
+ callback));
+}
+
+PP_Bool DecryptAndDecode(PP_Instance instance,
+ PP_Resource encrypted_block,
+ PP_CompletionCallback callback) {
+ void* object =
+ Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
+ if (!object)
+ return PP_FALSE;
+ return PP_FromBool(
+ static_cast<ContentDecryptor_Dev*>(object)->DecryptAndDecode(
+ encrypted_block,
+ callback));
+}
+
+const PPP_ContentDecryptor_Dev ppp_content_decryptor = {
+ &GenerateKeyRequest,
+ &AddKey,
+ &CancelKeyRequest,
+ &Decrypt,
+ &DecryptAndDecode
+};
+
+template <> const char* interface_name<PPB_ContentDecryptor_Dev>() {
+ return PPB_CONTENTDECRYPTOR_DEV_INTERFACE;
+}
+
+} // namespace
+
+ContentDecryptor_Dev::ContentDecryptor_Dev(Instance* instance)
+ : associated_instance_(instance) {
+ Module::Get()->AddPluginInterface(kPPPContentDecryptorInterface,
+ &ppp_content_decryptor);
+ instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this);
+}
+
+ContentDecryptor_Dev::~ContentDecryptor_Dev() {
+ Instance::RemovePerInstanceObject(associated_instance_,
+ kPPPContentDecryptorInterface,
+ this);
+}
+
+void ContentDecryptor_Dev::NeedKey(PP_Var key_system,
+ PP_Var session_id,
+ PP_Resource init_data) {
+ if (has_interface<PPB_ContentDecryptor_Dev>()) {
+ get_interface<PPB_ContentDecryptor_Dev>()->NeedKey(
+ associated_instance_.pp_instance(), key_system, session_id, init_data);
+ }
+}
+
+void ContentDecryptor_Dev::KeyAdded(PP_Var key_system,
+ PP_Var session_id) {
+ if (has_interface<PPB_ContentDecryptor_Dev>()) {
+ get_interface<PPB_ContentDecryptor_Dev>()->KeyAdded(
+ associated_instance_.pp_instance(), key_system, session_id);
+ }
+}
+
+void ContentDecryptor_Dev::KeyMessage(PP_Var key_system,
+ PP_Var session_id,
+ PP_Resource message,
+ PP_Var default_url) {
+ if (has_interface<PPB_ContentDecryptor_Dev>()) {
+ get_interface<PPB_ContentDecryptor_Dev>()->KeyMessage(
+ associated_instance_.pp_instance(),
+ key_system,
+ session_id,
+ message,
+ default_url);
+ }
+}
+
+void ContentDecryptor_Dev::KeyError(PP_Var key_system,
+ PP_Var session_id,
+ uint16_t media_error,
+ uint16_t system_error) {
+ if (has_interface<PPB_ContentDecryptor_Dev>()) {
+ get_interface<PPB_ContentDecryptor_Dev>()->KeyError(
+ associated_instance_.pp_instance(),
+ key_system,
+ session_id,
+ media_error,
+ system_error);
+ }
+}
+
+void ContentDecryptor_Dev::DeliverBlock(PP_Resource decrypted_block,
+ PP_CompletionCallback callback) {
+ if (has_interface<PPB_ContentDecryptor_Dev>()) {
+ get_interface<PPB_ContentDecryptor_Dev>()->DeliverBlock(
+ associated_instance_.pp_instance(),
+ decrypted_block,
+ callback);
+ }
+}
+
+void ContentDecryptor_Dev::DeliverFrame(PP_Resource decrypted_frame,
+ PP_CompletionCallback callback) {
+ if (has_interface<PPB_ContentDecryptor_Dev>()) {
+ get_interface<PPB_ContentDecryptor_Dev>()->DeliverFrame(
+ associated_instance_.pp_instance(),
+ decrypted_frame,
+ callback);
+ }
+}
+
+void ContentDecryptor_Dev::DeliverSamples(PP_Resource decrypted_samples,
+ PP_CompletionCallback callback) {
+ if (has_interface<PPB_ContentDecryptor_Dev>()) {
+ get_interface<PPB_ContentDecryptor_Dev>()->DeliverSamples(
+ associated_instance_.pp_instance(),
+ decrypted_samples,
+ callback);
+ }
+}
+
+} // namespace pp

Powered by Google App Engine
This is Rietveld 408576698