Bug 1319159 - Updates how 'ParseChromiumManifest' works so that it doesn't assume Widevine (now it assumes Widevine or Clearkey..). r?cpearce draft
authorJay Harris <jharris@mozilla.com>
Thu, 22 Dec 2016 11:28:40 +1300
changeset 457826 3fdd916a781d6ea05cd6198f1622ecc66b5f14a5
parent 457446 d192a99be4b436f2dc839435319f7630d5d8f4b0
child 457828 08e8e01437ed0edc7bdde31b156e821870697dfd
child 457844 31f94adc71dc8fe5dd8c3c3cd87348311018ae0a
push id40908
push userbmo:jharris@mozilla.com
push dateTue, 10 Jan 2017 00:30:43 +0000
reviewerscpearce
bugs1319159
milestone53.0a1
Bug 1319159 - Updates how 'ParseChromiumManifest' works so that it doesn't assume Widevine (now it assumes Widevine or Clearkey..). r?cpearce MozReview-Commit-ID: 8m6hPIiUPT
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
dom/media/gmp/GMPParent.cpp
media/gmp-clearkey/0.1/clearkey.info.in
media/gmp-clearkey/0.1/manifest.json.in
media/gmp-clearkey/0.1/moz.build
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -798,16 +798,16 @@ bin/libfreebl_32int64_3.so
 #endif
 
 #ifdef PACKAGE_MOZTT
 @RESPATH@/fonts/*
 #endif
 
 ; media
 @RESPATH@/gmp-clearkey/0.1/@DLL_PREFIX@clearkey@DLL_SUFFIX@
-@RESPATH@/gmp-clearkey/0.1/clearkey.info
+@RESPATH@/gmp-clearkey/0.1/manifest.json
 
 #ifdef PKG_LOCALE_MANIFEST
 #include @PKG_LOCALE_MANIFEST@
 #endif
 
 @RESPATH@/components/simpleServices.js
 @RESPATH@/components/utils.manifest
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -794,17 +794,17 @@ bin/libfreebl_32int64_3.so
 
 #if defined(MOZ_ASAN) && defined(CLANG_CL)
 @BINPATH@/clang_rt.asan_dynamic-*.dll
 #endif
 
 
 ; media
 @RESPATH@/gmp-clearkey/0.1/@DLL_PREFIX@clearkey@DLL_SUFFIX@
-@RESPATH@/gmp-clearkey/0.1/clearkey.info
+@RESPATH@/gmp-clearkey/0.1/manifest.json
 
 ; gfx
 #ifdef XP_WIN
 @RESPATH@/components/GfxSanityTest.manifest
 @RESPATH@/components/SanityTest.js
 #endif
 
 #ifdef MOZ_MULET
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -953,31 +953,61 @@ GMPParent::ParseChromiumManifest(const n
                                  m.mX_cdm_host_versions.ToInteger(&ignored))) {
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   mDisplayName = NS_ConvertUTF16toUTF8(m.mName);
   mDescription = NS_ConvertUTF16toUTF8(m.mDescription);
   mVersion = NS_ConvertUTF16toUTF8(m.mVersion);
 
+  // We have two booleans, because it could concievably be a third, unsupported
+  // CDM.
+  bool isClearkey = mDisplayName.EqualsASCII("clearkey");
+  bool isWidevine = mDisplayName.EqualsASCII("WidevineCdm");
+
+  // Assert that it is one, so it breaks here if we're adding more CDMs.
+  MOZ_ASSERT(isClearkey || isWidevine);
+
+  nsCString kEMEKeySystem;
+  nsCString libs;
+
+  // We hard code a few of the settings because they can't be stored in the
+  // widevine manifest without making our API different to widevine's.
+  if (isClearkey) {
+	  kEMEKeySystem = kEMEKeySystemClearkey;
+	  libs = NS_LITERAL_CSTRING(
+		     "dxva2.dll, d3d9.dll, msmpeg2vdec.dll, msmpeg2adec.dll, MSAudDecMFT.dll, evr.dll, mfheaacdec.dll, mfh264dec.dll, mfplat.dll");
+  }
+
+  if (isWidevine) {
+	  kEMEKeySystem = kEMEKeySystemWidevine;
+	  libs = NS_LITERAL_CSTRING("dxva2.dll");
+  }
+
   GMPCapability video(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER));
-  video.mAPITags.AppendElement(NS_LITERAL_CSTRING("h264"));
-  video.mAPITags.AppendElement(NS_LITERAL_CSTRING("vp8"));
-  video.mAPITags.AppendElement(NS_LITERAL_CSTRING("vp9"));
-  video.mAPITags.AppendElement(kEMEKeySystemWidevine);
+
+  nsCString codecsString = NS_ConvertUTF16toUTF8(m.mX_cdm_codecs);
+  nsTArray<nsCString> codecs;
+  SplitAt(",", codecsString, codecs);
+
+  for (uint32_t i = 0; i < codecs.Length(); ++i) {
+	  video.mAPITags.AppendElement(codecs.ElementAt(i));
+  }
+
+  video.mAPITags.AppendElement(kEMEKeySystem);
   mCapabilities.AppendElement(Move(video));
 
   GMPCapability decrypt(NS_LITERAL_CSTRING(GMP_API_DECRYPTOR));
-  decrypt.mAPITags.AppendElement(kEMEKeySystemWidevine);
+
+  decrypt.mAPITags.AppendElement(kEMEKeySystem);
   mCapabilities.AppendElement(Move(decrypt));
 
-  MOZ_ASSERT(mName.EqualsLiteral("widevinecdm"));
   mAdapter = NS_LITERAL_STRING("widevine");
 #ifdef XP_WIN
-  mLibs = NS_LITERAL_CSTRING("dxva2.dll");
+  mLibs = libs;
 #endif
 
   return GenericPromise::CreateAndResolve(true, __func__);
 }
 
 bool
 GMPParent::CanBeSharedCrossNodeIds() const
 {
deleted file mode 100644
--- a/media/gmp-clearkey/0.1/clearkey.info.in
+++ /dev/null
@@ -1,10 +0,0 @@
-Name: clearkey
-Description: ClearKey Gecko Media Plugin
-Version: 1
-#ifdef ENABLE_WMF
-APIs: eme-decrypt-v9[org.w3.clearkey], decode-video[h264:org.w3.clearkey]
-Libraries: dxva2.dll, d3d9.dll, msmpeg2vdec.dll, msmpeg2adec.dll, MSAudDecMFT.dll, evr.dll, mfheaacdec.dll, mfh264dec.dll, mfplat.dll
-#else
-APIs: eme-decrypt-v9[org.w3.clearkey]
-Libraries:
-#endif
new file mode 100644
--- /dev/null
+++ b/media/gmp-clearkey/0.1/manifest.json.in
@@ -0,0 +1,13 @@
+{
+    "name": "clearkey",
+    "description": "ClearKey Gecko Media Plugin",
+    "version": "1",
+    "x-cdm-module-versions": "4",
+    "x-cdm-interface-versions": "8",
+    "x-cdm-host-versions": "8",
+#ifdef ENABLE_WMF
+    "x-cdm-codecs": "h264"
+#else
+    "x-cdm-codecs": ""
+#endif
+}
\ No newline at end of file
--- a/media/gmp-clearkey/0.1/moz.build
+++ b/media/gmp-clearkey/0.1/moz.build
@@ -3,17 +3,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SharedLibrary('clearkey')
 
 FINAL_TARGET = 'dist/bin/gmp-clearkey/0.1'
 
-FINAL_TARGET_PP_FILES += ['clearkey.info.in']
+FINAL_TARGET_PP_FILES += ['manifest.json.in']
 
 UNIFIED_SOURCES += [
     'ClearKeyAsyncShutdown.cpp',
     'ClearKeyBase64.cpp',
     'ClearKeyDecryptionManager.cpp',
     'ClearKeyPersistence.cpp',
     'ClearKeySession.cpp',
     'ClearKeySessionManager.cpp',