Bug 1217170: [MSE] P2. Enable WebM/MSE on systems with no MP4/H264 support. r=kentuckyfriedtakahe a=lizzard
--- 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;