wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / evr / main.c
blobe75fb0ad691e6bf4c4aa70d19971b4ffad91944e
1 /*
2 * Copyright (C) 2015 Austin English
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
26 #include "ole2.h"
27 #include "rpcproxy.h"
29 #include "evr_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(evr);
35 static HINSTANCE instance_evr;
37 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
39 switch (reason)
41 case DLL_PROCESS_ATTACH:
42 DisableThreadLibraryCalls(instance);
43 break;
44 case DLL_PROCESS_DETACH:
45 if (reserved) break;
46 strmbase_release_typelibs();
47 break;
49 return TRUE;
52 typedef struct {
53 IClassFactory IClassFactory_iface;
55 LONG ref;
56 HRESULT (*pfnCreateInstance)(IUnknown *unk_outer, void **ppobj);
57 } IClassFactoryImpl;
59 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
61 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
64 struct object_creation_info
66 const CLSID *clsid;
67 HRESULT (*pfnCreateInstance)(IUnknown *unk_outer, void **ppobj);
70 static const struct object_creation_info object_creation[] =
72 { &CLSID_EnhancedVideoRenderer, evr_filter_create },
73 { &CLSID_MFVideoMixer9, evr_mixer_create },
74 { &CLSID_MFVideoPresenter9, evr_presenter_create },
77 static HRESULT WINAPI classfactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
79 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
81 if (IsEqualGUID(riid, &IID_IUnknown)
82 || IsEqualGUID(riid, &IID_IClassFactory))
84 IClassFactory_AddRef(iface);
85 *ppobj = &This->IClassFactory_iface;
86 return S_OK;
89 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
90 return E_NOINTERFACE;
93 static ULONG WINAPI classfactory_AddRef(IClassFactory *iface)
95 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
96 return InterlockedIncrement(&This->ref);
99 static ULONG WINAPI classfactory_Release(IClassFactory *iface)
101 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
102 ULONG ref = InterlockedDecrement(&This->ref);
104 if (ref == 0)
105 HeapFree(GetProcessHeap(), 0, This);
107 return ref;
110 static HRESULT WINAPI classfactory_CreateInstance(IClassFactory *iface, IUnknown *outer_unk, REFIID riid, void **ppobj)
112 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
113 HRESULT hres;
114 IUnknown *unk;
116 TRACE("(%p)->(%p,%s,%p)\n", This, outer_unk, debugstr_guid(riid), ppobj);
118 *ppobj = NULL;
120 if (outer_unk && !IsEqualGUID(riid, &IID_IUnknown))
121 return E_NOINTERFACE;
123 hres = This->pfnCreateInstance(outer_unk, (void **) &unk);
124 if (SUCCEEDED(hres))
126 hres = IUnknown_QueryInterface(unk, riid, ppobj);
127 IUnknown_Release(unk);
129 return hres;
132 static HRESULT WINAPI classfactory_LockServer(IClassFactory *iface, BOOL dolock)
134 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
135 FIXME("(%p)->(%d), stub!\n", This, dolock);
136 return S_OK;
139 static const IClassFactoryVtbl classfactory_Vtbl =
141 classfactory_QueryInterface,
142 classfactory_AddRef,
143 classfactory_Release,
144 classfactory_CreateInstance,
145 classfactory_LockServer
148 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
150 unsigned int i;
151 IClassFactoryImpl *factory;
153 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
155 if (!IsEqualGUID(&IID_IClassFactory, riid)
156 && !IsEqualGUID( &IID_IUnknown, riid))
157 return E_NOINTERFACE;
159 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
161 if (IsEqualGUID(object_creation[i].clsid, rclsid))
162 break;
165 if (i == ARRAY_SIZE(object_creation))
167 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
168 return CLASS_E_CLASSNOTAVAILABLE;
171 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
172 if (factory == NULL)
173 return E_OUTOFMEMORY;
175 factory->IClassFactory_iface.lpVtbl = &classfactory_Vtbl;
176 factory->ref = 1;
178 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
180 *ppv = &(factory->IClassFactory_iface);
181 return S_OK;
184 HRESULT WINAPI DllCanUnloadNow(void)
186 return S_FALSE;
189 HRESULT WINAPI DllRegisterServer(void)
191 return __wine_register_resources(instance_evr);
194 HRESULT WINAPI DllUnregisterServer(void)
196 return __wine_unregister_resources(instance_evr);
199 HRESULT WINAPI MFCreateVideoMixerAndPresenter(IUnknown *mixer_outer, IUnknown *presenter_outer,
200 REFIID riid_mixer, void **mixer, REFIID riid_presenter, void **presenter)
202 HRESULT hr;
204 TRACE("%p, %p, %s, %p, %s, %p.\n", mixer_outer, presenter_outer, debugstr_guid(riid_mixer), mixer,
205 debugstr_guid(riid_presenter), presenter);
207 if (!mixer || !presenter)
208 return E_POINTER;
210 *mixer = *presenter = NULL;
212 if (SUCCEEDED(hr = CoCreateInstance(&CLSID_MFVideoMixer9, mixer_outer, CLSCTX_INPROC_SERVER, riid_mixer, mixer)))
213 hr = CoCreateInstance(&CLSID_MFVideoPresenter9, presenter_outer, CLSCTX_INPROC_SERVER, riid_presenter, presenter);
215 if (FAILED(hr))
217 if (*mixer)
218 IUnknown_Release((IUnknown *)*mixer);
219 if (*presenter)
220 IUnknown_Release((IUnknown *)*presenter);
221 *mixer = *presenter = NULL;
224 return hr;