DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (409f3966645a)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=799315
-->
<head>
  <title>Test for MP4 and MP3 support</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>

<video id="v"></video>

<pre id="test">
<script>

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("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", "");

  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");
  check("video/mp4; codecs=\"avc1.58A01E, mp4a.40.2\"", "probably");

  // H.264 Main Profile Level 3.0, AAC-LC
  check("video/mp4; codecs=\"avc1.4D401E, mp4a.40.2\"", "probably");
  // H.264 Main Profile Level 3.1, AAC-LC
  check("video/mp4; codecs=\"avc1.4D401F, mp4a.40.2\"", "probably");
  // H.264 Main Profile Level 4.0, AAC-LC
  check("video/mp4; codecs=\"avc1.4D4028, mp4a.40.2\"", "probably");
  // H.264 High Profile Level 3.0, AAC-LC
  check("video/mp4; codecs=\"avc1.64001E, mp4a.40.2\"", "probably");
  // H.264 High Profile Level 3.1, AAC-LC
  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.64001F\"", "probably");

  // AAC-LC
  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");

  check("audio/mp4; codecs=\"mp4a.40.2,\"", ""); // Invalid codecs string

  // HE-AAC v1
  check("audio/mp4; codecs=\"mp4a.40.5\"", "probably");
  check("audio/mp4; codecs=mp4a.40.5", "probably");
  check("audio/x-m4a; codecs=\"mp4a.40.5\"", "probably");
  check("audio/x-m4a; codecs=mp4a.40.5", "probably");
  // HE-AAC v2
  check("audio/mp4; codecs=\"mp4a.40.29\"", "probably");

  // Opus
  check("audio/mp4; codecs=\"opus\"", "probably");
  check("audio/mp4; codecs=opus", "probably");

  // Flac.
  check("audio/mp4; codecs=\"flac\"", "probably");
  check("audio/mp4; codecs=flac", "probably");

  // VP9.
  [ "video/mp4; codecs=vp9",
    "video/mp4; codecs=\"vp9\"",
    "video/mp4; codecs=\"vp9.0\""
  ].forEach((codec) => {
    // canPlayType should support VP9 in MP4...
    check(codec, "probably");
    ok(MediaSource.isTypeSupported(codec), "VP9 in MP4 should be supported in MSE");
  });
  // AV1 is temporarily disabled on Win32 due to linker issues
  // https://bugzilla.mozilla.org/show_bug.cgi?id=1475564
  if (!isWindows32() && !isAndroid()) {
    check("video/mp4; codecs=\"av1\"", "probably");
  } else {
    check("video/mp4; codecs=\"av1\"", "");
  }
}

function check_mp3(v, enabled) {
  function check(type, expected) {
    var ex = enabled ? expected : "";
    is(v.canPlayType(type), ex, type + "='" + ex + "'");
  }

  check("audio/mpeg", "maybe");
  check("audio/mp3", "maybe");

  check("audio/mpeg; codecs=\"mp3\"", "probably");
  check("audio/mpeg; codecs=mp3", "probably");

  check("audio/mp3; codecs=\"mp3\"", "probably");
  check("audio/mp3; codecs=mp3", "probably");
}

function IsMacOSSnowLeopardOrLater() {
  var re = /Mac OS X (\d+)\.(\d+)/;
  var ver = navigator.userAgent.match(re);
  if (!ver || ver.length != 3) {
    return false;
  }
  var major = ver[1] | 0;
  var minor = ver[2] | 0;
  return major == 10 && minor >= 6;
}

function IsLinux() {
  return navigator.userAgent.includes("Linux");
}

function getPref(name) {
  var pref = false;
  try {
    pref = SpecialPowers.getBoolPref(name);
  } catch(ex) { }
  return pref;
}

function IsSupportedAndroid() {
  return getAndroidVersion() >= 14;
}

function IsJellyBeanOrLater() {
  return getAndroidVersion() >= 16;
}

var haveMp4 = getPref("media.wmf.enabled") ||
              IsMacOSSnowLeopardOrLater() ||
              (IsSupportedAndroid() &&
               (IsJellyBeanOrLater() || getPref("media.plugins.enabled"))) ||
              (IsLinux() && getPref("media.ffmpeg.enabled"));

check_mp4(document.getElementById('v'), haveMp4);

var haveMp3 = getPref("media.wmf.enabled") ||
              (IsLinux() && getPref("media.ffmpeg.enabled")) ||
              (IsSupportedAndroid() &&
               ((IsJellyBeanOrLater() && getPref("media.android-media-codec.enabled")) ||
                getPref("media.plugins.enabled"))) ||
              IsMacOSSnowLeopardOrLater();
check_mp3(document.getElementById('v'), haveMp3);

mediaTestCleanup();
</script>
</pre>
</body>
</html>