| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 dispatcher->Send( | 180 dispatcher->Send( |
| 181 new PpapiMsg_PPPContentDecryptor_Decrypt( | 181 new PpapiMsg_PPPContentDecryptor_Decrypt( |
| 182 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 182 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 183 instance, | 183 instance, |
| 184 buffer, | 184 buffer, |
| 185 serialized_block_info)); | 185 serialized_block_info)); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void DecryptAndDecode(PP_Instance instance, | 188 void DecryptAndDecodeFrame( |
| 189 PP_Resource encrypted_block, | 189 PP_Instance instance, |
| 190 const PP_EncryptedBlockInfo* encrypted_block_info) { | 190 PP_Resource encrypted_frame, |
| 191 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { |
| 191 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 192 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 192 if (!dispatcher) { | 193 if (!dispatcher) { |
| 193 NOTREACHED(); | 194 NOTREACHED(); |
| 194 return; | 195 return; |
| 195 } | 196 } |
| 196 | 197 |
| 197 if (!AddRefResourceForPlugin(dispatcher, encrypted_block)) { | 198 if (!AddRefResourceForPlugin(dispatcher, encrypted_frame)) { |
| 198 NOTREACHED(); | 199 NOTREACHED(); |
| 199 return; | 200 return; |
| 200 } | 201 } |
| 201 | 202 |
| 202 HostResource host_resource; | 203 HostResource host_resource; |
| 203 host_resource.SetHostResource(instance, encrypted_block); | 204 host_resource.SetHostResource(instance, encrypted_frame); |
| 204 | 205 |
| 205 uint32_t size = 0; | 206 uint32_t size = 0; |
| 206 if (DescribeHostBufferResource(encrypted_block, &size) == PP_FALSE) | 207 if (DescribeHostBufferResource(encrypted_frame, &size) == PP_FALSE) |
| 207 return; | 208 return; |
| 208 | 209 |
| 209 base::SharedMemoryHandle handle; | 210 base::SharedMemoryHandle handle; |
| 210 if (ShareHostBufferResourceToPlugin(dispatcher, | 211 if (ShareHostBufferResourceToPlugin(dispatcher, |
| 211 encrypted_block, | 212 encrypted_frame, |
| 212 &handle) == PP_FALSE) | 213 &handle) == PP_FALSE) |
| 213 return; | 214 return; |
| 214 | 215 |
| 215 PPPDecryptor_Buffer buffer; | 216 PPPDecryptor_Buffer buffer; |
| 216 buffer.resource = host_resource; | 217 buffer.resource = host_resource; |
| 217 buffer.handle = handle; | 218 buffer.handle = handle; |
| 218 buffer.size = size; | 219 buffer.size = size; |
| 219 | 220 |
| 220 std::string serialized_block_info; | 221 std::string serialized_frame_info; |
| 221 if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) | 222 if (!SerializeBlockInfo(*encrypted_video_frame_info, &serialized_frame_info)) |
| 222 return; | 223 return; |
| 223 | 224 |
| 224 dispatcher->Send( | 225 dispatcher->Send( |
| 225 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( | 226 new PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame( |
| 226 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 227 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 227 instance, | 228 instance, |
| 228 buffer, | 229 buffer, |
| 229 serialized_block_info)); | 230 serialized_frame_info)); |
| 230 } | 231 } |
| 231 | 232 |
| 232 static const PPP_ContentDecryptor_Private content_decryptor_interface = { | 233 static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
| 233 &GenerateKeyRequest, | 234 &GenerateKeyRequest, |
| 234 &AddKey, | 235 &AddKey, |
| 235 &CancelKeyRequest, | 236 &CancelKeyRequest, |
| 236 &Decrypt, | 237 &Decrypt, |
| 237 &DecryptAndDecode | 238 &DecryptAndDecodeFrame |
| 238 }; | 239 }; |
| 239 | 240 |
| 240 } // namespace | 241 } // namespace |
| 241 | 242 |
| 242 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( | 243 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( |
| 243 Dispatcher* dispatcher) | 244 Dispatcher* dispatcher) |
| 244 : InterfaceProxy(dispatcher), | 245 : InterfaceProxy(dispatcher), |
| 245 ppp_decryptor_impl_(NULL) { | 246 ppp_decryptor_impl_(NULL) { |
| 246 if (dispatcher->IsPlugin()) { | 247 if (dispatcher->IsPlugin()) { |
| 247 ppp_decryptor_impl_ = static_cast<const PPP_ContentDecryptor_Private*>( | 248 ppp_decryptor_impl_ = static_cast<const PPP_ContentDecryptor_Private*>( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 264 bool handled = true; | 265 bool handled = true; |
| 265 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) | 266 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) |
| 266 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, | 267 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, |
| 267 OnMsgGenerateKeyRequest) | 268 OnMsgGenerateKeyRequest) |
| 268 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, | 269 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, |
| 269 OnMsgAddKey) | 270 OnMsgAddKey) |
| 270 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, | 271 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, |
| 271 OnMsgCancelKeyRequest) | 272 OnMsgCancelKeyRequest) |
| 272 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, | 273 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
| 273 OnMsgDecrypt) | 274 OnMsgDecrypt) |
| 274 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, | 275 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, |
| 275 OnMsgDecryptAndDecode) | 276 OnMsgDecryptAndDecodeFrame) |
| 276 IPC_MESSAGE_UNHANDLED(handled = false) | 277 IPC_MESSAGE_UNHANDLED(handled = false) |
| 277 IPC_END_MESSAGE_MAP() | 278 IPC_END_MESSAGE_MAP() |
| 278 DCHECK(handled); | 279 DCHECK(handled); |
| 279 return handled; | 280 return handled; |
| 280 } | 281 } |
| 281 | 282 |
| 282 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( | 283 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( |
| 283 PP_Instance instance, | 284 PP_Instance instance, |
| 284 SerializedVarReceiveInput key_system, | 285 SerializedVarReceiveInput key_system, |
| 285 SerializedVarReceiveInput init_data) { | 286 SerializedVarReceiveInput init_data) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 PP_EncryptedBlockInfo block_info; | 328 PP_EncryptedBlockInfo block_info; |
| 328 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) | 329 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) |
| 329 return; | 330 return; |
| 330 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, | 331 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, |
| 331 instance, | 332 instance, |
| 332 plugin_resource, | 333 plugin_resource, |
| 333 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); | 334 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); |
| 334 } | 335 } |
| 335 } | 336 } |
| 336 | 337 |
| 337 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecode( | 338 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( |
| 338 PP_Instance instance, | 339 PP_Instance instance, |
| 339 const PPPDecryptor_Buffer& encrypted_buffer, | 340 const PPPDecryptor_Buffer& encrypted_frame, |
| 340 const std::string& serialized_block_info) { | 341 const std::string& serialized_frame_info) { |
| 341 if (ppp_decryptor_impl_) { | 342 if (ppp_decryptor_impl_) { |
| 342 PP_Resource plugin_resource = | 343 PP_Resource plugin_resource = |
| 343 PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, | 344 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, |
| 344 encrypted_buffer.handle, | 345 encrypted_frame.handle, |
| 345 encrypted_buffer.size); | 346 encrypted_frame.size); |
| 346 PP_EncryptedBlockInfo block_info; | 347 PP_EncryptedVideoFrameInfo frame_info; |
| 347 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) | 348 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) |
| 348 return; | 349 return; |
| 349 CallWhileUnlocked(ppp_decryptor_impl_->DecryptAndDecode, | 350 CallWhileUnlocked( |
| 350 instance, | 351 ppp_decryptor_impl_->DecryptAndDecodeFrame, |
| 351 plugin_resource, | 352 instance, |
| 352 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); | 353 plugin_resource, |
| 354 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); |
| 353 } | 355 } |
| 354 } | 356 } |
| 355 | 357 |
| 356 } // namespace proxy | 358 } // namespace proxy |
| 357 } // namespace ppapi | 359 } // namespace ppapi |
| OLD | NEW |