Bug 848994 - p4. Record GMP diagnostics - r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 22 Apr 2016 13:42:11 +1000
changeset 332309 1c4133b49948431d4c98d0e9bde33eb6f38f3916
parent 332308 826d477a117b93d745f8dddb2ca3e1a3f2bc77eb
child 332310 0843709b5d55e352fc464a43619bb982a4af6487
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs848994
milestone48.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 848994 - p4. Record GMP diagnostics - r=cpearce Record diagnostics information about whether the GMP CDM failed to load (though currently impossible!), and which GMP is used in the current media format check. MozReview-Commit-ID: 4B8kDTAiV6b
dom/media/DecoderDoctorDiagnostics.cpp
dom/media/DecoderDoctorDiagnostics.h
dom/media/platforms/PDMFactory.cpp
dom/media/platforms/PDMFactory.h
dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -519,16 +519,23 @@ DecoderDoctorDiagnostics::GetDescription
     s += NS_ConvertUTF16toUTF8(mFormat).get();
     s += mCanPlay ? "', can play" : "', cannot play";
     if (mWMFFailedToLoad) {
       s += ", Windows platform decoder failed to load";
     }
     if (mFFmpegFailedToLoad) {
       s += ", Linux platform decoder failed to load";
     }
+    if (mGMPPDMFailedToStartup) {
+      s += ", GMP PDM failed to startup";
+    } else if (!mGMP.IsEmpty()) {
+      s += ", Using GMP '";
+      s += mGMP;
+      s += "'";
+    }
     break;
   case eMediaKeySystemAccessRequest:
     s = "key system='";
     s += NS_ConvertUTF16toUTF8(mKeySystem).get();
     s += mIsKeySystemSupported ? "', supported" : "', not supported";
     switch (mKeySystemIssue) {
     case eUnset:
       break;
--- a/dom/media/DecoderDoctorDiagnostics.h
+++ b/dom/media/DecoderDoctorDiagnostics.h
@@ -62,16 +62,21 @@ public:
   bool CanPlay() const { return mCanPlay; }
 
   void SetWMFFailedToLoad() { mWMFFailedToLoad = true; }
   bool DidWMFFailToLoad() const { return mWMFFailedToLoad; }
 
   void SetFFmpegFailedToLoad() { mFFmpegFailedToLoad = true; }
   bool DidFFmpegFailToLoad() const { return mFFmpegFailedToLoad; }
 
+  void SetGMPPDMFailedToStartup() { mGMPPDMFailedToStartup = true; }
+  bool DidGMPPDMFailToStartup() const { return mGMPPDMFailedToStartup; }
+  void SetGMP(const nsACString& aGMP) { mGMP = aGMP; }
+  const nsACString& GMP() const { return mGMP; }
+
   const nsAString& KeySystem() const { return mKeySystem; }
   bool IsKeySystemSupported() const { return mIsKeySystemSupported; }
   enum KeySystemIssue {
     eUnset,
     eWidevineWithNoWMF
   };
   void SetKeySystemIssue(KeySystemIssue aKeySystemIssue)
   {
@@ -89,16 +94,18 @@ private:
   DiagnosticsType mDiagnosticsType = eUnsaved;
 
   nsString mFormat;
   // True if there is at least one decoder that can play that format.
   bool mCanPlay = false;
 
   bool mWMFFailedToLoad = false;
   bool mFFmpegFailedToLoad = false;
+  bool mGMPPDMFailedToStartup = false;
+  nsCString mGMP;
 
   nsString mKeySystem;
   bool mIsKeySystemSupported = false;
   KeySystemIssue mKeySystemIssue = eUnset;
 };
 
 } // namespace mozilla
 
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -166,16 +166,19 @@ PDMFactory::CreateDecoder(const TrackInf
     // If libraries failed to load, the following loop over mCurrentPDMs
     // will not even try to use them. So we record failures now.
     if (mWMFFailedToLoad) {
       aDiagnostics->SetWMFFailedToLoad();
     }
     if (mFFmpegFailedToLoad) {
       aDiagnostics->SetFFmpegFailedToLoad();
     }
+    if (mGMPPDMFailedToStartup) {
+      aDiagnostics->SetGMPPDMFailedToStartup();
+    }
   }
 
   for (auto& current : mCurrentPDMs) {
     if (!current->SupportsMimeType(aConfig.mMimeType, aDiagnostics)) {
       continue;
     }
     RefPtr<MediaDataDecoder> m =
       CreateDecoderWithPDM(current,
@@ -329,18 +332,20 @@ PDMFactory::CreatePDMs()
   }
 #endif
 
   m = new AgnosticDecoderModule();
   StartupPDM(m);
 
   if (sGMPDecoderEnabled) {
     m = new GMPDecoderModule();
-    StartupPDM(m);
-  }  
+    if (!StartupPDM(m)) {
+      mGMPPDMFailedToStartup = true;
+    }
+  }
 }
 
 bool
 PDMFactory::StartupPDM(PlatformDecoderModule* aPDM)
 {
   if (aPDM && NS_SUCCEEDED(aPDM->Startup())) {
     mCurrentPDMs.AppendElement(aPDM);
     return true;
@@ -356,16 +361,19 @@ PDMFactory::GetDecoder(const nsACString&
     // If libraries failed to load, the following loop over mCurrentPDMs
     // will not even try to use them. So we record failures now.
     if (mWMFFailedToLoad) {
       aDiagnostics->SetWMFFailedToLoad();
     }
     if (mFFmpegFailedToLoad) {
       aDiagnostics->SetFFmpegFailedToLoad();
     }
+    if (mGMPPDMFailedToStartup) {
+      aDiagnostics->SetGMPPDMFailedToStartup();
+    }
   }
 
   RefPtr<PlatformDecoderModule> pdm;
   for (auto& current : mCurrentPDMs) {
     if (current->SupportsMimeType(aMimeType, aDiagnostics)) {
       pdm = current;
       break;
     }
--- a/dom/media/platforms/PDMFactory.h
+++ b/dom/media/platforms/PDMFactory.h
@@ -92,13 +92,14 @@ private:
   static uint32_t sVideoOutputMinimumInterval_ms;
   static bool sDontDelayInputExhausted;
 
   nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
   RefPtr<PlatformDecoderModule> mEMEPDM;
 
   bool mWMFFailedToLoad = false;
   bool mFFmpegFailedToLoad = false;
+  bool mGMPPDMFailedToStartup = false;
 };
 
 } // namespace mozilla
 
 #endif /* PDMFactory_h_ */
--- a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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 "GMPDecoderModule.h"
+#include "DecoderDoctorDiagnostics.h"
 #include "GMPAudioDecoder.h"
 #include "GMPVideoDecoder.h"
 #include "MediaDataDecoderProxy.h"
 #include "mozIGeckoMediaPluginService.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticMutex.h"
 #include "gmp-audio-decode.h"
@@ -50,16 +51,23 @@ GMPDecoderModule::CreateVideoDecoder(con
                                      FlushableTaskQueue* aVideoTaskQueue,
                                      MediaDataDecoderCallback* aCallback,
                                      DecoderDoctorDiagnostics* aDiagnostics)
 {
   if (!aConfig.mMimeType.EqualsLiteral("video/avc")) {
     return nullptr;
   }
 
+  if (aDiagnostics) {
+    const Maybe<nsCString> preferredGMP = PreferredGMP(aConfig.mMimeType);
+    if (preferredGMP.isSome()) {
+      aDiagnostics->SetGMP(preferredGMP.value());
+    }
+  }
+
   RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aCallback);
   wrapper->SetProxyTarget(new GMPVideoDecoder(aConfig,
                                               aLayersBackend,
                                               aImageContainer,
                                               aVideoTaskQueue,
                                               wrapper->Callback()));
   return wrapper.forget();
 }
@@ -69,16 +77,23 @@ GMPDecoderModule::CreateAudioDecoder(con
                                      FlushableTaskQueue* aAudioTaskQueue,
                                      MediaDataDecoderCallback* aCallback,
                                      DecoderDoctorDiagnostics* aDiagnostics)
 {
   if (!aConfig.mMimeType.EqualsLiteral("audio/mp4a-latm")) {
     return nullptr;
   }
 
+  if (aDiagnostics) {
+    const Maybe<nsCString> preferredGMP = PreferredGMP(aConfig.mMimeType);
+    if (preferredGMP.isSome()) {
+      aDiagnostics->SetGMP(preferredGMP.value());
+    }
+  }
+
   RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aCallback);
   wrapper->SetProxyTarget(new GMPAudioDecoder(aConfig,
                                               aAudioTaskQueue,
                                               wrapper->Callback()));
   return wrapper.forget();
 }
 
 PlatformDecoderModule::ConversionRequired
@@ -227,12 +242,17 @@ GMPDecoderModule::SupportsMimeType(const
 
   return false;
 }
 
 bool
 GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType,
                                    DecoderDoctorDiagnostics* aDiagnostics) const
 {
-  return SupportsMimeType(aMimeType, PreferredGMP(aMimeType));
+  const Maybe<nsCString> preferredGMP = PreferredGMP(aMimeType);
+  bool rv = SupportsMimeType(aMimeType, preferredGMP);
+  if (rv && aDiagnostics && preferredGMP.isSome()) {
+    aDiagnostics->SetGMP(preferredGMP.value());
+  }
+  return rv;
 }
 
 } // namespace mozilla