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/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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 entry.sinf.format.format == FOURCC_MP4A))) { | 195 entry.sinf.format.format == FOURCC_MP4A))) { |
196 LOG(ERROR) << "Unsupported audio format."; | 196 LOG(ERROR) << "Unsupported audio format."; |
197 return false; | 197 return false; |
198 } | 198 } |
199 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3. | 199 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3. |
200 if (entry.esds.object_type != kISO_14496_3) { | 200 if (entry.esds.object_type != kISO_14496_3) { |
201 LOG(ERROR) << "Unsupported audio object type."; | 201 LOG(ERROR) << "Unsupported audio object type."; |
202 return false; | 202 return false; |
203 } | 203 } |
204 | 204 |
| 205 SampleFormat sample_format; |
| 206 if (entry.samplesize == 8) { |
| 207 sample_format = kSampleFormatU8; |
| 208 } else if (entry.samplesize == 16) { |
| 209 sample_format = kSampleFormatS16; |
| 210 } else if (entry.samplesize == 32) { |
| 211 sample_format = kSampleFormatS32; |
| 212 } else { |
| 213 LOG(ERROR) << "Unsupported sample size."; |
| 214 return false; |
| 215 } |
| 216 |
205 bool is_encrypted = entry.sinf.info.track_encryption.is_encrypted; | 217 bool is_encrypted = entry.sinf.info.track_encryption.is_encrypted; |
206 audio_config.Initialize(kCodecAAC, entry.samplesize, | 218 audio_config.Initialize(kCodecAAC, entry.samplesize, |
207 aac.channel_layout(), | 219 aac.channel_layout(), |
208 aac.GetOutputSamplesPerSecond(has_sbr_), | 220 aac.GetOutputSamplesPerSecond(has_sbr_), |
209 NULL, 0, is_encrypted, false); | 221 NULL, 0, sample_format, is_encrypted, false); |
210 has_audio_ = true; | 222 has_audio_ = true; |
211 audio_track_id_ = track->header.track_id; | 223 audio_track_id_ = track->header.track_id; |
212 } | 224 } |
213 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { | 225 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { |
214 RCHECK(!samp_descr.video_entries.empty()); | 226 RCHECK(!samp_descr.video_entries.empty()); |
215 if (desc_idx >= samp_descr.video_entries.size()) | 227 if (desc_idx >= samp_descr.video_entries.size()) |
216 desc_idx = 0; | 228 desc_idx = 0; |
217 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; | 229 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; |
218 | 230 |
219 if (!(entry.format == FOURCC_AVC1 || | 231 if (!(entry.format == FOURCC_AVC1 || |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 return !err; | 511 return !err; |
500 } | 512 } |
501 | 513 |
502 void MP4StreamParser::ChangeState(State new_state) { | 514 void MP4StreamParser::ChangeState(State new_state) { |
503 DVLOG(2) << "Changing state: " << new_state; | 515 DVLOG(2) << "Changing state: " << new_state; |
504 state_ = new_state; | 516 state_ = new_state; |
505 } | 517 } |
506 | 518 |
507 } // namespace mp4 | 519 } // namespace mp4 |
508 } // namespace media | 520 } // namespace media |
OLD | NEW |