Bug 1314858 - Remove GMPDecoderModule::UpdateUsableCodecs. r=gerald draft
authorChris Pearce <cpearce@mozilla.com>
Wed, 02 Nov 2016 15:31:21 +1300
changeset 433501 77cd678431669cc3932cfaabc7034e546b92166c
parent 433500 6f66e97cb22fa8f92a2d26adffeba60ec8a30936
child 433502 fc6b582bb302b8c9aa26d055c6a7297e740a4e54
push id34604
push usercpearce@mozilla.com
push dateThu, 03 Nov 2016 21:15:09 +0000
reviewersgerald
bugs1314858
milestone52.0a1
Bug 1314858 - Remove GMPDecoderModule::UpdateUsableCodecs. r=gerald MozReview-Commit-ID: 7678JImLL9T
dom/media/gmp/GMPServiceParent.cpp
dom/media/platforms/PDMFactory.cpp
dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
dom/media/platforms/agnostic/gmp/GMPDecoderModule.h
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -832,24 +832,16 @@ private:
 NS_IMETHODIMP
 GeckoMediaPluginServiceParent::PathRunnable::Run()
 {
   mService->RemoveOnGMPThread(mPath,
                               mOperation == REMOVE_AND_DELETE_FROM_DISK,
                               mDefer);
 
   mService->UpdateContentProcessGMPCapabilities();
-
-#ifndef MOZ_WIDGET_GONK // Bug 1214967: disabled on B2G due to inscrutable test failures.
-  // For non-e10s, and for decoding in the chrome process, must update GMP
-  // PDM's codecs list directly.
-  NS_DispatchToMainThread(NS_NewRunnableFunction([]() -> void {
-    GMPDecoderModule::UpdateUsableCodecs();
-  }));
-#endif
   return NS_OK;
 }
 
 void
 GeckoMediaPluginServiceParent::UpdateContentProcessGMPCapabilities()
 {
   if (!NS_IsMainThread()) {
     nsCOMPtr<nsIRunnable> task =
@@ -914,19 +906,16 @@ GeckoMediaPluginServiceParent::AsyncAddP
   RefPtr<GeckoMediaPluginServiceParent> self = this;
   return InvokeAsync(thread, this, __func__, &GeckoMediaPluginServiceParent::AddOnGMPThread, dir)
     ->Then(AbstractThread::MainThread(), __func__,
       [dir, self]() -> void {
         LOGD(("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s succeeded",
               NS_ConvertUTF16toUTF8(dir).get()));
         MOZ_ASSERT(NS_IsMainThread());
         self->UpdateContentProcessGMPCapabilities();
-        // For non-e10s, and for decoding in the chrome process, must update GMP
-        // PDM's codecs list directly.
-        GMPDecoderModule::UpdateUsableCodecs();
       },
       [dir]() -> void {
         LOGD(("GeckoMediaPluginServiceParent::AsyncAddPluginDirectory %s failed",
               NS_ConvertUTF16toUTF8(dir).get()));
       })
     ->CompletionPromise();
 }
 
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -68,17 +68,16 @@ public:
     AppleDecoderModule::Init();
 #endif
 #ifdef MOZ_FFVPX
     FFVPXRuntimeLinker::Init();
 #endif
 #ifdef MOZ_FFMPEG
     FFmpegRuntimeLinker::Init();
 #endif
-    GMPDecoderModule::Init();
   }
 };
 
 StaticAutoPtr<PDMFactoryImpl> PDMFactory::sInstance;
 StaticMutex PDMFactory::sMonitor;
 
 class SupportChecker
 {
--- a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
@@ -115,65 +115,16 @@ HasGMPFor(const nsACString& aAPI,
   }
   bool hasPlugin = false;
   if (NS_FAILED(mps->HasPluginForAPI(aAPI, &tags, &hasPlugin))) {
     return false;
   }
   return hasPlugin;
 }
 
-StaticMutex sGMPCodecsMutex;
-
-struct GMPCodecs {
-  const nsLiteralCString mKeySystem;
-  bool mHasAAC;
-  bool mHasH264;
-  bool mHasVP8;
-  bool mHasVP9;
-};
-
-static GMPCodecs sGMPCodecs[] = {
-  { kEMEKeySystemClearkey, false, false, false, false },
-  { kEMEKeySystemWidevine, false, false, false, false },
-  { kEMEKeySystemPrimetime, false, false, false, false },
-};
-
-void
-GMPDecoderModule::UpdateUsableCodecs()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  StaticMutexAutoLock lock(sGMPCodecsMutex);
-  for (GMPCodecs& gmp : sGMPCodecs) {
-    gmp.mHasAAC = HasGMPFor(NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER),
-                            NS_LITERAL_CSTRING("aac"),
-                            gmp.mKeySystem);
-    gmp.mHasH264 = HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
-                             NS_LITERAL_CSTRING("h264"),
-                             gmp.mKeySystem);
-    gmp.mHasVP8 = HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
-                            NS_LITERAL_CSTRING("vp8"),
-                            gmp.mKeySystem);
-    gmp.mHasVP9 = HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
-                            NS_LITERAL_CSTRING("vp9"),
-                            gmp.mKeySystem);
-  }
-}
-
-/* static */
-void
-GMPDecoderModule::Init()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  // GMPService::HasPluginForAPI is main thread only, so to implement
-  // SupportsMimeType() we build a table of the codecs which each whitelisted
-  // GMP has and update it when any GMPs are removed or added at runtime.
-  UpdateUsableCodecs();
-}
-
 /* static */
 const Maybe<nsCString>
 GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
 {
   Maybe<nsCString> rv;
   if (aMimeType.EqualsLiteral("audio/mp4a-latm")) {
     switch (MediaPrefs::GMPAACPreferred()) {
       case 1: rv.emplace(kEMEKeySystemClearkey); break;
--- a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.h
+++ b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.h
@@ -41,23 +41,17 @@ public:
 
   ConversionRequired
   DecoderNeedsConversion(const TrackInfo& aConfig) const override;
 
   bool
   SupportsMimeType(const nsACString& aMimeType,
                    DecoderDoctorDiagnostics* aDiagnostics) const override;
 
-  // Main thread only.
-  static void Init();
-
   static const Maybe<nsCString> PreferredGMP(const nsACString& aMimeType);
 
   static bool SupportsMimeType(const nsACString& aMimeType,
                                const Maybe<nsCString>& aGMP);
-
-  // Main thread only.
-  static void UpdateUsableCodecs();
 };
 
 } // namespace mozilla
 
 #endif // GMPDecoderModule_h_