Bug 1314858 - Make GMPDecoderModule::SupportsMimeType call GMPService::HasPluginForAPI() directly. r=gerald draft
authorChris Pearce <cpearce@mozilla.com>
Wed, 02 Nov 2016 10:04:39 +1300
changeset 433500 6f66e97cb22fa8f92a2d26adffeba60ec8a30936
parent 433499 90e6018b6574c0d2f5a51ad56ab87ef5b535f124
child 433501 77cd678431669cc3932cfaabc7034e546b92166c
push id34604
push usercpearce@mozilla.com
push dateThu, 03 Nov 2016 21:15:09 +0000
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