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_IMediaControl
, offsetof(CFilterGraph
,mediacontrol
)-offsetof(CFilterGraph
,unk
) },
54 { &IID_IMediaFilter
, offsetof(CFilterGraph
,mediafilter
)-offsetof(CFilterGraph
,unk
) },
55 { &IID_IMediaEvent
, offsetof(CFilterGraph
,mediaevent
)-offsetof(CFilterGraph
,unk
) },
56 { &IID_IMediaEventEx
, offsetof(CFilterGraph
,mediaevent
)-offsetof(CFilterGraph
,unk
) },
57 { &IID_IMediaEventSink
, offsetof(CFilterGraph
,mediaeventsink
)-offsetof(CFilterGraph
,unk
) },
58 { &IID_IMediaPosition
, offsetof(CFilterGraph
,mediaposition
)-offsetof(CFilterGraph
,unk
) },
59 { &IID_IMediaSeeking
, offsetof(CFilterGraph
,mediaseeking
)-offsetof(CFilterGraph
,unk
) },
60 { &IID_IBasicVideo
, offsetof(CFilterGraph
,basvid
)-offsetof(CFilterGraph
,unk
) },
61 { &IID_IBasicAudio
, offsetof(CFilterGraph
,basaud
)-offsetof(CFilterGraph
,unk
) },
62 { &IID_IVideoWindow
, offsetof(CFilterGraph
,vidwin
)-offsetof(CFilterGraph
,unk
) },
68 HRESULT (*pInit
)(CFilterGraph
*);
69 void (*pUninit
)(CFilterGraph
*);
72 static const struct FGInitEntry FGRAPH_Init
[] =
74 #define FGENT(a) {&CFilterGraph_Init##a,&CFilterGraph_Uninit##a},
83 FGENT(IMediaEventSink
)
95 static void QUARTZ_DestroyFilterGraph(IUnknown
* punk
)
97 CFilterGraph_THIS(punk
,unk
);
100 TRACE( "(%p)\n", punk
);
102 /* At first, call Stop. */
103 IMediaControl_Stop( CFilterGraph_IMediaControl(This
) );
104 IMediaFilter_Stop( CFilterGraph_IMediaFilter(This
) );
107 while ( FGRAPH_Init
[i
].pInit
!= NULL
)
109 FGRAPH_Init
[i
].pUninit( This
);
113 TRACE( "succeeded.\n" );
116 HRESULT
QUARTZ_CreateFilterGraph(IUnknown
* punkOuter
,void** ppobj
)
122 TRACE("(%p,%p)\n",punkOuter
,ppobj
);
124 pfg
= (CFilterGraph
*)QUARTZ_AllocObj( sizeof(CFilterGraph
) );
126 return E_OUTOFMEMORY
;
128 QUARTZ_IUnkInit( &pfg
->unk
, punkOuter
);
132 while ( FGRAPH_Init
[i
].pInit
!= NULL
)
134 hr
= FGRAPH_Init
[i
].pInit( pfg
);
143 FGRAPH_Init
[i
].pUninit( pfg
);
144 QUARTZ_FreeObj( pfg
);
148 pfg
->unk
.pEntries
= IFEntries
;
149 pfg
->unk
.dwEntries
= sizeof(IFEntries
)/sizeof(IFEntries
[0]);
150 pfg
->unk
.pOnFinalRelease
= QUARTZ_DestroyFilterGraph
;
152 *ppobj
= (void*)(&pfg
->unk
);
158 /***************************************************************************
160 * CFilterGraph::IPersist
164 static HRESULT WINAPI
165 IPersist_fnQueryInterface(IPersist
* iface
,REFIID riid
,void** ppobj
)
167 CFilterGraph_THIS(iface
,persist
);
169 TRACE("(%p)->()\n",This
);
171 return IUnknown_QueryInterface(This
->unk
.punkControl
,riid
,ppobj
);
175 IPersist_fnAddRef(IPersist
* iface
)
177 CFilterGraph_THIS(iface
,persist
);
179 TRACE("(%p)->()\n",This
);
181 return IUnknown_AddRef(This
->unk
.punkControl
);
185 IPersist_fnRelease(IPersist
* iface
)
187 CFilterGraph_THIS(iface
,persist
);
189 TRACE("(%p)->()\n",This
);
191 return IUnknown_Release(This
->unk
.punkControl
);
195 static HRESULT WINAPI
196 IPersist_fnGetClassID(IPersist
* iface
,CLSID
* pclsid
)
198 CFilterGraph_THIS(iface
,persist
);
200 TRACE("(%p)->()\n",This
);
202 if ( pclsid
== NULL
)
204 memcpy( pclsid
, &CLSID_FilterGraph
, sizeof(CLSID
) );
210 static ICOM_VTABLE(IPersist
) ipersist
=
212 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
213 /* IUnknown fields */
214 IPersist_fnQueryInterface
,
217 /* IPersist fields */
218 IPersist_fnGetClassID
,
221 HRESULT
CFilterGraph_InitIPersist( CFilterGraph
* pfg
)
224 ICOM_VTBL(&pfg
->persist
) = &ipersist
;
229 void CFilterGraph_UninitIPersist( CFilterGraph
* pfg
)
234 /***************************************************************************
236 * CFilterGraph::IDispatch
240 static HRESULT WINAPI
241 IDispatch_fnQueryInterface(IDispatch
* iface
,REFIID riid
,void** ppobj
)
243 CFilterGraph_THIS(iface
,disp
);
245 TRACE("(%p)->()\n",This
);
247 return IUnknown_QueryInterface(This
->unk
.punkControl
,riid
,ppobj
);
251 IDispatch_fnAddRef(IDispatch
* iface
)
253 CFilterGraph_THIS(iface
,disp
);
255 TRACE("(%p)->()\n",This
);
257 return IUnknown_AddRef(This
->unk
.punkControl
);
261 IDispatch_fnRelease(IDispatch
* iface
)
263 CFilterGraph_THIS(iface
,disp
);
265 TRACE("(%p)->()\n",This
);
267 return IUnknown_Release(This
->unk
.punkControl
);
270 static HRESULT WINAPI
271 IDispatch_fnGetTypeInfoCount(IDispatch
* iface
,UINT
* pcTypeInfo
)
273 CFilterGraph_THIS(iface
,disp
);
275 FIXME("(%p)->()\n",This
);
280 static HRESULT WINAPI
281 IDispatch_fnGetTypeInfo(IDispatch
* iface
,UINT iTypeInfo
, LCID lcid
, ITypeInfo
** ppobj
)
283 CFilterGraph_THIS(iface
,disp
);
285 FIXME("(%p)->()\n",This
);
290 static HRESULT WINAPI
291 IDispatch_fnGetIDsOfNames(IDispatch
* iface
,REFIID riid
, LPOLESTR
* ppwszName
, UINT cNames
, LCID lcid
, DISPID
* pDispId
)
293 CFilterGraph_THIS(iface
,disp
);
295 FIXME("(%p)->()\n",This
);
300 static HRESULT WINAPI
301 IDispatch_fnInvoke(IDispatch
* iface
,DISPID DispId
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarRes
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
303 CFilterGraph_THIS(iface
,disp
);
305 FIXME("(%p)->()\n",This
);
312 static ICOM_VTABLE(IDispatch
) idispatch
=
314 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
315 /* IUnknown fields */
316 IDispatch_fnQueryInterface
,
319 /* IDispatch fields */
320 IDispatch_fnGetTypeInfoCount
,
321 IDispatch_fnGetTypeInfo
,
322 IDispatch_fnGetIDsOfNames
,
327 HRESULT
CFilterGraph_InitIDispatch( CFilterGraph
* pfg
)
330 ICOM_VTBL(&pfg
->disp
) = &idispatch
;
335 void CFilterGraph_UninitIDispatch( CFilterGraph
* pfg
)