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

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) {
xhwang 2013/09/18 00:07:18 nit: one line
jrummell 2013/09/18 21:01:15 Added additional parameter, so it doesn't fit anym
28 PP_Var type_arg,
29 PP_Var init_data_arg) {
30 void* object = 28 void* object =
31 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 29 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
32 if (!object) 30 if (!object)
33 return; 31 return;
34 32
35 pp::Var key_system_var(pp::PASS_REF, key_system_arg); 33 pp::Var key_system_var(pp::PASS_REF, key_system_arg);
36 if (!key_system_var.is_string()) 34 if (!key_system_var.is_string())
37 return; 35 return;
38 36
37 static_cast<ContentDecryptor_Private*>(object)->Initialize(
38 key_system_var.AsString());
39 }
40
41 void GenerateKeyRequest(PP_Instance instance,
42 PP_Var type_arg,
43 PP_Var init_data_arg) {
44 void* object =
45 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
46 if (!object)
47 return;
48
39 pp::Var type_var(pp::PASS_REF, type_arg); 49 pp::Var type_var(pp::PASS_REF, type_arg);
40 if (!type_var.is_string()) 50 if (!type_var.is_string())
41 return; 51 return;
42 52
43 pp::Var init_data_var(pp::PASS_REF, init_data_arg); 53 pp::Var init_data_var(pp::PASS_REF, init_data_arg);
44 if (!init_data_var.is_array_buffer()) 54 if (!init_data_var.is_array_buffer())
45 return; 55 return;
46 pp::VarArrayBuffer init_data_array_buffer(init_data_var); 56 pp::VarArrayBuffer init_data_array_buffer(init_data_var);
47 57
48 static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest( 58 static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest(
49 key_system_var.AsString(),
50 type_var.AsString(), 59 type_var.AsString(),
51 init_data_array_buffer); 60 init_data_array_buffer);
52 } 61 }
53 62
54 void AddKey(PP_Instance instance, 63 void AddKey(PP_Instance instance,
55 PP_Var session_id_arg, 64 PP_Var session_id_arg,
56 PP_Var key_arg, 65 PP_Var key_arg,
57 PP_Var init_data_arg) { 66 PP_Var init_data_arg) {
58 void* object = 67 void* object =
59 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 68 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (!object) 186 if (!object)
178 return; 187 return;
179 188
180 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode( 189 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode(
181 decoder_type, 190 decoder_type,
182 encrypted_buffer, 191 encrypted_buffer,
183 *encrypted_block_info); 192 *encrypted_block_info);
184 } 193 }
185 194
186 const PPP_ContentDecryptor_Private ppp_content_decryptor = { 195 const PPP_ContentDecryptor_Private ppp_content_decryptor = {
196 &Initialize,
187 &GenerateKeyRequest, 197 &GenerateKeyRequest,
188 &AddKey, 198 &AddKey,
189 &CancelKeyRequest, 199 &CancelKeyRequest,
190 &Decrypt, 200 &Decrypt,
191 &InitializeAudioDecoder, 201 &InitializeAudioDecoder,
192 &InitializeVideoDecoder, 202 &InitializeVideoDecoder,
193 &DeinitializeDecoder, 203 &DeinitializeDecoder,
194 &ResetDecoder, 204 &ResetDecoder,
195 &DecryptAndDecode 205 &DecryptAndDecode
196 }; 206 };
(...skipping 10 matching lines...) Expand all
207 &ppp_content_decryptor); 217 &ppp_content_decryptor);
208 instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this); 218 instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this);
209 } 219 }
210 220
211 ContentDecryptor_Private::~ContentDecryptor_Private() { 221 ContentDecryptor_Private::~ContentDecryptor_Private() {
212 Instance::RemovePerInstanceObject(associated_instance_, 222 Instance::RemovePerInstanceObject(associated_instance_,
213 kPPPContentDecryptorInterface, 223 kPPPContentDecryptorInterface,
214 this); 224 this);
215 } 225 }
216 226
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, 227 void ContentDecryptor_Private::KeyAdded(const std::string& key_system,
234 const std::string& session_id) { 228 const std::string& session_id) {
235 if (has_interface<PPB_ContentDecryptor_Private>()) { 229 if (has_interface<PPB_ContentDecryptor_Private>()) {
236 pp::Var key_system_var(key_system); 230 pp::Var key_system_var(key_system);
237 pp::Var session_id_var(session_id); 231 pp::Var session_id_var(session_id);
238 get_interface<PPB_ContentDecryptor_Private>()->KeyAdded( 232 get_interface<PPB_ContentDecryptor_Private>()->KeyAdded(
239 associated_instance_.pp_instance(), 233 associated_instance_.pp_instance(),
240 key_system_var.pp_var(), 234 key_system_var.pp_var(),
241 session_id_var.pp_var()); 235 session_id_var.pp_var());
242 } 236 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 const PP_DecryptedBlockInfo& decrypted_block_info) { 331 const PP_DecryptedBlockInfo& decrypted_block_info) {
338 if (has_interface<PPB_ContentDecryptor_Private>()) { 332 if (has_interface<PPB_ContentDecryptor_Private>()) {
339 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( 333 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples(
340 associated_instance_.pp_instance(), 334 associated_instance_.pp_instance(),
341 audio_frames.pp_resource(), 335 audio_frames.pp_resource(),
342 &decrypted_block_info); 336 &decrypted_block_info);
343 } 337 }
344 } 338 }
345 339
346 } // namespace pp 340 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698