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) },
65 { &IID_IAMStats, offsetof(CFilterGraph,amstats)-offsetof(CFilterGraph,unk) },
71 HRESULT (*pInit)(CFilterGraph*);
72 void (*pUninit)(CFilterGraph*);
75 static const struct FGInitEntry FGRAPH_Init[] =
77 #define FGENT(a) {&CFilterGraph_Init##a,&CFilterGraph_Uninit##a},
87 FGENT(IMediaEventSink)
100 static void QUARTZ_DestroyFilterGraph(IUnknown* punk)
102 CFilterGraph_THIS(punk,unk);
105 TRACE( "(%p)\n", punk );
107 /* At first, call Stop. */
108 IMediaControl_Stop( CFilterGraph_IMediaControl(This) );
109 IMediaFilter_Stop( CFilterGraph_IMediaFilter(This) );
112 while ( FGRAPH_Init[i].pInit != NULL )
114 FGRAPH_Init[i].pUninit( This );
118 TRACE( "succeeded.\n" );
121 HRESULT QUARTZ_CreateFilterGraph(IUnknown* punkOuter,void** ppobj)
127 TRACE("(%p,%p)\n",punkOuter,ppobj);
129 pfg = (CFilterGraph*)QUARTZ_AllocObj( sizeof(CFilterGraph) );
131 return E_OUTOFMEMORY;
133 QUARTZ_IUnkInit( &pfg->unk, punkOuter );
137 while ( FGRAPH_Init[i].pInit != NULL )
139 hr = FGRAPH_Init[i].pInit( pfg );
148 FGRAPH_Init[i].pUninit( pfg );
149 QUARTZ_FreeObj( pfg );
153 pfg->unk.pEntries = IFEntries;
154 pfg->unk.dwEntries = sizeof(IFEntries)/sizeof(IFEntries[0]);
155 pfg->unk.pOnFinalRelease = QUARTZ_DestroyFilterGraph;
157 *ppobj = (void*)(&pfg->unk);
163 /***************************************************************************
165 * CFilterGraph::IPersist
169 static HRESULT WINAPI
170 IPersist_fnQueryInterface(IPersist* iface,REFIID riid,void** ppobj)
172 CFilterGraph_THIS(iface,persist);
174 TRACE("(%p)->()\n",This);
176 return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
180 IPersist_fnAddRef(IPersist* iface)
182 CFilterGraph_THIS(iface,persist);
184 TRACE("(%p)->()\n",This);
186 return IUnknown_AddRef(This->unk.punkControl);
190 IPersist_fnRelease(IPersist* iface)
192 CFilterGraph_THIS(iface,persist);
194 TRACE("(%p)->()\n",This);
196 return IUnknown_Release(This->unk.punkControl);
200 static HRESULT WINAPI
201 IPersist_fnGetClassID(IPersist* iface,CLSID* pclsid)
203 CFilterGraph_THIS(iface,persist);
205 TRACE("(%p)->()\n",This);
207 if ( pclsid == NULL )
209 memcpy( pclsid, &CLSID_FilterGraph, sizeof(CLSID) );
215 static ICOM_VTABLE(IPersist) ipersist =
217 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
218 /* IUnknown fields */
219 IPersist_fnQueryInterface,
222 /* IPersist fields */
223 IPersist_fnGetClassID,
226 HRESULT CFilterGraph_InitIPersist( CFilterGraph* pfg )
229 ICOM_VTBL(&pfg->persist) = &ipersist;
234 void CFilterGraph_UninitIPersist( CFilterGraph* pfg )
239 /***************************************************************************
241 * CFilterGraph::IDispatch
245 static HRESULT WINAPI
246 IDispatch_fnQueryInterface(IDispatch* iface,REFIID riid,void** ppobj)
248 CFilterGraph_THIS(iface,disp);
250 TRACE("(%p)->()\n",This);
252 return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
256 IDispatch_fnAddRef(IDispatch* iface)
258 CFilterGraph_THIS(iface,disp);
260 TRACE("(%p)->()\n",This);
262 return IUnknown_AddRef(This->unk.punkControl);
266 IDispatch_fnRelease(IDispatch* iface)
268 CFilterGraph_THIS(iface,disp);
270 TRACE("(%p)->()\n",This);
272 return IUnknown_Release(This->unk.punkControl);
275 static HRESULT WINAPI
276 IDispatch_fnGetTypeInfoCount(IDispatch* iface,UINT* pcTypeInfo)
278 CFilterGraph_THIS(iface,disp);
280 FIXME("(%p)->()\n",This);
285 static HRESULT WINAPI
286 IDispatch_fnGetTypeInfo(IDispatch* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
288 CFilterGraph_THIS(iface,disp);
290 FIXME("(%p)->()\n",This);
295 static HRESULT WINAPI
296 IDispatch_fnGetIDsOfNames(IDispatch* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
298 CFilterGraph_THIS(iface,disp);
300 FIXME("(%p)->()\n",This);
305 static HRESULT WINAPI
306 IDispatch_fnInvoke(IDispatch* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
308 CFilterGraph_THIS(iface,disp);
310 FIXME("(%p)->()\n",This);
317 static ICOM_VTABLE(IDispatch) idispatch =
319 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
320 /* IUnknown fields */
321 IDispatch_fnQueryInterface,
324 /* IDispatch fields */
325 IDispatch_fnGetTypeInfoCount,
326 IDispatch_fnGetTypeInfo,
327 IDispatch_fnGetIDsOfNames,
332 HRESULT CFilterGraph_InitIDispatch( CFilterGraph* pfg )
335 ICOM_VTBL(&pfg->disp) = &idispatch;
340 void CFilterGraph_UninitIDispatch( CFilterGraph* pfg )
345 /***************************************************************************
347 * CFilterGraph::IAMStats
351 static HRESULT WINAPI
352 IAMStats_fnQueryInterface(IAMStats* iface,REFIID riid,void** ppobj)
354 CFilterGraph_THIS(iface,amstats);
356 TRACE("(%p)->()\n",This);
358 return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
362 IAMStats_fnAddRef(IAMStats* iface)
364 CFilterGraph_THIS(iface,amstats);
366 TRACE("(%p)->()\n",This);
368 return IUnknown_AddRef(This->unk.punkControl);
372 IAMStats_fnRelease(IAMStats* iface)
374 CFilterGraph_THIS(iface,amstats);
376 TRACE("(%p)->()\n",This);
378 return IUnknown_Release(This->unk.punkControl);
381 static HRESULT WINAPI
382 IAMStats_fnGetTypeInfoCount(IAMStats* iface,UINT* pcTypeInfo)
384 CFilterGraph_THIS(iface,amstats);
386 FIXME("(%p)->()\n",This);
391 static HRESULT WINAPI
392 IAMStats_fnGetTypeInfo(IAMStats* iface,UINT iTypeInfo, LCID lcid, ITypeInfo** ppobj)
394 CFilterGraph_THIS(iface,amstats);
396 FIXME("(%p)->()\n",This);
401 static HRESULT WINAPI
402 IAMStats_fnGetIDsOfNames(IAMStats* iface,REFIID riid, LPOLESTR* ppwszName, UINT cNames, LCID lcid, DISPID* pDispId)
404 CFilterGraph_THIS(iface,amstats);
406 FIXME("(%p)->()\n",This);
411 static HRESULT WINAPI
412 IAMStats_fnInvoke(IAMStats* iface,DISPID DispId, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarRes, EXCEPINFO* pExcepInfo, UINT* puArgErr)
414 CFilterGraph_THIS(iface,amstats);
416 FIXME("(%p)->()\n",This);
421 static HRESULT WINAPI
422 IAMStats_fnReset(IAMStats* iface)
424 CFilterGraph_THIS(iface,amstats);
426 FIXME("(%p) stub\n",This);
430 static HRESULT WINAPI
431 IAMStats_fnget_Count(IAMStats* iface,long* plCount)
433 CFilterGraph_THIS(iface,amstats);
435 FIXME("(%p,%p) stub\n",This,plCount);
437 if ( plCount == NULL )
444 static HRESULT WINAPI
445 IAMStats_fnGetValueByIndex(IAMStats* iface,long lIndex,BSTR* pbstrName,long* lCount,double* pdblLast,double* pdblAverage,double* pdblStdDev,double* pdblMin,double* pdblMax)
447 CFilterGraph_THIS(iface,amstats);
449 FIXME("(%p) stub\n",This);
453 static HRESULT WINAPI
454 IAMStats_fnGetValueByName(IAMStats* iface,BSTR bstrName,long* plIndex,long* plCount,double* pdblLast,double* pdblAverage,double* pdblStdDev,double* pdblMin,double* pdblMax)
456 CFilterGraph_THIS(iface,amstats);
458 FIXME("(%p) stub\n",This);
462 static HRESULT WINAPI
463 IAMStats_fnGetIndex(IAMStats* iface,BSTR bstrName,long lCreate,long* plIndex)
465 CFilterGraph_THIS(iface,amstats);
467 FIXME("(%p) stub\n",This);
471 static HRESULT WINAPI
472 IAMStats_fnAddValue(IAMStats* iface,long lIndex,double dValue)
474 CFilterGraph_THIS(iface,amstats);
476 FIXME("(%p) stub\n",This);
481 static ICOM_VTABLE(IAMStats) iamstats =
483 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
484 /* IUnknown fields */
485 IAMStats_fnQueryInterface,
488 /* IDispatch fields */
489 IAMStats_fnGetTypeInfoCount,
490 IAMStats_fnGetTypeInfo,
491 IAMStats_fnGetIDsOfNames,
493 /* IAMStats fields */
495 IAMStats_fnget_Count,
496 IAMStats_fnGetValueByIndex,
497 IAMStats_fnGetValueByName,
502 HRESULT CFilterGraph_InitIAMStats( CFilterGraph* pfg )
505 ICOM_VTBL(&pfg->amstats) = &iamstats;
510 void CFilterGraph_UninitIAMStats( CFilterGraph* pfg )