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

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

Issue 26956002: Plumb support for audio sample formats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
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 <cstring> 5 #include <cstring>
6 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 switch (format) { 129 switch (format) {
130 case cdm::kYv12: 130 case cdm::kYv12:
131 return PP_DECRYPTEDFRAMEFORMAT_YV12; 131 return PP_DECRYPTEDFRAMEFORMAT_YV12;
132 case cdm::kI420: 132 case cdm::kI420:
133 return PP_DECRYPTEDFRAMEFORMAT_I420; 133 return PP_DECRYPTEDFRAMEFORMAT_I420;
134 default: 134 default:
135 return PP_DECRYPTEDFRAMEFORMAT_UNKNOWN; 135 return PP_DECRYPTEDFRAMEFORMAT_UNKNOWN;
136 } 136 }
137 } 137 }
138 138
139 PP_DecryptedSampleFormat CdmAudioFormatToPpDecryptedSampleFormat(
140 cdm::AudioFormat format) {
141 switch (format) {
142 case cdm::kAudioFormatU8:
143 return PP_DECRYPTEDSAMPLEFORMAT_U8;
144 case cdm::kAudioFormatS16:
145 return PP_DECRYPTEDSAMPLEFORMAT_S16;
146 case cdm::kAudioFormatS32:
147 return PP_DECRYPTEDSAMPLEFORMAT_S32;
148 case cdm::kAudioFormatF32:
149 return PP_DECRYPTEDSAMPLEFORMAT_F32;
150 case cdm::kAudioFormatPlanarS16:
151 return PP_DECRYPTEDSAMPLEFORMAT_PLANAR_S16;
152 case cdm::kAudioFormatPlanarF32:
153 return PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32;
154 default:
155 return PP_DECRYPTEDSAMPLEFORMAT_UNKNOWN;
156 }
157 }
158
139 cdm::AudioDecoderConfig::AudioCodec PpAudioCodecToCdmAudioCodec( 159 cdm::AudioDecoderConfig::AudioCodec PpAudioCodecToCdmAudioCodec(
140 PP_AudioCodec codec) { 160 PP_AudioCodec codec) {
141 switch (codec) { 161 switch (codec) {
142 case PP_AUDIOCODEC_VORBIS: 162 case PP_AUDIOCODEC_VORBIS:
143 return cdm::AudioDecoderConfig::kCodecVorbis; 163 return cdm::AudioDecoderConfig::kCodecVorbis;
144 case PP_AUDIOCODEC_AAC: 164 case PP_AUDIOCODEC_AAC:
145 return cdm::AudioDecoderConfig::kCodecAac; 165 return cdm::AudioDecoderConfig::kCodecAac;
146 default: 166 default:
147 return cdm::AudioDecoderConfig::kUnknownAudioCodec; 167 return cdm::AudioDecoderConfig::kUnknownAudioCodec;
148 } 168 }
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 } 1188 }
1169 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info); 1189 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info);
1170 } 1190 }
1171 1191
1172 void CdmWrapper::DeliverSamples(int32_t result, 1192 void CdmWrapper::DeliverSamples(int32_t result,
1173 const cdm::Status& status, 1193 const cdm::Status& status,
1174 const LinkedAudioFrames& audio_frames, 1194 const LinkedAudioFrames& audio_frames,
1175 const PP_DecryptTrackingInfo& tracking_info) { 1195 const PP_DecryptTrackingInfo& tracking_info) {
1176 PP_DCHECK(result == PP_OK); 1196 PP_DCHECK(result == PP_OK);
1177 1197
1178 PP_DecryptedBlockInfo decrypted_block_info; 1198 PP_DecryptedSampleInfo decrypted_sample_info;
1179 decrypted_block_info.tracking_info = tracking_info; 1199 decrypted_sample_info.tracking_info = tracking_info;
1180 decrypted_block_info.tracking_info.timestamp = 0; 1200 decrypted_sample_info.tracking_info.timestamp = 0;
1181 decrypted_block_info.tracking_info.buffer_id = 0; 1201 decrypted_sample_info.tracking_info.buffer_id = 0;
1182 decrypted_block_info.data_size = 0; 1202 decrypted_sample_info.data_size = 0;
1183 decrypted_block_info.result = CdmStatusToPpDecryptResult(status); 1203 decrypted_sample_info.result = CdmStatusToPpDecryptResult(status);
1184 1204
1185 pp::Buffer_Dev buffer; 1205 pp::Buffer_Dev buffer;
1186 1206
1187 if (decrypted_block_info.result == PP_DECRYPTRESULT_SUCCESS) { 1207 if (decrypted_sample_info.result == PP_DECRYPTRESULT_SUCCESS) {
1188 PP_DCHECK(audio_frames.get() && audio_frames->FrameBuffer()); 1208 PP_DCHECK(audio_frames.get() && audio_frames->FrameBuffer());
1189 if (!audio_frames.get() || !audio_frames->FrameBuffer()) { 1209 if (!audio_frames.get() || !audio_frames->FrameBuffer()) {
1190 PP_NOTREACHED(); 1210 PP_NOTREACHED();
1191 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR; 1211 decrypted_sample_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR;
1192 } else { 1212 } else {
1193 PpbBuffer* ppb_buffer = 1213 PpbBuffer* ppb_buffer =
1194 static_cast<PpbBuffer*>(audio_frames->FrameBuffer()); 1214 static_cast<PpbBuffer*>(audio_frames->FrameBuffer());
1195 buffer = ppb_buffer->buffer_dev(); 1215 buffer = ppb_buffer->buffer_dev();
1196 decrypted_block_info.tracking_info.buffer_id = ppb_buffer->buffer_id(); 1216 decrypted_sample_info.tracking_info.buffer_id = ppb_buffer->buffer_id();
1197 decrypted_block_info.data_size = ppb_buffer->Size(); 1217 decrypted_sample_info.data_size = ppb_buffer->Size();
1218 decrypted_sample_info.format =
1219 CdmAudioFormatToPpDecryptedSampleFormat(audio_frames->Format());
1198 } 1220 }
1199 } 1221 }
1200 1222
1201 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_block_info); 1223 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_sample_info);
1202 } 1224 }
1203 1225
1204 bool CdmWrapper::IsValidVideoFrame(const LinkedVideoFrame& video_frame) { 1226 bool CdmWrapper::IsValidVideoFrame(const LinkedVideoFrame& video_frame) {
1205 if (!video_frame.get() || 1227 if (!video_frame.get() ||
1206 !video_frame->FrameBuffer() || 1228 !video_frame->FrameBuffer() ||
1207 (video_frame->Format() != cdm::kI420 && 1229 (video_frame->Format() != cdm::kI420 &&
1208 video_frame->Format() != cdm::kYv12)) { 1230 video_frame->Format() != cdm::kYv12)) {
1209 return false; 1231 return false;
1210 } 1232 }
1211 1233
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 } // namespace media 1415 } // namespace media
1394 1416
1395 namespace pp { 1417 namespace pp {
1396 1418
1397 // Factory function for your specialization of the Module object. 1419 // Factory function for your specialization of the Module object.
1398 Module* CreateModule() { 1420 Module* CreateModule() {
1399 return new media::CdmWrapperModule(); 1421 return new media::CdmWrapperModule();
1400 } 1422 }
1401 1423
1402 } // namespace pp 1424 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698