diff options
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 1 | ||||
-rw-r--r-- | media/base/audio_decoder_config.h | 1 | ||||
-rw-r--r-- | media/base/media_switches.cc | 3 | ||||
-rw-r--r-- | media/base/media_switches.h | 2 | ||||
-rw-r--r-- | media/filters/stream_parser_factory.cc | 23 | ||||
-rw-r--r-- | media/media.gyp | 5 | ||||
-rw-r--r-- | media/mp4/box_definitions.cc | 3 | ||||
-rw-r--r-- | media/mp4/es_descriptor.cc | 5 | ||||
-rw-r--r-- | media/mp4/es_descriptor.h | 6 | ||||
-rw-r--r-- | media/mp4/fourccs.h | 1 | ||||
-rw-r--r-- | media/mp4/mp4_stream_parser.cc | 29 |
11 files changed, 70 insertions, 9 deletions
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 3498062..a0eda74 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -884,6 +884,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kEnableOpusPlayback, switches::kEnableVp9Playback, switches::kEnableVp8AlphaPlayback, + switches::kEnableEac3Playback, switches::kForceDeviceScaleFactor, switches::kFullMemoryCrashReport, #if !defined (GOOGLE_CHROME_BUILD) diff --git a/media/base/audio_decoder_config.h b/media/base/audio_decoder_config.h index 455fea0..5b886e0 100644 --- a/media/base/audio_decoder_config.h +++ b/media/base/audio_decoder_config.h @@ -30,6 +30,7 @@ enum AudioCodec { kCodecPCM_S16BE, kCodecPCM_S24BE, kCodecOpus, + kCodecEAC3, // DO NOT ADD RANDOM AUDIO CODECS! // // The only acceptable time to add a new codec is if there is production code diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc index 7c1ab90..c0de2e9 100644 --- a/media/base/media_switches.cc +++ b/media/base/media_switches.cc @@ -60,6 +60,9 @@ const char kEnableVp9Playback[] = "enable-vp9-playback"; // Enables VP8 Alpha playback in media elements. const char kEnableVp8AlphaPlayback[] = "enable-vp8-alpha-playback"; +// Enable EAC3 playback in MSE. +const char kEnableEac3Playback[] = "enable-eac3-playback"; + #if defined(OS_WIN) const char kWaveOutBuffers[] = "waveout-buffers"; #endif diff --git a/media/base/media_switches.h b/media/base/media_switches.h index e9b6ab9..b6eb468 100644 --- a/media/base/media_switches.h +++ b/media/base/media_switches.h @@ -46,6 +46,8 @@ MEDIA_EXPORT extern const char kEnableVp9Playback[]; MEDIA_EXPORT extern const char kEnableVp8AlphaPlayback[]; +MEDIA_EXPORT extern const char kEnableEac3Playback[]; + #if defined(OS_WIN) MEDIA_EXPORT extern const char kWaveOutBuffers[]; #endif diff --git a/media/filters/stream_parser_factory.cc b/media/filters/stream_parser_factory.cc index 93b0e8b..8f4a55f 100644 --- a/media/filters/stream_parser_factory.cc +++ b/media/filters/stream_parser_factory.cc @@ -108,6 +108,12 @@ static const CodecInfo kMPEG2AACLCCodecInfo = { "mp4a.67", CodecInfo::AUDIO, NULL }; +#if defined(ENABLE_EAC3_PLAYBACK) +static const CodecInfo kEAC3CodecInfo = { + "mp4a.a6", CodecInfo::AUDIO, NULL +}; +#endif + static const CodecInfo* kVideoMP4Codecs[] = { &kH264CodecInfo, &kMPEG4AACCodecInfo, @@ -118,6 +124,9 @@ static const CodecInfo* kVideoMP4Codecs[] = { static const CodecInfo* kAudioMP4Codecs[] = { &kMPEG4AACCodecInfo, &kMPEG2AACLCCodecInfo, +#if defined(ENABLE_EAC3_PLAYBACK) + &kEAC3CodecInfo, +#endif NULL }; @@ -125,6 +134,10 @@ static media::StreamParser* BuildMP4Parser( const std::vector<std::string>& codecs, const media::LogCB& log_cb) { std::set<int> audio_object_types; bool has_sbr = false; +#if defined(ENABLE_EAC3_PLAYBACK) + bool enable_eac3 = CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableEac3Playback); +#endif for (size_t i = 0; i < codecs.size(); ++i) { std::string codec_id = codecs[i]; if (MatchPattern(codec_id, kMPEG2AACLCCodecInfo.pattern)) { @@ -139,6 +152,10 @@ static media::StreamParser* BuildMP4Parser( has_sbr = true; break; } +#if defined(ENABLE_EAC3_PLAYBACK) + } else if (enable_eac3 && MatchPattern(codec_id, kEAC3CodecInfo.pattern)) { + audio_object_types.insert(media::mp4::kEAC3); +#endif } } @@ -204,6 +221,12 @@ static bool IsSupported(const std::string& type, const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); switch (codec_type) { case CodecInfo::AUDIO: +#if defined(ENABLE_EAC3_PLAYBACK) + if (MatchPattern(codec_id, kEAC3CodecInfo.pattern) && + !cmd_line->HasSwitch(switches::kEnableEac3Playback)) { + return false; + } +#endif *has_audio = true; break; case CodecInfo::VIDEO: diff --git a/media/media.gyp b/media/media.gyp index 692e7bc..3e20cc6 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -881,6 +881,11 @@ 'media_sse', ], }], + ['google_tv == 1', { + 'defines': [ + 'ENABLE_EAC3_PLAYBACK', + ], + }], ], 'target_conditions': [ ['OS == "ios"', { diff --git a/media/mp4/box_definitions.cc b/media/mp4/box_definitions.cc index 6c645be..e7f1693 100644 --- a/media/mp4/box_definitions.cc +++ b/media/mp4/box_definitions.cc @@ -467,7 +467,8 @@ bool AudioSampleEntry::Parse(BoxReader* reader) { } } - RCHECK(reader->ReadChild(&esds)); + // ESDS is not valid in case of EAC3. + RCHECK(reader->MaybeReadChild(&esds)); return true; } diff --git a/media/mp4/es_descriptor.cc b/media/mp4/es_descriptor.cc index f9480dd..8517b82 100644 --- a/media/mp4/es_descriptor.cc +++ b/media/mp4/es_descriptor.cc @@ -31,6 +31,11 @@ namespace media { namespace mp4 { +// static +bool ESDescriptor::IsAAC(uint8 object_type) { + return object_type == kISO_14496_3 || object_type == kISO_13818_7_AAC_LC; +} + ESDescriptor::ESDescriptor() : object_type_(kForbidden) { } diff --git a/media/mp4/es_descriptor.h b/media/mp4/es_descriptor.h index 65b9cd2..36e1bf2 100644 --- a/media/mp4/es_descriptor.h +++ b/media/mp4/es_descriptor.h @@ -21,7 +21,8 @@ namespace mp4 { enum ObjectType { kForbidden = 0, kISO_14496_3 = 0x40, // MPEG4 AAC - kISO_13818_7_AAC_LC = 0x67 // MPEG2 AAC-LC + kISO_13818_7_AAC_LC = 0x67, // MPEG2 AAC-LC + kEAC3 = 0xa6 // Dolby Digital Plus }; // This class parse object type and decoder specific information from an @@ -29,6 +30,9 @@ enum ObjectType { // Please refer to ISO 14496 Part 1 7.2.6.5 for more details. class MEDIA_EXPORT ESDescriptor { public: + // Utility function to check if the given object type is AAC. + static bool IsAAC(uint8 object_type); + ESDescriptor(); ~ESDescriptor(); diff --git a/media/mp4/fourccs.h b/media/mp4/fourccs.h index 642a9f5..b71d2ff3 100644 --- a/media/mp4/fourccs.h +++ b/media/mp4/fourccs.h @@ -19,6 +19,7 @@ enum FourCC { FOURCC_CO64 = 0x636f3634, FOURCC_CTTS = 0x63747473, FOURCC_DINF = 0x64696e66, + FOURCC_EAC3 = 0x65632d33, FOURCC_EDTS = 0x65647473, FOURCC_ELST = 0x656c7374, FOURCC_ENCA = 0x656e6361, diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc index 1909600..5898615 100644 --- a/media/mp4/mp4_stream_parser.cc +++ b/media/mp4/mp4_stream_parser.cc @@ -197,7 +197,7 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx]; const AAC& aac = entry.esds.aac; - if (!(entry.format == FOURCC_MP4A || + if (!(entry.format == FOURCC_MP4A || entry.format == FOURCC_EAC3 || (entry.format == FOURCC_ENCA && entry.sinf.format.format == FOURCC_MP4A))) { MEDIA_LOG(log_cb_) << "Unsupported audio format 0x" @@ -205,8 +205,11 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { return false; } - int audio_type = entry.esds.object_type; + uint8 audio_type = entry.esds.object_type; DVLOG(1) << "audio_type " << std::hex << audio_type; + if (audio_type == kForbidden && entry.format == FOURCC_EAC3) { + audio_type = kEAC3; + } 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" @@ -214,9 +217,20 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { return false; } + AudioCodec codec = kUnknownAudioCodec; + ChannelLayout channel_layout = CHANNEL_LAYOUT_NONE; + int sample_per_second = 0; // 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) { + if (ESDescriptor::IsAAC(audio_type)) { + codec = kCodecAAC; + channel_layout = aac.GetChannelLayout(has_sbr_); + sample_per_second = aac.GetOutputSamplesPerSecond(has_sbr_); + } else if (audio_type == kEAC3) { + codec = kCodecEAC3; + channel_layout = GuessChannelLayout(entry.channelcount); + sample_per_second = entry.samplerate; + } else { MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex << audio_type << " in esds."; return false; @@ -236,9 +250,9 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) { is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_; - audio_config.Initialize(kCodecAAC, sample_format, - aac.GetChannelLayout(has_sbr_), - aac.GetOutputSamplesPerSecond(has_sbr_), + audio_config.Initialize(codec, sample_format, + channel_layout, + sample_per_second, NULL, 0, is_audio_track_encrypted_, false); has_audio_ = true; audio_track_id_ = track->header.track_id; @@ -455,7 +469,8 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, } if (audio) { - if (!PrepareAACBuffer(runs_->audio_description().esds.aac, + if (ESDescriptor::IsAAC(runs_->audio_description().esds.object_type) && + !PrepareAACBuffer(runs_->audio_description().esds.aac, &frame_buf, &subsamples)) { MEDIA_LOG(log_cb_) << "Failed to prepare AAC sample for decode"; *err = true; |