From 008cf28373d9db4c07d4c1ff2f8f9f0f7a6f7e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Thu, 22 Aug 2024 22:08:29 +0200 Subject: [PATCH] resampledmo: Register the Resampler DMO class. --- configure | 2 + configure.ac | 1 + dlls/resampledmo/Makefile.in | 6 + dlls/resampledmo/resampledmo.c | 136 +++++++++++++++++++ dlls/resampledmo/resampledmo.idl | 25 ++++ dlls/resampledmo/resampledmo.spec | 4 + dlls/winegstreamer/main.c | 13 +- dlls/winegstreamer/mfplat.c | 16 --- dlls/winegstreamer/winegstreamer_classes.idl | 4 +- loader/wine.inf.in | 1 + 10 files changed, 179 insertions(+), 29 deletions(-) create mode 100644 dlls/resampledmo/Makefile.in create mode 100644 dlls/resampledmo/resampledmo.c create mode 100644 dlls/resampledmo/resampledmo.idl create mode 100644 dlls/resampledmo/resampledmo.spec diff --git a/configure b/configure index 745b6faa46e..d24a05350ae 100755 --- a/configure +++ b/configure @@ -1387,6 +1387,7 @@ enable_qwave enable_rasapi32 enable_rasdlg enable_regapi +enable_resampledmo enable_resutils enable_riched20 enable_riched32 @@ -22585,6 +22586,7 @@ wine_fn_config_makefile dlls/rasapi32 enable_rasapi32 wine_fn_config_makefile dlls/rasapi32/tests enable_tests wine_fn_config_makefile dlls/rasdlg enable_rasdlg wine_fn_config_makefile dlls/regapi enable_regapi +wine_fn_config_makefile dlls/resampledmo enable_resampledmo wine_fn_config_makefile dlls/resutils enable_resutils wine_fn_config_makefile dlls/riched20 enable_riched20 wine_fn_config_makefile dlls/riched20/tests enable_tests diff --git a/configure.ac b/configure.ac index 12c308bcc8b..56f24f721df 100644 --- a/configure.ac +++ b/configure.ac @@ -3063,6 +3063,7 @@ WINE_CONFIG_MAKEFILE(dlls/rasapi32) WINE_CONFIG_MAKEFILE(dlls/rasapi32/tests) WINE_CONFIG_MAKEFILE(dlls/rasdlg) WINE_CONFIG_MAKEFILE(dlls/regapi) +WINE_CONFIG_MAKEFILE(dlls/resampledmo) WINE_CONFIG_MAKEFILE(dlls/resutils) WINE_CONFIG_MAKEFILE(dlls/riched20) WINE_CONFIG_MAKEFILE(dlls/riched20/tests) diff --git a/dlls/resampledmo/Makefile.in b/dlls/resampledmo/Makefile.in new file mode 100644 index 00000000000..73c59999c02 --- /dev/null +++ b/dlls/resampledmo/Makefile.in @@ -0,0 +1,6 @@ +MODULE = resampledmo.dll +IMPORTS = combase mfplat msdmo mfuuid dmoguids strmiids wmcodecdspuuid uuid + +SOURCES = \ + resampledmo.c \ + resampledmo.idl diff --git a/dlls/resampledmo/resampledmo.c b/dlls/resampledmo/resampledmo.c new file mode 100644 index 00000000000..486a379b7de --- /dev/null +++ b/dlls/resampledmo/resampledmo.c @@ -0,0 +1,136 @@ +/* + * Copyright 2024 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#define COBJMACROS +#include "windef.h" +#include "winbase.h" + +#include "dmoreg.h" +#include "dshow.h" +#include "mfapi.h" +#include "rpcproxy.h" +#include "wmcodecdsp.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(dmo); + +static HRESULT WINAPI resampler_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, + REFIID riid, void **out) +{ + static const GUID CLSID_wg_resampler = {0x92f35e78,0x15a5,0x486b,{0x88,0x8e,0x57,0x5f,0x99,0x65,0x1c,0xe2}}; + return CoCreateInstance(&CLSID_wg_resampler, outer, CLSCTX_INPROC_SERVER, riid, out); +} + +static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID riid, void **out) +{ + *out = IsEqualGUID(riid, &IID_IClassFactory) || IsEqualGUID(riid, &IID_IUnknown) ? iface : NULL; + return *out ? S_OK : E_NOINTERFACE; +} +static ULONG WINAPI class_factory_AddRef(IClassFactory *iface) +{ + return 2; +} +static ULONG WINAPI class_factory_Release(IClassFactory *iface) +{ + return 1; +} +static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL dolock) +{ + return S_OK; +} + +static const IClassFactoryVtbl resampler_factory_vtbl = +{ + class_factory_QueryInterface, + class_factory_AddRef, + class_factory_Release, + resampler_factory_CreateInstance, + class_factory_LockServer, +}; + +static IClassFactory resampler_factory = {&resampler_factory_vtbl}; + +/*********************************************************************** + * DllGetClassObject (resampledmo.@) + */ +HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out) +{ + if (IsEqualGUID(clsid, &CLSID_CResamplerMediaObject)) + return IClassFactory_QueryInterface(&resampler_factory, riid, out); + + *out = NULL; + FIXME("Unknown clsid %s.\n", debugstr_guid(clsid)); + return CLASS_E_CLASSNOTAVAILABLE; +} + +/*********************************************************************** + * DllRegisterServer (resampledmo.@) + */ +HRESULT WINAPI DllRegisterServer(void) +{ + MFT_REGISTER_TYPE_INFO resampler_mft_types[] = + { + {MFMediaType_Audio, MFAudioFormat_PCM}, + {MFMediaType_Audio, MFAudioFormat_Float}, + }; + DMO_PARTIAL_MEDIATYPE resampler_dmo_types[] = + { + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_PCM}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_IEEE_FLOAT}, + }; + HRESULT hr; + + TRACE("\n"); + + if (FAILED(hr = __wine_register_resources())) + return hr; + if (FAILED(hr = MFTRegister(CLSID_CResamplerMediaObject, MFT_CATEGORY_AUDIO_EFFECT, + (WCHAR *)L"Resampler MFT", MFT_ENUM_FLAG_SYNCMFT, + ARRAY_SIZE(resampler_mft_types), resampler_mft_types, + ARRAY_SIZE(resampler_mft_types), resampler_mft_types, NULL))) + return hr; + if (FAILED(hr = DMORegister(L"Resampler DMO", &CLSID_CResamplerMediaObject, &DMOCATEGORY_AUDIO_EFFECT, 0, + ARRAY_SIZE(resampler_dmo_types), resampler_dmo_types, + ARRAY_SIZE(resampler_dmo_types), resampler_dmo_types))) + return hr; + + return S_OK; +} + +/*********************************************************************** + * DllUnregisterServer (resampledmo.@) + */ +HRESULT WINAPI DllUnregisterServer(void) +{ + HRESULT hr; + + TRACE("\n"); + + if (FAILED(hr = __wine_unregister_resources())) + return hr; + if (FAILED(hr = MFTUnregister(CLSID_CResamplerMediaObject))) + return hr; + if (FAILED(hr = DMOUnregister(&CLSID_CResamplerMediaObject, &DMOCATEGORY_AUDIO_EFFECT))) + return hr; + + return S_OK; +} diff --git a/dlls/resampledmo/resampledmo.idl b/dlls/resampledmo/resampledmo.idl new file mode 100644 index 00000000000..40069e6d63f --- /dev/null +++ b/dlls/resampledmo/resampledmo.idl @@ -0,0 +1,25 @@ +/* + * Copyright 2024 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#pragma makedep register + +[ + threading(both), + uuid(f447b69e-1884-4a7e-8055-346f74d6edb3) +] +coclass CResamplerMediaObject {} diff --git a/dlls/resampledmo/resampledmo.spec b/dlls/resampledmo/resampledmo.spec new file mode 100644 index 00000000000..b16365d0c9f --- /dev/null +++ b/dlls/resampledmo/resampledmo.spec @@ -0,0 +1,4 @@ +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetClassObject(ptr ptr ptr) +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer() diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index 0a968bdfdaf..ccb3e9f52e5 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -994,6 +994,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out) static const GUID CLSID_wg_color_converter = {0xf47e2da5,0xe370,0x47b7,{0x90,0x3a,0x07,0x8d,0xdd,0x45,0xa5,0xcc}}; static const GUID CLSID_wg_mp3_sink_factory = {0x1f302877,0xaaab,0x40a3,{0xb9,0xe0,0x9f,0x48,0xda,0xf3,0x5b,0xc8}}; static const GUID CLSID_wg_mpeg4_sink_factory = {0x5d5407d9,0xc6ca,0x4770,{0xa7,0xcc,0x27,0xc0,0xcb,0x8a,0x76,0x27}}; + static const GUID CLSID_wg_resampler = {0x92f35e78,0x15a5,0x486b,{0x88,0x8e,0x57,0x5f,0x99,0x65,0x1c,0xe2}}; struct class_factory *factory; HRESULT hr; @@ -1023,7 +1024,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out) factory = &wma_decoder_cf; else if (IsEqualGUID(clsid, &CLSID_WMVDecoderMFT)) factory = &wmv_decoder_cf; - else if (IsEqualGUID(clsid, &CLSID_CResamplerMediaObject)) + else if (IsEqualGUID(clsid, &CLSID_wg_resampler)) factory = &resampler_cf; else if (IsEqualGUID(clsid, &CLSID_wg_color_converter)) factory = &color_convert_cf; @@ -1297,11 +1298,6 @@ static const REGFILTER2 reg_decodebin_parser = HRESULT WINAPI DllRegisterServer(void) { - DMO_PARTIAL_MEDIATYPE audio_convert_types[2] = - { - {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_PCM}, - {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_IEEE_FLOAT}, - }; DMO_PARTIAL_MEDIATYPE wma_decoder_output[2] = { {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_PCM}, @@ -1373,9 +1369,6 @@ HRESULT WINAPI DllRegisterServer(void) if (FAILED(hr = DMORegister(L"WMVideo Decoder DMO", &CLSID_WMVDecoderMFT, &DMOCATEGORY_VIDEO_DECODER, 0, ARRAY_SIZE(wmv_decoder_input), wmv_decoder_input, ARRAY_SIZE(wmv_decoder_output), wmv_decoder_output))) return hr; - if (FAILED(hr = DMORegister(L"Resampler DMO", &CLSID_CResamplerMediaObject, &DMOCATEGORY_AUDIO_EFFECT, - 0, ARRAY_SIZE(audio_convert_types), audio_convert_types, ARRAY_SIZE(audio_convert_types), audio_convert_types))) - return hr; return mfplat_DllRegisterServer(); } @@ -1404,8 +1397,6 @@ HRESULT WINAPI DllUnregisterServer(void) IFilterMapper2_Release(mapper); - if (FAILED(hr = DMOUnregister(&CLSID_CResamplerMediaObject, &DMOCATEGORY_AUDIO_EFFECT))) - return hr; if (FAILED(hr = DMOUnregister(&CLSID_WMADecMediaObject, &DMOCATEGORY_AUDIO_DECODER))) return hr; if (FAILED(hr = DMOUnregister(&CLSID_WMVDecoderMFT, &DMOCATEGORY_VIDEO_DECODER))) diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index ca2227656d9..afa04f152dc 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -165,12 +165,6 @@ HRESULT mfplat_get_class_object(REFCLSID rclsid, REFIID riid, void **obj) HRESULT mfplat_DllRegisterServer(void) { - MFT_REGISTER_TYPE_INFO resampler_types[] = - { - {MFMediaType_Audio, MFAudioFormat_PCM}, - {MFMediaType_Audio, MFAudioFormat_Float}, - }; - MFT_REGISTER_TYPE_INFO aac_decoder_input_types[] = { {MFMediaType_Audio, MFAudioFormat_AAC}, @@ -312,16 +306,6 @@ HRESULT mfplat_DllRegisterServer(void) ARRAY_SIZE(wmv_decoder_output_types), wmv_decoder_output_types, }, - { - CLSID_CResamplerMediaObject, - MFT_CATEGORY_AUDIO_EFFECT, - L"Resampler MFT", - MFT_ENUM_FLAG_SYNCMFT, - ARRAY_SIZE(resampler_types), - resampler_types, - ARRAY_SIZE(resampler_types), - resampler_types, - }, }; unsigned int i; diff --git a/dlls/winegstreamer/winegstreamer_classes.idl b/dlls/winegstreamer/winegstreamer_classes.idl index 421424a9577..7b38084badc 100644 --- a/dlls/winegstreamer/winegstreamer_classes.idl +++ b/dlls/winegstreamer/winegstreamer_classes.idl @@ -115,9 +115,9 @@ coclass CMSH264EncoderMFT {} [ threading(both), - uuid(f447b69e-1884-4a7e-8055-346f74d6edb3) + uuid(92f35e78-15a5-486b-888e-575f99651ce2) ] -coclass CResamplerMediaObject {} +coclass wg_resampler {} [ threading(both), diff --git a/loader/wine.inf.in b/loader/wine.inf.in index a529a9d9408..cd862135cef 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -2116,6 +2116,7 @@ HKLM,%CurrentVersion%\Telephony\Country List\998,"SameAreaRule",,"G" 11,,msvproc.dll,1 11,,qcap.dll,1 11,,qedit.dll,1 +11,,resampledmo.dll,1 11,,urlmon.dll,1 11,,windowscodecs.dll,1 11,,winegstreamer.dll,1