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/platforms/wmf/MFPMPHostWrapper.cpp | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 dom/media/platforms/wmf/MFPMPHostWrapper.cpp (limited to 'dom/media/platforms/wmf/MFPMPHostWrapper.cpp') diff --git a/dom/media/platforms/wmf/MFPMPHostWrapper.cpp b/dom/media/platforms/wmf/MFPMPHostWrapper.cpp new file mode 100644 index 0000000000..64266f4ad5 --- /dev/null +++ b/dom/media/platforms/wmf/MFPMPHostWrapper.cpp @@ -0,0 +1,66 @@ +/* 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 "MFPMPHostWrapper.h" + +#include "MFMediaEngineUtils.h" +#include "WMF.h" +#include "mozilla/EMEUtils.h" + +namespace mozilla { + +using Microsoft::WRL::ComPtr; + +#define LOG(msg, ...) EME_LOG("MFPMPHostWrapper=%p, " msg, this, ##__VA_ARGS__) + +HRESULT MFPMPHostWrapper::RuntimeClassInitialize( + Microsoft::WRL::ComPtr& aHost) { + mPMPHost = aHost; + return S_OK; +} + +STDMETHODIMP MFPMPHostWrapper::LockProcess() { return mPMPHost->LockProcess(); } + +STDMETHODIMP MFPMPHostWrapper::UnlockProcess() { + return mPMPHost->UnlockProcess(); +} + +STDMETHODIMP MFPMPHostWrapper::ActivateClassById(LPCWSTR aId, IStream* aStream, + REFIID aRiid, + void** aActivatedClass) { + LOG("ActivateClassById, id=%ls", aId); + ComPtr creationAttributes; + RETURN_IF_FAILED(wmf::MFCreateAttributes(&creationAttributes, 2)); + RETURN_IF_FAILED(creationAttributes->SetString(GUID_ClassName, aId)); + + if (aStream) { + STATSTG statstg; + RETURN_IF_FAILED( + aStream->Stat(&statstg, STATFLAG_NOOPEN | STATFLAG_NONAME)); + nsTArray streamBlob; + streamBlob.SetLength(statstg.cbSize.LowPart); + unsigned long readSize = 0; + RETURN_IF_FAILED( + aStream->Read(&streamBlob[0], streamBlob.Length(), &readSize)); + RETURN_IF_FAILED(creationAttributes->SetBlob(GUID_ObjectStream, + &streamBlob[0], readSize)); + } + + ComPtr outputStream; + RETURN_IF_FAILED(CreateStreamOnHGlobal(nullptr, TRUE, &outputStream)); + RETURN_IF_FAILED(wmf::MFSerializeAttributesToStream(creationAttributes.Get(), + 0, outputStream.Get())); + RETURN_IF_FAILED(outputStream->Seek({}, STREAM_SEEK_SET, nullptr)); + + ComPtr activator; + RETURN_IF_FAILED(mPMPHost->CreateObjectByCLSID( + CLSID_EMEStoreActivate, outputStream.Get(), IID_PPV_ARGS(&activator))); + RETURN_IF_FAILED(activator->ActivateObject(aRiid, aActivatedClass)); + LOG("Done ActivateClassById, id=%ls", aId); + return S_OK; +} + +#undef LOG + +} // namespace mozilla -- cgit v1.2.3