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/eme/mediafoundation/WMFCDMProxy.h | 134 ++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 dom/media/eme/mediafoundation/WMFCDMProxy.h (limited to 'dom/media/eme/mediafoundation/WMFCDMProxy.h') diff --git a/dom/media/eme/mediafoundation/WMFCDMProxy.h b/dom/media/eme/mediafoundation/WMFCDMProxy.h new file mode 100644 index 0000000000..7766b73f21 --- /dev/null +++ b/dom/media/eme/mediafoundation/WMFCDMProxy.h @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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_EME_MEDIAFOUNDATION_WMFCDMPROXY_H_ +#define DOM_MEDIA_EME_MEDIAFOUNDATION_WMFCDMPROXY_H_ + +#include "mozilla/CDMProxy.h" +#include "mozilla/CDMCaps.h" +#include "mozilla/MozPromise.h" +#include "mozilla/dom/MediaKeys.h" +#include "mozilla/dom/MediaKeySession.h" +#include "mozilla/RefPtr.h" +#include "mozilla/WMFCDMImpl.h" + +#include "nsString.h" + +namespace mozilla { + +class WMFCDMProxyCallback; + +class WMFCDMProxy : public CDMProxy { + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WMFCDMProxy, override) + + WMFCDMProxy(dom::MediaKeys* aKeys, const nsAString& aKeySystem, + const dom::MediaKeySystemConfiguration& aConfig); + + // CDMProxy interface + void Init(PromiseId aPromiseId, const nsAString& aOrigin, + const nsAString& aTopLevelOrigin, const nsAString& aName) override; + + void CreateSession(uint32_t aCreateSessionToken, + MediaKeySessionType aSessionType, PromiseId aPromiseId, + const nsAString& aInitDataType, + nsTArray& aInitData) override; + + void LoadSession(PromiseId aPromiseId, dom::MediaKeySessionType aSessionType, + const nsAString& aSessionId) override; + + void SetServerCertificate(PromiseId aPromiseId, + nsTArray& aCert) override {} + + void UpdateSession(const nsAString& aSessionId, PromiseId aPromiseId, + nsTArray& aResponse) override; + + void CloseSession(const nsAString& aSessionId, PromiseId aPromiseId) override; + + void RemoveSession(const nsAString& aSessionId, + PromiseId aPromiseId) override; + + void QueryOutputProtectionStatus() override {} + + void NotifyOutputProtectionStatus( + OutputProtectionCheckStatus aCheckStatus, + OutputProtectionCaptureStatus aCaptureStatus) override {} + + void Shutdown() override; + + void Terminated() override {} + + void OnSetSessionId(uint32_t aCreateSessionToken, + const nsAString& aSessionId) override {} + + void OnResolveLoadSessionPromise(uint32_t aPromiseId, + bool aSuccess) override {} + + void OnSessionMessage(const nsAString& aSessionId, + dom::MediaKeyMessageType aMessageType, + const nsTArray& aMessage) override; + + void OnExpirationChange(const nsAString& aSessionId, + UnixTime aExpiryTime) override; + + void OnSessionClosed(const nsAString& aSessionId) override {} + + void OnSessionError(const nsAString& aSessionId, nsresult aException, + uint32_t aSystemCode, const nsAString& aMsg) override {} + + void OnRejectPromise(uint32_t aPromiseId, ErrorResult&& aException, + const nsCString& aMsg) override {} + + RefPtr Decrypt(MediaRawData* aSample) override { + return nullptr; + } + void OnDecrypted(uint32_t aId, DecryptStatus aResult, + const nsTArray& aDecryptedData) override {} + + void ResolvePromise(PromiseId aId) override; + void RejectPromise(PromiseId aId, ErrorResult&& aException, + const nsCString& aReason) override; + + void OnKeyStatusesChange(const nsAString& aSessionId) override; + + void GetStatusForPolicy(PromiseId aPromiseId, + const nsAString& aMinHdcpVersion) override {} + +#ifdef DEBUG + bool IsOnOwnerThread() override { + return NS_GetCurrentThread() == mOwnerThread; + } +#endif + + WMFCDMProxy* AsWMFCDMProxy() override { return this; } + + // Can only be called after initialization succeeded. + uint64_t GetCDMProxyId() const; + + private: + virtual ~WMFCDMProxy(); + + template + void ResolvePromiseWithResult(PromiseId aId, const T& aResult) {} + void RejectPromiseOnMainThread(PromiseId aId, + CopyableErrorResult&& aException, + const nsCString& aReason); + // Reject promise with an InvalidStateError and the given message. + void RejectPromiseWithStateError(PromiseId aId, const nsCString& aReason); + + RefPtr mCDM; + + const dom::MediaKeySystemConfiguration mConfig; + + RefPtr mProxyCallback; + + // It can only be used on the main thread. + bool mIsShutdown = false; +}; + +} // namespace mozilla + +#endif // DOM_MEDIA_EME_MEDIAFOUNDATION_WMFCDMPROXY_H_ -- cgit v1.2.3