Chromium Code Reviews| 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" |
| 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/base/video_util.h" | 14 #include "media/base/video_util.h" |
| 15 #include "media/mp4/box_definitions.h" | 15 #include "media/mp4/box_definitions.h" |
| 16 #include "media/mp4/box_reader.h" | 16 #include "media/mp4/box_reader.h" |
| 17 #include "media/mp4/es_descriptor.h" | 17 #include "media/mp4/es_descriptor.h" |
| 18 #include "media/mp4/rcheck.h" | 18 #include "media/mp4/rcheck.h" |
| 19 | 19 |
| 20 namespace media { | 20 namespace media { |
| 21 namespace mp4 { | 21 namespace mp4 { |
| 22 | 22 |
| 23 // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed. | 23 // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed. |
| 24 static const char kMp4InitDataType[] = "video/mp4"; | 24 static const char kMp4InitDataType[] = "video/mp4"; |
| 25 | 25 |
| 26 MP4StreamParser::MP4StreamParser(bool has_sbr) | 26 MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types, |
| 27 bool has_sbr) | |
| 27 : state_(kWaitingForInit), | 28 : state_(kWaitingForInit), |
| 28 moof_head_(0), | 29 moof_head_(0), |
| 29 mdat_tail_(0), | 30 mdat_tail_(0), |
| 30 has_audio_(false), | 31 has_audio_(false), |
| 31 has_video_(false), | 32 has_video_(false), |
| 32 audio_track_id_(0), | 33 audio_track_id_(0), |
| 33 video_track_id_(0), | 34 video_track_id_(0), |
| 35 audio_object_types_(audio_object_types), | |
| 34 has_sbr_(has_sbr) { | 36 has_sbr_(has_sbr) { |
| 35 } | 37 } |
| 36 | 38 |
| 37 MP4StreamParser::~MP4StreamParser() {} | 39 MP4StreamParser::~MP4StreamParser() {} |
| 38 | 40 |
| 39 void MP4StreamParser::Init(const InitCB& init_cb, | 41 void MP4StreamParser::Init(const InitCB& init_cb, |
| 40 const NewConfigCB& config_cb, | 42 const NewConfigCB& config_cb, |
| 41 const NewBuffersCB& audio_cb, | 43 const NewBuffersCB& audio_cb, |
| 42 const NewBuffersCB& video_cb, | 44 const NewBuffersCB& video_cb, |
| 43 const NeedKeyCB& need_key_cb, | 45 const NeedKeyCB& need_key_cb, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx]; | 195 const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx]; |
| 194 const AAC& aac = entry.esds.aac; | 196 const AAC& aac = entry.esds.aac; |
| 195 | 197 |
| 196 if (!(entry.format == FOURCC_MP4A || | 198 if (!(entry.format == FOURCC_MP4A || |
| 197 (entry.format == FOURCC_ENCA && | 199 (entry.format == FOURCC_ENCA && |
| 198 entry.sinf.format.format == FOURCC_MP4A))) { | 200 entry.sinf.format.format == FOURCC_MP4A))) { |
| 199 MEDIA_LOG(log_cb_) << "Unsupported audio format 0x" | 201 MEDIA_LOG(log_cb_) << "Unsupported audio format 0x" |
| 200 << std::hex << entry.format << " in stsd box."; | 202 << std::hex << entry.format << " in stsd box."; |
| 201 return false; | 203 return false; |
| 202 } | 204 } |
| 203 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3. | 205 |
| 204 if (entry.esds.object_type != kISO_14496_3) { | 206 int audio_type = entry.esds.object_type; |
| 205 MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex | 207 if (audio_object_types_.find(audio_type) == audio_object_types_.end()) { |
| 206 << static_cast<int>(entry.esds.object_type) | 208 MEDIA_LOG(log_cb_) << "audio object type 0x" << std::hex << audio_type |
| 207 << " in esds."; | 209 << " does not match what is specified in the" |
| 210 << " mimetype."; | |
| 208 return false; | 211 return false; |
| 209 } | 212 } |
| 210 | 213 |
| 214 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or | |
| 215 // supported MPEG2 AAC varients. | |
| 216 if (audio_type != kISO_14496_3 && audio_type != kISO_13818_7_AAC_LC) { | |
|
scherkus (not reviewing)
2013/01/08 23:51:08
worth switch+case-ifying against future changes to
acolwell GONE FROM CHROMIUM
2013/01/16 17:35:09
Unfortunately since audio_type comes directly from
| |
| 217 MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex | |
| 218 << audio_type << " in esds."; | |
| 219 return false; | |
| 220 } | |
| 221 | |
| 211 SampleFormat sample_format; | 222 SampleFormat sample_format; |
| 212 if (entry.samplesize == 8) { | 223 if (entry.samplesize == 8) { |
| 213 sample_format = kSampleFormatU8; | 224 sample_format = kSampleFormatU8; |
| 214 } else if (entry.samplesize == 16) { | 225 } else if (entry.samplesize == 16) { |
| 215 sample_format = kSampleFormatS16; | 226 sample_format = kSampleFormatS16; |
| 216 } else if (entry.samplesize == 32) { | 227 } else if (entry.samplesize == 32) { |
| 217 sample_format = kSampleFormatS32; | 228 sample_format = kSampleFormatS32; |
| 218 } else { | 229 } else { |
| 219 LOG(ERROR) << "Unsupported sample size."; | 230 LOG(ERROR) << "Unsupported sample size."; |
| 220 return false; | 231 return false; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 return !err; | 530 return !err; |
| 520 } | 531 } |
| 521 | 532 |
| 522 void MP4StreamParser::ChangeState(State new_state) { | 533 void MP4StreamParser::ChangeState(State new_state) { |
| 523 DVLOG(2) << "Changing state: " << new_state; | 534 DVLOG(2) << "Changing state: " << new_state; |
| 524 state_ = new_state; | 535 state_ = new_state; |
| 525 } | 536 } |
| 526 | 537 |
| 527 } // namespace mp4 | 538 } // namespace mp4 |
| 528 } // namespace media | 539 } // namespace media |
| OLD | NEW |