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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 virtual void AddKey(const std::string& session_id, | 400 virtual void AddKey(const std::string& session_id, |
401 pp::VarArrayBuffer key, | 401 pp::VarArrayBuffer key, |
402 pp::VarArrayBuffer init_data) OVERRIDE; | 402 pp::VarArrayBuffer init_data) OVERRIDE; |
403 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; | 403 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; |
404 virtual void Decrypt( | 404 virtual void Decrypt( |
405 pp::Buffer_Dev encrypted_buffer, | 405 pp::Buffer_Dev encrypted_buffer, |
406 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 406 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
407 virtual void InitializeVideoDecoder( | 407 virtual void InitializeVideoDecoder( |
408 const PP_VideoDecoderConfig& decoder_config, | 408 const PP_VideoDecoderConfig& decoder_config, |
409 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | 409 pp::Buffer_Dev extra_data_buffer) OVERRIDE; |
| 410 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| 411 uint32_t request_id) OVERRIDE; |
| 412 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, |
| 413 uint32_t request_id) OVERRIDE; |
410 virtual void DecryptAndDecodeFrame( | 414 virtual void DecryptAndDecodeFrame( |
411 pp::Buffer_Dev encrypted_frame, | 415 pp::Buffer_Dev encrypted_frame, |
412 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; | 416 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; |
413 | 417 |
414 // CdmHost methods. | 418 // CdmHost methods. |
415 virtual void SetTimer(int64 delay_ms) OVERRIDE; | 419 virtual void SetTimer(int64 delay_ms) OVERRIDE; |
416 virtual double GetCurrentWallTimeMs() OVERRIDE; | 420 virtual double GetCurrentWallTimeMs() OVERRIDE; |
417 | 421 |
418 private: | 422 private: |
419 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 423 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
420 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; | 424 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; |
421 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 425 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
422 | 426 |
423 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 427 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
424 // <code>callback_factory_</code> to ensure that calls into | 428 // <code>callback_factory_</code> to ensure that calls into |
425 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 429 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
426 void KeyAdded(int32_t result, const std::string& session_id); | 430 void KeyAdded(int32_t result, const std::string& session_id); |
427 void KeyMessage(int32_t result, const LinkedKeyMessage& message); | 431 void KeyMessage(int32_t result, const LinkedKeyMessage& message); |
428 void KeyError(int32_t result, const std::string& session_id); | 432 void KeyError(int32_t result, const std::string& session_id); |
429 void DeliverBlock(int32_t result, | 433 void DeliverBlock(int32_t result, |
430 const cdm::Status& status, | 434 const cdm::Status& status, |
431 const LinkedDecryptedBlock& decrypted_block, | 435 const LinkedDecryptedBlock& decrypted_block, |
432 const PP_DecryptTrackingInfo& tracking_info); | 436 const PP_DecryptTrackingInfo& tracking_info); |
433 void DecoderInitialized(int32_t result, | 437 void DecoderInitialized(int32_t result, |
434 bool success, | 438 bool success, |
435 uint32_t request_id); | 439 uint32_t request_id); |
| 440 void DecoderDeinitializeDone(int32_t result, |
| 441 PP_DecryptorStreamType decoder_type, |
| 442 uint32_t request_id); |
| 443 void DecoderResetDone(int32_t result, |
| 444 PP_DecryptorStreamType decoder_type, |
| 445 uint32_t request_id); |
436 void DeliverFrame(int32_t result, | 446 void DeliverFrame(int32_t result, |
437 const cdm::Status& status, | 447 const cdm::Status& status, |
438 const LinkedVideoFrame& video_frame, | 448 const LinkedVideoFrame& video_frame, |
439 const PP_DecryptTrackingInfo& tracking_info); | 449 const PP_DecryptTrackingInfo& tracking_info); |
440 | 450 |
441 // Helper for SetTimer(). | 451 // Helper for SetTimer(). |
442 void TimerExpired(int32 result); | 452 void TimerExpired(int32 result); |
443 | 453 |
444 PpbBufferAllocator allocator_; | 454 PpbBufferAllocator allocator_; |
445 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; | 455 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 static_cast<int32_t>(extra_data_buffer.size()); | 597 static_cast<int32_t>(extra_data_buffer.size()); |
588 cdm::Status status = cdm_->InitializeVideoDecoder(cdm_decoder_config); | 598 cdm::Status status = cdm_->InitializeVideoDecoder(cdm_decoder_config); |
589 | 599 |
590 CallOnMain(callback_factory_.NewCallback( | 600 CallOnMain(callback_factory_.NewCallback( |
591 &CdmWrapper::DecoderInitialized, | 601 &CdmWrapper::DecoderInitialized, |
592 status == cdm::kSuccess, | 602 status == cdm::kSuccess, |
593 decoder_config.request_id)); | 603 decoder_config.request_id)); |
594 | 604 |
595 } | 605 } |
596 | 606 |
| 607 void CdmWrapper::DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| 608 uint32_t request_id) { |
| 609 // TODO(tomfinegan): Implement DeinitializeDecoder in clear key CDM, and call |
| 610 // it here. |
| 611 CallOnMain(callback_factory_.NewCallback( |
| 612 &CdmWrapper::DecoderDeinitializeDone, |
| 613 decoder_type, |
| 614 request_id)); |
| 615 } |
| 616 |
| 617 void CdmWrapper::ResetDecoder(PP_DecryptorStreamType decoder_type, |
| 618 uint32_t request_id) { |
| 619 // TODO(tomfinegan): Implement ResetDecoder in clear key CDM, and call it |
| 620 // here. |
| 621 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone, |
| 622 decoder_type, |
| 623 request_id)); |
| 624 } |
| 625 |
597 void CdmWrapper::DecryptAndDecodeFrame( | 626 void CdmWrapper::DecryptAndDecodeFrame( |
598 pp::Buffer_Dev encrypted_frame, | 627 pp::Buffer_Dev encrypted_frame, |
599 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { | 628 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { |
600 PP_DCHECK(!encrypted_frame.is_null()); | 629 PP_DCHECK(!encrypted_frame.is_null()); |
601 PP_DCHECK(cdm_); | 630 PP_DCHECK(cdm_); |
602 | 631 |
603 cdm::InputBuffer input_buffer; | 632 cdm::InputBuffer input_buffer; |
604 std::vector<cdm::SubsampleEntry> subsamples; | 633 std::vector<cdm::SubsampleEntry> subsamples; |
605 ConfigureInputBuffer(encrypted_frame, | 634 ConfigureInputBuffer(encrypted_frame, |
606 encrypted_video_frame_info.encryption_info, | 635 encrypted_video_frame_info.encryption_info, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 734 |
706 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); | 735 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); |
707 } | 736 } |
708 | 737 |
709 void CdmWrapper::DecoderInitialized(int32_t result, | 738 void CdmWrapper::DecoderInitialized(int32_t result, |
710 bool success, | 739 bool success, |
711 uint32_t request_id) { | 740 uint32_t request_id) { |
712 pp::ContentDecryptor_Private::DecoderInitialized(success, request_id); | 741 pp::ContentDecryptor_Private::DecoderInitialized(success, request_id); |
713 } | 742 } |
714 | 743 |
| 744 void CdmWrapper::DecoderDeinitializeDone(int32_t result, |
| 745 PP_DecryptorStreamType decoder_type, |
| 746 uint32_t request_id) { |
| 747 pp::ContentDecryptor_Private::DecoderDeinitializeDone(decoder_type, |
| 748 request_id); |
| 749 } |
| 750 |
| 751 void CdmWrapper::DecoderResetDone(int32_t result, |
| 752 PP_DecryptorStreamType decoder_type, |
| 753 uint32_t request_id) { |
| 754 pp::ContentDecryptor_Private::DecoderResetDone(decoder_type, request_id); |
| 755 } |
| 756 |
715 void CdmWrapper::DeliverFrame( | 757 void CdmWrapper::DeliverFrame( |
716 int32_t result, | 758 int32_t result, |
717 const cdm::Status& status, | 759 const cdm::Status& status, |
718 const LinkedVideoFrame& video_frame, | 760 const LinkedVideoFrame& video_frame, |
719 const PP_DecryptTrackingInfo& tracking_info) { | 761 const PP_DecryptTrackingInfo& tracking_info) { |
720 PP_DCHECK(result == PP_OK); | 762 PP_DCHECK(result == PP_OK); |
721 PP_DecryptedFrameInfo decrypted_frame_info; | 763 PP_DecryptedFrameInfo decrypted_frame_info; |
722 decrypted_frame_info.tracking_info = tracking_info; | 764 decrypted_frame_info.tracking_info = tracking_info; |
723 | 765 |
724 switch (status) { | 766 switch (status) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 } // namespace webkit_media | 823 } // namespace webkit_media |
782 | 824 |
783 namespace pp { | 825 namespace pp { |
784 | 826 |
785 // Factory function for your specialization of the Module object. | 827 // Factory function for your specialization of the Module object. |
786 Module* CreateModule() { | 828 Module* CreateModule() { |
787 return new webkit_media::CdmWrapperModule(); | 829 return new webkit_media::CdmWrapperModule(); |
788 } | 830 } |
789 | 831 |
790 } // namespace pp | 832 } // namespace pp |
OLD | NEW |