2005-02-08 13:43:59 +00:00
|
|
|
/*
|
|
|
|
* Parser (Base for parsers and splitters)
|
|
|
|
*
|
|
|
|
* Copyright 2003 Robert Shearman
|
|
|
|
* Copyright 2004-2005 Christian Costa
|
|
|
|
*
|
|
|
|
* 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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-02-08 13:43:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
#include "control_private.h"
|
|
|
|
#include "pin.h"
|
|
|
|
|
|
|
|
#include "vfwmsgs.h"
|
|
|
|
#include "amvideo.h"
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "parser.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
|
|
|
static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
|
2005-06-06 19:50:35 +00:00
|
|
|
static const IMediaSeekingVtbl Parser_Seeking_Vtbl;
|
|
|
|
static const IPinVtbl Parser_OutputPin_Vtbl;
|
|
|
|
static const IPinVtbl Parser_InputPin_Vtbl;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
static HRESULT Parser_OutputPin_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt);
|
2008-03-25 23:11:22 +00:00
|
|
|
static HRESULT Parser_ChangeCurrent(IBaseFilter *iface);
|
2008-03-18 23:05:00 +00:00
|
|
|
static HRESULT Parser_ChangeStop(IBaseFilter *iface);
|
|
|
|
static HRESULT Parser_ChangeRate(IBaseFilter *iface);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-03-18 23:05:00 +00:00
|
|
|
static inline ParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
|
2005-07-27 15:14:18 +00:00
|
|
|
{
|
2008-03-18 23:05:00 +00:00
|
|
|
return (ParserImpl *)((char*)iface - FIELD_OFFSET(ParserImpl, mediaSeeking.lpVtbl));
|
2005-07-27 15:14:18 +00:00
|
|
|
}
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-04-25 21:59:05 +00:00
|
|
|
HRESULT Parser_Create(ParserImpl* pParser, const IBaseFilterVtbl *Parser_Vtbl, const CLSID* pClsid, PFN_PROCESS_SAMPLE fnProcessSample, PFN_QUERY_ACCEPT fnQueryAccept, PFN_PRE_CONNECT fnPreConnect, PFN_CLEANUP fnCleanup, PFN_DISCONNECT fnDisconnect, REQUESTPROC fnRequest, STOPPROCESSPROC fnDone, CHANGEPROC stop, CHANGEPROC current, CHANGEPROC rate)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
PIN_INFO piInput;
|
|
|
|
|
|
|
|
/* pTransformFilter is already allocated */
|
|
|
|
pParser->clsid = *pClsid;
|
2008-04-23 18:23:43 +00:00
|
|
|
pParser->lpVtbl = Parser_Vtbl;
|
2005-02-08 13:43:59 +00:00
|
|
|
pParser->refCount = 1;
|
|
|
|
InitializeCriticalSection(&pParser->csFilter);
|
2007-03-10 21:10:20 +00:00
|
|
|
pParser->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ParserImpl.csFilter");
|
2005-02-08 13:43:59 +00:00
|
|
|
pParser->state = State_Stopped;
|
|
|
|
pParser->pClock = NULL;
|
2008-04-16 03:39:36 +00:00
|
|
|
pParser->fnDisconnect = fnDisconnect;
|
2005-02-08 13:43:59 +00:00
|
|
|
ZeroMemory(&pParser->filterInfo, sizeof(FILTER_INFO));
|
2008-04-25 21:25:49 +00:00
|
|
|
pParser->lastpinchange = GetTickCount();
|
2008-04-25 21:59:05 +00:00
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
pParser->cStreams = 0;
|
|
|
|
pParser->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
|
|
|
|
|
|
|
|
/* construct input pin */
|
|
|
|
piInput.dir = PINDIR_INPUT;
|
|
|
|
piInput.pFilter = (IBaseFilter *)pParser;
|
2005-03-28 14:17:51 +00:00
|
|
|
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-03-25 23:11:22 +00:00
|
|
|
if (!current)
|
|
|
|
current = Parser_ChangeCurrent;
|
|
|
|
|
|
|
|
if (!stop)
|
|
|
|
stop = Parser_ChangeStop;
|
|
|
|
|
|
|
|
if (!rate)
|
|
|
|
rate = Parser_ChangeRate;
|
|
|
|
|
|
|
|
MediaSeekingImpl_Init((IBaseFilter*)pParser, stop, current, rate, &pParser->mediaSeeking, &pParser->csFilter);
|
2008-03-18 23:05:00 +00:00
|
|
|
pParser->mediaSeeking.lpVtbl = &Parser_Seeking_Vtbl;
|
|
|
|
|
2008-04-25 21:59:05 +00:00
|
|
|
hr = PullPin_Construct(&Parser_InputPin_Vtbl, &piInput, fnProcessSample, (LPVOID)pParser, fnQueryAccept, fnCleanup, fnRequest, fnDone, &pParser->csFilter, (IPin **)&pParser->pInputPin);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
pParser->ppPins[0] = (IPin *)pParser->pInputPin;
|
|
|
|
pParser->pInputPin->fnPreConnect = fnPreConnect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CoTaskMemFree(pParser->ppPins);
|
2007-03-10 21:10:20 +00:00
|
|
|
pParser->csFilter.DebugInfo->Spare[0] = 0;
|
2005-02-08 13:43:59 +00:00
|
|
|
DeleteCriticalSection(&pParser->csFilter);
|
|
|
|
CoTaskMemFree(pParser);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
2009-01-29 10:14:55 +00:00
|
|
|
*ppv = This;
|
2005-02-08 13:43:59 +00:00
|
|
|
else if (IsEqualIID(riid, &IID_IPersist))
|
2009-01-29 10:14:55 +00:00
|
|
|
*ppv = This;
|
2005-02-08 13:43:59 +00:00
|
|
|
else if (IsEqualIID(riid, &IID_IMediaFilter))
|
2009-01-29 10:14:55 +00:00
|
|
|
*ppv = This;
|
2005-02-08 13:43:59 +00:00
|
|
|
else if (IsEqualIID(riid, &IID_IBaseFilter))
|
2009-01-29 10:14:55 +00:00
|
|
|
*ppv = This;
|
2008-03-18 23:05:00 +00:00
|
|
|
else if (IsEqualIID(riid, &IID_IMediaSeeking))
|
2009-01-29 10:14:55 +00:00
|
|
|
*ppv = &This->mediaSeeking;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)(*ppv));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-10 22:38:56 +00:00
|
|
|
if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow))
|
2008-03-21 22:36:51 +00:00
|
|
|
FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
ULONG WINAPI Parser_AddRef(IBaseFilter * iface)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
ULONG refCount = InterlockedIncrement(&This->refCount);
|
|
|
|
|
2006-10-12 18:57:23 +00:00
|
|
|
TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
void Parser_Destroy(ParserImpl *This)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-04-23 18:23:43 +00:00
|
|
|
IPin *connected = NULL;
|
2008-04-25 21:59:05 +00:00
|
|
|
ULONG pinref;
|
|
|
|
|
|
|
|
assert(!This->refCount);
|
|
|
|
PullPin_WaitForStateChange(This->pInputPin, INFINITE);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_Release(This->pClock);
|
|
|
|
|
|
|
|
/* Don't need to clean up output pins, freeing input pin will do that */
|
|
|
|
IPin_ConnectedTo((IPin *)This->pInputPin, &connected);
|
|
|
|
if (connected)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-04-25 21:59:05 +00:00
|
|
|
assert(IPin_Disconnect(connected) == S_OK);
|
2008-04-23 18:23:43 +00:00
|
|
|
IPin_Release(connected);
|
2008-04-25 21:59:05 +00:00
|
|
|
assert(IPin_Disconnect((IPin *)This->pInputPin) == S_OK);
|
2008-04-23 18:23:43 +00:00
|
|
|
}
|
2008-04-25 21:59:05 +00:00
|
|
|
pinref = IPin_Release((IPin *)This->pInputPin);
|
|
|
|
if (pinref)
|
|
|
|
{
|
|
|
|
/* Valgrind could find this, if I kill it here */
|
|
|
|
ERR("pinref should be null, is %u, destroying anyway\n", pinref);
|
|
|
|
assert((LONG)pinref > 0);
|
|
|
|
|
|
|
|
while (pinref)
|
|
|
|
pinref = IPin_Release((IPin *)This->pInputPin);
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
CoTaskMemFree(This->ppPins);
|
|
|
|
This->lpVtbl = NULL;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
This->csFilter.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&This->csFilter);
|
2007-04-07 04:18:25 +00:00
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
TRACE("Destroying parser\n");
|
|
|
|
CoTaskMemFree(This);
|
|
|
|
}
|
2007-03-13 17:47:47 +00:00
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
ULONG WINAPI Parser_Release(IBaseFilter * iface)
|
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
ULONG refCount = InterlockedDecrement(&This->refCount);
|
2007-03-13 17:47:47 +00:00
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
TRACE("(%p)->() Release from %d\n", This, refCount + 1);
|
|
|
|
|
|
|
|
if (!refCount)
|
|
|
|
Parser_Destroy(This);
|
|
|
|
|
|
|
|
return refCount;
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** IPersist methods **/
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_GetClassID(IBaseFilter * iface, CLSID * pClsid)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2007-03-26 08:18:17 +00:00
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
TRACE("(%p)\n", pClsid);
|
|
|
|
|
2007-03-26 08:18:17 +00:00
|
|
|
*pClsid = This->clsid;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IMediaFilter methods **/
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_Stop(IBaseFilter * iface)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
2008-04-07 22:45:51 +00:00
|
|
|
PullPin *pin = (PullPin *)This->ppPins[0];
|
2008-11-04 22:22:53 +00:00
|
|
|
ULONG i;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
2008-04-07 22:45:51 +00:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2008-07-05 01:43:05 +00:00
|
|
|
|
|
|
|
IAsyncReader_BeginFlush(This->pInputPin->pReader);
|
2005-02-08 13:43:59 +00:00
|
|
|
EnterCriticalSection(&This->csFilter);
|
2008-07-05 01:43:05 +00:00
|
|
|
|
|
|
|
if (This->state == State_Stopped)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-07-05 01:43:05 +00:00
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-09-15 17:47:44 +00:00
|
|
|
IAsyncReader_EndFlush(This->pInputPin->pReader);
|
2008-07-05 01:43:05 +00:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
|
|
|
return S_OK;
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
2008-07-05 01:43:05 +00:00
|
|
|
|
|
|
|
This->state = State_Stopped;
|
|
|
|
|
|
|
|
for (i = 1; i < (This->cStreams + 1); i++)
|
|
|
|
{
|
|
|
|
OutputPin_DecommitAllocator((OutputPin *)This->ppPins[i]);
|
|
|
|
}
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-07-05 01:43:05 +00:00
|
|
|
|
|
|
|
PullPin_PauseProcessing(This->pInputPin);
|
|
|
|
PullPin_WaitForStateChange(This->pInputPin, INFINITE);
|
2008-09-15 17:47:44 +00:00
|
|
|
IAsyncReader_EndFlush(This->pInputPin->pReader);
|
2008-07-05 01:43:05 +00:00
|
|
|
|
2008-04-07 22:45:51 +00:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2008-06-24 15:52:52 +00:00
|
|
|
return S_OK;
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_Pause(IBaseFilter * iface)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
2008-04-07 22:45:51 +00:00
|
|
|
PullPin *pin = (PullPin *)This->ppPins[0];
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
TRACE("()\n");
|
|
|
|
|
2008-04-07 22:45:51 +00:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2005-02-08 13:43:59 +00:00
|
|
|
EnterCriticalSection(&This->csFilter);
|
2008-04-07 22:45:51 +00:00
|
|
|
|
|
|
|
if (This->state == State_Paused)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-04-07 22:45:51 +00:00
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-04-08 21:13:19 +00:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2008-04-07 22:45:51 +00:00
|
|
|
return S_OK;
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
|
2008-04-07 22:45:51 +00:00
|
|
|
if (This->state == State_Stopped)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-04-07 22:45:51 +00:00
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
hr = IBaseFilter_Run(iface, -1);
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
|
2008-07-09 20:00:43 +00:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->state = State_Paused;
|
2008-04-07 22:45:51 +00:00
|
|
|
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-06-07 20:29:23 +00:00
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
2008-04-07 22:45:51 +00:00
|
|
|
PullPin *pin = (PullPin *)This->ppPins[0];
|
|
|
|
|
2008-11-04 22:22:53 +00:00
|
|
|
ULONG i;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
TRACE("(%s)\n", wine_dbgstr_longlong(tStart));
|
|
|
|
|
2008-04-07 22:45:51 +00:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2005-02-08 13:43:59 +00:00
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
2008-07-09 20:00:43 +00:00
|
|
|
HRESULT hr_any = VFW_E_NOT_CONNECTED;
|
|
|
|
|
2008-07-05 01:43:05 +00:00
|
|
|
if (This->state == State_Running || This->state == State_Paused)
|
2005-06-07 20:29:23 +00:00
|
|
|
{
|
2008-07-05 01:43:05 +00:00
|
|
|
This->state = State_Running;
|
2005-06-07 20:29:23 +00:00
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-04-08 21:13:19 +00:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-06-07 20:29:23 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
This->rtStreamStart = tStart;
|
|
|
|
|
2008-07-05 01:43:05 +00:00
|
|
|
for (i = 1; i < (This->cStreams + 1); i++)
|
2005-06-07 20:29:23 +00:00
|
|
|
{
|
2008-07-05 01:43:05 +00:00
|
|
|
hr = OutputPin_CommitAllocator((OutputPin *)This->ppPins[i]);
|
2008-07-09 20:00:43 +00:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr_any = hr;
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
2005-06-07 20:29:23 +00:00
|
|
|
|
2008-07-14 18:49:08 +00:00
|
|
|
hr = hr_any;
|
2005-06-07 20:29:23 +00:00
|
|
|
if (SUCCEEDED(hr))
|
2008-04-01 21:35:14 +00:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2005-06-07 20:29:23 +00:00
|
|
|
hr = PullPin_StartProcessing(This->pInputPin);
|
2008-04-01 21:35:14 +00:00
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
}
|
2005-06-07 20:29:23 +00:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->state = State_Running;
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-04-07 22:45:51 +00:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
2008-04-07 22:45:51 +00:00
|
|
|
PullPin *pin = (PullPin *)This->ppPins[0];
|
|
|
|
HRESULT hr = S_OK;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2006-10-12 18:57:23 +00:00
|
|
|
TRACE("(%d, %p)\n", dwMilliSecsTimeout, pState);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-04-07 22:45:51 +00:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2005-02-08 13:43:59 +00:00
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
*pState = This->state;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
if (This->pInputPin && (PullPin_WaitForStateChange(This->pInputPin, dwMilliSecsTimeout) == S_FALSE))
|
2008-04-07 22:45:51 +00:00
|
|
|
hr = VFW_S_STATE_INTERMEDIATE;
|
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-04-07 22:45:51 +00:00
|
|
|
return hr;
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
2008-04-07 22:45:51 +00:00
|
|
|
PullPin *pin = (PullPin *)This->ppPins[0];
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
TRACE("(%p)\n", pClock);
|
|
|
|
|
2008-04-07 22:45:51 +00:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2005-02-08 13:43:59 +00:00
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_Release(This->pClock);
|
|
|
|
This->pClock = pClock;
|
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_AddRef(This->pClock);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
2008-04-07 22:45:51 +00:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", ppClock);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
*ppClock = This->pClock;
|
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_AddRef(This->pClock);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IBaseFilter implementation **/
|
|
|
|
|
2008-04-25 21:59:05 +00:00
|
|
|
/* FIXME: WRONG */
|
2008-04-25 21:25:49 +00:00
|
|
|
static HRESULT Parser_GetPin(IBaseFilter *iface, ULONG pos, IPin **pin, DWORD *lastsynctick)
|
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
|
|
|
|
*lastsynctick = This->lastpinchange;
|
|
|
|
|
|
|
|
TRACE("Asking for pos %x\n", pos);
|
|
|
|
|
|
|
|
/* Input pin also has a pin, hence the > and not >= */
|
|
|
|
if (pos > This->cStreams)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
*pin = This->ppPins[pos];
|
|
|
|
IPin_AddRef(*pin);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
|
2008-04-25 21:25:49 +00:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-04-25 21:25:49 +00:00
|
|
|
return IEnumPinsImpl_Construct(ppEnum, Parser_GetPin, iface);
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s,%p)\n", iface, debugstr_w(Id), ppPin);
|
|
|
|
|
|
|
|
/* FIXME: critical section */
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pInfo);
|
|
|
|
|
|
|
|
strcpyW(pInfo->achName, This->filterInfo.achName);
|
|
|
|
pInfo->pGraph = This->filterInfo.pGraph;
|
|
|
|
|
|
|
|
if (pInfo->pGraph)
|
|
|
|
IFilterGraph_AddRef(pInfo->pGraph);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
ParserImpl *This = (ParserImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p, %s)\n", pGraph, debugstr_w(pName));
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
if (pName)
|
|
|
|
strcpyW(This->filterInfo.achName, pName);
|
|
|
|
else
|
|
|
|
*This->filterInfo.achName = '\0';
|
|
|
|
This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-04-23 18:23:43 +00:00
|
|
|
HRESULT WINAPI Parser_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pVendorInfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-03-18 23:05:00 +00:00
|
|
|
HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PROPERTIES * props, const AM_MEDIA_TYPE * amt)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
IPin ** ppOldPins;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
ppOldPins = This->ppPins;
|
|
|
|
|
2007-03-08 11:03:06 +00:00
|
|
|
This->ppPins = CoTaskMemAlloc((This->cStreams + 2) * sizeof(IPin *));
|
2005-02-08 13:43:59 +00:00
|
|
|
memcpy(This->ppPins, ppOldPins, (This->cStreams + 1) * sizeof(IPin *));
|
|
|
|
|
2008-04-25 21:59:05 +00:00
|
|
|
hr = OutputPin_Construct(&Parser_OutputPin_Vtbl, sizeof(Parser_OutputPin), piOutput, props, NULL, Parser_OutputPin_QueryAccept, &This->csFilter, This->ppPins + (This->cStreams + 1));
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2008-04-04 21:29:21 +00:00
|
|
|
IPin *pPin = This->ppPins[This->cStreams + 1];
|
|
|
|
Parser_OutputPin *pin = (Parser_OutputPin *)pPin;
|
|
|
|
pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
|
|
|
|
CopyMediaType(pin->pmt, amt);
|
|
|
|
pin->dwSamplesProcessed = 0;
|
|
|
|
|
2009-01-29 10:14:55 +00:00
|
|
|
pin->pin.pin.pUserData = This->ppPins[This->cStreams + 1];
|
2008-04-22 20:57:11 +00:00
|
|
|
pin->pin.pin.pinInfo.pFilter = (LPVOID)This;
|
|
|
|
pin->pin.custom_allocator = 1;
|
2005-02-08 13:43:59 +00:00
|
|
|
This->cStreams++;
|
2008-04-25 21:25:49 +00:00
|
|
|
This->lastpinchange = GetTickCount();
|
2007-03-08 11:03:06 +00:00
|
|
|
CoTaskMemFree(ppOldPins);
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-08 11:03:06 +00:00
|
|
|
CoTaskMemFree(This->ppPins);
|
2005-02-08 13:43:59 +00:00
|
|
|
This->ppPins = ppOldPins;
|
2006-10-12 18:57:23 +00:00
|
|
|
ERR("Failed with error %x\n", hr);
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
|
|
|
|
{
|
|
|
|
/* NOTE: should be in critical section when calling this function */
|
2008-04-25 21:59:05 +00:00
|
|
|
HRESULT hr;
|
2005-02-08 13:43:59 +00:00
|
|
|
ULONG i;
|
|
|
|
IPin ** ppOldPins = This->ppPins;
|
|
|
|
|
2008-04-25 21:59:05 +00:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
/* reduce the pin array down to 1 (just our input pin) */
|
2007-03-08 11:03:06 +00:00
|
|
|
This->ppPins = CoTaskMemAlloc(sizeof(IPin *) * 1);
|
2005-02-08 13:43:59 +00:00
|
|
|
memcpy(This->ppPins, ppOldPins, sizeof(IPin *) * 1);
|
|
|
|
|
|
|
|
for (i = 0; i < This->cStreams; i++)
|
|
|
|
{
|
2008-04-25 21:59:05 +00:00
|
|
|
hr = OutputPin_DeliverDisconnect((OutputPin *)ppOldPins[i + 1]);
|
2008-04-30 21:39:36 +00:00
|
|
|
TRACE("Disconnect: %08x\n", hr);
|
2005-02-08 13:43:59 +00:00
|
|
|
IPin_Release(ppOldPins[i + 1]);
|
|
|
|
}
|
|
|
|
|
2008-04-25 21:25:49 +00:00
|
|
|
This->lastpinchange = GetTickCount();
|
2008-04-25 21:59:05 +00:00
|
|
|
This->cStreams = 0;
|
2007-03-08 11:03:06 +00:00
|
|
|
CoTaskMemFree(ppOldPins);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-25 23:11:22 +00:00
|
|
|
static HRESULT Parser_ChangeCurrent(IBaseFilter *iface)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-03-25 23:11:22 +00:00
|
|
|
FIXME("(%p) filter hasn't implemented current position change!\n", iface);
|
2005-02-08 13:43:59 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-18 23:05:00 +00:00
|
|
|
static HRESULT Parser_ChangeStop(IBaseFilter *iface)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-03-25 23:11:22 +00:00
|
|
|
FIXME("(%p) filter hasn't implemented stop position change!\n", iface);
|
2005-02-08 13:43:59 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-18 23:05:00 +00:00
|
|
|
static HRESULT Parser_ChangeRate(IBaseFilter *iface)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-03-25 23:11:22 +00:00
|
|
|
FIXME("(%p) filter hasn't implemented rate change!\n", iface);
|
2005-02-08 13:43:59 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI Parser_Seeking_QueryInterface(IMediaSeeking * iface, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
2008-03-18 23:05:00 +00:00
|
|
|
ParserImpl *This = impl_from_IMediaSeeking(iface);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return IUnknown_QueryInterface((IUnknown *)This, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Parser_Seeking_AddRef(IMediaSeeking * iface)
|
|
|
|
{
|
2008-03-18 23:05:00 +00:00
|
|
|
ParserImpl *This = impl_from_IMediaSeeking(iface);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return IUnknown_AddRef((IUnknown *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Parser_Seeking_Release(IMediaSeeking * iface)
|
|
|
|
{
|
2008-03-18 23:05:00 +00:00
|
|
|
ParserImpl *This = impl_from_IMediaSeeking(iface);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
return IUnknown_Release((IUnknown *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMediaSeekingVtbl Parser_Seeking_Vtbl =
|
|
|
|
{
|
|
|
|
Parser_Seeking_QueryInterface,
|
|
|
|
Parser_Seeking_AddRef,
|
|
|
|
Parser_Seeking_Release,
|
|
|
|
MediaSeekingImpl_GetCapabilities,
|
|
|
|
MediaSeekingImpl_CheckCapabilities,
|
|
|
|
MediaSeekingImpl_IsFormatSupported,
|
|
|
|
MediaSeekingImpl_QueryPreferredFormat,
|
|
|
|
MediaSeekingImpl_GetTimeFormat,
|
|
|
|
MediaSeekingImpl_IsUsingTimeFormat,
|
|
|
|
MediaSeekingImpl_SetTimeFormat,
|
|
|
|
MediaSeekingImpl_GetDuration,
|
|
|
|
MediaSeekingImpl_GetStopPosition,
|
|
|
|
MediaSeekingImpl_GetCurrentPosition,
|
|
|
|
MediaSeekingImpl_ConvertTimeFormat,
|
|
|
|
MediaSeekingImpl_SetPositions,
|
|
|
|
MediaSeekingImpl_GetPositions,
|
|
|
|
MediaSeekingImpl_GetAvailable,
|
|
|
|
MediaSeekingImpl_SetRate,
|
|
|
|
MediaSeekingImpl_GetRate,
|
|
|
|
MediaSeekingImpl_GetPreroll
|
|
|
|
};
|
|
|
|
|
2007-01-23 20:53:30 +00:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
Parser_OutputPin *This = (Parser_OutputPin *)iface;
|
|
|
|
|
|
|
|
TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
2009-01-29 10:14:55 +00:00
|
|
|
*ppv = iface;
|
2005-02-08 13:43:59 +00:00
|
|
|
else if (IsEqualIID(riid, &IID_IPin))
|
2009-01-29 10:14:55 +00:00
|
|
|
*ppv = iface;
|
2005-02-08 13:43:59 +00:00
|
|
|
else if (IsEqualIID(riid, &IID_IMediaSeeking))
|
2008-03-18 23:05:00 +00:00
|
|
|
{
|
2008-03-21 23:12:54 +00:00
|
|
|
return IBaseFilter_QueryInterface(This->pin.pin.pinInfo.pFilter, &IID_IMediaSeeking, ppv);
|
2008-03-18 23:05:00 +00:00
|
|
|
}
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)(*ppv));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Parser_OutputPin_Release(IPin * iface)
|
|
|
|
{
|
|
|
|
Parser_OutputPin *This = (Parser_OutputPin *)iface;
|
|
|
|
ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
|
|
|
|
|
2006-10-12 18:57:23 +00:00
|
|
|
TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
|
2008-04-25 21:59:05 +00:00
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
if (!refCount)
|
|
|
|
{
|
2005-06-05 19:18:34 +00:00
|
|
|
FreeMediaType(This->pmt);
|
2005-02-08 13:43:59 +00:00
|
|
|
CoTaskMemFree(This->pmt);
|
2005-06-05 19:18:34 +00:00
|
|
|
FreeMediaType(&This->pin.pin.mtCurrent);
|
2005-02-08 13:43:59 +00:00
|
|
|
CoTaskMemFree(This);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Parser_OutputPin_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum)
|
|
|
|
{
|
|
|
|
ENUMMEDIADETAILS emd;
|
|
|
|
Parser_OutputPin *This = (Parser_OutputPin *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", ppEnum);
|
|
|
|
|
|
|
|
/* override this method to allow enumeration of your types */
|
|
|
|
emd.cMediaTypes = 1;
|
|
|
|
emd.pMediaTypes = This->pmt;
|
|
|
|
|
|
|
|
return IEnumMediaTypesImpl_Construct(&emd, ppEnum);
|
|
|
|
}
|
|
|
|
|
2008-04-22 20:57:11 +00:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
|
|
|
Parser_OutputPin *This = (Parser_OutputPin *)iface;
|
|
|
|
ParserImpl *parser = (ParserImpl *)This->pin.pin.pinInfo.pFilter;
|
|
|
|
|
|
|
|
/* Set the allocator to our input pin's */
|
|
|
|
EnterCriticalSection(This->pin.pin.pCritSec);
|
|
|
|
This->pin.alloc = parser->pInputPin->pAlloc;
|
|
|
|
LeaveCriticalSection(This->pin.pin.pCritSec);
|
|
|
|
|
|
|
|
return OutputPin_Connect(iface, pReceivePin, pmt);
|
|
|
|
}
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
static HRESULT Parser_OutputPin_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
2009-01-29 10:14:55 +00:00
|
|
|
Parser_OutputPin *This = iface;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
|
|
|
|
return (memcmp(This->pmt, pmt, sizeof(AM_MEDIA_TYPE)) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPinVtbl Parser_OutputPin_Vtbl =
|
|
|
|
{
|
|
|
|
Parser_OutputPin_QueryInterface,
|
|
|
|
IPinImpl_AddRef,
|
|
|
|
Parser_OutputPin_Release,
|
2008-04-22 20:57:11 +00:00
|
|
|
Parser_OutputPin_Connect,
|
2005-02-08 13:43:59 +00:00
|
|
|
OutputPin_ReceiveConnection,
|
|
|
|
OutputPin_Disconnect,
|
|
|
|
IPinImpl_ConnectedTo,
|
|
|
|
IPinImpl_ConnectionMediaType,
|
|
|
|
IPinImpl_QueryPinInfo,
|
|
|
|
IPinImpl_QueryDirection,
|
|
|
|
IPinImpl_QueryId,
|
|
|
|
IPinImpl_QueryAccept,
|
|
|
|
Parser_OutputPin_EnumMediaTypes,
|
|
|
|
IPinImpl_QueryInternalConnections,
|
|
|
|
OutputPin_EndOfStream,
|
|
|
|
OutputPin_BeginFlush,
|
|
|
|
OutputPin_EndFlush,
|
|
|
|
OutputPin_NewSegment
|
|
|
|
};
|
|
|
|
|
2008-04-16 03:39:36 +00:00
|
|
|
static HRESULT WINAPI Parser_PullPin_Disconnect(IPin * iface)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2008-04-25 21:59:05 +00:00
|
|
|
PullPin *This = (PullPin *)iface;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
2008-04-25 21:59:05 +00:00
|
|
|
EnterCriticalSection(&This->thread_lock);
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-04-25 21:59:05 +00:00
|
|
|
if (This->pin.pConnectedTo)
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
|
|
|
FILTER_STATE state;
|
2008-04-25 21:59:05 +00:00
|
|
|
ParserImpl *Parser = (ParserImpl *)This->pin.pinInfo.pFilter;
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-04-25 21:59:05 +00:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
hr = IBaseFilter_GetState(This->pin.pinInfo.pFilter, INFINITE, &state);
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
2005-02-08 13:43:59 +00:00
|
|
|
|
2008-04-16 03:39:36 +00:00
|
|
|
if (SUCCEEDED(hr) && (state == State_Stopped) && SUCCEEDED(Parser->fnDisconnect(Parser)))
|
2005-02-08 13:43:59 +00:00
|
|
|
{
|
2008-06-24 15:52:52 +00:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
PullPin_Disconnect(iface);
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
2008-04-25 21:59:05 +00:00
|
|
|
hr = Parser_RemoveOutputPins((ParserImpl *)This->pin.pinInfo.pFilter);
|
2005-02-08 13:43:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = VFW_E_NOT_STOPPED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = S_FALSE;
|
|
|
|
}
|
2008-04-25 21:59:05 +00:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
LeaveCriticalSection(&This->thread_lock);
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-12-02 14:25:19 +00:00
|
|
|
static HRESULT WINAPI Parser_PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
2007-03-30 12:36:21 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
hr = PullPin_ReceiveConnection(iface, pReceivePin, pmt);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IPinImpl *This = (IPinImpl *)iface;
|
|
|
|
|
|
|
|
EnterCriticalSection(This->pCritSec);
|
|
|
|
Parser_RemoveOutputPins((ParserImpl *)This->pinInfo.pFilter);
|
|
|
|
LeaveCriticalSection(This->pCritSec);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2005-02-08 13:43:59 +00:00
|
|
|
static const IPinVtbl Parser_InputPin_Vtbl =
|
|
|
|
{
|
|
|
|
PullPin_QueryInterface,
|
|
|
|
IPinImpl_AddRef,
|
|
|
|
PullPin_Release,
|
2008-04-22 20:57:11 +00:00
|
|
|
InputPin_Connect,
|
2007-03-30 12:36:21 +00:00
|
|
|
Parser_PullPin_ReceiveConnection,
|
2008-04-16 03:39:36 +00:00
|
|
|
Parser_PullPin_Disconnect,
|
2005-02-08 13:43:59 +00:00
|
|
|
IPinImpl_ConnectedTo,
|
|
|
|
IPinImpl_ConnectionMediaType,
|
|
|
|
IPinImpl_QueryPinInfo,
|
|
|
|
IPinImpl_QueryDirection,
|
|
|
|
IPinImpl_QueryId,
|
|
|
|
IPinImpl_QueryAccept,
|
|
|
|
IPinImpl_EnumMediaTypes,
|
|
|
|
IPinImpl_QueryInternalConnections,
|
|
|
|
PullPin_EndOfStream,
|
|
|
|
PullPin_BeginFlush,
|
|
|
|
PullPin_EndFlush,
|
|
|
|
PullPin_NewSegment
|
|
|
|
};
|