2001-08-15 21:26:52 +02:00
|
|
|
/*
|
2001-10-14 18:13:14 +02:00
|
|
|
* Implementation of IFilterGraph and related interfaces
|
2002-03-22 20:19:23 +01:00
|
|
|
* + IGraphVersion
|
2001-08-15 21:26:52 +02:00
|
|
|
*
|
2001-09-26 00:37:04 +02:00
|
|
|
* FIXME - create a thread to process some methods correctly.
|
|
|
|
*
|
|
|
|
* FIXME - ReconnectEx
|
|
|
|
* FIXME - process Pause/Stop asynchronously and notify when completed.
|
|
|
|
*
|
2001-08-15 21:26:52 +02:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-08-15 21:26:52 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2001-09-17 22:04:28 +02:00
|
|
|
#include "winuser.h"
|
2001-08-15 21:26:52 +02:00
|
|
|
#include "winerror.h"
|
2001-10-28 22:16:00 +01:00
|
|
|
#include "winreg.h"
|
2001-08-15 21:26:52 +02:00
|
|
|
#include "strmif.h"
|
2001-08-22 20:06:00 +02:00
|
|
|
#include "control.h"
|
2001-08-15 21:26:52 +02:00
|
|
|
#include "uuids.h"
|
2001-09-07 21:46:49 +02:00
|
|
|
#include "vfwmsgs.h"
|
2001-09-26 00:37:04 +02:00
|
|
|
#include "evcode.h"
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
2001-08-15 21:26:52 +02:00
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
#include "fgraph.h"
|
2001-09-07 21:46:49 +02:00
|
|
|
#include "enumunk.h"
|
2001-09-26 00:37:04 +02:00
|
|
|
#include "sysclock.h"
|
2001-10-28 22:16:00 +01:00
|
|
|
#include "regsvr.h"
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
|
2001-10-28 22:16:00 +01:00
|
|
|
#ifndef NUMELEMS
|
|
|
|
#define NUMELEMS(elem) (sizeof(elem)/sizeof(elem[0]))
|
|
|
|
#endif /* NUMELEMS */
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
static HRESULT CFilterGraph_DisconnectAllPins( IBaseFilter* pFilter )
|
|
|
|
{
|
|
|
|
IEnumPins* pEnum = NULL;
|
|
|
|
IPin* pPin;
|
|
|
|
IPin* pConnTo;
|
|
|
|
ULONG cFetched;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IBaseFilter_EnumPins( pFilter, &pEnum );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
if ( pEnum == NULL )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
while ( 1 )
|
|
|
|
{
|
|
|
|
pPin = NULL;
|
|
|
|
cFetched = 0;
|
|
|
|
hr = IEnumPins_Next( pEnum, 1, &pPin, &cFetched );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
break;
|
|
|
|
if ( hr != NOERROR || pPin == NULL || cFetched != 1 )
|
|
|
|
{
|
|
|
|
hr = NOERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pConnTo = NULL;
|
|
|
|
hr = IPin_ConnectedTo(pPin,&pConnTo);
|
|
|
|
if ( hr == NOERROR && pConnTo != NULL )
|
|
|
|
{
|
|
|
|
IPin_Disconnect(pPin);
|
|
|
|
IPin_Disconnect(pConnTo);
|
|
|
|
IPin_Release(pConnTo);
|
|
|
|
}
|
|
|
|
|
|
|
|
IPin_Release( pPin );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumPins_Release( pEnum );
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-01 22:53:58 +02:00
|
|
|
static HRESULT CFilterGraph_GraphChanged( CFilterGraph* This )
|
|
|
|
{
|
|
|
|
/* IDistributorNotify_NotifyGraphChange() */
|
|
|
|
|
|
|
|
This->m_lGraphVersion ++;
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
2001-10-28 22:16:00 +01:00
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* CFilterGraph internal methods for IFilterGraph2::AddSourceFilter().
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT QUARTZ_PeekFile(
|
|
|
|
const WCHAR* pwszFileName,
|
|
|
|
BYTE* pData, DWORD cbData, DWORD* pcbRead )
|
|
|
|
{
|
|
|
|
HANDLE hFile;
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
|
|
|
|
*pcbRead = 0;
|
|
|
|
hFile = CreateFileW( pwszFileName,
|
|
|
|
GENERIC_READ, FILE_SHARE_READ,
|
|
|
|
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL );
|
|
|
|
if ( hFile == INVALID_HANDLE_VALUE )
|
|
|
|
return E_FAIL;
|
|
|
|
if ( ReadFile( hFile, pData, cbData, pcbRead, NULL ) )
|
|
|
|
hr = NOERROR;
|
|
|
|
CloseHandle( hFile );
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const WCHAR* skip_space(const WCHAR* pwsz)
|
|
|
|
{
|
|
|
|
if ( pwsz == NULL ) return NULL;
|
|
|
|
while ( *pwsz == (WCHAR)' ' ) pwsz++;
|
|
|
|
return pwsz;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WCHAR* get_dword(const WCHAR* pwsz,DWORD* pdw)
|
|
|
|
{
|
|
|
|
DWORD dw = 0;
|
|
|
|
|
|
|
|
*pdw = 0;
|
|
|
|
if ( pwsz == NULL ) return NULL;
|
|
|
|
while ( *pwsz >= (WCHAR)'0' && *pwsz <= (WCHAR)'9' )
|
|
|
|
{
|
|
|
|
dw = dw * 10 + (DWORD)(*pwsz-(WCHAR)'0');
|
|
|
|
pwsz ++;
|
|
|
|
}
|
|
|
|
*pdw = dw;
|
|
|
|
return pwsz;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wchar_to_hex(WCHAR wch)
|
|
|
|
{
|
|
|
|
if ( wch >= (WCHAR)'0' && wch <= (WCHAR)'9' )
|
|
|
|
return (int)(wch - (WCHAR)'0');
|
|
|
|
if ( wch >= (WCHAR)'A' && wch <= (WCHAR)'F' )
|
|
|
|
return (int)(wch - (WCHAR)'A' + 10);
|
|
|
|
if ( wch >= (WCHAR)'a' && wch <= (WCHAR)'f' )
|
|
|
|
return (int)(wch - (WCHAR)'a' + 10);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WCHAR* get_hex(const WCHAR* pwsz,BYTE* pb)
|
|
|
|
{
|
|
|
|
int hi,lo;
|
|
|
|
|
|
|
|
*pb = 0;
|
|
|
|
if ( pwsz == NULL ) return NULL;
|
|
|
|
hi = wchar_to_hex(*pwsz); if ( hi < 0 ) return NULL; pwsz++;
|
|
|
|
lo = wchar_to_hex(*pwsz); if ( lo < 0 ) return NULL; pwsz++;
|
|
|
|
*pb = (BYTE)( (hi << 4) | lo );
|
|
|
|
return pwsz;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WCHAR* skip_hex(const WCHAR* pwsz)
|
|
|
|
{
|
|
|
|
if ( pwsz == NULL ) return NULL;
|
|
|
|
while ( 1 )
|
|
|
|
{
|
|
|
|
if ( wchar_to_hex(*pwsz) < 0 )
|
|
|
|
break;
|
|
|
|
pwsz++;
|
|
|
|
}
|
|
|
|
return pwsz;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const WCHAR* next_token(const WCHAR* pwsz)
|
|
|
|
{
|
|
|
|
if ( pwsz == NULL ) return NULL;
|
|
|
|
pwsz = skip_space(pwsz);
|
|
|
|
if ( *pwsz != (WCHAR)',' ) return NULL; pwsz++;
|
|
|
|
return skip_space(pwsz);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT QUARTZ_SourceTypeIsMatch(
|
|
|
|
const BYTE* pData, DWORD cbData,
|
|
|
|
const WCHAR* pwszTempl, DWORD cchTempl )
|
|
|
|
{
|
|
|
|
DWORD dwOfs;
|
|
|
|
DWORD n;
|
|
|
|
DWORD cbLen;
|
|
|
|
const WCHAR* pwszMask;
|
|
|
|
const WCHAR* pwszValue;
|
|
|
|
BYTE bMask;
|
|
|
|
BYTE bValue;
|
|
|
|
|
|
|
|
TRACE("(%p,%lu,%s,%lu)\n",pData,cbData,debugstr_w(pwszTempl),cchTempl);
|
|
|
|
|
|
|
|
pwszTempl = skip_space(pwszTempl);
|
|
|
|
while ( 1 )
|
|
|
|
{
|
|
|
|
pwszTempl = get_dword(pwszTempl,&dwOfs);
|
|
|
|
pwszTempl = next_token(pwszTempl);
|
|
|
|
pwszTempl = get_dword(pwszTempl,&cbLen);
|
|
|
|
pwszMask = pwszTempl = next_token(pwszTempl);
|
|
|
|
pwszTempl = skip_hex(pwszTempl);
|
|
|
|
pwszValue = pwszTempl = next_token(pwszTempl);
|
|
|
|
pwszTempl = skip_hex(pwszValue);
|
|
|
|
pwszTempl = skip_space(pwszTempl);
|
|
|
|
if ( pwszValue == NULL )
|
|
|
|
{
|
|
|
|
WARN( "parse error\n" );
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( dwOfs >= cbData || ( (dwOfs+cbLen) >= cbData ) )
|
|
|
|
{
|
|
|
|
WARN( "length of given data is too short\n" );
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( n = 0; n < cbLen; n++ )
|
|
|
|
{
|
|
|
|
pwszMask = get_hex(pwszMask,&bMask);
|
|
|
|
if ( pwszMask == NULL ) bMask = 0xff;
|
|
|
|
pwszValue = get_hex(pwszValue,&bValue);
|
|
|
|
if ( pwszValue == NULL )
|
|
|
|
{
|
|
|
|
WARN( "parse error - invalid hex data\n" );
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
if ( (pData[dwOfs+n]&bMask) != (bValue&bMask) )
|
|
|
|
{
|
|
|
|
TRACE( "not matched\n" );
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( *pwszTempl == 0 )
|
|
|
|
break;
|
|
|
|
pwszTempl = next_token(pwszTempl);
|
|
|
|
if ( pwszTempl == NULL )
|
|
|
|
{
|
|
|
|
WARN( "parse error\n" );
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE( "matched\n" );
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT QUARTZ_GetSourceTypeFromData(
|
|
|
|
const BYTE* pData, DWORD cbData,
|
|
|
|
GUID* pidMajor, GUID* pidSub, CLSID* pidSource )
|
|
|
|
{
|
|
|
|
HRESULT hr = S_FALSE;
|
|
|
|
LONG lr;
|
|
|
|
WCHAR wszMajor[128];
|
|
|
|
WCHAR wszSub[128];
|
|
|
|
WCHAR wszSource[128];
|
|
|
|
WCHAR wszSourceFilter[128];
|
|
|
|
WCHAR* pwszLocalBuf = NULL;
|
|
|
|
WCHAR* pwszTemp;
|
|
|
|
DWORD cbLocalBuf = 0;
|
|
|
|
DWORD cbPath;
|
|
|
|
DWORD dwIndexMajor;
|
|
|
|
HKEY hkMajor;
|
|
|
|
DWORD dwIndexSub;
|
|
|
|
HKEY hkSub;
|
|
|
|
DWORD dwIndexSource;
|
|
|
|
HKEY hkSource;
|
|
|
|
DWORD dwRegType;
|
|
|
|
DWORD cbRegData;
|
|
|
|
FILETIME ftLastWrite;
|
|
|
|
static const WCHAR wszFmt[] = {'%','l','u',0};
|
|
|
|
|
|
|
|
if ( RegOpenKeyExW( HKEY_CLASSES_ROOT, QUARTZ_wszMediaType, 0, KEY_READ, &hkMajor ) == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
dwIndexMajor = 0;
|
|
|
|
while ( hr == S_FALSE )
|
|
|
|
{
|
|
|
|
cbPath = NUMELEMS(wszMajor)-1;
|
|
|
|
lr = RegEnumKeyExW(
|
|
|
|
hkMajor, dwIndexMajor ++, wszMajor, &cbPath,
|
|
|
|
NULL, NULL, NULL, &ftLastWrite );
|
|
|
|
if ( lr != ERROR_SUCCESS )
|
|
|
|
break;
|
|
|
|
if ( RegOpenKeyExW( hkMajor, wszMajor, 0, KEY_READ, &hkSub ) == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
dwIndexSub = 0;
|
|
|
|
while ( hr == S_FALSE )
|
|
|
|
{
|
|
|
|
cbPath = NUMELEMS(wszSub)-1;
|
|
|
|
lr = RegEnumKeyExW(
|
|
|
|
hkSub, dwIndexSub ++, wszSub, &cbPath,
|
|
|
|
NULL, NULL, NULL, &ftLastWrite );
|
|
|
|
if ( lr != ERROR_SUCCESS )
|
|
|
|
break;
|
|
|
|
if ( RegOpenKeyExW( hkSub, wszSub, 0, KEY_READ, &hkSource ) == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
dwIndexSource = 0;
|
|
|
|
while ( hr == S_FALSE )
|
|
|
|
{
|
|
|
|
wsprintfW(wszSource,wszFmt,dwIndexSource++);
|
|
|
|
lr = RegQueryValueExW(
|
|
|
|
hkSource, wszSource, NULL,
|
|
|
|
&dwRegType, NULL, &cbRegData );
|
|
|
|
if ( lr != ERROR_SUCCESS )
|
|
|
|
break;
|
|
|
|
if ( cbLocalBuf < cbRegData )
|
|
|
|
{
|
|
|
|
pwszTemp = (WCHAR*)QUARTZ_ReallocMem( pwszLocalBuf, cbRegData+sizeof(WCHAR) );
|
|
|
|
if ( pwszTemp == NULL )
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pwszLocalBuf = pwszTemp;
|
|
|
|
cbLocalBuf = cbRegData+sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
cbRegData = cbLocalBuf;
|
|
|
|
lr = RegQueryValueExW(
|
|
|
|
hkSource, wszSource, NULL,
|
|
|
|
&dwRegType, (BYTE*)pwszLocalBuf, &cbRegData );
|
|
|
|
if ( lr != ERROR_SUCCESS )
|
|
|
|
break;
|
|
|
|
|
|
|
|
hr = QUARTZ_SourceTypeIsMatch(
|
|
|
|
pData, cbData,
|
|
|
|
pwszLocalBuf, cbRegData / sizeof(WCHAR) );
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
hr = CLSIDFromString(wszMajor,pidMajor);
|
|
|
|
if ( hr == NOERROR )
|
|
|
|
hr = CLSIDFromString(wszSub,pidSub);
|
|
|
|
if ( hr == NOERROR )
|
|
|
|
{
|
|
|
|
lstrcpyW(wszSource,QUARTZ_wszSourceFilter);
|
|
|
|
cbRegData = NUMELEMS(wszSourceFilter)-sizeof(WCHAR);
|
|
|
|
lr = RegQueryValueExW(
|
|
|
|
hkSource, wszSource, NULL,
|
|
|
|
&dwRegType,
|
|
|
|
(BYTE*)wszSourceFilter, &cbRegData );
|
|
|
|
if ( lr == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
hr = CLSIDFromString(wszSourceFilter,pidSource);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( hr != NOERROR && SUCCEEDED(hr) )
|
|
|
|
hr = E_FAIL;
|
|
|
|
}
|
|
|
|
if ( hr != S_FALSE )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RegCloseKey( hkSource );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey( hkSub );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey( hkMajor );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pwszLocalBuf != NULL )
|
|
|
|
QUARTZ_FreeMem(pwszLocalBuf);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-01 22:53:58 +02:00
|
|
|
|
2001-10-14 18:13:14 +02:00
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* CFilterGraph::IFilterGraph2 methods
|
|
|
|
*
|
|
|
|
*/
|
2001-08-15 21:26:52 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnQueryInterface(IFilterGraph2* iface,REFIID riid,void** ppobj)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IFilterGraph2_fnAddRef(IFilterGraph2* iface)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
return IUnknown_AddRef(This->unk.punkControl);
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IFilterGraph2_fnRelease(IFilterGraph2* iface)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
2001-08-22 20:06:00 +02:00
|
|
|
return IUnknown_Release(This->unk.punkControl);
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnAddFilter(IFilterGraph2* iface,IBaseFilter* pFilter, LPCWSTR pName)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-09-26 00:37:04 +02:00
|
|
|
FILTER_STATE fs;
|
2001-09-07 21:46:49 +02:00
|
|
|
FILTER_INFO info;
|
2002-03-19 03:15:26 +01:00
|
|
|
IBaseFilter* pTempFilter;
|
|
|
|
FG_FilterData* pActiveFiltersNew;
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT hr;
|
|
|
|
HRESULT hrSucceeded = S_OK;
|
|
|
|
int i,iLen;
|
|
|
|
|
|
|
|
TRACE( "(%p)->(%p,%s)\n",This,pFilter,debugstr_w(pName) );
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
EnterCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
hr = IMediaFilter_GetState(CFilterGraph_IMediaFilter(This),0,&fs);
|
|
|
|
if ( hr == VFW_S_STATE_INTERMEDIATE )
|
|
|
|
hr = VFW_E_STATE_CHANGED;
|
|
|
|
if ( fs != State_Stopped )
|
|
|
|
hr = VFW_E_NOT_STOPPED;
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
TRACE( "(%p) search the specified name.\n",This );
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
if ( pName != NULL )
|
|
|
|
{
|
2002-03-19 03:15:26 +01:00
|
|
|
hr = IFilterGraph2_FindFilterByName( CFilterGraph_IFilterGraph2(This), pName, &pTempFilter );
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
IBaseFilter_Release(pTempFilter);
|
|
|
|
hrSucceeded = VFW_S_DUPLICATE_NAME;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-07 21:46:49 +02:00
|
|
|
goto name_ok;
|
2002-03-19 03:15:26 +01:00
|
|
|
}
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-10-14 18:13:14 +02:00
|
|
|
iLen = lstrlenW(pName);
|
2001-09-07 21:46:49 +02:00
|
|
|
if ( iLen > 32 )
|
|
|
|
iLen = 32;
|
|
|
|
memcpy( info.achName, pName, sizeof(WCHAR)*iLen );
|
|
|
|
info.achName[iLen] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory( &info, sizeof(info) );
|
|
|
|
hr = IBaseFilter_QueryFilterInfo( pFilter, &info );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
2002-03-19 03:15:26 +01:00
|
|
|
if ( info.pGraph != NULL )
|
|
|
|
{
|
|
|
|
IFilterGraph_Release(info.pGraph);
|
|
|
|
hr = E_FAIL; /* FIXME */
|
|
|
|
goto end;
|
|
|
|
}
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
hr = IFilterGraph2_FindFilterByName( CFilterGraph_IFilterGraph2(This), pName, &pTempFilter );
|
|
|
|
if ( hr != S_OK )
|
2001-09-07 21:46:49 +02:00
|
|
|
{
|
|
|
|
pName = info.achName;
|
|
|
|
goto name_ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* generate modified names for this filter.. */
|
2001-10-14 18:13:14 +02:00
|
|
|
iLen = lstrlenW(info.achName);
|
2001-09-07 21:46:49 +02:00
|
|
|
if ( iLen > 32 )
|
|
|
|
iLen = 32;
|
|
|
|
info.achName[iLen++] = ' ';
|
|
|
|
|
|
|
|
for ( i = 0; i <= 99; i++ )
|
|
|
|
{
|
|
|
|
info.achName[iLen+0] = (i%10) + '0';
|
|
|
|
info.achName[iLen+1] = ((i/10)%10) + '0';
|
|
|
|
info.achName[iLen+2] = 0;
|
2002-03-19 03:15:26 +01:00
|
|
|
|
|
|
|
hr = IFilterGraph2_FindFilterByName( CFilterGraph_IFilterGraph2(This), info.achName, &pTempFilter );
|
|
|
|
if ( hr != S_OK )
|
2001-09-07 21:46:49 +02:00
|
|
|
{
|
|
|
|
pName = info.achName;
|
|
|
|
goto name_ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ( pName == NULL ) ? E_FAIL : VFW_E_DUPLICATE_NAME;
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
name_ok:
|
2001-10-28 22:16:00 +01:00
|
|
|
TRACE( "(%p) add this filter - %s.\n",This,debugstr_w(pName) );
|
2001-09-26 00:37:04 +02:00
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
/* register this filter. */
|
2002-03-19 03:15:26 +01:00
|
|
|
pActiveFiltersNew = (FG_FilterData*)QUARTZ_ReallocMem(
|
|
|
|
This->m_pActiveFilters,
|
|
|
|
sizeof(FG_FilterData) * (This->m_cActiveFilters+1) );
|
|
|
|
if ( pActiveFiltersNew == NULL )
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
This->m_pActiveFilters = pActiveFiltersNew;
|
|
|
|
pActiveFiltersNew = &This->m_pActiveFilters[This->m_cActiveFilters];
|
|
|
|
|
|
|
|
pActiveFiltersNew->pFilter = NULL;
|
|
|
|
pActiveFiltersNew->pPosition = NULL;
|
|
|
|
pActiveFiltersNew->pSeeking = NULL;
|
|
|
|
pActiveFiltersNew->pwszName = NULL;
|
|
|
|
pActiveFiltersNew->cbName = 0;
|
|
|
|
|
|
|
|
pActiveFiltersNew->cbName = sizeof(WCHAR)*(lstrlenW(pName)+1);
|
|
|
|
pActiveFiltersNew->pwszName = (WCHAR*)QUARTZ_AllocMem( pActiveFiltersNew->cbName );
|
|
|
|
if ( pActiveFiltersNew->pwszName == NULL )
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
2001-09-07 21:46:49 +02:00
|
|
|
goto end;
|
2002-03-19 03:15:26 +01:00
|
|
|
}
|
|
|
|
memcpy( pActiveFiltersNew->pwszName, pName, pActiveFiltersNew->cbName );
|
|
|
|
|
|
|
|
pActiveFiltersNew->pFilter = pFilter;
|
|
|
|
IBaseFilter_AddRef(pFilter);
|
|
|
|
IBaseFilter_QueryInterface( pFilter, &IID_IMediaPosition, (void**)&pActiveFiltersNew->pPosition );
|
|
|
|
IBaseFilter_QueryInterface( pFilter, &IID_IMediaSeeking, (void**)&pActiveFiltersNew->pSeeking );
|
|
|
|
|
|
|
|
This->m_cActiveFilters ++;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
hr = IBaseFilter_JoinFilterGraph(pFilter,(IFilterGraph*)iface,pName);
|
2001-09-26 00:37:04 +02:00
|
|
|
if ( SUCCEEDED(hr) )
|
|
|
|
{
|
|
|
|
EnterCriticalSection( &This->m_csClock );
|
|
|
|
hr = IBaseFilter_SetSyncSource( pFilter, This->m_pClock );
|
|
|
|
LeaveCriticalSection( &This->m_csClock );
|
|
|
|
}
|
2001-09-07 21:46:49 +02:00
|
|
|
if ( FAILED(hr) )
|
|
|
|
{
|
2001-09-26 00:37:04 +02:00
|
|
|
IBaseFilter_JoinFilterGraph(pFilter,NULL,pName);
|
2002-03-19 03:15:26 +01:00
|
|
|
IFilterGraph2_RemoveFilter(CFilterGraph_IFilterGraph2(This),pFilter);
|
2001-09-07 21:46:49 +02:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2001-10-01 22:53:58 +02:00
|
|
|
hr = CFilterGraph_GraphChanged(This);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
hr = hrSucceeded;
|
|
|
|
end:
|
2002-03-19 03:15:26 +01:00
|
|
|
LeaveCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
TRACE( "(%p) return %08lx\n", This, hr );
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnRemoveFilter(IFilterGraph2* iface,IBaseFilter* pFilter)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-09-26 00:37:04 +02:00
|
|
|
FILTER_STATE fs;
|
2002-03-19 03:15:26 +01:00
|
|
|
DWORD n,copy;
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT hr = NOERROR;
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
TRACE( "(%p)->(%p)\n",This,pFilter );
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
EnterCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
hr = IMediaFilter_GetState(CFilterGraph_IMediaFilter(This),0,&fs);
|
|
|
|
if ( hr == VFW_S_STATE_INTERMEDIATE )
|
|
|
|
hr = VFW_E_STATE_CHANGED;
|
|
|
|
if ( fs != State_Stopped )
|
|
|
|
hr = VFW_E_NOT_STOPPED;
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
hr = S_FALSE; /* FIXME? */
|
2002-03-19 03:15:26 +01:00
|
|
|
|
|
|
|
for ( n = 0; n < This->m_cActiveFilters; n++ )
|
2001-09-07 21:46:49 +02:00
|
|
|
{
|
2002-03-19 03:15:26 +01:00
|
|
|
if ( This->m_pActiveFilters[n].pFilter == pFilter )
|
|
|
|
{
|
|
|
|
CFilterGraph_DisconnectAllPins(pFilter);
|
|
|
|
(void)IBaseFilter_SetSyncSource( pFilter, NULL );
|
|
|
|
(void)IBaseFilter_JoinFilterGraph(
|
|
|
|
pFilter, NULL, This->m_pActiveFilters[n].pwszName );
|
|
|
|
|
|
|
|
if ( This->m_pActiveFilters[n].pFilter != NULL )
|
2002-04-14 21:32:31 +02:00
|
|
|
IBaseFilter_Release(This->m_pActiveFilters[n].pFilter);
|
2002-03-19 03:15:26 +01:00
|
|
|
if ( This->m_pActiveFilters[n].pPosition != NULL )
|
|
|
|
IMediaPosition_Release(This->m_pActiveFilters[n].pPosition);
|
|
|
|
if ( This->m_pActiveFilters[n].pSeeking != NULL )
|
|
|
|
IMediaSeeking_Release(This->m_pActiveFilters[n].pSeeking);
|
|
|
|
if ( This->m_pActiveFilters[n].pwszName != NULL )
|
|
|
|
QUARTZ_FreeMem(This->m_pActiveFilters[n].pwszName);
|
|
|
|
|
|
|
|
copy = This->m_cActiveFilters - n - 1;
|
|
|
|
if ( copy > 0 )
|
|
|
|
memmove( &This->m_pActiveFilters[n],
|
|
|
|
&This->m_pActiveFilters[n+1],
|
|
|
|
sizeof(FG_FilterData) * copy );
|
|
|
|
This->m_cActiveFilters --;
|
|
|
|
|
|
|
|
hr = CFilterGraph_GraphChanged(This);
|
|
|
|
break;
|
|
|
|
}
|
2001-09-07 21:46:49 +02:00
|
|
|
}
|
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
end:;
|
2002-03-19 03:15:26 +01:00
|
|
|
LeaveCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnEnumFilters(IFilterGraph2* iface,IEnumFilters** ppEnum)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2002-03-19 03:15:26 +01:00
|
|
|
QUARTZ_CompList* pList = NULL;
|
|
|
|
DWORD n;
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
TRACE( "(%p)->(%p)\n",This,ppEnum );
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
EnterCriticalSection( &This->m_csFilters );
|
|
|
|
|
|
|
|
pList = QUARTZ_CompList_Alloc();
|
|
|
|
if ( pList == NULL )
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
for ( n = 0; n < This->m_cActiveFilters; n++ )
|
|
|
|
{
|
|
|
|
hr = QUARTZ_CompList_AddTailComp(
|
|
|
|
pList, (IUnknown*)This->m_pActiveFilters[n].pFilter, NULL, 0 );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto err;
|
|
|
|
}
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
hr = QUARTZ_CreateEnumUnknown(
|
2002-03-19 03:15:26 +01:00
|
|
|
&IID_IEnumFilters, (void**)ppEnum, pList );
|
|
|
|
err:
|
|
|
|
if ( pList != NULL )
|
|
|
|
QUARTZ_CompList_Free( pList );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
LeaveCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnFindFilterByName(IFilterGraph2* iface,LPCWSTR pName,IBaseFilter** ppFilter)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2002-03-19 03:15:26 +01:00
|
|
|
DWORD n;
|
|
|
|
DWORD cbName;
|
|
|
|
HRESULT hr = E_FAIL; /* FIXME */
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
TRACE( "(%p)->(%s,%p)\n",This,debugstr_w(pName),ppFilter );
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
if ( pName == NULL || ppFilter == NULL )
|
2001-09-07 21:46:49 +02:00
|
|
|
return E_POINTER;
|
|
|
|
*ppFilter = NULL;
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
cbName = sizeof(WCHAR) * (lstrlenW(pName) + 1);
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
EnterCriticalSection( &This->m_csFilters );
|
|
|
|
|
|
|
|
for ( n = 0; n < This->m_cActiveFilters; n++ )
|
2001-09-07 21:46:49 +02:00
|
|
|
{
|
2002-03-19 03:15:26 +01:00
|
|
|
if ( This->m_pActiveFilters[n].cbName == cbName &&
|
|
|
|
!memcmp( This->m_pActiveFilters[n].pwszName, pName, cbName ) )
|
|
|
|
{
|
|
|
|
*ppFilter = This->m_pActiveFilters[n].pFilter;
|
|
|
|
IBaseFilter_AddRef(*ppFilter);
|
|
|
|
hr = NOERROR;
|
|
|
|
}
|
2001-09-07 21:46:49 +02:00
|
|
|
}
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
LeaveCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnConnectDirect(IFilterGraph2* iface,IPin* pOut,IPin* pIn,const AM_MEDIA_TYPE* pmt)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-09-07 21:46:49 +02:00
|
|
|
IPin* pConnTo;
|
|
|
|
PIN_INFO infoIn;
|
|
|
|
PIN_INFO infoOut;
|
|
|
|
FILTER_INFO finfoIn;
|
|
|
|
FILTER_INFO finfoOut;
|
2001-10-14 18:13:14 +02:00
|
|
|
FILTER_STATE fs;
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE( "(%p)->(%p,%p,%p)\n",This,pOut,pIn,pmt );
|
|
|
|
|
|
|
|
infoIn.pFilter = NULL;
|
|
|
|
infoOut.pFilter = NULL;
|
|
|
|
finfoIn.pGraph = NULL;
|
|
|
|
finfoOut.pGraph = NULL;
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
EnterCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-10-14 18:13:14 +02:00
|
|
|
hr = IMediaFilter_GetState(CFilterGraph_IMediaFilter(This),0,&fs);
|
|
|
|
if ( hr == VFW_S_STATE_INTERMEDIATE )
|
|
|
|
hr = VFW_E_STATE_CHANGED;
|
|
|
|
if ( fs != State_Stopped )
|
|
|
|
hr = VFW_E_NOT_STOPPED;
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
hr = IPin_QueryPinInfo(pIn,&infoIn);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
hr = IPin_QueryPinInfo(pOut,&infoOut);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
if ( infoIn.pFilter == NULL || infoOut.pFilter == NULL ||
|
|
|
|
infoIn.dir != PINDIR_INPUT || infoOut.dir != PINDIR_OUTPUT )
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IBaseFilter_QueryFilterInfo(infoIn.pFilter,&finfoIn);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
hr = IBaseFilter_QueryFilterInfo(infoOut.pFilter,&finfoOut);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
if ( finfoIn.pGraph != ((IFilterGraph*)iface) ||
|
|
|
|
finfoOut.pGraph != ((IFilterGraph*)iface) )
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
pConnTo = NULL;
|
|
|
|
hr = IPin_ConnectedTo(pIn,&pConnTo);
|
2001-09-26 00:37:04 +02:00
|
|
|
if ( hr == NOERROR && pConnTo != NULL )
|
2001-09-07 21:46:49 +02:00
|
|
|
{
|
|
|
|
IPin_Release(pConnTo);
|
2001-09-26 00:37:04 +02:00
|
|
|
hr = VFW_E_ALREADY_CONNECTED;
|
2001-09-07 21:46:49 +02:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
pConnTo = NULL;
|
|
|
|
hr = IPin_ConnectedTo(pOut,&pConnTo);
|
2001-09-26 00:37:04 +02:00
|
|
|
if ( hr == NOERROR && pConnTo != NULL )
|
2001-09-07 21:46:49 +02:00
|
|
|
{
|
|
|
|
IPin_Release(pConnTo);
|
2001-09-26 00:37:04 +02:00
|
|
|
hr = VFW_E_ALREADY_CONNECTED;
|
2001-09-07 21:46:49 +02:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
TRACE("(%p) try to connect %p<->%p\n",This,pIn,pOut);
|
2001-09-07 21:46:49 +02:00
|
|
|
hr = IPin_Connect(pOut,pIn,pmt);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
{
|
2001-09-26 00:37:04 +02:00
|
|
|
TRACE("(%p)->Connect(%p,%p) hr = %08lx\n",pOut,pIn,pmt,hr);
|
|
|
|
IPin_Disconnect(pOut);
|
2001-09-07 21:46:49 +02:00
|
|
|
IPin_Disconnect(pIn);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2001-10-01 22:53:58 +02:00
|
|
|
hr = CFilterGraph_GraphChanged(This);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
end:
|
2002-03-19 03:15:26 +01:00
|
|
|
LeaveCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
if ( infoIn.pFilter != NULL )
|
|
|
|
IBaseFilter_Release(infoIn.pFilter);
|
|
|
|
if ( infoOut.pFilter != NULL )
|
|
|
|
IBaseFilter_Release(infoOut.pFilter);
|
|
|
|
if ( finfoIn.pGraph != NULL )
|
|
|
|
IFilterGraph_Release(finfoIn.pGraph);
|
|
|
|
if ( finfoOut.pGraph != NULL )
|
|
|
|
IFilterGraph_Release(finfoOut.pGraph);
|
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnReconnect(IFilterGraph2* iface,IPin* pPin)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
TRACE( "(%p)->(%p)\n",This,pPin );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
return IFilterGraph2_ReconnectEx(iface,pPin,NULL);
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnDisconnect(IFilterGraph2* iface,IPin* pPin)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-09-26 00:37:04 +02:00
|
|
|
IPin* pConnTo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE( "(%p)->(%p)\n",This,pPin );
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
EnterCriticalSection( &This->m_csFilters );
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
pConnTo = NULL;
|
|
|
|
hr = IPin_ConnectedTo(pPin,&pConnTo);
|
|
|
|
if ( hr == NOERROR && pConnTo != NULL )
|
|
|
|
{
|
|
|
|
IPin_Disconnect(pConnTo);
|
|
|
|
IPin_Release(pConnTo);
|
|
|
|
}
|
|
|
|
hr = IPin_Disconnect(pPin);
|
2001-10-01 22:53:58 +02:00
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-10-01 22:53:58 +02:00
|
|
|
hr = CFilterGraph_GraphChanged(This);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-10-01 22:53:58 +02:00
|
|
|
end:
|
2002-03-19 03:15:26 +01:00
|
|
|
LeaveCriticalSection( &This->m_csFilters );
|
2001-09-26 00:37:04 +02:00
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnSetDefaultSyncSource(IFilterGraph2* iface)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-09-26 00:37:04 +02:00
|
|
|
IUnknown* punk;
|
|
|
|
IReferenceClock* pClock;
|
|
|
|
HRESULT hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
2001-09-26 00:37:04 +02:00
|
|
|
|
2001-10-14 18:13:14 +02:00
|
|
|
/* FIXME - search all filters from renderer. */
|
2001-09-26 00:37:04 +02:00
|
|
|
|
|
|
|
hr = QUARTZ_CreateSystemClock( NULL, (void**)&punk );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
hr = IUnknown_QueryInterface( punk, &IID_IReferenceClock, (void**)&pClock ); IUnknown_Release( punk );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IMediaFilter_SetSyncSource(
|
|
|
|
CFilterGraph_IMediaFilter(This), pClock );
|
|
|
|
IReferenceClock_Release( pClock );
|
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnConnect(IFilterGraph2* iface,IPin* pOut,IPin* pIn)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-10-28 22:16:00 +01:00
|
|
|
IFilterMapper2* pMap2 = NULL;
|
|
|
|
IEnumMoniker* pEnumMon = NULL;
|
|
|
|
IMoniker* pMon = NULL;
|
|
|
|
IBaseFilter* pFilter = NULL;
|
|
|
|
IEnumPins* pEnumPin = NULL;
|
|
|
|
IPin* pPinTry = NULL;
|
|
|
|
PIN_INFO info;
|
|
|
|
PIN_DIRECTION pindir;
|
|
|
|
ULONG cReturned;
|
|
|
|
BOOL bTryConnect;
|
|
|
|
BOOL bConnected = FALSE;
|
|
|
|
CLSID clsidOutFilter;
|
|
|
|
CLSID clsidInFilter;
|
|
|
|
CLSID clsid;
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE( "(%p)->(%p,%p)\n",This,pOut,pIn );
|
|
|
|
|
|
|
|
/* At first, try to connect directly. */
|
|
|
|
hr = IFilterGraph_ConnectDirect(iface,pOut,pIn,NULL);
|
|
|
|
if ( hr == NOERROR )
|
|
|
|
return NOERROR;
|
|
|
|
|
|
|
|
/* FIXME - try to connect indirectly. */
|
2002-04-14 21:32:31 +02:00
|
|
|
FIXME( "(%p)->(%p,%p) not fully implemented\n",This,pOut,pIn );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-10-28 22:16:00 +01:00
|
|
|
info.pFilter = NULL;
|
|
|
|
hr = IPin_QueryPinInfo(pOut,&info);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
if ( info.pFilter == NULL )
|
|
|
|
return E_FAIL;
|
|
|
|
hr = IBaseFilter_GetClassID(info.pFilter,&clsidOutFilter);
|
|
|
|
IBaseFilter_Release(info.pFilter);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2001-10-28 22:16:00 +01:00
|
|
|
info.pFilter = NULL;
|
|
|
|
hr = IPin_QueryPinInfo(pIn,&info);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
if ( info.pFilter == NULL )
|
|
|
|
return E_FAIL;
|
|
|
|
hr = IBaseFilter_GetClassID(info.pFilter,&clsidInFilter);
|
|
|
|
IBaseFilter_Release(info.pFilter);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* FIXME - try to connect with unused filters. */
|
|
|
|
/* FIXME - try to connect with cached filters. */
|
|
|
|
/* FIXME - enumerate transform filters and try to connect */
|
|
|
|
hr = CoCreateInstance(
|
|
|
|
&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IFilterMapper2, (void**)&pMap2 );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
hr = IFilterMapper2_EnumMatchingFilters(
|
|
|
|
pMap2,&pEnumMon,0,FALSE,MERIT_DO_NOT_USE+1,
|
|
|
|
TRUE,0,NULL,NULL,NULL,FALSE,
|
|
|
|
TRUE,0,NULL,NULL,NULL);
|
|
|
|
IFilterMapper2_Release(pMap2);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
TRACE("try to connect indirectly\n");
|
|
|
|
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
while ( !bConnected && hr == S_OK )
|
|
|
|
{
|
|
|
|
hr = IEnumMoniker_Next(pEnumMon,1,&pMon,&cReturned);
|
|
|
|
if ( hr != S_OK )
|
|
|
|
break;
|
|
|
|
hr = IMoniker_BindToObject(pMon,NULL,NULL,&IID_IBaseFilter,(void**)&pFilter );
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
hr = IBaseFilter_GetClassID(pFilter,&clsid);
|
|
|
|
if ( hr == S_OK &&
|
|
|
|
( IsEqualGUID(&clsidOutFilter,&clsid) || IsEqualGUID(&clsidInFilter,&clsid) ) )
|
|
|
|
hr = S_FALSE;
|
|
|
|
else
|
|
|
|
hr = IFilterGraph2_AddFilter(iface,pFilter,NULL);
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
bTryConnect = FALSE;
|
|
|
|
hr = IBaseFilter_EnumPins(pFilter,&pEnumPin);
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while ( !bTryConnect )
|
|
|
|
{
|
|
|
|
hr = IEnumPins_Next(pEnumPin,1,&pPinTry,&cReturned);
|
|
|
|
if ( hr != S_OK )
|
|
|
|
break;
|
|
|
|
hr = IPin_QueryDirection(pPinTry,&pindir);
|
|
|
|
if ( hr == S_OK && pindir == PINDIR_INPUT )
|
|
|
|
{
|
|
|
|
/* try to connect directly. */
|
|
|
|
hr = IFilterGraph2_ConnectDirect(iface,pOut,pPinTry,NULL);
|
|
|
|
if ( hr == S_OK )
|
|
|
|
bTryConnect = TRUE;
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
IPin_Release(pPinTry); pPinTry = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IEnumPins_Release(pEnumPin); pEnumPin = NULL;
|
|
|
|
}
|
|
|
|
TRACE("TryConnect %d\n",bTryConnect);
|
|
|
|
|
|
|
|
if ( bTryConnect )
|
|
|
|
{
|
|
|
|
hr = IBaseFilter_EnumPins(pFilter,&pEnumPin);
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
while ( !bConnected )
|
|
|
|
{
|
|
|
|
hr = IEnumPins_Next(pEnumPin,1,&pPinTry,&cReturned);
|
|
|
|
if ( hr != S_OK )
|
|
|
|
break;
|
|
|
|
hr = IPin_QueryDirection(pPinTry,&pindir);
|
|
|
|
if ( hr == S_OK && pindir == PINDIR_OUTPUT )
|
|
|
|
{
|
|
|
|
/* try to connect indirectly. */
|
|
|
|
hr = IFilterGraph2_Connect(iface,pPinTry,pIn);
|
|
|
|
if ( hr == S_OK )
|
|
|
|
bConnected = TRUE;
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
IPin_Release(pPinTry); pPinTry = NULL;
|
|
|
|
}
|
|
|
|
IEnumPins_Release(pEnumPin); pEnumPin = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bConnected )
|
|
|
|
hr = IFilterGraph2_RemoveFilter(iface,pFilter);
|
|
|
|
}
|
|
|
|
IBaseFilter_Release(pFilter); pFilter = NULL;
|
|
|
|
if ( SUCCEEDED(hr) )
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
2002-03-19 03:15:26 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
2001-10-28 22:16:00 +01:00
|
|
|
IMoniker_Release(pMon); pMon = NULL;
|
|
|
|
}
|
|
|
|
IEnumMoniker_Release(pEnumMon); pEnumMon = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( SUCCEEDED(hr) && !bConnected )
|
|
|
|
hr = VFW_E_CANNOT_CONNECT;
|
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnRender(IFilterGraph2* iface,IPin* pOut)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-10-28 22:16:00 +01:00
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
TRACE( "(%p)->(%p)\n",This,pOut);
|
2001-10-28 22:16:00 +01:00
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
return IFilterGraph2_RenderEx( CFilterGraph_IFilterGraph2(This), pOut, 0, NULL );
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnRenderFile(IFilterGraph2* iface,LPCWSTR lpFileName,LPCWSTR lpPlayList)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT hr;
|
|
|
|
IBaseFilter* pFilter = NULL;
|
|
|
|
IEnumPins* pEnum = NULL;
|
|
|
|
IPin* pPin;
|
|
|
|
ULONG cFetched;
|
|
|
|
PIN_DIRECTION dir;
|
|
|
|
ULONG cTryToRender;
|
|
|
|
ULONG cActRender;
|
|
|
|
|
|
|
|
TRACE( "(%p)->(%s,%s)\n",This,
|
|
|
|
debugstr_w(lpFileName),debugstr_w(lpPlayList) );
|
|
|
|
|
|
|
|
if ( lpPlayList != NULL )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
pFilter = NULL;
|
|
|
|
hr = IFilterGraph2_AddSourceFilter(iface,lpFileName,NULL,&pFilter);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
if ( pFilter == NULL )
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
goto end;
|
|
|
|
}
|
2001-10-28 22:16:00 +01:00
|
|
|
TRACE("(%p) source filter %p\n",This,pFilter);
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
pEnum = NULL;
|
|
|
|
hr = IBaseFilter_EnumPins( pFilter, &pEnum );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
if ( pEnum == NULL )
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
cTryToRender = 0;
|
|
|
|
cActRender = 0;
|
|
|
|
|
|
|
|
while ( 1 )
|
|
|
|
{
|
|
|
|
pPin = NULL;
|
|
|
|
cFetched = 0;
|
|
|
|
hr = IEnumPins_Next( pEnum, 1, &pPin, &cFetched );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
goto end;
|
|
|
|
if ( hr != NOERROR || pPin == NULL || cFetched != 1 )
|
|
|
|
{
|
|
|
|
hr = NOERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hr = IPin_QueryDirection( pPin, &dir );
|
|
|
|
if ( hr == NOERROR && dir == PINDIR_OUTPUT )
|
|
|
|
{
|
|
|
|
cTryToRender ++;
|
|
|
|
hr = IFilterGraph2_Render( iface, pPin );
|
|
|
|
if ( hr == NOERROR )
|
|
|
|
cActRender ++;
|
|
|
|
}
|
|
|
|
IPin_Release( pPin );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( hr == NOERROR )
|
|
|
|
{
|
|
|
|
if ( cTryToRender > cActRender )
|
|
|
|
hr = VFW_S_PARTIAL_RENDER;
|
|
|
|
if ( cActRender == 0 )
|
|
|
|
hr = E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
if ( pEnum != NULL )
|
|
|
|
IEnumPins_Release( pEnum );
|
|
|
|
if ( pFilter != NULL )
|
|
|
|
IBaseFilter_Release( pFilter );
|
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnAddSourceFilter(IFilterGraph2* iface,LPCWSTR lpFileName,LPCWSTR lpFilterName,IBaseFilter** ppBaseFilter)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-10-28 22:16:00 +01:00
|
|
|
HRESULT hr;
|
|
|
|
BYTE bStartData[512];
|
|
|
|
DWORD cbStartData;
|
|
|
|
AM_MEDIA_TYPE mt;
|
|
|
|
CLSID clsidSource;
|
|
|
|
IFileSourceFilter* pSource;
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2002-04-14 21:32:31 +02:00
|
|
|
TRACE( "(%p)->(%s,%s,%p)\n",This,
|
2001-09-07 21:46:49 +02:00
|
|
|
debugstr_w(lpFileName),debugstr_w(lpFilterName),ppBaseFilter );
|
2001-10-28 22:16:00 +01:00
|
|
|
|
|
|
|
if ( lpFileName == NULL || ppBaseFilter == NULL )
|
|
|
|
return E_POINTER;
|
|
|
|
*ppBaseFilter = NULL;
|
|
|
|
|
|
|
|
hr = QUARTZ_PeekFile( lpFileName, bStartData, 512, &cbStartData );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
{
|
|
|
|
FIXME("cannot open %s (NOTE: URL is not implemented)\n", debugstr_w(lpFileName));
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ZeroMemory( &mt, sizeof(AM_MEDIA_TYPE) );
|
|
|
|
mt.bFixedSizeSamples = 1;
|
|
|
|
mt.lSampleSize = 1;
|
|
|
|
memcpy( &mt.majortype, &MEDIATYPE_Stream, sizeof(GUID) );
|
|
|
|
memcpy( &mt.subtype, &MEDIASUBTYPE_NULL, sizeof(GUID) );
|
|
|
|
memcpy( &mt.formattype, &FORMAT_None, sizeof(GUID) );
|
|
|
|
hr = QUARTZ_GetSourceTypeFromData(
|
|
|
|
bStartData, cbStartData,
|
|
|
|
&mt.majortype, &mt.subtype, &clsidSource );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
{
|
|
|
|
ERR("QUARTZ_GetSourceTypeFromData() failed - return %08lx\n",hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
if ( hr != S_OK )
|
|
|
|
{
|
|
|
|
FIXME( "file %s - unknown format\n", debugstr_w(lpFileName) );
|
|
|
|
return VFW_E_INVALID_FILE_FORMAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CoCreateInstance(
|
|
|
|
&clsidSource, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IBaseFilter, (void**)ppBaseFilter );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
hr = IBaseFilter_QueryInterface(*ppBaseFilter,&IID_IFileSourceFilter,(void**)&pSource);
|
|
|
|
if ( SUCCEEDED(hr) )
|
|
|
|
{
|
|
|
|
hr = IFileSourceFilter_Load(pSource,lpFileName,&mt);
|
|
|
|
IFileSourceFilter_Release(pSource);
|
|
|
|
}
|
|
|
|
if ( SUCCEEDED(hr) )
|
|
|
|
hr = IFilterGraph2_AddFilter(iface,*ppBaseFilter,lpFilterName);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
{
|
|
|
|
IBaseFilter_Release(*ppBaseFilter);
|
|
|
|
*ppBaseFilter = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnSetLogFile(IFilterGraph2* iface,DWORD_PTR hFile)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
2002-03-19 03:15:26 +01:00
|
|
|
|
|
|
|
return S_OK; /* no debug output */
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnAbort(IFilterGraph2* iface)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
2002-03-19 03:15:26 +01:00
|
|
|
|
|
|
|
/* FIXME - abort the current asynchronous task. */
|
|
|
|
|
|
|
|
return S_OK;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnShouldOperationContinue(IFilterGraph2* iface)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
2002-03-19 03:15:26 +01:00
|
|
|
|
2001-08-15 21:26:52 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnAddSourceFilterForMoniker(IFilterGraph2* iface,IMoniker* pMon,IBindCtx* pCtx,LPCWSTR pFilterName,IBaseFilter** ppFilter)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
|
|
|
|
|
|
|
FIXME( "(%p)->() stub!\n", This );
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IFilterGraph2_fnReconnectEx(IFilterGraph2* iface,IPin* pPin,const AM_MEDIA_TYPE* pmt)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2001-10-01 22:53:58 +02:00
|
|
|
HRESULT hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
FIXME( "(%p)->(%p,%p) stub!\n",This,pPin,pmt );
|
|
|
|
|
2001-09-26 00:37:04 +02:00
|
|
|
/* reconnect asynchronously. */
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
EnterCriticalSection( &This->m_csFilters );
|
2001-10-01 22:53:58 +02:00
|
|
|
hr = CFilterGraph_GraphChanged(This);
|
2002-03-19 03:15:26 +01:00
|
|
|
LeaveCriticalSection( &This->m_csFilters );
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2001-08-15 21:26:52 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
2002-03-19 03:15:26 +01:00
|
|
|
IFilterGraph2_fnRenderEx(IFilterGraph2* iface,IPin* pOut,DWORD dwFlags,DWORD* pdwReserved)
|
2001-08-15 21:26:52 +02:00
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,fgraph);
|
2002-03-19 03:15:26 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IFilterMapper2* pMap2 = NULL;
|
|
|
|
IEnumMoniker* pEnumMon = NULL;
|
|
|
|
IMoniker* pMon = NULL;
|
|
|
|
IBaseFilter* pFilter = NULL;
|
|
|
|
IEnumPins* pEnumPin = NULL;
|
|
|
|
IPin* pPin = NULL;
|
|
|
|
PIN_DIRECTION pindir;
|
|
|
|
BOOL bRendered = FALSE;
|
|
|
|
ULONG cReturned;
|
2001-08-15 21:26:52 +02:00
|
|
|
|
2002-04-14 21:32:31 +02:00
|
|
|
TRACE( "(%p)->(%p,%08lx,%p)\n",This,pPin,dwFlags,pdwReserved);
|
2002-03-19 03:15:26 +01:00
|
|
|
|
|
|
|
if ( pdwReserved != NULL )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if ( dwFlags != 0 )
|
|
|
|
{
|
2002-04-14 21:32:31 +02:00
|
|
|
FIXME( "dwFlags != 0 (0x%08lx)\n", dwFlags );
|
2002-03-19 03:15:26 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME - must be locked */
|
|
|
|
/*EnterCriticalSection( &This->m_csFilters );*/
|
|
|
|
|
|
|
|
if ( pOut == NULL )
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(
|
|
|
|
&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IFilterMapper2, (void**)&pMap2 );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
hr = IFilterMapper2_EnumMatchingFilters(
|
|
|
|
pMap2,&pEnumMon,0,FALSE,MERIT_DO_NOT_USE+1,
|
|
|
|
TRUE,0,NULL,NULL,NULL,TRUE,
|
|
|
|
FALSE,0,NULL,NULL,NULL);
|
|
|
|
IFilterMapper2_Release(pMap2);
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return hr;
|
|
|
|
TRACE("try to render pin\n");
|
|
|
|
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
/* try to render pin. */
|
|
|
|
while ( !bRendered && hr == S_OK )
|
|
|
|
{
|
|
|
|
hr = IEnumMoniker_Next(pEnumMon,1,&pMon,&cReturned);
|
|
|
|
if ( hr != S_OK )
|
|
|
|
break;
|
|
|
|
hr = IMoniker_BindToObject(pMon,NULL,NULL,&IID_IBaseFilter,(void**)&pFilter );
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
hr = IFilterGraph2_AddFilter(iface,pFilter,NULL);
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
hr = IBaseFilter_EnumPins(pFilter,&pEnumPin);
|
|
|
|
if ( hr == S_OK )
|
|
|
|
{
|
|
|
|
while ( !bRendered )
|
|
|
|
{
|
|
|
|
hr = IEnumPins_Next(pEnumPin,1,&pPin,&cReturned);
|
|
|
|
if ( hr != S_OK )
|
|
|
|
break;
|
|
|
|
hr = IPin_QueryDirection(pPin,&pindir);
|
|
|
|
if ( hr == S_OK && pindir == PINDIR_INPUT )
|
|
|
|
{
|
|
|
|
/* try to connect. */
|
|
|
|
hr = IFilterGraph2_Connect(iface,pOut,pPin);
|
|
|
|
if ( hr == S_OK )
|
|
|
|
bRendered = TRUE;
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
IPin_Release(pPin); pPin = NULL;
|
|
|
|
}
|
|
|
|
IEnumPins_Release(pEnumPin); pEnumPin = NULL;
|
|
|
|
}
|
|
|
|
if ( !bRendered )
|
|
|
|
hr = IFilterGraph2_RemoveFilter(iface,pFilter);
|
|
|
|
}
|
|
|
|
IBaseFilter_Release(pFilter); pFilter = NULL;
|
|
|
|
if ( SUCCEEDED(hr) )
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
IMoniker_Release(pMon); pMon = NULL;
|
|
|
|
}
|
|
|
|
IEnumMoniker_Release(pEnumMon); pEnumMon = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bRendered )
|
|
|
|
{
|
|
|
|
/* successfully rendered(but may be partial now) */
|
|
|
|
hr = S_OK;
|
|
|
|
|
|
|
|
/* FIXME - try to render all inserted filters. */
|
|
|
|
/* hr = VFW_S_PARTIAL_RENDER; */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( SUCCEEDED(hr) )
|
|
|
|
hr = VFW_E_CANNOT_RENDER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*LeaveCriticalSection( &This->m_csFilters );*/
|
|
|
|
|
|
|
|
return hr;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IFilterGraph2) ifgraph =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
/* IUnknown fields */
|
|
|
|
IFilterGraph2_fnQueryInterface,
|
|
|
|
IFilterGraph2_fnAddRef,
|
|
|
|
IFilterGraph2_fnRelease,
|
|
|
|
/* IFilterGraph fields */
|
|
|
|
IFilterGraph2_fnAddFilter,
|
|
|
|
IFilterGraph2_fnRemoveFilter,
|
|
|
|
IFilterGraph2_fnEnumFilters,
|
|
|
|
IFilterGraph2_fnFindFilterByName,
|
|
|
|
IFilterGraph2_fnConnectDirect,
|
|
|
|
IFilterGraph2_fnReconnect,
|
|
|
|
IFilterGraph2_fnDisconnect,
|
|
|
|
IFilterGraph2_fnSetDefaultSyncSource,
|
|
|
|
/* IGraphBuilder fields */
|
|
|
|
IFilterGraph2_fnConnect,
|
|
|
|
IFilterGraph2_fnRender,
|
|
|
|
IFilterGraph2_fnRenderFile,
|
|
|
|
IFilterGraph2_fnAddSourceFilter,
|
|
|
|
IFilterGraph2_fnSetLogFile,
|
|
|
|
IFilterGraph2_fnAbort,
|
|
|
|
IFilterGraph2_fnShouldOperationContinue,
|
|
|
|
/* IFilterGraph2 fields */
|
|
|
|
IFilterGraph2_fnAddSourceFilterForMoniker,
|
|
|
|
IFilterGraph2_fnReconnectEx,
|
|
|
|
IFilterGraph2_fnRenderEx,
|
|
|
|
};
|
|
|
|
|
2001-09-07 21:46:49 +02:00
|
|
|
HRESULT CFilterGraph_InitIFilterGraph2( CFilterGraph* pfg )
|
2001-08-15 21:26:52 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pfg);
|
|
|
|
ICOM_VTBL(&pfg->fgraph) = &ifgraph;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
InitializeCriticalSection( &pfg->m_csFilters );
|
|
|
|
pfg->m_cActiveFilters = 0;
|
|
|
|
pfg->m_pActiveFilters = NULL;
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
return NOERROR;
|
2001-08-15 21:26:52 +02:00
|
|
|
}
|
2001-08-28 19:25:39 +02:00
|
|
|
|
|
|
|
void CFilterGraph_UninitIFilterGraph2( CFilterGraph* pfg )
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pfg);
|
2001-09-07 21:46:49 +02:00
|
|
|
|
|
|
|
/* remove all filters... */
|
2002-03-19 03:15:26 +01:00
|
|
|
while ( pfg->m_cActiveFilters > 0 )
|
2001-09-07 21:46:49 +02:00
|
|
|
{
|
2001-09-26 00:37:04 +02:00
|
|
|
IFilterGraph2_RemoveFilter(
|
2002-03-19 03:15:26 +01:00
|
|
|
CFilterGraph_IFilterGraph2(pfg),
|
|
|
|
pfg->m_pActiveFilters[pfg->m_cActiveFilters-1].pFilter );
|
2001-09-07 21:46:49 +02:00
|
|
|
}
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
if ( pfg->m_pActiveFilters != NULL )
|
|
|
|
QUARTZ_FreeMem( pfg->m_pActiveFilters );
|
|
|
|
|
|
|
|
DeleteCriticalSection( &pfg->m_csFilters );
|
2001-08-28 19:25:39 +02:00
|
|
|
}
|
2001-10-14 18:13:14 +02:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* CFilterGraph::IGraphVersion methods
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IGraphVersion_fnQueryInterface(IGraphVersion* iface,REFIID riid,void** ppobj)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,graphversion);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IGraphVersion_fnAddRef(IGraphVersion* iface)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,graphversion);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
|
|
|
return IUnknown_AddRef(This->unk.punkControl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
IGraphVersion_fnRelease(IGraphVersion* iface)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,graphversion);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
|
|
|
return IUnknown_Release(This->unk.punkControl);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
IGraphVersion_fnQueryVersion(IGraphVersion* iface,LONG* plVersion)
|
|
|
|
{
|
|
|
|
CFilterGraph_THIS(iface,graphversion);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n",This,plVersion);
|
|
|
|
|
|
|
|
if ( plVersion == NULL )
|
|
|
|
return E_POINTER;
|
|
|
|
|
2002-03-19 03:15:26 +01:00
|
|
|
EnterCriticalSection( &This->m_csFilters );
|
2001-10-14 18:13:14 +02:00
|
|
|
*plVersion = This->m_lGraphVersion;
|
2002-03-19 03:15:26 +01:00
|
|
|
LeaveCriticalSection( &This->m_csFilters );
|
2001-10-14 18:13:14 +02:00
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IGraphVersion) igraphversion =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
/* IUnknown fields */
|
|
|
|
IGraphVersion_fnQueryInterface,
|
|
|
|
IGraphVersion_fnAddRef,
|
|
|
|
IGraphVersion_fnRelease,
|
|
|
|
/* IGraphVersion fields */
|
|
|
|
IGraphVersion_fnQueryVersion,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT CFilterGraph_InitIGraphVersion( CFilterGraph* pfg )
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pfg);
|
|
|
|
ICOM_VTBL(&pfg->graphversion) = &igraphversion;
|
|
|
|
|
|
|
|
pfg->m_lGraphVersion = 1;
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFilterGraph_UninitIGraphVersion( CFilterGraph* pfg )
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pfg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|