1 /* DirectShow Editing Services (qedit.dll)
3 * Copyright 2008 Google (Lei Zhang)
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.
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.
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
20 #include "qedit_private.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(qedit
);
26 static HINSTANCE instance
;
28 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
31 case DLL_PROCESS_ATTACH
:
33 DisableThreadLibraryCalls(hInstDLL
);
35 case DLL_PROCESS_DETACH
:
41 /******************************************************************************
42 * DirectShow ClassFactory
45 IClassFactory IClassFactory_iface
;
47 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
50 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
52 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
55 struct object_creation_info
58 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
61 static const struct object_creation_info object_creation
[] =
63 { &CLSID_MediaDet
, MediaDet_create
},
64 { &CLSID_SampleGrabber
, SampleGrabber_create
},
67 static HRESULT WINAPI
DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
69 if (IsEqualGUID(riid
, &IID_IUnknown
)
70 || IsEqualGUID(riid
, &IID_IClassFactory
))
72 IClassFactory_AddRef(iface
);
78 WARN("(%p)->(%s,%p), not found\n", iface
, debugstr_guid(riid
), ppobj
);
82 static ULONG WINAPI
DSCF_AddRef(IClassFactory
*iface
)
84 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
85 return InterlockedIncrement(&This
->ref
);
88 static ULONG WINAPI
DSCF_Release(IClassFactory
*iface
)
90 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
91 ULONG ref
= InterlockedDecrement(&This
->ref
);
99 static HRESULT WINAPI
DSCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
, REFIID riid
,
102 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
106 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
109 if (pOuter
&& !IsEqualGUID(&IID_IUnknown
, riid
))
112 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
113 if (SUCCEEDED(hres
)) {
114 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
115 IUnknown_Release(punk
);
120 static HRESULT WINAPI
DSCF_LockServer(IClassFactory
*iface
, BOOL dolock
)
122 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
123 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
127 static const IClassFactoryVtbl DSCF_Vtbl
=
137 /***********************************************************************
138 * DllCanUnloadNow (QEDIT.@)
140 HRESULT WINAPI
DllCanUnloadNow(void)
145 /*******************************************************************************
146 * DllGetClassObject [QEDIT.@]
147 * Retrieves class object from a DLL object
150 * rclsid [I] CLSID for the class object
151 * riid [I] Reference to identifier of interface for class object
152 * ppv [O] Address of variable to receive interface pointer for riid
156 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
157 * E_UNEXPECTED, E_NOINTERFACE
160 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
163 IClassFactoryImpl
*factory
;
165 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
167 if ( !IsEqualGUID( &IID_IClassFactory
, riid
)
168 && ! IsEqualGUID( &IID_IUnknown
, riid
) )
169 return E_NOINTERFACE
;
171 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
173 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
177 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
179 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
180 return CLASS_E_CLASSNOTAVAILABLE
;
183 factory
= CoTaskMemAlloc(sizeof(*factory
));
184 if (factory
== NULL
) return E_OUTOFMEMORY
;
186 factory
->IClassFactory_iface
.lpVtbl
= &DSCF_Vtbl
;
189 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
191 *ppv
= &factory
->IClassFactory_iface
;
195 /***********************************************************************
196 * DllRegisterServer (QEDIT.@)
198 HRESULT WINAPI
DllRegisterServer(void)
200 return __wine_register_resources( instance
);
203 /***********************************************************************
204 * DllUnregisterServer (QEDIT.@)
206 HRESULT WINAPI
DllUnregisterServer(void)
208 return __wine_unregister_resources( instance
);