Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- v2: - Fix MSMPEGDecoderMFTFactory_CreateInstance. --- dlls/msmpeg2vdec/Makefile.in | 3 + dlls/msmpeg2vdec/main.c | 80 +++++++++++++++++++++++- dlls/msmpeg2vdec/msmpeg2vdec_classes.idl | 21 +++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 dlls/msmpeg2vdec/msmpeg2vdec_classes.idl
diff --git a/dlls/msmpeg2vdec/Makefile.in b/dlls/msmpeg2vdec/Makefile.in index 54ada2f20c4..44377594b91 100644 --- a/dlls/msmpeg2vdec/Makefile.in +++ b/dlls/msmpeg2vdec/Makefile.in @@ -1,6 +1,9 @@ MODULE = msmpeg2vdec.dll +IMPORTS = mfuuid uuid
EXTRADLLFLAGS = -Wb,--prefer-native
C_SRCS = \ main.c + +IDL_SRCS = msmpeg2vdec_classes.idl diff --git a/dlls/msmpeg2vdec/main.c b/dlls/msmpeg2vdec/main.c index 61ada37b2f6..5ae00b36a5f 100644 --- a/dlls/msmpeg2vdec/main.c +++ b/dlls/msmpeg2vdec/main.c @@ -18,15 +18,93 @@
#include <stdarg.h>
+#define COBJMACROS + #include "windef.h" #include "winbase.h" +#include "mfidl.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msmpeg2vdec);
+typedef struct { + IClassFactory IClassFactory_iface; + LONG ref; + HRESULT (*create_instance)(REFIID riid, void **obj); +} msmpeg2vdec_class_factory; + +static inline msmpeg2vdec_class_factory *impl_from_IClassFactory(IClassFactory *iface) +{ + return CONTAINING_RECORD(iface, msmpeg2vdec_class_factory, IClassFactory_iface); +} + +static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **obj) +{ + TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), obj); + + if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) + { + *obj = iface; + IClassFactory_AddRef(iface); + return S_OK; + } + + WARN("no interface for %s\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 MSMPEGDecoderMFTFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj) +{ + msmpeg2vdec_class_factory *factory = impl_from_IClassFactory(iface); + + TRACE("(iface %p, outer %p, riid %s, obj %p)\n", iface, outer, debugstr_guid(riid), obj); + + if (outer) + { + *obj = NULL; + return CLASS_E_NOAGGREGATION; + } + + return factory->create_instance(riid, obj); +} + +static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL lock) +{ + FIXME("(%d) stub\n", lock); + return S_OK; +} + +static const IClassFactoryVtbl MSMPEGDecoderMFTFactoryVtbl = +{ + ClassFactory_QueryInterface, + ClassFactory_AddRef, + ClassFactory_Release, + MSMPEGDecoderMFTFactory_CreateInstance, + ClassFactory_LockServer, +}; + +static IClassFactory MSMPEGDecoderMFTFactory = { &MSMPEGDecoderMFTFactoryVtbl }; + HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, LPVOID *ppv) { - FIXME("(%s %s %p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppv); + TRACE("(%s, %s, %p)\n", debugstr_guid(clsid), debugstr_guid(riid), ppv); + + if (IsEqualGUID(clsid, &CLSID_MSMPEGDecoderMFT)) + return ClassFactory_QueryInterface(&MSMPEGDecoderMFTFactory, riid, ppv); + + WARN("Unsupported class %s.\n", debugstr_guid(clsid)); + *ppv = NULL; return CLASS_E_CLASSNOTAVAILABLE; } diff --git a/dlls/msmpeg2vdec/msmpeg2vdec_classes.idl b/dlls/msmpeg2vdec/msmpeg2vdec_classes.idl new file mode 100644 index 00000000000..2df633a06dd --- /dev/null +++ b/dlls/msmpeg2vdec/msmpeg2vdec_classes.idl @@ -0,0 +1,21 @@ +/* + * COM Classes for msmpeg2vdec + * + * Copyright 2022 Mohamad Al-Jaf + * + * 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