Bug 1159495 - Only report that Adobe EME is available if we have a plugin-container voucher. r=edwin
authorChris Pearce <cpearce@mozilla.com>
Thu, 30 Apr 2015 21:52:14 +1200
changeset 273146 469ae46092fcaff123de2b291dddd107155f88c9
parent 273145 2a4864545b47eb36c526408cded4c79eff399bcd
child 273147 1f42bc6b4b8c3177798b38ede9478f3b9fe2f584
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [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/MediaKeySystemAccess.cpp
dom/media/gmp/GMPProcessParent.cpp
dom/media/gmp/GMPUtils.cpp
dom/media/gmp/GMPUtils.h
dom/media/gmp/moz.build
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -17,16 +17,17 @@
 #endif
 #include "nsContentCID.h"
 #include "nsServiceManagerUtils.h"
 #include "mozIGeckoMediaPluginService.h"
 #include "VideoUtils.h"
 #include "mozilla/Services.h"
 #include "nsIObserverService.h"
 #include "mozilla/EMEUtils.h"
+#include "GMPUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeySystemAccess,
                                       mParent)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeySystemAccess)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeySystemAccess)
@@ -155,19 +156,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 "GMPUtils.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"\\*");
new file mode 100644
--- /dev/null
+++ b/dom/media/gmp/GMPUtils.cpp
@@ -0,0 +1,38 @@
+/* -*- 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 "GMPUtils.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsIFile.h"
+#include "nsCOMPtr.h"
+
+namespace mozilla {
+
+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/gmp/GMPUtils.h
+++ b/dom/media/gmp/GMPUtils.h
@@ -16,11 +16,15 @@ struct DestroyPolicy
   void operator()(T* aGMPObject) const {
     aGMPObject->Destroy();
   }
 };
 
 template<typename T>
 using GMPUniquePtr = mozilla::UniquePtr<T, DestroyPolicy<T>>;
 
+bool GetEMEVoucherPath(nsIFile** aPath);
+
+bool EMEVoucherFileExists();
+
 } // namespace mozilla
 
 #endif
--- a/dom/media/gmp/moz.build
+++ b/dom/media/gmp/moz.build
@@ -93,16 +93,17 @@ UNIFIED_SOURCES += [
     'GMPService.cpp',
     'GMPServiceChild.cpp',
     'GMPServiceParent.cpp',
     'GMPSharedMemManager.cpp',
     'GMPStorageChild.cpp',
     'GMPStorageParent.cpp',
     'GMPTimerChild.cpp',
     'GMPTimerParent.cpp',
+    'GMPUtils.cpp',
     'GMPVideoDecoderChild.cpp',
     'GMPVideoDecoderParent.cpp',
     'GMPVideoEncodedFrameImpl.cpp',
     'GMPVideoEncoderChild.cpp',
     'GMPVideoEncoderParent.cpp',
     'GMPVideoHost.cpp',
     'GMPVideoi420FrameImpl.cpp',
     'GMPVideoPlaneImpl.cpp',