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