2 * Implementation of CLSID_FilterGraph.
4 * hidenori@a2.ctktv.ne.jp
18 #include "debugtools.h"
19 DEFAULT_DEBUG_CHANNEL(quartz
);
21 #include "quartz_private.h"
24 /***************************************************************************
26 * new/delete for CFilterGraph
30 /* can I use offsetof safely? - FIXME? */
31 static QUARTZ_IFEntry IFEntries
[] =
33 { &IID_IPersist
, offsetof(CFilterGraph
,persist
)-offsetof(CFilterGraph
,unk
) },
34 { &IID_IDispatch
, offsetof(CFilterGraph
,disp
)-offsetof(CFilterGraph
,unk
) },
35 { &IID_IFilterGraph
, offsetof(CFilterGraph
,fgraph
)-offsetof(CFilterGraph
,unk
) },
36 { &IID_IGraphBuilder
, offsetof(CFilterGraph
,fgraph
)-offsetof(CFilterGraph
,unk
) },
37 { &IID_IFilterGraph2
, offsetof(CFilterGraph
,fgraph
)-offsetof(CFilterGraph
,unk
) },
38 { &IID_IGraphVersion
, offsetof(CFilterGraph
,graphversion
)-offsetof(CFilterGraph
,unk
) },
39 { &IID_IGraphConfig
, offsetof(CFilterGraph
,grphconf
)-offsetof(CFilterGraph
,unk
) },
40 { &IID_IMediaControl
, offsetof(CFilterGraph
,mediacontrol
)-offsetof(CFilterGraph
,unk
) },
41 { &IID_IMediaFilter
, offsetof(CFilterGraph
,mediafilter
)-offsetof(CFilterGraph
,unk
) },
42 { &IID_IMediaEvent
, offsetof(CFilterGraph
,mediaevent
)-offsetof(CFilterGraph
,unk
) },
43 { &IID_IMediaEventEx
, offsetof(CFilterGraph
,mediaevent
)-offsetof(CFilterGraph
,unk
) },
44 { &IID_IMediaEventSink
, offsetof(CFilterGraph
,mediaeventsink
)-offsetof(CFilterGraph
,unk
) },
45 { &IID_IMediaPosition
, offsetof(CFilterGraph
,mediaposition
)-offsetof(CFilterGraph
,unk
) },
46 { &IID_IMediaSeeking
, offsetof(CFilterGraph
,mediaseeking
)-offsetof(CFilterGraph
,unk
) },
47 { &IID_IBasicVideo
, offsetof(CFilterGraph
,basvid
)-offsetof(CFilterGraph
,unk
) },
48 { &IID_IBasicVideo2
, offsetof(CFilterGraph
,basvid
)-offsetof(CFilterGraph
,unk
) },
49 { &IID_IBasicAudio
, offsetof(CFilterGraph
,basaud
)-offsetof(CFilterGraph
,unk
) },
50 { &IID_IVideoWindow
, offsetof(CFilterGraph
,vidwin
)-offsetof(CFilterGraph
,unk
) },
56 HRESULT (*pInit
)(CFilterGraph
*);
57 void (*pUninit
)(CFilterGraph
*);
60 static const struct FGInitEntry FGRAPH_Init
[] =
62 #define FGENT(a) {&CFilterGraph_Init##a,&CFilterGraph_Uninit##a},
72 FGENT(IMediaEventSink
)
84 static void QUARTZ_DestroyFilterGraph(IUnknown
* punk
)
86 CFilterGraph_THIS(punk
,unk
);
89 TRACE( "(%p)\n", punk
);
91 /* At first, call Stop. */
92 IMediaControl_Stop( CFilterGraph_IMediaControl(This
) );
93 IMediaFilter_Stop( CFilterGraph_IMediaFilter(This
) );
96 while ( FGRAPH_Init
[i
].pInit
!= NULL
)
98 FGRAPH_Init
[i
].pUninit( This
);
102 TRACE( "succeeded.\n" );
105 HRESULT
QUARTZ_CreateFilterGraph(IUnknown
* punkOuter
,void** ppobj
)
111 TRACE("(%p,%p)\n",punkOuter
,ppobj
);
113 pfg
= (CFilterGraph
*)QUARTZ_AllocObj( sizeof(CFilterGraph
) );
115 return E_OUTOFMEMORY
;
117 QUARTZ_IUnkInit( &pfg
->unk
, punkOuter
);
121 while ( FGRAPH_Init
[i
].pInit
!= NULL
)
123 hr
= FGRAPH_Init
[i
].pInit( pfg
);
132 FGRAPH_Init
[i
].pUninit( pfg
);
133 QUARTZ_FreeObj( pfg
);
137 pfg
->unk
.pEntries
= IFEntries
;
138 pfg
->unk
.dwEntries
= sizeof(IFEntries
)/sizeof(IFEntries
[0]);
139 pfg
->unk
.pOnFinalRelease
= QUARTZ_DestroyFilterGraph
;
141 *ppobj
= (void*)(&pfg
->unk
);
147 /***************************************************************************
149 * CFilterGraph::IPersist
153 static HRESULT WINAPI
154 IPersist_fnQueryInterface(IPersist
* iface
,REFIID riid
,void** ppobj
)
156 CFilterGraph_THIS(iface
,persist
);
158 TRACE("(%p)->()\n",This
);
160 return IUnknown_QueryInterface(This
->unk
.punkControl
,riid
,ppobj
);
164 IPersist_fnAddRef(IPersist
* iface
)
166 CFilterGraph_THIS(iface
,persist
);
168 TRACE("(%p)->()\n",This
);
170 return IUnknown_AddRef(This
->unk
.punkControl
);
174 IPersist_fnRelease(IPersist
* iface
)
176 CFilterGraph_THIS(iface
,persist
);
178 TRACE("(%p)->()\n",This
);
180 return IUnknown_Release(This
->unk
.punkControl
);
184 static HRESULT WINAPI
185 IPersist_fnGetClassID(IPersist
* iface
,CLSID
* pclsid
)
187 CFilterGraph_THIS(iface
,persist
);
189 TRACE("(%p)->()\n",This
);
191 if ( pclsid
== NULL
)
193 memcpy( pclsid
, &CLSID_FilterGraph
, sizeof(CLSID
) );
199 static ICOM_VTABLE(IPersist
) ipersist
=
201 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
202 /* IUnknown fields */
203 IPersist_fnQueryInterface
,
206 /* IPersist fields */
207 IPersist_fnGetClassID
,
210 HRESULT
CFilterGraph_InitIPersist( CFilterGraph
* pfg
)
213 ICOM_VTBL(&pfg
->persist
) = &ipersist
;
218 void CFilterGraph_UninitIPersist( CFilterGraph
* pfg
)
223 /***************************************************************************
225 * CFilterGraph::IDispatch
229 static HRESULT WINAPI
230 IDispatch_fnQueryInterface(IDispatch
* iface
,REFIID riid
,void** ppobj
)
232 CFilterGraph_THIS(iface
,disp
);
234 TRACE("(%p)->()\n",This
);
236 return IUnknown_QueryInterface(This
->unk
.punkControl
,riid
,ppobj
);
240 IDispatch_fnAddRef(IDispatch
* iface
)
242 CFilterGraph_THIS(iface
,disp
);
244 TRACE("(%p)->()\n",This
);
246 return IUnknown_AddRef(This
->unk
.punkControl
);
250 IDispatch_fnRelease(IDispatch
* iface
)
252 CFilterGraph_THIS(iface
,disp
);
254 TRACE("(%p)->()\n",This
);
256 return IUnknown_Release(This
->unk
.punkControl
);
259 static HRESULT WINAPI
260 IDispatch_fnGetTypeInfoCount(IDispatch
* iface
,UINT
* pcTypeInfo
)
262 CFilterGraph_THIS(iface
,disp
);
264 FIXME("(%p)->()\n",This
);
269 static HRESULT WINAPI
270 IDispatch_fnGetTypeInfo(IDispatch
* iface
,UINT iTypeInfo
, LCID lcid
, ITypeInfo
** ppobj
)
272 CFilterGraph_THIS(iface
,disp
);
274 FIXME("(%p)->()\n",This
);
279 static HRESULT WINAPI
280 IDispatch_fnGetIDsOfNames(IDispatch
* iface
,REFIID riid
, LPOLESTR
* ppwszName
, UINT cNames
, LCID lcid
, DISPID
* pDispId
)
282 CFilterGraph_THIS(iface
,disp
);
284 FIXME("(%p)->()\n",This
);
289 static HRESULT WINAPI
290 IDispatch_fnInvoke(IDispatch
* iface
,DISPID DispId
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarRes
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
292 CFilterGraph_THIS(iface
,disp
);
294 FIXME("(%p)->()\n",This
);
301 static ICOM_VTABLE(IDispatch
) idispatch
=
303 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
304 /* IUnknown fields */
305 IDispatch_fnQueryInterface
,
308 /* IDispatch fields */
309 IDispatch_fnGetTypeInfoCount
,
310 IDispatch_fnGetTypeInfo
,
311 IDispatch_fnGetIDsOfNames
,
316 HRESULT
CFilterGraph_InitIDispatch( CFilterGraph
* pfg
)
319 ICOM_VTBL(&pfg
->disp
) = &idispatch
;
324 void CFilterGraph_UninitIDispatch( CFilterGraph
* pfg
)