diff --git a/dom/media/ipc/PVideoDecoderManager.ipdl b/dom/media/ipc/PVideoDecoderManager.ipdl index 4ebe8dd8fbb7..60c0dbe29a26 100644 --- a/dom/media/ipc/PVideoDecoderManager.ipdl +++ b/dom/media/ipc/PVideoDecoderManager.ipdl @@ -9,6 +9,8 @@ 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 { @@ -23,7 +25,7 @@ parent: // 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, diff --git a/dom/media/ipc/RemoteVideoDecoder.cpp b/dom/media/ipc/RemoteVideoDecoder.cpp index 895bf05839fe..0c212c698c58 100644 --- a/dom/media/ipc/RemoteVideoDecoder.cpp +++ b/dom/media/ipc/RemoteVideoDecoder.cpp @@ -192,8 +192,7 @@ RemoteDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams) result = object->mActor->InitIPDL( aParams.VideoConfig(), aParams.mRate.mValue, - aParams.mOptions.contains( - CreateDecoderParams::Option::HardwareDecoderNotAllowed), + aParams.mOptions, aParams.mKnowsCompositor->GetTextureFactoryIdentifier()); }), NS_DISPATCH_NORMAL); diff --git a/dom/media/ipc/VideoDecoderChild.cpp b/dom/media/ipc/VideoDecoderChild.cpp index bfaed69582a1..8cd2e258a3d3 100644 --- a/dom/media/ipc/VideoDecoderChild.cpp +++ b/dom/media/ipc/VideoDecoderChild.cpp @@ -177,7 +177,7 @@ VideoDecoderChild::ActorDestroy(ActorDestroyReason aWhy) MediaResult VideoDecoderChild::InitIPDL(const VideoInfo& aVideoInfo, float aFramerate, - bool aDisallowHWDecoder, + const CreateDecoderParams::OptionSet& aOptions, const layers::TextureFactoryIdentifier& aIdentifier) { RefPtr manager = @@ -207,7 +207,7 @@ VideoDecoderChild::InitIPDL(const VideoInfo& aVideoInfo, if (manager->SendPVideoDecoderConstructor(this, aVideoInfo, aFramerate, - aDisallowHWDecoder, + aOptions, aIdentifier, &success, &mBlacklistedD3D11Driver, diff --git a/dom/media/ipc/VideoDecoderChild.h b/dom/media/ipc/VideoDecoderChild.h index 458ef0a2f0d6..8eaf65ea0004 100644 --- a/dom/media/ipc/VideoDecoderChild.h +++ b/dom/media/ipc/VideoDecoderChild.h @@ -51,7 +51,7 @@ public: MOZ_IS_CLASS_INIT MediaResult InitIPDL(const VideoInfo& aVideoInfo, float aFramerate, - bool aDisallowHWDecoder, + const CreateDecoderParams::OptionSet& aOptions, const layers::TextureFactoryIdentifier& aIdentifier); void DestroyIPDL(); diff --git a/dom/media/ipc/VideoDecoderManagerChild.cpp b/dom/media/ipc/VideoDecoderManagerChild.cpp index 0e3a051b3bc5..a9a900d704a8 100644 --- a/dom/media/ipc/VideoDecoderManagerChild.cpp +++ b/dom/media/ipc/VideoDecoderManagerChild.cpp @@ -116,14 +116,15 @@ VideoDecoderManagerChild::GetManagerAbstractThread() } 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(); } diff --git a/dom/media/ipc/VideoDecoderManagerChild.h b/dom/media/ipc/VideoDecoderManagerChild.h index 2e78a968df4d..eef952fda3ac 100644 --- a/dom/media/ipc/VideoDecoderManagerChild.h +++ b/dom/media/ipc/VideoDecoderManagerChild.h @@ -70,14 +70,15 @@ protected: 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: diff --git a/dom/media/ipc/VideoDecoderManagerParent.cpp b/dom/media/ipc/VideoDecoderManagerParent.cpp index e5c723088540..9926365b442d 100644 --- a/dom/media/ipc/VideoDecoderManagerParent.cpp +++ b/dom/media/ipc/VideoDecoderManagerParent.cpp @@ -201,22 +201,29 @@ VideoDecoderManagerParent::ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyRea } 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 decodeTaskQueue = new TaskQueue( - GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER), - "VideoDecoderParent::mDecodeTaskQueue"); + RefPtr 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(); diff --git a/dom/media/ipc/VideoDecoderManagerParent.h b/dom/media/ipc/VideoDecoderManagerParent.h index 563906565dc6..39fa935c5103 100644 --- a/dom/media/ipc/VideoDecoderManagerParent.h +++ b/dom/media/ipc/VideoDecoderManagerParent.h @@ -31,14 +31,15 @@ public: 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; diff --git a/dom/media/ipc/VideoDecoderParent.cpp b/dom/media/ipc/VideoDecoderParent.cpp index 98718445a0a5..037af7cc2703 100644 --- a/dom/media/ipc/VideoDecoderParent.cpp +++ b/dom/media/ipc/VideoDecoderParent.cpp @@ -42,15 +42,16 @@ 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) @@ -82,8 +83,7 @@ VideoDecoderParent::VideoDecoderParent(VideoDecoderManagerParent* aParent, 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; diff --git a/dom/media/ipc/VideoDecoderParent.h b/dom/media/ipc/VideoDecoderParent.h index 7ac75f30d0a9..c8857a07091f 100644 --- a/dom/media/ipc/VideoDecoderParent.h +++ b/dom/media/ipc/VideoDecoderParent.h @@ -29,7 +29,7 @@ public: VideoDecoderParent(VideoDecoderManagerParent* aParent, const VideoInfo& aVideoInfo, float aFramerate, - bool aDisallowHWDecoder, + const CreateDecoderParams::OptionSet& aOptions, const layers::TextureFactoryIdentifier& aIdentifier, TaskQueue* aManagerTaskQueue, TaskQueue* aDecodeTaskQueue, diff --git a/dom/media/platforms/PlatformDecoderModule.h b/dom/media/platforms/PlatformDecoderModule.h index be27199cd8f7..a52902d855ba 100644 --- a/dom/media/platforms/PlatformDecoderModule.h +++ b/dom/media/platforms/PlatformDecoderModule.h @@ -13,6 +13,7 @@ #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" @@ -159,6 +160,15 @@ private: } }; +// 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(CreateDecoderParams::Option::HardwareDecoderNotAllowed); +}; + + // The PlatformDecoderModule interface is used by the MediaFormatReader to // abstract access to decoders provided by various // platforms.