Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- include/wmcodecdsp.idl | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/include/wmcodecdsp.idl b/include/wmcodecdsp.idl index 809e528d7e2..2d74790179c 100644 --- a/include/wmcodecdsp.idl +++ b/include/wmcodecdsp.idl @@ -21,6 +21,9 @@ import "strmif.idl";
cpp_quote("DEFINE_GUID(MEDIASUBTYPE_I420,0x30323449,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71);") cpp_quote("DEFINE_GUID(MEDIASUBTYPE_MSAUDIO1,0x00000160,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71);") +cpp_quote("DEFINE_GUID(MEDIASUBTYPE_WMAUDIO2,0x00000161,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71);") +cpp_quote("DEFINE_GUID(MEDIASUBTYPE_WMAUDIO3,0x00000162,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71);") +cpp_quote("DEFINE_GUID(MEDIASUBTYPE_WMAUDIO_LOSSLESS,0x00000163,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71);")
[ uuid(bbeea841-0a63-4f52-a7ab-a9b3a84ed38a)
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- configure.ac | 2 + dlls/wmadmod/Makefile.in | 4 + dlls/wmadmod/main.c | 35 +++++++ dlls/wmadmod/tests/Makefile.in | 5 + dlls/wmadmod/tests/wmadmod.c | 183 +++++++++++++++++++++++++++++++++ dlls/wmadmod/wmadmod.spec | 5 + 6 files changed, 234 insertions(+) create mode 100644 dlls/wmadmod/Makefile.in create mode 100644 dlls/wmadmod/main.c create mode 100644 dlls/wmadmod/tests/Makefile.in create mode 100644 dlls/wmadmod/tests/wmadmod.c create mode 100644 dlls/wmadmod/wmadmod.spec
diff --git a/configure.ac b/configure.ac index eb481554960..30cecd790cb 100644 --- a/configure.ac +++ b/configure.ac @@ -3422,6 +3422,8 @@ WINE_CONFIG_MAKEFILE(dlls/wlanapi/tests) WINE_CONFIG_MAKEFILE(dlls/wlanui) WINE_CONFIG_MAKEFILE(dlls/wldap32) WINE_CONFIG_MAKEFILE(dlls/wldap32/tests) +WINE_CONFIG_MAKEFILE(dlls/wmadmod) +WINE_CONFIG_MAKEFILE(dlls/wmadmod/tests) WINE_CONFIG_MAKEFILE(dlls/wmasf) WINE_CONFIG_MAKEFILE(dlls/wmi) WINE_CONFIG_MAKEFILE(dlls/wmiutils) diff --git a/dlls/wmadmod/Makefile.in b/dlls/wmadmod/Makefile.in new file mode 100644 index 00000000000..49fe2f92e08 --- /dev/null +++ b/dlls/wmadmod/Makefile.in @@ -0,0 +1,4 @@ +MODULE = wmadmod.dll + +C_SRCS = \ + main.c diff --git a/dlls/wmadmod/main.c b/dlls/wmadmod/main.c new file mode 100644 index 00000000000..2a13143eeae --- /dev/null +++ b/dlls/wmadmod/main.c @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 <stdarg.h> + +#include "windef.h" +#include "winbase.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wmadmod); + +/************************************************************************* + * DllGetClassObject (WMADMOD.@) + */ +HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj ) +{ + FIXME( "class %s not available\n", debugstr_guid( clsid ) ); + return CLASS_E_CLASSNOTAVAILABLE; +} diff --git a/dlls/wmadmod/tests/Makefile.in b/dlls/wmadmod/tests/Makefile.in new file mode 100644 index 00000000000..254d9322b2b --- /dev/null +++ b/dlls/wmadmod/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = wmadmod.dll +IMPORTS = dmoguids msdmo ole32 strmiids uuid mfuuid wmcodecdspuuid + +C_SRCS = \ + wmadmod.c diff --git a/dlls/wmadmod/tests/wmadmod.c b/dlls/wmadmod/tests/wmadmod.c new file mode 100644 index 00000000000..820f38ebbbd --- /dev/null +++ b/dlls/wmadmod/tests/wmadmod.c @@ -0,0 +1,183 @@ +/* + * Copyright 2022 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 <stdarg.h> + +#include "windef.h" +#include "winbase.h" + +#define COBJMACROS +#include "dmo.h" +#include "uuids.h" +#include "control.h" +#include "wmcodecdsp.h" +#include "mftransform.h" + +#include "wine/test.h" + +static void test_DMOGetTypes(void) +{ + DMO_PARTIAL_MEDIATYPE expect_output[2] = + { + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_PCM}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_IEEE_FLOAT}, + }; + DMO_PARTIAL_MEDIATYPE expect_input[4] = + { + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_MSAUDIO1}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO2}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO3}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO_LOSSLESS}, + }; + + ULONG i, input_count = 0, output_count = 0; + DMO_PARTIAL_MEDIATYPE output[16] = {0}; + DMO_PARTIAL_MEDIATYPE input[16] = {0}; + HRESULT hr; + + hr = DMOGetTypes( &CLSID_CWMADecMediaObject, ARRAY_SIZE(input), &input_count, input, + ARRAY_SIZE(output), &output_count, output ); + todo_wine + ok( hr == S_OK, "DMOGetTypes returned %#x\n", hr ); + todo_wine + ok( input_count == ARRAY_SIZE(expect_input), "got input_count %u\n", input_count ); + todo_wine + ok( output_count == ARRAY_SIZE(expect_output), "got output_count %u\n", output_count ); + + for (i = 0; i < input_count; ++i) + { + winetest_push_context( "in %u", i ); + ok( IsEqualGUID( &input[i].type, &expect_input[i].type ), + "got type %s\n", debugstr_guid( &input[i].type ) ); + ok( IsEqualGUID( &input[i].subtype, &expect_input[i].subtype ), + "got subtype %s\n", debugstr_guid( &input[i].subtype ) ); + winetest_pop_context(); + } + + for (i = 0; i < output_count; ++i) + { + winetest_push_context( "out %u", i ); + ok( IsEqualGUID( &output[i].type, &expect_output[i].type ), + "got type %s\n", debugstr_guid( &output[i].type ) ); + ok( IsEqualGUID( &output[i].subtype, &expect_output[i].subtype ), + "got subtype %s\n", debugstr_guid( &output[i].subtype ) ); + winetest_pop_context(); + } +} + +static HRESULT WINAPI outer_QueryInterface( IUnknown *iface, REFIID iid, void **obj ) +{ + if (IsEqualGUID( iid, &IID_IUnknown )) + { + *obj = (IUnknown *)iface; + return S_OK; + } + + ok( 0, "unexpected call %s\n", debugstr_guid( iid ) ); + return E_NOINTERFACE; +} + +static ULONG WINAPI outer_AddRef( IUnknown *iface ) +{ + return 2; +} + +static ULONG WINAPI outer_Release( IUnknown *iface ) +{ + return 1; +} + +static IUnknownVtbl outer_vtbl = +{ + outer_QueryInterface, + outer_AddRef, + outer_Release, +}; + +static IUnknown outer = {&outer_vtbl}; + +#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface, REFIID iid, BOOL supported) +{ + HRESULT hr, expected_hr; + IUnknown *tmp; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface( (IUnknown *)iface, iid, (void **)&tmp ); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) IUnknown_Release( tmp ); +} + +static void test_interfaces(void) +{ + IUnknown *unknown, *tmp_unknown; + IMediaObject *media_object; + IPropertyBag *property_bag; + IMFTransform *transform; + HRESULT hr; + ULONG ref; + + hr = CoCreateInstance( &CLSID_CWMADecMediaObject, &outer, CLSCTX_INPROC_SERVER, &IID_IUnknown, + (void **)&unknown ); + todo_wine + ok( hr == S_OK, "CoCreateInstance returned %#x\n", hr ); + if (FAILED(hr)) return; + hr = IUnknown_QueryInterface( unknown, &IID_IMFTransform, (void **)&transform ); + ok( hr == S_OK, "QueryInterface returned %#x\n", hr ); + hr = IUnknown_QueryInterface( unknown, &IID_IMediaObject, (void **)&media_object ); + ok( hr == S_OK, "QueryInterface returned %#x\n", hr ); + hr = IUnknown_QueryInterface( unknown, &IID_IPropertyBag, (void **)&property_bag ); + ok( hr == S_OK, "QueryInterface returned %#x\n", hr ); + hr = IUnknown_QueryInterface( media_object, &IID_IUnknown, (void **)&tmp_unknown ); + ok( hr == S_OK, "QueryInterface returned %#x\n", hr ); + + ok( unknown != &outer, "got outer IUnknown\n" ); + ok( transform != (void *)unknown, "got IUnknown == IMFTransform\n" ); + ok( media_object != (void *)unknown, "got IUnknown == IMediaObject\n" ); + ok( property_bag != (void *)unknown, "got IUnknown == IPropertyBag\n" ); + ok( tmp_unknown != unknown, "got inner IUnknown\n" ); + + check_interface( unknown, &IID_IPersistPropertyBag, FALSE ); + check_interface( unknown, &IID_IAMFilterMiscFlags, FALSE ); + check_interface( unknown, &IID_IMediaSeeking, FALSE ); + check_interface( unknown, &IID_IMediaPosition, FALSE ); + check_interface( unknown, &IID_IReferenceClock, FALSE ); + check_interface( unknown, &IID_IBasicAudio, FALSE ); + + ref = IUnknown_Release( tmp_unknown ); + ok( ref == 1, "Release returned %u\n", ref ); + ref = IPropertyBag_Release( property_bag ); + ok( ref == 1, "Release returned %u\n", ref ); + ref = IMediaObject_Release( media_object ); + ok( ref == 1, "Release returned %u\n", ref ); + ref = IMFTransform_Release( transform ); + ok( ref == 1, "Release returned %u\n", ref ); + ref = IUnknown_Release( unknown ); + ok( ref == 0, "Release returned %u\n", ref ); +} + +START_TEST( wmadmod ) +{ + CoInitialize( NULL ); + + test_DMOGetTypes(); + test_interfaces(); + + CoUninitialize(); +} diff --git a/dlls/wmadmod/wmadmod.spec b/dlls/wmadmod/wmadmod.spec new file mode 100644 index 00000000000..25104058c7d --- /dev/null +++ b/dlls/wmadmod/wmadmod.spec @@ -0,0 +1,5 @@ +@ stub CreateInstance +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetClassObject(ptr ptr ptr) +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer()
Final Fantasy XIV intro videos require media_object_GetStreamCount and property_bag_Write to return S_OK in order to not get stuck.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
This could be split in a separate commits to only have E_NOTIMPL first, but it could cause a temporary regression.
dlls/mf/tests/mf.c | 1 - dlls/winegstreamer/Makefile.in | 5 +- dlls/winegstreamer/gst_private.h | 1 + dlls/winegstreamer/main.c | 26 + dlls/winegstreamer/mfplat.c | 28 +- dlls/winegstreamer/quartz_parser.c | 2 +- dlls/winegstreamer/winegstreamer_classes.idl | 6 + dlls/winegstreamer/wma_decoder.c | 553 +++++++++++++++++++ dlls/wmadmod/tests/wmadmod.c | 5 - 9 files changed, 617 insertions(+), 10 deletions(-) create mode 100644 dlls/winegstreamer/wma_decoder.c
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index a9467a7fdb6..526ee3f14ad 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -5742,7 +5742,6 @@ static void test_wma_decoder(void) &transform, &class_id)) goto failed;
- todo_wine check_interface(transform, &IID_IMediaObject, TRUE);
/* check default media types */ diff --git a/dlls/winegstreamer/Makefile.in b/dlls/winegstreamer/Makefile.in index 76e6aeed54d..c53e914e246 100644 --- a/dlls/winegstreamer/Makefile.in +++ b/dlls/winegstreamer/Makefile.in @@ -1,7 +1,7 @@ MODULE = winegstreamer.dll UNIXLIB = winegstreamer.so IMPORTLIB = winegstreamer -IMPORTS = strmbase ole32 +IMPORTS = strmbase ole32 msdmo DELAYIMPORTS = mfplat EXTRAINCL = $(GSTREAMER_CFLAGS) EXTRALIBS = $(GSTREAMER_LIBS) $(PTHREAD_LIBS) @@ -15,7 +15,8 @@ C_SRCS = \ wg_parser.c \ wm_asyncreader.c \ wm_reader.c \ - wm_syncreader.c + wm_syncreader.c \ + wma_decoder.c
IDL_SRCS = \ winegstreamer_classes.idl diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 9e1d67417d4..222bce3b2c7 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -102,6 +102,7 @@ HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; HRESULT wave_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; +HRESULT wma_decoder_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
bool amt_from_wg_format(AM_MEDIA_TYPE *mt, const struct wg_format *format, bool wm); bool amt_to_wg_format(const AM_MEDIA_TYPE *mt, struct wg_format *format); diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index ac9a3201792..260dd208e2f 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -25,7 +25,9 @@ #include "gst_private.h" #include "winternl.h" #include "rpcproxy.h" +#include "dmoreg.h" #include "gst_guids.h" +#include "wmcodecdsp.h"
static unixlib_handle_t unix_handle;
@@ -339,6 +341,7 @@ static struct class_factory avi_splitter_cf = {{&class_factory_vtbl}, avi_splitt static struct class_factory decodebin_parser_cf = {{&class_factory_vtbl}, decodebin_parser_create}; static struct class_factory mpeg_splitter_cf = {{&class_factory_vtbl}, mpeg_splitter_create}; static struct class_factory wave_parser_cf = {{&class_factory_vtbl}, wave_parser_create}; +static struct class_factory wma_decoder_cf = {{&class_factory_vtbl}, wma_decoder_create};
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out) { @@ -361,6 +364,8 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out) factory = &mpeg_splitter_cf; else if (IsEqualGUID(clsid, &CLSID_WAVEParser)) factory = &wave_parser_cf; + else if (IsEqualGUID(clsid, &CLSID_WMADecMediaObject)) + factory = &wma_decoder_cf; else { FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid)); @@ -522,6 +527,19 @@ static const REGFILTER2 reg_decodebin_parser =
HRESULT WINAPI DllRegisterServer(void) { + DMO_PARTIAL_MEDIATYPE wma_decoder_output[2] = + { + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_PCM}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_IEEE_FLOAT}, + }; + DMO_PARTIAL_MEDIATYPE wma_decoder_input[4] = + { + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_MSAUDIO1}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO2}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO3}, + {.type = MEDIATYPE_Audio, .subtype = MEDIASUBTYPE_WMAUDIO_LOSSLESS}, + }; + IFilterMapper2 *mapper; HRESULT hr;
@@ -543,6 +561,10 @@ HRESULT WINAPI DllRegisterServer(void)
IFilterMapper2_Release(mapper);
+ if (FAILED(hr = DMORegister(L"WMA Decoder DMO", &CLSID_WMADecMediaObject, &DMOCATEGORY_AUDIO_DECODER, + 0, ARRAY_SIZE(wma_decoder_input), wma_decoder_input, ARRAY_SIZE(wma_decoder_output), wma_decoder_output))) + return hr; + return mfplat_DllRegisterServer(); }
@@ -566,5 +588,9 @@ HRESULT WINAPI DllUnregisterServer(void) IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_WAVEParser);
IFilterMapper2_Release(mapper); + + if (FAILED(hr = DMOUnregister(&CLSID_WMADecMediaObject, &DMOCATEGORY_AUDIO_DECODER))) + return hr; + return S_OK; } diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 5404728ba83..6a58f444204 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -21,6 +21,7 @@
#include "ks.h" #include "ksmedia.h" +#include "wmcodecdsp.h" #include "initguid.h" #include "mfapi.h"
@@ -442,6 +443,20 @@ static const GUID *audio_converter_supported_types[] = &MFAudioFormat_Float, };
+static WCHAR wma_decoderW[] = L"WMAudio Decoder MFT"; +static const GUID *wma_decoder_input_types[] = +{ + &MEDIASUBTYPE_MSAUDIO1, + &MFAudioFormat_WMAudioV8, + &MFAudioFormat_WMAudioV9, + &MFAudioFormat_WMAudio_Lossless, +}; +static const GUID *wma_decoder_output_types[] = +{ + &MFAudioFormat_PCM, + &MFAudioFormat_Float, +}; + static const struct mft { const GUID *clsid; @@ -467,13 +482,24 @@ mfts[] = ARRAY_SIZE(audio_converter_supported_types), audio_converter_supported_types, }, + { + &CLSID_WMADecMediaObject, + &MFT_CATEGORY_AUDIO_DECODER, + wma_decoderW, + MFT_ENUM_FLAG_SYNCMFT, + &MFMediaType_Audio, + ARRAY_SIZE(wma_decoder_input_types), + wma_decoder_input_types, + ARRAY_SIZE(wma_decoder_output_types), + wma_decoder_output_types, + }, };
HRESULT mfplat_DllRegisterServer(void) { unsigned int i, j; HRESULT hr; - MFT_REGISTER_TYPE_INFO input_types[2], output_types[2]; + MFT_REGISTER_TYPE_INFO input_types[4], output_types[2];
for (i = 0; i < ARRAY_SIZE(mfts); i++) { diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index 8532fc1af8b..e8d56d54785 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -29,8 +29,8 @@ #include "dvdmedia.h" #include "mmreg.h" #include "ks.h" -#include "initguid.h" #include "wmcodecdsp.h" +#include "initguid.h" #include "ksmedia.h"
WINE_DEFAULT_DEBUG_CHANNEL(quartz); diff --git a/dlls/winegstreamer/winegstreamer_classes.idl b/dlls/winegstreamer/winegstreamer_classes.idl index 072ec90eea4..90dc1dc839b 100644 --- a/dlls/winegstreamer/winegstreamer_classes.idl +++ b/dlls/winegstreamer/winegstreamer_classes.idl @@ -67,3 +67,9 @@ coclass GStreamerByteStreamHandler {} uuid(6a170414-aad9-4693-b806-3a0c47c570d6) ] coclass WINEAudioConverter { } + +[ + threading(both), + uuid(2eeb4adf-4578-4d10-bca7-bb955f56320a) +] +coclass CWMADecMediaObject {}; diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c new file mode 100644 index 00000000000..f034c34395e --- /dev/null +++ b/dlls/winegstreamer/wma_decoder.c @@ -0,0 +1,553 @@ +/* WMA Decoder DMO / MF Transform + * + * Copyright 2022 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 "gst_private.h" + +#include "mfapi.h" +#include "mferror.h" +#include "mfobjects.h" +#include "mftransform.h" +#include "wmcodecdsp.h" + +#include "wine/debug.h" +#include "wine/heap.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wmadec); + +struct wma_decoder +{ + IUnknown IUnknown_inner; + IMFTransform IMFTransform_iface; + IMediaObject IMediaObject_iface; + IPropertyBag IPropertyBag_iface; + IUnknown *outer; + LONG refcount; +}; + +static inline struct wma_decoder *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, struct wma_decoder, IUnknown_inner); +} + +static HRESULT WINAPI unknown_QueryInterface(IUnknown *iface, REFIID iid, void **out) +{ + struct wma_decoder *decoder = impl_from_IUnknown(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown)) + *out = &decoder->IUnknown_inner; + else if (IsEqualGUID(iid, &IID_IMFTransform)) + *out = &decoder->IMFTransform_iface; + else if (IsEqualGUID(iid, &IID_IMediaObject)) + *out = &decoder->IMediaObject_iface; + else if (IsEqualIID(iid, &IID_IPropertyBag)) + *out = &decoder->IPropertyBag_iface; + else + { + *out = NULL; + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*out); + return S_OK; +} + +static ULONG WINAPI unknown_AddRef(IUnknown *iface) +{ + struct wma_decoder *decoder = impl_from_IUnknown(iface); + ULONG refcount = InterlockedIncrement(&decoder->refcount); + + TRACE("iface %p increasing refcount to %u.\n", decoder, refcount); + + return refcount; +} + +static ULONG WINAPI unknown_Release(IUnknown *iface) +{ + struct wma_decoder *decoder = impl_from_IUnknown(iface); + ULONG refcount = InterlockedDecrement(&decoder->refcount); + + TRACE("iface %p decreasing refcount to %u.\n", decoder, refcount); + + if (!refcount) + free(decoder); + + return refcount; +} + +static const IUnknownVtbl unknown_vtbl = +{ + unknown_QueryInterface, + unknown_AddRef, + unknown_Release, +}; + +static struct wma_decoder *impl_from_IMFTransform(IMFTransform *iface) +{ + return CONTAINING_RECORD(iface, struct wma_decoder, IMFTransform_iface); +} + +static HRESULT WINAPI transform_QueryInterface(IMFTransform *iface, REFIID iid, void **out) +{ + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + return IUnknown_QueryInterface(decoder->outer, iid, out); +} + +static ULONG WINAPI transform_AddRef(IMFTransform *iface) +{ + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + return IUnknown_AddRef(decoder->outer); +} + +static ULONG WINAPI transform_Release(IMFTransform *iface) +{ + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + return IUnknown_Release(decoder->outer); +} + +static HRESULT WINAPI transform_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum, + DWORD *input_maximum, DWORD *output_minimum, DWORD *output_maximum) +{ + FIXME("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p stub!\n", + iface, input_minimum, input_maximum, output_minimum, output_maximum); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs) +{ + FIXME("iface %p, inputs %p, outputs %p stub!\n", iface, inputs, outputs); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs, + DWORD output_size, DWORD *outputs) +{ + FIXME("iface %p, input_size %u, inputs %p, output_size %u, outputs %p stub!\n", iface, + input_size, inputs, output_size, outputs); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info) +{ + FIXME("iface %p, id %u, info %p stub!\n", iface, id, info); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info) +{ + FIXME("iface %p, id %u, info %p stub!\n", iface, id, info); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetAttributes(IMFTransform *iface, IMFAttributes **attributes) +{ + FIXME("iface %p, attributes %p stub!\n", iface, attributes); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes) +{ + FIXME("iface %p, id %u, attributes %p stub!\n", iface, id, attributes); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes) +{ + FIXME("iface %p, id %u, attributes %p stub!\n", iface, id, attributes); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_DeleteInputStream(IMFTransform *iface, DWORD id) +{ + FIXME("iface %p, id %u stub!\n", iface, id); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids) +{ + FIXME("iface %p, streams %u, ids %p stub!\n", iface, streams, ids); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index, + IMFMediaType **type) +{ + FIXME("iface %p, id %u, index %u, type %p stub!\n", iface, id, index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index, + IMFMediaType **type) +{ + FIXME("iface %p, id %u, index %u, type %p stub!\n", iface, id, index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) +{ + FIXME("iface %p, id %u, type %p, flags %#x stub!\n", iface, id, type, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) +{ + FIXME("iface %p, id %u, type %p, flags %#x stub!\n", iface, id, type, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) +{ + FIXME("iface %p, id %u, type %p stub!\n", iface, id, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) +{ + FIXME("iface %p, id %u, type %p stub!\n", iface, id, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags) +{ + FIXME("iface %p, id %u, flags %p stub!\n", iface, id, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_GetOutputStatus(IMFTransform *iface, DWORD *flags) +{ + FIXME("iface %p, flags %p stub!\n", iface, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_SetOutputBounds(IMFTransform *iface, LONGLONG lower, LONGLONG upper) +{ + FIXME("iface %p, lower %s, upper %s stub!\n", iface, wine_dbgstr_longlong(lower), + wine_dbgstr_longlong(upper)); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_ProcessEvent(IMFTransform *iface, DWORD id, IMFMediaEvent *event) +{ + FIXME("iface %p, id %u, event %p stub!\n", iface, id, event); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_TYPE message, ULONG_PTR param) +{ + FIXME("iface %p, message %#x, param %p stub!\n", iface, message, (void *)param); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags) +{ + FIXME("iface %p, id %u, sample %p, flags %#x stub!\n", iface, id, sample, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count, + MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status) +{ + FIXME("iface %p, flags %#x, count %u, samples %p, status %p stub!\n", iface, flags, count, samples, status); + return E_NOTIMPL; +} + +static const IMFTransformVtbl transform_vtbl = +{ + transform_QueryInterface, + transform_AddRef, + transform_Release, + transform_GetStreamLimits, + transform_GetStreamCount, + transform_GetStreamIDs, + transform_GetInputStreamInfo, + transform_GetOutputStreamInfo, + transform_GetAttributes, + transform_GetInputStreamAttributes, + transform_GetOutputStreamAttributes, + transform_DeleteInputStream, + transform_AddInputStreams, + transform_GetInputAvailableType, + transform_GetOutputAvailableType, + transform_SetInputType, + transform_SetOutputType, + transform_GetInputCurrentType, + transform_GetOutputCurrentType, + transform_GetInputStatus, + transform_GetOutputStatus, + transform_SetOutputBounds, + transform_ProcessEvent, + transform_ProcessMessage, + transform_ProcessInput, + transform_ProcessOutput, +}; + +static inline struct wma_decoder *impl_from_IMediaObject(IMediaObject *iface) +{ + return CONTAINING_RECORD(iface, struct wma_decoder, IMediaObject_iface); +} + +static HRESULT WINAPI media_object_QueryInterface(IMediaObject *iface, REFIID iid, void **obj) +{ + struct wma_decoder *decoder = impl_from_IMediaObject(iface); + return IUnknown_QueryInterface(decoder->outer, iid, obj); +} + +static ULONG WINAPI media_object_AddRef(IMediaObject *iface) +{ + struct wma_decoder *decoder = impl_from_IMediaObject(iface); + return IUnknown_AddRef(decoder->outer); +} + +static ULONG WINAPI media_object_Release(IMediaObject *iface) +{ + struct wma_decoder *decoder = impl_from_IMediaObject(iface); + return IUnknown_Release(decoder->outer); +} + +static HRESULT WINAPI media_object_GetStreamCount(IMediaObject *iface, DWORD *input, DWORD *output) +{ + FIXME("iface %p, input %p, output %p semi-stub!\n", iface, input, output); + *input = *output = 1; + return S_OK; +} + +static HRESULT WINAPI media_object_GetInputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) +{ + FIXME("iface %p, index %u, flags %p stub!\n", iface, index, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetOutputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) +{ + FIXME("iface %p, index %u, flags %p stub!\n", iface, index, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputType(IMediaObject *iface, DWORD index, DWORD type_index, + DMO_MEDIA_TYPE *type) +{ + FIXME("iface %p, index %u, type_index %u, type %p stub!\n", iface, index, type_index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD index, DWORD type_index, + DMO_MEDIA_TYPE *type) +{ + FIXME("iface %p, index %u, type_index %u, type %p stub!\n", iface, index, type_index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index, + const DMO_MEDIA_TYPE *type, DWORD flags) +{ + FIXME("iface %p, index %u, type %p, flags %#x stub!\n", iface, index, type, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD index, + const DMO_MEDIA_TYPE *type, DWORD flags) +{ + FIXME("iface %p, index %u, type %p, flags %#x stub!\n", iface, index, type, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) +{ + FIXME("iface %p, index %u, type %p stub!\n", iface, index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetOutputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) +{ + FIXME("iface %p, index %u, type %p stub!\n", iface, index, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, + DWORD *lookahead, DWORD *alignment) +{ + FIXME("iface %p, index %u, size %p, lookahead %p, alignment %p stub!\n", iface, index, size, + lookahead, alignment); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetOutputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *alignment) +{ + FIXME("iface %p, index %u, size %p, alignment %p stub!\n", iface, index, size, alignment); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME *latency) +{ + FIXME("iface %p, index %u, latency %p stub!\n", iface, index, latency); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_SetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME latency) +{ + FIXME("iface %p, index %u, latency %s stub!\n", iface, index, wine_dbgstr_longlong(latency)); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_Flush(IMediaObject *iface) +{ + FIXME("iface %p stub!\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_Discontinuity(IMediaObject *iface, DWORD index) +{ + FIXME("iface %p, index %u stub!\n", iface, index); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_AllocateStreamingResources(IMediaObject *iface) +{ + FIXME("iface %p stub!\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_FreeStreamingResources(IMediaObject *iface) +{ + FIXME("iface %p stub!\n", iface); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_GetInputStatus(IMediaObject *iface, DWORD index, DWORD *flags) +{ + FIXME("iface %p, index %u, flags %p stub!\n", iface, index, flags); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_ProcessInput(IMediaObject *iface, DWORD index, + IMediaBuffer *buffer, DWORD flags, REFERENCE_TIME timestamp, REFERENCE_TIME timelength) +{ + FIXME("iface %p, index %u, buffer %p, flags %#x, timestamp %s, timelength %s stub!\n", iface, + index, buffer, flags, wine_dbgstr_longlong(timestamp), wine_dbgstr_longlong(timelength)); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_ProcessOutput(IMediaObject *iface, DWORD flags, DWORD count, + DMO_OUTPUT_DATA_BUFFER *buffers, DWORD *status) +{ + FIXME("iface %p, flags %#x, count %u, buffers %p, status %p stub!\n", iface, flags, count, buffers, status); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_object_Lock(IMediaObject *iface, LONG lock) +{ + FIXME("iface %p, lock %d stub!\n", iface, lock); + return E_NOTIMPL; +} + +static const IMediaObjectVtbl media_object_vtbl = +{ + media_object_QueryInterface, + media_object_AddRef, + media_object_Release, + media_object_GetStreamCount, + media_object_GetInputStreamInfo, + media_object_GetOutputStreamInfo, + media_object_GetInputType, + media_object_GetOutputType, + media_object_SetInputType, + media_object_SetOutputType, + media_object_GetInputCurrentType, + media_object_GetOutputCurrentType, + media_object_GetInputSizeInfo, + media_object_GetOutputSizeInfo, + media_object_GetInputMaxLatency, + media_object_SetInputMaxLatency, + media_object_Flush, + media_object_Discontinuity, + media_object_AllocateStreamingResources, + media_object_FreeStreamingResources, + media_object_GetInputStatus, + media_object_ProcessInput, + media_object_ProcessOutput, + media_object_Lock, +}; + +static inline struct wma_decoder *impl_from_IPropertyBag(IPropertyBag *iface) +{ + return CONTAINING_RECORD(iface, struct wma_decoder, IPropertyBag_iface); +} + +static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID iid, void **out) +{ + struct wma_decoder *filter = impl_from_IPropertyBag(iface); + return IUnknown_QueryInterface(filter->outer, iid, out); +} + +static ULONG WINAPI property_bag_AddRef(IPropertyBag *iface) +{ + struct wma_decoder *filter = impl_from_IPropertyBag(iface); + return IUnknown_AddRef(filter->outer); +} + +static ULONG WINAPI property_bag_Release(IPropertyBag *iface) +{ + struct wma_decoder *filter = impl_from_IPropertyBag(iface); + return IUnknown_Release(filter->outer); +} + +static HRESULT WINAPI property_bag_Read(IPropertyBag *iface, const WCHAR *prop_name, VARIANT *value, + IErrorLog *error_log) +{ + FIXME("iface %p, prop_name %s, value %p, error_log %p stub!\n", iface, debugstr_w(prop_name), value, error_log); + return E_NOTIMPL; +} + +static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, const WCHAR *prop_name, VARIANT *value) +{ + FIXME("iface %p, prop_name %s, value %p stub!\n", iface, debugstr_w(prop_name), value); + return S_OK; +} + +static const IPropertyBagVtbl property_bag_vtbl = +{ + property_bag_QueryInterface, + property_bag_AddRef, + property_bag_Release, + property_bag_Read, + property_bag_Write, +}; + +HRESULT wma_decoder_create(IUnknown *outer, IUnknown **out) +{ + struct wma_decoder *decoder; + + TRACE("outer %p, out %p.\n", outer, out); + + if (!(decoder = calloc(1, sizeof(*decoder)))) + return E_OUTOFMEMORY; + + decoder->IUnknown_inner.lpVtbl = &unknown_vtbl; + decoder->IMFTransform_iface.lpVtbl = &transform_vtbl; + decoder->IMediaObject_iface.lpVtbl = &media_object_vtbl; + decoder->IPropertyBag_iface.lpVtbl = &property_bag_vtbl; + decoder->refcount = 1; + decoder->outer = outer ? outer : &decoder->IUnknown_inner; + + *out = &decoder->IUnknown_inner; + TRACE("Created decoder %p\n", *out); + return S_OK; +} diff --git a/dlls/wmadmod/tests/wmadmod.c b/dlls/wmadmod/tests/wmadmod.c index 820f38ebbbd..c163c054424 100644 --- a/dlls/wmadmod/tests/wmadmod.c +++ b/dlls/wmadmod/tests/wmadmod.c @@ -52,11 +52,8 @@ static void test_DMOGetTypes(void)
hr = DMOGetTypes( &CLSID_CWMADecMediaObject, ARRAY_SIZE(input), &input_count, input, ARRAY_SIZE(output), &output_count, output ); - todo_wine ok( hr == S_OK, "DMOGetTypes returned %#x\n", hr ); - todo_wine ok( input_count == ARRAY_SIZE(expect_input), "got input_count %u\n", input_count ); - todo_wine ok( output_count == ARRAY_SIZE(expect_output), "got output_count %u\n", output_count );
for (i = 0; i < input_count; ++i) @@ -135,9 +132,7 @@ static void test_interfaces(void)
hr = CoCreateInstance( &CLSID_CWMADecMediaObject, &outer, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unknown ); - todo_wine ok( hr == S_OK, "CoCreateInstance returned %#x\n", hr ); - if (FAILED(hr)) return; hr = IUnknown_QueryInterface( unknown, &IID_IMFTransform, (void **)&transform ); ok( hr == S_OK, "QueryInterface returned %#x\n", hr ); hr = IUnknown_QueryInterface( unknown, &IID_IMediaObject, (void **)&media_object );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106301
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/winegstreamer/Makefile.in:1 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/winegstreamer/Makefile.in:1 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/winegstreamer/Makefile.in:1 Task: Patch failed to apply
On 1/28/22 10:36, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=106301
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/winegstreamer/Makefile.in:1 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/winegstreamer/Makefile.in:1 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/winegstreamer/Makefile.in:1 Task: Patch failed to apply
Ah... well, I'll resend it, but I'll wait to see whether it should be split.