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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 dispatcher->Send( | 232 dispatcher->Send( |
233 new PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder( | 233 new PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder( |
234 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, | 234 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
235 instance, | 235 instance, |
236 serialized_decoder_config, | 236 serialized_decoder_config, |
237 buffer)); | 237 buffer)); |
238 } | 238 } |
239 | 239 |
240 | 240 |
| 241 void DeinitializeDecoder(PP_Instance instance, |
| 242 PP_DecryptorStreamType decoder_type, |
| 243 uint32_t request_id) { |
| 244 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 245 if (!dispatcher) { |
| 246 NOTREACHED(); |
| 247 return; |
| 248 } |
| 249 |
| 250 dispatcher->Send( |
| 251 new PpapiMsg_PPPContentDecryptor_DeinitializeDecoder( |
| 252 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 253 instance, |
| 254 decoder_type, |
| 255 request_id)); |
| 256 } |
| 257 |
| 258 void ResetDecoder(PP_Instance instance, |
| 259 PP_DecryptorStreamType decoder_type, |
| 260 uint32_t request_id) { |
| 261 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
| 262 if (!dispatcher) { |
| 263 NOTREACHED(); |
| 264 return; |
| 265 } |
| 266 |
| 267 dispatcher->Send( |
| 268 new PpapiMsg_PPPContentDecryptor_ResetDecoder( |
| 269 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, |
| 270 instance, |
| 271 decoder_type, |
| 272 request_id)); |
| 273 } |
| 274 |
241 void DecryptAndDecodeFrame( | 275 void DecryptAndDecodeFrame( |
242 PP_Instance instance, | 276 PP_Instance instance, |
243 PP_Resource encrypted_frame, | 277 PP_Resource encrypted_frame, |
244 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { | 278 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { |
245 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); | 279 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); |
246 if (!dispatcher) { | 280 if (!dispatcher) { |
247 NOTREACHED(); | 281 NOTREACHED(); |
248 return; | 282 return; |
249 } | 283 } |
250 | 284 |
(...skipping 20 matching lines...) Expand all Loading... |
271 buffer, | 305 buffer, |
272 serialized_frame_info)); | 306 serialized_frame_info)); |
273 } | 307 } |
274 | 308 |
275 static const PPP_ContentDecryptor_Private content_decryptor_interface = { | 309 static const PPP_ContentDecryptor_Private content_decryptor_interface = { |
276 &GenerateKeyRequest, | 310 &GenerateKeyRequest, |
277 &AddKey, | 311 &AddKey, |
278 &CancelKeyRequest, | 312 &CancelKeyRequest, |
279 &Decrypt, | 313 &Decrypt, |
280 &InitializeVideoDecoder, | 314 &InitializeVideoDecoder, |
| 315 &DeinitializeDecoder, |
| 316 &ResetDecoder, |
281 &DecryptAndDecodeFrame | 317 &DecryptAndDecodeFrame |
282 }; | 318 }; |
283 | 319 |
284 } // namespace | 320 } // namespace |
285 | 321 |
286 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( | 322 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( |
287 Dispatcher* dispatcher) | 323 Dispatcher* dispatcher) |
288 : InterfaceProxy(dispatcher), | 324 : InterfaceProxy(dispatcher), |
289 ppp_decryptor_impl_(NULL) { | 325 ppp_decryptor_impl_(NULL) { |
290 if (dispatcher->IsPlugin()) { | 326 if (dispatcher->IsPlugin()) { |
(...skipping 19 matching lines...) Expand all Loading... |
310 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, | 346 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, |
311 OnMsgGenerateKeyRequest) | 347 OnMsgGenerateKeyRequest) |
312 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, | 348 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, |
313 OnMsgAddKey) | 349 OnMsgAddKey) |
314 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, | 350 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, |
315 OnMsgCancelKeyRequest) | 351 OnMsgCancelKeyRequest) |
316 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, | 352 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, |
317 OnMsgDecrypt) | 353 OnMsgDecrypt) |
318 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, | 354 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeVideoDecoder, |
319 OnMsgInitializeVideoDecoder) | 355 OnMsgInitializeVideoDecoder) |
| 356 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DeinitializeDecoder, |
| 357 OnMsgDeinitializeDecoder) |
| 358 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetDecoder, |
| 359 OnMsgResetDecoder) |
320 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, | 360 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, |
321 OnMsgDecryptAndDecodeFrame) | 361 OnMsgDecryptAndDecodeFrame) |
322 IPC_MESSAGE_UNHANDLED(handled = false) | 362 IPC_MESSAGE_UNHANDLED(handled = false) |
323 IPC_END_MESSAGE_MAP() | 363 IPC_END_MESSAGE_MAP() |
324 DCHECK(handled); | 364 DCHECK(handled); |
325 return handled; | 365 return handled; |
326 } | 366 } |
327 | 367 |
328 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( | 368 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( |
329 PP_Instance instance, | 369 PP_Instance instance, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 439 } |
400 | 440 |
401 CallWhileUnlocked( | 441 CallWhileUnlocked( |
402 ppp_decryptor_impl_->InitializeVideoDecoder, | 442 ppp_decryptor_impl_->InitializeVideoDecoder, |
403 instance, | 443 instance, |
404 const_cast<const PP_VideoDecoderConfig*>(&decoder_config), | 444 const_cast<const PP_VideoDecoderConfig*>(&decoder_config), |
405 plugin_resource); | 445 plugin_resource); |
406 } | 446 } |
407 } | 447 } |
408 | 448 |
| 449 void PPP_ContentDecryptor_Private_Proxy::OnMsgDeinitializeDecoder( |
| 450 PP_Instance instance, |
| 451 PP_DecryptorStreamType decoder_type, |
| 452 uint32_t request_id) { |
| 453 if (ppp_decryptor_impl_) { |
| 454 CallWhileUnlocked( |
| 455 ppp_decryptor_impl_->DeinitializeDecoder, |
| 456 instance, |
| 457 decoder_type, |
| 458 request_id); |
| 459 } |
| 460 } |
| 461 |
| 462 void PPP_ContentDecryptor_Private_Proxy::OnMsgResetDecoder( |
| 463 PP_Instance instance, |
| 464 PP_DecryptorStreamType decoder_type, |
| 465 uint32_t request_id) { |
| 466 if (ppp_decryptor_impl_) { |
| 467 CallWhileUnlocked( |
| 468 ppp_decryptor_impl_->ResetDecoder, |
| 469 instance, |
| 470 decoder_type, |
| 471 request_id); |
| 472 } |
| 473 } |
| 474 |
409 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( | 475 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( |
410 PP_Instance instance, | 476 PP_Instance instance, |
411 const PPPDecryptor_Buffer& encrypted_frame, | 477 const PPPDecryptor_Buffer& encrypted_frame, |
412 const std::string& serialized_frame_info) { | 478 const std::string& serialized_frame_info) { |
413 if (ppp_decryptor_impl_) { | 479 if (ppp_decryptor_impl_) { |
414 PP_Resource plugin_resource = | 480 PP_Resource plugin_resource = |
415 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, | 481 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, |
416 encrypted_frame.handle, | 482 encrypted_frame.handle, |
417 encrypted_frame.size); | 483 encrypted_frame.size); |
418 PP_EncryptedVideoFrameInfo frame_info; | 484 PP_EncryptedVideoFrameInfo frame_info; |
419 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) | 485 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) |
420 return; | 486 return; |
421 CallWhileUnlocked( | 487 CallWhileUnlocked( |
422 ppp_decryptor_impl_->DecryptAndDecodeFrame, | 488 ppp_decryptor_impl_->DecryptAndDecodeFrame, |
423 instance, | 489 instance, |
424 plugin_resource, | 490 plugin_resource, |
425 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); | 491 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); |
426 } | 492 } |
427 } | 493 } |
428 | 494 |
429 } // namespace proxy | 495 } // namespace proxy |
430 } // namespace ppapi | 496 } // namespace ppapi |
OLD | NEW |