Bug 1322234 - P5. Pass the disallow HW decoder flag to remote video decoder. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 04 Oct 2018 09:45:26 +0000
changeset 439553 ce1b5017a90e556d4f70a8a85fbce6470c912b31
parent 439552 415c0a43a2405afb40480b370dea0e0a2a2049c5
child 439554 7790aa7225e2426134e2414b0be0bd79c7479fe9
push id34778
push usernbeleuzu@mozilla.com
push dateThu, 04 Oct 2018 15:22:02 +0000
treeherdermozilla-central@01634947caab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1322234
milestone64.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 1322234 - P5. Pass the disallow HW decoder flag to remote video decoder. r=mattwoodrow We'll need to handle EnumSet in ipdl at some stage. Depends on D7648 Differential Revision: https://phabricator.services.mozilla.com/D7699
dom/media/ipc/PVideoDecoderManager.ipdl
dom/media/ipc/RemoteVideoDecoder.cpp
dom/media/ipc/VideoDecoderChild.cpp
dom/media/ipc/VideoDecoderChild.h
dom/media/ipc/VideoDecoderManagerChild.cpp
dom/media/ipc/VideoDecoderManagerChild.h
dom/media/ipc/VideoDecoderManagerParent.cpp
dom/media/ipc/VideoDecoderManagerParent.h
dom/media/ipc/VideoDecoderParent.cpp
dom/media/ipc/VideoDecoderParent.h
--- a/dom/media/ipc/PVideoDecoderManager.ipdl
+++ b/dom/media/ipc/PVideoDecoderManager.ipdl
@@ -18,17 +18,17 @@ sync protocol PVideoDecoderManager
   manages PVideoDecoder;
 parent:
   // aBlacklistedD3D11Driver and aBlacklistedD3D9Driver are used to read back the blacklisted driver information
   // from GPU process to content process.
   // We should have added a new sync method to read back this information but, in that way, we also introduce one
   // more sync IPC call.
   // Considering that this information is only used for telemetry usage in bug 1393392 and should be removed once
   // we have collected enough data, we add these two return values here for convenience.
-  sync PVideoDecoder(VideoInfo info, float framerate, TextureFactoryIdentifier identifier)
+  sync PVideoDecoder(VideoInfo info, float framerate, bool disallowHWDecoder, TextureFactoryIdentifier identifier)
          returns (bool success,
                   nsCString aBlacklistedD3D11Driver,
                   nsCString aBlacklistedD3D9Driver,
                   nsCString aErrorDescription);
 
   sync Readback(SurfaceDescriptorGPUVideo sd) returns (SurfaceDescriptor aResult);
 
   async DeallocateSurfaceDescriptorGPUVideo(SurfaceDescriptorGPUVideo sd);
--- a/dom/media/ipc/RemoteVideoDecoder.cpp
+++ b/dom/media/ipc/RemoteVideoDecoder.cpp
@@ -187,16 +187,18 @@ RemoteDecoderModule::CreateVideoDecoder(
   VideoDecoderManagerChild::GetManagerThread()->Dispatch(
     NS_NewRunnableFunction(
       "dom::RemoteDecoderModule::CreateVideoDecoder",
       [&]() {
         AutoCompleteTask complete(&task);
         result = object->mActor->InitIPDL(
           aParams.VideoConfig(),
           aParams.mRate.mValue,
+          aParams.mOptions.contains(
+            CreateDecoderParams::Option::HardwareDecoderNotAllowed),
           aParams.mKnowsCompositor->GetTextureFactoryIdentifier());
       }),
     NS_DISPATCH_NORMAL);
   task.Wait();
 
   if (NS_FAILED(result)) {
     if (aParams.mError) {
       *aParams.mError = result;
--- a/dom/media/ipc/VideoDecoderChild.cpp
+++ b/dom/media/ipc/VideoDecoderChild.cpp
@@ -172,16 +172,17 @@ VideoDecoderChild::ActorDestroy(ActorDes
                                 mBlacklistedD3D11Driver,
                                 mBlacklistedD3D9Driver);
 #endif // XP_WIN
 }
 
 MediaResult
 VideoDecoderChild::InitIPDL(const VideoInfo& aVideoInfo,
                             float aFramerate,
+                            bool aDisallowHWDecoder,
                             const layers::TextureFactoryIdentifier& aIdentifier)
 {
   RefPtr<VideoDecoderManagerChild> manager =
     VideoDecoderManagerChild::GetSingleton();
 
   // The manager isn't available because VideoDecoderManagerChild has been
   // initialized with null end points and we don't want to decode video on GPU
   // process anymore. Return false here so that we can fallback to other PDMs.
@@ -201,16 +202,17 @@ VideoDecoderChild::InitIPDL(const VideoI
   }
 
   mIPDLSelfRef = this;
   bool success = false;
   nsCString errorDescription;
   if (manager->SendPVideoDecoderConstructor(this,
                                             aVideoInfo,
                                             aFramerate,
+                                            aDisallowHWDecoder,
                                             aIdentifier,
                                             &success,
                                             &mBlacklistedD3D11Driver,
                                             &mBlacklistedD3D9Driver,
                                             &errorDescription)) {
     mCanSend = true;
   }
 
--- a/dom/media/ipc/VideoDecoderChild.h
+++ b/dom/media/ipc/VideoDecoderChild.h
@@ -46,16 +46,17 @@ public:
   bool IsHardwareAccelerated(nsACString& aFailureReason) const;
   nsCString GetDescriptionName() const;
   void SetSeekThreshold(const media::TimeUnit& aTime);
   MediaDataDecoder::ConversionRequired NeedsConversion() const;
 
   MOZ_IS_CLASS_INIT
   MediaResult InitIPDL(const VideoInfo& aVideoInfo,
                        float aFramerate,
+                       bool aDisallowHWDecoder,
                        const layers::TextureFactoryIdentifier& aIdentifier);
   void DestroyIPDL();
 
   // Called from IPDL when our actor has been destroyed
   void IPDLActorDestroyed();
 
   VideoDecoderManagerChild* GetManager();
 
--- a/dom/media/ipc/VideoDecoderManagerChild.cpp
+++ b/dom/media/ipc/VideoDecoderManagerChild.cpp
@@ -113,16 +113,17 @@ VideoDecoderManagerChild::GetManagerThre
 VideoDecoderManagerChild::GetManagerAbstractThread()
 {
   return sVideoDecoderChildAbstractThread;
 }
 
 PVideoDecoderChild*
 VideoDecoderManagerChild::AllocPVideoDecoderChild(const VideoInfo& aVideoInfo,
                                                   const float& aFramerate,
+                                                  const bool& aDisallowHWDecoder,
                                                   const layers::TextureFactoryIdentifier& aIdentifier,
                                                   bool* aSuccess,
                                                   nsCString* /* not used */,
                                                   nsCString* /* not used */,
                                                   nsCString* /* not used */)
 {
   return new VideoDecoderChild();
 }
--- a/dom/media/ipc/VideoDecoderManagerChild.h
+++ b/dom/media/ipc/VideoDecoderManagerChild.h
@@ -67,16 +67,17 @@ protected:
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
   void DeallocPVideoDecoderManagerChild() override;
 
   void HandleFatalError(const char* aMsg) const override;
 
   PVideoDecoderChild* AllocPVideoDecoderChild(const VideoInfo& aVideoInfo,
                                               const float& aFramerate,
+                                              const bool& aDisallowHWDecoder,
                                               const layers::TextureFactoryIdentifier& aIdentifier,
                                               bool* aSuccess,
                                               nsCString* aBlacklistedD3D11Driver,
                                               nsCString* aBlacklistedD3D9Driver,
                                               nsCString* aErrorDescription) override;
   bool DeallocPVideoDecoderChild(PVideoDecoderChild* actor) override;
 
 private:
--- a/dom/media/ipc/VideoDecoderManagerParent.cpp
+++ b/dom/media/ipc/VideoDecoderManagerParent.cpp
@@ -198,28 +198,29 @@ void
 VideoDecoderManagerParent::ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason)
 {
   mThreadHolder = nullptr;
 }
 
 PVideoDecoderParent*
 VideoDecoderManagerParent::AllocPVideoDecoderParent(const VideoInfo& aVideoInfo,
                                                     const float& aFramerate,
+                                                    const bool& aDisallowHWDecoder,
                                                     const layers::TextureFactoryIdentifier& aIdentifier,
                                                     bool* aSuccess,
                                                     nsCString* aBlacklistedD3D11Driver,
                                                     nsCString* aBlacklistedD3D9Driver,
                                                     nsCString* aErrorDescription)
 {
   RefPtr<TaskQueue> decodeTaskQueue = new TaskQueue(
     GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER),
     "VideoDecoderParent::mDecodeTaskQueue");
 
   auto* parent = new VideoDecoderParent(
-    this, aVideoInfo, aFramerate, aIdentifier,
+    this, aVideoInfo, aFramerate, aDisallowHWDecoder, aIdentifier,
     sManagerTaskQueue, decodeTaskQueue, aSuccess, aErrorDescription);
 
 #ifdef XP_WIN
   *aBlacklistedD3D11Driver = GetFoundD3D11BlacklistedDLL();
   *aBlacklistedD3D9Driver = GetFoundD3D9BlacklistedDLL();
 #endif // XP_WIN
 
   return parent;
--- a/dom/media/ipc/VideoDecoderManagerParent.h
+++ b/dom/media/ipc/VideoDecoderManagerParent.h
@@ -28,16 +28,17 @@ public:
 
   static void ShutdownVideoBridge();
 
   bool OnManagerThread();
 
 protected:
   PVideoDecoderParent* AllocPVideoDecoderParent(const VideoInfo& aVideoInfo,
                                                 const float& aFramerate,
+                                                const bool& aDisallowHWDecoder,
                                                 const layers::TextureFactoryIdentifier& aIdentifier,
                                                 bool* aSuccess,
                                                 nsCString* aBlacklistedD3D11Driver,
                                                 nsCString* aBlacklistedD3D9Driver,
                                                 nsCString* aErrorDescription) override;
   bool DeallocPVideoDecoderParent(PVideoDecoderParent* actor) override;
 
   mozilla::ipc::IPCResult RecvReadback(const SurfaceDescriptorGPUVideo& aSD, SurfaceDescriptor* aResult) override;
--- a/dom/media/ipc/VideoDecoderParent.cpp
+++ b/dom/media/ipc/VideoDecoderParent.cpp
@@ -40,16 +40,17 @@ public:
   }
 private:
   virtual ~KnowsCompositorVideo() = default;
 };
 
 VideoDecoderParent::VideoDecoderParent(VideoDecoderManagerParent* aParent,
                                        const VideoInfo& aVideoInfo,
                                        float aFramerate,
+                                       bool aDisallowHWDecoder,
                                        const layers::TextureFactoryIdentifier& aIdentifier,
                                        TaskQueue* aManagerTaskQueue,
                                        TaskQueue* aDecodeTaskQueue,
                                        bool* aSuccess,
                                        nsCString* aErrorDescription)
   : mParent(aParent)
   , mManagerTaskQueue(aManagerTaskQueue)
   , mDecodeTaskQueue(aDecodeTaskQueue)
@@ -62,27 +63,32 @@ VideoDecoderParent::VideoDecoderParent(V
   // explictly destroys us. There may still be refs held by
   // tasks, but no new ones should be added after we're
   // destroyed.
   mIPDLSelfRef = this;
 
   mKnowsCompositor->IdentifyTextureHost(aIdentifier);
 
 #ifdef XP_WIN
+  using Option = CreateDecoderParams::Option;
+  using OptionSet = CreateDecoderParams::OptionSet;
+
   // TODO: Ideally we wouldn't hardcode the WMF PDM, and we'd use the normal PDM
   // factory logic for picking a decoder.
   WMFDecoderModule::Init();
   RefPtr<WMFDecoderModule> pdm(new WMFDecoderModule());
   pdm->Startup();
 
   CreateDecoderParams params(aVideoInfo);
   params.mTaskQueue = mDecodeTaskQueue;
   params.mKnowsCompositor = mKnowsCompositor;
   params.mImageContainer = new layers::ImageContainer();
   params.mRate = CreateDecoderParams::VideoFrameRate(aFramerate);
+  params.mOptions = OptionSet(
+    aDisallowHWDecoder ? Option::HardwareDecoderNotAllowed : Option::Default);
   MediaResult error(NS_OK);
   params.mError = &error;
 
   mDecoder = pdm->CreateVideoDecoder(params);
 
   if (NS_FAILED(error)) {
     MOZ_ASSERT(aErrorDescription);
     *aErrorDescription = error.Description();
--- a/dom/media/ipc/VideoDecoderParent.h
+++ b/dom/media/ipc/VideoDecoderParent.h
@@ -24,16 +24,17 @@ class VideoDecoderParent final : public 
 public:
   // We refcount this class since the task queue can have runnables
   // that reference us.
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderParent)
 
   VideoDecoderParent(VideoDecoderManagerParent* aParent,
                      const VideoInfo& aVideoInfo,
                      float aFramerate,
+                     bool aDisallowHWDecoder,
                      const layers::TextureFactoryIdentifier& aIdentifier,
                      TaskQueue* aManagerTaskQueue,
                      TaskQueue* aDecodeTaskQueue,
                      bool* aSuccess,
                      nsCString* aErrorDescription);
 
   void Destroy();