msado15: Semi-stub _Recordset get/put Filter.
[wine.git] / dlls / evr / main.c
blob702e464083120f22bc1ce4e48984a497edee4c45
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"
28 #include "d3d9.h"
30 #include "evr_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(evr);
36 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
38 switch (reason)
40 case DLL_PROCESS_ATTACH:
41 DisableThreadLibraryCalls(instance);
42 break;
43 case DLL_PROCESS_DETACH:
44 if (reserved) break;
45 strmbase_release_typelibs();
46 break;
48 return TRUE;
51 struct class_factory
53 IClassFactory IClassFactory_iface;
54 LONG refcount;
55 HRESULT (*pfnCreateInstance)(IUnknown *unk_outer, void **ppobj);
58 static inline struct class_factory *impl_from_IClassFactory(IClassFactory *iface)
60 return CONTAINING_RECORD(iface, struct class_factory, IClassFactory_iface);
63 struct object_creation_info
65 const CLSID *clsid;
66 HRESULT (*pfnCreateInstance)(IUnknown *unk_outer, void **ppobj);
69 static const struct object_creation_info object_creation[] =
71 { &CLSID_EnhancedVideoRenderer, evr_filter_create },
72 { &CLSID_MFVideoMixer9, evr_mixer_create },
73 { &CLSID_MFVideoPresenter9, evr_presenter_create },
76 static HRESULT WINAPI classfactory_QueryInterface(IClassFactory *iface, REFIID riid, void **out)
78 struct class_factory *factory = impl_from_IClassFactory(iface);
80 if (IsEqualGUID(riid, &IID_IUnknown)
81 || IsEqualGUID(riid, &IID_IClassFactory))
83 IClassFactory_AddRef(iface);
84 *out = &factory->IClassFactory_iface;
85 return S_OK;
88 WARN("Unimplemented interface %s.\n", debugstr_guid(riid));
89 return E_NOINTERFACE;
92 static ULONG WINAPI classfactory_AddRef(IClassFactory *iface)
94 struct class_factory *factory = impl_from_IClassFactory(iface);
95 return InterlockedIncrement(&factory->refcount);
98 static ULONG WINAPI classfactory_Release(IClassFactory *iface)
100 struct class_factory *factory = impl_from_IClassFactory(iface);
101 ULONG refcount = InterlockedDecrement(&factory->refcount);
103 if (!refcount)
104 free(factory);
106 return refcount;
109 static HRESULT WINAPI classfactory_CreateInstance(IClassFactory *iface, IUnknown *outer_unk, REFIID riid, void **ppobj)
111 struct class_factory *factory = impl_from_IClassFactory(iface);
112 IUnknown *unk;
113 HRESULT hr;
115 TRACE("%p, %p, %s, %p.\n", iface, outer_unk, debugstr_guid(riid), ppobj);
117 *ppobj = NULL;
119 if (outer_unk && !IsEqualGUID(riid, &IID_IUnknown))
120 return E_NOINTERFACE;
122 hr = factory->pfnCreateInstance(outer_unk, (void **) &unk);
123 if (SUCCEEDED(hr))
125 hr = IUnknown_QueryInterface(unk, riid, ppobj);
126 IUnknown_Release(unk);
128 return hr;
131 static HRESULT WINAPI classfactory_LockServer(IClassFactory *iface, BOOL dolock)
133 FIXME("%p, %d stub!\n", iface, dolock);
135 return S_OK;
138 static const IClassFactoryVtbl classfactory_Vtbl =
140 classfactory_QueryInterface,
141 classfactory_AddRef,
142 classfactory_Release,
143 classfactory_CreateInstance,
144 classfactory_LockServer
147 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **out)
149 struct class_factory *factory;
150 unsigned int i;
152 TRACE("%s, %s, %p.\n", debugstr_guid(rclsid), debugstr_guid(riid), out);
154 if (!IsEqualGUID(&IID_IClassFactory, riid)
155 && !IsEqualGUID( &IID_IUnknown, riid))
156 return E_NOINTERFACE;
158 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
160 if (IsEqualGUID(object_creation[i].clsid, rclsid))
161 break;
164 if (i == ARRAY_SIZE(object_creation))
166 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
167 return CLASS_E_CLASSNOTAVAILABLE;
170 if (!(factory = malloc(sizeof(*factory))))
171 return E_OUTOFMEMORY;
173 factory->IClassFactory_iface.lpVtbl = &classfactory_Vtbl;
174 factory->refcount = 1;
176 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
178 *out = &factory->IClassFactory_iface;
180 return S_OK;
183 HRESULT WINAPI MFCreateVideoMixerAndPresenter(IUnknown *mixer_outer, IUnknown *presenter_outer,
184 REFIID riid_mixer, void **mixer, REFIID riid_presenter, void **presenter)
186 HRESULT hr;
188 TRACE("%p, %p, %s, %p, %s, %p.\n", mixer_outer, presenter_outer, debugstr_guid(riid_mixer), mixer,
189 debugstr_guid(riid_presenter), presenter);
191 if (!mixer || !presenter)
192 return E_POINTER;
194 *mixer = *presenter = NULL;
196 if (SUCCEEDED(hr = CoCreateInstance(&CLSID_MFVideoMixer9, mixer_outer, CLSCTX_INPROC_SERVER, riid_mixer, mixer)))
197 hr = CoCreateInstance(&CLSID_MFVideoPresenter9, presenter_outer, CLSCTX_INPROC_SERVER, riid_presenter, presenter);
199 if (FAILED(hr))
201 if (*mixer)
202 IUnknown_Release((IUnknown *)*mixer);
203 if (*presenter)
204 IUnknown_Release((IUnknown *)*presenter);
205 *mixer = *presenter = NULL;
208 return hr;
211 /***********************************************************************
212 * MFIsFormatYUV (evr.@)
214 BOOL WINAPI MFIsFormatYUV(DWORD format)
216 TRACE("%s.\n", debugstr_an((char *)&format, 4));
218 switch (format)
220 case D3DFMT_UYVY:
221 case D3DFMT_YUY2:
222 case MAKEFOURCC('A','Y','U','V'):
223 case MAKEFOURCC('I','M','C','1'):
224 case MAKEFOURCC('I','M','C','2'):
225 case MAKEFOURCC('Y','V','1','2'):
226 case MAKEFOURCC('N','V','1','1'):
227 case MAKEFOURCC('N','V','1','2'):
228 case MAKEFOURCC('Y','2','1','0'):
229 case MAKEFOURCC('Y','2','1','6'):
230 return TRUE;
231 default:
232 return FALSE;