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 <cstring> | 5 #include <cstring> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // PPB_ContentDecryptor_Private interface. | 371 // PPB_ContentDecryptor_Private interface. |
372 virtual void GenerateKeyRequest(const std::string& key_system, | 372 virtual void GenerateKeyRequest(const std::string& key_system, |
373 pp::VarArrayBuffer init_data) OVERRIDE; | 373 pp::VarArrayBuffer init_data) OVERRIDE; |
374 virtual void AddKey(const std::string& session_id, | 374 virtual void AddKey(const std::string& session_id, |
375 pp::VarArrayBuffer key, | 375 pp::VarArrayBuffer key, |
376 pp::VarArrayBuffer init_data) OVERRIDE; | 376 pp::VarArrayBuffer init_data) OVERRIDE; |
377 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; | 377 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; |
378 virtual void Decrypt( | 378 virtual void Decrypt( |
379 pp::Buffer_Dev encrypted_buffer, | 379 pp::Buffer_Dev encrypted_buffer, |
380 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 380 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 381 virtual void DeinitializeDecoder(PP_StreamType decoder_type, |
| 382 uint32_t request_id) OVERRIDE; |
| 383 virtual void ResetDecoder(PP_StreamType decoder_type, |
| 384 uint32_t request_id) OVERRIDE; |
381 virtual void DecryptAndDecodeFrame( | 385 virtual void DecryptAndDecodeFrame( |
382 pp::Buffer_Dev encrypted_frame, | 386 pp::Buffer_Dev encrypted_frame, |
383 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; | 387 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; |
384 | 388 |
385 private: | 389 private: |
386 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 390 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
387 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; | 391 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; |
388 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 392 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
389 | 393 |
390 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 394 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
391 // <code>callback_factory_</code> to ensure that calls into | 395 // <code>callback_factory_</code> to ensure that calls into |
392 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 396 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
393 void KeyAdded(int32_t result, const std::string& session_id); | 397 void KeyAdded(int32_t result, const std::string& session_id); |
394 void KeyMessage(int32_t result, const LinkedKeyMessage& message); | 398 void KeyMessage(int32_t result, const LinkedKeyMessage& message); |
395 void KeyError(int32_t result, const std::string& session_id); | 399 void KeyError(int32_t result, const std::string& session_id); |
396 void DeliverBlock(int32_t result, | 400 void DeliverBlock(int32_t result, |
397 const cdm::Status& status, | 401 const cdm::Status& status, |
398 const LinkedDecryptedBlock& decrypted_block, | 402 const LinkedDecryptedBlock& decrypted_block, |
399 const PP_DecryptTrackingInfo& tracking_info); | 403 const PP_DecryptTrackingInfo& tracking_info); |
| 404 void DecoderDeinitializeDone(int32_t result, |
| 405 PP_StreamType decoder_type, |
| 406 uint32_t request_id); |
| 407 void DecoderResetDone(int32_t result, |
| 408 PP_StreamType decoder_type, |
| 409 uint32_t request_id); |
400 void DeliverFrame(int32_t result, | 410 void DeliverFrame(int32_t result, |
401 const cdm::Status& status, | 411 const cdm::Status& status, |
402 const LinkedVideoFrame& video_frame, | 412 const LinkedVideoFrame& video_frame, |
403 const PP_DecryptTrackingInfo& tracking_info); | 413 const PP_DecryptTrackingInfo& tracking_info); |
404 | 414 |
405 PpbBufferAllocator allocator_; | 415 PpbBufferAllocator allocator_; |
406 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; | 416 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; |
407 cdm::ContentDecryptionModule* cdm_; | 417 cdm::ContentDecryptionModule* cdm_; |
408 std::string key_system_; | 418 std::string key_system_; |
409 }; | 419 }; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); | 533 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); |
524 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); | 534 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); |
525 | 535 |
526 CallOnMain(callback_factory_.NewCallback( | 536 CallOnMain(callback_factory_.NewCallback( |
527 &CdmWrapper::DeliverBlock, | 537 &CdmWrapper::DeliverBlock, |
528 status, | 538 status, |
529 decrypted_block, | 539 decrypted_block, |
530 encrypted_block_info.tracking_info)); | 540 encrypted_block_info.tracking_info)); |
531 } | 541 } |
532 | 542 |
| 543 void CdmWrapper::DeinitializeDecoder(PP_StreamType decoder_type, |
| 544 uint32_t request_id) { |
| 545 // TODO(tomfinegan): Implement DeinitializeDecoder in clear key CDM, and call |
| 546 // it here. |
| 547 CallOnMain(callback_factory_.NewCallback( |
| 548 &CdmWrapper::DecoderDeinitializeDone, |
| 549 decoder_type, |
| 550 request_id)); |
| 551 } |
| 552 |
| 553 void CdmWrapper::ResetDecoder(PP_StreamType decoder_type, |
| 554 uint32_t request_id) { |
| 555 // TODO(tomfinegan): Implement ResetDecoder in clear key CDM, and call it |
| 556 // here. |
| 557 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone, |
| 558 decoder_type, |
| 559 request_id)); |
| 560 } |
| 561 |
533 void CdmWrapper::DecryptAndDecodeFrame( | 562 void CdmWrapper::DecryptAndDecodeFrame( |
534 pp::Buffer_Dev encrypted_frame, | 563 pp::Buffer_Dev encrypted_frame, |
535 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { | 564 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { |
536 PP_DCHECK(!encrypted_frame.is_null()); | 565 PP_DCHECK(!encrypted_frame.is_null()); |
537 PP_DCHECK(cdm_); | 566 PP_DCHECK(cdm_); |
538 | 567 |
539 cdm::InputBuffer input_buffer; | 568 cdm::InputBuffer input_buffer; |
540 std::vector<cdm::SubsampleEntry> subsamples; | 569 std::vector<cdm::SubsampleEntry> subsamples; |
541 ConfigureInputBuffer(encrypted_frame, | 570 ConfigureInputBuffer(encrypted_frame, |
542 encrypted_video_frame_info.encryption_info, | 571 encrypted_video_frame_info.encryption_info, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 629 } |
601 | 630 |
602 const pp::Buffer_Dev& buffer = | 631 const pp::Buffer_Dev& buffer = |
603 decrypted_block.get() && decrypted_block->buffer() ? | 632 decrypted_block.get() && decrypted_block->buffer() ? |
604 static_cast<PpbBuffer*>(decrypted_block->buffer())->buffer_dev() : | 633 static_cast<PpbBuffer*>(decrypted_block->buffer())->buffer_dev() : |
605 pp::Buffer_Dev(); | 634 pp::Buffer_Dev(); |
606 | 635 |
607 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); | 636 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); |
608 } | 637 } |
609 | 638 |
| 639 void CdmWrapper::DecoderDeinitializeDone(int32_t result, |
| 640 PP_StreamType decoder_type, |
| 641 uint32_t request_id) { |
| 642 pp::ContentDecryptor_Private::DecoderDeinitializeDone(decoder_type, |
| 643 request_id); |
| 644 } |
| 645 |
| 646 void CdmWrapper::DecoderResetDone(int32_t result, |
| 647 PP_StreamType decoder_type, |
| 648 uint32_t request_id) { |
| 649 pp::ContentDecryptor_Private::DecoderResetDone(decoder_type, request_id); |
| 650 } |
| 651 |
610 void CdmWrapper::DeliverFrame( | 652 void CdmWrapper::DeliverFrame( |
611 int32_t result, | 653 int32_t result, |
612 const cdm::Status& status, | 654 const cdm::Status& status, |
613 const LinkedVideoFrame& video_frame, | 655 const LinkedVideoFrame& video_frame, |
614 const PP_DecryptTrackingInfo& tracking_info) { | 656 const PP_DecryptTrackingInfo& tracking_info) { |
615 PP_DecryptedFrameInfo decrypted_frame_info; | 657 PP_DecryptedFrameInfo decrypted_frame_info; |
616 decrypted_frame_info.tracking_info = tracking_info; | 658 decrypted_frame_info.tracking_info = tracking_info; |
617 | 659 |
618 switch (status) { | 660 switch (status) { |
619 case cdm::kSuccess: | 661 case cdm::kSuccess: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 } // namespace webkit_media | 717 } // namespace webkit_media |
676 | 718 |
677 namespace pp { | 719 namespace pp { |
678 | 720 |
679 // Factory function for your specialization of the Module object. | 721 // Factory function for your specialization of the Module object. |
680 Module* CreateModule() { | 722 Module* CreateModule() { |
681 return new webkit_media::CdmWrapperModule(); | 723 return new webkit_media::CdmWrapperModule(); |
682 } | 724 } |
683 | 725 |
684 } // namespace pp | 726 } // namespace pp |
OLD | NEW |