OLD | NEW |
---|---|
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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "media/base/audio_decoder_config.h" | 10 #include "media/base/audio_decoder_config.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 if (track->media.handler.type == kAudio && !audio_config.IsValidConfig()) { | 156 if (track->media.handler.type == kAudio && !audio_config.IsValidConfig()) { |
157 RCHECK(!samp_descr.audio_entries.empty()); | 157 RCHECK(!samp_descr.audio_entries.empty()); |
158 const AudioSampleEntry& entry = samp_descr.audio_entries[0]; | 158 const AudioSampleEntry& entry = samp_descr.audio_entries[0]; |
159 | 159 |
160 // TODO(strobe): We accept all format values, pending clarification on | 160 // TODO(strobe): We accept all format values, pending clarification on |
161 // the formats used for encrypted media (http://crbug.com/132351). | 161 // the formats used for encrypted media (http://crbug.com/132351). |
162 // RCHECK(entry.format == FOURCC_MP4A || | 162 // RCHECK(entry.format == FOURCC_MP4A || |
163 // (entry.format == FOURCC_ENCA && | 163 // (entry.format == FOURCC_ENCA && |
164 // entry.sinf.format.format == FOURCC_MP4A)); | 164 // entry.sinf.format.format == FOURCC_MP4A)); |
165 | 165 |
166 const ChannelLayout layout = | 166 aac_ = entry.esds.aac; |
acolwell GONE FROM CHROMIUM
2012/06/28 17:31:25
What protects this code from other audio codecs be
| |
167 AVC::ConvertAACChannelCountToChannelLayout(entry.channelcount); | 167 audio_config.Initialize(kCodecAAC, entry.samplesize, |
168 audio_config.Initialize(kCodecAAC, entry.samplesize, layout, | 168 aac_.channel_layout(), aac_.frequency(), |
169 entry.samplerate, NULL, 0, false); | 169 NULL, 0, false); |
170 | |
170 has_audio_ = true; | 171 has_audio_ = true; |
171 audio_track_id_ = track->header.track_id; | 172 audio_track_id_ = track->header.track_id; |
172 } | 173 } |
173 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { | 174 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { |
174 RCHECK(!samp_descr.video_entries.empty()); | 175 RCHECK(!samp_descr.video_entries.empty()); |
175 const VideoSampleEntry& entry = samp_descr.video_entries[0]; | 176 const VideoSampleEntry& entry = samp_descr.video_entries[0]; |
176 | 177 |
177 // RCHECK(entry.format == FOURCC_AVC1 || | 178 // RCHECK(entry.format == FOURCC_AVC1 || |
178 // (entry.format == FOURCC_ENCV && | 179 // (entry.format == FOURCC_ENCV && |
179 // entry.sinf.format.format == FOURCC_AVC1)); | 180 // entry.sinf.format.format == FOURCC_AVC1)); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 sample_table.description.video_entries[0].avcc; | 281 sample_table.description.video_entries[0].avcc; |
281 break; | 282 break; |
282 } | 283 } |
283 } | 284 } |
284 RCHECK(avc_config != NULL); | 285 RCHECK(avc_config != NULL); |
285 RCHECK(AVC::InsertParameterSets(*avc_config, &frame_buf)); | 286 RCHECK(AVC::InsertParameterSets(*avc_config, &frame_buf)); |
286 parameter_sets_inserted_ = true; | 287 parameter_sets_inserted_ = true; |
287 } | 288 } |
288 } | 289 } |
289 | 290 |
291 if (audio) { | |
292 aac_.ConvertEsdsToADTS(&frame_buf); | |
293 } | |
294 | |
290 scoped_refptr<StreamParserBuffer> stream_buf = | 295 scoped_refptr<StreamParserBuffer> stream_buf = |
291 StreamParserBuffer::CopyFrom(&frame_buf[0], frame_buf.size(), | 296 StreamParserBuffer::CopyFrom(&frame_buf[0], frame_buf.size(), |
292 runs_.is_keyframe()); | 297 runs_.is_keyframe()); |
293 | 298 |
294 stream_buf->SetDuration(runs_.duration()); | 299 stream_buf->SetDuration(runs_.duration()); |
295 // We depend on the decoder performing frame reordering without reordering | 300 // We depend on the decoder performing frame reordering without reordering |
296 // timestamps, and only provide the decode timestamp in the buffer. | 301 // timestamps, and only provide the decode timestamp in the buffer. |
297 stream_buf->SetTimestamp(runs_.dts()); | 302 stream_buf->SetTimestamp(runs_.dts()); |
298 | 303 |
299 DVLOG(3) << "Pushing frame: aud=" << audio | 304 DVLOG(3) << "Pushing frame: aud=" << audio |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 return true; | 357 return true; |
353 } | 358 } |
354 | 359 |
355 void MP4StreamParser::ChangeState(State new_state) { | 360 void MP4StreamParser::ChangeState(State new_state) { |
356 DVLOG(2) << "Changing state: " << new_state; | 361 DVLOG(2) << "Changing state: " << new_state; |
357 state_ = new_state; | 362 state_ = new_state; |
358 } | 363 } |
359 | 364 |
360 } // namespace mp4 | 365 } // namespace mp4 |
361 } // namespace media | 366 } // namespace media |
OLD | NEW |