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

Side by Side 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: Revert change to ppapi_tests.gypi. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/cpp/dev/content_decryptor_dev.h"
6
7 #include "ppapi/c/dev/ppb_content_decryptor_dev.h"
8 #include "ppapi/c/dev/ppp_content_decryptor_dev.h"
9 #include "ppapi/cpp/instance.h"
10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/module_impl.h"
13
14 namespace pp {
15
16 namespace {
17
18 static const char kPPPContentDecryptorInterface[] =
19 PPP_CONTENTDECRYPTOR_DEV_INTERFACE;
20
21 PP_Bool GenerateKeyRequest(PP_Instance instance,
22 PP_Var key_system,
23 PP_Resource init_data) {
24 void* object =
25 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
26 if (!object)
27 return PP_FALSE;
28 return PP_FromBool(
29 static_cast<ContentDecryptor_Dev*>(object)->GenerateKeyRequest(
30 key_system,
31 init_data));
32 }
33
34 PP_Bool AddKey(PP_Instance instance,
35 PP_Var session_id,
36 PP_Resource key) {
37 void* object =
38 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
39 if (!object)
40 return PP_FALSE;
41 return PP_FromBool(
42 static_cast<ContentDecryptor_Dev*>(object)->AddKey(session_id, key));
43 }
44
45 PP_Bool CancelKeyRequest(PP_Instance instance,
46 PP_Var session_id) {
47 void* object =
48 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
49 if (!object)
50 return PP_FALSE;
51 return PP_FromBool(
52 static_cast<ContentDecryptor_Dev*>(object)->CancelKeyRequest(session_id));
53 }
54
55
56 PP_Bool Decrypt(PP_Instance instance,
57 PP_Resource encrypted_block,
58 PP_CompletionCallback callback) {
59 void* object =
60 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
61 if (!object)
62 return PP_FALSE;
63 return PP_FromBool(
64 static_cast<ContentDecryptor_Dev*>(object)->Decrypt(encrypted_block,
65 callback));
66 }
67
68 PP_Bool DecryptAndDecode(PP_Instance instance,
69 PP_Resource encrypted_block,
70 PP_CompletionCallback callback) {
71 void* object =
72 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
73 if (!object)
74 return PP_FALSE;
75 return PP_FromBool(
76 static_cast<ContentDecryptor_Dev*>(object)->DecryptAndDecode(
77 encrypted_block,
78 callback));
79 }
80
81 const PPP_ContentDecryptor_Dev ppp_content_decryptor = {
82 &GenerateKeyRequest,
83 &AddKey,
84 &CancelKeyRequest,
85 &Decrypt,
86 &DecryptAndDecode
87 };
88
89 template <> const char* interface_name<PPB_ContentDecryptor_Dev>() {
90 return PPB_CONTENTDECRYPTOR_DEV_INTERFACE;
91 }
92
93 } // namespace
94
95 ContentDecryptor_Dev::ContentDecryptor_Dev(Instance* instance)
96 : associated_instance_(instance) {
97 Module::Get()->AddPluginInterface(kPPPContentDecryptorInterface,
98 &ppp_content_decryptor);
99 instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this);
100 }
101
102 ContentDecryptor_Dev::~ContentDecryptor_Dev() {
103 Instance::RemovePerInstanceObject(associated_instance_,
104 kPPPContentDecryptorInterface,
105 this);
106 }
107
108 void ContentDecryptor_Dev::NeedKey(PP_Var key_system,
109 PP_Var session_id,
110 PP_Resource init_data) {
111 if (has_interface<PPB_ContentDecryptor_Dev>()) {
112 get_interface<PPB_ContentDecryptor_Dev>()->NeedKey(
113 associated_instance_.pp_instance(), key_system, session_id, init_data);
114 }
115 }
116
117 void ContentDecryptor_Dev::KeyAdded(PP_Var key_system,
118 PP_Var session_id) {
119 if (has_interface<PPB_ContentDecryptor_Dev>()) {
120 get_interface<PPB_ContentDecryptor_Dev>()->KeyAdded(
121 associated_instance_.pp_instance(), key_system, session_id);
122 }
123 }
124
125 void ContentDecryptor_Dev::KeyMessage(PP_Var key_system,
126 PP_Var session_id,
127 PP_Resource message,
128 PP_Var default_url) {
129 if (has_interface<PPB_ContentDecryptor_Dev>()) {
130 get_interface<PPB_ContentDecryptor_Dev>()->KeyMessage(
131 associated_instance_.pp_instance(),
132 key_system,
133 session_id,
134 message,
135 default_url);
136 }
137 }
138
139 void ContentDecryptor_Dev::KeyError(PP_Var key_system,
140 PP_Var session_id,
141 uint16_t media_error,
142 uint16_t system_error) {
143 if (has_interface<PPB_ContentDecryptor_Dev>()) {
144 get_interface<PPB_ContentDecryptor_Dev>()->KeyError(
145 associated_instance_.pp_instance(),
146 key_system,
147 session_id,
148 media_error,
149 system_error);
150 }
151 }
152
153 void ContentDecryptor_Dev::DeliverBlock(PP_Resource decrypted_block,
154 PP_CompletionCallback callback) {
155 if (has_interface<PPB_ContentDecryptor_Dev>()) {
156 get_interface<PPB_ContentDecryptor_Dev>()->DeliverBlock(
157 associated_instance_.pp_instance(),
158 decrypted_block,
159 callback);
160 }
161 }
162
163 void ContentDecryptor_Dev::DeliverFrame(PP_Resource decrypted_frame,
164 PP_CompletionCallback callback) {
165 if (has_interface<PPB_ContentDecryptor_Dev>()) {
166 get_interface<PPB_ContentDecryptor_Dev>()->DeliverFrame(
167 associated_instance_.pp_instance(),
168 decrypted_frame,
169 callback);
170 }
171 }
172
173 void ContentDecryptor_Dev::DeliverSamples(PP_Resource decrypted_samples,
174 PP_CompletionCallback callback) {
175 if (has_interface<PPB_ContentDecryptor_Dev>()) {
176 get_interface<PPB_ContentDecryptor_Dev>()->DeliverSamples(
177 associated_instance_.pp_instance(),
178 decrypted_samples,
179 callback);
180 }
181 }
182
183 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698