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/MFCDMParent.h | 116 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 dom/media/ipc/MFCDMParent.h (limited to 'dom/media/ipc/MFCDMParent.h') diff --git a/dom/media/ipc/MFCDMParent.h b/dom/media/ipc/MFCDMParent.h new file mode 100644 index 0000000000..c0696d5edc --- /dev/null +++ b/dom/media/ipc/MFCDMParent.h @@ -0,0 +1,116 @@ +/* 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 DOM_MEDIA_IPC_MFCDMPARENT_H_ +#define DOM_MEDIA_IPC_MFCDMPARENT_H_ + +#include + +#include "mozilla/Assertions.h" +#include "mozilla/PMFCDMParent.h" +#include "MFCDMExtra.h" +#include "MFCDMSession.h" +#include "MFPMPHostWrapper.h" +#include "RemoteDecoderManagerParent.h" + +namespace mozilla { + +class MFCDMProxy; + +/** + * MFCDMParent is a wrapper class for the Media Foundation CDM in the utility + * process. + * It's responsible to create and manage a CDM and its sessions, and acts as a + * proxy to the Media Foundation interfaces + * (https://learn.microsoft.com/en-us/windows/win32/api/mfcontentdecryptionmodule/) + * by accepting calls from and calling back to MFCDMChild in the content + * process. + */ +class MFCDMParent final : public PMFCDMParent { + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MFCDMParent); + + MFCDMParent(const nsAString& aKeySystem, RemoteDecoderManagerParent* aManager, + nsISerialEventTarget* aManagerThread); + + static MFCDMParent* GetCDMById(uint64_t aId) { + MOZ_ASSERT(sRegisteredCDMs.Contains(aId)); + return sRegisteredCDMs.Get(aId); + } + uint64_t Id() const { return mId; } + + mozilla::ipc::IPCResult RecvGetCapabilities( + GetCapabilitiesResolver&& aResolver); + + mozilla::ipc::IPCResult RecvInit(const MFCDMInitParamsIPDL& aParams, + InitResolver&& aResolver); + + mozilla::ipc::IPCResult RecvCreateSessionAndGenerateRequest( + const MFCDMCreateSessionParamsIPDL& aParams, + CreateSessionAndGenerateRequestResolver&& aResolver); + + mozilla::ipc::IPCResult RecvLoadSession( + const KeySystemConfig::SessionType& aSessionType, + const nsString& aSessionId, LoadSessionResolver&& aResolver); + + mozilla::ipc::IPCResult RecvUpdateSession( + const nsString& aSessionId, const CopyableTArray& aResponse, + UpdateSessionResolver&& aResolver); + + mozilla::ipc::IPCResult RecvCloseSession(const nsString& aSessionId, + UpdateSessionResolver&& aResolver); + + mozilla::ipc::IPCResult RecvRemoveSession(const nsString& aSessionId, + UpdateSessionResolver&& aResolver); + + nsISerialEventTarget* ManagerThread() { return mManagerThread; } + void AssertOnManagerThread() const { + MOZ_ASSERT(mManagerThread->IsOnCurrentThread()); + } + + already_AddRefed GetMFCDMProxy(); + + void Destroy(); + + private: + ~MFCDMParent() { Unregister(); } + + HRESULT LoadFactory(); + + void Register(); + void Unregister(); + + void ConnectSessionEvents(MFCDMSession* aSession); + + MFCDMSession* GetSession(const nsString& aSessionId); + + nsString mKeySystem; + + const RefPtr mManager; + const RefPtr mManagerThread; + + static inline nsTHashMap sRegisteredCDMs; + + static inline uint64_t sNextId = 1; + const uint64_t mId; + + RefPtr mIPDLSelfRef; + Microsoft::WRL::ComPtr mFactory; + Microsoft::WRL::ComPtr mCDM; + Microsoft::WRL::ComPtr mPMPHostWrapper; + + std::map> mSessions; + + MediaEventForwarder mKeyMessageEvents; + MediaEventForwarder mKeyChangeEvents; + MediaEventForwarder mExpirationEvents; + + MediaEventListener mKeyMessageListener; + MediaEventListener mKeyChangeListener; + MediaEventListener mExpirationListener; +}; + +} // namespace mozilla + +#endif // DOM_MEDIA_IPC_MFCDMPARENT_H_ -- cgit v1.2.3