2005-01-31 17:24:00 +01:00
|
|
|
/*
|
|
|
|
* Transform Filter (Base for decoders, etc...)
|
|
|
|
*
|
|
|
|
* Copyright 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-01-31 17:24:00 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
#include "control_private.h"
|
|
|
|
#include "pin.h"
|
|
|
|
|
|
|
|
#include "amvideo.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "dshow.h"
|
|
|
|
#include "strmif.h"
|
|
|
|
#include "vfw.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "transform.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
|
|
|
static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
|
|
|
|
static const WCHAR wcsOutputPinName[] = {'o','u','t','p','u','t',' ','p','i','n',0};
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl TransformFilter_Vtbl;
|
|
|
|
static const IPinVtbl TransformFilter_InputPin_Vtbl;
|
|
|
|
static const IPinVtbl TransformFilter_OutputPin_Vtbl;
|
|
|
|
|
|
|
|
static HRESULT TransformFilter_Input_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
2008-07-22 14:35:28 +02:00
|
|
|
TransformFilterImpl* This = (TransformFilterImpl *)((IPinImpl *)iface)->pinInfo.pFilter;
|
2005-01-31 17:24:00 +01:00
|
|
|
TRACE("%p\n", iface);
|
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
|
|
|
|
2007-04-03 09:06:16 +02:00
|
|
|
if (This->pFuncsTable->pfnQueryConnect)
|
|
|
|
return This->pFuncsTable->pfnQueryConnect(This, pmt);
|
|
|
|
/* Assume OK if there's no query method (the connection will fail if
|
|
|
|
needed) */
|
2007-04-03 08:45:27 +02:00
|
|
|
return S_OK;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT TransformFilter_Output_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
|
|
|
TransformFilterImpl* pTransformFilter = (TransformFilterImpl*)iface;
|
2008-07-22 13:13:44 +02:00
|
|
|
AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt;
|
2005-01-31 17:24:00 +01:00
|
|
|
TRACE("%p\n", iface);
|
|
|
|
|
2008-07-22 14:35:28 +02:00
|
|
|
if (IsEqualIID(&pmt->majortype, &outpmt->majortype)
|
|
|
|
&& (IsEqualIID(&pmt->subtype, &outpmt->subtype) || IsEqualIID(&outpmt->subtype, &GUID_NULL)))
|
2005-01-31 17:24:00 +01:00
|
|
|
return S_OK;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-01 22:41:25 +02:00
|
|
|
|
|
|
|
static inline TransformFilterImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
|
|
|
|
{
|
|
|
|
return (TransformFilterImpl *)((char*)iface - FIELD_OFFSET(TransformFilterImpl, mediaSeeking.lpVtbl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_Seeking_QueryInterface(IMediaSeeking * iface, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = impl_from_IMediaSeeking(iface);
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface((IUnknown *)This, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TransformFilter_Seeking_AddRef(IMediaSeeking * iface)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = impl_from_IMediaSeeking(iface);
|
|
|
|
|
|
|
|
return IUnknown_AddRef((IUnknown *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TransformFilter_Seeking_Release(IMediaSeeking * iface)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = impl_from_IMediaSeeking(iface);
|
|
|
|
|
|
|
|
return IUnknown_Release((IUnknown *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMediaSeekingVtbl TransformFilter_Seeking_Vtbl =
|
|
|
|
{
|
|
|
|
TransformFilter_Seeking_QueryInterface,
|
|
|
|
TransformFilter_Seeking_AddRef,
|
|
|
|
TransformFilter_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
|
|
|
|
};
|
|
|
|
|
2008-04-13 04:15:34 +02:00
|
|
|
/* These shouldn't be implemented by default.
|
|
|
|
* Usually only source filters should implement these
|
|
|
|
* and even it's not needed all of the time
|
|
|
|
*/
|
2008-04-01 22:41:25 +02:00
|
|
|
static HRESULT TransformFilter_ChangeCurrent(IBaseFilter *iface)
|
|
|
|
{
|
2008-04-13 04:15:34 +02:00
|
|
|
TRACE("(%p) filter hasn't implemented current position change!\n", iface);
|
2008-04-01 22:41:25 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT TransformFilter_ChangeStop(IBaseFilter *iface)
|
|
|
|
{
|
2008-04-13 04:15:34 +02:00
|
|
|
TRACE("(%p) filter hasn't implemented stop position change!\n", iface);
|
2008-04-01 22:41:25 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT TransformFilter_ChangeRate(IBaseFilter *iface)
|
|
|
|
{
|
2008-04-13 04:15:34 +02:00
|
|
|
TRACE("(%p) filter hasn't implemented rate change!\n", iface);
|
2008-04-01 22:41:25 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSID* pClsid, const TransformFuncsTable* pFuncsTable, CHANGEPROC stop, CHANGEPROC current, CHANGEPROC rate)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
PIN_INFO piInput;
|
|
|
|
PIN_INFO piOutput;
|
|
|
|
|
|
|
|
/* pTransformFilter is already allocated */
|
|
|
|
pTransformFilter->clsid = *pClsid;
|
2005-02-21 21:37:45 +01:00
|
|
|
pTransformFilter->pFuncsTable = pFuncsTable;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
pTransformFilter->lpVtbl = &TransformFilter_Vtbl;
|
|
|
|
|
|
|
|
pTransformFilter->refCount = 1;
|
|
|
|
InitializeCriticalSection(&pTransformFilter->csFilter);
|
2007-03-10 22:10:20 +01:00
|
|
|
pTransformFilter->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": TransformFilterImpl.csFilter");
|
2005-01-31 17:24:00 +01:00
|
|
|
pTransformFilter->state = State_Stopped;
|
|
|
|
pTransformFilter->pClock = NULL;
|
|
|
|
ZeroMemory(&pTransformFilter->filterInfo, sizeof(FILTER_INFO));
|
2008-07-11 06:41:35 +02:00
|
|
|
ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt));
|
2008-07-22 14:35:28 +02:00
|
|
|
pTransformFilter->npins = 2;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
pTransformFilter->ppPins = CoTaskMemAlloc(2 * sizeof(IPin *));
|
|
|
|
|
|
|
|
/* construct input pin */
|
|
|
|
piInput.dir = PINDIR_INPUT;
|
|
|
|
piInput.pFilter = (IBaseFilter *)pTransformFilter;
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
|
2005-01-31 17:24:00 +01:00
|
|
|
piOutput.dir = PINDIR_OUTPUT;
|
|
|
|
piOutput.pFilter = (IBaseFilter *)pTransformFilter;
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2008-07-22 14:35:28 +02:00
|
|
|
hr = InputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, (SAMPLEPROC_PUSH)pFuncsTable->pfnProcessSampleData, NULL, TransformFilter_Input_QueryAccept, NULL, &pTransformFilter->csFilter, NULL, &pTransformFilter->ppPins[0]);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ALLOCATOR_PROPERTIES props;
|
|
|
|
props.cbAlign = 1;
|
|
|
|
props.cbPrefix = 0;
|
|
|
|
props.cbBuffer = 0; /* Will be updated at connection time */
|
2008-07-11 20:20:23 +02:00
|
|
|
props.cBuffers = 1;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2008-07-22 14:35:28 +02:00
|
|
|
((InputPin *)pTransformFilter->ppPins[0])->pin.pUserData = pTransformFilter->ppPins[0];
|
|
|
|
|
2008-04-04 23:29:21 +02:00
|
|
|
hr = OutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(OutputPin), &piOutput, &props, pTransformFilter, TransformFilter_Output_QueryAccept, &pTransformFilter->csFilter, &pTransformFilter->ppPins[1]);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2008-04-01 22:41:25 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Cannot create output pin (%x)\n", hr);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!stop)
|
|
|
|
stop = TransformFilter_ChangeStop;
|
|
|
|
if (!current)
|
|
|
|
current = TransformFilter_ChangeCurrent;
|
|
|
|
if (!rate)
|
|
|
|
rate = TransformFilter_ChangeRate;
|
|
|
|
|
|
|
|
MediaSeekingImpl_Init((IBaseFilter*)pTransformFilter, stop, current, rate, &pTransformFilter->mediaSeeking, &pTransformFilter->csFilter);
|
|
|
|
pTransformFilter->mediaSeeking.lpVtbl = &TransformFilter_Seeking_Vtbl;
|
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CoTaskMemFree(pTransformFilter->ppPins);
|
2007-03-10 22:10:20 +01:00
|
|
|
pTransformFilter->csFilter.DebugInfo->Spare[0] = 0;
|
2005-01-31 17:24:00 +01:00
|
|
|
DeleteCriticalSection(&pTransformFilter->csFilter);
|
|
|
|
CoTaskMemFree(pTransformFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
*ppv = (LPVOID)This;
|
|
|
|
else if (IsEqualIID(riid, &IID_IPersist))
|
|
|
|
*ppv = (LPVOID)This;
|
|
|
|
else if (IsEqualIID(riid, &IID_IMediaFilter))
|
|
|
|
*ppv = (LPVOID)This;
|
|
|
|
else if (IsEqualIID(riid, &IID_IBaseFilter))
|
|
|
|
*ppv = (LPVOID)This;
|
2008-04-01 22:41:25 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IMediaSeeking))
|
|
|
|
*ppv = &This->mediaSeeking;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)(*ppv));
|
|
|
|
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-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TransformFilter_AddRef(IBaseFilter * iface)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
ULONG refCount = InterlockedIncrement(&This->refCount);
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TransformFilter_Release(IBaseFilter * iface)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
ULONG refCount = InterlockedDecrement(&This->refCount);
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
if (!refCount)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
|
2005-06-05 21:18:34 +02:00
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_Release(This->pClock);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2008-07-22 14:35:28 +02:00
|
|
|
for (i = 0; i < This->npins; i++)
|
2007-03-13 18:47:47 +01:00
|
|
|
{
|
|
|
|
IPin *pConnectedTo;
|
|
|
|
|
|
|
|
if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[i], &pConnectedTo)))
|
|
|
|
{
|
|
|
|
IPin_Disconnect(pConnectedTo);
|
|
|
|
IPin_Release(pConnectedTo);
|
|
|
|
}
|
|
|
|
IPin_Disconnect(This->ppPins[i]);
|
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
IPin_Release(This->ppPins[i]);
|
2007-03-13 18:47:47 +01:00
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2007-03-08 12:03:06 +01:00
|
|
|
CoTaskMemFree(This->ppPins);
|
2005-01-31 17:24:00 +01:00
|
|
|
This->lpVtbl = NULL;
|
|
|
|
|
2007-03-19 21:26:09 +01:00
|
|
|
This->csFilter.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&This->csFilter);
|
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
TRACE("Destroying transform filter\n");
|
2008-07-11 06:41:35 +02:00
|
|
|
FreeMediaType(&This->pmt);
|
2005-01-31 17:24:00 +01:00
|
|
|
CoTaskMemFree(This);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IPersist methods **/
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_GetClassID(IBaseFilter * iface, CLSID * pClsid)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
|
|
|
|
|
|
|
|
*pClsid = This->clsid;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IMediaFilter methods **/
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_Stop(IBaseFilter * iface)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
2008-07-22 13:09:55 +02:00
|
|
|
HRESULT hr = S_OK;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p/%p)\n", This, iface);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
This->state = State_Stopped;
|
2005-02-21 21:37:45 +01:00
|
|
|
if (This->pFuncsTable->pfnProcessEnd)
|
2008-07-22 13:09:55 +02:00
|
|
|
hr = This->pFuncsTable->pfnProcessEnd(This);
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
2008-07-22 13:09:55 +02:00
|
|
|
return hr;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_Pause(IBaseFilter * iface)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
2008-07-22 13:09:55 +02:00
|
|
|
HRESULT hr;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
2008-04-05 01:27:29 +02:00
|
|
|
if (This->state == State_Stopped)
|
2008-07-22 13:09:55 +02:00
|
|
|
hr = IBaseFilter_Run(iface, -1);
|
|
|
|
else
|
|
|
|
hr = S_OK;
|
2008-04-05 01:27:29 +02:00
|
|
|
|
2008-07-22 13:09:55 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
This->state = State_Paused;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
2008-07-22 13:09:55 +02:00
|
|
|
return hr;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
2008-04-05 01:27:29 +02:00
|
|
|
if (This->state == State_Stopped)
|
2008-07-05 03:42:09 +02:00
|
|
|
{
|
2008-04-05 01:27:29 +02:00
|
|
|
((InputPin *)This->ppPins[0])->end_of_stream = 0;
|
2008-07-05 03:42:09 +02:00
|
|
|
if (This->pFuncsTable->pfnProcessBegin)
|
2008-07-22 13:09:55 +02:00
|
|
|
hr = This->pFuncsTable->pfnProcessBegin(This);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = OutputPin_CommitAllocator((OutputPin *)This->ppPins[1]);
|
2008-07-05 03:42:09 +02:00
|
|
|
}
|
2008-04-05 01:27:29 +02:00
|
|
|
|
2008-07-22 13:09:55 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
This->rtStreamStart = tStart;
|
|
|
|
This->state = State_Running;
|
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
*pState = This->state;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_Release(This->pClock);
|
|
|
|
This->pClock = pClock;
|
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_AddRef(This->pClock);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csFilter);
|
|
|
|
{
|
|
|
|
*ppClock = This->pClock;
|
2008-04-20 00:19:32 +02:00
|
|
|
if (This->pClock)
|
|
|
|
IReferenceClock_AddRef(This->pClock);
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->csFilter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IBaseFilter implementation **/
|
|
|
|
|
2008-04-25 23:25:49 +02:00
|
|
|
static HRESULT TransformFilter_GetPin(IBaseFilter *iface, ULONG pos, IPin **pin, DWORD *lastsynctick)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
/* Our pins are static, not changing so setting static tick count is ok */
|
|
|
|
*lastsynctick = 0;
|
|
|
|
|
2008-07-22 14:35:28 +02:00
|
|
|
if (pos >= This->npins)
|
2008-04-25 23:25:49 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
*pin = This->ppPins[pos];
|
|
|
|
IPin_AddRef(*pin);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
static HRESULT WINAPI TransformFilter_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
|
|
|
|
|
2008-04-25 23:25:49 +02:00
|
|
|
return IEnumPinsImpl_Construct(ppEnum, TransformFilter_GetPin, iface);
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
|
|
|
|
|
|
|
|
strcpyW(pInfo->achName, This->filterInfo.achName);
|
|
|
|
pInfo->pGraph = This->filterInfo.pGraph;
|
|
|
|
|
|
|
|
if (pInfo->pGraph)
|
|
|
|
IFilterGraph_AddRef(pInfo->pGraph);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p, %s)\n", This, iface, 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
|
|
|
|
{
|
|
|
|
TransformFilterImpl *This = (TransformFilterImpl *)iface;
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl TransformFilter_Vtbl =
|
|
|
|
{
|
|
|
|
TransformFilter_QueryInterface,
|
|
|
|
TransformFilter_AddRef,
|
|
|
|
TransformFilter_Release,
|
|
|
|
TransformFilter_GetClassID,
|
|
|
|
TransformFilter_Stop,
|
|
|
|
TransformFilter_Pause,
|
|
|
|
TransformFilter_Run,
|
|
|
|
TransformFilter_GetState,
|
|
|
|
TransformFilter_SetSyncSource,
|
|
|
|
TransformFilter_GetSyncSource,
|
|
|
|
TransformFilter_EnumPins,
|
|
|
|
TransformFilter_FindPin,
|
|
|
|
TransformFilter_QueryFilterInfo,
|
|
|
|
TransformFilter_JoinFilterGraph,
|
|
|
|
TransformFilter_QueryVendorInfo
|
|
|
|
};
|
|
|
|
|
2005-06-20 20:39:40 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface)
|
2005-03-02 11:12:12 +01:00
|
|
|
{
|
|
|
|
InputPin* This = (InputPin*) iface;
|
|
|
|
TransformFilterImpl* pTransform;
|
|
|
|
IPin* ppin;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
|
|
|
/* Since we process samples synchronously, just forward notification downstream */
|
|
|
|
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter;
|
|
|
|
if (!pTransform)
|
|
|
|
hr = E_FAIL;
|
|
|
|
else
|
|
|
|
hr = IPin_ConnectedTo(pTransform->ppPins[1], &ppin);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IPin_EndOfStream(ppin);
|
|
|
|
IPin_Release(ppin);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("%x\n", hr);
|
2005-03-02 11:12:12 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2007-04-03 08:45:27 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
|
|
|
InputPin* This = (InputPin*) iface;
|
|
|
|
TransformFilterImpl* pTransform;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt);
|
|
|
|
|
|
|
|
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter;
|
|
|
|
|
2008-07-22 14:35:28 +02:00
|
|
|
hr = pTransform->pFuncsTable->pfnConnectInput(This, pmt);
|
2007-04-03 08:45:27 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = InputPin_ReceiveConnection(iface, pReceivePin, pmt);
|
|
|
|
if (FAILED(hr))
|
2008-07-22 14:35:28 +02:00
|
|
|
pTransform->pFuncsTable->pfnCleanup(This);
|
2007-04-03 08:45:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
|
|
|
|
{
|
|
|
|
InputPin* This = (InputPin*) iface;
|
|
|
|
TransformFilterImpl* pTransform;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
|
|
|
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter;
|
2008-07-22 14:35:28 +02:00
|
|
|
pTransform->pFuncsTable->pfnCleanup(This);
|
2007-04-03 08:45:27 +02:00
|
|
|
|
|
|
|
return IPinImpl_Disconnect(iface);
|
|
|
|
}
|
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
static const IPinVtbl TransformFilter_InputPin_Vtbl =
|
|
|
|
{
|
|
|
|
InputPin_QueryInterface,
|
|
|
|
IPinImpl_AddRef,
|
|
|
|
InputPin_Release,
|
|
|
|
InputPin_Connect,
|
2007-04-03 08:45:27 +02:00
|
|
|
TransformFilter_InputPin_ReceiveConnection,
|
|
|
|
TransformFilter_InputPin_Disconnect,
|
2005-01-31 17:24:00 +01:00
|
|
|
IPinImpl_ConnectedTo,
|
|
|
|
IPinImpl_ConnectionMediaType,
|
|
|
|
IPinImpl_QueryPinInfo,
|
|
|
|
IPinImpl_QueryDirection,
|
|
|
|
IPinImpl_QueryId,
|
|
|
|
IPinImpl_QueryAccept,
|
|
|
|
IPinImpl_EnumMediaTypes,
|
|
|
|
IPinImpl_QueryInternalConnections,
|
2005-03-02 11:12:12 +01:00
|
|
|
TransformFilter_InputPin_EndOfStream,
|
2005-01-31 17:24:00 +01:00
|
|
|
InputPin_BeginFlush,
|
|
|
|
InputPin_EndFlush,
|
|
|
|
InputPin_NewSegment
|
|
|
|
};
|
|
|
|
|
2005-06-20 20:39:40 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_Output_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
|
|
|
IPinImpl *This = (IPinImpl *)iface;
|
2008-07-11 06:41:35 +02:00
|
|
|
TransformFilterImpl *pTransform = (TransformFilterImpl *)This->pinInfo.pFilter;
|
2005-01-31 17:24:00 +01:00
|
|
|
ENUMMEDIADETAILS emd;
|
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
|
|
|
|
|
|
|
|
emd.cMediaTypes = 1;
|
2008-07-11 06:41:35 +02:00
|
|
|
emd.pMediaTypes = &pTransform->pmt;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
return IEnumMediaTypesImpl_Construct(&emd, ppEnum);
|
|
|
|
}
|
|
|
|
|
2007-04-03 08:45:27 +02:00
|
|
|
static const IPinVtbl TransformFilter_OutputPin_Vtbl =
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
|
|
|
OutputPin_QueryInterface,
|
|
|
|
IPinImpl_AddRef,
|
|
|
|
OutputPin_Release,
|
|
|
|
OutputPin_Connect,
|
|
|
|
OutputPin_ReceiveConnection,
|
2007-04-03 08:45:27 +02:00
|
|
|
OutputPin_Disconnect,
|
2005-01-31 17:24:00 +01:00
|
|
|
IPinImpl_ConnectedTo,
|
|
|
|
IPinImpl_ConnectionMediaType,
|
|
|
|
IPinImpl_QueryPinInfo,
|
|
|
|
IPinImpl_QueryDirection,
|
|
|
|
IPinImpl_QueryId,
|
|
|
|
IPinImpl_QueryAccept,
|
|
|
|
TransformFilter_Output_EnumMediaTypes,
|
|
|
|
IPinImpl_QueryInternalConnections,
|
|
|
|
OutputPin_EndOfStream,
|
|
|
|
OutputPin_BeginFlush,
|
|
|
|
OutputPin_EndFlush,
|
|
|
|
OutputPin_NewSegment
|
|
|
|
};
|