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

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

Issue 811923002: Changes to support CDM_7 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CrOS compile error Created 5 years, 11 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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 pp::Var server_certificate_var(server_certificate_arg); 50 pp::Var server_certificate_var(server_certificate_arg);
51 if (!server_certificate_var.is_array_buffer()) 51 if (!server_certificate_var.is_array_buffer())
52 return; 52 return;
53 pp::VarArrayBuffer server_certificate(server_certificate_var); 53 pp::VarArrayBuffer server_certificate(server_certificate_var);
54 54
55 static_cast<ContentDecryptor_Private*>(object) 55 static_cast<ContentDecryptor_Private*>(object)
56 ->SetServerCertificate(promise_id, server_certificate); 56 ->SetServerCertificate(promise_id, server_certificate);
57 } 57 }
58 58
59 void CreateSession(PP_Instance instance, 59 void CreateSessionAndGenerateRequest(PP_Instance instance,
60 uint32_t promise_id, 60 uint32_t promise_id,
61 PP_Var init_data_type_arg, 61 PP_SessionType session_type,
62 PP_Var init_data_arg, 62 PP_Var init_data_type_arg,
63 PP_SessionType session_type) { 63 PP_Var init_data_arg) {
64 void* object = 64 void* object =
65 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 65 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
66 if (!object) 66 if (!object)
67 return; 67 return;
68 68
69 pp::Var init_data_type_var(pp::PASS_REF, init_data_type_arg); 69 pp::Var init_data_type_var(pp::PASS_REF, init_data_type_arg);
70 if (!init_data_type_var.is_string()) 70 if (!init_data_type_var.is_string())
71 return; 71 return;
72 72
73 pp::Var init_data_var(pp::PASS_REF, init_data_arg); 73 pp::Var init_data_var(pp::PASS_REF, init_data_arg);
74 if (!init_data_var.is_array_buffer()) 74 if (!init_data_var.is_array_buffer())
75 return; 75 return;
76 pp::VarArrayBuffer init_data_array_buffer(init_data_var); 76 pp::VarArrayBuffer init_data_array_buffer(init_data_var);
77 77
78 static_cast<ContentDecryptor_Private*>(object) 78 static_cast<ContentDecryptor_Private*>(object)
79 ->CreateSession(promise_id, 79 ->CreateSessionAndGenerateRequest(promise_id, session_type,
80 init_data_type_var.AsString(), 80 init_data_type_var.AsString(),
81 init_data_array_buffer, 81 init_data_array_buffer);
82 session_type);
83 } 82 }
84 83
85 void LoadSession(PP_Instance instance, 84 void LoadSession(PP_Instance instance,
86 uint32_t promise_id, 85 uint32_t promise_id,
86 PP_SessionType session_type,
87 PP_Var web_session_id_arg) { 87 PP_Var web_session_id_arg) {
88 void* object = 88 void* object =
89 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 89 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
90 if (!object) 90 if (!object)
91 return; 91 return;
92 92
93 pp::Var web_session_id_var(web_session_id_arg); 93 pp::Var web_session_id_var(web_session_id_arg);
94 if (!web_session_id_var.is_string()) 94 if (!web_session_id_var.is_string())
95 return; 95 return;
96 96
97 static_cast<ContentDecryptor_Private*>(object) 97 static_cast<ContentDecryptor_Private*>(object)
98 ->LoadSession(promise_id, web_session_id_var.AsString()); 98 ->LoadSession(promise_id, session_type, web_session_id_var.AsString());
99 } 99 }
100 100
101 void UpdateSession(PP_Instance instance, 101 void UpdateSession(PP_Instance instance,
102 uint32_t promise_id, 102 uint32_t promise_id,
103 PP_Var web_session_id_arg, 103 PP_Var web_session_id_arg,
104 PP_Var response_arg) { 104 PP_Var response_arg) {
105 void* object = 105 void* object =
106 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 106 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
107 if (!object) 107 if (!object)
108 return; 108 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return; 145 return;
146 146
147 pp::Var web_session_id_var(web_session_id_arg); 147 pp::Var web_session_id_var(web_session_id_arg);
148 if (!web_session_id_var.is_string()) 148 if (!web_session_id_var.is_string())
149 return; 149 return;
150 150
151 static_cast<ContentDecryptor_Private*>(object) 151 static_cast<ContentDecryptor_Private*>(object)
152 ->RemoveSession(promise_id, web_session_id_var.AsString()); 152 ->RemoveSession(promise_id, web_session_id_var.AsString());
153 } 153 }
154 154
155 void GetUsableKeyIds(PP_Instance instance,
156 uint32_t promise_id,
157 PP_Var web_session_id_arg) {
158 void* object =
159 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
160 if (!object)
161 return;
162
163 pp::Var web_session_id_var(web_session_id_arg);
164 if (!web_session_id_var.is_string())
165 return;
166
167 static_cast<ContentDecryptor_Private*>(object)
168 ->GetUsableKeyIds(promise_id, web_session_id_var.AsString());
169 }
170
171 void Decrypt(PP_Instance instance, 155 void Decrypt(PP_Instance instance,
172 PP_Resource encrypted_resource, 156 PP_Resource encrypted_resource,
173 const PP_EncryptedBlockInfo* encrypted_block_info) { 157 const PP_EncryptedBlockInfo* encrypted_block_info) {
174 pp::Buffer_Dev encrypted_block(encrypted_resource); 158 pp::Buffer_Dev encrypted_block(encrypted_resource);
175 159
176 void* object = 160 void* object =
177 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); 161 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
178 if (!object) 162 if (!object)
179 return; 163 return;
180 164
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 235
252 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode( 236 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode(
253 decoder_type, 237 decoder_type,
254 encrypted_buffer, 238 encrypted_buffer,
255 *encrypted_block_info); 239 *encrypted_block_info);
256 } 240 }
257 241
258 const PPP_ContentDecryptor_Private ppp_content_decryptor = { 242 const PPP_ContentDecryptor_Private ppp_content_decryptor = {
259 &Initialize, 243 &Initialize,
260 &SetServerCertificate, 244 &SetServerCertificate,
261 &CreateSession, 245 &CreateSessionAndGenerateRequest,
262 &LoadSession, 246 &LoadSession,
263 &UpdateSession, 247 &UpdateSession,
264 &CloseSession, 248 &CloseSession,
265 &RemoveSession, 249 &RemoveSession,
266 &GetUsableKeyIds,
267 &Decrypt, 250 &Decrypt,
268 &InitializeAudioDecoder, 251 &InitializeAudioDecoder,
269 &InitializeVideoDecoder, 252 &InitializeVideoDecoder,
270 &DeinitializeDecoder, 253 &DeinitializeDecoder,
271 &ResetDecoder, 254 &ResetDecoder,
272 &DecryptAndDecode}; 255 &DecryptAndDecode};
273 256
274 template <> const char* interface_name<PPB_ContentDecryptor_Private>() { 257 template <> const char* interface_name<PPB_ContentDecryptor_Private>() {
275 return PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE; 258 return PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE;
276 } 259 }
(...skipping 25 matching lines...) Expand all
302 const std::string& web_session_id) { 285 const std::string& web_session_id) {
303 if (has_interface<PPB_ContentDecryptor_Private>()) { 286 if (has_interface<PPB_ContentDecryptor_Private>()) {
304 pp::Var web_session_id_var(web_session_id); 287 pp::Var web_session_id_var(web_session_id);
305 get_interface<PPB_ContentDecryptor_Private>()->PromiseResolvedWithSession( 288 get_interface<PPB_ContentDecryptor_Private>()->PromiseResolvedWithSession(
306 associated_instance_.pp_instance(), 289 associated_instance_.pp_instance(),
307 promise_id, 290 promise_id,
308 web_session_id_var.pp_var()); 291 web_session_id_var.pp_var());
309 } 292 }
310 } 293 }
311 294
312 void ContentDecryptor_Private::PromiseResolvedWithKeyIds(
313 uint32_t promise_id,
314 const std::vector<std::vector<uint8_t> >& key_ids) {
315 if (has_interface<PPB_ContentDecryptor_Private>()) {
316 pp::VarArray key_ids_array = pp::VarArray();
317 key_ids_array.SetLength(key_ids.size());
318 for (size_t i = 0; i < key_ids.size(); ++i) {
319 const std::vector<uint8_t>& entry = key_ids[i];
320 pp::VarArrayBuffer array_buffer(entry.size());
321 memcpy(array_buffer.Map(), &entry[0], entry.size());
322 key_ids_array.Set(i, array_buffer);
323 }
324 get_interface<PPB_ContentDecryptor_Private>()->PromiseResolvedWithKeyIds(
325 associated_instance_.pp_instance(), promise_id, key_ids_array.pp_var());
326 }
327 }
328
329 void ContentDecryptor_Private::PromiseRejected( 295 void ContentDecryptor_Private::PromiseRejected(
330 uint32_t promise_id, 296 uint32_t promise_id,
331 PP_CdmExceptionCode exception_code, 297 PP_CdmExceptionCode exception_code,
332 uint32_t system_code, 298 uint32_t system_code,
333 const std::string& error_description) { 299 const std::string& error_description) {
334 if (has_interface<PPB_ContentDecryptor_Private>()) { 300 if (has_interface<PPB_ContentDecryptor_Private>()) {
335 pp::Var error_description_var(error_description); 301 pp::Var error_description_var(error_description);
336 get_interface<PPB_ContentDecryptor_Private>()->PromiseRejected( 302 get_interface<PPB_ContentDecryptor_Private>()->PromiseRejected(
337 associated_instance_.pp_instance(), 303 associated_instance_.pp_instance(),
338 promise_id, 304 promise_id,
339 exception_code, 305 exception_code,
340 system_code, 306 system_code,
341 error_description_var.pp_var()); 307 error_description_var.pp_var());
342 } 308 }
343 } 309 }
344 310
345 void ContentDecryptor_Private::SessionMessage( 311 void ContentDecryptor_Private::SessionMessage(const std::string& web_session_id,
346 const std::string& web_session_id, 312 PP_CdmMessageType message_type,
347 pp::VarArrayBuffer message, 313 pp::VarArrayBuffer message) {
348 const std::string& destination_url) {
349 if (has_interface<PPB_ContentDecryptor_Private>()) { 314 if (has_interface<PPB_ContentDecryptor_Private>()) {
350 pp::Var web_session_id_var(web_session_id); 315 pp::Var web_session_id_var(web_session_id);
351 pp::Var destination_url_var(destination_url);
352 get_interface<PPB_ContentDecryptor_Private>()->SessionMessage( 316 get_interface<PPB_ContentDecryptor_Private>()->SessionMessage(
353 associated_instance_.pp_instance(), 317 associated_instance_.pp_instance(), web_session_id_var.pp_var(),
354 web_session_id_var.pp_var(), 318 message_type, message.pp_var());
355 message.pp_var(),
356 destination_url_var.pp_var());
357 } 319 }
358 } 320 }
359 321
360 void ContentDecryptor_Private::SessionKeysChange( 322 void ContentDecryptor_Private::SessionKeysChange(
361 const std::string& web_session_id, 323 const std::string& web_session_id,
362 bool has_additional_usable_key) { 324 bool has_additional_usable_key,
325 const std::vector<PP_KeyInformation>& key_information) {
363 if (has_interface<PPB_ContentDecryptor_Private>()) { 326 if (has_interface<PPB_ContentDecryptor_Private>()) {
364 pp::Var web_session_id_var(web_session_id); 327 pp::Var web_session_id_var(web_session_id);
365 get_interface<PPB_ContentDecryptor_Private>()->SessionKeysChange( 328 get_interface<PPB_ContentDecryptor_Private>()->SessionKeysChange(
366 associated_instance_.pp_instance(), 329 associated_instance_.pp_instance(), web_session_id_var.pp_var(),
367 web_session_id_var.pp_var(), 330 PP_FromBool(has_additional_usable_key), key_information.size(),
368 PP_FromBool(has_additional_usable_key)); 331 key_information.empty() ? NULL : &key_information[0]);
369 } 332 }
370 } 333 }
371 334
372 void ContentDecryptor_Private::SessionExpirationChange( 335 void ContentDecryptor_Private::SessionExpirationChange(
373 const std::string& web_session_id, 336 const std::string& web_session_id,
374 PP_Time new_expiry_time) { 337 PP_Time new_expiry_time) {
375 if (has_interface<PPB_ContentDecryptor_Private>()) { 338 if (has_interface<PPB_ContentDecryptor_Private>()) {
376 pp::Var web_session_id_var(web_session_id); 339 pp::Var web_session_id_var(web_session_id);
377 get_interface<PPB_ContentDecryptor_Private>()->SessionExpirationChange( 340 get_interface<PPB_ContentDecryptor_Private>()->SessionExpirationChange(
378 associated_instance_.pp_instance(), 341 associated_instance_.pp_instance(),
379 web_session_id_var.pp_var(), 342 web_session_id_var.pp_var(),
380 new_expiry_time); 343 new_expiry_time);
381 } 344 }
382 } 345 }
383 346
384 void ContentDecryptor_Private::SessionReady(const std::string& web_session_id) {
385 if (has_interface<PPB_ContentDecryptor_Private>()) {
386 pp::Var web_session_id_var(web_session_id);
387 get_interface<PPB_ContentDecryptor_Private>()->SessionReady(
388 associated_instance_.pp_instance(), web_session_id_var.pp_var());
389 }
390 }
391
392 void ContentDecryptor_Private::SessionClosed( 347 void ContentDecryptor_Private::SessionClosed(
393 const std::string& web_session_id) { 348 const std::string& web_session_id) {
394 if (has_interface<PPB_ContentDecryptor_Private>()) { 349 if (has_interface<PPB_ContentDecryptor_Private>()) {
395 pp::Var web_session_id_var(web_session_id); 350 pp::Var web_session_id_var(web_session_id);
396 get_interface<PPB_ContentDecryptor_Private>()->SessionClosed( 351 get_interface<PPB_ContentDecryptor_Private>()->SessionClosed(
397 associated_instance_.pp_instance(), web_session_id_var.pp_var()); 352 associated_instance_.pp_instance(), web_session_id_var.pp_var());
398 } 353 }
399 } 354 }
400 355
401 void ContentDecryptor_Private::SessionError( 356 void ContentDecryptor_Private::SessionError(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 const PP_DecryptedSampleInfo& decrypted_sample_info) { 432 const PP_DecryptedSampleInfo& decrypted_sample_info) {
478 if (has_interface<PPB_ContentDecryptor_Private>()) { 433 if (has_interface<PPB_ContentDecryptor_Private>()) {
479 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( 434 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples(
480 associated_instance_.pp_instance(), 435 associated_instance_.pp_instance(),
481 audio_frames.pp_resource(), 436 audio_frames.pp_resource(),
482 &decrypted_sample_info); 437 &decrypted_sample_info);
483 } 438 }
484 } 439 }
485 440
486 } // namespace pp 441 } // 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