From 54a034693a23fef78145240ceaeb0dc926076dc4 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Tue, 11 Mar 2008 16:24:54 -0700 Subject: [PATCH] qcap: Add better findpin stub for capturegraphbuilder --- dlls/qcap/capturegraph.c | 89 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 85 insertions(+), 4 deletions(-) diff --git a/dlls/qcap/capturegraph.c b/dlls/qcap/capturegraph.c index c5631b1..6dec92a 100644 --- a/dlls/qcap/capturegraph.c +++ b/dlls/qcap/capturegraph.c @@ -34,10 +34,10 @@ #include "evcode.h" #include "strmif.h" #include "control.h" +#include "vfwmsgs.h" /* *#include "amvideo.h" *#include "mmreg.h" - *#include "vfwmsgs.h" *#include "dshow.h" *#include "ddraw.h" */ @@ -326,6 +326,27 @@ fnCaptureGraphBuilder2_CopyCaptureFile(ICaptureGraphBuilder2 * iface, return E_NOTIMPL; } +static BOOL pin_matches(IPin *pin, PIN_DIRECTION direction, const GUID *cat, const GUID *type, BOOL unconnected) +{ + IPin *partner; + PIN_DIRECTION pindir; + + IPin_QueryDirection(pin, &pindir); + if (pindir != direction) + return FALSE; + + if (unconnected && IPin_ConnectedTo(pin, &partner) == S_OK) + { + IPin_Release(partner); + return FALSE; + } + + if (cat || type) + FIXME("Ignoring category/type\n"); + + return TRUE; +} + static HRESULT WINAPI fnCaptureGraphBuilder2_FindPin(ICaptureGraphBuilder2 * iface, IUnknown *pSource, @@ -333,16 +354,76 @@ fnCaptureGraphBuilder2_FindPin(ICaptureGraphBuilder2 * iface, const GUID *pCategory, const GUID *pType, BOOL fUnconnected, - int num, + INT num, IPin **ppPin) { + HRESULT hr; + IEnumPins *enumpins = NULL; + IPin *pin; CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface); - FIXME("(%p/%p)->(%p, %x, %s, %s, %d, %i, %p) Stub!\n", This, iface, + TRACE("(%p/%p)->(%p, %x, %s, %s, %d, %i, %p)\n", This, iface, pSource, pindir, debugstr_guid(pCategory), debugstr_guid(pType), fUnconnected, num, ppPin); - return E_NOTIMPL; + pin = NULL; + + hr = IUnknown_QueryInterface(pSource, &IID_IPin, (void**)&pin); + if (hr == E_NOINTERFACE) + { + IBaseFilter *filter = NULL; + int numcurrent = 0; + + hr = IUnknown_QueryInterface(pSource, &IID_IBaseFilter, (void**)&filter); + if (hr == E_NOINTERFACE) + { + WARN("Input not filter or pin?!\n"); + return E_FAIL; + } + + hr = IBaseFilter_EnumPins(filter, &enumpins); + if (FAILED(hr)) + { + WARN("Could not enumerate\n"); + return hr; + } + + IEnumPins_Reset(enumpins); + + while (1) + { + hr = IEnumPins_Next(enumpins, 1, &pin, NULL); + if (hr == VFW_E_ENUM_OUT_OF_SYNC) + { + numcurrent = 0; + IEnumPins_Reset(enumpins); + pin = NULL; + continue; + } + + if (hr != S_OK) + break; + if (pin_matches(pin, pindir, pCategory, pType, fUnconnected) && numcurrent++ == num) + break; + IPin_Release(pin); + pin = NULL; + } + IEnumPins_Release(enumpins); + + if (hr != S_OK) + { + WARN("Could not find pin # %d\n", numcurrent); + return E_FAIL; + } + } + else if (!pin_matches(pin, pindir, pCategory, pType, fUnconnected)) + { + IPin_Release(pin); + return E_FAIL; + } + + *ppPin = pin; + return S_OK; } static const ICaptureGraphBuilder2Vtbl builder2_Vtbl = -- 1.5.4.1