Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Side by Side Diff: media/cdm/ppapi/cdm_adapter.cc

Issue 374353004: Encrypted Media: Fix PpbBuffer::Destroy(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/cdm/ppapi/cdm_helpers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
861 buffer = ppb_buffer->TakeBuffer();
861 } 862 }
862 } 863 }
863 864
864 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); 865 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info);
865 } 866 }
866 867
867 void CdmAdapter::DecoderInitializeDone(int32_t result, 868 void CdmAdapter::DecoderInitializeDone(int32_t result,
868 PP_DecryptorStreamType decoder_type, 869 PP_DecryptorStreamType decoder_type,
869 uint32_t request_id, 870 uint32_t request_id,
870 bool success) { 871 bool success) {
(...skipping 30 matching lines...) Expand all
901 pp::Buffer_Dev buffer; 902 pp::Buffer_Dev buffer;
902 903
903 if (decrypted_frame_info.result == PP_DECRYPTRESULT_SUCCESS) { 904 if (decrypted_frame_info.result == PP_DECRYPTRESULT_SUCCESS) {
904 if (!IsValidVideoFrame(video_frame)) { 905 if (!IsValidVideoFrame(video_frame)) {
905 PP_NOTREACHED(); 906 PP_NOTREACHED();
906 decrypted_frame_info.result = PP_DECRYPTRESULT_DECODE_ERROR; 907 decrypted_frame_info.result = PP_DECRYPTRESULT_DECODE_ERROR;
907 } else { 908 } else {
908 PpbBuffer* ppb_buffer = 909 PpbBuffer* ppb_buffer =
909 static_cast<PpbBuffer*>(video_frame->FrameBuffer()); 910 static_cast<PpbBuffer*>(video_frame->FrameBuffer());
910 911
911 buffer = ppb_buffer->buffer_dev();
912
913 decrypted_frame_info.tracking_info.timestamp = video_frame->Timestamp(); 912 decrypted_frame_info.tracking_info.timestamp = video_frame->Timestamp();
914 decrypted_frame_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); 913 decrypted_frame_info.tracking_info.buffer_id = ppb_buffer->buffer_id();
915 decrypted_frame_info.format = 914 decrypted_frame_info.format =
916 CdmVideoFormatToPpDecryptedFrameFormat(video_frame->Format()); 915 CdmVideoFormatToPpDecryptedFrameFormat(video_frame->Format());
917 decrypted_frame_info.width = video_frame->Size().width; 916 decrypted_frame_info.width = video_frame->Size().width;
918 decrypted_frame_info.height = video_frame->Size().height; 917 decrypted_frame_info.height = video_frame->Size().height;
919 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y] = 918 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y] =
920 video_frame->PlaneOffset(cdm::VideoFrame::kYPlane); 919 video_frame->PlaneOffset(cdm::VideoFrame::kYPlane);
921 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_U] = 920 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_U] =
922 video_frame->PlaneOffset(cdm::VideoFrame::kUPlane); 921 video_frame->PlaneOffset(cdm::VideoFrame::kUPlane);
923 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_V] = 922 decrypted_frame_info.plane_offsets[PP_DECRYPTEDFRAMEPLANES_V] =
924 video_frame->PlaneOffset(cdm::VideoFrame::kVPlane); 923 video_frame->PlaneOffset(cdm::VideoFrame::kVPlane);
925 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_Y] = 924 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_Y] =
926 video_frame->Stride(cdm::VideoFrame::kYPlane); 925 video_frame->Stride(cdm::VideoFrame::kYPlane);
927 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_U] = 926 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_U] =
928 video_frame->Stride(cdm::VideoFrame::kUPlane); 927 video_frame->Stride(cdm::VideoFrame::kUPlane);
929 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_V] = 928 decrypted_frame_info.strides[PP_DECRYPTEDFRAMEPLANES_V] =
930 video_frame->Stride(cdm::VideoFrame::kVPlane); 929 video_frame->Stride(cdm::VideoFrame::kVPlane);
930
931 buffer = ppb_buffer->TakeBuffer();
931 } 932 }
932 } 933 }
934
933 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info); 935 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info);
934 } 936 }
935 937
936 void CdmAdapter::DeliverSamples(int32_t result, 938 void CdmAdapter::DeliverSamples(int32_t result,
937 const cdm::Status& status, 939 const cdm::Status& status,
938 const LinkedAudioFrames& audio_frames, 940 const LinkedAudioFrames& audio_frames,
939 const PP_DecryptTrackingInfo& tracking_info) { 941 const PP_DecryptTrackingInfo& tracking_info) {
940 PP_DCHECK(result == PP_OK); 942 PP_DCHECK(result == PP_OK);
941 943
942 PP_DecryptedSampleInfo decrypted_sample_info; 944 PP_DecryptedSampleInfo decrypted_sample_info;
943 decrypted_sample_info.tracking_info = tracking_info; 945 decrypted_sample_info.tracking_info = tracking_info;
944 decrypted_sample_info.tracking_info.timestamp = 0; 946 decrypted_sample_info.tracking_info.timestamp = 0;
945 decrypted_sample_info.tracking_info.buffer_id = 0; 947 decrypted_sample_info.tracking_info.buffer_id = 0;
946 decrypted_sample_info.data_size = 0; 948 decrypted_sample_info.data_size = 0;
947 decrypted_sample_info.result = CdmStatusToPpDecryptResult(status); 949 decrypted_sample_info.result = CdmStatusToPpDecryptResult(status);
948 950
949 pp::Buffer_Dev buffer; 951 pp::Buffer_Dev buffer;
950 952
951 if (decrypted_sample_info.result == PP_DECRYPTRESULT_SUCCESS) { 953 if (decrypted_sample_info.result == PP_DECRYPTRESULT_SUCCESS) {
952 PP_DCHECK(audio_frames.get() && audio_frames->FrameBuffer()); 954 PP_DCHECK(audio_frames.get() && audio_frames->FrameBuffer());
953 if (!audio_frames.get() || !audio_frames->FrameBuffer()) { 955 if (!audio_frames.get() || !audio_frames->FrameBuffer()) {
954 PP_NOTREACHED(); 956 PP_NOTREACHED();
955 decrypted_sample_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; 957 decrypted_sample_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR;
956 } else { 958 } else {
957 PpbBuffer* ppb_buffer = 959 PpbBuffer* ppb_buffer =
958 static_cast<PpbBuffer*>(audio_frames->FrameBuffer()); 960 static_cast<PpbBuffer*>(audio_frames->FrameBuffer());
959 buffer = ppb_buffer->buffer_dev(); 961
960 decrypted_sample_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); 962 decrypted_sample_info.tracking_info.buffer_id = ppb_buffer->buffer_id();
961 decrypted_sample_info.data_size = ppb_buffer->Size(); 963 decrypted_sample_info.data_size = ppb_buffer->Size();
962 decrypted_sample_info.format = 964 decrypted_sample_info.format =
963 CdmAudioFormatToPpDecryptedSampleFormat(audio_frames->Format()); 965 CdmAudioFormatToPpDecryptedSampleFormat(audio_frames->Format());
966
967 buffer = ppb_buffer->TakeBuffer();
964 } 968 }
965 } 969 }
966 970
967 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_sample_info); 971 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_sample_info);
968 } 972 }
969 973
970 bool CdmAdapter::IsValidVideoFrame(const LinkedVideoFrame& video_frame) { 974 bool CdmAdapter::IsValidVideoFrame(const LinkedVideoFrame& video_frame) {
971 if (!video_frame.get() || 975 if (!video_frame.get() ||
972 !video_frame->FrameBuffer() || 976 !video_frame->FrameBuffer() ||
973 (video_frame->Format() != cdm::kI420 && 977 (video_frame->Format() != cdm::kI420 &&
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 } // namespace media 1265 } // namespace media
1262 1266
1263 namespace pp { 1267 namespace pp {
1264 1268
1265 // Factory function for your specialization of the Module object. 1269 // Factory function for your specialization of the Module object.
1266 Module* CreateModule() { 1270 Module* CreateModule() {
1267 return new media::CdmAdapterModule(); 1271 return new media::CdmAdapterModule();
1268 } 1272 }
1269 1273
1270 } // namespace pp 1274 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | media/cdm/ppapi/cdm_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698