Bug 1496529 - P7. Pass full range of CreateDecoderParam::Option to RemoteVideoDecoder r=bryce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 09 Oct 2018 16:59:24 +0000
changeset 498803 970b4aaccd355a7512297b26c198441937fc9328
parent 498802 40f7fbd43f5189d6710be9a96bc852f73debf6ac
child 498804 357d4762fa8fda3470020886958c300aae51cb22
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbryce
bugs1496529
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 1496529 - P7. Pass full range of CreateDecoderParam::Option to RemoteVideoDecoder r=bryce Depends on D7882 Differential Revision: https://phabricator.services.mozilla.com/D7895
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
dom/media/platforms/PlatformDecoderModule.h
--- a/dom/media/ipc/PVideoDecoderManager.ipdl
+++ b/dom/media/ipc/PVideoDecoderManager.ipdl
@@ -4,31 +4,33 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PTexture;
 include protocol PVideoDecoder;
 include LayersSurfaces;
 include "mozilla/dom/MediaIPCUtils.h";
 using VideoInfo from "MediaInfo.h";
 using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
+using mozilla::CreateDecoderParams::Option from "PlatformDecoderModule.h";
+using mozilla::CreateDecoderParams::OptionSet from "PlatformDecoderModule.h";
 
 namespace mozilla {
 namespace dom {
 
 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, bool disallowHWDecoder, TextureFactoryIdentifier identifier)
+  sync PVideoDecoder(VideoInfo info, float framerate, OptionSet options, 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,18 +187,17 @@ 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.mOptions,
           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,17 +172,17 @@ VideoDecoderChild::ActorDestroy(ActorDes
                                 mBlacklistedD3D11Driver,
                                 mBlacklistedD3D9Driver);
 #endif // XP_WIN
 }
 
 MediaResult
 VideoDecoderChild::InitIPDL(const VideoInfo& aVideoInfo,
                             float aFramerate,
-                            bool aDisallowHWDecoder,
+                            const CreateDecoderParams::OptionSet& aOptions,
                             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.
@@ -202,17 +202,17 @@ VideoDecoderChild::InitIPDL(const VideoI
   }
 
   mIPDLSelfRef = this;
   bool success = false;
   nsCString errorDescription;
   if (manager->SendPVideoDecoderConstructor(this,
                                             aVideoInfo,
                                             aFramerate,
-                                            aDisallowHWDecoder,
+                                            aOptions,
                                             aIdentifier,
                                             &success,
                                             &mBlacklistedD3D11Driver,
                                             &mBlacklistedD3D9Driver,
                                             &errorDescription)) {
     mCanSend = true;
   }
 
--- a/dom/media/ipc/VideoDecoderChild.h
+++ b/dom/media/ipc/VideoDecoderChild.h
@@ -46,17 +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 CreateDecoderParams::OptionSet& aOptions,
                        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
@@ -111,24 +111,25 @@ VideoDecoderManagerChild::GetManagerThre
 
 /* static */ AbstractThread*
 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 */)
+VideoDecoderManagerChild::AllocPVideoDecoderChild(
+  const VideoInfo& aVideoInfo,
+  const float& aFramerate,
+  const CreateDecoderParams::OptionSet& aOptions,
+  const layers::TextureFactoryIdentifier& aIdentifier,
+  bool* aSuccess,
+  nsCString* /* not used */,
+  nsCString* /* not used */,
+  nsCString* /* not used */)
 {
   return new VideoDecoderChild();
 }
 
 bool
 VideoDecoderManagerChild::DeallocPVideoDecoderChild(PVideoDecoderChild* actor)
 {
   VideoDecoderChild* child = static_cast<VideoDecoderChild*>(actor);
--- a/dom/media/ipc/VideoDecoderManagerChild.h
+++ b/dom/media/ipc/VideoDecoderManagerChild.h
@@ -65,24 +65,25 @@ public:
 protected:
   void InitIPDL();
 
   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;
+  PVideoDecoderChild* AllocPVideoDecoderChild(
+    const VideoInfo& aVideoInfo,
+    const float& aFramerate,
+    const CreateDecoderParams::OptionSet& aOptions,
+    const layers::TextureFactoryIdentifier& aIdentifier,
+    bool* aSuccess,
+    nsCString* aBlacklistedD3D11Driver,
+    nsCString* aBlacklistedD3D9Driver,
+    nsCString* aErrorDescription) override;
   bool DeallocPVideoDecoderChild(PVideoDecoderChild* actor) override;
 
 private:
   // Main thread only
   static void InitializeThread();
 
   VideoDecoderManagerChild()
     : mCanSend(false)
--- a/dom/media/ipc/VideoDecoderManagerParent.cpp
+++ b/dom/media/ipc/VideoDecoderManagerParent.cpp
@@ -196,32 +196,39 @@ VideoDecoderManagerParent::~VideoDecoder
 
 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)
+VideoDecoderManagerParent::AllocPVideoDecoderParent(
+  const VideoInfo& aVideoInfo,
+  const float& aFramerate,
+  const CreateDecoderParams::OptionSet& aOptions,
+  const layers::TextureFactoryIdentifier& aIdentifier,
+  bool* aSuccess,
+  nsCString* aBlacklistedD3D11Driver,
+  nsCString* aBlacklistedD3D9Driver,
+  nsCString* aErrorDescription)
 {
-  RefPtr<TaskQueue> decodeTaskQueue = new TaskQueue(
-    GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER),
-    "VideoDecoderParent::mDecodeTaskQueue");
+  RefPtr<TaskQueue> decodeTaskQueue =
+    new TaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER),
+                  "VideoDecoderParent::mDecodeTaskQueue");
 
-  auto* parent = new VideoDecoderParent(
-    this, aVideoInfo, aFramerate, aDisallowHWDecoder, aIdentifier,
-    sManagerTaskQueue, decodeTaskQueue, aSuccess, aErrorDescription);
+  auto* parent = new VideoDecoderParent(this,
+                                        aVideoInfo,
+                                        aFramerate,
+                                        aOptions,
+                                        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
@@ -26,24 +26,25 @@ public:
   static void StartupThreads();
   static void ShutdownThreads();
 
   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;
+  PVideoDecoderParent* AllocPVideoDecoderParent(
+    const VideoInfo& aVideoInfo,
+    const float& aFramerate,
+    const CreateDecoderParams::OptionSet& aOptions,
+    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;
   mozilla::ipc::IPCResult RecvDeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD) override;
 
   void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override;
 
   void DeallocPVideoDecoderManagerParent() override;
--- a/dom/media/ipc/VideoDecoderParent.cpp
+++ b/dom/media/ipc/VideoDecoderParent.cpp
@@ -37,25 +37,26 @@ public:
   layers::LayersIPCActor* GetLayersIPCActor() override
   {
     return VideoBridgeChild::GetSingleton();
   }
 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)
+VideoDecoderParent::VideoDecoderParent(
+  VideoDecoderManagerParent* aParent,
+  const VideoInfo& aVideoInfo,
+  float aFramerate,
+  const CreateDecoderParams::OptionSet& aOptions,
+  const layers::TextureFactoryIdentifier& aIdentifier,
+  TaskQueue* aManagerTaskQueue,
+  TaskQueue* aDecodeTaskQueue,
+  bool* aSuccess,
+  nsCString* aErrorDescription)
   : mParent(aParent)
   , mManagerTaskQueue(aManagerTaskQueue)
   , mDecodeTaskQueue(aDecodeTaskQueue)
   , mKnowsCompositor(new KnowsCompositorVideo)
   , mDestroyed(false)
 {
   MOZ_COUNT_CTOR(VideoDecoderParent);
   MOZ_ASSERT(OnManagerThread());
@@ -77,18 +78,17 @@ VideoDecoderParent::VideoDecoderParent(V
   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);
+  params.mOptions = aOptions;
   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,17 +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 CreateDecoderParams::OptionSet& aOptions,
                      const layers::TextureFactoryIdentifier& aIdentifier,
                      TaskQueue* aManagerTaskQueue,
                      TaskQueue* aDecodeTaskQueue,
                      bool* aSuccess,
                      nsCString* aErrorDescription);
 
   void Destroy();
 
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -8,16 +8,17 @@
 #define PlatformDecoderModule_h_
 
 #include "DecoderDoctorLogger.h"
 #include "GMPCrashHelper.h"
 #include "MediaEventSource.h"
 #include "MediaInfo.h"
 #include "MediaResult.h"
 #include "mozilla/EnumSet.h"
+#include "mozilla/EnumTypeTraits.h"
 #include "mozilla/MozPromise.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/TaskQueue.h"
 #include "mozilla/layers/KnowsCompositor.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "nsTArray.h"
 #include <queue>
 
@@ -154,16 +155,25 @@ private:
   template <typename T1, typename T2, typename... Ts>
   void Set(T1&& a1, T2&& a2, Ts&&... args)
   {
     Set(std::forward<T1>(a1));
     Set(std::forward<T2>(a2), std::forward<Ts>(args)...);
   }
 };
 
+// Used for IPDL serialization.
+// The 'value' have to be the biggest enum from CreateDecoderParams::Option.
+template <>
+struct MaxEnumValue<::mozilla::CreateDecoderParams::Option>
+{
+  static constexpr unsigned int value = static_cast<unsigned int>(CreateDecoderParams::Option::HardwareDecoderNotAllowed);
+};
+
+
 // The PlatformDecoderModule interface is used by the MediaFormatReader to
 // abstract access to decoders provided by various
 // platforms.
 // Each platform (Windows, MacOSX, Linux, B2G etc) must implement a
 // PlatformDecoderModule to provide access to its decoders in order to get
 // decompressed H.264/AAC from the MediaFormatReader.
 //
 // Decoding is asynchronous, and should be performed on the task queue