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 #define WINE_NO_NAMELESS_EXTENSION
22 #include "qedit_private.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(qedit
);
28 static HINSTANCE qedit_instance
;
30 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
32 if (reason
== DLL_PROCESS_ATTACH
)
34 qedit_instance
= instance
;
35 DisableThreadLibraryCalls(instance
);
37 else if (reason
== DLL_PROCESS_DETACH
&& !reserved
)
39 strmbase_release_typelibs();
44 /******************************************************************************
45 * DirectShow ClassFactory
48 IClassFactory IClassFactory_iface
;
50 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
53 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
55 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
58 struct object_creation_info
61 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
64 static const struct object_creation_info object_creation
[] =
66 {&CLSID_AMTimeline
, timeline_create
},
67 {&CLSID_MediaDet
, media_detector_create
},
68 {&CLSID_NullRenderer
, null_renderer_create
},
69 {&CLSID_SampleGrabber
, sample_grabber_create
},
72 static HRESULT WINAPI
DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
74 if (IsEqualGUID(riid
, &IID_IUnknown
)
75 || IsEqualGUID(riid
, &IID_IClassFactory
))
77 IClassFactory_AddRef(iface
);
83 WARN("(%p)->(%s,%p), not found\n", iface
, debugstr_guid(riid
), ppobj
);
87 static ULONG WINAPI
DSCF_AddRef(IClassFactory
*iface
)
89 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
90 return InterlockedIncrement(&This
->ref
);
93 static ULONG WINAPI
DSCF_Release(IClassFactory
*iface
)
95 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
96 ULONG ref
= InterlockedDecrement(&This
->ref
);
104 static HRESULT WINAPI
DSCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
, REFIID riid
,
107 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
111 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
114 if (pOuter
&& !IsEqualGUID(&IID_IUnknown
, riid
))
115 return E_NOINTERFACE
;
117 hres
= This
->create_instance(pOuter
, &punk
);
118 if (SUCCEEDED(hres
)) {
119 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
120 IUnknown_Release(punk
);
125 static HRESULT WINAPI
DSCF_LockServer(IClassFactory
*iface
, BOOL dolock
)
127 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
128 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
132 static const IClassFactoryVtbl DSCF_Vtbl
=
142 /***********************************************************************
143 * DllCanUnloadNow (QEDIT.@)
145 HRESULT WINAPI
DllCanUnloadNow(void)
150 /*******************************************************************************
151 * DllGetClassObject [QEDIT.@]
152 * Retrieves class object from a DLL object
155 * rclsid [I] CLSID for the class object
156 * riid [I] Reference to identifier of interface for class object
157 * ppv [O] Address of variable to receive interface pointer for riid
161 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
162 * E_UNEXPECTED, E_NOINTERFACE
165 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
168 IClassFactoryImpl
*factory
;
170 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
172 if ( !IsEqualGUID( &IID_IClassFactory
, riid
)
173 && ! IsEqualGUID( &IID_IUnknown
, riid
) )
174 return E_NOINTERFACE
;
176 for (i
= 0; i
< ARRAY_SIZE(object_creation
); i
++)
178 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
182 if (i
== ARRAY_SIZE(object_creation
))
184 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
185 return CLASS_E_CLASSNOTAVAILABLE
;
188 factory
= CoTaskMemAlloc(sizeof(*factory
));
189 if (factory
== NULL
) return E_OUTOFMEMORY
;
191 factory
->IClassFactory_iface
.lpVtbl
= &DSCF_Vtbl
;
194 factory
->create_instance
= object_creation
[i
].create_instance
;
196 *ppv
= &factory
->IClassFactory_iface
;
200 static const REGPINTYPES reg_null_mt
= {&GUID_NULL
, &GUID_NULL
};
202 static const REGFILTERPINS2 reg_sample_grabber_pins
[2] =
207 .lpMediaType
= ®_null_mt
,
210 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
213 .lpMediaType
= ®_null_mt
,
217 static const REGFILTER2 reg_sample_grabber
=
220 .dwMerit
= MERIT_DO_NOT_USE
,
222 .u
.s2
.rgPins2
= reg_sample_grabber_pins
,
225 static const REGFILTERPINS2 reg_null_renderer_pins
[1] =
228 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
231 .lpMediaType
= ®_null_mt
,
235 static const REGFILTER2 reg_null_renderer
=
238 .dwMerit
= MERIT_DO_NOT_USE
,
240 .u
.s2
.rgPins2
= reg_null_renderer_pins
,
243 /***********************************************************************
244 * DllRegisterServer (QEDIT.@)
246 HRESULT WINAPI
DllRegisterServer(void)
248 IFilterMapper2
*mapper
;
251 if (FAILED(hr
= __wine_register_resources(qedit_instance
)))
254 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
255 &IID_IFilterMapper2
, (void **)&mapper
)))
258 IFilterMapper2_RegisterFilter(mapper
, &CLSID_SampleGrabber
, L
"SampleGrabber",
259 NULL
, NULL
, NULL
, ®_sample_grabber
);
260 IFilterMapper2_RegisterFilter(mapper
, &CLSID_NullRenderer
, L
"Null Renderer",
261 NULL
, NULL
, NULL
, ®_null_renderer
);
263 IFilterMapper2_Release(mapper
);
267 /***********************************************************************
268 * DllUnregisterServer (QEDIT.@)
270 HRESULT WINAPI
DllUnregisterServer(void)
272 IFilterMapper2
*mapper
;
275 if (FAILED(hr
= __wine_unregister_resources(qedit_instance
)))
278 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
279 &IID_IFilterMapper2
, (void **)&mapper
)))
282 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_SampleGrabber
);
283 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_NullRenderer
);
285 IFilterMapper2_Release(mapper
);