Bug 1057877 - Account for fmp4 not working on MacOS X 10.6. r=cpearce
authorRalph Giles <giles@mozilla.com>
Mon, 25 Aug 2014 13:48:00 -0700
changeset 201592 d8c1c88cde24da8d53cd66efe91c5733801562dc
parent 201591 36271619da174b783e33f4208f07010606bd1c93
child 201593 c4d86cfb8fa24bdddd6c472f53f5b779b95c85f6
push id27375
push userryanvm@gmail.com
push dateTue, 26 Aug 2014 19:56:59 +0000
treeherdermozilla-central@f9bfe115fee5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1057877
milestone34.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 1057877 - Account for fmp4 not working on MacOS X 10.6. r=cpearce Consolidate the various fmp4-related checks in their own function; the ad hoc logic was getting complicated and we'll want to add more such checks as we enable more platforms.
content/media/test/test_can_play_type_mpeg.html
--- a/content/media/test/test_can_play_type_mpeg.html
+++ b/content/media/test/test_can_play_type_mpeg.html
@@ -16,39 +16,51 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 <video id="v"></video>
 
 <pre id="test">
 <script src="can_play_type_mpeg.js"></script>
 <script>
 
 function IsWindowsVistaOrLater() {
-  var re = /Windows NT (\d.\d)/;
+  var re = /Windows NT (\d+\.\d)/;
   var winver = navigator.userAgent.match(re);
   return winver && winver.length == 2 && parseFloat(winver[1]) >= 6.0;
 }
 
-function IsWindowsXPOrEarlier() {
-  var re = /Windows NT (\d.\d)/;
-  var winver = navigator.userAgent.match(re);
-  return winver && winver.length == 2 && parseFloat(winver[1]) < 6.0;
+function IsMacOSLionOrLater() {
+  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 >= 7;
 }
 
 function getPref(name) {
   var pref = false;
   try {
     pref = SpecialPowers.getBoolPref(name);
   } catch(ex) { }
   return pref;
 }
 
+// Check whether we should expect the new MP4Reader-based support to work.
+function IsMP4ReaderAvailable() {
+  var prefs = getPref("media.fragmented-mp4.enabled") &&
+              getPref("media.fragmented-mp4.exposed");
+  return prefs && (IsWindowsVistaOrLater() || IsMacOSLionOrLater());
+}
+
 var haveMp4 = (getPref("media.windows-media-foundation.enabled") && IsWindowsVistaOrLater()) ||
                getPref("media.omx.enabled") ||
                getPref("media.gstreamer.enabled") ||
-               (getPref("media.fragmented-mp4.exposed") && !IsWindowsXPOrEarlier());
+               IsMP4ReaderAvailable();
 // TODO:  Add "getPref("media.plugins.enabled")" once MP4 works on Gingerbread.
              
 check_mp4(document.getElementById('v'), haveMp4);
 
 var haveMp3 = getPref("media.directshow.enabled") ||
               (getPref("media.windows-media-foundation.enabled") && IsWindowsVistaOrLater()) ||
                getPref("media.omx.enabled") ||
                getPref("media.gstreamer.enabled") ||