Module: wine Branch: master Commit: 7e32b11ab6ec2a53f70e6bf19144c04680011f1a URL: http://source.winehq.org/git/wine.git/?a=commit;h=7e32b11ab6ec2a53f70e6bf191...
Author: Maarten Lankhorst m.b.lankhorst@gmail.com Date: Tue Mar 11 16:24:54 2008 -0700
qcap: Add better findpin stub for CaptureGraphBuilder.
ICaptureGraphBuilder::RenderStream needs to enumerate pins, and to prevent duplication I implemented a bit of findpin first.
---
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 =