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

Side by Side Diff: media/mp4/mp4_stream_parser.cc

Issue 16114009: Add AAC codec specific data for MSE on android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing comments Created 7 years, 6 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 | « media/mp4/aac.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/mp4/mp4_stream_parser.h" 5 #include "media/mp4/mp4_stream_parser.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (audio_object_types_.find(audio_type) == audio_object_types_.end()) { 215 if (audio_object_types_.find(audio_type) == audio_object_types_.end()) {
216 MEDIA_LOG(log_cb_) << "audio object type 0x" << std::hex << audio_type 216 MEDIA_LOG(log_cb_) << "audio object type 0x" << std::hex << audio_type
217 << " does not match what is specified in the" 217 << " does not match what is specified in the"
218 << " mimetype."; 218 << " mimetype.";
219 return false; 219 return false;
220 } 220 }
221 221
222 AudioCodec codec = kUnknownAudioCodec; 222 AudioCodec codec = kUnknownAudioCodec;
223 ChannelLayout channel_layout = CHANNEL_LAYOUT_NONE; 223 ChannelLayout channel_layout = CHANNEL_LAYOUT_NONE;
224 int sample_per_second = 0; 224 int sample_per_second = 0;
225 std::vector<uint8> extra_data;
225 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or 226 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or
226 // supported MPEG2 AAC varients. 227 // supported MPEG2 AAC varients.
227 if (ESDescriptor::IsAAC(audio_type)) { 228 if (ESDescriptor::IsAAC(audio_type)) {
228 codec = kCodecAAC; 229 codec = kCodecAAC;
229 channel_layout = aac.GetChannelLayout(has_sbr_); 230 channel_layout = aac.GetChannelLayout(has_sbr_);
230 sample_per_second = aac.GetOutputSamplesPerSecond(has_sbr_); 231 sample_per_second = aac.GetOutputSamplesPerSecond(has_sbr_);
232 #if defined(OS_ANDROID)
233 extra_data = aac.codec_specific_data();
234 #endif
231 } else if (audio_type == kEAC3) { 235 } else if (audio_type == kEAC3) {
232 codec = kCodecEAC3; 236 codec = kCodecEAC3;
233 channel_layout = GuessChannelLayout(entry.channelcount); 237 channel_layout = GuessChannelLayout(entry.channelcount);
234 sample_per_second = entry.samplerate; 238 sample_per_second = entry.samplerate;
235 } else { 239 } else {
236 MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex 240 MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex
237 << audio_type << " in esds."; 241 << audio_type << " in esds.";
238 return false; 242 return false;
239 } 243 }
240 244
241 SampleFormat sample_format; 245 SampleFormat sample_format;
242 if (entry.samplesize == 8) { 246 if (entry.samplesize == 8) {
243 sample_format = kSampleFormatU8; 247 sample_format = kSampleFormatU8;
244 } else if (entry.samplesize == 16) { 248 } else if (entry.samplesize == 16) {
245 sample_format = kSampleFormatS16; 249 sample_format = kSampleFormatS16;
246 } else if (entry.samplesize == 32) { 250 } else if (entry.samplesize == 32) {
247 sample_format = kSampleFormatS32; 251 sample_format = kSampleFormatS32;
248 } else { 252 } else {
249 LOG(ERROR) << "Unsupported sample size."; 253 LOG(ERROR) << "Unsupported sample size.";
250 return false; 254 return false;
251 } 255 }
252 256
253 is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; 257 is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted;
254 DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_; 258 DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_;
255 audio_config.Initialize(codec, sample_format, 259 audio_config.Initialize(
256 channel_layout, 260 codec, sample_format, channel_layout, sample_per_second,
257 sample_per_second, 261 extra_data.size() ? &extra_data[0] : NULL, extra_data.size(),
258 NULL, 0, is_audio_track_encrypted_, false); 262 is_audio_track_encrypted_, false);
259 has_audio_ = true; 263 has_audio_ = true;
260 audio_track_id_ = track->header.track_id; 264 audio_track_id_ = track->header.track_id;
261 } 265 }
262 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { 266 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) {
263 RCHECK(!samp_descr.video_entries.empty()); 267 RCHECK(!samp_descr.video_entries.empty());
264 if (desc_idx >= samp_descr.video_entries.size()) 268 if (desc_idx >= samp_descr.video_entries.size())
265 desc_idx = 0; 269 desc_idx = 0;
266 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; 270 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx];
267 271
268 if (!(entry.format == FOURCC_AVC1 || 272 if (!(entry.format == FOURCC_AVC1 ||
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 return !err; 567 return !err;
564 } 568 }
565 569
566 void MP4StreamParser::ChangeState(State new_state) { 570 void MP4StreamParser::ChangeState(State new_state) {
567 DVLOG(2) << "Changing state: " << new_state; 571 DVLOG(2) << "Changing state: " << new_state;
568 state_ = new_state; 572 state_ = new_state;
569 } 573 }
570 574
571 } // namespace mp4 575 } // namespace mp4
572 } // namespace media 576 } // namespace media
OLDNEW
« no previous file with comments | « media/mp4/aac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698