Bug 1217170: [MSE] P2. Enable WebM/MSE on systems with no MP4/H264 support. r=kentuckyfriedtakahe
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 27 Oct 2015 12:52:28 +1100
changeset 304870 910ba8ed6e1869cfb492d72f0d2b9cc2c94156ff
parent 304869 1c75443c6026daca3d7677613dd0fcf01be59deb
child 304871 98c007c604157648f091c4ce8ac63b4c8a8ca3f5
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1217170
milestone44.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 1217170: [MSE] P2. Enable WebM/MSE on systems with no MP4/H264 support. r=kentuckyfriedtakahe
dom/media/mediasource/MediaSource.cpp
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -64,16 +64,31 @@ namespace mozilla {
 static const char* const gMediaSourceTypes[6] = {
   "video/mp4",
   "audio/mp4",
   "video/webm",
   "audio/webm",
   nullptr
 };
 
+// Returns true if we should enable MSE webm regardless of preferences.
+// 1. If MP4/H264 isn't supported:
+//   * Windows XP
+//   * Windows Vista and Server 2008 without the optional "Platform Update Supplement"
+//   * N/KN editions (Europe and Korea) of Windows 7/8/8.1/10 without the
+//     optional "Windows Media Feature Pack"
+
+static bool
+IsWebMForced()
+{
+  bool mp4supported =
+    DecoderTraits::IsMP4TypeAndEnabled(NS_LITERAL_CSTRING("video/mp4"));
+  return !mp4supported;
+}
+
 static nsresult
 IsTypeSupported(const nsAString& aType)
 {
   if (aType.IsEmpty()) {
     return NS_ERROR_DOM_INVALID_ACCESS_ERR;
   }
   nsContentTypeParser parser(aType);
   nsAutoString mimeType;
@@ -94,17 +109,18 @@ IsTypeSupported(const nsAString& aType)
         }
         if (hasCodecs &&
             DecoderTraits::CanHandleCodecsType(mimeTypeUTF8.get(),
                                                codecs) == CANPLAY_NO) {
           return NS_ERROR_DOM_INVALID_STATE_ERR;
         }
         return NS_OK;
       } else if (DecoderTraits::IsWebMTypeAndEnabled(mimeTypeUTF8)) {
-        if (!Preferences::GetBool("media.mediasource.webm.enabled", false)) {
+        if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) ||
+              IsWebMForced())) {
           return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
         }
         if (hasCodecs &&
             DecoderTraits::CanHandleCodecsType(mimeTypeUTF8.get(),
                                                codecs) == CANPLAY_NO) {
           return NS_ERROR_DOM_INVALID_STATE_ERR;
         }
         return NS_OK;