Bug 1314858 - Make GMPDecoderModule::SupportsMimeType call GMPService::HasPluginForAPI() directly. r=gerald
authorChris Pearce <cpearce@mozilla.com>
Wed, 02 Nov 2016 10:04:39 +1300
changeset 347650 a37b70e85582ca5c46d5f9e7874c340472f27af1
parent 347649 86b73731ba98bf9e2cebeca248469f5ecca25790
child 347651 d0325b2bd63cdb685e1df4393eb03e6fc14c0400
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1314858
milestone52.0a1
Bug 1314858 - Make GMPDecoderModule::SupportsMimeType call GMPService::HasPluginForAPI() directly. r=gerald MozReview-Commit-ID: 3VblaPbTQFJ
dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
--- a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
@@ -100,35 +100,16 @@ GMPDecoderModule::DecoderNeedsConversion
   }
 }
 
 static bool
 HasGMPFor(const nsACString& aAPI,
           const nsACString& aCodec,
           const nsACString& aGMP)
 {
-#ifdef XP_WIN
-  // gmp-clearkey uses WMF for decoding, so if we're using clearkey we must
-  // verify that WMF works before continuing.
-  if (aGMP.Equals(kEMEKeySystemClearkey)) {
-    RefPtr<WMFDecoderModule> pdm(new WMFDecoderModule());
-    if (aCodec.EqualsLiteral("aac") &&
-        !pdm->SupportsMimeType(NS_LITERAL_CSTRING("audio/mp4a-latm"),
-                               /* DecoderDoctorDiagnostics* */ nullptr)) {
-      return false;
-    }
-    if (aCodec.EqualsLiteral("h264") &&
-        !pdm->SupportsMimeType(NS_LITERAL_CSTRING("video/avc"),
-                               /* DecoderDoctorDiagnostics* */ nullptr)) {
-      return false;
-    }
-  }
-#endif
-  MOZ_ASSERT(NS_IsMainThread(),
-             "HasPluginForAPI must be called on the main thread");
   nsTArray<nsCString> tags;
   tags.AppendElement(aCodec);
   tags.AppendElement(aGMP);
   nsCOMPtr<mozIGeckoMediaPluginService> mps =
     do_GetService("@mozilla.org/gecko-media-plugin-service;1");
   if (NS_WARN_IF(!mps)) {
     return false;
   }
@@ -212,25 +193,42 @@ GMPDecoderModule::PreferredGMP(const nsA
   return rv;
 }
 
 /* static */
 bool
 GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType,
                                    const Maybe<nsCString>& aGMP)
 {
-  StaticMutexAutoLock lock(sGMPCodecsMutex);
-  for (GMPCodecs& gmp : sGMPCodecs) {
-    if (((aMimeType.EqualsLiteral("audio/mp4a-latm") && gmp.mHasAAC) ||
-         (MP4Decoder::IsH264(aMimeType) && gmp.mHasH264) ||
-         (VPXDecoder::IsVP8(aMimeType) && gmp.mHasVP8) ||
-         (VPXDecoder::IsVP9(aMimeType) && gmp.mHasVP9)) &&
-        (aGMP.isNothing() || aGMP.value().Equals(gmp.mKeySystem))) {
-      return true;
-    }
+  if (aGMP.isNothing()) {
+    return false;
+  }
+
+  if (MP4Decoder::IsH264(aMimeType)) {
+    return HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
+                     NS_LITERAL_CSTRING("h264"),
+                     aGMP.value());
+  }
+
+  if (VPXDecoder::IsVP9(aMimeType)) {
+    return HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
+                     NS_LITERAL_CSTRING("vp9"),
+                     aGMP.value());
+  }
+
+  if (VPXDecoder::IsVP8(aMimeType)) {
+    return HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
+                     NS_LITERAL_CSTRING("vp8"),
+                     aGMP.value());
+  }
+
+  if (MP4Decoder::IsAAC(aMimeType)) {
+    return HasGMPFor(NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER),
+                     NS_LITERAL_CSTRING("aac"),
+                     aGMP.value());
   }
 
   return false;
 }
 
 bool
 GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType,
                                    DecoderDoctorDiagnostics* aDiagnostics) const