From 50ea7241a3824453466085867757e71f7a7d04c3 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Fri, 27 Nov 2015 14:40:36 +1000 Subject: [PATCH] Bug 1169212 - Part 2: Advertise support for ADTS via DecoderTraits. r=jya for mimetype audio/aacp --- dom/media/DecoderTraits.cpp | 24 +++++++++++++++++++++ dom/media/test/test_can_play_type_mpeg.html | 6 +++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index f607204a3b2..3bcb4500652 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -57,6 +57,9 @@ #include "MP3Decoder.h" #include "MP3Demuxer.h" +#include "ADTSDecoder.h" +#include "ADTSDemuxer.h" + namespace mozilla { @@ -354,6 +357,13 @@ IsMP3SupportedType(const nsACString& aType, return MP3Decoder::CanHandleMediaType(aType, aCodecs); } +static bool +IsAACSupportedType(const nsACString& aType, + const nsAString& aCodecs = EmptyString()) +{ + return ADTSDecoder::CanHandleMediaType(aType, aCodecs); +} + /* static */ bool DecoderTraits::ShouldHandleMediaType(const char* aMIMEType) { @@ -414,6 +424,9 @@ DecoderTraits::CanHandleCodecsType(const char* aMIMEType, if (IsMP3SupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) { return CANPLAY_YES; } + if (IsAACSupportedType(nsDependentCString(aMIMEType), aRequestedCodecs)) { + return CANPLAY_YES; + } #ifdef MOZ_OMX_DECODER if (IsOmxSupportedType(nsDependentCString(aMIMEType))) { if (nsDependentCString(aMIMEType).EqualsASCII("audio/mpeg")) { @@ -499,6 +512,9 @@ DecoderTraits::CanHandleMediaType(const char* aMIMEType, if (IsMP3SupportedType(nsDependentCString(aMIMEType))) { return CANPLAY_MAYBE; } + if (IsAACSupportedType(nsDependentCString(aMIMEType))) { + return CANPLAY_MAYBE; + } #ifdef MOZ_GSTREAMER if (GStreamerDecoder::CanHandleMediaType(nsDependentCString(aMIMEType), aHaveRequestedCodecs ? &aRequestedCodecs : nullptr)) { @@ -547,6 +563,10 @@ InstantiateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner) decoder = new MP3Decoder(aOwner); return decoder.forget(); } + if (IsAACSupportedType(aType)) { + decoder = new ADTSDecoder(aOwner); + return decoder.forget(); + } #ifdef MOZ_GSTREAMER if (IsGStreamerSupportedType(aType)) { decoder = new GStreamerDecoder(aOwner); @@ -646,6 +666,9 @@ MediaDecoderReader* DecoderTraits::CreateReader(const nsACString& aType, Abstrac if (IsMP3SupportedType(aType)) { decoderReader = new MediaFormatReader(aDecoder, new mp3::MP3Demuxer(aDecoder->GetResource())); } else + if (IsAACSupportedType(aType)) { + decoderReader = new MediaFormatReader(aDecoder, new ADTSDemuxer(aDecoder->GetResource())); + } else #ifdef MOZ_GSTREAMER if (IsGStreamerSupportedType(aType)) { decoderReader = new GStreamerReader(aDecoder); @@ -725,6 +748,7 @@ bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType) IsMP4SupportedType(aType) || #endif IsMP3SupportedType(aType) || + IsAACSupportedType(aType) || #ifdef MOZ_DIRECTSHOW IsDirectShowSupportedType(aType) || #endif diff --git a/dom/media/test/test_can_play_type_mpeg.html b/dom/media/test/test_can_play_type_mpeg.html index 591cb33c610..ee6dd610d3f 100644 --- a/dom/media/test/test_can_play_type_mpeg.html +++ b/dom/media/test/test_can_play_type_mpeg.html @@ -33,9 +33,9 @@ function check_mp4(v, enabled) { // Not the MIME type that other browsers respond to, so we won't either. check("audio/m4a", ""); check("video/m4v", ""); - // Only Safari responds affirmatively to "audio/aac", - // so we'll let x-m4a cover aac support. - check("audio/aac", ""); + + check("audio/aac", "maybe"); + check("audio/aacp", "maybe"); // H.264 Constrained Baseline Profile Level 3.0, AAC-LC check("video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"", "probably");