Bug 841239 - Have HTMLMediaElement.canPlayType respond affirmatively to codecs=mp3 and audio/x-m4a. r=padenot
authorChris Pearce <cpearce@mozilla.com>
Wed, 27 Feb 2013 09:27:43 +1300
changeset 123091 a212819b76b7c9e85fedc31aeda7ebdf58ce7fd1
parent 123090 e6c86595edbadd844e3388072cb8a3c819a174d8
child 123092 94c4b6ba217b6ee4b705a1c9686f82ffcfdfe6c1
push id24372
push useremorley@mozilla.com
push dateWed, 27 Feb 2013 13:22:59 +0000
treeherdermozilla-central@0a91da5f5eab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs841239
milestone22.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 841239 - Have HTMLMediaElement.canPlayType respond affirmatively to codecs=mp3 and audio/x-m4a. r=padenot
content/html/content/src/nsHTMLMediaElement.cpp
content/media/test/can_play_type_mpeg.js
content/media/wmf/WMFDecoder.cpp
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -2182,16 +2182,21 @@ nsHTMLMediaElement::CanPlayType(const ns
   case CANPLAY_YES:
     aResult.AssignLiteral("probably");
     break;
   default:
   case CANPLAY_MAYBE:
     aResult.AssignLiteral("maybe");
     break;
   }
+
+  LOG(PR_LOG_DEBUG, ("%p CanPlayType(%s) = \"%s\"", this,
+                     NS_ConvertUTF16toUTF8(aType).get(),
+                     NS_ConvertUTF16toUTF8(aResult).get()));
+
   return NS_OK;
 }
 
 already_AddRefed<MediaDecoder>
 nsHTMLMediaElement::CreateDecoder(const nsACString& aType)
 {
   // If you change this list to add support for new decoders for codecs that
   // can be used by <audio>, please consider updating MediaDecodeTask::CreateDecoder
--- a/content/media/test/can_play_type_mpeg.js
+++ b/content/media/test/can_play_type_mpeg.js
@@ -2,26 +2,42 @@ function check_mp4(v, enabled) {
   function check(type, expected) {
     var ex = enabled ? expected : "";
     is(v.canPlayType(type), ex, type + "='" + ex + "'");
   }
 
   check("video/mp4", "maybe");
   check("audio/mp4", "maybe");
   check("audio/mpeg", "maybe");
+  check("audio/mp3", "maybe");
+  check("audio/x-m4a", "maybe");
+
+  // Not the MIME type that other browsers respond to, so we won't either.
+  check("audio/m4a", "");
+  // Only Safari responds affirmatively to "audio/aac",
+  // so we'll let x-m4a cover aac support.
+  check("audio/aac", "");
 
   check("video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"", "probably");
   check("video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"", "probably");
   check("video/mp4; codecs=\"avc1.58A01E, mp4a.40.2\"", "probably");
   check("video/mp4; codecs=\"avc1.4D401E, mp4a.40.2\"", "probably");
   check("video/mp4; codecs=\"avc1.64001E, mp4a.40.2\"", "probably");
   check("video/mp4; codecs=\"avc1.64001F, mp4a.40.2\"", "probably");
 
   check("video/mp4; codecs=\"avc1.42E01E\"", "probably");
   check("video/mp4; codecs=\"avc1.42001E\"", "probably");
   check("video/mp4; codecs=\"avc1.58A01E\"", "probably");
   check("video/mp4; codecs=\"avc1.4D401E\"", "probably");
   check("video/mp4; codecs=\"avc1.64001E\"", "probably");
   check("video/mp4; codecs=\"avc1.64001F\"", "probably");
 
+  check("audio/mpeg; codecs=\"mp3\"", "probably");
+  check("audio/mpeg; codecs=mp3", "probably");
+
+  check("audio/mp3; codecs=\"mp3\"", "probably");
+  check("audio/mp3; codecs=mp3", "probably");
+
   check("audio/mp4; codecs=\"mp4a.40.2\"", "probably");
   check("audio/mp4; codecs=mp4a.40.2", "probably");
+  check("audio/x-m4a; codecs=\"mp4a.40.2\"", "probably");
+  check("audio/x-m4a; codecs=mp4a.40.2", "probably");
 }
--- a/content/media/wmf/WMFDecoder.cpp
+++ b/content/media/wmf/WMFDecoder.cpp
@@ -21,38 +21,37 @@ MediaDecoderStateMachine* WMFDecoder::Cr
 bool
 WMFDecoder::GetSupportedCodecs(const nsACString& aType,
                                char const *const ** aCodecList)
 {
   if (!MediaDecoder::IsWMFEnabled() ||
       NS_FAILED(LoadDLLs()))
     return false;
 
-  // MP3 is specified to have no codecs in its "type" param:
-  // http://wiki.whatwg.org/wiki/Video_type_parameters#MPEG
-  // So specify an empty codecs list, so that if script specifies 
-  // a "type" param with codecs, it will be reported as not supported
-  // as per the spec.
+  // Assume that if LoadDLLs() didn't fail, we can playback the types that
+  // we know should be supported on Windows 7+ using WMF.
   static char const *const mp3AudioCodecs[] = {
+    "mp3",
     nullptr
   };
-  if (aType.EqualsASCII("audio/mpeg")) {
+  if (aType.EqualsASCII("audio/mpeg") ||
+      aType.EqualsASCII("audio/mp3")) {
     if (aCodecList) {
       *aCodecList = mp3AudioCodecs;
     }
-    // Assume that if LoadDLLs() didn't fail, we can decode MP3.
     return true;
   }
 
   // AAC in M4A.
   static char const *const aacAudioCodecs[] = {
     "mp4a.40.2",    // AAC-LC
     nullptr
   };
-  if (aType.EqualsASCII("audio/mp4")) {
+  if (aType.EqualsASCII("audio/mp4") ||
+      aType.EqualsASCII("audio/x-m4a")) {
     if (aCodecList) {
       *aCodecList = aacAudioCodecs;
     }
     return true;
   }
 
   // H.264 + AAC in MP4.
   static char const *const H264Codecs[] = {