OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/formats/mp4/mp4_stream_parser.h" | 5 #include "media/formats/mp4/mp4_stream_parser.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 if (track->media.handler.type == kAudio && !audio_config.IsValidConfig()) { | 210 if (track->media.handler.type == kAudio && !audio_config.IsValidConfig()) { |
211 RCHECK(!samp_descr.audio_entries.empty()); | 211 RCHECK(!samp_descr.audio_entries.empty()); |
212 | 212 |
213 // It is not uncommon to find otherwise-valid files with incorrect sample | 213 // It is not uncommon to find otherwise-valid files with incorrect sample |
214 // description indices, so we fail gracefully in that case. | 214 // description indices, so we fail gracefully in that case. |
215 if (desc_idx >= samp_descr.audio_entries.size()) | 215 if (desc_idx >= samp_descr.audio_entries.size()) |
216 desc_idx = 0; | 216 desc_idx = 0; |
217 const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx]; | 217 const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx]; |
218 const AAC& aac = entry.esds.aac; | 218 const AAC& aac = entry.esds.aac; |
219 | 219 |
220 if (!(entry.format == FOURCC_MP4A || | 220 FourCC audio_format = (entry.format == FOURCC_ENCA) |
ddorwin
2016/01/04 23:22:17
If you can provide some context on this (basically
servolk
2016/01/07 02:30:04
FOURCC_ENCA just means that audio stream is encryp
| |
221 (entry.format == FOURCC_ENCA && | 221 ? entry.sinf.format.format |
222 entry.sinf.format.format == FOURCC_MP4A))) { | 222 : entry.format; |
ddorwin
2016/01/04 23:22:17
nit: Empty line after since this is it's own chunk
servolk
2016/01/07 02:30:04
Done.
| |
223 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
224 if (audio_format != FOURCC_MP4A && audio_format != FOURCC_A52 && | |
ddorwin
2016/01/04 23:22:17
I think a switch statement will be cleaner and avo
servolk
2016/01/07 02:30:04
Now that I've removed a52/a52b the ifs are only fo
| |
225 audio_format != FOURCC_A52b && audio_format != FOURCC_AC3 && | |
ddorwin
2016/01/04 23:22:17
I see AC3 and EAC3 values are mixed here. Should t
servolk
2016/01/07 02:30:04
Now, with only one value for AC3/EAC3 each, this l
| |
226 audio_format != FOURCC_AC_3 && audio_format != FOURCC_EAC3) { | |
227 #else | |
228 if (audio_format != FOURCC_MP4A) { | |
229 #endif | |
223 MEDIA_LOG(ERROR, media_log_) << "Unsupported audio format 0x" | 230 MEDIA_LOG(ERROR, media_log_) << "Unsupported audio format 0x" |
224 << std::hex << entry.format | 231 << std::hex << entry.format |
225 << " in stsd box."; | 232 << " in stsd box."; |
226 return false; | 233 return false; |
227 } | 234 } |
228 | 235 |
229 uint8_t audio_type = entry.esds.object_type; | 236 uint8_t audio_type = entry.esds.object_type; |
237 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
238 if (audio_type == kForbidden && | |
ddorwin
2016/01/04 23:22:17
No need to duplicate the kForbidden check. Put eve
servolk
2016/01/07 02:30:04
kForbidden means the mp4 parser used by MSE doesn'
| |
239 (audio_format == FOURCC_EAC3 || audio_format == FOURCC_A52b)) { | |
ddorwin
2016/01/04 23:22:17
With the change above, a switch statement probably
servolk
2016/01/07 02:30:04
Now that we have only two values, I believe if sho
| |
240 audio_type = kEAC3; | |
241 } | |
242 if (audio_type == kForbidden && | |
243 (audio_format == FOURCC_A52 || audio_format == FOURCC_AC3 || | |
ddorwin
2016/01/04 23:22:17
AC3 has been before EAC3 except here.
servolk
2016/01/07 02:30:04
Fixed the ordering above. AC3 should be before EAC
| |
244 audio_format == FOURCC_AC_3)) { | |
245 audio_type = kAC3; | |
246 } | |
247 #endif | |
230 DVLOG(1) << "audio_type " << std::hex << static_cast<int>(audio_type); | 248 DVLOG(1) << "audio_type " << std::hex << static_cast<int>(audio_type); |
231 if (audio_object_types_.find(audio_type) == audio_object_types_.end()) { | 249 if (audio_object_types_.find(audio_type) == audio_object_types_.end()) { |
232 MEDIA_LOG(ERROR, media_log_) | 250 MEDIA_LOG(ERROR, media_log_) |
233 << "audio object type 0x" << std::hex << audio_type | 251 << "audio object type 0x" << std::hex << audio_type |
234 << " does not match what is specified in the" | 252 << " does not match what is specified in the" |
235 << " mimetype."; | 253 << " mimetype."; |
236 return false; | 254 return false; |
237 } | 255 } |
238 | 256 |
239 AudioCodec codec = kUnknownAudioCodec; | 257 AudioCodec codec = kUnknownAudioCodec; |
240 ChannelLayout channel_layout = CHANNEL_LAYOUT_NONE; | 258 ChannelLayout channel_layout = CHANNEL_LAYOUT_NONE; |
241 int sample_per_second = 0; | 259 int sample_per_second = 0; |
242 std::vector<uint8_t> extra_data; | 260 std::vector<uint8_t> extra_data; |
243 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or | 261 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or |
244 // supported MPEG2 AAC varients. | 262 // supported MPEG2 AAC varients. |
245 if (ESDescriptor::IsAAC(audio_type)) { | 263 if (ESDescriptor::IsAAC(audio_type)) { |
246 codec = kCodecAAC; | 264 codec = kCodecAAC; |
247 channel_layout = aac.GetChannelLayout(has_sbr_); | 265 channel_layout = aac.GetChannelLayout(has_sbr_); |
248 sample_per_second = aac.GetOutputSamplesPerSecond(has_sbr_); | 266 sample_per_second = aac.GetOutputSamplesPerSecond(has_sbr_); |
249 #if defined(OS_ANDROID) | 267 #if defined(OS_ANDROID) |
250 extra_data = aac.codec_specific_data(); | 268 extra_data = aac.codec_specific_data(); |
251 #endif | 269 #endif |
270 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
271 } else if (audio_type == kAC3) { | |
272 codec = kCodecAC3; | |
273 channel_layout = GuessChannelLayout(entry.channelcount); | |
274 sample_per_second = entry.samplerate; | |
275 } else if (audio_type == kEAC3) { | |
276 codec = kCodecEAC3; | |
277 channel_layout = GuessChannelLayout(entry.channelcount); | |
278 sample_per_second = entry.samplerate; | |
279 #endif | |
252 } else { | 280 } else { |
253 MEDIA_LOG(ERROR, media_log_) << "Unsupported audio object type 0x" | 281 MEDIA_LOG(ERROR, media_log_) << "Unsupported audio object type 0x" |
254 << std::hex << audio_type << " in esds."; | 282 << std::hex << audio_type << " in esds."; |
255 return false; | 283 return false; |
256 } | 284 } |
257 | 285 |
258 SampleFormat sample_format; | 286 SampleFormat sample_format; |
259 if (entry.samplesize == 8) { | 287 if (entry.samplesize == 8) { |
260 sample_format = kSampleFormatU8; | 288 sample_format = kSampleFormatU8; |
261 } else if (entry.samplesize == 16) { | 289 } else if (entry.samplesize == 16) { |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 runs.AdvanceSample(); | 652 runs.AdvanceSample(); |
625 } | 653 } |
626 runs.AdvanceRun(); | 654 runs.AdvanceRun(); |
627 } | 655 } |
628 | 656 |
629 return true; | 657 return true; |
630 } | 658 } |
631 | 659 |
632 } // namespace mp4 | 660 } // namespace mp4 |
633 } // namespace media | 661 } // namespace media |
OLD | NEW |