2 * Implementation of CLSID_FilterGraph.
4 * hidenori@a2.ctktv.ne.jp
14 #include "wine/obj_base.h"
15 #include "wine/obj_oleaut.h"
20 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(quartz);
23 #include "quartz_private.h"
26 /***************************************************************************
28 * new/delete for CFilterGraph
32 /* can I use offsetof safely? - FIXME? */
33 static QUARTZ_IFEntry IFEntries[] =
35 { &IID_IPersist, offsetof(CFilterGraph,persist)-offsetof(CFilterGraph,unk) },
36 { &IID_IDispatch, offsetof(CFilterGraph,disp)-offsetof(CFilterGraph,unk) },
37 { &IID_IFilterGraph, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
38 { &IID_IGraphBuilder, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
39 { &IID_IFilterGraph2, offsetof(CFilterGraph,fgraph)-offsetof(CFilterGraph,unk) },
40 { &IID_IGraphVersion, offsetof(CFilterGraph,graphversion)-offsetof(CFilterGraph,unk) },
41 { &IID_IGraphConfig, offsetof(CFilterGraph,grphconf)-offsetof(CFilterGraph,unk) },
42 { &IID_IMediaControl, offsetof(CFilterGraph,mediacontrol)-offsetof(CFilterGraph,unk) },
43 { &IID_IMediaFilter, offsetof(CFilterGraph,mediafilter)-offsetof(CFilterGraph,unk) },
44 { &IID_IMediaEvent, offsetof(CFilterGraph,mediaevent)-offsetof(CFilterGraph,unk) },
45 { &IID_IMediaEventEx, offsetof(CFilterGraph,mediaevent)-offsetof(CFilterGraph,unk) },
46 { &IID_IMediaEventSink, offsetof(CFilterGraph,mediaeventsink)-offsetof(CFilterGraph,unk) },
47 { &IID_IMediaPosition, offsetof(CFilterGraph,mediaposition)-offsetof(CFilterGraph,unk) },
48 { &IID_IMediaSeeking, offsetof(CFilterGraph,mediaseeking)-offsetof(CFilterGraph,unk) },
49 { &IID_IBasicVideo, offsetof(CFilterGraph,basvid)-offsetof(CFilterGraph,unk) },
50 { &IID_IBasicVideo2, offsetof(CFilterGraph,basvid)-offsetof(CFilterGraph,unk) },
51 { &IID_IBasicAudio, offsetof(CFilterGraph,basaud)-offsetof(CFilterGraph,unk) },
52 { &IID_IVideoWindow, offsetof(CFilterGraph,vidwin)-offsetof(CFilterGraph,unk) },
58 HRESULT (*pInit)(CFilterGraph*);
59 void (*pUninit)(CFilterGraph*);
62 static const struct FGInitEntry FGRAPH_Init[] =
64 #define FGENT(a) {&CFilterGraph_Init##a,&CFilterGraph_Uninit##a},
74 FGENT(IMediaEventSink)
86 static void QUARTZ_DestroyFilterGraph(IUnknown* punk)
88 CFilterGraph_THIS(punk,unk);
91 TRACE( "(%p)\n", punk );
93 /* At first, call Stop. */
94 IMediaControl_Stop( CFilterGraph_IMediaControl(This) );
95 IMediaFilter_Stop( CFilterGraph_IMediaFilter(This) );
98 while ( FGRAPH_Init[i].pInit != NULL )
100 FGRAPH_Init[i].pUninit( This );
104 TRACE( "succeeded.\n" );
107 HRESULT QUARTZ_CreateFilterGraph(IUnknown* punkOuter,void** ppobj)
113 TRACE("(%p,%p)\n",punkOuter,ppobj);
115 pfg = (CFilterGraph*)QUARTZ_AllocObj( sizeof(CFilterGraph) );
117 return E_OUTOFMEMORY;
119 QUARTZ_IUnkInit( &pfg->unk, punkOuter );
123 while ( FGRAPH_Init[i].pInit != NULL )
125 hr = FGRAPH_Init[i].pInit( pfg );
134 FGRAPH_Init[i].pUninit( pfg );
135 QUARTZ_FreeObj( pfg );
139 pfg->unk.pEntries = IFEntries;
140 pfg->unk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
141 pfg->unk.pOnFinalRelease = QUARTZ_DestroyFilterGraph;
143 *ppobj = (void*)(&pfg->unk);
149 /***************************************************************************
151 * CFilterGraph::IPersist
155 static HRESULT WINAPI
156 IPersist_fnQueryInterface(IPersist* iface,REFIID riid,void** ppobj)
158 CFilterGraph_THIS(iface,persist);
160 TRACE("(%p)->()\n",This);
162 return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
166 IPersist_fnAddRef(IPersist* iface)
168 CFilterGraph_THIS(iface,persist);
170 TRACE("(%p)->()\n",This);
172 return IUnknown_AddRef(This->unk.punkControl);
176 IPersist_fnRelease(IPersist* iface)
178 CFilterGraph_THIS(iface,persist);
180 TRACE("(%p)->()\n",This);
182 return IUnknown_Release(This->unk.punkControl);
186 static HRESULT WINAPI
187 IPersist_fnGetClassID(IPersist* iface,CLSID* pclsid)
189 CFilterGraph_THIS(iface,persist);
191 TRACE("(%p)->()\n",This);
193 if ( pclsid == NULL )
195 memcpy( pclsid, &CLSID_FilterGraph, sizeof(CLSID) );
201 static ICOM_VTABLE(IPersist) ipersist =
203 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
204 /* IUnknown fields */
205 IPersist_fnQueryInterface,
208 /* IPersist fields */
209 IPersist_fnGetClassID,
212 HRESULT CFilterGraph_InitIPersist( CFilterGraph* pfg )
215 ICOM_VTBL(&pfg->persist) = &ipersist;
220 void CFilterGraph_UninitIPersist( CFilterGraph* pfg )