| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Configures a cdm::InputBuffer. |subsamples| must exist as long as | 57 // Configures a cdm::InputBuffer. |subsamples| must exist as long as |
| 58 // |input_buffer| is in use. | 58 // |input_buffer| is in use. |
| 59 void ConfigureInputBuffer( | 59 void ConfigureInputBuffer( |
| 60 const pp::Buffer_Dev& encrypted_buffer, | 60 const pp::Buffer_Dev& encrypted_buffer, |
| 61 const PP_EncryptedBlockInfo& encrypted_block_info, | 61 const PP_EncryptedBlockInfo& encrypted_block_info, |
| 62 std::vector<cdm::SubsampleEntry>* subsamples, | 62 std::vector<cdm::SubsampleEntry>* subsamples, |
| 63 cdm::InputBuffer* input_buffer) { | 63 cdm::InputBuffer* input_buffer) { |
| 64 PP_DCHECK(subsamples); | 64 PP_DCHECK(subsamples); |
| 65 PP_DCHECK(!encrypted_buffer.is_null()); |
| 66 |
| 65 input_buffer->data = reinterpret_cast<uint8_t*>(encrypted_buffer.data()); | 67 input_buffer->data = reinterpret_cast<uint8_t*>(encrypted_buffer.data()); |
| 66 input_buffer->data_size = encrypted_buffer.size(); | 68 input_buffer->data_size = encrypted_buffer.size(); |
| 67 input_buffer->data_offset = encrypted_block_info.data_offset; | 69 input_buffer->data_offset = encrypted_block_info.data_offset; |
| 68 input_buffer->key_id = encrypted_block_info.key_id; | 70 input_buffer->key_id = encrypted_block_info.key_id; |
| 69 input_buffer->key_id_size = encrypted_block_info.key_id_size; | 71 input_buffer->key_id_size = encrypted_block_info.key_id_size; |
| 70 input_buffer->iv = encrypted_block_info.iv; | 72 input_buffer->iv = encrypted_block_info.iv; |
| 71 input_buffer->iv_size = encrypted_block_info.iv_size; | 73 input_buffer->iv_size = encrypted_block_info.iv_size; |
| 72 input_buffer->num_subsamples = encrypted_block_info.num_subsamples; | 74 input_buffer->num_subsamples = encrypted_block_info.num_subsamples; |
| 73 | 75 |
| 74 if (encrypted_block_info.num_subsamples > 0) { | 76 if (encrypted_block_info.num_subsamples > 0) { |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 decoder_type, | 639 decoder_type, |
| 638 request_id)); | 640 request_id)); |
| 639 } | 641 } |
| 640 | 642 |
| 641 void CdmWrapper::DecryptAndDecode( | 643 void CdmWrapper::DecryptAndDecode( |
| 642 PP_DecryptorStreamType decoder_type, | 644 PP_DecryptorStreamType decoder_type, |
| 643 pp::Buffer_Dev encrypted_buffer, | 645 pp::Buffer_Dev encrypted_buffer, |
| 644 const PP_EncryptedBlockInfo& encrypted_block_info) { | 646 const PP_EncryptedBlockInfo& encrypted_block_info) { |
| 645 // TODO(tomfinegan): Remove this check when audio decoding is added. | 647 // TODO(tomfinegan): Remove this check when audio decoding is added. |
| 646 PP_DCHECK(decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO); | 648 PP_DCHECK(decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO); |
| 647 | |
| 648 PP_DCHECK(!encrypted_buffer.is_null()); | |
| 649 PP_DCHECK(cdm_); | 649 PP_DCHECK(cdm_); |
| 650 | 650 |
| 651 cdm::InputBuffer input_buffer; | 651 cdm::InputBuffer input_buffer; |
| 652 std::vector<cdm::SubsampleEntry> subsamples; | 652 std::vector<cdm::SubsampleEntry> subsamples; |
| 653 ConfigureInputBuffer(encrypted_buffer, | 653 if (!encrypted_buffer.is_null()) { |
| 654 encrypted_block_info, | 654 ConfigureInputBuffer(encrypted_buffer, |
| 655 &subsamples, | 655 encrypted_block_info, |
| 656 &input_buffer); | 656 &subsamples, |
| 657 &input_buffer); |
| 658 } |
| 657 | 659 |
| 658 LinkedVideoFrame video_frame(new VideoFrameImpl()); | 660 LinkedVideoFrame video_frame(new VideoFrameImpl()); |
| 659 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, | 661 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, |
| 660 video_frame.get()); | 662 video_frame.get()); |
| 661 CallOnMain(callback_factory_.NewCallback( | 663 CallOnMain(callback_factory_.NewCallback( |
| 662 &CdmWrapper::DeliverFrame, | 664 &CdmWrapper::DeliverFrame, |
| 663 status, | 665 status, |
| 664 video_frame, | 666 video_frame, |
| 665 encrypted_block_info.tracking_info)); | 667 encrypted_block_info.tracking_info)); |
| 666 } | 668 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 int32_t result, | 779 int32_t result, |
| 778 const cdm::Status& status, | 780 const cdm::Status& status, |
| 779 const LinkedVideoFrame& video_frame, | 781 const LinkedVideoFrame& video_frame, |
| 780 const PP_DecryptTrackingInfo& tracking_info) { | 782 const PP_DecryptTrackingInfo& tracking_info) { |
| 781 PP_DCHECK(result == PP_OK); | 783 PP_DCHECK(result == PP_OK); |
| 782 PP_DecryptedFrameInfo decrypted_frame_info; | 784 PP_DecryptedFrameInfo decrypted_frame_info; |
| 783 decrypted_frame_info.tracking_info = tracking_info; | 785 decrypted_frame_info.tracking_info = tracking_info; |
| 784 | 786 |
| 785 switch (status) { | 787 switch (status) { |
| 786 case cdm::kSuccess: | 788 case cdm::kSuccess: |
| 787 PP_DCHECK(video_frame->format() == cdm::kI420 || | 789 PP_DCHECK(video_frame.get()); |
| 790 PP_DCHECK(video_frame->format() == cdm::kEmptyVideoFrame || |
| 791 video_frame->format() == cdm::kI420 || |
| 788 video_frame->format() == cdm::kYv12); | 792 video_frame->format() == cdm::kYv12); |
| 789 PP_DCHECK(video_frame.get() && video_frame->frame_buffer()); | 793 |
| 790 decrypted_frame_info.result = PP_DECRYPTRESULT_SUCCESS; | 794 decrypted_frame_info.result = PP_DECRYPTRESULT_SUCCESS; |
| 791 decrypted_frame_info.format = | 795 decrypted_frame_info.format = |
| 792 CdmVideoFormatToPpDecryptedFrameFormat(video_frame->format()); | 796 CdmVideoFormatToPpDecryptedFrameFormat(video_frame->format()); |
| 797 |
| 798 if (video_frame->format() == cdm::kEmptyVideoFrame) |
| 799 break; |
| 800 |
| 801 PP_DCHECK(video_frame->frame_buffer()); |
| 793 decrypted_frame_info.width = video_frame->size().width; | 802 decrypted_frame_info.width = video_frame->size().width; |
| 794 decrypted_frame_info.height = video_frame->size().height; | 803 decrypted_frame_info.height = video_frame->size().height; |
| 795 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y] = | 804 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y] = |
| 796 video_frame->plane_offset(cdm::VideoFrame::kYPlane); | 805 video_frame->plane_offset(cdm::VideoFrame::kYPlane); |
| 797 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_U] = | 806 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_U] = |
| 798 video_frame->plane_offset(cdm::VideoFrame::kUPlane); | 807 video_frame->plane_offset(cdm::VideoFrame::kUPlane); |
| 799 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_V] = | 808 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_V] = |
| 800 video_frame->plane_offset(cdm::VideoFrame::kVPlane); | 809 video_frame->plane_offset(cdm::VideoFrame::kVPlane); |
| 801 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_Y] = | 810 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_Y] = |
| 802 video_frame->stride(cdm::VideoFrame::kYPlane); | 811 video_frame->stride(cdm::VideoFrame::kYPlane); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 } // namespace webkit_media | 853 } // namespace webkit_media |
| 845 | 854 |
| 846 namespace pp { | 855 namespace pp { |
| 847 | 856 |
| 848 // Factory function for your specialization of the Module object. | 857 // Factory function for your specialization of the Module object. |
| 849 Module* CreateModule() { | 858 Module* CreateModule() { |
| 850 return new webkit_media::CdmWrapperModule(); | 859 return new webkit_media::CdmWrapperModule(); |
| 851 } | 860 } |
| 852 | 861 |
| 853 } // namespace pp | 862 } // namespace pp |
| OLD | NEW |