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 qedit_instance
;
28 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
30 if (reason
== DLL_PROCESS_ATTACH
)
32 qedit_instance
= instance
;
33 DisableThreadLibraryCalls(instance
);
35 else if (reason
== DLL_PROCESS_DETACH
&& !reserved
)
37 strmbase_release_typelibs();
42 /******************************************************************************
43 * DirectShow ClassFactory
46 IClassFactory IClassFactory_iface
;
48 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
51 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
53 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
56 struct object_creation_info
59 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
62 static const struct object_creation_info object_creation
[] =
64 {&CLSID_AMTimeline
, timeline_create
},
65 {&CLSID_MediaDet
, media_detector_create
},
66 {&CLSID_NullRenderer
, null_renderer_create
},
67 {&CLSID_SampleGrabber
, sample_grabber_create
},
70 static HRESULT WINAPI
DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
72 if (IsEqualGUID(riid
, &IID_IUnknown
)
73 || IsEqualGUID(riid
, &IID_IClassFactory
))
75 IClassFactory_AddRef(iface
);
81 WARN("(%p)->(%s,%p), not found\n", iface
, debugstr_guid(riid
), ppobj
);
85 static ULONG WINAPI
DSCF_AddRef(IClassFactory
*iface
)
87 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
88 return InterlockedIncrement(&This
->ref
);
91 static ULONG WINAPI
DSCF_Release(IClassFactory
*iface
)
93 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
94 ULONG ref
= InterlockedDecrement(&This
->ref
);
102 static HRESULT WINAPI
DSCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
, REFIID riid
,
105 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
109 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
112 if (pOuter
&& !IsEqualGUID(&IID_IUnknown
, riid
))
113 return E_NOINTERFACE
;
115 hres
= This
->create_instance(pOuter
, &punk
);
116 if (SUCCEEDED(hres
)) {
117 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
118 IUnknown_Release(punk
);
123 static HRESULT WINAPI
DSCF_LockServer(IClassFactory
*iface
, BOOL dolock
)
125 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
126 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
130 static const IClassFactoryVtbl DSCF_Vtbl
=
140 /***********************************************************************
141 * DllCanUnloadNow (QEDIT.@)
143 HRESULT WINAPI
DllCanUnloadNow(void)
148 /*******************************************************************************
149 * DllGetClassObject [QEDIT.@]
150 * Retrieves class object from a DLL object
153 * rclsid [I] CLSID for the class object
154 * riid [I] Reference to identifier of interface for class object
155 * ppv [O] Address of variable to receive interface pointer for riid
159 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
160 * E_UNEXPECTED, E_NOINTERFACE
163 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
166 IClassFactoryImpl
*factory
;
168 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
170 if ( !IsEqualGUID( &IID_IClassFactory
, riid
)
171 && ! IsEqualGUID( &IID_IUnknown
, riid
) )
172 return E_NOINTERFACE
;
174 for (i
= 0; i
< ARRAY_SIZE(object_creation
); i
++)
176 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
180 if (i
== ARRAY_SIZE(object_creation
))
182 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
183 return CLASS_E_CLASSNOTAVAILABLE
;
186 factory
= CoTaskMemAlloc(sizeof(*factory
));
187 if (factory
== NULL
) return E_OUTOFMEMORY
;
189 factory
->IClassFactory_iface
.lpVtbl
= &DSCF_Vtbl
;
192 factory
->create_instance
= object_creation
[i
].create_instance
;
194 *ppv
= &factory
->IClassFactory_iface
;
198 static const REGPINTYPES reg_null_mt
= {&GUID_NULL
, &GUID_NULL
};
200 static const REGFILTERPINS2 reg_sample_grabber_pins
[2] =
205 .lpMediaType
= ®_null_mt
,
208 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
211 .lpMediaType
= ®_null_mt
,
215 static const REGFILTER2 reg_sample_grabber
=
218 .dwMerit
= MERIT_DO_NOT_USE
,
220 .u
.s2
.rgPins2
= reg_sample_grabber_pins
,
223 static const REGFILTERPINS2 reg_null_renderer_pins
[1] =
226 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
229 .lpMediaType
= ®_null_mt
,
233 static const REGFILTER2 reg_null_renderer
=
236 .dwMerit
= MERIT_DO_NOT_USE
,
238 .u
.s2
.rgPins2
= reg_null_renderer_pins
,
241 /***********************************************************************
242 * DllRegisterServer (QEDIT.@)
244 HRESULT WINAPI
DllRegisterServer(void)
246 IFilterMapper2
*mapper
;
249 if (FAILED(hr
= __wine_register_resources(qedit_instance
)))
252 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
253 &IID_IFilterMapper2
, (void **)&mapper
)))
256 IFilterMapper2_RegisterFilter(mapper
, &CLSID_SampleGrabber
, L
"SampleGrabber",
257 NULL
, NULL
, NULL
, ®_sample_grabber
);
258 IFilterMapper2_RegisterFilter(mapper
, &CLSID_NullRenderer
, L
"Null Renderer",
259 NULL
, NULL
, NULL
, ®_null_renderer
);
261 IFilterMapper2_Release(mapper
);
265 /***********************************************************************
266 * DllUnregisterServer (QEDIT.@)
268 HRESULT WINAPI
DllUnregisterServer(void)
270 IFilterMapper2
*mapper
;
273 if (FAILED(hr
= __wine_unregister_resources(qedit_instance
)))
276 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
277 &IID_IFilterMapper2
, (void **)&mapper
)))
280 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_SampleGrabber
);
281 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_NullRenderer
);
283 IFilterMapper2_Release(mapper
);