--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -30,16 +30,17 @@
#include "GMPUtils.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsDirectoryServiceDefs.h"
#include "nsXULAppAPI.h"
#include "gmp-audio-decode.h"
#include "gmp-video-decode.h"
#include "DecoderDoctorDiagnostics.h"
+#include "WebMDecoder.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeySystemAccess,
mParent)
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeySystemAccess)
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeySystemAccess)
@@ -350,16 +351,44 @@ GMPDecryptsAndDecodesH264(mozIGeckoMedia
NS_ConvertUTF16toUTF8(aKeySystem),
NS_LITERAL_CSTRING(GMP_API_DECRYPTOR)));
return HaveGMPFor(aGMPS,
NS_ConvertUTF16toUTF8(aKeySystem),
NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
NS_LITERAL_CSTRING("h264"));
}
+static bool
+GMPDecryptsAndDecodesVP8(mozIGeckoMediaPluginService* aGMPS,
+ const nsAString& aKeySystem,
+ DecoderDoctorDiagnostics* aDiagnostics)
+{
+ MOZ_ASSERT(HaveGMPFor(aGMPS,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_DECRYPTOR)));
+ return HaveGMPFor(aGMPS,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
+ NS_LITERAL_CSTRING("vp8"));
+}
+
+static bool
+GMPDecryptsAndDecodesVP9(mozIGeckoMediaPluginService* aGMPS,
+ const nsAString& aKeySystem,
+ DecoderDoctorDiagnostics* aDiagnostics)
+{
+ MOZ_ASSERT(HaveGMPFor(aGMPS,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_DECRYPTOR)));
+ return HaveGMPFor(aGMPS,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
+ NS_LITERAL_CSTRING("vp9"));
+}
+
// If this keysystem's CDM explicitly says it doesn't support decoding,
// that means it's OK with passing the decrypted samples back to Gecko
// for decoding.
static bool
GMPDecryptsAndGeckoDecodesH264(mozIGeckoMediaPluginService* aGMPService,
const nsAString& aKeySystem,
const nsAString& aContentType,
DecoderDoctorDiagnostics* aDiagnostics)
@@ -407,35 +436,108 @@ GMPDecryptsAndGeckoDecodesAAC(mozIGeckoM
}
return false;
}
#endif
return MP4Decoder::CanHandleMediaType(aContentType, aDiagnostics);
}
static bool
+GMPDecryptsAndGeckoDecodesVorbis(mozIGeckoMediaPluginService* aGMPService,
+ const nsAString& aKeySystem,
+ const nsAString& aContentType,
+ DecoderDoctorDiagnostics* aDiagnostics)
+{
+ MOZ_ASSERT(HaveGMPFor(aGMPService,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_DECRYPTOR)));
+ MOZ_ASSERT(IsVorbisContentType(aContentType));
+ return !HaveGMPFor(aGMPService,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER),
+ NS_LITERAL_CSTRING("vorbis")) &&
+ WebMDecoder::CanHandleMediaType(aContentType);
+}
+
+static bool
+GMPDecryptsAndGeckoDecodesVP8(mozIGeckoMediaPluginService* aGMPService,
+ const nsAString& aKeySystem,
+ const nsAString& aContentType,
+ DecoderDoctorDiagnostics* aDiagnostics)
+{
+ MOZ_ASSERT(HaveGMPFor(aGMPService,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_DECRYPTOR)));
+ MOZ_ASSERT(IsVP8ContentType(aContentType));
+ return !HaveGMPFor(aGMPService,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
+ NS_LITERAL_CSTRING("vp8")) &&
+ WebMDecoder::CanHandleMediaType(aContentType);
+}
+
+static bool
+GMPDecryptsAndGeckoDecodesVP9(mozIGeckoMediaPluginService* aGMPService,
+ const nsAString& aKeySystem,
+ const nsAString& aContentType,
+ DecoderDoctorDiagnostics* aDiagnostics)
+{
+ MOZ_ASSERT(HaveGMPFor(aGMPService,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_DECRYPTOR)));
+ MOZ_ASSERT(IsVP9ContentType(aContentType));
+ return !HaveGMPFor(aGMPService,
+ NS_ConvertUTF16toUTF8(aKeySystem),
+ NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
+ NS_LITERAL_CSTRING("vp9")) &&
+ WebMDecoder::CanHandleMediaType(aContentType);
+}
+
+static bool
IsSupportedAudio(mozIGeckoMediaPluginService* aGMPService,
const nsAString& aKeySystem,
const nsAString& aAudioType,
DecoderDoctorDiagnostics* aDiagnostics)
{
- return IsAACContentType(aAudioType) &&
- (GMPDecryptsAndDecodesAAC(aGMPService, aKeySystem, aDiagnostics) ||
- GMPDecryptsAndGeckoDecodesAAC(aGMPService, aKeySystem, aAudioType, aDiagnostics));
+ if (IsAACContentType(aAudioType)) {
+ return GMPDecryptsAndDecodesAAC(aGMPService, aKeySystem, aDiagnostics) ||
+ GMPDecryptsAndGeckoDecodesAAC(aGMPService, aKeySystem, aAudioType, aDiagnostics);
+ }
+ if (IsVorbisContentType(aAudioType) && aKeySystem.EqualsLiteral("org.w3.clearkey")) {
+ // GMP does not decode Vorbis, so don't bother checking
+ return GMPDecryptsAndGeckoDecodesVorbis(aGMPService, aKeySystem, aAudioType, aDiagnostics);
+ }
+ return false;
}
static bool
IsSupportedVideo(mozIGeckoMediaPluginService* aGMPService,
const nsAString& aKeySystem,
const nsAString& aVideoType,
DecoderDoctorDiagnostics* aDiagnostics)
{
- return IsH264ContentType(aVideoType) &&
- (GMPDecryptsAndDecodesH264(aGMPService, aKeySystem, aDiagnostics) ||
- GMPDecryptsAndGeckoDecodesH264(aGMPService, aKeySystem, aVideoType, aDiagnostics));
+ if (IsH264ContentType(aVideoType)) {
+ return GMPDecryptsAndDecodesH264(aGMPService, aKeySystem, aDiagnostics) ||
+ GMPDecryptsAndGeckoDecodesH264(aGMPService, aKeySystem, aVideoType, aDiagnostics);
+ }
+ if (IsVP8ContentType(aVideoType)) {
+ if (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
+ return GMPDecryptsAndGeckoDecodesVP8(aGMPService, aKeySystem, aVideoType, aDiagnostics);
+ } else if (aKeySystem.EqualsLiteral("come.widevine.alpha")) {
+ GMPDecryptsAndDecodesVP8(aGMPService, aKeySystem, aDiagnostics);
+ }
+ }
+ if (IsVP9ContentType(aVideoType)) {
+ if (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
+ return GMPDecryptsAndGeckoDecodesVP9(aGMPService, aKeySystem, aVideoType, aDiagnostics);
+ } else if (aKeySystem.EqualsLiteral("come.widevine.alpha")) {
+ GMPDecryptsAndDecodesVP9(aGMPService, aKeySystem, aDiagnostics);
+ }
+ }
+ return false;
}
static bool
IsSupported(mozIGeckoMediaPluginService* aGMPService,
const nsAString& aKeySystem,
const MediaKeySystemConfiguration& aConfig,
DecoderDoctorDiagnostics* aDiagnostics)
{
@@ -469,17 +571,17 @@ IsSupportedInitDataType(const nsString&
// All supported keySystems can handle "cenc" initDataType.
// ClearKey also supports "keyids" and "webm" initDataTypes.
return aCandidate.EqualsLiteral("cenc") ||
((aKeySystem.EqualsLiteral("org.w3.clearkey")
#ifdef MOZ_WIDEVINE_EME
|| aKeySystem.EqualsLiteral("com.widevine.alpha")
#endif
) &&
- (aCandidate.EqualsLiteral("keyids") || aCandidate.EqualsLiteral("webm)")));
+ (aCandidate.EqualsLiteral("keyids") || aCandidate.EqualsLiteral("webm")));
}
static bool
GetSupportedConfig(mozIGeckoMediaPluginService* aGMPService,
const nsAString& aKeySystem,
const MediaKeySystemConfiguration& aCandidate,
MediaKeySystemConfiguration& aOutConfig,
DecoderDoctorDiagnostics* aDiagnostics)