2 * Implementation of CLSID_FilterGraph.
4 * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
35 #include "quartz_private.h"
38 /***************************************************************************
40 * new/delete for CFilterGraph
44 /* can I use offsetof safely? - FIXME? */
45 static QUARTZ_IFEntry IFEntries[] =
47 { &IID_IPersist, offsetof(CFilterGraph,persist)-offsetof(CFilterGraph,unk) },
48 { &IID_IDispatch, offsetof(CFilterGraph,disp)-offsetof(CFilterGraph,unk) },
49 { &IID_IFilterGraph, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
50 { &IID_IGraphBuilder, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
51 { &IID_IFilterGraph2, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
52 { &IID_IGraphVersion, offsetof(CFilterGraph,graphversion)-offsetof(CFilterGraph,unk) },
53 { &IID_IGraphConfig, offsetof(CFilterGraph,grphconf)-offsetof(CFilterGraph,unk) },
54 { &IID_IMediaControl, offsetof(CFilterGraph,mediacontrol)-offsetof(CFilterGraph,unk) },
55 { &IID_IMediaFilter, offsetof(CFilterGraph,mediafilter)-offsetof(CFilterGraph,unk) },
56 { &IID_IMediaEvent, offsetof(CFilterGraph,mediaevent)-offsetof(CFilterGraph,unk) },
57 { &IID_IMediaEventEx, offsetof(CFilterGraph,mediaevent)-offsetof(CFilterGraph,unk) },
58 { &IID_IMediaEventSink, offsetof(CFilterGraph,mediaeventsink)-offsetof(CFilterGraph,unk) },
59 { &IID_IMediaPosition, offsetof(CFilterGraph,mediaposition)-offsetof(CFilterGraph,unk) },
60 { &IID_IMediaSeeking, offsetof(CFilterGraph,mediaseeking)-offsetof(CFilterGraph,unk) },
61 { &IID_IBasicVideo, offsetof(CFilterGraph,basvid)-offsetof(CFilterGraph,unk) },
62 { &IID_IBasicVideo2, offsetof(CFilterGraph,basvid)-offsetof(CFilterGraph,unk) },
63 { &IID_IBasicAudio, offsetof(CFilterGraph,basaud)-offsetof(CFilterGraph,unk) },
64 { &IID_IVideoWindow, offsetof(CFilterGraph,vidwin)-offsetof(CFilterGraph,unk) },
70 HRESULT (*pInit)(CFilterGraph*);
71 void (*pUninit)(CFilterGraph*);
74 static const struct FGInitEntry FGRAPH_Init[] =
76 #define FGENT(a) {&CFilterGraph_Init##a,&CFilterGraph_Uninit##a},
86 FGENT(IMediaEventSink)
98 static void QUARTZ_DestroyFilterGraph(IUnknown* punk)
100 CFilterGraph_THIS(punk,unk);
103 TRACE( "(%p)\n", punk );
105 /* At first, call Stop. */
106 IMediaControl_Stop( CFilterGraph_IMediaControl(This) );
107 IMediaFilter_Stop( CFilterGraph_IMediaFilter(This) );
110 while ( FGRAPH_Init[i].pInit != NULL )
112 FGRAPH_Init[i].pUninit( This );
116 TRACE( "succeeded.\n" );
119 HRESULT QUARTZ_CreateFilterGraph(IUnknown* punkOuter,void** ppobj)
125 TRACE("(%p,%p)\n",punkOuter,ppobj);
127 pfg = (CFilterGraph*)QUARTZ_AllocObj( sizeof(CFilterGraph) );
129 return E_OUTOFMEMORY;
131 QUARTZ_IUnkInit( &pfg->unk, punkOuter );
135 while ( FGRAPH_Init[i].pInit != NULL )
137 hr = FGRAPH_Init[i].pInit( pfg );
146 FGRAPH_Init[i].pUninit( pfg );
147 QUARTZ_FreeObj( pfg );
151 pfg->unk.pEntries = IFEntries;
152 pfg->unk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
153 pfg->unk.pOnFinalRelease = QUARTZ_DestroyFilterGraph;
155 *ppobj = (void*)(&pfg->unk);
161 /***************************************************************************
163 * CFilterGraph::IPersist
167 static HRESULT WINAPI
168 IPersist_fnQueryInterface(IPersist* iface,REFIID riid,void** ppobj)
170 CFilterGraph_THIS(iface,persist);
172 TRACE("(%p)->()\n",This);
174 return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
178 IPersist_fnAddRef(IPersist* iface)
180 CFilterGraph_THIS(iface,persist);
182 TRACE("(%p)->()\n",This);
184 return IUnknown_AddRef(This->unk.punkControl);
188 IPersist_fnRelease(IPersist* iface)
190 CFilterGraph_THIS(iface,persist);
192 TRACE("(%p)->()\n",This);
194 return IUnknown_Release(This->unk.punkControl);
198 static HRESULT WINAPI
199 IPersist_fnGetClassID(IPersist* iface,CLSID* pclsid)
201 CFilterGraph_THIS(iface,persist);
203 TRACE("(%p)->()\n",This);
205 if ( pclsid == NULL )
207 memcpy( pclsid, &CLSID_FilterGraph, sizeof(CLSID) );
213 static ICOM_VTABLE(IPersist) ipersist =
215 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
216 /* IUnknown fields */
217 IPersist_fnQueryInterface,
220 /* IPersist fields */
221 IPersist_fnGetClassID,
224 HRESULT CFilterGraph_InitIPersist( CFilterGraph* pfg )
227 ICOM_VTBL(&pfg->persist) = &ipersist;
232 void CFilterGraph_UninitIPersist( CFilterGraph* pfg )
237 /***************************************************************************
239 * CFilterGraph::IDispatch
243 static HRESULT WINAPI
244 IDispatch_fnQueryInterface(IDispatch* iface,REFIID riid,void** ppobj)
246 CFilterGraph_THIS(iface,disp);
248 TRACE("(%p)->()\n",This);
250 return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
254 IDispatch_fnAddRef(IDispatch* iface)
256 CFilterGraph_THIS(iface,disp);
258 TRACE("(%p)->()\n",This);
260 return IUnknown_AddRef(This->unk.punkControl);
264 IDispatch_fnRelease(IDispatch* iface)
266 CFilterGraph_THIS(iface,disp);
268 TRACE("(%p)->()\n",This);
270 return IUnknown_Release(This->unk.punkControl);
273 static HRESULT WINAPI
274 IDispatch_fnGetTypeInfoCount(IDispatch* iface,UINT* pcTypeInfo)
276 CFilterGraph_THIS(iface,disp);
278 FIXME("(%p)->()\n",This);
283 static HRESULT WINAPI
284 IDispatch_fnGetTypeInfo(IDispatch* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
286 CFilterGraph_THIS(iface,disp);
288 FIXME("(%p)->()\n",This);
293 static HRESULT WINAPI
294 IDispatch_fnGetIDsOfNames(IDispatch* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
296 CFilterGraph_THIS(iface,disp);
298 FIXME("(%p)->()\n",This);
303 static HRESULT WINAPI
304 IDispatch_fnInvoke(IDispatch* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
306 CFilterGraph_THIS(iface,disp);
308 FIXME("(%p)->()\n",This);
315 static ICOM_VTABLE(IDispatch) idispatch =
317 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
318 /* IUnknown fields */
319 IDispatch_fnQueryInterface,
322 /* IDispatch fields */
323 IDispatch_fnGetTypeInfoCount,
324 IDispatch_fnGetTypeInfo,
325 IDispatch_fnGetIDsOfNames,
330 HRESULT CFilterGraph_InitIDispatch( CFilterGraph* pfg )
333 ICOM_VTBL(&pfg->disp) = &idispatch;
338 void CFilterGraph_UninitIDispatch( CFilterGraph* pfg )