Bug 1159495 - Only report that Adobe EME is available if we have a plugin-container voucher. r=edwin
☠☠ backed out by d889fd14f2d9 ☠ ☠
authorChris Pearce <cpearce@mozilla.com>
Wed, 29 Apr 2015 16:47:37 +1200
changeset 271364 cb9c0ddc2e22b1f4f7ff08ad3b4db178d4908223
parent 271363 e3864c540beddad524480a53bf75201e8a2bf724
child 271365 3e18d65b28c3ad9d8248a3b159af3fcdef7a70ac
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1159495
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1159495 - Only report that Adobe EME is available if we have a plugin-container voucher. r=edwin
dom/media/eme/EMEUtils.cpp
dom/media/eme/EMEUtils.h
dom/media/eme/MediaKeySystemAccess.cpp
dom/media/gmp/GMPProcessParent.cpp
--- a/dom/media/eme/EMEUtils.cpp
+++ b/dom/media/eme/EMEUtils.cpp
@@ -1,15 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "mozilla/EMEUtils.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsIFile.h"
+#include "nsCOMPtr.h"
 
 namespace mozilla {
 
 #ifdef PR_LOGGING
 
 PRLogModuleInfo* GetEMELog() {
   static PRLogModuleInfo* log = nullptr;
   if (!log) {
@@ -108,9 +111,33 @@ ParseKeySystem(const nsAString& aInputKe
       aOutKeySystem = keySystem;
       aOutCDMVersion = minCDMVersion;
       return true;
     }
   }
   return false;
 }
 
+bool
+GetEMEVoucherPath(nsIFile** aPath)
+{
+  nsCOMPtr<nsIFile> path;
+  NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(path));
+  if (!path) {
+    NS_WARNING("GetEMEVoucherPath can't get NS_GRE_DIR!");
+    return false;
+  }
+  path->AppendNative(NS_LITERAL_CSTRING("voucher.bin"));
+  path.forget(aPath);
+  return true;
+}
+
+bool
+EMEVoucherFileExists()
+{
+  nsCOMPtr<nsIFile> path;
+  bool exists;
+  return GetEMEVoucherPath(getter_AddRefs(path)) &&
+         NS_SUCCEEDED(path->Exists(&exists)) &&
+         exists;
+}
+
 } // namespace mozilla
--- a/dom/media/eme/EMEUtils.h
+++ b/dom/media/eme/EMEUtils.h
@@ -59,11 +59,15 @@ namespace mozilla {
 //
 // On success, aOutKeySystem contains the keySystem string stripped of the
 // min version number, and aOutMinCDMVersion contains the min version number
 // if present. If it was not present, aOutMinCDMVersion is NO_CDM_VERSION.
 bool ParseKeySystem(const nsAString& aKeySystem,
                     nsAString& aOutKeySystem,
                     int32_t& aOutMinCDMVersion);
 
+bool GetEMEVoucherPath(nsIFile** aPath);
+
+bool EMEVoucherFileExists();
+
 } // namespace mozilla
 
 #endif // EME_LOG_H_
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -155,19 +155,21 @@ MediaKeySystemAccess::GetKeySystemStatus
        aKeySystem.EqualsLiteral("com.adobe.primetime"))) {
     // Win Vista and later only.
     if (!IsVistaOrLater()) {
       return MediaKeySystemStatus::Cdm_not_supported;
     }
     if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
       return MediaKeySystemStatus::Cdm_disabled;
     }
-    if (!WMFDecoderModule::HasH264() || !WMFDecoderModule::HasAAC()) {
+    if ((!WMFDecoderModule::HasH264() || !WMFDecoderModule::HasAAC()) ||
+        !EMEVoucherFileExists()) {
       // The system doesn't have the codecs that Adobe EME relies
-      // on installed.
+      // on installed, or doesn't have a voucher for the plugin-container.
+      // Adobe EME isn't going to work, so don't advertise that it will.
       return MediaKeySystemStatus::Cdm_not_supported;
     }
     return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, true);
   }
 #endif
 
   return MediaKeySystemStatus::Cdm_not_supported;
 }
--- a/dom/media/gmp/GMPProcessParent.cpp
+++ b/dom/media/gmp/GMPProcessParent.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=2 et :
  * 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/. */
 
 #include "GMPProcessParent.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsIFile.h"
+#include "mozilla/EMEUtils.h"
 
 #include "base/string_util.h"
 #include "base/process_util.h"
 
 #include <string>
 
 using std::vector;
 using std::string;
@@ -40,25 +39,23 @@ GMPProcessParent::GMPProcessParent(const
 GMPProcessParent::~GMPProcessParent()
 {
   MOZ_COUNT_DTOR(GMPProcessParent);
 }
 
 bool
 GMPProcessParent::Launch(int32_t aTimeoutMs)
 {
-  nsCOMPtr<nsIFile> greDir;
-  NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(greDir));
-  if (!greDir) {
-    NS_WARNING("GMPProcessParent can't get NS_GRE_DIR");
+  nsCOMPtr<nsIFile> path;
+  if (!GetEMEVoucherPath(getter_AddRefs(path))) {
+    NS_WARNING("GMPProcessParent can't get EME voucher path!");
     return false;
   }
-  greDir->AppendNative(NS_LITERAL_CSTRING("voucher.bin"));
   nsAutoCString voucherPath;
-  greDir->GetNativePath(voucherPath);
+  path->GetNativePath(voucherPath);
 
   vector<string> args;
   args.push_back(mGMPPath);
   args.push_back(string(voucherPath.BeginReading(), voucherPath.EndReading()));
 
 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
   std::wstring wGMPPath = UTF8ToWide(mGMPPath.c_str());
   mAllowedFilesRead.push_back(wGMPPath + L"\\*");