2005-05-07 20:18:39 +02:00
|
|
|
/* Capture Graph Builder, Minimal edition
|
|
|
|
*
|
|
|
|
* Copyright 2005 Maarten Lankhorst
|
|
|
|
* Copyright 2005 Rolf Kalbermatter
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-05-07 20:18:39 +02:00
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2008-07-10 19:38:47 +02:00
|
|
|
#include "wingdi.h"
|
2005-05-07 20:18:39 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
|
|
|
|
#include "evcode.h"
|
|
|
|
#include "strmif.h"
|
|
|
|
#include "control.h"
|
2008-03-12 00:24:54 +01:00
|
|
|
#include "vfwmsgs.h"
|
2005-05-07 20:18:39 +02:00
|
|
|
/*
|
|
|
|
*#include "amvideo.h"
|
|
|
|
*#include "mmreg.h"
|
|
|
|
*#include "dshow.h"
|
|
|
|
*#include "ddraw.h"
|
|
|
|
*/
|
|
|
|
#include "qcap_main.h"
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2005-05-18 19:45:35 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(qcap);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ICaptureGraphBuilder & ICaptureGraphBuilder2 implementation
|
|
|
|
*/
|
|
|
|
typedef struct CaptureGraphImpl
|
|
|
|
{
|
2011-08-10 23:57:01 +02:00
|
|
|
ICaptureGraphBuilder2 ICaptureGraphBuilder2_iface;
|
|
|
|
ICaptureGraphBuilder ICaptureGraphBuilder_iface;
|
2005-07-12 21:21:36 +02:00
|
|
|
LONG ref;
|
2005-05-07 20:18:39 +02:00
|
|
|
IGraphBuilder *mygraph;
|
|
|
|
CRITICAL_SECTION csFilter;
|
|
|
|
} CaptureGraphImpl;
|
|
|
|
|
|
|
|
static const ICaptureGraphBuilderVtbl builder_Vtbl;
|
|
|
|
static const ICaptureGraphBuilder2Vtbl builder2_Vtbl;
|
|
|
|
|
2011-08-10 23:57:01 +02:00
|
|
|
static inline CaptureGraphImpl *impl_from_ICaptureGraphBuilder(ICaptureGraphBuilder *iface)
|
2005-07-27 17:14:18 +02:00
|
|
|
{
|
2011-08-10 23:57:01 +02:00
|
|
|
return CONTAINING_RECORD(iface, CaptureGraphImpl, ICaptureGraphBuilder_iface);
|
2005-07-27 17:14:18 +02:00
|
|
|
}
|
2005-05-07 20:18:39 +02:00
|
|
|
|
2011-08-10 23:57:01 +02:00
|
|
|
static inline CaptureGraphImpl *impl_from_ICaptureGraphBuilder2(ICaptureGraphBuilder2 *iface)
|
2005-07-27 17:14:18 +02:00
|
|
|
{
|
2011-08-10 23:57:01 +02:00
|
|
|
return CONTAINING_RECORD(iface, CaptureGraphImpl, ICaptureGraphBuilder2_iface);
|
2005-07-27 17:14:18 +02:00
|
|
|
}
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
IUnknown * CALLBACK QCAP_createCaptureGraphBuilder2(IUnknown *pUnkOuter,
|
|
|
|
HRESULT *phr)
|
|
|
|
{
|
|
|
|
CaptureGraphImpl * pCapture = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pUnkOuter, phr);
|
|
|
|
|
|
|
|
*phr = CLASS_E_NOAGGREGATION;
|
|
|
|
if (pUnkOuter)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
*phr = E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
pCapture = CoTaskMemAlloc(sizeof(CaptureGraphImpl));
|
|
|
|
if (pCapture)
|
|
|
|
{
|
2011-08-10 23:57:01 +02:00
|
|
|
pCapture->ICaptureGraphBuilder2_iface.lpVtbl = &builder2_Vtbl;
|
|
|
|
pCapture->ICaptureGraphBuilder_iface.lpVtbl = &builder_Vtbl;
|
2005-05-07 20:18:39 +02:00
|
|
|
pCapture->ref = 1;
|
|
|
|
pCapture->mygraph = NULL;
|
|
|
|
InitializeCriticalSection(&pCapture->csFilter);
|
2007-03-10 22:10:09 +01:00
|
|
|
pCapture->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": CaptureGraphImpl.csFilter");
|
2005-05-07 20:18:39 +02:00
|
|
|
*phr = S_OK;
|
2005-05-18 19:45:35 +02:00
|
|
|
ObjectRefCount(TRUE);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
2011-08-10 23:57:01 +02:00
|
|
|
return (IUnknown *)&pCapture->ICaptureGraphBuilder_iface;
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_QueryInterface(ICaptureGraphBuilder2 * iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppv)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
2011-08-10 23:57:01 +02:00
|
|
|
*ppv = &This->ICaptureGraphBuilder2_iface;
|
2005-05-07 20:18:39 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_ICaptureGraphBuilder))
|
2011-08-10 23:57:01 +02:00
|
|
|
*ppv = &This->ICaptureGraphBuilder_iface;
|
2005-05-07 20:18:39 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_ICaptureGraphBuilder2))
|
2011-08-10 23:57:01 +02:00
|
|
|
*ppv = &This->ICaptureGraphBuilder2_iface;
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)(*ppv));
|
|
|
|
TRACE ("-- Interface = %p\n", *ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE ("-- Interface: E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
fnCaptureGraphBuilder2_AddRef(ICaptureGraphBuilder2 * iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
DWORD ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-08 19:36:31 +02:00
|
|
|
TRACE("(%p/%p)->() AddRef from %d\n", This, iface, ref - 1);
|
2005-05-07 20:18:39 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2012-10-14 18:22:07 +02:00
|
|
|
static ULONG WINAPI fnCaptureGraphBuilder2_Release(ICaptureGraphBuilder2 * iface)
|
2005-05-07 20:18:39 +02:00
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
DWORD ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-08 19:36:31 +02:00
|
|
|
TRACE("(%p/%p)->() Release from %d\n", This, iface, ref + 1);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
2007-03-10 22:10:09 +01:00
|
|
|
This->csFilter.DebugInfo->Spare[0] = 0;
|
2005-05-07 20:18:39 +02:00
|
|
|
DeleteCriticalSection(&This->csFilter);
|
2012-10-14 18:22:07 +02:00
|
|
|
if (This->mygraph)
|
2008-01-15 22:49:21 +01:00
|
|
|
IGraphBuilder_Release(This->mygraph);
|
2005-05-07 20:18:39 +02:00
|
|
|
CoTaskMemFree(This);
|
2005-05-18 19:45:35 +02:00
|
|
|
ObjectRefCount(FALSE);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
2005-05-18 19:45:35 +02:00
|
|
|
return ref;
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_SetFilterGraph(ICaptureGraphBuilder2 * iface,
|
|
|
|
IGraphBuilder *pfg)
|
|
|
|
{
|
|
|
|
/* The graph builder will automatically create a filter graph if you don't call
|
|
|
|
this method. If you call this method after the graph builder has created its
|
|
|
|
own filter graph, the call will fail. */
|
|
|
|
IMediaEvent *pmev;
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pfg);
|
|
|
|
|
2005-05-18 19:45:35 +02:00
|
|
|
if (This->mygraph)
|
2005-05-07 20:18:39 +02:00
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
if (!pfg)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
This->mygraph = pfg;
|
2008-01-15 22:49:21 +01:00
|
|
|
IGraphBuilder_AddRef(This->mygraph);
|
2012-08-19 20:21:46 +02:00
|
|
|
if (SUCCEEDED(IGraphBuilder_QueryInterface(This->mygraph,
|
2005-05-07 20:18:39 +02:00
|
|
|
&IID_IMediaEvent, (LPVOID *)&pmev)))
|
|
|
|
{
|
|
|
|
IMediaEvent_CancelDefaultHandling(pmev, EC_REPAINT);
|
|
|
|
IMediaEvent_Release(pmev);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_GetFilterGraph(ICaptureGraphBuilder2 * iface,
|
|
|
|
IGraphBuilder **pfg)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pfg);
|
|
|
|
|
|
|
|
if (!pfg)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pfg = This->mygraph;
|
|
|
|
if (!This->mygraph)
|
|
|
|
{
|
|
|
|
TRACE("(%p) Getting NULL filtergraph\n", iface);
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2008-01-15 22:49:21 +01:00
|
|
|
IGraphBuilder_AddRef(This->mygraph);
|
2012-10-14 18:22:07 +02:00
|
|
|
|
2005-05-07 20:18:39 +02:00
|
|
|
TRACE("(%p) return filtergraph %p\n", iface, *pfg);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_SetOutputFileName(ICaptureGraphBuilder2 * iface,
|
|
|
|
const GUID *pType,
|
|
|
|
LPCOLESTR lpstrFile,
|
|
|
|
IBaseFilter **ppf,
|
|
|
|
IFileSinkFilter **ppSink)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%s, %s, %p, %p) Stub!\n", This, iface,
|
|
|
|
debugstr_guid(pType), debugstr_w(lpstrFile), ppf, ppSink);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_FindInterface(ICaptureGraphBuilder2 * iface,
|
|
|
|
const GUID *pCategory,
|
|
|
|
const GUID *pType,
|
|
|
|
IBaseFilter *pf,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppint)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%s, %s, %p, %s, %p) - workaround stub!\n", This, iface,
|
|
|
|
debugstr_guid(pCategory), debugstr_guid(pType),
|
|
|
|
pf, debugstr_guid(riid), ppint);
|
|
|
|
|
|
|
|
return IBaseFilter_QueryInterface(pf, riid, ppint);
|
|
|
|
/* Looks for the specified interface on the filter, upstream and
|
|
|
|
* downstream from the filter, and, optionally, only on the output
|
|
|
|
* pin of the given category.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_RenderStream(ICaptureGraphBuilder2 * iface,
|
|
|
|
const GUID *pCategory,
|
|
|
|
const GUID *pType,
|
|
|
|
IUnknown *pSource,
|
|
|
|
IBaseFilter *pfCompressor,
|
|
|
|
IBaseFilter *pfRenderer)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2013-11-20 12:00:07 +01:00
|
|
|
IPin *source_out;
|
|
|
|
IPin *renderer_in;
|
2008-03-13 01:18:12 +01:00
|
|
|
HRESULT hr;
|
2005-05-07 20:18:39 +02:00
|
|
|
|
2013-11-20 12:00:07 +01:00
|
|
|
FIXME("(%p/%p)->(%s, %s, %p, %p, %p) semi-stub!\n", This, iface,
|
2005-05-07 20:18:39 +02:00
|
|
|
debugstr_guid(pCategory), debugstr_guid(pType),
|
|
|
|
pSource, pfCompressor, pfRenderer);
|
|
|
|
|
2008-03-13 01:18:12 +01:00
|
|
|
if (!This->mygraph)
|
|
|
|
{
|
|
|
|
FIXME("Need a capture graph\n");
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
2013-11-20 12:00:07 +01:00
|
|
|
if (!pfRenderer)
|
|
|
|
{
|
|
|
|
FIXME("pfRenderer == NULL not yet supported\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2008-03-13 01:18:12 +01:00
|
|
|
|
2013-11-20 12:00:07 +01:00
|
|
|
hr = ICaptureGraphBuilder2_FindPin(iface, pSource, PINDIR_OUTPUT, pCategory, pType, TRUE, 0, &source_out);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
hr = ICaptureGraphBuilder2_FindPin(iface, (IUnknown*)pfRenderer, PINDIR_INPUT, pCategory, pType, TRUE, 0, &renderer_in);
|
|
|
|
if (FAILED(hr))
|
2008-03-13 01:18:12 +01:00
|
|
|
{
|
2013-11-20 12:00:07 +01:00
|
|
|
IPin_Release(source_out);
|
|
|
|
return hr;
|
2008-03-13 01:18:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Uses 'Intelligent Connect', so Connect, not ConnectDirect here */
|
2013-11-20 12:00:07 +01:00
|
|
|
if (!pfCompressor)
|
|
|
|
hr = IGraphBuilder_Connect(This->mygraph, source_out, renderer_in);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IPin *compressor_in, *compressor_out;
|
|
|
|
|
|
|
|
hr = ICaptureGraphBuilder2_FindPin(iface, (IUnknown*)pfCompressor,
|
|
|
|
PINDIR_INPUT, NULL, NULL, TRUE, 0, &compressor_in);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IGraphBuilder_Connect(This->mygraph, source_out, compressor_in);
|
|
|
|
IPin_Release(compressor_in);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ICaptureGraphBuilder2_FindPin(iface, (IUnknown*)pfCompressor,
|
|
|
|
PINDIR_OUTPUT, NULL, NULL, TRUE, 0, &compressor_out);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IGraphBuilder_Connect(This->mygraph, compressor_out, renderer_in);
|
|
|
|
IPin_Release(compressor_out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IPin_Release(source_out);
|
|
|
|
IPin_Release(renderer_in);
|
2008-03-13 01:18:12 +01:00
|
|
|
return hr;
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_ControlStream(ICaptureGraphBuilder2 * iface,
|
|
|
|
const GUID *pCategory,
|
|
|
|
const GUID *pType,
|
|
|
|
IBaseFilter *pFilter,
|
|
|
|
REFERENCE_TIME *pstart,
|
|
|
|
REFERENCE_TIME *pstop,
|
|
|
|
WORD wStartCookie,
|
|
|
|
WORD wStopCookie)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%s, %s, %p, %p, %p, %i, %i) Stub!\n", This, iface,
|
|
|
|
debugstr_guid(pCategory), debugstr_guid(pType),
|
|
|
|
pFilter, pstart, pstop, wStartCookie, wStopCookie);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_AllocCapFile(ICaptureGraphBuilder2 * iface,
|
|
|
|
LPCOLESTR lpwstr,
|
|
|
|
DWORDLONG dwlSize)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
2006-08-18 22:25:23 +02:00
|
|
|
FIXME("(%p/%p)->(%s, 0x%s) Stub!\n", This, iface,
|
|
|
|
debugstr_w(lpwstr), wine_dbgstr_longlong(dwlSize));
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_CopyCaptureFile(ICaptureGraphBuilder2 * iface,
|
|
|
|
LPOLESTR lpwstrOld,
|
|
|
|
LPOLESTR lpwstrNew,
|
|
|
|
int fAllowEscAbort,
|
|
|
|
IAMCopyCaptureFileProgress *pCallback)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%s, %s, %i, %p) Stub!\n", This, iface,
|
|
|
|
debugstr_w(lpwstrOld), debugstr_w(lpwstrNew),
|
|
|
|
fAllowEscAbort, pCallback);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-03-12 00:24:54 +01:00
|
|
|
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)
|
2008-03-13 01:18:12 +01:00
|
|
|
{
|
|
|
|
TRACE("No match, wrong direction\n");
|
2008-03-12 00:24:54 +01:00
|
|
|
return FALSE;
|
2008-03-13 01:18:12 +01:00
|
|
|
}
|
2008-03-12 00:24:54 +01:00
|
|
|
|
|
|
|
if (unconnected && IPin_ConnectedTo(pin, &partner) == S_OK)
|
|
|
|
{
|
|
|
|
IPin_Release(partner);
|
2008-03-13 01:18:12 +01:00
|
|
|
TRACE("No match, %p already connected to %p\n", pin, partner);
|
2008-03-12 00:24:54 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cat || type)
|
|
|
|
FIXME("Ignoring category/type\n");
|
|
|
|
|
2008-03-13 01:18:12 +01:00
|
|
|
TRACE("Match made in heaven\n");
|
|
|
|
|
2008-03-12 00:24:54 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-05-07 20:18:39 +02:00
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder2_FindPin(ICaptureGraphBuilder2 * iface,
|
|
|
|
IUnknown *pSource,
|
|
|
|
PIN_DIRECTION pindir,
|
|
|
|
const GUID *pCategory,
|
|
|
|
const GUID *pType,
|
|
|
|
BOOL fUnconnected,
|
2008-03-12 00:24:54 +01:00
|
|
|
INT num,
|
2005-05-07 20:18:39 +02:00
|
|
|
IPin **ppPin)
|
|
|
|
{
|
2008-03-12 00:24:54 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IEnumPins *enumpins = NULL;
|
|
|
|
IPin *pin;
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder2(iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
|
2008-03-12 00:24:54 +01:00
|
|
|
TRACE("(%p/%p)->(%p, %x, %s, %s, %d, %i, %p)\n", This, iface,
|
2005-05-07 20:18:39 +02:00
|
|
|
pSource, pindir, debugstr_guid(pCategory), debugstr_guid(pType),
|
|
|
|
fUnconnected, num, ppPin);
|
|
|
|
|
2008-03-12 00:24:54 +01:00
|
|
|
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;
|
2008-03-13 01:18:12 +01:00
|
|
|
TRACE("Testing match\n");
|
2008-03-12 00:24:54 +01:00
|
|
|
if (pin_matches(pin, pindir, pCategory, pType, fUnconnected) && numcurrent++ == num)
|
|
|
|
break;
|
|
|
|
IPin_Release(pin);
|
|
|
|
pin = NULL;
|
|
|
|
}
|
|
|
|
IEnumPins_Release(enumpins);
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
2008-03-13 01:18:12 +01:00
|
|
|
WARN("Could not find %s pin # %d\n", (pindir == PINDIR_OUTPUT ? "output" : "input"), numcurrent);
|
2008-03-12 00:24:54 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!pin_matches(pin, pindir, pCategory, pType, fUnconnected))
|
|
|
|
{
|
|
|
|
IPin_Release(pin);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppPin = pin;
|
|
|
|
return S_OK;
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const ICaptureGraphBuilder2Vtbl builder2_Vtbl =
|
2012-10-14 18:22:07 +02:00
|
|
|
{
|
2005-05-07 20:18:39 +02:00
|
|
|
fnCaptureGraphBuilder2_QueryInterface,
|
|
|
|
fnCaptureGraphBuilder2_AddRef,
|
|
|
|
fnCaptureGraphBuilder2_Release,
|
|
|
|
fnCaptureGraphBuilder2_SetFilterGraph,
|
|
|
|
fnCaptureGraphBuilder2_GetFilterGraph,
|
|
|
|
fnCaptureGraphBuilder2_SetOutputFileName,
|
|
|
|
fnCaptureGraphBuilder2_FindInterface,
|
|
|
|
fnCaptureGraphBuilder2_RenderStream,
|
|
|
|
fnCaptureGraphBuilder2_ControlStream,
|
|
|
|
fnCaptureGraphBuilder2_AllocCapFile,
|
|
|
|
fnCaptureGraphBuilder2_CopyCaptureFile,
|
|
|
|
fnCaptureGraphBuilder2_FindPin
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_QueryInterface(ICaptureGraphBuilder * iface,
|
|
|
|
REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2012-08-19 20:21:46 +02:00
|
|
|
return ICaptureGraphBuilder2_QueryInterface(&This->ICaptureGraphBuilder2_iface, riid, ppv);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
fnCaptureGraphBuilder_AddRef(ICaptureGraphBuilder * iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2012-08-19 20:21:46 +02:00
|
|
|
return ICaptureGraphBuilder2_AddRef(&This->ICaptureGraphBuilder2_iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
fnCaptureGraphBuilder_Release(ICaptureGraphBuilder * iface)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2012-08-19 20:21:46 +02:00
|
|
|
return ICaptureGraphBuilder2_Release(&This->ICaptureGraphBuilder2_iface);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_SetFiltergraph(ICaptureGraphBuilder * iface,
|
|
|
|
IGraphBuilder *pfg)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2011-08-10 23:57:01 +02:00
|
|
|
return ICaptureGraphBuilder2_SetFiltergraph(&This->ICaptureGraphBuilder2_iface, pfg);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_GetFiltergraph(ICaptureGraphBuilder * iface,
|
|
|
|
IGraphBuilder **pfg)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2011-08-10 23:57:01 +02:00
|
|
|
return ICaptureGraphBuilder2_GetFiltergraph(&This->ICaptureGraphBuilder2_iface, pfg);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_SetOutputFileName(ICaptureGraphBuilder * iface,
|
|
|
|
const GUID *pType, LPCOLESTR lpstrFile,
|
|
|
|
IBaseFilter **ppf, IFileSinkFilter **ppSink)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2011-08-10 23:57:01 +02:00
|
|
|
return ICaptureGraphBuilder2_SetOutputFileName(&This->ICaptureGraphBuilder2_iface, pType,
|
|
|
|
lpstrFile, ppf, ppSink);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_FindInterface(ICaptureGraphBuilder * iface,
|
|
|
|
const GUID *pCategory, IBaseFilter *pf,
|
|
|
|
REFIID riid, void **ppint)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2011-08-10 23:57:01 +02:00
|
|
|
return ICaptureGraphBuilder2_FindInterface(&This->ICaptureGraphBuilder2_iface, pCategory, NULL,
|
|
|
|
pf, riid, ppint);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_RenderStream(ICaptureGraphBuilder * iface,
|
|
|
|
const GUID *pCategory, IUnknown *pSource,
|
|
|
|
IBaseFilter *pfCompressor, IBaseFilter *pfRenderer)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2011-08-10 23:57:01 +02:00
|
|
|
return ICaptureGraphBuilder2_RenderStream(&This->ICaptureGraphBuilder2_iface, pCategory, NULL,
|
|
|
|
pSource, pfCompressor, pfRenderer);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_ControlStream(ICaptureGraphBuilder * iface,
|
|
|
|
const GUID *pCategory, IBaseFilter *pFilter,
|
|
|
|
REFERENCE_TIME *pstart, REFERENCE_TIME *pstop,
|
|
|
|
WORD wStartCookie, WORD wStopCookie)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2011-08-10 23:57:01 +02:00
|
|
|
return ICaptureGraphBuilder2_ControlStream(&This->ICaptureGraphBuilder2_iface, pCategory, NULL,
|
|
|
|
pFilter, pstart, pstop, wStartCookie, wStopCookie);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_AllocCapFile(ICaptureGraphBuilder * iface,
|
|
|
|
LPCOLESTR lpstr, DWORDLONG dwlSize)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2011-08-10 23:57:01 +02:00
|
|
|
return ICaptureGraphBuilder2_AllocCapFile(&This->ICaptureGraphBuilder2_iface, lpstr, dwlSize);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
fnCaptureGraphBuilder_CopyCaptureFile(ICaptureGraphBuilder * iface,
|
|
|
|
LPOLESTR lpwstrOld, LPOLESTR lpwstrNew,
|
|
|
|
int fAllowEscAbort,
|
|
|
|
IAMCopyCaptureFileProgress *pCallback)
|
|
|
|
{
|
2005-07-27 17:14:18 +02:00
|
|
|
CaptureGraphImpl *This = impl_from_ICaptureGraphBuilder(iface);
|
2005-05-18 19:45:35 +02:00
|
|
|
TRACE("%p --> Forwarding to v2 (%p)\n", iface, This);
|
2011-08-10 23:57:01 +02:00
|
|
|
return ICaptureGraphBuilder2_CopyCaptureFile(&This->ICaptureGraphBuilder2_iface, lpwstrOld,
|
|
|
|
lpwstrNew, fAllowEscAbort, pCallback);
|
2005-05-07 20:18:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const ICaptureGraphBuilderVtbl builder_Vtbl =
|
2012-10-14 18:22:07 +02:00
|
|
|
{
|
2005-05-07 20:18:39 +02:00
|
|
|
fnCaptureGraphBuilder_QueryInterface,
|
|
|
|
fnCaptureGraphBuilder_AddRef,
|
|
|
|
fnCaptureGraphBuilder_Release,
|
|
|
|
fnCaptureGraphBuilder_SetFiltergraph,
|
|
|
|
fnCaptureGraphBuilder_GetFiltergraph,
|
|
|
|
fnCaptureGraphBuilder_SetOutputFileName,
|
|
|
|
fnCaptureGraphBuilder_FindInterface,
|
|
|
|
fnCaptureGraphBuilder_RenderStream,
|
|
|
|
fnCaptureGraphBuilder_ControlStream,
|
|
|
|
fnCaptureGraphBuilder_AllocCapFile,
|
|
|
|
fnCaptureGraphBuilder_CopyCaptureFile
|
|
|
|
};
|