From 4cd2ca96c2b65acd977f7c9217e260c024e0ecbc Mon Sep 17 00:00:00 2001 From: Gijs Vermeulen Date: Tue, 7 Jul 2020 10:14:56 -0500 Subject: [PATCH] qdvd: Add IDvdGraphBuilder stub. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=18072 Signed-off-by: Gijs Vermeulen Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/qdvd/Makefile.in | 2 + dlls/qdvd/graph.c | 112 +++++++++++++++++++++++++++++++++++++++ dlls/qdvd/qdvd_main.c | 89 ++++++++++++++++++++++++++++--- dlls/qdvd/qdvd_private.h | 30 +++++++++++ 4 files changed, 227 insertions(+), 6 deletions(-) create mode 100644 dlls/qdvd/graph.c create mode 100644 dlls/qdvd/qdvd_private.h diff --git a/dlls/qdvd/Makefile.in b/dlls/qdvd/Makefile.in index b3b13486ed5..8f5089b3acc 100644 --- a/dlls/qdvd/Makefile.in +++ b/dlls/qdvd/Makefile.in @@ -1,8 +1,10 @@ MODULE = qdvd.dll +IMPORTS = strmiids uuid ole32 EXTRADLLFLAGS = -mno-cygwin C_SRCS = \ + graph.c \ qdvd_main.c IDL_SRCS = \ diff --git a/dlls/qdvd/graph.c b/dlls/qdvd/graph.c new file mode 100644 index 00000000000..f33293bfa46 --- /dev/null +++ b/dlls/qdvd/graph.c @@ -0,0 +1,112 @@ +/* + * Graph builder + * + * Copyright 2020 Gijs Vermeulen + * + * 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 "qdvd_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(qdvd); + +struct graph_builder +{ + IDvdGraphBuilder IDvdGraphBuilder_iface; + LONG refcount; +}; + +static struct graph_builder *impl_from_IDvdGraphBuilder(IDvdGraphBuilder *iface) +{ + return CONTAINING_RECORD(iface, struct graph_builder, IDvdGraphBuilder_iface); +} + +static ULONG WINAPI graph_builder_AddRef(IDvdGraphBuilder *iface) +{ + struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface); + ULONG refcount = InterlockedIncrement(&builder->refcount); + TRACE("%p increasing refcount to %u.\n", builder, refcount); + return refcount; +} + +static ULONG WINAPI graph_builder_Release(IDvdGraphBuilder *iface) +{ + struct graph_builder *builder = impl_from_IDvdGraphBuilder(iface); + ULONG refcount = InterlockedDecrement(&builder->refcount); + TRACE("%p decreasing refcount to %u.\n", builder, refcount); + if (!refcount) + free(builder); + return refcount; +} + +static HRESULT WINAPI graph_builder_QueryInterface(IDvdGraphBuilder *iface, REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IDvdGraphBuilder) || IsEqualGUID(iid, &IID_IUnknown)) + *out = 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 HRESULT WINAPI graph_builder_GetFiltergraph(IDvdGraphBuilder *iface, IGraphBuilder **graph) +{ + FIXME("iface %p, graph %p, stub!\n", iface, graph); + return E_NOTIMPL; +} + +static HRESULT WINAPI graph_builder_GetDvdInterface(IDvdGraphBuilder *iface, REFIID iid, void **out) +{ + FIXME("iface %p, iid %s, out %p, stub!\n", iface, debugstr_guid(iid), out); + return E_NOTIMPL; +} + +static HRESULT WINAPI graph_builder_RenderDvdVideoVolume(IDvdGraphBuilder *iface, const WCHAR *path, DWORD flags, AM_DVD_RENDERSTATUS *status) +{ + FIXME("iface %p, path %s, flags %#x, status %p, stub!\n", iface, debugstr_w(path), flags, status); + return E_NOTIMPL; +} + +static const struct IDvdGraphBuilderVtbl graph_builder_vtbl = +{ + graph_builder_QueryInterface, + graph_builder_AddRef, + graph_builder_Release, + graph_builder_GetFiltergraph, + graph_builder_GetDvdInterface, + graph_builder_RenderDvdVideoVolume, +}; + +HRESULT graph_builder_create(IUnknown **out) +{ + struct graph_builder *builder; + + if (!(builder = calloc(1, sizeof(*builder)))) + return E_OUTOFMEMORY; + + builder->IDvdGraphBuilder_iface.lpVtbl = &graph_builder_vtbl; + builder->refcount = 1; + + TRACE("Created DVD graph builder %p.\n", builder); + *out = (IUnknown *)&builder->IDvdGraphBuilder_iface; + return S_OK; +} diff --git a/dlls/qdvd/qdvd_main.c b/dlls/qdvd/qdvd_main.c index 72dcda7c91e..9377f248ce9 100644 --- a/dlls/qdvd/qdvd_main.c +++ b/dlls/qdvd/qdvd_main.c @@ -18,17 +18,89 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include "windef.h" -#include "winbase.h" -#include "oleidl.h" +#include "qdvd_private.h" #include "rpcproxy.h" -#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(qdvd); static HINSTANCE qdvd_instance; +struct class_factory +{ + IClassFactory IClassFactory_iface; + HRESULT (*create_instance)(IUnknown **out); +}; + +static struct class_factory *impl_from_IClassFactory(IClassFactory *iface) +{ + return CONTAINING_RECORD(iface, struct class_factory, IClassFactory_iface); +} + +static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory)) + { + IClassFactory_AddRef(iface); + *out = iface; + return S_OK; + } + + *out = NULL; + WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(iid)); + return 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_CreateInstance(IClassFactory *iface, + IUnknown *outer, REFIID iid, void **out) +{ + struct class_factory *factory = impl_from_IClassFactory(iface); + IUnknown *unk; + HRESULT hr; + + TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out); + + *out = NULL; + + if (outer) + return CLASS_E_NOAGGREGATION; + + if (SUCCEEDED(hr = factory->create_instance(&unk))) + { + hr = IUnknown_QueryInterface(unk, iid, out); + IUnknown_Release(unk); + } + return hr; +} + +static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL lock) +{ + FIXME("lock %d, stub!\n", lock); + return S_OK; +} + +static const IClassFactoryVtbl class_factory_vtbl = +{ + class_factory_QueryInterface, + class_factory_AddRef, + class_factory_Release, + class_factory_CreateInstance, + class_factory_LockServer, +}; + +static struct class_factory graph_builder_cf = {{&class_factory_vtbl}, graph_builder_create}; + BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) { if (reason == DLL_WINE_PREATTACH) @@ -44,7 +116,12 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out) { - FIXME("clsid %s, iid %s, out %p, stub!\n", debugstr_guid(clsid), debugstr_guid(iid), out); + TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out); + + if (IsEqualGUID(clsid, &CLSID_DvdGraphBuilder)) + return IClassFactory_QueryInterface(&graph_builder_cf.IClassFactory_iface, iid, out); + + FIXME("%s not available, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid)); return CLASS_E_CLASSNOTAVAILABLE; } diff --git a/dlls/qdvd/qdvd_private.h b/dlls/qdvd/qdvd_private.h new file mode 100644 index 00000000000..b54dd3ddc1c --- /dev/null +++ b/dlls/qdvd/qdvd_private.h @@ -0,0 +1,30 @@ +/* + * DirectShow DVD filters + * + * Copyright 2020 Gijs Vermeulen + * + * 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 + */ + +#ifndef QDVD_PRIVATE_H +#define QDVD_PRIVATE_H + +#define COBJMACROS +#include "dshow.h" +#include "wine/debug.h" + +HRESULT graph_builder_create(IUnknown **out) DECLSPEC_HIDDEN; + +#endif /* QDVD_PRIVATE_H */