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(quartz
);
28 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
30 if (reason
== DLL_PROCESS_ATTACH
)
32 DisableThreadLibraryCalls(instance
);
34 else if (reason
== DLL_PROCESS_DETACH
&& !reserved
)
36 strmbase_release_typelibs();
41 /******************************************************************************
42 * DirectShow ClassFactory
45 IClassFactory IClassFactory_iface
;
47 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
50 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
52 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
55 struct object_creation_info
58 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
61 static const struct object_creation_info object_creation
[] =
63 {&CLSID_AMTimeline
, timeline_create
},
64 {&CLSID_MediaDet
, media_detector_create
},
65 {&CLSID_NullRenderer
, null_renderer_create
},
66 {&CLSID_SampleGrabber
, sample_grabber_create
},
69 static HRESULT WINAPI
DSCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
71 if (IsEqualGUID(riid
, &IID_IUnknown
)
72 || IsEqualGUID(riid
, &IID_IClassFactory
))
74 IClassFactory_AddRef(iface
);
80 WARN("(%p)->(%s,%p), not found\n", iface
, debugstr_guid(riid
), ppobj
);
84 static ULONG WINAPI
DSCF_AddRef(IClassFactory
*iface
)
86 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
87 return InterlockedIncrement(&This
->ref
);
90 static ULONG WINAPI
DSCF_Release(IClassFactory
*iface
)
92 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
93 ULONG ref
= InterlockedDecrement(&This
->ref
);
101 static HRESULT WINAPI
DSCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
, REFIID riid
,
104 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
108 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
111 if (pOuter
&& !IsEqualGUID(&IID_IUnknown
, riid
))
112 return E_NOINTERFACE
;
114 hres
= This
->create_instance(pOuter
, &punk
);
115 if (SUCCEEDED(hres
)) {
116 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
117 IUnknown_Release(punk
);
122 static HRESULT WINAPI
DSCF_LockServer(IClassFactory
*iface
, BOOL dolock
)
124 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
125 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
129 static const IClassFactoryVtbl DSCF_Vtbl
=
139 /*******************************************************************************
140 * DllGetClassObject [QEDIT.@]
141 * Retrieves class object from a DLL object
144 * rclsid [I] CLSID for the class object
145 * riid [I] Reference to identifier of interface for class object
146 * ppv [O] Address of variable to receive interface pointer for riid
150 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
151 * E_UNEXPECTED, E_NOINTERFACE
154 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
157 IClassFactoryImpl
*factory
;
159 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
161 if ( !IsEqualGUID( &IID_IClassFactory
, riid
)
162 && ! IsEqualGUID( &IID_IUnknown
, riid
) )
163 return E_NOINTERFACE
;
165 for (i
= 0; i
< ARRAY_SIZE(object_creation
); i
++)
167 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
171 if (i
== ARRAY_SIZE(object_creation
))
173 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
174 return CLASS_E_CLASSNOTAVAILABLE
;
177 factory
= CoTaskMemAlloc(sizeof(*factory
));
178 if (factory
== NULL
) return E_OUTOFMEMORY
;
180 factory
->IClassFactory_iface
.lpVtbl
= &DSCF_Vtbl
;
183 factory
->create_instance
= object_creation
[i
].create_instance
;
185 *ppv
= &factory
->IClassFactory_iface
;
189 static const REGPINTYPES reg_null_mt
= {&GUID_NULL
, &GUID_NULL
};
191 static const REGFILTERPINS2 reg_sample_grabber_pins
[2] =
196 .lpMediaType
= ®_null_mt
,
199 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
202 .lpMediaType
= ®_null_mt
,
206 static const REGFILTER2 reg_sample_grabber
=
209 .dwMerit
= MERIT_DO_NOT_USE
,
211 .u
.s2
.rgPins2
= reg_sample_grabber_pins
,
214 static const REGFILTERPINS2 reg_null_renderer_pins
[1] =
217 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
220 .lpMediaType
= ®_null_mt
,
224 static const REGFILTER2 reg_null_renderer
=
227 .dwMerit
= MERIT_DO_NOT_USE
,
229 .u
.s2
.rgPins2
= reg_null_renderer_pins
,
232 /***********************************************************************
233 * DllRegisterServer (QEDIT.@)
235 HRESULT WINAPI
DllRegisterServer(void)
237 IFilterMapper2
*mapper
;
240 if (FAILED(hr
= __wine_register_resources()))
243 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
244 &IID_IFilterMapper2
, (void **)&mapper
)))
247 IFilterMapper2_RegisterFilter(mapper
, &CLSID_SampleGrabber
, L
"SampleGrabber",
248 NULL
, NULL
, NULL
, ®_sample_grabber
);
249 IFilterMapper2_RegisterFilter(mapper
, &CLSID_NullRenderer
, L
"Null Renderer",
250 NULL
, NULL
, NULL
, ®_null_renderer
);
252 IFilterMapper2_Release(mapper
);
256 /***********************************************************************
257 * DllUnregisterServer (QEDIT.@)
259 HRESULT WINAPI
DllUnregisterServer(void)
261 IFilterMapper2
*mapper
;
264 if (FAILED(hr
= __wine_unregister_resources()))
267 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
268 &IID_IFilterMapper2
, (void **)&mapper
)))
271 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_SampleGrabber
);
272 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_NullRenderer
);
274 IFilterMapper2_Release(mapper
);