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