| OLD | NEW |
| 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 GenerateKeyRequest(PP_Instance instance, |
| 27 PP_Var key_system_arg, | 27 PP_Var key_system_arg, |
| 28 PP_Var type_arg, |
| 28 PP_Var init_data_arg) { | 29 PP_Var init_data_arg) { |
| 29 void* object = | 30 void* object = |
| 30 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 31 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 31 if (!object) | 32 if (!object) |
| 32 return; | 33 return; |
| 33 | 34 |
| 34 pp::Var key_system_var(pp::PASS_REF, key_system_arg); | 35 pp::Var key_system_var(pp::PASS_REF, key_system_arg); |
| 35 if (key_system_var.is_string() == false) | 36 if (!key_system_var.is_string()) |
| 37 return; |
| 38 |
| 39 pp::Var type_var(pp::PASS_REF, type_arg); |
| 40 if (!type_var.is_string()) |
| 36 return; | 41 return; |
| 37 | 42 |
| 38 pp::Var init_data_var(pp::PASS_REF, init_data_arg); | 43 pp::Var init_data_var(pp::PASS_REF, init_data_arg); |
| 39 if (init_data_var.is_array_buffer() == false) | 44 if (!init_data_var.is_array_buffer()) |
| 40 return; | 45 return; |
| 41 pp::VarArrayBuffer init_data_array_buffer(init_data_var); | 46 pp::VarArrayBuffer init_data_array_buffer(init_data_var); |
| 42 | 47 |
| 43 static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest( | 48 static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest( |
| 44 key_system_var.AsString(), | 49 key_system_var.AsString(), |
| 50 type_var.AsString(), |
| 45 init_data_array_buffer); | 51 init_data_array_buffer); |
| 46 } | 52 } |
| 47 | 53 |
| 48 void AddKey(PP_Instance instance, | 54 void AddKey(PP_Instance instance, |
| 49 PP_Var session_id_arg, | 55 PP_Var session_id_arg, |
| 50 PP_Var key_arg, | 56 PP_Var key_arg, |
| 51 PP_Var init_data_arg) { | 57 PP_Var init_data_arg) { |
| 52 void* object = | 58 void* object = |
| 53 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 59 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 54 if (!object) | 60 if (!object) |
| 55 return; | 61 return; |
| 56 | 62 |
| 57 pp::Var session_id_var(pp::PASS_REF, session_id_arg); | 63 pp::Var session_id_var(pp::PASS_REF, session_id_arg); |
| 58 if (session_id_var.is_string() == false) | 64 if (!session_id_var.is_string()) |
| 59 return; | 65 return; |
| 60 | 66 |
| 61 pp::Var key_var(pp::PASS_REF, key_arg); | 67 pp::Var key_var(pp::PASS_REF, key_arg); |
| 62 if (key_var.is_array_buffer() == false) | 68 if (!key_var.is_array_buffer()) |
| 63 return; | 69 return; |
| 64 pp::VarArrayBuffer key(key_var); | 70 pp::VarArrayBuffer key(key_var); |
| 65 | 71 |
| 66 pp::Var init_data_var(pp::PASS_REF, init_data_arg); | 72 pp::Var init_data_var(pp::PASS_REF, init_data_arg); |
| 67 if (init_data_var.is_array_buffer() == false) | 73 if (!init_data_var.is_array_buffer()) |
| 68 return; | 74 return; |
| 69 pp::VarArrayBuffer init_data(init_data_var); | 75 pp::VarArrayBuffer init_data(init_data_var); |
| 70 | 76 |
| 71 | 77 |
| 72 static_cast<ContentDecryptor_Private*>(object)->AddKey( | 78 static_cast<ContentDecryptor_Private*>(object)->AddKey( |
| 73 session_id_var.AsString(), | 79 session_id_var.AsString(), |
| 74 key, | 80 key, |
| 75 init_data); | 81 init_data); |
| 76 } | 82 } |
| 77 | 83 |
| 78 void CancelKeyRequest(PP_Instance instance, PP_Var session_id_arg) { | 84 void CancelKeyRequest(PP_Instance instance, PP_Var session_id_arg) { |
| 79 void* object = | 85 void* object = |
| 80 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 86 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 81 if (!object) | 87 if (!object) |
| 82 return; | 88 return; |
| 83 | 89 |
| 84 pp::Var session_id_var(pp::PASS_REF, session_id_arg); | 90 pp::Var session_id_var(pp::PASS_REF, session_id_arg); |
| 85 if (session_id_var.is_string() == false) | 91 if (!session_id_var.is_string()) |
| 86 return; | 92 return; |
| 87 | 93 |
| 88 static_cast<ContentDecryptor_Private*>(object)->CancelKeyRequest( | 94 static_cast<ContentDecryptor_Private*>(object)->CancelKeyRequest( |
| 89 session_id_var.AsString()); | 95 session_id_var.AsString()); |
| 90 } | 96 } |
| 91 | 97 |
| 92 | 98 |
| 93 void Decrypt(PP_Instance instance, | 99 void Decrypt(PP_Instance instance, |
| 94 PP_Resource encrypted_resource, | 100 PP_Resource encrypted_resource, |
| 95 const PP_EncryptedBlockInfo* encrypted_block_info) { | 101 const PP_EncryptedBlockInfo* encrypted_block_info) { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 const PP_DecryptedBlockInfo& decrypted_block_info) { | 337 const PP_DecryptedBlockInfo& decrypted_block_info) { |
| 332 if (has_interface<PPB_ContentDecryptor_Private>()) { | 338 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 333 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( | 339 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( |
| 334 associated_instance_.pp_instance(), | 340 associated_instance_.pp_instance(), |
| 335 audio_frames.pp_resource(), | 341 audio_frames.pp_resource(), |
| 336 &decrypted_block_info); | 342 &decrypted_block_info); |
| 337 } | 343 } |
| 338 } | 344 } |
| 339 | 345 |
| 340 } // namespace pp | 346 } // namespace pp |
| OLD | NEW |