| 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 410 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| 411 uint32_t request_id) OVERRIDE; | 411 uint32_t request_id) OVERRIDE; |
| 412 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, | 412 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, |
| 413 uint32_t request_id) OVERRIDE; | 413 uint32_t request_id) OVERRIDE; |
| 414 virtual void DecryptAndDecodeFrame( | 414 virtual void DecryptAndDecode( |
| 415 pp::Buffer_Dev encrypted_frame, | 415 PP_DecryptorStreamType decoder_type, |
| 416 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; | 416 pp::Buffer_Dev encrypted_buffer, |
| 417 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 417 | 418 |
| 418 // CdmHost methods. | 419 // CdmHost methods. |
| 419 virtual void SetTimer(int64 delay_ms) OVERRIDE; | 420 virtual void SetTimer(int64 delay_ms) OVERRIDE; |
| 420 virtual double GetCurrentWallTimeMs() OVERRIDE; | 421 virtual double GetCurrentWallTimeMs() OVERRIDE; |
| 421 | 422 |
| 422 private: | 423 private: |
| 423 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 424 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
| 424 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; | 425 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; |
| 425 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 426 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
| 426 | 427 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 617 |
| 617 void CdmWrapper::ResetDecoder(PP_DecryptorStreamType decoder_type, | 618 void CdmWrapper::ResetDecoder(PP_DecryptorStreamType decoder_type, |
| 618 uint32_t request_id) { | 619 uint32_t request_id) { |
| 619 // TODO(tomfinegan): Implement ResetDecoder in clear key CDM, and call it | 620 // TODO(tomfinegan): Implement ResetDecoder in clear key CDM, and call it |
| 620 // here. | 621 // here. |
| 621 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone, | 622 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone, |
| 622 decoder_type, | 623 decoder_type, |
| 623 request_id)); | 624 request_id)); |
| 624 } | 625 } |
| 625 | 626 |
| 626 void CdmWrapper::DecryptAndDecodeFrame( | 627 void CdmWrapper::DecryptAndDecode( |
| 627 pp::Buffer_Dev encrypted_frame, | 628 PP_DecryptorStreamType decoder_type, |
| 628 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { | 629 pp::Buffer_Dev encrypted_buffer, |
| 629 PP_DCHECK(!encrypted_frame.is_null()); | 630 const PP_EncryptedBlockInfo& encrypted_block_info) { |
| 631 // TODO(tomfinegan): Remove this check when audio decoding is added. |
| 632 PP_DCHECK(decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO); |
| 633 |
| 634 PP_DCHECK(!encrypted_buffer.is_null()); |
| 630 PP_DCHECK(cdm_); | 635 PP_DCHECK(cdm_); |
| 631 | 636 |
| 632 cdm::InputBuffer input_buffer; | 637 cdm::InputBuffer input_buffer; |
| 633 std::vector<cdm::SubsampleEntry> subsamples; | 638 std::vector<cdm::SubsampleEntry> subsamples; |
| 634 ConfigureInputBuffer(encrypted_frame, | 639 ConfigureInputBuffer(encrypted_buffer, |
| 635 encrypted_video_frame_info.encryption_info, | 640 encrypted_block_info, |
| 636 &subsamples, | 641 &subsamples, |
| 637 &input_buffer); | 642 &input_buffer); |
| 638 | 643 |
| 639 LinkedVideoFrame video_frame(new VideoFrameImpl()); | 644 LinkedVideoFrame video_frame(new VideoFrameImpl()); |
| 640 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, | 645 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, |
| 641 video_frame.get()); | 646 video_frame.get()); |
| 642 CallOnMain(callback_factory_.NewCallback( | 647 CallOnMain(callback_factory_.NewCallback( |
| 643 &CdmWrapper::DeliverFrame, | 648 &CdmWrapper::DeliverFrame, |
| 644 status, | 649 status, |
| 645 video_frame, | 650 video_frame, |
| 646 encrypted_video_frame_info.encryption_info.tracking_info)); | 651 encrypted_block_info.tracking_info)); |
| 647 } | 652 } |
| 648 | 653 |
| 649 void CdmWrapper::SetTimer(int64 delay_ms) { | 654 void CdmWrapper::SetTimer(int64 delay_ms) { |
| 650 // NOTE: doesn't really need to run on the main thread; could just as well run | 655 // NOTE: doesn't really need to run on the main thread; could just as well run |
| 651 // on a helper thread if |cdm_| were thread-friendly and care was taken. We | 656 // on a helper thread if |cdm_| were thread-friendly and care was taken. We |
| 652 // only use CallOnMainThread() here to get delayed-execution behavior. | 657 // only use CallOnMainThread() here to get delayed-execution behavior. |
| 653 pp::Module::Get()->core()->CallOnMainThread( | 658 pp::Module::Get()->core()->CallOnMainThread( |
| 654 delay_ms, | 659 delay_ms, |
| 655 callback_factory_.NewCallback(&CdmWrapper::TimerExpired), | 660 callback_factory_.NewCallback(&CdmWrapper::TimerExpired), |
| 656 PP_OK); | 661 PP_OK); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 } // namespace webkit_media | 828 } // namespace webkit_media |
| 824 | 829 |
| 825 namespace pp { | 830 namespace pp { |
| 826 | 831 |
| 827 // Factory function for your specialization of the Module object. | 832 // Factory function for your specialization of the Module object. |
| 828 Module* CreateModule() { | 833 Module* CreateModule() { |
| 829 return new webkit_media::CdmWrapperModule(); | 834 return new webkit_media::CdmWrapperModule(); |
| 830 } | 835 } |
| 831 | 836 |
| 832 } // namespace pp | 837 } // namespace pp |
| OLD | NEW |