Bug 1169212 - Part 2: Advertise support for ADTS via DecoderTraits. r=jya
authorDan Glastonbury <dglastonbury@mozilla.com>
Fri, 27 Nov 2015 14:40:36 +1000
changeset 309976 ba3bd2dae19a2c738baf7391bda17918f98599ea
parent 309975 864aa79515651a4c71f11779028ad6c52ec32c86
child 309977 0e03498265086330fc1cad3c047105b46d4c6068
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1169212
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1169212 - Part 2: Advertise support for ADTS via DecoderTraits. r=jya for mimetype audio/aacp
dom/media/DecoderTraits.cpp
dom/media/test/test_can_play_type_mpeg.html
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -52,16 +52,19 @@
 #include "MP4Decoder.h"
 #include "MP4Demuxer.h"
 #endif
 #include "MediaFormatReader.h"
 
 #include "MP3Decoder.h"
 #include "MP3Demuxer.h"
 
+#include "ADTSDecoder.h"
+#include "ADTSDemuxer.h"
+
 namespace mozilla
 {
 
 template <class String>
 static bool
 CodecListContains(char const *const * aCodecs, const String& aCodec)
 {
   for (int32_t i = 0; aCodecs[i]; ++i) {
@@ -349,16 +352,23 @@ IsMP3SupportedType(const nsACString& aTy
                    const nsAString& aCodecs = EmptyString())
 {
 #ifdef MOZ_OMX_DECODER
   return false;
 #endif
   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)
 {
 #ifdef MOZ_WAVE
   if (IsWaveType(nsDependentCString(aMIMEType))) {
     // We should not return true for Wave types, since there are some
     // Wave codecs actually in use in the wild that we don't support, and
     // we should allow those to be handled by plugins or helper apps.
@@ -409,16 +419,19 @@ DecoderTraits::CanHandleCodecsType(const
       // fmp4 is supported and working: the codec must be invalid.
       return CANPLAY_NO;
     }
   }
 #endif
   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")) {
       codecList = gMpegAudioCodecs;
 #ifdef MOZ_OMX_WEBM_DECODER
     } else if (nsDependentCString(aMIMEType).EqualsASCII("audio/webm") ||
                nsDependentCString(aMIMEType).EqualsASCII("video/webm")) {
       codecList = gOMXWebMCodecs;
@@ -494,16 +507,19 @@ DecoderTraits::CanHandleMediaType(const 
 #if !defined(MOZ_OMX_WEBM_DECODER)
   if (IsWebMTypeAndEnabled(nsDependentCString(aMIMEType))) {
     return CANPLAY_MAYBE;
   }
 #endif
   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)) {
     return aHaveRequestedCodecs ? CANPLAY_YES : CANPLAY_MAYBE;
   }
 #endif
 #ifdef MOZ_OMX_DECODER
   if (IsOmxSupportedType(nsDependentCString(aMIMEType))) {
@@ -542,16 +558,20 @@ InstantiateDecoder(const nsACString& aTy
     decoder = new MP4Decoder(aOwner);
     return decoder.forget();
   }
 #endif
   if (IsMP3SupportedType(aType)) {
     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);
     return decoder.forget();
   }
 #endif
 #ifdef MOZ_RAW
   if (IsRawType(aType)) {
@@ -641,16 +661,19 @@ MediaDecoderReader* DecoderTraits::Creat
 #ifdef MOZ_FMP4
   if (IsMP4SupportedType(aType)) {
     decoderReader = new MediaFormatReader(aDecoder, new MP4Demuxer(aDecoder->GetResource()));
   } else
 #endif
   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);
   } else
 #endif
 #ifdef MOZ_RAW
   if (IsRawType(aType)) {
     decoderReader = new RawReader(aDecoder);
@@ -720,16 +743,17 @@ bool DecoderTraits::IsSupportedInVideoDo
 #endif
 #ifdef MOZ_ANDROID_OMX
     (MediaDecoder::IsAndroidMediaEnabled() && IsAndroidMediaType(aType)) ||
 #endif
 #ifdef MOZ_FMP4
     IsMP4SupportedType(aType) ||
 #endif
     IsMP3SupportedType(aType) ||
+    IsAACSupportedType(aType) ||
 #ifdef MOZ_DIRECTSHOW
     IsDirectShowSupportedType(aType) ||
 #endif
 #ifdef NECKO_PROTOCOL_rtsp
     IsRtspSupportedType(aType) ||
 #endif
     false;
 }
--- a/dom/media/test/test_can_play_type_mpeg.html
+++ b/dom/media/test/test_can_play_type_mpeg.html
@@ -28,19 +28,19 @@ function check_mp4(v, enabled) {
   check("video/mp4", "maybe");
   check("video/x-m4v", "maybe");
   check("audio/mp4", "maybe");
   check("audio/x-m4a", "maybe");
 
   // 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");
 
   // H.264 Constrained Baseline Profile Level 3.0, mp3
   check("video/mp4; codecs=\"avc1.42E01E, mp3\"", "probably");
 
   check("video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"", "probably");