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
);
39 /******************************************************************************
40 * DirectShow ClassFactory
43 IClassFactory IClassFactory_iface
;
45 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
48 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
50 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
53 struct object_creation_info
56 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
59 static const struct object_creation_info object_creation
[] =
61 {&CLSID_AMTimeline
, timeline_create
},
62 {&CLSID_MediaDet
, media_detector_create
},
63 {&CLSID_NullRenderer
, null_renderer_create
},
64 {&CLSID_SampleGrabber
, sample_grabber_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
))
110 return E_NOINTERFACE
;
112 hres
= This
->create_instance(pOuter
, &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
< ARRAY_SIZE(object_creation
); i
++)
173 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
177 if (i
== ARRAY_SIZE(object_creation
))
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
->create_instance
= object_creation
[i
].create_instance
;
191 *ppv
= &factory
->IClassFactory_iface
;
195 static const REGPINTYPES reg_null_mt
= {&GUID_NULL
, &GUID_NULL
};
197 static const REGFILTERPINS2 reg_sample_grabber_pins
[2] =
202 .lpMediaType
= ®_null_mt
,
205 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
208 .lpMediaType
= ®_null_mt
,
212 static const REGFILTER2 reg_sample_grabber
=
215 .dwMerit
= MERIT_DO_NOT_USE
,
217 .u
.s2
.rgPins2
= reg_sample_grabber_pins
,
220 static const REGFILTERPINS2 reg_null_renderer_pins
[1] =
223 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
226 .lpMediaType
= ®_null_mt
,
230 static const REGFILTER2 reg_null_renderer
=
233 .dwMerit
= MERIT_DO_NOT_USE
,
235 .u
.s2
.rgPins2
= reg_null_renderer_pins
,
238 /***********************************************************************
239 * DllRegisterServer (QEDIT.@)
241 HRESULT WINAPI
DllRegisterServer(void)
243 IFilterMapper2
*mapper
;
246 if (FAILED(hr
= __wine_register_resources( instance
)))
249 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
250 &IID_IFilterMapper2
, (void **)&mapper
)))
253 IFilterMapper2_RegisterFilter(mapper
, &CLSID_SampleGrabber
, L
"SampleGrabber",
254 NULL
, NULL
, NULL
, ®_sample_grabber
);
255 IFilterMapper2_RegisterFilter(mapper
, &CLSID_NullRenderer
, L
"Null Renderer",
256 NULL
, NULL
, NULL
, ®_null_renderer
);
258 IFilterMapper2_Release(mapper
);
262 /***********************************************************************
263 * DllUnregisterServer (QEDIT.@)
265 HRESULT WINAPI
DllUnregisterServer(void)
267 IFilterMapper2
*mapper
;
270 if (FAILED(hr
= __wine_unregister_resources( instance
)))
273 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
274 &IID_IFilterMapper2
, (void **)&mapper
)))
277 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_SampleGrabber
);
278 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_NullRenderer
);
280 IFilterMapper2_Release(mapper
);