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

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

Issue 10710002: Add HE AAC support to ISO BMFF. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove unused entry from media.gyp Created 8 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
« no previous file with comments | « media/mp4/mp4_stream_parser.h ('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"
11 #include "media/base/audio_decoder_config.h" 11 #include "media/base/audio_decoder_config.h"
12 #include "media/base/stream_parser_buffer.h" 12 #include "media/base/stream_parser_buffer.h"
13 #include "media/base/video_decoder_config.h" 13 #include "media/base/video_decoder_config.h"
14 #include "media/mp4/box_definitions.h" 14 #include "media/mp4/box_definitions.h"
15 #include "media/mp4/box_reader.h" 15 #include "media/mp4/box_reader.h"
16 #include "media/mp4/es_descriptor.h"
16 #include "media/mp4/rcheck.h" 17 #include "media/mp4/rcheck.h"
17 18
18 namespace media { 19 namespace media {
19 namespace mp4 { 20 namespace mp4 {
20 21
21 MP4StreamParser::MP4StreamParser() 22 MP4StreamParser::MP4StreamParser()
22 : state_(kWaitingForInit), 23 : state_(kWaitingForInit),
23 moof_head_(0), 24 moof_head_(0),
24 mdat_tail_(0), 25 mdat_tail_(0),
25 has_audio_(false), 26 has_audio_(false),
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (track->media.handler.type == kAudio && !audio_config.IsValidConfig()) { 156 if (track->media.handler.type == kAudio && !audio_config.IsValidConfig()) {
156 RCHECK(!samp_descr.audio_entries.empty()); 157 RCHECK(!samp_descr.audio_entries.empty());
157 const AudioSampleEntry& entry = samp_descr.audio_entries[0]; 158 const AudioSampleEntry& entry = samp_descr.audio_entries[0];
158 159
159 // TODO(strobe): We accept all format values, pending clarification on 160 // TODO(strobe): We accept all format values, pending clarification on
160 // the formats used for encrypted media (http://crbug.com/132351). 161 // the formats used for encrypted media (http://crbug.com/132351).
161 // RCHECK(entry.format == FOURCC_MP4A || 162 // RCHECK(entry.format == FOURCC_MP4A ||
162 // (entry.format == FOURCC_ENCA && 163 // (entry.format == FOURCC_ENCA &&
163 // entry.sinf.format.format == FOURCC_MP4A)); 164 // entry.sinf.format.format == FOURCC_MP4A));
164 165
165 const ChannelLayout layout = 166 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3.
166 AVC::ConvertAACChannelCountToChannelLayout(entry.channelcount); 167 RCHECK(entry.esds.object_type == kISO_14496_3);
167 audio_config.Initialize(kCodecAAC, entry.samplesize, layout, 168 aac_ = entry.esds.aac;
168 entry.samplerate, NULL, 0, false); 169 audio_config.Initialize(kCodecAAC, entry.samplesize,
170 aac_.channel_layout(), aac_.frequency(),
171 NULL, 0, false);
172
169 has_audio_ = true; 173 has_audio_ = true;
170 audio_track_id_ = track->header.track_id; 174 audio_track_id_ = track->header.track_id;
171 } 175 }
172 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { 176 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) {
173 RCHECK(!samp_descr.video_entries.empty()); 177 RCHECK(!samp_descr.video_entries.empty());
174 const VideoSampleEntry& entry = samp_descr.video_entries[0]; 178 const VideoSampleEntry& entry = samp_descr.video_entries[0];
175 179
176 // RCHECK(entry.format == FOURCC_AVC1 || 180 // RCHECK(entry.format == FOURCC_AVC1 ||
177 // (entry.format == FOURCC_ENCV && 181 // (entry.format == FOURCC_ENCV &&
178 // entry.sinf.format.format == FOURCC_AVC1)); 182 // entry.sinf.format.format == FOURCC_AVC1));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 avc_config = &moov_->tracks[t].media.information. 288 avc_config = &moov_->tracks[t].media.information.
285 sample_table.description.video_entries[0].avcc; 289 sample_table.description.video_entries[0].avcc;
286 break; 290 break;
287 } 291 }
288 } 292 }
289 RCHECK(avc_config != NULL); 293 RCHECK(avc_config != NULL);
290 RCHECK(AVC::InsertParameterSets(*avc_config, &frame_buf)); 294 RCHECK(AVC::InsertParameterSets(*avc_config, &frame_buf));
291 } 295 }
292 } 296 }
293 297
298 if (audio) {
299 aac_.ConvertEsdsToADTS(&frame_buf);
300 }
301
294 scoped_refptr<StreamParserBuffer> stream_buf = 302 scoped_refptr<StreamParserBuffer> stream_buf =
295 StreamParserBuffer::CopyFrom(&frame_buf[0], frame_buf.size(), 303 StreamParserBuffer::CopyFrom(&frame_buf[0], frame_buf.size(),
296 runs_.is_keyframe()); 304 runs_.is_keyframe());
297 305
298 stream_buf->SetDuration(runs_.duration()); 306 stream_buf->SetDuration(runs_.duration());
299 stream_buf->SetTimestamp(runs_.cts()); 307 stream_buf->SetTimestamp(runs_.cts());
300 stream_buf->SetDecodeTimestamp(runs_.dts()); 308 stream_buf->SetDecodeTimestamp(runs_.dts());
301 309
302 DVLOG(3) << "Pushing frame: aud=" << audio 310 DVLOG(3) << "Pushing frame: aud=" << audio
303 << ", key=" << runs_.is_keyframe() 311 << ", key=" << runs_.is_keyframe()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return true; 364 return true;
357 } 365 }
358 366
359 void MP4StreamParser::ChangeState(State new_state) { 367 void MP4StreamParser::ChangeState(State new_state) {
360 DVLOG(2) << "Changing state: " << new_state; 368 DVLOG(2) << "Changing state: " << new_state;
361 state_ = new_state; 369 state_ = new_state;
362 } 370 }
363 371
364 } // namespace mp4 372 } // namespace mp4
365 } // namespace media 373 } // namespace media
OLDNEW
« no previous file with comments | « media/mp4/mp4_stream_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698