Bug 848994 - p2. Detect when WMF is not found - r=cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 22 Apr 2016 11:48:28 +1000
changeset 355183 f2506b33d79174616120f8413b7d890871bf239a
parent 355182 65499eec533972a21885a71365aa043e92aed53f
child 355184 63977c43feccf317a8d21715926b2b19d4325dc1
push id16221
push usergsquelart@mozilla.com
push dateFri, 22 Apr 2016 01:56:41 +0000
reviewerscpearce
bugs848994
milestone48.0a1
Bug 848994 - p2. Detect when WMF is not found - r=cpearce MozReview-Commit-ID: IHvgJNjuyQA
dom/media/DecoderDoctorDiagnostics.cpp
dom/media/DecoderDoctorDiagnostics.h
dom/media/platforms/PDMFactory.cpp
dom/media/platforms/PDMFactory.h
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -441,16 +441,19 @@ DecoderDoctorDiagnostics::StoreFormatDia
 nsCString
 DecoderDoctorDiagnostics::GetDescription() const
 {
   nsCString s;
   if (!mFormat.IsEmpty()) {
     s = "format='";
     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";
     }
   } else {
     s = "?";
   }
   return s;
 }
--- a/dom/media/DecoderDoctorDiagnostics.h
+++ b/dom/media/DecoderDoctorDiagnostics.h
@@ -43,22 +43,26 @@ public:
   // Description string, for logging purposes.
   nsCString GetDescription() const;
 
   // Methods to record diagnostic information:
 
   const nsAString& Format() const { return mFormat; }
   bool CanPlay() const { return mCanPlay; }
 
+  void SetWMFFailedToLoad() { mWMFFailedToLoad = true; }
+  bool DidWMFFailToLoad() const { return mWMFFailedToLoad; }
+
   void SetFFmpegFailedToLoad() { mFFmpegFailedToLoad = true; }
   bool DidFFmpegFailToLoad() const { return mFFmpegFailedToLoad; }
 
 private:
   nsString mFormat;
   // True if there is at least one decoder that can play that format.
   bool mCanPlay = false;
 
+  bool mWMFFailedToLoad = false;
   bool mFFmpegFailedToLoad = false;
 };
 
 } // namespace mozilla
 
 #endif
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -160,16 +160,19 @@ PDMFactory::CreateDecoder(const TrackInf
                                 aDiagnostics,
                                 aLayersBackend,
                                 aImageContainer);
   }
 
   if (aDiagnostics) {
     // 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();
     }
   }
 
   for (auto& current : mCurrentPDMs) {
     if (!current->SupportsMimeType(aConfig.mMimeType, aDiagnostics)) {
       continue;
@@ -285,17 +288,19 @@ PDMFactory::CreatePDMs()
   if(sAndroidMCDecoderPreferred && sAndroidMCDecoderEnabled) {
     m = new AndroidDecoderModule();
     StartupPDM(m);
   }
 #endif
 #ifdef XP_WIN
   if (sWMFDecoderEnabled) {
     m = new WMFDecoderModule();
-    StartupPDM(m);
+    if (!StartupPDM(m)) {
+      mWMFFailedToLoad = true;
+    }
   }
 #endif
 #ifdef MOZ_FFVPX
   if (sFFVPXDecoderEnabled) {
     m = FFVPXRuntimeLinker::CreateDecoderModule();
     StartupPDM(m);
   }
 #endif
@@ -345,16 +350,19 @@ PDMFactory::StartupPDM(PlatformDecoderMo
 
 already_AddRefed<PlatformDecoderModule>
 PDMFactory::GetDecoder(const nsACString& aMimeType,
                        DecoderDoctorDiagnostics* aDiagnostics) const
 {
   if (aDiagnostics) {
     // 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();
     }
   }
 
   RefPtr<PlatformDecoderModule> pdm;
   for (auto& current : mCurrentPDMs) {
     if (current->SupportsMimeType(aMimeType, aDiagnostics)) {
--- a/dom/media/platforms/PDMFactory.h
+++ b/dom/media/platforms/PDMFactory.h
@@ -90,14 +90,15 @@ private:
 #endif
   static bool sEnableFuzzingWrapper;
   static uint32_t sVideoOutputMinimumInterval_ms;
   static bool sDontDelayInputExhausted;
 
   nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
   RefPtr<PlatformDecoderModule> mEMEPDM;
 
+  bool mWMFFailedToLoad = false;
   bool mFFmpegFailedToLoad = false;
 };
 
 } // namespace mozilla
 
 #endif /* PDMFactory_h_ */