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_file_io_impl.h" | 7 #include "media/cdm/ppapi/cdm_file_io_impl.h" |
8 #include "media/cdm/ppapi/cdm_helpers.h" | 8 #include "media/cdm/ppapi/cdm_helpers.h" |
9 #include "media/cdm/ppapi/cdm_logging.h" | 9 #include "media/cdm/ppapi/cdm_logging.h" |
10 #include "media/cdm/ppapi/supported_cdm_versions.h" | 10 #include "media/cdm/ppapi/supported_cdm_versions.h" |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 pp::Buffer_Dev buffer; | 848 pp::Buffer_Dev buffer; |
849 | 849 |
850 if (decrypted_block_info.result == PP_DECRYPTRESULT_SUCCESS) { | 850 if (decrypted_block_info.result == PP_DECRYPTRESULT_SUCCESS) { |
851 PP_DCHECK(decrypted_block.get() && decrypted_block->DecryptedBuffer()); | 851 PP_DCHECK(decrypted_block.get() && decrypted_block->DecryptedBuffer()); |
852 if (!decrypted_block.get() || !decrypted_block->DecryptedBuffer()) { | 852 if (!decrypted_block.get() || !decrypted_block->DecryptedBuffer()) { |
853 PP_NOTREACHED(); | 853 PP_NOTREACHED(); |
854 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; | 854 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; |
855 } else { | 855 } else { |
856 PpbBuffer* ppb_buffer = | 856 PpbBuffer* ppb_buffer = |
857 static_cast<PpbBuffer*>(decrypted_block->DecryptedBuffer()); | 857 static_cast<PpbBuffer*>(decrypted_block->DecryptedBuffer()); |
858 buffer = ppb_buffer->buffer_dev(); | |
859 decrypted_block_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); | 858 decrypted_block_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); |
860 decrypted_block_info.data_size = ppb_buffer->Size(); | 859 decrypted_block_info.data_size = ppb_buffer->Size(); |
860 buffer = ppb_buffer->TakeBufferDev(); | |
xhwang
2014/07/10 16:42:39
This call also clears buffer_id and size. That's w
ddorwin
2014/07/10 21:56:14
We never fixed the original naming. PpbBuffer isn'
xhwang
2014/07/10 22:37:33
How about just BufferImpl, which is consistent wit
ddorwin
2014/07/10 22:43:24
BufferImpl sounds good. In a different CL, of cour
xhwang
2014/07/10 22:48:50
Will do.
| |
861 } | 861 } |
862 } | 862 } |
863 | 863 |
864 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); | 864 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); |
865 } | 865 } |
866 | 866 |
867 void CdmAdapter::DecoderInitializeDone(int32_t result, | 867 void CdmAdapter::DecoderInitializeDone(int32_t result, |
868 PP_DecryptorStreamType decoder_type, | 868 PP_DecryptorStreamType decoder_type, |
869 uint32_t request_id, | 869 uint32_t request_id, |
870 bool success) { | 870 bool success) { |
(...skipping 30 matching lines...) Expand all Loading... | |
901 pp::Buffer_Dev buffer; | 901 pp::Buffer_Dev buffer; |
902 | 902 |
903 if (decrypted_frame_info.result == PP_DECRYPTRESULT_SUCCESS) { | 903 if (decrypted_frame_info.result == PP_DECRYPTRESULT_SUCCESS) { |
904 if (!IsValidVideoFrame(video_frame)) { | 904 if (!IsValidVideoFrame(video_frame)) { |
905 PP_NOTREACHED(); | 905 PP_NOTREACHED(); |
906 decrypted_frame_info.result = PP_DECRYPTRESULT_DECODE_ERROR; | 906 decrypted_frame_info.result = PP_DECRYPTRESULT_DECODE_ERROR; |
907 } else { | 907 } else { |
908 PpbBuffer* ppb_buffer = | 908 PpbBuffer* ppb_buffer = |
909 static_cast<PpbBuffer*>(video_frame->FrameBuffer()); | 909 static_cast<PpbBuffer*>(video_frame->FrameBuffer()); |
910 | 910 |
911 buffer = ppb_buffer->buffer_dev(); | |
912 | |
913 decrypted_frame_info.tracking_info.timestamp = video_frame->Timestamp(); | 911 decrypted_frame_info.tracking_info.timestamp = video_frame->Timestamp(); |
914 decrypted_frame_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); | 912 decrypted_frame_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); |
915 decrypted_frame_info.format = | 913 decrypted_frame_info.format = |
916 CdmVideoFormatToPpDecryptedFrameFormat(video_frame->Format()); | 914 CdmVideoFormatToPpDecryptedFrameFormat(video_frame->Format()); |
917 decrypted_frame_info.width = video_frame->Size().width; | 915 decrypted_frame_info.width = video_frame->Size().width; |
918 decrypted_frame_info.height = video_frame->Size().height; | 916 decrypted_frame_info.height = video_frame->Size().height; |
919 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y] = | 917 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y] = |
920 video_frame->PlaneOffset(cdm::VideoFrame::kYPlane); | 918 video_frame->PlaneOffset(cdm::VideoFrame::kYPlane); |
921 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_U] = | 919 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_U] = |
922 video_frame->PlaneOffset(cdm::VideoFrame::kUPlane); | 920 video_frame->PlaneOffset(cdm::VideoFrame::kUPlane); |
923 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_V] = | 921 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_V] = |
924 video_frame->PlaneOffset(cdm::VideoFrame::kVPlane); | 922 video_frame->PlaneOffset(cdm::VideoFrame::kVPlane); |
925 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_Y] = | 923 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_Y] = |
926 video_frame->Stride(cdm::VideoFrame::kYPlane); | 924 video_frame->Stride(cdm::VideoFrame::kYPlane); |
927 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_U] = | 925 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_U] = |
928 video_frame->Stride(cdm::VideoFrame::kUPlane); | 926 video_frame->Stride(cdm::VideoFrame::kUPlane); |
929 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_V] = | 927 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_V] = |
930 video_frame->Stride(cdm::VideoFrame::kVPlane); | 928 video_frame->Stride(cdm::VideoFrame::kVPlane); |
929 | |
930 buffer = ppb_buffer->TakeBufferDev(); | |
931 } | 931 } |
932 } | 932 } |
933 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info); | 933 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info); |
ddorwin
2014/07/10 21:56:14
nit: add an empty line for consistency (and becaus
xhwang
2014/07/10 22:37:33
Done.
| |
934 } | 934 } |
935 | 935 |
936 void CdmAdapter::DeliverSamples(int32_t result, | 936 void CdmAdapter::DeliverSamples(int32_t result, |
937 const cdm::Status& status, | 937 const cdm::Status& status, |
938 const LinkedAudioFrames& audio_frames, | 938 const LinkedAudioFrames& audio_frames, |
939 const PP_DecryptTrackingInfo& tracking_info) { | 939 const PP_DecryptTrackingInfo& tracking_info) { |
940 PP_DCHECK(result == PP_OK); | 940 PP_DCHECK(result == PP_OK); |
941 | 941 |
942 PP_DecryptedSampleInfo decrypted_sample_info; | 942 PP_DecryptedSampleInfo decrypted_sample_info; |
943 decrypted_sample_info.tracking_info = tracking_info; | 943 decrypted_sample_info.tracking_info = tracking_info; |
944 decrypted_sample_info.tracking_info.timestamp = 0; | 944 decrypted_sample_info.tracking_info.timestamp = 0; |
945 decrypted_sample_info.tracking_info.buffer_id = 0; | 945 decrypted_sample_info.tracking_info.buffer_id = 0; |
946 decrypted_sample_info.data_size = 0; | 946 decrypted_sample_info.data_size = 0; |
947 decrypted_sample_info.result = CdmStatusToPpDecryptResult(status); | 947 decrypted_sample_info.result = CdmStatusToPpDecryptResult(status); |
948 | 948 |
949 pp::Buffer_Dev buffer; | 949 pp::Buffer_Dev buffer; |
950 | 950 |
951 if (decrypted_sample_info.result == PP_DECRYPTRESULT_SUCCESS) { | 951 if (decrypted_sample_info.result == PP_DECRYPTRESULT_SUCCESS) { |
952 PP_DCHECK(audio_frames.get() && audio_frames->FrameBuffer()); | 952 PP_DCHECK(audio_frames.get() && audio_frames->FrameBuffer()); |
953 if (!audio_frames.get() || !audio_frames->FrameBuffer()) { | 953 if (!audio_frames.get() || !audio_frames->FrameBuffer()) { |
954 PP_NOTREACHED(); | 954 PP_NOTREACHED(); |
955 decrypted_sample_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; | 955 decrypted_sample_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; |
956 } else { | 956 } else { |
957 PpbBuffer* ppb_buffer = | 957 PpbBuffer* ppb_buffer = |
958 static_cast<PpbBuffer*>(audio_frames->FrameBuffer()); | 958 static_cast<PpbBuffer*>(audio_frames->FrameBuffer()); |
959 buffer = ppb_buffer->buffer_dev(); | 959 |
960 decrypted_sample_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); | 960 decrypted_sample_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); |
961 decrypted_sample_info.data_size = ppb_buffer->Size(); | 961 decrypted_sample_info.data_size = ppb_buffer->Size(); |
962 decrypted_sample_info.format = | 962 decrypted_sample_info.format = |
963 CdmAudioFormatToPpDecryptedSampleFormat(audio_frames->Format()); | 963 CdmAudioFormatToPpDecryptedSampleFormat(audio_frames->Format()); |
964 | |
965 buffer = ppb_buffer->TakeBufferDev(); | |
964 } | 966 } |
965 } | 967 } |
966 | 968 |
967 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_sample_info); | 969 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_sample_info); |
968 } | 970 } |
969 | 971 |
970 bool CdmAdapter::IsValidVideoFrame(const LinkedVideoFrame& video_frame) { | 972 bool CdmAdapter::IsValidVideoFrame(const LinkedVideoFrame& video_frame) { |
971 if (!video_frame.get() || | 973 if (!video_frame.get() || |
972 !video_frame->FrameBuffer() || | 974 !video_frame->FrameBuffer() || |
973 (video_frame->Format() != cdm::kI420 && | 975 (video_frame->Format() != cdm::kI420 && |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 } // namespace media | 1263 } // namespace media |
1262 | 1264 |
1263 namespace pp { | 1265 namespace pp { |
1264 | 1266 |
1265 // Factory function for your specialization of the Module object. | 1267 // Factory function for your specialization of the Module object. |
1266 Module* CreateModule() { | 1268 Module* CreateModule() { |
1267 return new media::CdmAdapterModule(); | 1269 return new media::CdmAdapterModule(); |
1268 } | 1270 } |
1269 | 1271 |
1270 } // namespace pp | 1272 } // namespace pp |
OLD | NEW |