Chromium Code Reviews| Index: ppapi/proxy/ppp_content_decryptor_private_proxy.cc |
| diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc |
| index 91d81154a4658efd8ce0901ac3c3f1e6683a7ff6..f17dcc281a1b5a067eaf47d0bf155cd8c144f574 100644 |
| --- a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc |
| +++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc |
| @@ -91,6 +91,37 @@ PP_Bool AddRefResourceForPlugin(HostDispatcher* dispatcher, |
| return PP_TRUE; |
| } |
| +bool InitializePppDecryptorBuffer(PP_Instance instance, |
| + HostDispatcher* dispatcher, |
| + PP_Resource resource, |
| + PPPDecryptor_Buffer* buffer) { |
| + if (!buffer) { |
| + NOTREACHED(); |
| + return false; |
| + } |
| + |
| + if (!AddRefResourceForPlugin(dispatcher, resource)) |
| + return false; |
| + |
| + HostResource host_resource; |
| + host_resource.SetHostResource(instance, resource); |
| + |
| + uint32_t size = 0; |
| + if (DescribeHostBufferResource(resource, &size) == PP_FALSE) |
| + return false; |
| + |
| + base::SharedMemoryHandle handle; |
| + if (ShareHostBufferResourceToPlugin(dispatcher, |
| + resource, |
| + &handle) == PP_FALSE) |
| + return false; |
|
xhwang
2012/10/08 17:16:13
wrap this w/ braces since the "if" spans multiple
Tom Finegan
2012/10/08 23:23:27
dmichael@ said not to do that in here in a previou
|
| + |
| + buffer->resource = host_resource; |
| + buffer->handle = handle; |
| + buffer->size = size; |
| + return true; |
| +} |
| + |
| void GenerateKeyRequest(PP_Instance instance, |
| PP_Var key_system, |
| PP_Var init_data) { |
| @@ -150,32 +181,20 @@ void Decrypt(PP_Instance instance, |
| return; |
| } |
| - if (!AddRefResourceForPlugin(dispatcher, encrypted_block)) { |
| + PPPDecryptor_Buffer buffer; |
| + if (!InitializePppDecryptorBuffer(instance, |
| + dispatcher, |
| + encrypted_block, |
| + &buffer)) { |
| NOTREACHED(); |
| return; |
| } |
| - HostResource host_resource; |
| - host_resource.SetHostResource(instance, encrypted_block); |
| - |
| - uint32_t size = 0; |
| - if (DescribeHostBufferResource(encrypted_block, &size) == PP_FALSE) |
| - return; |
| - |
| - base::SharedMemoryHandle handle; |
| - if (ShareHostBufferResourceToPlugin(dispatcher, |
| - encrypted_block, |
| - &handle) == PP_FALSE) |
| - return; |
| - |
| - PPPDecryptor_Buffer buffer; |
| - buffer.resource = host_resource; |
| - buffer.handle = handle; |
| - buffer.size = size; |
| - |
| std::string serialized_block_info; |
| - if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) |
| + if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) { |
| + NOTREACHED(); |
| return; |
| + } |
| dispatcher->Send( |
| new PpapiMsg_PPPContentDecryptor_Decrypt( |
| @@ -185,42 +204,65 @@ void Decrypt(PP_Instance instance, |
| serialized_block_info)); |
| } |
| -void DecryptAndDecodeFrame( |
| +void InitializeVideoDecoder( |
| PP_Instance instance, |
| - PP_Resource encrypted_frame, |
| - const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { |
| + const PP_VideoDecoderConfig* decoder_config, |
| + PP_Resource extra_data_buffer) { |
| HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| if (!dispatcher) { |
| NOTREACHED(); |
| return; |
| } |
| - if (!AddRefResourceForPlugin(dispatcher, encrypted_frame)) { |
| + std::string serialized_decoder_config; |
| + if (!SerializeBlockInfo(*decoder_config, &serialized_decoder_config)) { |
| NOTREACHED(); |
| return; |
| } |
| - HostResource host_resource; |
| - host_resource.SetHostResource(instance, encrypted_frame); |
| - |
| - uint32_t size = 0; |
| - if (DescribeHostBufferResource(encrypted_frame, &size) == PP_FALSE) |
| + PPPDecryptor_Buffer buffer; |
| + if (!InitializePppDecryptorBuffer(instance, |
| + dispatcher, |
| + extra_data_buffer, |
| + &buffer)) { |
| + NOTREACHED(); |
| return; |
| + } |
| - base::SharedMemoryHandle handle; |
| - if (ShareHostBufferResourceToPlugin(dispatcher, |
| - encrypted_frame, |
| - &handle) == PP_FALSE) |
| + dispatcher->Send( |
| + new PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder( |
| + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| + instance, |
| + serialized_decoder_config, |
| + buffer)); |
| +} |
| + |
| + |
| +void DecryptAndDecodeFrame( |
| + PP_Instance instance, |
| + PP_Resource encrypted_frame, |
| + const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { |
| + HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| + if (!dispatcher) { |
| + NOTREACHED(); |
| return; |
| + } |
| PPPDecryptor_Buffer buffer; |
| - buffer.resource = host_resource; |
| - buffer.handle = handle; |
| - buffer.size = size; |
| + if (!InitializePppDecryptorBuffer(instance, |
| + dispatcher, |
| + encrypted_frame, |
| + &buffer)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| std::string serialized_frame_info; |
| - if (!SerializeBlockInfo(*encrypted_video_frame_info, &serialized_frame_info)) |
| + if (!SerializeBlockInfo(*encrypted_video_frame_info, |
| + &serialized_frame_info)) { |
| + NOTREACHED(); |
| return; |
| + } |
| dispatcher->Send( |
| new PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame( |
| @@ -235,6 +277,7 @@ static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
| &AddKey, |
| &CancelKeyRequest, |
| &Decrypt, |
| + &InitializeVideoDecoder, |
| &DecryptAndDecodeFrame |
| }; |
| @@ -335,6 +378,34 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgDecrypt( |
| } |
| } |
| +void PPP_ContentDecryptor_Private_Proxy::OnMsgInitializeVideoDecoder( |
| + PP_Instance instance, |
| + const std::string& serialized_decoder_config, |
| + const PPPDecryptor_Buffer& extra_data_buffer) { |
| + |
| + PP_VideoDecoderConfig decoder_config; |
| + if (!DeserializeBlockInfo(serialized_decoder_config, &decoder_config)) |
| + return; |
| + |
| + if (ppp_decryptor_impl_) { |
| + PP_Resource plugin_resource = 0; |
| + if (extra_data_buffer.size > 0) { |
| + plugin_resource = |
| + PPB_Buffer_Proxy::AddProxyResource(extra_data_buffer.resource, |
| + extra_data_buffer.handle, |
| + extra_data_buffer.size); |
| + } |
| + |
|
xhwang
2012/10/08 17:16:13
remove extra empty lines
Tom Finegan
2012/10/08 23:23:27
Done.
|
| + |
| + |
| + CallWhileUnlocked( |
| + ppp_decryptor_impl_->InitializeVideoDecoder, |
| + instance, |
| + const_cast<const PP_VideoDecoderConfig*>(&decoder_config), |
| + plugin_resource); |
| + } |
| +} |
| + |
| void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( |
| PP_Instance instance, |
| const PPPDecryptor_Buffer& encrypted_frame, |