Bug 1217170: [MSE] P2. Enable WebM/MSE on systems with no MP4/H264 support. r=kentuckyfriedtakahe a=lizzard
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 27 Oct 2015 12:52:28 +1100
changeset 296646 75d6468d0be1
parent 296645 0e749793c4c6
child 296647 e31f1aa9d84d
push id5273
push userjyavenard@mozilla.com
push date2015-11-08 23:21 +0000
treeherdermozilla-beta@75d6468d0be1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe, lizzard
bugs1217170
milestone43.0
Bug 1217170: [MSE] P2. Enable WebM/MSE on systems with no MP4/H264 support. r=kentuckyfriedtakahe a=lizzard
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;