2005-02-08 14:43:59 +01: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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-02-08 14:43:59 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "quartz_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 21:50:35 +02:00
|
|
|
static const IMediaSeekingVtbl Parser_Seeking_Vtbl;
|
|
|
|
static const IPinVtbl Parser_OutputPin_Vtbl;
|
|
|
|
static const IPinVtbl Parser_InputPin_Vtbl;
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2010-10-11 17:15:35 +02:00
|
|
|
static HRESULT WINAPI Parser_ChangeStart(IMediaSeeking *iface);
|
|
|
|
static HRESULT WINAPI Parser_ChangeStop(IMediaSeeking *iface);
|
|
|
|
static HRESULT WINAPI Parser_ChangeRate(IMediaSeeking *iface);
|
2010-10-13 18:02:01 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
|
2018-05-04 06:47:13 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_CheckMediaType(BasePin *pin, const AM_MEDIA_TYPE *pmt);
|
2010-10-13 18:02:08 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt);
|
2010-10-13 18:02:14 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_DecideAllocator(BaseOutputPin *This, IMemInputPin *pPin, IMemAllocator **pAlloc);
|
|
|
|
static HRESULT WINAPI Parser_OutputPin_BreakConnect(BaseOutputPin *This);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-03-19 00:05:00 +01:00
|
|
|
static inline ParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
|
2005-07-27 17:14:18 +02:00
|
|
|
{
|
2012-03-24 17:43:09 +01:00
|
|
|
return CONTAINING_RECORD(iface, ParserImpl, sourceSeeking.IMediaSeeking_iface);
|
2005-07-27 17:14:18 +02:00
|
|
|
}
|
|
|
|
|
2012-05-21 15:21:48 +02:00
|
|
|
static inline ParserImpl *impl_from_IBaseFilter( IBaseFilter *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ParserImpl, filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ParserImpl *impl_from_BaseFilter( BaseFilter *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ParserImpl, filter);
|
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:01 +02:00
|
|
|
/* FIXME: WRONG */
|
2010-10-13 18:02:01 +02:00
|
|
|
static IPin* WINAPI Parser_GetPin(BaseFilter *iface, int pos)
|
2010-10-07 21:48:01 +02:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_BaseFilter(iface);
|
2010-10-07 21:48:01 +02:00
|
|
|
|
2017-11-09 02:08:41 +01:00
|
|
|
TRACE("%p->(%x)\n", This, pos);
|
2010-10-07 21:48:01 +02:00
|
|
|
|
|
|
|
/* Input pin also has a pin, hence the > and not >= */
|
|
|
|
if (pos > This->cStreams || pos < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
IPin_AddRef(This->ppPins[pos]);
|
|
|
|
return This->ppPins[pos];
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static LONG WINAPI Parser_GetPinCount(BaseFilter *iface)
|
2010-10-07 21:48:01 +02:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_BaseFilter(iface);
|
2010-10-07 21:48:01 +02:00
|
|
|
|
2017-11-09 02:08:41 +01:00
|
|
|
TRACE("%p->()\n", This);
|
|
|
|
|
2010-10-07 21:48:01 +02:00
|
|
|
return This->cStreams;
|
|
|
|
}
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static const BaseFilterFuncTable BaseFuncTable = {
|
|
|
|
Parser_GetPin,
|
|
|
|
Parser_GetPinCount
|
|
|
|
};
|
|
|
|
|
2010-10-11 17:15:35 +02: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, SourceSeeking_ChangeStop stop, SourceSeeking_ChangeStart start, SourceSeeking_ChangeRate rate)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
PIN_INFO piInput;
|
|
|
|
|
|
|
|
/* pTransformFilter is already allocated */
|
2010-10-13 18:02:01 +02:00
|
|
|
BaseFilter_Init(&pParser->filter, Parser_Vtbl, pClsid, (DWORD_PTR)(__FILE__ ": ParserImpl.csFilter"), &BaseFuncTable);
|
2010-10-07 21:47:33 +02:00
|
|
|
|
2008-04-16 05:39:36 +02:00
|
|
|
pParser->fnDisconnect = fnDisconnect;
|
2008-04-25 23:59:05 +02:00
|
|
|
|
2005-02-08 14:43:59 +01:00
|
|
|
pParser->cStreams = 0;
|
|
|
|
pParser->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
|
|
|
|
|
|
|
|
/* construct input pin */
|
|
|
|
piInput.dir = PINDIR_INPUT;
|
2012-05-21 15:21:48 +02:00
|
|
|
piInput.pFilter = &pParser->filter.IBaseFilter_iface;
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2010-10-11 17:15:35 +02:00
|
|
|
if (!start)
|
|
|
|
start = Parser_ChangeStart;
|
2008-03-26 00:11:22 +01:00
|
|
|
|
|
|
|
if (!stop)
|
|
|
|
stop = Parser_ChangeStop;
|
|
|
|
|
|
|
|
if (!rate)
|
|
|
|
rate = Parser_ChangeRate;
|
|
|
|
|
2010-10-11 17:15:35 +02:00
|
|
|
SourceSeeking_Init(&pParser->sourceSeeking, &Parser_Seeking_Vtbl, stop, start, rate, &pParser->filter.csFilter);
|
2008-03-19 00:05:00 +01:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
hr = PullPin_Construct(&Parser_InputPin_Vtbl, &piInput, fnProcessSample, (LPVOID)pParser, fnQueryAccept, fnCleanup, fnRequest, fnDone, &pParser->filter.csFilter, (IPin **)&pParser->pInputPin);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2012-04-04 15:27:25 +02:00
|
|
|
pParser->ppPins[0] = &pParser->pInputPin->pin.IPin_iface;
|
2005-02-08 14:43:59 +01:00
|
|
|
pParser->pInputPin->fnPreConnect = fnPreConnect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CoTaskMemFree(pParser->ppPins);
|
2012-05-21 15:21:48 +02:00
|
|
|
BaseFilterImpl_Release(&pParser->filter.IBaseFilter_iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
CoTaskMemFree(pParser);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
2010-09-17 16:33:14 +02:00
|
|
|
if ( IsEqualIID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualIID(riid, &IID_IPersist)
|
|
|
|
|| IsEqualIID(riid, &IID_IMediaFilter)
|
|
|
|
|| IsEqualIID(riid, &IID_IBaseFilter) )
|
2015-10-21 13:31:49 +02:00
|
|
|
*ppv = &This->filter.IBaseFilter_iface;
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
2015-10-21 13:31:49 +02:00
|
|
|
IUnknown_AddRef((IUnknown *)*ppv);
|
2005-02-08 14:43:59 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-11 00:38:56 +02:00
|
|
|
if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow))
|
2008-03-21 23:36:51 +01:00
|
|
|
FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
ULONG WINAPI Parser_AddRef(IBaseFilter * iface)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
return BaseFilterImpl_AddRef(iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
void Parser_Destroy(ParserImpl *This)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2008-04-23 20:23:43 +02:00
|
|
|
IPin *connected = NULL;
|
2008-04-25 23:59:05 +02:00
|
|
|
ULONG pinref;
|
2014-07-26 22:04:29 +02:00
|
|
|
HRESULT hr;
|
2008-04-25 23:59:05 +02:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
assert(!This->filter.refCount);
|
2008-04-25 23:59:05 +02:00
|
|
|
PullPin_WaitForStateChange(This->pInputPin, INFINITE);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
/* Don't need to clean up output pins, freeing input pin will do that */
|
2012-04-04 15:27:25 +02:00
|
|
|
IPin_ConnectedTo(&This->pInputPin->pin.IPin_iface, &connected);
|
2008-04-23 20:23:43 +02:00
|
|
|
if (connected)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2014-07-26 22:04:29 +02:00
|
|
|
hr = IPin_Disconnect(connected);
|
|
|
|
assert(hr == S_OK);
|
2008-04-23 20:23:43 +02:00
|
|
|
IPin_Release(connected);
|
2014-07-26 22:04:29 +02:00
|
|
|
hr = IPin_Disconnect(&This->pInputPin->pin.IPin_iface);
|
|
|
|
assert(hr == S_OK);
|
2008-04-23 20:23:43 +02:00
|
|
|
}
|
2012-04-04 15:27:25 +02:00
|
|
|
pinref = IPin_Release(&This->pInputPin->pin.IPin_iface);
|
2008-04-25 23:59:05 +02:00
|
|
|
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)
|
2012-04-04 15:27:25 +02:00
|
|
|
pinref = IPin_Release(&This->pInputPin->pin.IPin_iface);
|
2008-04-25 23:59:05 +02:00
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
CoTaskMemFree(This->ppPins);
|
2014-07-19 10:29:54 +02:00
|
|
|
BaseFilter_Destroy(&This->filter);
|
2007-04-07 06:18:25 +02:00
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
TRACE("Destroying parser\n");
|
|
|
|
CoTaskMemFree(This);
|
|
|
|
}
|
2007-03-13 18:47:47 +01:00
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
ULONG WINAPI Parser_Release(IBaseFilter * iface)
|
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
2014-07-19 10:29:54 +02:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->filter.refCount);
|
2007-03-13 18:47:47 +01:00
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
TRACE("(%p)->() Release from %d\n", This, refCount + 1);
|
|
|
|
|
|
|
|
if (!refCount)
|
|
|
|
Parser_Destroy(This);
|
|
|
|
|
|
|
|
return refCount;
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** IPersist methods **/
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_GetClassID(IBaseFilter * iface, CLSID * pClsid)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
2007-03-26 10:18:17 +02:00
|
|
|
|
2017-11-09 02:08:41 +01:00
|
|
|
TRACE("%p->(%p)\n", This, pClsid);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
*pClsid = This->filter.clsid;
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IMediaFilter methods **/
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_Stop(IBaseFilter * iface)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
2012-04-04 15:27:25 +02:00
|
|
|
PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
|
2008-11-04 23:22:53 +01:00
|
|
|
ULONG i;
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2017-11-09 02:08:41 +01:00
|
|
|
TRACE("%p->()\n", This);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-08 00:45:51 +02:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2008-07-05 03:43:05 +02:00
|
|
|
|
|
|
|
IAsyncReader_BeginFlush(This->pInputPin->pReader);
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2008-07-05 03:43:05 +02:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
if (This->filter.state == State_Stopped)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2008-09-15 19:47:44 +02:00
|
|
|
IAsyncReader_EndFlush(This->pInputPin->pReader);
|
2008-07-05 03:43:05 +02:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
|
|
|
return S_OK;
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
2008-07-05 03:43:05 +02:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
This->filter.state = State_Stopped;
|
2008-07-05 03:43:05 +02:00
|
|
|
|
|
|
|
for (i = 1; i < (This->cStreams + 1); i++)
|
|
|
|
{
|
2010-10-05 21:37:56 +02:00
|
|
|
BaseOutputPinImpl_Inactive((BaseOutputPin *)This->ppPins[i]);
|
2008-07-05 03:43:05 +02:00
|
|
|
}
|
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2008-07-05 03:43:05 +02:00
|
|
|
|
|
|
|
PullPin_PauseProcessing(This->pInputPin);
|
|
|
|
PullPin_WaitForStateChange(This->pInputPin, INFINITE);
|
2008-09-15 19:47:44 +02:00
|
|
|
IAsyncReader_EndFlush(This->pInputPin->pReader);
|
2008-07-05 03:43:05 +02:00
|
|
|
|
2008-04-08 00:45:51 +02:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2008-06-24 17:52:52 +02:00
|
|
|
return S_OK;
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_Pause(IBaseFilter * iface)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
2012-04-04 15:27:25 +02:00
|
|
|
PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
|
2008-04-08 00:45:51 +02:00
|
|
|
|
2017-11-09 02:08:41 +01:00
|
|
|
TRACE("%p->()\n", This);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-08 00:45:51 +02:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2008-04-08 00:45:51 +02:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
if (This->filter.state == State_Paused)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2008-04-08 23:13:19 +02:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2008-04-08 00:45:51 +02:00
|
|
|
return S_OK;
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
if (This->filter.state == State_Stopped)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2008-04-08 00:45:51 +02:00
|
|
|
hr = IBaseFilter_Run(iface, -1);
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-07-09 22:00:43 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2010-10-07 21:47:33 +02:00
|
|
|
This->filter.state = State_Paused;
|
2008-04-08 00:45:51 +02:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2008-04-08 00:45:51 +02:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-06-07 22:29:23 +02:00
|
|
|
|
2005-02-08 14:43:59 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
2012-04-04 15:27:25 +02:00
|
|
|
PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
|
2008-04-08 00:45:51 +02:00
|
|
|
|
2008-11-04 23:22:53 +01:00
|
|
|
ULONG i;
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2017-11-09 02:08:41 +01:00
|
|
|
TRACE("%p->(%s)\n", This, wine_dbgstr_longlong(tStart));
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-08 00:45:51 +02:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2008-07-09 22:00:43 +02:00
|
|
|
HRESULT hr_any = VFW_E_NOT_CONNECTED;
|
|
|
|
|
2010-12-06 14:16:42 +01:00
|
|
|
This->filter.rtStreamStart = tStart;
|
2010-10-07 21:47:33 +02:00
|
|
|
if (This->filter.state == State_Running || This->filter.state == State_Paused)
|
2005-06-07 22:29:23 +02:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
This->filter.state = State_Running;
|
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2008-04-08 23:13:19 +02:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-06-07 22:29:23 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-05 03:43:05 +02:00
|
|
|
for (i = 1; i < (This->cStreams + 1); i++)
|
2005-06-07 22:29:23 +02:00
|
|
|
{
|
2010-10-05 21:37:56 +02:00
|
|
|
hr = BaseOutputPinImpl_Active((BaseOutputPin *)This->ppPins[i]);
|
2008-07-09 22:00:43 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr_any = hr;
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
2005-06-07 22:29:23 +02:00
|
|
|
|
2008-07-14 20:49:08 +02:00
|
|
|
hr = hr_any;
|
2005-06-07 22:29:23 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2008-04-01 23:35:14 +02:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2005-06-07 22:29:23 +02:00
|
|
|
hr = PullPin_StartProcessing(This->pInputPin);
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2008-04-01 23:35:14 +02:00
|
|
|
}
|
2005-06-07 22:29:23 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
2010-10-07 21:47:33 +02:00
|
|
|
This->filter.state = State_Running;
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2008-04-08 00:45:51 +02:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
2012-04-04 15:27:25 +02:00
|
|
|
PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
|
2008-04-08 00:45:51 +02:00
|
|
|
HRESULT hr = S_OK;
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2017-11-09 02:08:41 +01:00
|
|
|
TRACE("%p->(%d, %p)\n", This, dwMilliSecsTimeout, pState);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-08 00:45:51 +02:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
*pState = This->filter.state;
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
if (This->pInputPin && (PullPin_WaitForStateChange(This->pInputPin, dwMilliSecsTimeout) == S_FALSE))
|
2008-04-08 00:45:51 +02:00
|
|
|
hr = VFW_S_STATE_INTERMEDIATE;
|
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-08 00:45:51 +02:00
|
|
|
return hr;
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
2012-04-04 15:27:25 +02:00
|
|
|
PullPin *pin = impl_PullPin_from_IPin(This->ppPins[0]);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2017-11-09 02:08:41 +01:00
|
|
|
TRACE("%p->(%p)\n", This, pClock);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-08 00:45:51 +02:00
|
|
|
EnterCriticalSection(&pin->thread_lock);
|
2010-10-07 21:47:33 +02:00
|
|
|
BaseFilterImpl_SetSyncSource(iface,pClock);
|
2008-04-08 00:45:51 +02:00
|
|
|
LeaveCriticalSection(&pin->thread_lock);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
return BaseFilterImpl_GetSyncSource(iface, ppClock);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** IBaseFilter implementation **/
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:48:01 +02:00
|
|
|
return BaseFilterImpl_EnumPins(iface,ppEnum);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2017-11-09 02:08:41 +01:00
|
|
|
ParserImpl *This = impl_from_IBaseFilter(iface);
|
|
|
|
FIXME("(%p)->(%s,%p)\n", This, debugstr_w(Id), ppPin);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
/* FIXME: critical section */
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
return BaseFilterImpl_QueryFilterInfo(iface, pInfo);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
return BaseFilterImpl_JoinFilterGraph(iface, pGraph, pName);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
HRESULT WINAPI Parser_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
return BaseFilterImpl_QueryVendorInfo(iface, pVendorInfo);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
|
2014-01-06 17:54:13 +01:00
|
|
|
{
|
2018-05-04 06:47:13 +02:00
|
|
|
Parser_OutputPin_CheckMediaType,
|
2014-01-06 17:54:13 +01:00
|
|
|
BaseOutputPinImpl_AttemptConnection,
|
|
|
|
BasePinImpl_GetMediaTypeVersion,
|
|
|
|
Parser_OutputPin_GetMediaType
|
|
|
|
},
|
2010-10-13 18:02:14 +02:00
|
|
|
Parser_OutputPin_DecideBufferSize,
|
|
|
|
Parser_OutputPin_DecideAllocator,
|
|
|
|
Parser_OutputPin_BreakConnect
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
2008-03-19 00:05:00 +01:00
|
|
|
HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PROPERTIES * props, const AM_MEDIA_TYPE * amt)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
|
|
|
IPin ** ppOldPins;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
ppOldPins = This->ppPins;
|
|
|
|
|
2007-03-08 12:03:06 +01:00
|
|
|
This->ppPins = CoTaskMemAlloc((This->cStreams + 2) * sizeof(IPin *));
|
2005-02-08 14:43:59 +01:00
|
|
|
memcpy(This->ppPins, ppOldPins, (This->cStreams + 1) * sizeof(IPin *));
|
|
|
|
|
2014-01-06 17:54:13 +01:00
|
|
|
hr = BaseOutputPin_Construct(&Parser_OutputPin_Vtbl, sizeof(Parser_OutputPin), piOutput, &output_BaseOutputFuncTable, &This->filter.csFilter, This->ppPins + (This->cStreams + 1));
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2008-04-04 23:29:21 +02:00
|
|
|
IPin *pPin = This->ppPins[This->cStreams + 1];
|
2012-05-21 15:21:41 +02:00
|
|
|
Parser_OutputPin *pin = unsafe_impl_Parser_OutputPin_from_IPin(pPin);
|
2008-04-04 23:29:21 +02:00
|
|
|
pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
|
|
|
|
CopyMediaType(pin->pmt, amt);
|
|
|
|
pin->dwSamplesProcessed = 0;
|
|
|
|
|
2016-09-02 12:55:20 +02:00
|
|
|
pin->pin.pin.pinInfo.pFilter = &This->filter.IBaseFilter_iface;
|
2010-10-13 17:46:27 +02:00
|
|
|
pin->allocProps = *props;
|
2005-02-08 14:43:59 +01:00
|
|
|
This->cStreams++;
|
2012-05-21 15:21:48 +02:00
|
|
|
BaseFilterImpl_IncrementPinVersion(&This->filter);
|
2007-03-08 12:03:06 +01:00
|
|
|
CoTaskMemFree(ppOldPins);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-08 12:03:06 +01:00
|
|
|
CoTaskMemFree(This->ppPins);
|
2005-02-08 14:43:59 +01:00
|
|
|
This->ppPins = ppOldPins;
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("Failed with error %x\n", hr);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
|
|
|
|
{
|
|
|
|
/* NOTE: should be in critical section when calling this function */
|
2008-04-25 23:59:05 +02:00
|
|
|
HRESULT hr;
|
2005-02-08 14:43:59 +01:00
|
|
|
ULONG i;
|
|
|
|
IPin ** ppOldPins = This->ppPins;
|
|
|
|
|
2008-04-25 23:59:05 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
2005-02-08 14:43:59 +01:00
|
|
|
/* reduce the pin array down to 1 (just our input pin) */
|
2007-03-08 12:03:06 +01:00
|
|
|
This->ppPins = CoTaskMemAlloc(sizeof(IPin *) * 1);
|
2005-02-08 14:43:59 +01:00
|
|
|
memcpy(This->ppPins, ppOldPins, sizeof(IPin *) * 1);
|
|
|
|
|
|
|
|
for (i = 0; i < This->cStreams; i++)
|
|
|
|
{
|
2010-10-13 18:02:14 +02:00
|
|
|
hr = ((BaseOutputPin *)ppOldPins[i + 1])->pFuncsTable->pfnBreakConnect((BaseOutputPin *)ppOldPins[i + 1]);
|
2008-04-30 23:39:36 +02:00
|
|
|
TRACE("Disconnect: %08x\n", hr);
|
2005-02-08 14:43:59 +01:00
|
|
|
IPin_Release(ppOldPins[i + 1]);
|
|
|
|
}
|
|
|
|
|
2012-05-21 15:21:48 +02:00
|
|
|
BaseFilterImpl_IncrementPinVersion(&This->filter);
|
2008-04-25 23:59:05 +02:00
|
|
|
This->cStreams = 0;
|
2007-03-08 12:03:06 +01:00
|
|
|
CoTaskMemFree(ppOldPins);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-11 17:15:35 +02:00
|
|
|
static HRESULT WINAPI Parser_ChangeStart(IMediaSeeking *iface)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2010-10-11 17:15:35 +02:00
|
|
|
FIXME("(%p) filter hasn't implemented start position change!\n", iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-11 17:15:35 +02:00
|
|
|
static HRESULT WINAPI Parser_ChangeStop(IMediaSeeking *iface)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2008-03-26 00:11:22 +01:00
|
|
|
FIXME("(%p) filter hasn't implemented stop position change!\n", iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-11 17:15:35 +02:00
|
|
|
static HRESULT WINAPI Parser_ChangeRate(IMediaSeeking *iface)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2008-03-26 00:11:22 +01:00
|
|
|
FIXME("(%p) filter hasn't implemented rate change!\n", iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI Parser_Seeking_QueryInterface(IMediaSeeking * iface, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
2008-03-19 00:05:00 +01:00
|
|
|
ParserImpl *This = impl_from_IMediaSeeking(iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2015-10-21 13:31:49 +02:00
|
|
|
return IBaseFilter_QueryInterface(&This->filter.IBaseFilter_iface, riid, ppv);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Parser_Seeking_AddRef(IMediaSeeking * iface)
|
|
|
|
{
|
2008-03-19 00:05:00 +01:00
|
|
|
ParserImpl *This = impl_from_IMediaSeeking(iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2015-10-21 13:31:49 +02:00
|
|
|
return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Parser_Seeking_Release(IMediaSeeking * iface)
|
|
|
|
{
|
2008-03-19 00:05:00 +01:00
|
|
|
ParserImpl *This = impl_from_IMediaSeeking(iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2015-10-21 13:31:49 +02:00
|
|
|
return IBaseFilter_Release(&This->filter.IBaseFilter_iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IMediaSeekingVtbl Parser_Seeking_Vtbl =
|
|
|
|
{
|
|
|
|
Parser_Seeking_QueryInterface,
|
|
|
|
Parser_Seeking_AddRef,
|
|
|
|
Parser_Seeking_Release,
|
2010-10-11 17:15:35 +02:00
|
|
|
SourceSeekingImpl_GetCapabilities,
|
|
|
|
SourceSeekingImpl_CheckCapabilities,
|
|
|
|
SourceSeekingImpl_IsFormatSupported,
|
|
|
|
SourceSeekingImpl_QueryPreferredFormat,
|
|
|
|
SourceSeekingImpl_GetTimeFormat,
|
|
|
|
SourceSeekingImpl_IsUsingTimeFormat,
|
|
|
|
SourceSeekingImpl_SetTimeFormat,
|
|
|
|
SourceSeekingImpl_GetDuration,
|
|
|
|
SourceSeekingImpl_GetStopPosition,
|
|
|
|
SourceSeekingImpl_GetCurrentPosition,
|
|
|
|
SourceSeekingImpl_ConvertTimeFormat,
|
|
|
|
SourceSeekingImpl_SetPositions,
|
|
|
|
SourceSeekingImpl_GetPositions,
|
|
|
|
SourceSeekingImpl_GetAvailable,
|
|
|
|
SourceSeekingImpl_SetRate,
|
|
|
|
SourceSeekingImpl_GetRate,
|
|
|
|
SourceSeekingImpl_GetPreroll
|
2005-02-08 14:43:59 +01:00
|
|
|
};
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
|
2010-10-13 17:46:27 +02:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
Parser_OutputPin *This = (Parser_OutputPin*)iface;
|
2010-10-13 17:46:27 +02:00
|
|
|
ALLOCATOR_PROPERTIES actual;
|
|
|
|
|
|
|
|
if (ppropInputRequest->cbAlign && ppropInputRequest->cbAlign != This->allocProps.cbAlign)
|
|
|
|
FIXME("Requested Buffer cbAlign mismatch %i,%i\n",This->allocProps.cbAlign, ppropInputRequest->cbAlign);
|
|
|
|
if (ppropInputRequest->cbPrefix)
|
|
|
|
FIXME("Requested Buffer cbPrefix mismatch %i,%i\n",This->allocProps.cbPrefix, ppropInputRequest->cbPrefix);
|
|
|
|
if (ppropInputRequest->cbBuffer)
|
|
|
|
FIXME("Requested Buffer cbBuffer mismatch %i,%i\n",This->allocProps.cbBuffer, ppropInputRequest->cbBuffer);
|
|
|
|
if (ppropInputRequest->cBuffers)
|
|
|
|
FIXME("Requested Buffer cBuffers mismatch %i,%i\n",This->allocProps.cBuffers, ppropInputRequest->cBuffers);
|
|
|
|
|
|
|
|
return IMemAllocator_SetProperties(pAlloc, &This->allocProps, &actual);
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
|
2010-10-05 21:37:30 +02:00
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
Parser_OutputPin *This = (Parser_OutputPin*)iface;
|
2010-10-05 21:37:30 +02:00
|
|
|
if (iPosition < 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (iPosition > 0)
|
|
|
|
return VFW_S_NO_MORE_ITEMS;
|
|
|
|
CopyMediaType(pmt, This->pmt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:14 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_DecideAllocator(BaseOutputPin *iface, IMemInputPin *pPin, IMemAllocator **pAlloc)
|
|
|
|
{
|
2012-05-21 15:21:48 +02:00
|
|
|
Parser_OutputPin *This = (Parser_OutputPin*)iface;
|
2010-10-13 18:02:14 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2011-04-05 00:48:01 +02:00
|
|
|
*pAlloc = NULL;
|
2010-10-13 18:02:14 +02:00
|
|
|
|
|
|
|
if (This->alloc)
|
2013-01-17 06:40:39 +01:00
|
|
|
{
|
2010-10-13 18:02:14 +02:00
|
|
|
hr = IMemInputPin_NotifyAllocator(pPin, This->alloc, This->readonly);
|
2013-01-17 06:40:39 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
*pAlloc = This->alloc;
|
|
|
|
IMemAllocator_AddRef(*pAlloc);
|
|
|
|
}
|
|
|
|
}
|
2010-10-13 18:02:14 +02:00
|
|
|
else
|
|
|
|
hr = VFW_E_NO_ALLOCATOR;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Parser_OutputPin_BreakConnect(BaseOutputPin *This)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
|
|
|
if (!This->pin.pConnectedTo || !This->pMemInputPin)
|
|
|
|
hr = VFW_E_NOT_CONNECTED;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IPin_Disconnect(This->pin.pConnectedTo);
|
2012-05-21 15:21:48 +02:00
|
|
|
IPin_Disconnect(&This->pin.IPin_iface);
|
2010-10-13 18:02:14 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-23 21:53:30 +01:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2012-05-21 15:21:41 +02:00
|
|
|
Parser_OutputPin *This = unsafe_impl_Parser_OutputPin_from_IPin(iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = iface;
|
2005-02-08 14:43:59 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IPin))
|
2009-01-29 11:14:55 +01:00
|
|
|
*ppv = iface;
|
2011-05-14 19:14:36 +02:00
|
|
|
/* The Parser filter does not support querying IMediaSeeking, return it directly */
|
2005-02-08 14:43:59 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IMediaSeeking))
|
2012-05-21 15:21:48 +02:00
|
|
|
*ppv = &impl_from_IBaseFilter(This->pin.pin.pinInfo.pFilter)->sourceSeeking;
|
2005-02-08 14:43:59 +01: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)
|
|
|
|
{
|
2012-05-21 15:21:41 +02:00
|
|
|
Parser_OutputPin *This = unsafe_impl_Parser_OutputPin_from_IPin(iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->pin.pin.refCount);
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
|
2008-04-25 23:59:05 +02:00
|
|
|
|
2005-02-08 14:43:59 +01:00
|
|
|
if (!refCount)
|
|
|
|
{
|
2005-06-05 21:18:34 +02:00
|
|
|
FreeMediaType(This->pmt);
|
2005-02-08 14:43:59 +01:00
|
|
|
CoTaskMemFree(This->pmt);
|
2005-06-05 21:18:34 +02:00
|
|
|
FreeMediaType(&This->pin.pin.mtCurrent);
|
2013-01-17 06:40:39 +01:00
|
|
|
if (This->pin.pAllocator)
|
|
|
|
IMemAllocator_Release(This->pin.pAllocator);
|
2005-02-08 14:43:59 +01:00
|
|
|
CoTaskMemFree(This);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
2012-05-21 15:21:41 +02:00
|
|
|
Parser_OutputPin *This = unsafe_impl_Parser_OutputPin_from_IPin(iface);
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *parser = impl_from_IBaseFilter(This->pin.pin.pinInfo.pFilter);
|
2008-04-22 22:57:11 +02:00
|
|
|
|
|
|
|
/* Set the allocator to our input pin's */
|
|
|
|
EnterCriticalSection(This->pin.pin.pCritSec);
|
2010-10-13 18:02:14 +02:00
|
|
|
This->alloc = parser->pInputPin->pAlloc;
|
2008-04-22 22:57:11 +02:00
|
|
|
LeaveCriticalSection(This->pin.pin.pCritSec);
|
|
|
|
|
2010-10-05 21:37:56 +02:00
|
|
|
return BaseOutputPinImpl_Connect(iface, pReceivePin, pmt);
|
2008-04-22 22:57:11 +02:00
|
|
|
}
|
|
|
|
|
2018-05-04 06:47:13 +02:00
|
|
|
static HRESULT WINAPI Parser_OutputPin_CheckMediaType(BasePin *pin, const AM_MEDIA_TYPE *pmt)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2018-05-04 06:47:13 +02:00
|
|
|
Parser_OutputPin *This = (Parser_OutputPin *)pin;
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
|
|
|
|
return (memcmp(This->pmt, pmt, sizeof(AM_MEDIA_TYPE)) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPinVtbl Parser_OutputPin_Vtbl =
|
|
|
|
{
|
|
|
|
Parser_OutputPin_QueryInterface,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_AddRef,
|
2005-02-08 14:43:59 +01:00
|
|
|
Parser_OutputPin_Release,
|
2008-04-22 22:57:11 +02:00
|
|
|
Parser_OutputPin_Connect,
|
2010-10-05 21:37:56 +02:00
|
|
|
BaseOutputPinImpl_ReceiveConnection,
|
|
|
|
BaseOutputPinImpl_Disconnect,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
2018-05-04 06:47:13 +02:00
|
|
|
BasePinImpl_QueryAccept,
|
2010-10-13 18:02:08 +02:00
|
|
|
BasePinImpl_EnumMediaTypes,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_QueryInternalConnections,
|
2010-10-05 21:37:56 +02:00
|
|
|
BaseOutputPinImpl_EndOfStream,
|
|
|
|
BaseOutputPinImpl_BeginFlush,
|
|
|
|
BaseOutputPinImpl_EndFlush,
|
2010-11-01 13:42:14 +01:00
|
|
|
BasePinImpl_NewSegment
|
2005-02-08 14:43:59 +01:00
|
|
|
};
|
|
|
|
|
2011-05-14 19:14:45 +02:00
|
|
|
static HRESULT WINAPI Parser_PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
2012-04-04 15:27:25 +02:00
|
|
|
PullPin *This = impl_PullPin_from_IPin(iface);
|
2011-05-14 19:14:45 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* It is important to capture the request for the IMediaSeeking interface before it is passed
|
|
|
|
* on to PullPin_QueryInterface, this is necessary since the Parser filter does not support
|
|
|
|
* querying IMediaSeeking
|
|
|
|
*/
|
|
|
|
if (IsEqualIID(riid, &IID_IMediaSeeking))
|
2012-05-21 15:21:48 +02:00
|
|
|
*ppv = &impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->sourceSeeking;
|
2011-05-14 19:14:45 +02:00
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)(*ppv));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PullPin_QueryInterface(iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
2008-04-16 05:39:36 +02:00
|
|
|
static HRESULT WINAPI Parser_PullPin_Disconnect(IPin * iface)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2012-04-04 15:27:25 +02:00
|
|
|
PullPin *This = impl_PullPin_from_IPin(iface);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
2008-04-25 23:59:05 +02:00
|
|
|
EnterCriticalSection(&This->thread_lock);
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2008-04-25 23:59:05 +02:00
|
|
|
if (This->pin.pConnectedTo)
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
|
|
|
FILTER_STATE state;
|
2012-05-21 15:21:48 +02:00
|
|
|
ParserImpl *Parser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-25 23:59:05 +02:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
hr = IBaseFilter_GetState(This->pin.pinInfo.pFilter, INFINITE, &state);
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
2005-02-08 14:43:59 +01:00
|
|
|
|
2008-04-16 05:39:36 +02:00
|
|
|
if (SUCCEEDED(hr) && (state == State_Stopped) && SUCCEEDED(Parser->fnDisconnect(Parser)))
|
2005-02-08 14:43:59 +01:00
|
|
|
{
|
2008-06-24 17:52:52 +02:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
PullPin_Disconnect(iface);
|
|
|
|
EnterCriticalSection(This->pin.pCritSec);
|
2012-05-21 15:21:48 +02:00
|
|
|
hr = Parser_RemoveOutputPins(impl_from_IBaseFilter(This->pin.pinInfo.pFilter));
|
2005-02-08 14:43:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = VFW_E_NOT_STOPPED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = S_FALSE;
|
|
|
|
}
|
2008-04-25 23:59:05 +02:00
|
|
|
LeaveCriticalSection(This->pin.pCritSec);
|
|
|
|
LeaveCriticalSection(&This->thread_lock);
|
|
|
|
|
2005-02-08 14:43:59 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-12-02 15:25:19 +01:00
|
|
|
static HRESULT WINAPI Parser_PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
2007-03-30 14:36:21 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
hr = PullPin_ReceiveConnection(iface, pReceivePin, pmt);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePin *This = (BasePin *)iface;
|
2007-03-30 14:36:21 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(This->pCritSec);
|
2012-05-21 15:21:48 +02:00
|
|
|
Parser_RemoveOutputPins(impl_from_IBaseFilter(This->pinInfo.pFilter));
|
2007-03-30 14:36:21 +02:00
|
|
|
LeaveCriticalSection(This->pCritSec);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-11-07 16:13:56 +01:00
|
|
|
static HRESULT WINAPI Parser_PullPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **ppEnum)
|
|
|
|
{
|
|
|
|
BasePin *This = (BasePin *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
|
|
|
|
|
|
|
|
return EnumMediaTypes_Construct(This, BasePinImpl_GetMediaType, BasePinImpl_GetMediaTypeVersion, ppEnum);
|
|
|
|
}
|
|
|
|
|
2005-02-08 14:43:59 +01:00
|
|
|
static const IPinVtbl Parser_InputPin_Vtbl =
|
|
|
|
{
|
2011-05-14 19:14:45 +02:00
|
|
|
Parser_PullPin_QueryInterface,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_AddRef,
|
2005-02-08 14:43:59 +01:00
|
|
|
PullPin_Release,
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPinImpl_Connect,
|
2007-03-30 14:36:21 +02:00
|
|
|
Parser_PullPin_ReceiveConnection,
|
2008-04-16 05:39:36 +02:00
|
|
|
Parser_PullPin_Disconnect,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
|
|
|
PullPin_QueryAccept,
|
2010-11-07 16:13:56 +01:00
|
|
|
Parser_PullPin_EnumMediaTypes,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_QueryInternalConnections,
|
2005-02-08 14:43:59 +01:00
|
|
|
PullPin_EndOfStream,
|
|
|
|
PullPin_BeginFlush,
|
|
|
|
PullPin_EndFlush,
|
|
|
|
PullPin_NewSegment
|
|
|
|
};
|