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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 pp::Var key_system_var(pp::PASS_REF, key_system_arg); | 33 pp::Var key_system_var(pp::PASS_REF, key_system_arg); |
34 if (!key_system_var.is_string()) | 34 if (!key_system_var.is_string()) |
35 return; | 35 return; |
36 | 36 |
37 static_cast<ContentDecryptor_Private*>(object)->Initialize( | 37 static_cast<ContentDecryptor_Private*>(object)->Initialize( |
38 key_system_var.AsString()); | 38 key_system_var.AsString()); |
39 } | 39 } |
40 | 40 |
41 void CreateSession(PP_Instance instance, | 41 void CreateSession(PP_Instance instance, |
42 uint32_t session_id, | 42 uint32_t session_id, |
43 PP_Var type_arg, | 43 PP_Var content_type_arg, |
44 PP_Var init_data_arg) { | 44 PP_Var init_data_arg) { |
45 void* object = | 45 void* object = |
46 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 46 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
47 if (!object) | 47 if (!object) |
48 return; | 48 return; |
49 | 49 |
50 pp::Var type_var(pp::PASS_REF, type_arg); | 50 pp::Var content_type_var(pp::PASS_REF, content_type_arg); |
51 if (!type_var.is_string()) | 51 if (!content_type_var.is_string()) |
52 return; | 52 return; |
53 | 53 |
54 pp::Var init_data_var(pp::PASS_REF, init_data_arg); | 54 pp::Var init_data_var(pp::PASS_REF, init_data_arg); |
55 if (!init_data_var.is_array_buffer()) | 55 if (!init_data_var.is_array_buffer()) |
56 return; | 56 return; |
57 pp::VarArrayBuffer init_data_array_buffer(init_data_var); | 57 pp::VarArrayBuffer init_data_array_buffer(init_data_var); |
58 | 58 |
| 59 static_cast<ContentDecryptor_Private*>(object)->CreateSession( |
| 60 session_id, content_type_var.AsString(), init_data_array_buffer); |
| 61 } |
| 62 |
| 63 void LoadSession(PP_Instance instance, |
| 64 uint32_t session_id, |
| 65 PP_Var web_session_id_arg) { |
| 66 void* object = |
| 67 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 68 if (!object) |
| 69 return; |
| 70 |
| 71 pp::Var web_session_id_var(pp::PASS_REF, web_session_id_arg); |
| 72 if (!web_session_id_var.is_string()) |
| 73 return; |
| 74 |
59 static_cast<ContentDecryptor_Private*>(object) | 75 static_cast<ContentDecryptor_Private*>(object) |
60 ->CreateSession(session_id, type_var.AsString(), init_data_array_buffer); | 76 ->LoadSession(session_id, web_session_id_var.AsString()); |
61 } | 77 } |
62 | 78 |
63 void UpdateSession(PP_Instance instance, | 79 void UpdateSession(PP_Instance instance, |
64 uint32_t session_id, | 80 uint32_t session_id, |
65 PP_Var response_arg) { | 81 PP_Var response_arg) { |
66 void* object = | 82 void* object = |
67 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 83 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
68 if (!object) | 84 if (!object) |
69 return; | 85 return; |
70 | 86 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 186 |
171 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode( | 187 static_cast<ContentDecryptor_Private*>(object)->DecryptAndDecode( |
172 decoder_type, | 188 decoder_type, |
173 encrypted_buffer, | 189 encrypted_buffer, |
174 *encrypted_block_info); | 190 *encrypted_block_info); |
175 } | 191 } |
176 | 192 |
177 const PPP_ContentDecryptor_Private ppp_content_decryptor = { | 193 const PPP_ContentDecryptor_Private ppp_content_decryptor = { |
178 &Initialize, | 194 &Initialize, |
179 &CreateSession, | 195 &CreateSession, |
| 196 &LoadSession, |
180 &UpdateSession, | 197 &UpdateSession, |
181 &ReleaseSession, | 198 &ReleaseSession, |
182 &Decrypt, | 199 &Decrypt, |
183 &InitializeAudioDecoder, | 200 &InitializeAudioDecoder, |
184 &InitializeVideoDecoder, | 201 &InitializeVideoDecoder, |
185 &DeinitializeDecoder, | 202 &DeinitializeDecoder, |
186 &ResetDecoder, | 203 &ResetDecoder, |
187 &DecryptAndDecode | 204 &DecryptAndDecode |
188 }; | 205 }; |
189 | 206 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 const PP_DecryptedSampleInfo& decrypted_sample_info) { | 336 const PP_DecryptedSampleInfo& decrypted_sample_info) { |
320 if (has_interface<PPB_ContentDecryptor_Private>()) { | 337 if (has_interface<PPB_ContentDecryptor_Private>()) { |
321 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( | 338 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( |
322 associated_instance_.pp_instance(), | 339 associated_instance_.pp_instance(), |
323 audio_frames.pp_resource(), | 340 audio_frames.pp_resource(), |
324 &decrypted_sample_info); | 341 &decrypted_sample_info); |
325 } | 342 } |
326 } | 343 } |
327 | 344 |
328 } // namespace pp | 345 } // namespace pp |
OLD | NEW |