From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- dom/media/ipc/RemoteDecoderChild.h | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 dom/media/ipc/RemoteDecoderChild.h (limited to 'dom/media/ipc/RemoteDecoderChild.h') diff --git a/dom/media/ipc/RemoteDecoderChild.h b/dom/media/ipc/RemoteDecoderChild.h new file mode 100644 index 0000000000..b1c283cbe8 --- /dev/null +++ b/dom/media/ipc/RemoteDecoderChild.h @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef include_dom_media_ipc_RemoteDecoderChild_h +#define include_dom_media_ipc_RemoteDecoderChild_h + +#include + +#include "mozilla/PRemoteDecoderChild.h" +#include "mozilla/RemoteDecoderManagerChild.h" +#include "mozilla/ShmemRecycleAllocator.h" + +namespace mozilla { + +class RemoteDecoderManagerChild; +using mozilla::MediaDataDecoder; +using mozilla::ipc::IPCResult; + +class RemoteDecoderChild : public ShmemRecycleAllocator, + public PRemoteDecoderChild { + friend class PRemoteDecoderChild; + + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteDecoderChild); + + explicit RemoteDecoderChild(RemoteDecodeIn aLocation); + + void ActorDestroy(ActorDestroyReason aWhy) override; + + // This interface closely mirrors the MediaDataDecoder plus a bit + // (DestroyIPDL) to allow proxying to a remote decoder in RemoteDecoderModule. + RefPtr Init(); + RefPtr Decode( + const nsTArray>& aSamples); + RefPtr Drain(); + RefPtr Flush(); + RefPtr Shutdown(); + bool IsHardwareAccelerated(nsACString& aFailureReason) const; + nsCString GetDescriptionName() const; + nsCString GetProcessName() const; + nsCString GetCodecName() const; + void SetSeekThreshold(const media::TimeUnit& aTime); + MediaDataDecoder::ConversionRequired NeedsConversion() const; + void DestroyIPDL(); + + // Called from IPDL when our actor has been destroyed + void IPDLActorDestroyed(); + + RemoteDecoderManagerChild* GetManager(); + + protected: + virtual ~RemoteDecoderChild(); + void AssertOnManagerThread() const; + + virtual MediaResult ProcessOutput(DecodedOutputIPDL&& aDecodedData) = 0; + virtual void RecordShutdownTelemetry(bool aForAbnormalShutdown) {} + + RefPtr mIPDLSelfRef; + MediaDataDecoder::DecodedData mDecodedData; + const RemoteDecodeIn mLocation; + + private: + const nsCOMPtr mThread; + + MozPromiseHolder mInitPromise; + MozPromiseRequestHolder mInitPromiseRequest; + MozPromiseHolder mDecodePromise; + MozPromiseHolder mDrainPromise; + MozPromiseHolder mFlushPromise; + MozPromiseHolder mShutdownPromise; + + void HandleRejectionError( + const ipc::ResponseRejectReason& aReason, + std::function&& aCallback); + + nsCString mHardwareAcceleratedReason; + nsCString mDescription; + nsCString mProcessName; + nsCString mCodecName; + bool mIsHardwareAccelerated = false; + bool mRemoteDecoderCrashed = false; + MediaDataDecoder::ConversionRequired mConversion = + MediaDataDecoder::ConversionRequired::kNeedNone; +}; + +} // namespace mozilla + +#endif // include_dom_media_ipc_RemoteDecoderChild_h -- cgit v1.2.3