OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/cdm/ppapi/cdm_adapter.h" | 5 #include "media/cdm/ppapi/cdm_adapter.h" |
6 | 6 |
7 #include "media/cdm/ppapi/cdm_helpers.h" | 7 #include "media/cdm/ppapi/cdm_helpers.h" |
8 | 8 |
9 #if defined(CHECK_DOCUMENT_URL) | 9 #if defined(CHECK_DOCUMENT_URL) |
10 #include "ppapi/cpp/dev/url_util_dev.h" | 10 #include "ppapi/cpp/dev/url_util_dev.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 switch (format) { | 100 switch (format) { |
101 case cdm::kYv12: | 101 case cdm::kYv12: |
102 return PP_DECRYPTEDFRAMEFORMAT_YV12; | 102 return PP_DECRYPTEDFRAMEFORMAT_YV12; |
103 case cdm::kI420: | 103 case cdm::kI420: |
104 return PP_DECRYPTEDFRAMEFORMAT_I420; | 104 return PP_DECRYPTEDFRAMEFORMAT_I420; |
105 default: | 105 default: |
106 return PP_DECRYPTEDFRAMEFORMAT_UNKNOWN; | 106 return PP_DECRYPTEDFRAMEFORMAT_UNKNOWN; |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
| 110 PP_DecryptedSampleFormat CdmAudioFormatToPpDecryptedSampleFormat( |
| 111 cdm::AudioFormat format) { |
| 112 switch (format) { |
| 113 case cdm::kAudioFormatU8: |
| 114 return PP_DECRYPTEDSAMPLEFORMAT_U8; |
| 115 case cdm::kAudioFormatS16: |
| 116 return PP_DECRYPTEDSAMPLEFORMAT_S16; |
| 117 case cdm::kAudioFormatS32: |
| 118 return PP_DECRYPTEDSAMPLEFORMAT_S32; |
| 119 case cdm::kAudioFormatF32: |
| 120 return PP_DECRYPTEDSAMPLEFORMAT_F32; |
| 121 case cdm::kAudioFormatPlanarS16: |
| 122 return PP_DECRYPTEDSAMPLEFORMAT_PLANAR_S16; |
| 123 case cdm::kAudioFormatPlanarF32: |
| 124 return PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32; |
| 125 default: |
| 126 return PP_DECRYPTEDSAMPLEFORMAT_UNKNOWN; |
| 127 } |
| 128 } |
| 129 |
110 cdm::AudioDecoderConfig::AudioCodec PpAudioCodecToCdmAudioCodec( | 130 cdm::AudioDecoderConfig::AudioCodec PpAudioCodecToCdmAudioCodec( |
111 PP_AudioCodec codec) { | 131 PP_AudioCodec codec) { |
112 switch (codec) { | 132 switch (codec) { |
113 case PP_AUDIOCODEC_VORBIS: | 133 case PP_AUDIOCODEC_VORBIS: |
114 return cdm::AudioDecoderConfig::kCodecVorbis; | 134 return cdm::AudioDecoderConfig::kCodecVorbis; |
115 case PP_AUDIOCODEC_AAC: | 135 case PP_AUDIOCODEC_AAC: |
116 return cdm::AudioDecoderConfig::kCodecAac; | 136 return cdm::AudioDecoderConfig::kCodecAac; |
117 default: | 137 default: |
118 return cdm::AudioDecoderConfig::kUnknownAudioCodec; | 138 return cdm::AudioDecoderConfig::kUnknownAudioCodec; |
119 } | 139 } |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 } | 688 } |
669 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info); | 689 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info); |
670 } | 690 } |
671 | 691 |
672 void CdmAdapter::DeliverSamples(int32_t result, | 692 void CdmAdapter::DeliverSamples(int32_t result, |
673 const cdm::Status& status, | 693 const cdm::Status& status, |
674 const LinkedAudioFrames& audio_frames, | 694 const LinkedAudioFrames& audio_frames, |
675 const PP_DecryptTrackingInfo& tracking_info) { | 695 const PP_DecryptTrackingInfo& tracking_info) { |
676 PP_DCHECK(result == PP_OK); | 696 PP_DCHECK(result == PP_OK); |
677 | 697 |
678 PP_DecryptedBlockInfo decrypted_block_info; | 698 PP_DecryptedSampleInfo decrypted_sample_info; |
679 decrypted_block_info.tracking_info = tracking_info; | 699 decrypted_sample_info.tracking_info = tracking_info; |
680 decrypted_block_info.tracking_info.timestamp = 0; | 700 decrypted_sample_info.tracking_info.timestamp = 0; |
681 decrypted_block_info.tracking_info.buffer_id = 0; | 701 decrypted_sample_info.tracking_info.buffer_id = 0; |
682 decrypted_block_info.data_size = 0; | 702 decrypted_sample_info.data_size = 0; |
683 decrypted_block_info.result = CdmStatusToPpDecryptResult(status); | 703 decrypted_sample_info.result = CdmStatusToPpDecryptResult(status); |
684 | 704 |
685 pp::Buffer_Dev buffer; | 705 pp::Buffer_Dev buffer; |
686 | 706 |
687 if (decrypted_block_info.result == PP_DECRYPTRESULT_SUCCESS) { | 707 if (decrypted_sample_info.result == PP_DECRYPTRESULT_SUCCESS) { |
688 PP_DCHECK(audio_frames.get() && audio_frames->FrameBuffer()); | 708 PP_DCHECK(audio_frames.get() && audio_frames->FrameBuffer()); |
689 if (!audio_frames.get() || !audio_frames->FrameBuffer()) { | 709 if (!audio_frames.get() || !audio_frames->FrameBuffer()) { |
690 PP_NOTREACHED(); | 710 PP_NOTREACHED(); |
691 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; | 711 decrypted_sample_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; |
692 } else { | 712 } else { |
693 PpbBuffer* ppb_buffer = | 713 PpbBuffer* ppb_buffer = |
694 static_cast<PpbBuffer*>(audio_frames->FrameBuffer()); | 714 static_cast<PpbBuffer*>(audio_frames->FrameBuffer()); |
695 buffer = ppb_buffer->buffer_dev(); | 715 buffer = ppb_buffer->buffer_dev(); |
696 decrypted_block_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); | 716 decrypted_sample_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); |
697 decrypted_block_info.data_size = ppb_buffer->Size(); | 717 decrypted_sample_info.data_size = ppb_buffer->Size(); |
| 718 decrypted_sample_info.format = |
| 719 CdmAudioFormatToPpDecryptedSampleFormat(audio_frames->Format()); |
698 } | 720 } |
699 } | 721 } |
700 | 722 |
701 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_block_info); | 723 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_sample_info); |
702 } | 724 } |
703 | 725 |
704 bool CdmAdapter::IsValidVideoFrame(const LinkedVideoFrame& video_frame) { | 726 bool CdmAdapter::IsValidVideoFrame(const LinkedVideoFrame& video_frame) { |
705 if (!video_frame.get() || | 727 if (!video_frame.get() || |
706 !video_frame->FrameBuffer() || | 728 !video_frame->FrameBuffer() || |
707 (video_frame->Format() != cdm::kI420 && | 729 (video_frame->Format() != cdm::kI420 && |
708 video_frame->Format() != cdm::kYv12)) { | 730 video_frame->Format() != cdm::kYv12)) { |
709 return false; | 731 return false; |
710 } | 732 } |
711 | 733 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 } // namespace media | 902 } // namespace media |
881 | 903 |
882 namespace pp { | 904 namespace pp { |
883 | 905 |
884 // Factory function for your specialization of the Module object. | 906 // Factory function for your specialization of the Module object. |
885 Module* CreateModule() { | 907 Module* CreateModule() { |
886 return new media::CdmAdapterModule(); | 908 return new media::CdmAdapterModule(); |
887 } | 909 } |
888 | 910 |
889 } // namespace pp | 911 } // namespace pp |
OLD | NEW |