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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "qcap_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
25 /***********************************************************************
26 * ICaptureGraphBuilder & ICaptureGraphBuilder2 implementation
28 typedef struct CaptureGraphImpl
30 ICaptureGraphBuilder2 ICaptureGraphBuilder2_iface
;
31 ICaptureGraphBuilder ICaptureGraphBuilder_iface
;
33 IGraphBuilder
*mygraph
;
34 CRITICAL_SECTION csFilter
;
37 static const ICaptureGraphBuilderVtbl builder_Vtbl
;
38 static const ICaptureGraphBuilder2Vtbl builder2_Vtbl
;
40 static inline CaptureGraphImpl
*impl_from_ICaptureGraphBuilder(ICaptureGraphBuilder
*iface
)
42 return CONTAINING_RECORD(iface
, CaptureGraphImpl
, ICaptureGraphBuilder_iface
);
45 static inline CaptureGraphImpl
*impl_from_ICaptureGraphBuilder2(ICaptureGraphBuilder2
*iface
)
47 return CONTAINING_RECORD(iface
, CaptureGraphImpl
, ICaptureGraphBuilder2_iface
);
51 HRESULT
capture_graph_create(IUnknown
*outer
, IUnknown
**out
)
53 CaptureGraphImpl
*object
;
56 return CLASS_E_NOAGGREGATION
;
58 if (!(object
= calloc(1, sizeof(*object
))))
61 object
->ICaptureGraphBuilder2_iface
.lpVtbl
= &builder2_Vtbl
;
62 object
->ICaptureGraphBuilder_iface
.lpVtbl
= &builder_Vtbl
;
64 object
->mygraph
= NULL
;
65 InitializeCriticalSection(&object
->csFilter
);
66 object
->csFilter
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": CaptureGraphImpl.csFilter");
68 TRACE("Created capture graph builder %p.\n", object
);
70 *out
= (IUnknown
*)&object
->ICaptureGraphBuilder_iface
;
75 fnCaptureGraphBuilder2_QueryInterface(ICaptureGraphBuilder2
* iface
,
79 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
81 TRACE("(%p/%p)->(%s, %p)\n", This
, iface
, debugstr_guid(riid
), ppv
);
84 if (IsEqualIID(riid
, &IID_IUnknown
))
85 *ppv
= &This
->ICaptureGraphBuilder2_iface
;
86 else if (IsEqualIID(riid
, &IID_ICaptureGraphBuilder
))
87 *ppv
= &This
->ICaptureGraphBuilder_iface
;
88 else if (IsEqualIID(riid
, &IID_ICaptureGraphBuilder2
))
89 *ppv
= &This
->ICaptureGraphBuilder2_iface
;
93 IUnknown_AddRef((IUnknown
*)(*ppv
));
94 TRACE ("-- Interface = %p\n", *ppv
);
98 TRACE ("-- Interface: E_NOINTERFACE\n");
103 fnCaptureGraphBuilder2_AddRef(ICaptureGraphBuilder2
* iface
)
105 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
106 DWORD ref
= InterlockedIncrement(&This
->ref
);
108 TRACE("(%p/%p)->() AddRef from %d\n", This
, iface
, ref
- 1);
112 static ULONG WINAPI
fnCaptureGraphBuilder2_Release(ICaptureGraphBuilder2
* iface
)
114 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
115 DWORD ref
= InterlockedDecrement(&This
->ref
);
117 TRACE("(%p/%p)->() Release from %d\n", This
, iface
, ref
+ 1);
121 This
->csFilter
.DebugInfo
->Spare
[0] = 0;
122 DeleteCriticalSection(&This
->csFilter
);
124 IGraphBuilder_Release(This
->mygraph
);
126 ObjectRefCount(FALSE
);
131 static HRESULT WINAPI
132 fnCaptureGraphBuilder2_SetFilterGraph(ICaptureGraphBuilder2
* iface
,
135 /* The graph builder will automatically create a filter graph if you don't call
136 this method. If you call this method after the graph builder has created its
137 own filter graph, the call will fail. */
139 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
141 TRACE("(%p/%p)->(%p)\n", This
, iface
, pfg
);
150 IGraphBuilder_AddRef(This
->mygraph
);
151 if (SUCCEEDED(IGraphBuilder_QueryInterface(This
->mygraph
,
152 &IID_IMediaEvent
, (LPVOID
*)&pmev
)))
154 IMediaEvent_CancelDefaultHandling(pmev
, EC_REPAINT
);
155 IMediaEvent_Release(pmev
);
160 static HRESULT WINAPI
161 fnCaptureGraphBuilder2_GetFilterGraph(ICaptureGraphBuilder2
* iface
,
164 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
166 TRACE("(%p/%p)->(%p)\n", This
, iface
, pfg
);
171 *pfg
= This
->mygraph
;
174 TRACE("(%p) Getting NULL filtergraph\n", iface
);
178 IGraphBuilder_AddRef(This
->mygraph
);
180 TRACE("(%p) return filtergraph %p\n", iface
, *pfg
);
184 static HRESULT WINAPI
185 fnCaptureGraphBuilder2_SetOutputFileName(ICaptureGraphBuilder2
* iface
,
189 IFileSinkFilter
**ppSink
)
191 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
193 FIXME("(%p/%p)->(%s, %s, %p, %p) Stub!\n", This
, iface
,
194 debugstr_guid(pType
), debugstr_w(lpstrFile
), ppf
, ppSink
);
199 static BOOL
pin_has_majortype(IPin
*pin
, const GUID
*majortype
)
201 IEnumMediaTypes
*enummt
;
204 if (FAILED(IPin_EnumMediaTypes(pin
, &enummt
)))
207 while (IEnumMediaTypes_Next(enummt
, 1, &mt
, NULL
) == S_OK
)
209 if (IsEqualGUID(&mt
->majortype
, majortype
))
212 IEnumMediaTypes_Release(enummt
);
217 IEnumMediaTypes_Release(enummt
);
221 static BOOL
pin_matches(IPin
*pin
, PIN_DIRECTION dir
, const GUID
*category
,
222 const GUID
*majortype
, BOOL unconnected
)
224 PIN_DIRECTION candidate_dir
;
228 if (FAILED(hr
= IPin_QueryDirection(pin
, &candidate_dir
)))
229 ERR("Failed to query direction, hr %#x.\n", hr
);
231 if (dir
!= candidate_dir
)
234 if (unconnected
&& IPin_ConnectedTo(pin
, &peer
) == S_OK
&& peer
)
246 if (FAILED(IPin_QueryInterface(pin
, &IID_IKsPropertySet
, (void **)&set
)))
249 hr
= IKsPropertySet_Get(set
, &ROPSETID_Pin
, AMPROPERTY_PIN_CATEGORY
,
250 NULL
, 0, &property
, sizeof(property
), &size
);
251 IKsPropertySet_Release(set
);
252 if (FAILED(hr
) || !IsEqualGUID(&property
, category
))
256 if (majortype
&& !pin_has_majortype(pin
, majortype
))
262 static HRESULT
find_interface_recurse(PIN_DIRECTION dir
, const GUID
*category
,
263 const GUID
*majortype
, IBaseFilter
*filter
, REFIID iid
, void **out
)
265 BOOL found_category
= FALSE
;
271 TRACE("Looking for %s pins, category %s, majortype %s from filter %p.\n",
272 dir
== PINDIR_INPUT
? "sink" : "source", debugstr_guid(category
),
273 debugstr_guid(majortype
), filter
);
275 if (FAILED(hr
= IBaseFilter_EnumPins(filter
, &enumpins
)))
277 ERR("Failed to enumerate pins, hr %#x.\n", hr
);
281 while (IEnumPins_Next(enumpins
, 1, &pin
, NULL
) == S_OK
)
283 if (!pin_matches(pin
, dir
, category
, majortype
, FALSE
))
290 found_category
= TRUE
;
292 if (IPin_QueryInterface(pin
, iid
, out
) == S_OK
)
295 IEnumPins_Release(enumpins
);
299 hr
= IPin_ConnectedTo(pin
, &peer
);
303 if (IPin_QueryInterface(peer
, iid
, out
) == S_OK
)
306 IEnumPins_Release(enumpins
);
310 IPin_QueryPinInfo(peer
, &info
);
313 if (IBaseFilter_QueryInterface(info
.pFilter
, iid
, out
) == S_OK
)
315 IBaseFilter_Release(info
.pFilter
);
316 IEnumPins_Release(enumpins
);
320 hr
= find_interface_recurse(dir
, NULL
, NULL
, info
.pFilter
, iid
, out
);
321 IBaseFilter_Release(info
.pFilter
);
324 IEnumPins_Release(enumpins
);
329 IEnumPins_Release(enumpins
);
331 if (category
&& !found_category
)
332 return E_NOINTERFACE
;
337 static HRESULT WINAPI
fnCaptureGraphBuilder2_FindInterface(ICaptureGraphBuilder2
*iface
,
338 const GUID
*category
, const GUID
*majortype
, IBaseFilter
*filter
, REFIID iid
, void **out
)
340 CaptureGraphImpl
*graph
= impl_from_ICaptureGraphBuilder2(iface
);
343 TRACE("graph %p, category %s, majortype %s, filter %p, iid %s, out %p.\n",
344 graph
, debugstr_guid(category
), debugstr_guid(majortype
), filter
, debugstr_guid(iid
), out
);
349 if (category
&& IsEqualGUID(category
, &LOOK_DOWNSTREAM_ONLY
))
350 return find_interface_recurse(PINDIR_OUTPUT
, NULL
, NULL
, filter
, iid
, out
);
352 if (category
&& IsEqualGUID(category
, &LOOK_UPSTREAM_ONLY
))
353 return find_interface_recurse(PINDIR_INPUT
, NULL
, NULL
, filter
, iid
, out
);
355 if (IBaseFilter_QueryInterface(filter
, iid
, out
) == S_OK
)
361 hr
= find_interface_recurse(PINDIR_OUTPUT
, category
, majortype
, filter
, iid
, out
);
362 if (hr
== S_OK
|| hr
== E_NOINTERFACE
)
365 return find_interface_recurse(PINDIR_INPUT
, NULL
, NULL
, filter
, iid
, out
);
368 static HRESULT
match_smart_tee_pin(CaptureGraphImpl
*This
,
369 const GUID
*pCategory
,
374 IPin
*capture
= NULL
;
375 IPin
*preview
= NULL
;
377 IBaseFilter
*smartTee
= NULL
;
378 BOOL needSmartTee
= FALSE
;
381 TRACE("(%p, %s, %s, %p, %p)\n", This
, debugstr_guid(pCategory
), debugstr_guid(pType
), pSource
, source_out
);
382 hr
= ICaptureGraphBuilder2_FindPin(&This
->ICaptureGraphBuilder2_iface
, pSource
,
383 PINDIR_OUTPUT
, &PIN_CATEGORY_CAPTURE
, pType
, FALSE
, 0, &capture
);
385 hr
= ICaptureGraphBuilder2_FindPin(&This
->ICaptureGraphBuilder2_iface
, pSource
,
386 PINDIR_OUTPUT
, &PIN_CATEGORY_PREVIEW
, pType
, FALSE
, 0, &preview
);
394 if (IsEqualIID(pCategory
, &PIN_CATEGORY_CAPTURE
)) {
395 hr
= IPin_ConnectedTo(capture
, &peer
);
396 if (hr
== VFW_E_NOT_CONNECTED
) {
397 *source_out
= capture
;
398 IPin_AddRef(*source_out
);
403 hr
= IPin_ConnectedTo(preview
, &peer
);
404 if (hr
== VFW_E_NOT_CONNECTED
) {
405 *source_out
= preview
;
406 IPin_AddRef(*source_out
);
413 hr
= IPin_ConnectedTo(capture
, &peer
);
417 hr
= IPin_QueryPinInfo(peer
, &pinInfo
);
419 hr
= IBaseFilter_GetClassID(pinInfo
.pFilter
, &classID
);
421 if (IsEqualIID(&classID
, &CLSID_SmartTee
)) {
422 smartTee
= pinInfo
.pFilter
;
423 IBaseFilter_AddRef(smartTee
);
426 IBaseFilter_Release(pinInfo
.pFilter
);
432 } else if (hr
== VFW_E_NOT_CONNECTED
) {
433 hr
= CoCreateInstance(&CLSID_SmartTee
, NULL
, CLSCTX_INPROC_SERVER
,
434 &IID_IBaseFilter
, (LPVOID
*)&smartTee
);
436 hr
= IGraphBuilder_AddFilter(This
->mygraph
, smartTee
, NULL
);
438 IPin
*smartTeeInput
= NULL
;
439 hr
= IBaseFilter_FindPin(smartTee
, L
"Input", &smartTeeInput
);
441 hr
= IGraphBuilder_ConnectDirect(This
->mygraph
, capture
, smartTeeInput
, NULL
);
442 IPin_Release(smartTeeInput
);
447 TRACE("adding SmartTee failed with hr=0x%08x\n", hr
);
455 if (IsEqualIID(pCategory
, &PIN_CATEGORY_CAPTURE
))
456 hr
= IBaseFilter_FindPin(smartTee
, L
"Capture", source_out
);
458 hr
= IBaseFilter_FindPin(smartTee
, L
"Preview", source_out
);
460 hr
= VFW_S_NOPREVIEWPIN
;
465 IPin_Release(capture
);
467 IPin_Release(preview
);
471 IBaseFilter_Release(smartTee
);
472 TRACE("for %s returning hr=0x%08x, *source_out=%p\n", IsEqualIID(pCategory
, &PIN_CATEGORY_CAPTURE
) ? "capture" : "preview", hr
, source_out
? *source_out
: 0);
476 static HRESULT
find_unconnected_source_from_filter(CaptureGraphImpl
*capture_graph
,
477 const GUID
*category
, const GUID
*majortype
, IBaseFilter
*filter
, IPin
**ret
);
479 static HRESULT
find_unconnected_source_from_pin(CaptureGraphImpl
*capture_graph
,
480 const GUID
*category
, const GUID
*majortype
, IPin
*pin
, IPin
**ret
)
487 IPin_QueryDirection(pin
, &dir
);
488 if (dir
!= PINDIR_OUTPUT
)
489 return VFW_E_INVALID_DIRECTION
;
491 if (category
&& (IsEqualGUID(category
, &PIN_CATEGORY_CAPTURE
)
492 || IsEqualGUID(category
, &PIN_CATEGORY_PREVIEW
)))
494 if (FAILED(hr
= match_smart_tee_pin(capture_graph
, category
, majortype
, (IUnknown
*)pin
, &pin
)))
497 if (FAILED(IPin_ConnectedTo(pin
, &peer
)))
505 if (FAILED(IPin_ConnectedTo(pin
, &peer
)))
507 if (!pin_matches(pin
, PINDIR_OUTPUT
, category
, majortype
, FALSE
))
510 IPin_AddRef(*ret
= pin
);
516 IPin_QueryPinInfo(peer
, &info
);
517 hr
= find_unconnected_source_from_filter(capture_graph
, category
, majortype
, info
.pFilter
, ret
);
518 IBaseFilter_Release(info
.pFilter
);
524 static HRESULT
find_unconnected_source_from_filter(CaptureGraphImpl
*capture_graph
,
525 const GUID
*category
, const GUID
*majortype
, IBaseFilter
*filter
, IPin
**ret
)
531 if (category
&& (IsEqualGUID(category
, &PIN_CATEGORY_CAPTURE
)
532 || IsEqualGUID(category
, &PIN_CATEGORY_PREVIEW
)))
534 if (FAILED(hr
= match_smart_tee_pin(capture_graph
, category
, majortype
, (IUnknown
*)filter
, &pin
)))
537 if (FAILED(IPin_ConnectedTo(pin
, &peer
)))
548 if (FAILED(hr
= IBaseFilter_EnumPins(filter
, &enumpins
)))
551 while (IEnumPins_Next(enumpins
, 1, &pin
, NULL
) == S_OK
)
553 if (SUCCEEDED(hr
= find_unconnected_source_from_pin(capture_graph
, category
, majortype
, pin
, ret
)))
555 IEnumPins_Release(enumpins
);
561 IEnumPins_Release(enumpins
);
566 static HRESULT WINAPI
fnCaptureGraphBuilder2_RenderStream(ICaptureGraphBuilder2
*iface
,
567 const GUID
*category
, const GUID
*majortype
, IUnknown
*source
,
568 IBaseFilter
*pfCompressor
, IBaseFilter
*pfRenderer
)
570 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
571 IPin
*source_out
= NULL
, *renderer_in
;
572 BOOL rendererNeedsRelease
= FALSE
;
573 HRESULT hr
, return_hr
= S_OK
;
577 TRACE("graph %p, category %s, majortype %s, source %p, intermediate %p, sink %p.\n",
578 This
, debugstr_guid(category
), debugstr_guid(majortype
), source
, pfCompressor
, pfRenderer
);
582 FIXME("Need a capture graph\n");
586 if (category
&& IsEqualGUID(category
, &PIN_CATEGORY_VBI
))
588 FIXME("Tee/Sink-to-Sink filter not supported\n");
592 if (IUnknown_QueryInterface(source
, &IID_IPin
, (void **)&pin
) == S_OK
)
594 hr
= find_unconnected_source_from_pin(This
, category
, majortype
, pin
, &source_out
);
597 else if (IUnknown_QueryInterface(source
, &IID_IBaseFilter
, (void **)&filter
) == S_OK
)
599 hr
= find_unconnected_source_from_filter(This
, category
, majortype
, filter
, &source_out
);
600 IBaseFilter_Release(filter
);
604 WARN("Source object does not expose IBaseFilter or IPin.\n");
613 IEnumMediaTypes
*enumMedia
= NULL
;
614 hr
= IPin_EnumMediaTypes(source_out
, &enumMedia
);
616 AM_MEDIA_TYPE
*mediaType
;
617 hr
= IEnumMediaTypes_Next(enumMedia
, 1, &mediaType
, NULL
);
619 if (IsEqualIID(&mediaType
->majortype
, &MEDIATYPE_Video
)) {
620 hr
= CoCreateInstance(&CLSID_VideoRenderer
, NULL
, CLSCTX_INPROC_SERVER
,
621 &IID_IBaseFilter
, (void**)&pfRenderer
);
622 } else if (IsEqualIID(&mediaType
->majortype
, &MEDIATYPE_Audio
)) {
623 hr
= CoCreateInstance(&CLSID_DSoundRender
, NULL
, CLSCTX_INPROC_SERVER
,
624 &IID_IBaseFilter
, (void**)&pfRenderer
);
626 FIXME("cannot automatically load renderer for majortype %s\n", debugstr_guid(&mediaType
->majortype
));
630 rendererNeedsRelease
= TRUE
;
631 hr
= IGraphBuilder_AddFilter(This
->mygraph
, pfRenderer
, NULL
);
633 DeleteMediaType(mediaType
);
635 IEnumMediaTypes_Release(enumMedia
);
638 if (rendererNeedsRelease
)
639 IBaseFilter_Release(pfRenderer
);
640 IPin_Release(source_out
);
645 hr
= ICaptureGraphBuilder2_FindPin(iface
, (IUnknown
*)pfRenderer
, PINDIR_INPUT
, NULL
, NULL
, TRUE
, 0, &renderer_in
);
648 if (rendererNeedsRelease
)
649 IBaseFilter_Release(pfRenderer
);
650 IPin_Release(source_out
);
655 hr
= IGraphBuilder_Connect(This
->mygraph
, source_out
, renderer_in
);
658 IPin
*compressor_in
, *compressor_out
;
660 hr
= ICaptureGraphBuilder2_FindPin(iface
, (IUnknown
*)pfCompressor
,
661 PINDIR_INPUT
, NULL
, NULL
, TRUE
, 0, &compressor_in
);
664 hr
= IGraphBuilder_Connect(This
->mygraph
, source_out
, compressor_in
);
665 IPin_Release(compressor_in
);
670 hr
= ICaptureGraphBuilder2_FindPin(iface
, (IUnknown
*)pfCompressor
,
671 PINDIR_OUTPUT
, NULL
, NULL
, TRUE
, 0, &compressor_out
);
674 hr
= IGraphBuilder_Connect(This
->mygraph
, compressor_out
, renderer_in
);
675 IPin_Release(compressor_out
);
680 IPin_Release(source_out
);
681 IPin_Release(renderer_in
);
682 if (rendererNeedsRelease
)
683 IBaseFilter_Release(pfRenderer
);
689 static HRESULT WINAPI
690 fnCaptureGraphBuilder2_ControlStream(ICaptureGraphBuilder2
* iface
,
691 const GUID
*pCategory
,
693 IBaseFilter
*pFilter
,
694 REFERENCE_TIME
*pstart
,
695 REFERENCE_TIME
*pstop
,
699 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
701 FIXME("(%p/%p)->(%s, %s, %p, %p, %p, %i, %i) Stub!\n", This
, iface
,
702 debugstr_guid(pCategory
), debugstr_guid(pType
),
703 pFilter
, pstart
, pstop
, wStartCookie
, wStopCookie
);
708 static HRESULT WINAPI
709 fnCaptureGraphBuilder2_AllocCapFile(ICaptureGraphBuilder2
* iface
,
713 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
715 FIXME("(%p/%p)->(%s, 0x%s) Stub!\n", This
, iface
,
716 debugstr_w(lpwstr
), wine_dbgstr_longlong(dwlSize
));
721 static HRESULT WINAPI
722 fnCaptureGraphBuilder2_CopyCaptureFile(ICaptureGraphBuilder2
* iface
,
726 IAMCopyCaptureFileProgress
*pCallback
)
728 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
730 FIXME("(%p/%p)->(%s, %s, %i, %p) Stub!\n", This
, iface
,
731 debugstr_w(lpwstrOld
), debugstr_w(lpwstrNew
),
732 fAllowEscAbort
, pCallback
);
737 static HRESULT WINAPI
738 fnCaptureGraphBuilder2_FindPin(ICaptureGraphBuilder2
* iface
,
740 PIN_DIRECTION pindir
,
741 const GUID
*pCategory
,
748 IEnumPins
*enumpins
= NULL
;
750 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder2(iface
);
752 TRACE("(%p/%p)->(%p, %x, %s, %s, %d, %i, %p)\n", This
, iface
,
753 pSource
, pindir
, debugstr_guid(pCategory
), debugstr_guid(pType
),
754 fUnconnected
, num
, ppPin
);
758 hr
= IUnknown_QueryInterface(pSource
, &IID_IPin
, (void**)&pin
);
759 if (hr
== E_NOINTERFACE
)
761 IBaseFilter
*filter
= NULL
;
764 hr
= IUnknown_QueryInterface(pSource
, &IID_IBaseFilter
, (void**)&filter
);
765 if (hr
== E_NOINTERFACE
)
767 WARN("Input not filter or pin?!\n");
768 return E_NOINTERFACE
;
771 hr
= IBaseFilter_EnumPins(filter
, &enumpins
);
774 WARN("Could not enumerate\n");
775 IBaseFilter_Release(filter
);
783 hr
= IEnumPins_Next(enumpins
, 1, &pin
, &fetched
);
784 if (hr
== VFW_E_ENUM_OUT_OF_SYNC
)
787 IEnumPins_Reset(enumpins
);
799 TRACE("Testing match\n");
800 if (pin_matches(pin
, pindir
, pCategory
, pType
, fUnconnected
) && numcurrent
++ == num
)
805 IEnumPins_Release(enumpins
);
806 IBaseFilter_Release(filter
);
810 WARN("Could not find %s pin # %d\n", (pindir
== PINDIR_OUTPUT
? "output" : "input"), numcurrent
);
814 else if (!pin_matches(pin
, pindir
, pCategory
, pType
, fUnconnected
))
824 static const ICaptureGraphBuilder2Vtbl builder2_Vtbl
=
826 fnCaptureGraphBuilder2_QueryInterface
,
827 fnCaptureGraphBuilder2_AddRef
,
828 fnCaptureGraphBuilder2_Release
,
829 fnCaptureGraphBuilder2_SetFilterGraph
,
830 fnCaptureGraphBuilder2_GetFilterGraph
,
831 fnCaptureGraphBuilder2_SetOutputFileName
,
832 fnCaptureGraphBuilder2_FindInterface
,
833 fnCaptureGraphBuilder2_RenderStream
,
834 fnCaptureGraphBuilder2_ControlStream
,
835 fnCaptureGraphBuilder2_AllocCapFile
,
836 fnCaptureGraphBuilder2_CopyCaptureFile
,
837 fnCaptureGraphBuilder2_FindPin
841 static HRESULT WINAPI
842 fnCaptureGraphBuilder_QueryInterface(ICaptureGraphBuilder
* iface
,
843 REFIID riid
, LPVOID
* ppv
)
845 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
846 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
847 return ICaptureGraphBuilder2_QueryInterface(&This
->ICaptureGraphBuilder2_iface
, riid
, ppv
);
851 fnCaptureGraphBuilder_AddRef(ICaptureGraphBuilder
* iface
)
853 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
854 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
855 return ICaptureGraphBuilder2_AddRef(&This
->ICaptureGraphBuilder2_iface
);
859 fnCaptureGraphBuilder_Release(ICaptureGraphBuilder
* iface
)
861 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
862 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
863 return ICaptureGraphBuilder2_Release(&This
->ICaptureGraphBuilder2_iface
);
866 static HRESULT WINAPI
867 fnCaptureGraphBuilder_SetFiltergraph(ICaptureGraphBuilder
* iface
,
870 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
871 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
872 return ICaptureGraphBuilder2_SetFiltergraph(&This
->ICaptureGraphBuilder2_iface
, pfg
);
875 static HRESULT WINAPI
876 fnCaptureGraphBuilder_GetFiltergraph(ICaptureGraphBuilder
* iface
,
879 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
880 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
881 return ICaptureGraphBuilder2_GetFiltergraph(&This
->ICaptureGraphBuilder2_iface
, pfg
);
884 static HRESULT WINAPI
885 fnCaptureGraphBuilder_SetOutputFileName(ICaptureGraphBuilder
* iface
,
886 const GUID
*pType
, LPCOLESTR lpstrFile
,
887 IBaseFilter
**ppf
, IFileSinkFilter
**ppSink
)
889 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
890 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
891 return ICaptureGraphBuilder2_SetOutputFileName(&This
->ICaptureGraphBuilder2_iface
, pType
,
892 lpstrFile
, ppf
, ppSink
);
895 static HRESULT WINAPI
896 fnCaptureGraphBuilder_FindInterface(ICaptureGraphBuilder
* iface
,
897 const GUID
*pCategory
, IBaseFilter
*pf
,
898 REFIID riid
, void **ppint
)
900 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
901 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
902 return ICaptureGraphBuilder2_FindInterface(&This
->ICaptureGraphBuilder2_iface
, pCategory
, NULL
,
906 static HRESULT WINAPI
907 fnCaptureGraphBuilder_RenderStream(ICaptureGraphBuilder
* iface
,
908 const GUID
*pCategory
, IUnknown
*pSource
,
909 IBaseFilter
*pfCompressor
, IBaseFilter
*pfRenderer
)
911 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
912 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
913 return ICaptureGraphBuilder2_RenderStream(&This
->ICaptureGraphBuilder2_iface
, pCategory
, NULL
,
914 pSource
, pfCompressor
, pfRenderer
);
917 static HRESULT WINAPI
918 fnCaptureGraphBuilder_ControlStream(ICaptureGraphBuilder
* iface
,
919 const GUID
*pCategory
, IBaseFilter
*pFilter
,
920 REFERENCE_TIME
*pstart
, REFERENCE_TIME
*pstop
,
921 WORD wStartCookie
, WORD wStopCookie
)
923 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
924 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
925 return ICaptureGraphBuilder2_ControlStream(&This
->ICaptureGraphBuilder2_iface
, pCategory
, NULL
,
926 pFilter
, pstart
, pstop
, wStartCookie
, wStopCookie
);
929 static HRESULT WINAPI
930 fnCaptureGraphBuilder_AllocCapFile(ICaptureGraphBuilder
* iface
,
931 LPCOLESTR lpstr
, DWORDLONG dwlSize
)
933 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
934 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
935 return ICaptureGraphBuilder2_AllocCapFile(&This
->ICaptureGraphBuilder2_iface
, lpstr
, dwlSize
);
938 static HRESULT WINAPI
939 fnCaptureGraphBuilder_CopyCaptureFile(ICaptureGraphBuilder
* iface
,
940 LPOLESTR lpwstrOld
, LPOLESTR lpwstrNew
,
942 IAMCopyCaptureFileProgress
*pCallback
)
944 CaptureGraphImpl
*This
= impl_from_ICaptureGraphBuilder(iface
);
945 TRACE("%p --> Forwarding to v2 (%p)\n", iface
, This
);
946 return ICaptureGraphBuilder2_CopyCaptureFile(&This
->ICaptureGraphBuilder2_iface
, lpwstrOld
,
947 lpwstrNew
, fAllowEscAbort
, pCallback
);
950 static const ICaptureGraphBuilderVtbl builder_Vtbl
=
952 fnCaptureGraphBuilder_QueryInterface
,
953 fnCaptureGraphBuilder_AddRef
,
954 fnCaptureGraphBuilder_Release
,
955 fnCaptureGraphBuilder_SetFiltergraph
,
956 fnCaptureGraphBuilder_GetFiltergraph
,
957 fnCaptureGraphBuilder_SetOutputFileName
,
958 fnCaptureGraphBuilder_FindInterface
,
959 fnCaptureGraphBuilder_RenderStream
,
960 fnCaptureGraphBuilder_ControlStream
,
961 fnCaptureGraphBuilder_AllocCapFile
,
962 fnCaptureGraphBuilder_CopyCaptureFile