| 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..6368170721b6ae257614028d0df4d7abc9d6c807
|
| --- /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_Var 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_Var 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_Var 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,
|
| + int32_t media_error,
|
| + int32_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
|
|
|