d3d9/tests: Add r500 fp_special results.
[wine] / dlls / qedit / main.c
1 /*              DirectShow Editing Services (qedit.dll)
2  *
3  * Copyright 2008 Google (Lei Zhang)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include "qedit_private.h"
21 #include "rpcproxy.h"
22 #include "wine/debug.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(qedit);
25
26 static HINSTANCE instance;
27
28 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
29 {
30     switch(fdwReason) {
31         case DLL_PROCESS_ATTACH:
32             instance = hInstDLL;
33             DisableThreadLibraryCalls(hInstDLL);
34             break;
35     }
36     return TRUE;
37 }
38
39 /******************************************************************************
40  * DirectShow ClassFactory
41  */
42 typedef struct {
43     IClassFactory IClassFactory_iface;
44     LONG ref;
45     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
46 } IClassFactoryImpl;
47
48 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
49 {
50     return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
51 }
52
53 struct object_creation_info
54 {
55     const CLSID *clsid;
56     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
57 };
58
59 static const struct object_creation_info object_creation[] =
60 {
61     { &CLSID_MediaDet, MediaDet_create },
62     { &CLSID_SampleGrabber, SampleGrabber_create },
63 };
64
65 static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
66 {
67     if (IsEqualGUID(riid, &IID_IUnknown)
68         || IsEqualGUID(riid, &IID_IClassFactory))
69     {
70         IClassFactory_AddRef(iface);
71         *ppobj = iface;
72         return S_OK;
73     }
74
75     *ppobj = NULL;
76     WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
77     return E_NOINTERFACE;
78 }
79
80 static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
81 {
82     IClassFactoryImpl *This = impl_from_IClassFactory(iface);
83     return InterlockedIncrement(&This->ref);
84 }
85
86 static ULONG WINAPI DSCF_Release(IClassFactory *iface)
87 {
88     IClassFactoryImpl *This = impl_from_IClassFactory(iface);
89     ULONG ref = InterlockedDecrement(&This->ref);
90
91     if (ref == 0)
92         CoTaskMemFree(This);
93
94     return ref;
95 }
96
97 static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid,
98         void **ppobj)
99 {
100     IClassFactoryImpl *This = impl_from_IClassFactory(iface);
101     HRESULT hres;
102     LPUNKNOWN punk;
103
104     TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
105
106     *ppobj = NULL;
107     if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
108         return E_INVALIDARG;
109
110     hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
111     if (SUCCEEDED(hres)) {
112         hres = IUnknown_QueryInterface(punk, riid, ppobj);
113         IUnknown_Release(punk);
114     }
115     return hres;
116 }
117
118 static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
119 {
120     IClassFactoryImpl *This = impl_from_IClassFactory(iface);
121     FIXME("(%p)->(%d),stub!\n",This,dolock);
122     return S_OK;
123 }
124
125 static const IClassFactoryVtbl DSCF_Vtbl =
126 {
127     DSCF_QueryInterface,
128     DSCF_AddRef,
129     DSCF_Release,
130     DSCF_CreateInstance,
131     DSCF_LockServer
132 };
133
134
135 /***********************************************************************
136  *              DllCanUnloadNow (QEDIT.@)
137  */
138 HRESULT WINAPI DllCanUnloadNow(void)
139 {
140     return S_FALSE;
141 }
142
143 /*******************************************************************************
144  * DllGetClassObject [QEDIT.@]
145  * Retrieves class object from a DLL object
146  *
147  * PARAMS
148  *    rclsid [I] CLSID for the class object
149  *    riid   [I] Reference to identifier of interface for class object
150  *    ppv    [O] Address of variable to receive interface pointer for riid
151  *
152  * RETURNS
153  *    Success: S_OK
154  *    Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
155  *             E_UNEXPECTED, E_NOINTERFACE
156  */
157
158 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
159 {
160     unsigned int i;
161     IClassFactoryImpl *factory;
162
163     TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
164
165     if ( !IsEqualGUID( &IID_IClassFactory, riid )
166          && ! IsEqualGUID( &IID_IUnknown, riid) )
167         return E_NOINTERFACE;
168
169     for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
170     {
171         if (IsEqualGUID(object_creation[i].clsid, rclsid))
172             break;
173     }
174
175     if (i == sizeof(object_creation)/sizeof(object_creation[0]))
176     {
177         FIXME("%s: no class found.\n", debugstr_guid(rclsid));
178         return CLASS_E_CLASSNOTAVAILABLE;
179     }
180
181     factory = CoTaskMemAlloc(sizeof(*factory));
182     if (factory == NULL) return E_OUTOFMEMORY;
183
184     factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
185     factory->ref = 1;
186
187     factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
188
189     *ppv = &factory->IClassFactory_iface;
190     return S_OK;
191 }
192
193 /***********************************************************************
194  *              DllRegisterServer (QEDIT.@)
195  */
196 HRESULT WINAPI DllRegisterServer(void)
197 {
198     return __wine_register_resources( instance );
199 }
200
201 /***********************************************************************
202  *              DllUnregisterServer (QEDIT.@)
203  */
204 HRESULT WINAPI DllUnregisterServer(void)
205 {
206     return __wine_unregister_resources( instance );
207 }