| 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/proxy/ppp_content_decryptor_private_proxy.h" | 5 #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h" |
| 6 | 6 |
| 7 #include "base/platform_file.h" | 7 #include "base/platform_file.h" |
| 8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/ppb_core.h" | 9 #include "ppapi/c/ppb_core.h" |
| 10 #include "ppapi/proxy/content_decryptor_private_serializer.h" | 10 #include "ppapi/proxy/content_decryptor_private_serializer.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 265 } |
| 266 | 266 |
| 267 dispatcher->Send( | 267 dispatcher->Send( |
| 268 new PpapiMsg_PPPContentDecryptor_ResetDecoder( | 268 new PpapiMsg_PPPContentDecryptor_ResetDecoder( |
| 269 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 269 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 270 instance, | 270 instance, |
| 271 decoder_type, | 271 decoder_type, |
| 272 request_id)); | 272 request_id)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void DecryptAndDecodeFrame( | 275 void DecryptAndDecode(PP_Instance instance, |
| 276 PP_Instance instance, | 276 PP_DecryptorStreamType decoder_type, |
| 277 PP_Resource encrypted_frame, | 277 PP_Resource encrypted_buffer, |
| 278 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { | 278 const PP_EncryptedBlockInfo* encrypted_block_info) { |
| 279 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 279 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 280 if (!dispatcher) { | 280 if (!dispatcher) { |
| 281 NOTREACHED(); | 281 NOTREACHED(); |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 | 284 |
| 285 PPPDecryptor_Buffer buffer; | 285 PPPDecryptor_Buffer buffer; |
| 286 if (!InitializePppDecryptorBuffer(instance, | 286 if (!InitializePppDecryptorBuffer(instance, |
| 287 dispatcher, | 287 dispatcher, |
| 288 encrypted_frame, | 288 encrypted_buffer, |
| 289 &buffer)) { | 289 &buffer)) { |
| 290 NOTREACHED(); | 290 NOTREACHED(); |
| 291 return; | 291 return; |
| 292 } | 292 } |
| 293 | 293 |
| 294 std::string serialized_frame_info; | 294 std::string serialized_block_info; |
| 295 if (!SerializeBlockInfo(*encrypted_video_frame_info, | 295 if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) { |
| 296 &serialized_frame_info)) { | |
| 297 NOTREACHED(); | 296 NOTREACHED(); |
| 298 return; | 297 return; |
| 299 } | 298 } |
| 300 | 299 |
| 301 dispatcher->Send( | 300 dispatcher->Send( |
| 302 new PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame( | 301 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( |
| 303 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 302 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 304 instance, | 303 instance, |
| 304 decoder_type, |
| 305 buffer, | 305 buffer, |
| 306 serialized_frame_info)); | 306 serialized_block_info)); |
| 307 } | 307 } |
| 308 | 308 |
| 309 static const PPP_ContentDecryptor_Private content_decryptor_interface = { | 309 static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
| 310 &GenerateKeyRequest, | 310 &GenerateKeyRequest, |
| 311 &AddKey, | 311 &AddKey, |
| 312 &CancelKeyRequest, | 312 &CancelKeyRequest, |
| 313 &Decrypt, | 313 &Decrypt, |
| 314 &InitializeVideoDecoder, | 314 &InitializeVideoDecoder, |
| 315 &DeinitializeDecoder, | 315 &DeinitializeDecoder, |
| 316 &ResetDecoder, | 316 &ResetDecoder, |
| 317 &DecryptAndDecodeFrame | 317 &DecryptAndDecode |
| 318 }; | 318 }; |
| 319 | 319 |
| 320 } // namespace | 320 } // namespace |
| 321 | 321 |
| 322 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( | 322 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( |
| 323 Dispatcher* dispatcher) | 323 Dispatcher* dispatcher) |
| 324 : InterfaceProxy(dispatcher), | 324 : InterfaceProxy(dispatcher), |
| 325 ppp_decryptor_impl_(NULL) { | 325 ppp_decryptor_impl_(NULL) { |
| 326 if (dispatcher->IsPlugin()) { | 326 if (dispatcher->IsPlugin()) { |
| 327 ppp_decryptor_impl_ = static_cast<const PPP_ContentDecryptor_Private*>( | 327 ppp_decryptor_impl_ = static_cast<const PPP_ContentDecryptor_Private*>( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 350 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, | 350 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, |
| 351 OnMsgCancelKeyRequest) | 351 OnMsgCancelKeyRequest) |
| 352 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, | 352 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
| 353 OnMsgDecrypt) | 353 OnMsgDecrypt) |
| 354 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, | 354 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, |
| 355 OnMsgInitializeVideoDecoder) | 355 OnMsgInitializeVideoDecoder) |
| 356 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, | 356 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, |
| 357 OnMsgDeinitializeDecoder) | 357 OnMsgDeinitializeDecoder) |
| 358 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, | 358 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, |
| 359 OnMsgResetDecoder) | 359 OnMsgResetDecoder) |
| 360 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, | 360 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, |
| 361 OnMsgDecryptAndDecodeFrame) | 361 OnMsgDecryptAndDecode) |
| 362 IPC_MESSAGE_UNHANDLED(handled = false) | 362 IPC_MESSAGE_UNHANDLED(handled = false) |
| 363 IPC_END_MESSAGE_MAP() | 363 IPC_END_MESSAGE_MAP() |
| 364 DCHECK(handled); | 364 DCHECK(handled); |
| 365 return handled; | 365 return handled; |
| 366 } | 366 } |
| 367 | 367 |
| 368 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( | 368 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( |
| 369 PP_Instance instance, | 369 PP_Instance instance, |
| 370 SerializedVarReceiveInput key_system, | 370 SerializedVarReceiveInput key_system, |
| 371 SerializedVarReceiveInput init_data) { | 371 SerializedVarReceiveInput init_data) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 uint32_t request_id) { | 465 uint32_t request_id) { |
| 466 if (ppp_decryptor_impl_) { | 466 if (ppp_decryptor_impl_) { |
| 467 CallWhileUnlocked( | 467 CallWhileUnlocked( |
| 468 ppp_decryptor_impl_->ResetDecoder, | 468 ppp_decryptor_impl_->ResetDecoder, |
| 469 instance, | 469 instance, |
| 470 decoder_type, | 470 decoder_type, |
| 471 request_id); | 471 request_id); |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 | 474 |
| 475 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( | 475 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecode( |
| 476 PP_Instance instance, | 476 PP_Instance instance, |
| 477 const PPPDecryptor_Buffer& encrypted_frame, | 477 PP_DecryptorStreamType decoder_type, |
| 478 const std::string& serialized_frame_info) { | 478 const PPPDecryptor_Buffer& encrypted_buffer, |
| 479 const std::string& serialized_block_info) { |
| 479 if (ppp_decryptor_impl_) { | 480 if (ppp_decryptor_impl_) { |
| 480 PP_Resource plugin_resource = | 481 PP_Resource plugin_resource = |
| 481 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, | 482 PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, |
| 482 encrypted_frame.handle, | 483 encrypted_buffer.handle, |
| 483 encrypted_frame.size); | 484 encrypted_buffer.size); |
| 484 PP_EncryptedVideoFrameInfo frame_info; | 485 PP_EncryptedBlockInfo block_info; |
| 485 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) | 486 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) |
| 486 return; | 487 return; |
| 487 CallWhileUnlocked( | 488 CallWhileUnlocked( |
| 488 ppp_decryptor_impl_->DecryptAndDecodeFrame, | 489 ppp_decryptor_impl_->DecryptAndDecode, |
| 489 instance, | 490 instance, |
| 491 decoder_type, |
| 490 plugin_resource, | 492 plugin_resource, |
| 491 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); | 493 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
| 492 } | 494 } |
| 493 } | 495 } |
| 494 | 496 |
| 495 } // namespace proxy | 497 } // namespace proxy |
| 496 } // namespace ppapi | 498 } // namespace ppapi |
| OLD | NEW |