Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- configure | 1 + configure.ac | 1 + dlls/mfmediaengine/Makefile.in | 3 + dlls/mfmediaengine/main.c | 141 +++++++++++++++++++++ dlls/mfmediaengine/mediaengine.idl | 26 ++++ dlls/mfmediaengine/mediaengine_classes.idl | 26 ++++ dlls/mfmediaengine/mfmediaengine.spec | 4 +- dlls/mfmediaengine/tests/Makefile.in | 5 + dlls/mfmediaengine/tests/mfmediaengine.c | 62 +++++++++ 9 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 dlls/mfmediaengine/mediaengine.idl create mode 100644 dlls/mfmediaengine/mediaengine_classes.idl create mode 100644 dlls/mfmediaengine/tests/Makefile.in create mode 100644 dlls/mfmediaengine/tests/mfmediaengine.c
diff --git a/configure b/configure index 82c3611b40..db7db910c0 100755 --- a/configure +++ b/configure @@ -20380,6 +20380,7 @@ wine_fn_config_makefile dlls/mf/tests enable_tests wine_fn_config_makefile dlls/mf3216 enable_mf3216 wine_fn_config_makefile dlls/mferror enable_mferror wine_fn_config_makefile dlls/mfmediaengine enable_mfmediaengine +wine_fn_config_makefile dlls/mfmediaengine/tests enable_tests wine_fn_config_makefile dlls/mfplat enable_mfplat wine_fn_config_makefile dlls/mfplat/tests enable_tests wine_fn_config_makefile dlls/mfplay enable_mfplay diff --git a/configure.ac b/configure.ac index ef41e94df6..2dbcaebed4 100644 --- a/configure.ac +++ b/configure.ac @@ -3359,6 +3359,7 @@ WINE_CONFIG_MAKEFILE(dlls/mf/tests) WINE_CONFIG_MAKEFILE(dlls/mf3216) WINE_CONFIG_MAKEFILE(dlls/mferror) WINE_CONFIG_MAKEFILE(dlls/mfmediaengine) +WINE_CONFIG_MAKEFILE(dlls/mfmediaengine/tests) WINE_CONFIG_MAKEFILE(dlls/mfplat) WINE_CONFIG_MAKEFILE(dlls/mfplat/tests) WINE_CONFIG_MAKEFILE(dlls/mfplay) diff --git a/dlls/mfmediaengine/Makefile.in b/dlls/mfmediaengine/Makefile.in index 1654130574..fc84c48a7e 100644 --- a/dlls/mfmediaengine/Makefile.in +++ b/dlls/mfmediaengine/Makefile.in @@ -1,7 +1,10 @@ MODULE = mfmediaengine.dll IMPORTLIB = mfmediaengine +IMPORTS = mfuuid uuid
EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ main.c + +IDL_SRCS = mediaengine_classes.idl diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index 81aaf77e2c..4bca0fe0ba 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -16,11 +16,19 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define COBJMACROS + #include <stdarg.h>
#include "windef.h" #include "winbase.h"
+#include "mfmediaengine.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mfplat); + BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { switch (reason) @@ -34,3 +42,136 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
return TRUE; } + +static HRESULT WINAPI media_engine_factory_QueryInterface(IMFMediaEngineClassFactory *iface, REFIID riid, void **obj) +{ + if (IsEqualIID(riid, &IID_IMFMediaEngineClassFactory) || + IsEqualIID(riid, &IID_IUnknown)) + { + *obj = iface; + IMFMediaEngineClassFactory_AddRef(iface); + return S_OK; + } + + WARN("Unsupported interface %s.\n", debugstr_guid(riid)); + *obj = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI media_engine_factory_AddRef(IMFMediaEngineClassFactory *iface) +{ + return 2; +} + +static ULONG WINAPI media_engine_factory_Release(IMFMediaEngineClassFactory *iface) +{ + return 1; +} + +static HRESULT WINAPI media_engine_factory_CreateInstance(IMFMediaEngineClassFactory *iface, DWORD flags, + IMFAttributes *attributes, IMFMediaEngine **engine) +{ + FIXME("(%p, %#x, %p, %p): stub.\n", iface, flags, attributes, engine); + + return E_NOTIMPL; +} + +static HRESULT WINAPI media_engine_factory_CreateTimeRange(IMFMediaEngineClassFactory *iface, + IMFMediaTimeRange **range) +{ + FIXME("(%p, %p): stub.\n", iface, range); + + return E_NOTIMPL; +} + +static HRESULT WINAPI media_engine_factory_CreateError(IMFMediaEngineClassFactory *iface, IMFMediaError **error) +{ + FIXME("(%p, %p): stub.\n", iface, error); + + return E_NOTIMPL; +} + +static const IMFMediaEngineClassFactoryVtbl media_engine_factory_vtbl = +{ + media_engine_factory_QueryInterface, + media_engine_factory_AddRef, + media_engine_factory_Release, + media_engine_factory_CreateInstance, + media_engine_factory_CreateTimeRange, + media_engine_factory_CreateError, +}; + +static IMFMediaEngineClassFactory media_engine_factory = { &media_engine_factory_vtbl }; + +static HRESULT WINAPI classfactory_QueryInterface(IClassFactory *iface, REFIID riid, void **obj) +{ + TRACE("(%s, %p).\n", debugstr_guid(riid), obj); + + if (IsEqualGUID(riid, &IID_IClassFactory) || + IsEqualGUID(riid, &IID_IUnknown)) + { + IClassFactory_AddRef(iface); + *obj = iface; + return S_OK; + } + + WARN("interface %s not implemented.\n", debugstr_guid(riid)); + *obj = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI classfactory_AddRef(IClassFactory *iface) +{ + return 2; +} + +static ULONG WINAPI classfactory_Release(IClassFactory *iface) +{ + return 1; +} + +static HRESULT WINAPI classfactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj) +{ + TRACE("(%p, %s, %p).\n", outer, debugstr_guid(riid), obj); + + *obj = NULL; + + if (outer) + return CLASS_E_NOAGGREGATION; + + return IMFMediaEngineClassFactory_QueryInterface(&media_engine_factory, riid, obj); +} + +static HRESULT WINAPI classfactory_LockServer(IClassFactory *iface, BOOL dolock) +{ + FIXME("(%d): stub.\n", dolock); + return S_OK; +} + +static const struct IClassFactoryVtbl class_factory_vtbl = +{ + classfactory_QueryInterface, + classfactory_AddRef, + classfactory_Release, + classfactory_CreateInstance, + classfactory_LockServer, +}; + +static IClassFactory classfactory = { &class_factory_vtbl }; + +HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **obj) +{ + TRACE("(%s, %s, %p).\n", debugstr_guid(clsid), debugstr_guid(riid), obj); + + if (IsEqualGUID(clsid, &CLSID_MFMediaEngineClassFactory)) + return IClassFactory_QueryInterface(&classfactory, riid, obj); + + WARN("Unsupported class %s.\n", debugstr_guid(clsid)); + *obj = NULL; + return CLASS_E_CLASSNOTAVAILABLE; +} + +HRESULT WINAPI DllCanUnloadNow(void) +{ + return S_FALSE; +} diff --git a/dlls/mfmediaengine/mediaengine.idl b/dlls/mfmediaengine/mediaengine.idl new file mode 100644 index 0000000000..a04dabe6a8 --- /dev/null +++ b/dlls/mfmediaengine/mediaengine.idl @@ -0,0 +1,26 @@ +/* + * Copyright 2019 Jactry Zeng 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 + +[ + helpstring("Media Engine Class Factory"), + threading(both), + uuid(b44392da-499b-446b-a4cb-005fead0e6d5) +] +coclass MFMediaEngineClassFactory { interface IMFMediaEngineClassFactory; } diff --git a/dlls/mfmediaengine/mediaengine_classes.idl b/dlls/mfmediaengine/mediaengine_classes.idl new file mode 100644 index 0000000000..a04dabe6a8 --- /dev/null +++ b/dlls/mfmediaengine/mediaengine_classes.idl @@ -0,0 +1,26 @@ +/* + * Copyright 2019 Jactry Zeng 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 + +[ + helpstring("Media Engine Class Factory"), + threading(both), + uuid(b44392da-499b-446b-a4cb-005fead0e6d5) +] +coclass MFMediaEngineClassFactory { interface IMFMediaEngineClassFactory; } diff --git a/dlls/mfmediaengine/mfmediaengine.spec b/dlls/mfmediaengine/mfmediaengine.spec index a7e7cb9036..f216d235a3 100644 --- a/dlls/mfmediaengine/mfmediaengine.spec +++ b/dlls/mfmediaengine/mfmediaengine.spec @@ -1,3 +1,3 @@ -@ stub DllCanUnloadNow +@ stdcall -private DllCanUnloadNow() @ stub DllGetActivationFactory -@ stub DllGetClassObject +@ stdcall -private DllGetClassObject(ptr ptr ptr) diff --git a/dlls/mfmediaengine/tests/Makefile.in b/dlls/mfmediaengine/tests/Makefile.in new file mode 100644 index 0000000000..3f2bb5a094 --- /dev/null +++ b/dlls/mfmediaengine/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = mfmediaengine.dll +IMPORTS = ole32 mfplat mfmediaengine mfuuid + +C_SRCS = \ + mfmediaengine.c diff --git a/dlls/mfmediaengine/tests/mfmediaengine.c b/dlls/mfmediaengine/tests/mfmediaengine.c new file mode 100644 index 0000000000..8c68ddd5e3 --- /dev/null +++ b/dlls/mfmediaengine/tests/mfmediaengine.c @@ -0,0 +1,62 @@ +/* + * Copyright 2019 Jactry Zeng 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> + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" + +#include "mfapi.h" +#include "mfmediaengine.h" + +#include "wine/heap.h" +#include "wine/test.h" + +static void test_factory(void) +{ + IMFMediaEngineClassFactory *factory, *factory2; + HRESULT hr; + + CoInitialize(NULL); + + hr = CoCreateInstance(&CLSID_MFMediaEngineClassFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IMFMediaEngineClassFactory, (void **)&factory); + ok(hr == S_OK, "Failed to create class factory, hr %#x.\n", hr); + + hr = CoCreateInstance(&CLSID_MFMediaEngineClassFactory, (IUnknown *)factory, CLSCTX_INPROC_SERVER, + &IID_IMFMediaEngineClassFactory, (void **)&factory2); + ok(hr == CLASS_E_NOAGGREGATION, "Unexpected hr %#x.\n", hr); + + IMFMediaEngineClassFactory_Release(factory); + + CoUninitialize(); +} + +START_TEST(mfmediaengine) +{ + HRESULT hr; + + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "MFStartup failed: %#x.\n", hr); + + test_factory(); + + MFShutdown(); +}