Bug 1657521 - P6. Attempt to create a decoder via the PDMFactory as fallback. r=jolin
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 13 Aug 2020 02:15:58 +0000
changeset 544500 d6c1978bcabea9bbadd17764a249a504577e3ca9
parent 544499 791287b954142d17ae82c82ce9a4cf992d36eeea
child 544501 a0b9da32637e3aa75aa5386a66ac21030d1c6f1a
push id124072
push userjyavenard@mozilla.com
push dateThu, 13 Aug 2020 04:30:00 +0000
treeherderautoland@d6c1978bcabe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjolin
bugs1657521
milestone81.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 1657521 - P6. Attempt to create a decoder via the PDMFactory as fallback. r=jolin The MediaChangeMonitor would always use the selected PDM in order to create a decoder; this only worked if the Decode method returned an error if the format was unsupported and this is how the WMF decoder worked. However, the AppleVTDecoder fails on creation instead. Now that the VP9 profile is known at creation time, we should move the WMF decoder to do the same. Differential Revision: https://phabricator.services.mozilla.com/D86545
dom/media/platforms/PlatformDecoderModule.h
dom/media/platforms/wrappers/MediaChangeMonitor.cpp
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -61,17 +61,17 @@ struct MOZ_STACK_CLASS CreateDecoderPara
   using OptionSet = EnumSet<Option>;
 
   struct UseNullDecoder {
     UseNullDecoder() = default;
     explicit UseNullDecoder(bool aUseNullDecoder) : mUse(aUseNullDecoder) {}
     bool mUse = false;
   };
 
-  // Do not wrap H264 decoder in a H264Converter.
+  // Do not wrap decoder in a MediaChangeMonitor.
   struct NoWrapper {
     NoWrapper() = default;
     explicit NoWrapper(bool aDontUseWrapper)
         : mDontUseWrapper(aDontUseWrapper) {}
     bool mDontUseWrapper = false;
   };
 
   struct VideoFrameRate {
--- a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp
+++ b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp
@@ -466,20 +466,29 @@ MediaResult MediaChangeMonitor::CreateDe
 
   MediaResult error = NS_OK;
   mDecoder = mPDM->CreateVideoDecoder(
       {mCurrentConfig, mTaskQueue, aDiagnostics, mImageContainer,
        mKnowsCompositor, mGMPCrashHelper, mType, mOnWaitingForKeyEvent,
        mDecoderOptions, mRate, &error});
 
   if (!mDecoder) {
-    if (NS_FAILED(error)) {
-      // The decoder supports CreateDecoderParam::mError, returns the value.
-      return error;
-    } else {
+    // We failed to create a decoder with the existing PDM; attempt once again
+    // with a PDMFactory.
+    RefPtr<PDMFactory> factory = new PDMFactory();
+    mDecoder = factory->CreateDecoder(
+        {mCurrentConfig, mTaskQueue, aDiagnostics, mImageContainer,
+         mKnowsCompositor, mGMPCrashHelper, mType, mOnWaitingForKeyEvent,
+         mDecoderOptions, mRate, &error, CreateDecoderParams::NoWrapper(true)});
+
+    if (!mDecoder) {
+      if (NS_FAILED(error)) {
+        // The decoder supports CreateDecoderParam::mError, returns the value.
+        return error;
+      }
       return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                          RESULT_DETAIL("Unable to create decoder"));
     }
   }
 
   DDLINKCHILD("decoder", mDecoder.get());
 
   mDecoderInitialized = false;