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

Side by Side Diff: ppapi/cpp/private/content_decryptor_private.cc

Issue 24192004: Changes to the EME Pepper API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/private/content_decryptor_private.h" 5 #include "ppapi/cpp/private/content_decryptor_private.h"
6 6
7 #include <cstring> // memcpy 7 #include <cstring> // memcpy
8 8
9 #include "ppapi/c/ppb_var.h" 9 #include "ppapi/c/ppb_var.h"
10 #include "ppapi/c/private/ppb_content_decryptor_private.h" 10 #include "ppapi/c/private/ppb_content_decryptor_private.h"
11 #include "ppapi/c/private/ppp_content_decryptor_private.h" 11 #include "ppapi/c/private/ppp_content_decryptor_private.h"
12 #include "ppapi/cpp/instance.h" 12 #include "ppapi/cpp/instance.h"
13 #include "ppapi/cpp/instance_handle.h" 13 #include "ppapi/cpp/instance_handle.h"
14 #include "ppapi/cpp/logging.h" 14 #include "ppapi/cpp/logging.h"
15 #include "ppapi/cpp/module.h" 15 #include "ppapi/cpp/module.h"
16 #include "ppapi/cpp/module_impl.h" 16 #include "ppapi/cpp/module_impl.h"
17 #include "ppapi/cpp/var.h" 17 #include "ppapi/cpp/var.h"
18 18
19 namespace pp { 19 namespace pp {
20 20
21 namespace { 21 namespace {
22 22
23 static const char kPPPContentDecryptorInterface[] = 23 static const char kPPPContentDecryptorInterface[] =
24 PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE; 24 PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE;
25 25
26 void GenerateKeyRequest(PP_Instance instance, 26 void Initialize(PP_Instance instance,
27 PP_Var key_system_arg, 27 PP_Var key_system_arg,
28 PP_Var type_arg, 28 PP_Bool can_challenge_platform) {
29 PP_Var init_data_arg) {
30 void* object = 29 void* object =
31 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 30 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
32 if (!object) 31 if (!object)
33 return; 32 return;
34 33
35 pp::Var key_system_var(pp::PASS_REF, key_system_arg); 34 pp::Var key_system_var(pp::PASS_REF, key_system_arg);
36 if (!key_system_var.is_string()) 35 if (!key_system_var.is_string())
37 return; 36 return;
38 37
38 static_cast<ContentDecryptor_Private*>(object)->Initialize(
39 key_system_var.AsString(),
40 PP_ToBool(can_challenge_platform));
41 }
42
43 void GenerateKeyRequest(PP_Instance instance,
44 PP_Var type_arg,
45 PP_Var init_data_arg) {
46 void* object =
47 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
48 if (!object)
49 return;
50
39 pp::Var type_var(pp::PASS_REF, type_arg); 51 pp::Var type_var(pp::PASS_REF, type_arg);
40 if (!type_var.is_string()) 52 if (!type_var.is_string())
41 return; 53 return;
42 54
43 pp::Var init_data_var(pp::PASS_REF, init_data_arg); 55 pp::Var init_data_var(pp::PASS_REF, init_data_arg);
44 if (!init_data_var.is_array_buffer()) 56 if (!init_data_var.is_array_buffer())
45 return; 57 return;
46 pp::VarArrayBuffer init_data_array_buffer(init_data_var); 58 pp::VarArrayBuffer init_data_array_buffer(init_data_var);
47 59
48 static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest( 60 static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest(
49 key_system_var.AsString(),
50 type_var.AsString(), 61 type_var.AsString(),
51 init_data_array_buffer); 62 init_data_array_buffer);
52 } 63 }
53 64
54 void AddKey(PP_Instance instance, 65 void AddKey(PP_Instance instance,
55 PP_Var session_id_arg, 66 PP_Var session_id_arg,
56 PP_Var key_arg, 67 PP_Var key_arg,
57 PP_Var init_data_arg) { 68 PP_Var init_data_arg) {
58 void* object = 69 void* object =
59 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 70 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (!object) 188 if (!object)
178 return; 189 return;
179 190
180 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode( 191 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode(
181 decoder_type, 192 decoder_type,
182 encrypted_buffer, 193 encrypted_buffer,
183 *encrypted_block_info); 194 *encrypted_block_info);
184 } 195 }
185 196
186 const PPP_ContentDecryptor_Private ppp_content_decryptor = { 197 const PPP_ContentDecryptor_Private ppp_content_decryptor = {
198 &Initialize,
187 &GenerateKeyRequest, 199 &GenerateKeyRequest,
188 &AddKey, 200 &AddKey,
189 &CancelKeyRequest, 201 &CancelKeyRequest,
190 &Decrypt, 202 &Decrypt,
191 &InitializeAudioDecoder, 203 &InitializeAudioDecoder,
192 &InitializeVideoDecoder, 204 &InitializeVideoDecoder,
193 &DeinitializeDecoder, 205 &DeinitializeDecoder,
194 &ResetDecoder, 206 &ResetDecoder,
195 &DecryptAndDecode 207 &DecryptAndDecode
196 }; 208 };
(...skipping 10 matching lines...) Expand all
207 &ppp_content_decryptor); 219 &ppp_content_decryptor);
208 instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this); 220 instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this);
209 } 221 }
210 222
211 ContentDecryptor_Private::~ContentDecryptor_Private() { 223 ContentDecryptor_Private::~ContentDecryptor_Private() {
212 Instance::RemovePerInstanceObject(associated_instance_, 224 Instance::RemovePerInstanceObject(associated_instance_,
213 kPPPContentDecryptorInterface, 225 kPPPContentDecryptorInterface,
214 this); 226 this);
215 } 227 }
216 228
217 void ContentDecryptor_Private::NeedKey(const std::string& key_system,
218 const std::string& session_id,
219 pp::VarArrayBuffer init_data) {
220 // session_id can be empty here.
221 if (has_interface<PPB_ContentDecryptor_Private>()) {
222 pp::Var key_system_var(key_system);
223 pp::Var session_id_var(session_id);
224
225 get_interface<PPB_ContentDecryptor_Private>()->NeedKey(
226 associated_instance_.pp_instance(),
227 key_system_var.pp_var(),
228 session_id_var.pp_var(),
229 init_data.pp_var());
230 }
231 }
232
233 void ContentDecryptor_Private::KeyAdded(const std::string& key_system, 229 void ContentDecryptor_Private::KeyAdded(const std::string& key_system,
234 const std::string& session_id) { 230 const std::string& session_id) {
235 if (has_interface<PPB_ContentDecryptor_Private>()) { 231 if (has_interface<PPB_ContentDecryptor_Private>()) {
236 pp::Var key_system_var(key_system); 232 pp::Var key_system_var(key_system);
237 pp::Var session_id_var(session_id); 233 pp::Var session_id_var(session_id);
238 get_interface<PPB_ContentDecryptor_Private>()->KeyAdded( 234 get_interface<PPB_ContentDecryptor_Private>()->KeyAdded(
239 associated_instance_.pp_instance(), 235 associated_instance_.pp_instance(),
240 key_system_var.pp_var(), 236 key_system_var.pp_var(),
241 session_id_var.pp_var()); 237 session_id_var.pp_var());
242 } 238 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 const PP_DecryptedBlockInfo& decrypted_block_info) { 333 const PP_DecryptedBlockInfo& decrypted_block_info) {
338 if (has_interface<PPB_ContentDecryptor_Private>()) { 334 if (has_interface<PPB_ContentDecryptor_Private>()) {
339 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( 335 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples(
340 associated_instance_.pp_instance(), 336 associated_instance_.pp_instance(),
341 audio_frames.pp_resource(), 337 audio_frames.pp_resource(),
342 &decrypted_block_info); 338 &decrypted_block_info);
343 } 339 }
344 } 340 }
345 341
346 } // namespace pp 342 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/private/content_decryptor_private.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698