diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/platforms/wmf/MFCDMProxy.cpp | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/platforms/wmf/MFCDMProxy.cpp')
-rw-r--r-- | dom/media/platforms/wmf/MFCDMProxy.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/dom/media/platforms/wmf/MFCDMProxy.cpp b/dom/media/platforms/wmf/MFCDMProxy.cpp new file mode 100644 index 0000000000..f460f5fb02 --- /dev/null +++ b/dom/media/platforms/wmf/MFCDMProxy.cpp @@ -0,0 +1,74 @@ +/* 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/. */ + +#include "MFCDMProxy.h" + +#include "MFMediaEngineUtils.h" + +namespace mozilla { + +using Microsoft::WRL::ComPtr; + +#define LOG(msg, ...) \ + MOZ_LOG(gMFMediaEngineLog, LogLevel::Debug, \ + ("MFCDMProxy=%p, " msg, this, ##__VA_ARGS__)) + +HRESULT MFCDMProxy::GetPMPServer(REFIID aRiid, LPVOID* aPMPServerOut) { + ComPtr<IMFGetService> cdmServices; + RETURN_IF_FAILED(mCDM.As(&cdmServices)); + RETURN_IF_FAILED(cdmServices->GetService(MF_CONTENTDECRYPTIONMODULE_SERVICE, + aRiid, aPMPServerOut)); + return S_OK; +} + +HRESULT MFCDMProxy::GetInputTrustAuthority(uint32_t aStreamId, + const uint8_t* aContentInitData, + uint32_t aContentInitDataSize, + REFIID aRiid, + IUnknown** aInputTrustAuthorityOut) { + if (mInputTrustAuthorities.count(aStreamId)) { + RETURN_IF_FAILED( + mInputTrustAuthorities[aStreamId].CopyTo(aInputTrustAuthorityOut)); + return S_OK; + } + + if (!mTrustedInput) { + RETURN_IF_FAILED(mCDM->CreateTrustedInput( + aContentInitData, aContentInitDataSize, &mTrustedInput)); + LOG("Created a trust input for stream %u", aStreamId); + } + + // GetInputTrustAuthority takes IUnknown* as the output. Using other COM + // interface will have a v-table mismatch issue. + ComPtr<IUnknown> unknown; + RETURN_IF_FAILED( + mTrustedInput->GetInputTrustAuthority(aStreamId, aRiid, &unknown)); + + ComPtr<IMFInputTrustAuthority> inputTrustAuthority; + RETURN_IF_FAILED(unknown.As(&inputTrustAuthority)); + RETURN_IF_FAILED(unknown.CopyTo(aInputTrustAuthorityOut)); + + mInputTrustAuthorities[aStreamId] = inputTrustAuthority; + return S_OK; +} + +HRESULT MFCDMProxy::SetContentEnabler(IUnknown* aRequest, + IMFAsyncResult* aResult) { + LOG("SetContentEnabler"); + ComPtr<IMFContentEnabler> contentEnabler; + RETURN_IF_FAILED(aRequest->QueryInterface(IID_PPV_ARGS(&contentEnabler))); + return mCDM->SetContentEnabler(contentEnabler.Get(), aResult); +} + +void MFCDMProxy::OnHardwareContextReset() { + LOG("OnHardwareContextReset"); + // Hardware context reset happens, all the crypto sessions are in invalid + // states. So drop everything here. + mTrustedInput.Reset(); + mInputTrustAuthorities.clear(); +} + +#undef LOG + +} // namespace mozilla |