Bug 1143278 - Make gmp-clearkey not require a Win8 only DLL to decode audio on Win7. r=edwin, a=sledru
authorChris Pearce <cpearce@mozilla.com>
Mon, 13 Apr 2015 13:39:46 +1200
changeset 258470 f9f96ba1dbdb
parent 258469 48976876cdb9
child 258471 5779893b39a5
push id4676
push userryanvm@gmail.com
push date2015-04-15 02:06 +0000
treeherdermozilla-beta@91df81e2edac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin, sledru
bugs1143278
milestone38.0
Bug 1143278 - Make gmp-clearkey not require a Win8 only DLL to decode audio on Win7. r=edwin, a=sledru
dom/media/eme/CDMCaps.cpp
dom/media/gmp/gmp-api/gmp-decryption.h
media/gmp-clearkey/0.1/WMFUtils.cpp
--- a/dom/media/eme/CDMCaps.cpp
+++ b/dom/media/eme/CDMCaps.cpp
@@ -46,20 +46,48 @@ CDMCaps::AutoLock::AutoLock(CDMCaps& aIn
   mData.Lock();
 }
 
 CDMCaps::AutoLock::~AutoLock()
 {
   mData.Unlock();
 }
 
+#ifdef PR_LOGGING
+static void
+TestCap(uint64_t aFlag,
+        uint64_t aCaps,
+        const nsACString& aCapName,
+        nsACString& aCapStr)
+{
+  if (!(aFlag & aCaps)) {
+    return;
+  }
+  if (!aCapStr.IsEmpty()) {
+    aCapStr.AppendLiteral(",");
+  }
+  aCapStr.Append(aCapName);
+}
+
+nsCString
+CapsToString(uint64_t aCaps)
+{
+  nsCString capsStr;
+  TestCap(GMP_EME_CAP_DECRYPT_AUDIO, aCaps, NS_LITERAL_CSTRING("DecryptAudio"), capsStr);
+  TestCap(GMP_EME_CAP_DECRYPT_VIDEO, aCaps, NS_LITERAL_CSTRING("DecryptVideo"), capsStr);
+  TestCap(GMP_EME_CAP_DECRYPT_AND_DECODE_AUDIO, aCaps, NS_LITERAL_CSTRING("DecryptAndDecodeAudio"), capsStr);
+  TestCap(GMP_EME_CAP_DECRYPT_AND_DECODE_VIDEO, aCaps, NS_LITERAL_CSTRING("DecryptAndDecodeVideo"), capsStr);
+  return capsStr;
+}
+#endif // PR_LOGGING
+
 void
 CDMCaps::AutoLock::SetCaps(uint64_t aCaps)
 {
-  EME_LOG("SetCaps()");
+  EME_LOG("SetCaps() %s", CapsToString(aCaps).get());
   mData.mMonitor.AssertCurrentThreadOwns();
   mData.mCaps = aCaps;
   for (size_t i = 0; i < mData.mWaitForCaps.Length(); i++) {
     NS_DispatchToMainThread(mData.mWaitForCaps[i], NS_DISPATCH_NORMAL);
   }
   mData.mWaitForCaps.Clear();
 }
 
--- a/dom/media/gmp/gmp-api/gmp-decryption.h
+++ b/dom/media/gmp/gmp-api/gmp-decryption.h
@@ -108,17 +108,17 @@ typedef int64_t GMPTimestamp;
 // callback and specifying the logical OR of the GMP_EME_CAP_* flags below.
 //
 // Note the DECRYPT and the DECRYPT_AND_DECODE are mutually exclusive;
 // only one mode should be reported for each stream type, but different
 // modes can be reported for different stream types.
 //
 // Note: Gecko does not currently support the caps changing at runtime.
 // Set them once per plugin initialization, during the startup of
-// the GMPdecryptor.
+// the GMPDecryptor.
 
 // Capability; CDM can decrypt encrypted buffers and return still
 // compressed buffers back to Gecko for decompression there.
 #define GMP_EME_CAP_DECRYPT_AUDIO (uint64_t(1) << 0)
 #define GMP_EME_CAP_DECRYPT_VIDEO (uint64_t(1) << 1)
 
 // Capability; CDM can decrypt and then decode encrypted buffers,
 // and return decompressed samples to Gecko for playback.
--- a/media/gmp-clearkey/0.1/WMFUtils.cpp
+++ b/media/gmp-clearkey/0.1/WMFUtils.cpp
@@ -68,19 +68,21 @@ LinkMfplat()
 }
 
 bool
 EnsureLibs()
 {
   static bool sInitDone = false;
   static bool sInitOk = false;
   if (!sInitDone) {
+    // Note: For AAC decoding, we need to use msauddecmft.dll on Win8,
+    // and msmpeg2adec.dll on earlier Windows. So if we have at least
+    // one of these, assume we can decode.
     sInitOk = LinkMfplat() &&
-      !!GetModuleHandleA("msauddecmft.dll") &&
-      !!GetModuleHandleA("msmpeg2adec.dll") &&
+      (!!GetModuleHandleA("msauddecmft.dll") || !!GetModuleHandleA("msmpeg2adec.dll")) &&
       !!GetModuleHandleA("msmpeg2vdec.dll");
     sInitDone = true;
   }
   return sInitOk;
 }
 
 int32_t
 MFOffsetToInt32(const MFOffset& aOffset)