Bug 1169212 - Part 2: Advertise support for ADTS via DecoderTraits. r=jya

for mimetype audio/aacp
This commit is contained in:
Dan Glastonbury 2015-11-27 14:40:36 +10:00
parent ee369feabb
commit 50ea7241a3
2 changed files with 27 additions and 3 deletions

View File

@ -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

View File

@ -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");