diff options
author | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-16 23:03:42 +0000 |
---|---|---|
committer | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-16 23:03:42 +0000 |
commit | bd4380a58a06e0614264c071fbb5a3e4d18ac0d2 (patch) | |
tree | b2b3cba527ba90bf12b7545f53b0cf7df0da16f5 /media | |
parent | e62624d9f5116b16a20a5ee6c03b90347959337f (diff) | |
download | chromium_src-bd4380a58a06e0614264c071fbb5a3e4d18ac0d2.zip chromium_src-bd4380a58a06e0614264c071fbb5a3e4d18ac0d2.tar.gz chromium_src-bd4380a58a06e0614264c071fbb5a3e4d18ac0d2.tar.bz2 |
Add support for accepting MPEG2 AAC-LC bitstreams.
BUG=168891
TEST=MP4StreamParserTest.TestMPEG2_AAC_LC
Review URL: https://chromiumcodereview.appspot.com/11819013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/filters/chunk_demuxer.cc | 30 | ||||
-rw-r--r-- | media/mp4/es_descriptor.h | 3 | ||||
-rw-r--r-- | media/mp4/mp4_stream_parser.cc | 22 | ||||
-rw-r--r-- | media/mp4/mp4_stream_parser.h | 5 | ||||
-rw-r--r-- | media/mp4/mp4_stream_parser_unittest.cc | 14 |
5 files changed, 61 insertions, 13 deletions
diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc index 0df3551..1f091c3 100644 --- a/media/filters/chunk_demuxer.cc +++ b/media/filters/chunk_demuxer.cc @@ -17,6 +17,7 @@ #include "media/base/stream_parser_buffer.h" #include "media/base/video_decoder_config.h" #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) +#include "media/mp4/es_descriptor.h" #include "media/mp4/mp4_stream_parser.h" #endif #include "media/webm/webm_stream_parser.h" @@ -59,16 +60,30 @@ static StreamParser* BuildWebMParser(const std::vector<std::string>& codecs) { #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) static const CodecInfo kH264CodecInfo = { "avc1.*", DemuxerStream::VIDEO }; -static const CodecInfo kAACCodecInfo = { "mp4a.40.*", DemuxerStream::AUDIO }; +static const CodecInfo kMPEG4AACLCCodecInfo = { + "mp4a.40.2", DemuxerStream::AUDIO +}; + +static const CodecInfo kMPEG4AACSBRCodecInfo = { + "mp4a.40.5", DemuxerStream::AUDIO +}; + +static const CodecInfo kMPEG2AACLCCodecInfo = { + "mp4a.67", DemuxerStream::AUDIO +}; static const CodecInfo* kVideoMP4Codecs[] = { &kH264CodecInfo, - &kAACCodecInfo, + &kMPEG4AACLCCodecInfo, + &kMPEG4AACSBRCodecInfo, + &kMPEG2AACLCCodecInfo, NULL }; static const CodecInfo* kAudioMP4Codecs[] = { - &kAACCodecInfo, + &kMPEG4AACLCCodecInfo, + &kMPEG4AACSBRCodecInfo, + &kMPEG2AACLCCodecInfo, NULL }; @@ -76,15 +91,22 @@ static const CodecInfo* kAudioMP4Codecs[] = { static const char* kSBRCodecId = "mp4a.40.5"; static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs) { + std::set<int> audio_object_types; bool has_sbr = false; for (size_t i = 0; i < codecs.size(); ++i) { + if (MatchPattern(codecs[i], kMPEG2AACLCCodecInfo.pattern)) { + audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); + } else { + audio_object_types.insert(mp4::kISO_14496_3); + } + if (codecs[i] == kSBRCodecId) { has_sbr = true; break; } } - return new mp4::MP4StreamParser(has_sbr); + return new mp4::MP4StreamParser(audio_object_types, has_sbr); } #endif diff --git a/media/mp4/es_descriptor.h b/media/mp4/es_descriptor.h index daddbc0..65b9cd2 100644 --- a/media/mp4/es_descriptor.h +++ b/media/mp4/es_descriptor.h @@ -20,7 +20,8 @@ namespace mp4 { // objectTypeIndication Values. Only values currently in use are included. enum ObjectType { kForbidden = 0, - kISO_14496_3 = 0x40 // MPEG4 AAC + kISO_14496_3 = 0x40, // MPEG4 AAC + kISO_13818_7_AAC_LC = 0x67 // MPEG2 AAC-LC }; // This class parse object type and decoder specific information from an diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc index 3f9b016..970c516 100644 --- a/media/mp4/mp4_stream_parser.cc +++ b/media/mp4/mp4_stream_parser.cc @@ -23,7 +23,8 @@ namespace mp4 { // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed. static const char kMp4InitDataType[] = "video/mp4"; -MP4StreamParser::MP4StreamParser(bool has_sbr) +MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types, + bool has_sbr) : state_(kWaitingForInit), moof_head_(0), mdat_tail_(0), @@ -31,6 +32,7 @@ MP4StreamParser::MP4StreamParser(bool has_sbr) has_video_(false), audio_track_id_(0), video_track_id_(0), + audio_object_types_(audio_object_types), has_sbr_(has_sbr), is_audio_track_encrypted_(false), is_video_track_encrypted_(false) { @@ -202,11 +204,21 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { << std::hex << entry.format << " in stsd box."; return false; } - // Check if it is MPEG4 AAC defined in ISO 14496 Part 3. - if (entry.esds.object_type != kISO_14496_3) { + + int audio_type = entry.esds.object_type; + DVLOG(1) << "audio_type " << std::hex << audio_type; + if (audio_object_types_.find(audio_type) == audio_object_types_.end()) { + MEDIA_LOG(log_cb_) << "audio object type 0x" << std::hex << audio_type + << " does not match what is specified in the" + << " mimetype."; + return false; + } + + // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or + // supported MPEG2 AAC varients. + if (audio_type != kISO_14496_3 && audio_type != kISO_13818_7_AAC_LC) { MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex - << static_cast<int>(entry.esds.object_type) - << " in esds."; + << audio_type << " in esds."; return false; } diff --git a/media/mp4/mp4_stream_parser.h b/media/mp4/mp4_stream_parser.h index 05206ef..0fc65c6 100644 --- a/media/mp4/mp4_stream_parser.h +++ b/media/mp4/mp4_stream_parser.h @@ -5,6 +5,7 @@ #ifndef MEDIA_MP4_MP4_STREAM_PARSER_H_ #define MEDIA_MP4_MP4_STREAM_PARSER_H_ +#include <set> #include <vector> #include "base/basictypes.h" @@ -24,7 +25,7 @@ class BoxReader; class MEDIA_EXPORT MP4StreamParser : public StreamParser { public: - MP4StreamParser(bool has_sbr); + MP4StreamParser(const std::set<int>& audio_object_types, bool has_sbr); virtual ~MP4StreamParser(); virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, @@ -107,6 +108,8 @@ class MEDIA_EXPORT MP4StreamParser : public StreamParser { bool has_video_; uint32 audio_track_id_; uint32 video_track_id_; + // The object types allowed for audio tracks. + std::set<int> audio_object_types_; bool has_sbr_; bool is_audio_track_encrypted_; bool is_video_track_encrypted_; diff --git a/media/mp4/mp4_stream_parser_unittest.cc b/media/mp4/mp4_stream_parser_unittest.cc index 99aa206..252d490 100644 --- a/media/mp4/mp4_stream_parser_unittest.cc +++ b/media/mp4/mp4_stream_parser_unittest.cc @@ -15,6 +15,7 @@ #include "media/base/stream_parser_buffer.h" #include "media/base/test_data_util.h" #include "media/base/video_decoder_config.h" +#include "media/mp4/es_descriptor.h" #include "media/mp4/mp4_stream_parser.h" #include "testing/gtest/include/gtest/gtest.h" @@ -29,8 +30,10 @@ static const char kMp4InitDataType[] = "video/mp4"; class MP4StreamParserTest : public testing::Test { public: MP4StreamParserTest() - : parser_(new MP4StreamParser(false)), - configs_received_(false) { + : configs_received_(false) { + std::set<int> audio_object_types; + audio_object_types.insert(kISO_14496_3); + parser_.reset(new MP4StreamParser(audio_object_types, false)); } protected: @@ -164,6 +167,13 @@ TEST_F(MP4StreamParserTest, TestReinitialization) { 512)); } +TEST_F(MP4StreamParserTest, TestMPEG2_AAC_LC) { + std::set<int> audio_object_types; + audio_object_types.insert(kISO_13818_7_AAC_LC); + parser_.reset(new MP4StreamParser(audio_object_types, false)); + ParseMP4File("bear-mpeg2-aac-only_frag.mp4", 512); +} + // TODO(strobe): Create and test media which uses CENC auxiliary info stored // inside a private box |