Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 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 reference_id, | 42 uint32_t session_id, |
| 43 PP_Var type_arg, | 43 PP_Var 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 type_var(pp::PASS_REF, type_arg); |
| 51 if (!type_var.is_string()) | 51 if (!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( | 59 static_cast<ContentDecryptor_Private*>(object) |
| 60 reference_id, type_var.AsString(), init_data_array_buffer); | 60 ->CreateSession(session_id, type_var.AsString(), init_data_array_buffer); |
|
ddorwin
2013/12/05 00:44:52
Weird break. Did a tool do this?
jrummell
2013/12/06 23:42:35
clang-format.
| |
| 61 } | 61 } |
| 62 | 62 |
| 63 void UpdateSession(PP_Instance instance, | 63 void UpdateSession(PP_Instance instance, |
| 64 uint32_t reference_id, | 64 uint32_t session_id, |
| 65 PP_Var response_arg) { | 65 PP_Var response_arg) { |
| 66 void* object = | 66 void* object = |
| 67 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 67 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 68 if (!object) | 68 if (!object) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 pp::Var response_var(pp::PASS_REF, response_arg); | 71 pp::Var response_var(pp::PASS_REF, response_arg); |
| 72 if (!response_var.is_array_buffer()) | 72 if (!response_var.is_array_buffer()) |
| 73 return; | 73 return; |
| 74 pp::VarArrayBuffer response(response_var); | 74 pp::VarArrayBuffer response(response_var); |
| 75 | 75 |
| 76 static_cast<ContentDecryptor_Private*>(object) | 76 static_cast<ContentDecryptor_Private*>(object) |
| 77 ->UpdateSession(reference_id, response); | 77 ->UpdateSession(session_id, response); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ReleaseSession(PP_Instance instance, uint32_t reference_id) { | 80 void ReleaseSession(PP_Instance instance, uint32_t session_id) { |
| 81 void* object = | 81 void* object = |
| 82 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 82 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| 83 if (!object) | 83 if (!object) |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 static_cast<ContentDecryptor_Private*>(object)->ReleaseSession(reference_id); | 86 static_cast<ContentDecryptor_Private*>(object)->ReleaseSession(session_id); |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 void Decrypt(PP_Instance instance, | 90 void Decrypt(PP_Instance instance, |
| 91 PP_Resource encrypted_resource, | 91 PP_Resource encrypted_resource, |
| 92 const PP_EncryptedBlockInfo* encrypted_block_info) { | 92 const PP_EncryptedBlockInfo* encrypted_block_info) { |
| 93 pp::Buffer_Dev encrypted_block(encrypted_resource); | 93 pp::Buffer_Dev encrypted_block(encrypted_resource); |
| 94 | 94 |
| 95 void* object = | 95 void* object = |
| 96 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); | 96 Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 &ppp_content_decryptor); | 199 &ppp_content_decryptor); |
| 200 instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this); | 200 instance->AddPerInstanceObject(kPPPContentDecryptorInterface, this); |
| 201 } | 201 } |
| 202 | 202 |
| 203 ContentDecryptor_Private::~ContentDecryptor_Private() { | 203 ContentDecryptor_Private::~ContentDecryptor_Private() { |
| 204 Instance::RemovePerInstanceObject(associated_instance_, | 204 Instance::RemovePerInstanceObject(associated_instance_, |
| 205 kPPPContentDecryptorInterface, | 205 kPPPContentDecryptorInterface, |
| 206 this); | 206 this); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void ContentDecryptor_Private::SessionCreated(uint32_t reference_id, | 209 void ContentDecryptor_Private::SessionCreated( |
| 210 const std::string& session_id) { | 210 uint32_t session_id, |
| 211 const std::string& web_session_id) { | |
| 211 if (has_interface<PPB_ContentDecryptor_Private>()) { | 212 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 212 pp::Var session_id_var(session_id); | 213 pp::Var web_session_id_var(web_session_id); |
| 213 get_interface<PPB_ContentDecryptor_Private>()->SessionCreated( | 214 get_interface<PPB_ContentDecryptor_Private>()->SessionCreated( |
| 214 associated_instance_.pp_instance(), | 215 associated_instance_.pp_instance(), |
| 215 reference_id, | 216 session_id, |
| 216 session_id_var.pp_var()); | 217 web_session_id_var.pp_var()); |
| 217 } | 218 } |
| 218 } | 219 } |
| 219 | 220 |
| 220 void ContentDecryptor_Private::SessionMessage(uint32_t reference_id, | 221 void ContentDecryptor_Private::SessionMessage(uint32_t session_id, |
| 221 pp::VarArrayBuffer message, | 222 pp::VarArrayBuffer message, |
| 222 const std::string& default_url) { | 223 const std::string& default_url) { |
| 223 if (has_interface<PPB_ContentDecryptor_Private>()) { | 224 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 224 pp::Var default_url_var(default_url); | 225 pp::Var default_url_var(default_url); |
| 225 get_interface<PPB_ContentDecryptor_Private>()->SessionMessage( | 226 get_interface<PPB_ContentDecryptor_Private>()->SessionMessage( |
| 226 associated_instance_.pp_instance(), | 227 associated_instance_.pp_instance(), |
| 227 reference_id, | 228 session_id, |
| 228 message.pp_var(), | 229 message.pp_var(), |
| 229 default_url_var.pp_var()); | 230 default_url_var.pp_var()); |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 | 233 |
| 233 void ContentDecryptor_Private::SessionReady(uint32_t reference_id) { | 234 void ContentDecryptor_Private::SessionReady(uint32_t session_id) { |
| 234 if (has_interface<PPB_ContentDecryptor_Private>()) { | 235 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 235 get_interface<PPB_ContentDecryptor_Private>()->SessionReady( | 236 get_interface<PPB_ContentDecryptor_Private>()->SessionReady( |
| 236 associated_instance_.pp_instance(), reference_id); | 237 associated_instance_.pp_instance(), session_id); |
| 237 } | 238 } |
| 238 } | 239 } |
| 239 | 240 |
| 240 void ContentDecryptor_Private::SessionClosed(uint32_t reference_id) { | 241 void ContentDecryptor_Private::SessionClosed(uint32_t session_id) { |
| 241 if (has_interface<PPB_ContentDecryptor_Private>()) { | 242 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 242 get_interface<PPB_ContentDecryptor_Private>()->SessionClosed( | 243 get_interface<PPB_ContentDecryptor_Private>()->SessionClosed( |
| 243 associated_instance_.pp_instance(), reference_id); | 244 associated_instance_.pp_instance(), session_id); |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 | 247 |
| 247 void ContentDecryptor_Private::SessionError(uint32_t reference_id, | 248 void ContentDecryptor_Private::SessionError(uint32_t session_id, |
| 248 int32_t media_error, | 249 int32_t media_error, |
| 249 int32_t system_code) { | 250 int32_t system_code) { |
| 250 if (has_interface<PPB_ContentDecryptor_Private>()) { | 251 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 251 get_interface<PPB_ContentDecryptor_Private>()->SessionError( | 252 get_interface<PPB_ContentDecryptor_Private>()->SessionError( |
| 252 associated_instance_.pp_instance(), | 253 associated_instance_.pp_instance(), |
| 253 reference_id, | 254 session_id, |
| 254 media_error, | 255 media_error, |
| 255 system_code); | 256 system_code); |
| 256 } | 257 } |
| 257 } | 258 } |
| 258 | 259 |
| 259 void ContentDecryptor_Private::DeliverBlock( | 260 void ContentDecryptor_Private::DeliverBlock( |
| 260 pp::Buffer_Dev decrypted_block, | 261 pp::Buffer_Dev decrypted_block, |
| 261 const PP_DecryptedBlockInfo& decrypted_block_info) { | 262 const PP_DecryptedBlockInfo& decrypted_block_info) { |
| 262 if (has_interface<PPB_ContentDecryptor_Private>()) { | 263 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 263 get_interface<PPB_ContentDecryptor_Private>()->DeliverBlock( | 264 get_interface<PPB_ContentDecryptor_Private>()->DeliverBlock( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 const PP_DecryptedSampleInfo& decrypted_sample_info) { | 319 const PP_DecryptedSampleInfo& decrypted_sample_info) { |
| 319 if (has_interface<PPB_ContentDecryptor_Private>()) { | 320 if (has_interface<PPB_ContentDecryptor_Private>()) { |
| 320 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( | 321 get_interface<PPB_ContentDecryptor_Private>()->DeliverSamples( |
| 321 associated_instance_.pp_instance(), | 322 associated_instance_.pp_instance(), |
| 322 audio_frames.pp_resource(), | 323 audio_frames.pp_resource(), |
| 323 &decrypted_sample_info); | 324 &decrypted_sample_info); |
| 324 } | 325 } |
| 325 } | 326 } |
| 326 | 327 |
| 327 } // namespace pp | 328 } // namespace pp |
| OLD | NEW |