1 /* Capture Graph Builder, Minimal edition
3 * Copyright 2005 Maarten Lankhorst
4 * Copyright 2005 Rolf Kalbermatter
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
26 #define NONAMELESSSTRUCT
27 #define NONAMELESSUNION
45 #include "qcap_main.h"
47 #include "wine/unicode.h"
48 #include "wine/debug.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(qcap
);
52 /***********************************************************************
53 * ICaptureGraphBuilder & ICaptureGraphBuilder2 implementation
55 typedef struct CaptureGraphImpl
57 const ICaptureGraphBuilder2Vtbl
* lpVtbl2
;
58 const ICaptureGraphBuilderVtbl
* lpVtbl
;
60 IGraphBuilder
*mygraph
;
62 CRITICAL_SECTION csFilter
;
65 static const ICaptureGraphBuilderVtbl builder_Vtbl
;
66 static const ICaptureGraphBuilder2Vtbl builder2_Vtbl
;
68 #define _ICaptureGraphBuilder_Offset ((int)(&(((CaptureGraphImpl*)0)->lpVtbl)))
69 #define _ICOM_THIS_From_ICaptureGraphBuilder(class, name) class* This = (class*)(((char*)name)-_ICaptureGraphBuilder_Offset)
71 #define _ICaptureGraphBuilder2_Offset ((int)(&(((CaptureGraphImpl*)0)->lpVtbl2)))
72 #define _ICOM_THIS_From_ICaptureGraphBuilder2(class, name) class* This = (class*)(((char*)name)-_ICaptureGraphBuilder2_Offset)
75 converts This to an interface pointer
77 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl2)
78 #define _ICaptureGraphBuilder_(This) (ICaptureGraphBuilder*)&(This->lpVtbl)
79 #define _ICaptureGraphBuilder2_(This) (ICaptureGraphBuilder2*)&(This->lpVtbl2)
82 IUnknown
* CALLBACK
QCAP_createCaptureGraphBuilder2(IUnknown
*pUnkOuter
,
85 CaptureGraphImpl
* pCapture
= NULL
;
87 TRACE("(%p, %p)\n", pUnkOuter
, phr
);
89 *phr
= CLASS_E_NOAGGREGATION
;
96 pCapture
= CoTaskMemAlloc(sizeof(CaptureGraphImpl
));
99 pCapture
->lpVtbl2
= &builder2_Vtbl
;
100 pCapture
->lpVtbl
= &builder_Vtbl
;
102 pCapture
->mygraph
= NULL
;
103 InitializeCriticalSection(&pCapture
->csFilter
);
105 ObjectRefCount(TRUE
);
107 return (IUnknown
*)pCapture
;
110 static HRESULT WINAPI
111 fnCaptureGraphBuilder2_QueryInterface(ICaptureGraphBuilder2
* iface
,
115 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
117 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, debugstr_guid(riid
), ppv
);
120 if (IsEqualIID(riid
, &IID_IUnknown
))
121 *ppv
= _IUnknown_(This
);
122 else if (IsEqualIID(riid
, &IID_ICaptureGraphBuilder
))
123 *ppv
= _ICaptureGraphBuilder_(This
);
124 else if (IsEqualIID(riid
, &IID_ICaptureGraphBuilder2
))
125 *ppv
= _ICaptureGraphBuilder2_(This
);
129 IUnknown_AddRef((IUnknown
*)(*ppv
));
130 TRACE ("-- Interface = %p\n", *ppv
);
134 TRACE ("-- Interface: E_NOINTERFACE\n");
135 return E_NOINTERFACE
;
139 fnCaptureGraphBuilder2_AddRef(ICaptureGraphBuilder2
* iface
)
141 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
142 DWORD ref
= InterlockedIncrement(&This
->ref
);
144 TRACE("(%p/%p)->() AddRef from %ld\n", This
, iface
, ref
- 1);
149 fnCaptureGraphBuilder2_Release(ICaptureGraphBuilder2
* iface
)
151 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
152 DWORD ref
= InterlockedDecrement(&This
->ref
);
154 TRACE("(%p/%p)->() Release from %ld\n", This
, iface
, ref
+ 1);
158 FIXME("Release IGraphFilter or w/e\n");
159 DeleteCriticalSection(&This
->csFilter
);
161 This
->lpVtbl2
= NULL
;
162 if (This
->mygraph
!= NULL
)
163 IGraphBuilder_Release((IGraphBuilder
*)This
->mygraph
);
165 ObjectRefCount(FALSE
);
170 static HRESULT WINAPI
171 fnCaptureGraphBuilder2_SetFilterGraph(ICaptureGraphBuilder2
* iface
,
174 /* The graph builder will automatically create a filter graph if you don't call
175 this method. If you call this method after the graph builder has created its
176 own filter graph, the call will fail. */
178 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
180 TRACE("(%p/%p)->(%p)\n", This
, iface
, pfg
);
189 IGraphBuilder_AddRef((IGraphBuilder
*)This
->mygraph
);
190 if (SUCCEEDED(IUnknown_QueryInterface(This
->mygraph
,
191 &IID_IMediaEvent
, (LPVOID
*)&pmev
)))
193 IMediaEvent_CancelDefaultHandling(pmev
, EC_REPAINT
);
194 IMediaEvent_Release(pmev
);
199 static HRESULT WINAPI
200 fnCaptureGraphBuilder2_GetFilterGraph(ICaptureGraphBuilder2
* iface
,
203 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
205 TRACE("(%p/%p)->(%p)\n", This
, iface
, pfg
);
210 *pfg
= This
->mygraph
;
213 TRACE("(%p) Getting NULL filtergraph\n", iface
);
217 IGraphBuilder_AddRef((IGraphBuilder
*)This
->mygraph
);
219 TRACE("(%p) return filtergraph %p\n", iface
, *pfg
);
223 static HRESULT WINAPI
224 fnCaptureGraphBuilder2_SetOutputFileName(ICaptureGraphBuilder2
* iface
,
228 IFileSinkFilter
**ppSink
)
230 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
232 FIXME("(%p/%p)->(%s, %s, %p, %p) Stub!\n", This
, iface
,
233 debugstr_guid(pType
), debugstr_w(lpstrFile
), ppf
, ppSink
);
238 static HRESULT WINAPI
239 fnCaptureGraphBuilder2_FindInterface(ICaptureGraphBuilder2
* iface
,
240 const GUID
*pCategory
,
246 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
248 FIXME("(%p/%p)->(%s, %s, %p, %s, %p) - workaround stub!\n", This
, iface
,
249 debugstr_guid(pCategory
), debugstr_guid(pType
),
250 pf
, debugstr_guid(riid
), ppint
);
252 return IBaseFilter_QueryInterface(pf
, riid
, ppint
);
253 /* Looks for the specified interface on the filter, upstream and
254 * downstream from the filter, and, optionally, only on the output
255 * pin of the given category.
259 static HRESULT WINAPI
260 fnCaptureGraphBuilder2_RenderStream(ICaptureGraphBuilder2
* iface
,
261 const GUID
*pCategory
,
264 IBaseFilter
*pfCompressor
,
265 IBaseFilter
*pfRenderer
)
267 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
269 FIXME("(%p/%p)->(%s, %s, %p, %p, %p) Stub!\n", This
, iface
,
270 debugstr_guid(pCategory
), debugstr_guid(pType
),
271 pSource
, pfCompressor
, pfRenderer
);
276 static HRESULT WINAPI
277 fnCaptureGraphBuilder2_ControlStream(ICaptureGraphBuilder2
* iface
,
278 const GUID
*pCategory
,
280 IBaseFilter
*pFilter
,
281 REFERENCE_TIME
*pstart
,
282 REFERENCE_TIME
*pstop
,
286 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
288 FIXME("(%p/%p)->(%s, %s, %p, %p, %p, %i, %i) Stub!\n", This
, iface
,
289 debugstr_guid(pCategory
), debugstr_guid(pType
),
290 pFilter
, pstart
, pstop
, wStartCookie
, wStopCookie
);
295 static HRESULT WINAPI
296 fnCaptureGraphBuilder2_AllocCapFile(ICaptureGraphBuilder2
* iface
,
300 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
302 FIXME("(%p/%p)->(%s, %lld) Stub!\n", This
, iface
,
303 debugstr_w(lpwstr
), dwlSize
);
308 static HRESULT WINAPI
309 fnCaptureGraphBuilder2_CopyCaptureFile(ICaptureGraphBuilder2
* iface
,
313 IAMCopyCaptureFileProgress
*pCallback
)
315 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
317 FIXME("(%p/%p)->(%s, %s, %i, %p) Stub!\n", This
, iface
,
318 debugstr_w(lpwstrOld
), debugstr_w(lpwstrNew
),
319 fAllowEscAbort
, pCallback
);
324 static HRESULT WINAPI
325 fnCaptureGraphBuilder2_FindPin(ICaptureGraphBuilder2
* iface
,
327 PIN_DIRECTION pindir
,
328 const GUID
*pCategory
,
334 _ICOM_THIS_From_ICaptureGraphBuilder2(CaptureGraphImpl
, iface
);
336 FIXME("(%p/%p)->(%p, %x, %s, %s, %d, %i, %p) Stub!\n", This
, iface
,
337 pSource
, pindir
, debugstr_guid(pCategory
), debugstr_guid(pType
),
338 fUnconnected
, num
, ppPin
);
343 static const ICaptureGraphBuilder2Vtbl builder2_Vtbl
=
345 fnCaptureGraphBuilder2_QueryInterface
,
346 fnCaptureGraphBuilder2_AddRef
,
347 fnCaptureGraphBuilder2_Release
,
348 fnCaptureGraphBuilder2_SetFilterGraph
,
349 fnCaptureGraphBuilder2_GetFilterGraph
,
350 fnCaptureGraphBuilder2_SetOutputFileName
,
351 fnCaptureGraphBuilder2_FindInterface
,
352 fnCaptureGraphBuilder2_RenderStream
,
353 fnCaptureGraphBuilder2_ControlStream
,
354 fnCaptureGraphBuilder2_AllocCapFile
,
355 fnCaptureGraphBuilder2_CopyCaptureFile
,
356 fnCaptureGraphBuilder2_FindPin
360 static HRESULT WINAPI
361 fnCaptureGraphBuilder_QueryInterface(ICaptureGraphBuilder
* iface
,
362 REFIID riid
, LPVOID
* ppv
)
364 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
365 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
366 return IUnknown_QueryInterface(_ICaptureGraphBuilder2_(This
), riid
, ppv
);
370 fnCaptureGraphBuilder_AddRef(ICaptureGraphBuilder
* iface
)
372 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
373 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
374 return IUnknown_AddRef(_ICaptureGraphBuilder2_(This
));
378 fnCaptureGraphBuilder_Release(ICaptureGraphBuilder
* iface
)
380 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
381 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
382 return IUnknown_Release(_ICaptureGraphBuilder2_(This
));
385 static HRESULT WINAPI
386 fnCaptureGraphBuilder_SetFiltergraph(ICaptureGraphBuilder
* iface
,
389 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
390 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
391 return ICaptureGraphBuilder2_SetFiltergraph(_ICaptureGraphBuilder2_(This
), pfg
);
394 static HRESULT WINAPI
395 fnCaptureGraphBuilder_GetFiltergraph(ICaptureGraphBuilder
* iface
,
398 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
399 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
400 return ICaptureGraphBuilder2_GetFiltergraph(_ICaptureGraphBuilder2_(This
), pfg
);
403 static HRESULT WINAPI
404 fnCaptureGraphBuilder_SetOutputFileName(ICaptureGraphBuilder
* iface
,
405 const GUID
*pType
, LPCOLESTR lpstrFile
,
406 IBaseFilter
**ppf
, IFileSinkFilter
**ppSink
)
408 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
409 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
410 return ICaptureGraphBuilder2_SetOutputFileName(_ICaptureGraphBuilder2_(This
),
411 pType
, lpstrFile
, ppf
, ppSink
);
414 static HRESULT WINAPI
415 fnCaptureGraphBuilder_FindInterface(ICaptureGraphBuilder
* iface
,
416 const GUID
*pCategory
, IBaseFilter
*pf
,
417 REFIID riid
, void **ppint
)
419 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
420 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
421 return ICaptureGraphBuilder2_FindInterface(_ICaptureGraphBuilder2_(This
),
422 pCategory
, NULL
, pf
, riid
, ppint
);
425 static HRESULT WINAPI
426 fnCaptureGraphBuilder_RenderStream(ICaptureGraphBuilder
* iface
,
427 const GUID
*pCategory
, IUnknown
*pSource
,
428 IBaseFilter
*pfCompressor
, IBaseFilter
*pfRenderer
)
430 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
431 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
432 return ICaptureGraphBuilder2_RenderStream(_ICaptureGraphBuilder2_(This
),
433 pCategory
, NULL
, pSource
,
434 pfCompressor
, pfRenderer
);
437 static HRESULT WINAPI
438 fnCaptureGraphBuilder_ControlStream(ICaptureGraphBuilder
* iface
,
439 const GUID
*pCategory
, IBaseFilter
*pFilter
,
440 REFERENCE_TIME
*pstart
, REFERENCE_TIME
*pstop
,
441 WORD wStartCookie
, WORD wStopCookie
)
443 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
444 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
445 return ICaptureGraphBuilder2_ControlStream(_ICaptureGraphBuilder2_(This
),
446 pCategory
, NULL
, pFilter
, pstart
,
447 pstop
, wStartCookie
, wStopCookie
);
450 static HRESULT WINAPI
451 fnCaptureGraphBuilder_AllocCapFile(ICaptureGraphBuilder
* iface
,
452 LPCOLESTR lpstr
, DWORDLONG dwlSize
)
454 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
455 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
456 return ICaptureGraphBuilder2_AllocCapFile(_ICaptureGraphBuilder2_(This
),
460 static HRESULT WINAPI
461 fnCaptureGraphBuilder_CopyCaptureFile(ICaptureGraphBuilder
* iface
,
462 LPOLESTR lpwstrOld
, LPOLESTR lpwstrNew
,
464 IAMCopyCaptureFileProgress
*pCallback
)
466 _ICOM_THIS_From_ICaptureGraphBuilder(CaptureGraphImpl
, iface
);
467 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
468 return ICaptureGraphBuilder2_CopyCaptureFile(_ICaptureGraphBuilder2_(This
),
469 lpwstrOld
, lpwstrNew
,
470 fAllowEscAbort
, pCallback
);
473 static const ICaptureGraphBuilderVtbl builder_Vtbl
=
475 fnCaptureGraphBuilder_QueryInterface
,
476 fnCaptureGraphBuilder_AddRef
,
477 fnCaptureGraphBuilder_Release
,
478 fnCaptureGraphBuilder_SetFiltergraph
,
479 fnCaptureGraphBuilder_GetFiltergraph
,
480 fnCaptureGraphBuilder_SetOutputFileName
,
481 fnCaptureGraphBuilder_FindInterface
,
482 fnCaptureGraphBuilder_RenderStream
,
483 fnCaptureGraphBuilder_ControlStream
,
484 fnCaptureGraphBuilder_AllocCapFile
,
485 fnCaptureGraphBuilder_CopyCaptureFile