quartz: Pass InputPin as parameter to transform filter.

This commit is contained in:
Maarten Lankhorst 2008-07-22 05:35:28 -07:00 committed by Alexandre Julliard
parent 2b452ced74
commit 89f4eeece3
4 changed files with 42 additions and 44 deletions

View File

@ -52,9 +52,9 @@ typedef struct ACMWrapperImpl
LONGLONG lasttime_sent; LONGLONG lasttime_sent;
} ACMWrapperImpl; } ACMWrapperImpl;
static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilter, IMediaSample *pSample) static HRESULT ACMWrapper_ProcessSampleData(InputPin *pin, IMediaSample *pSample)
{ {
ACMWrapperImpl* This = (ACMWrapperImpl*)pTransformFilter; ACMWrapperImpl* This = (ACMWrapperImpl*)pin->pin.pinInfo.pFilter;
AM_MEDIA_TYPE amt; AM_MEDIA_TYPE amt;
IMediaSample* pOutSample = NULL; IMediaSample* pOutSample = NULL;
DWORD cbDstStream, cbSrcStream; DWORD cbDstStream, cbSrcStream;
@ -65,18 +65,17 @@ static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilte
MMRESULT res; MMRESULT res;
HRESULT hr; HRESULT hr;
LONGLONG tStart = -1, tStop = -1, tMed; LONGLONG tStart = -1, tStop = -1, tMed;
InputPin *pin = (InputPin *)pTransformFilter->ppPins[0];
EnterCriticalSection(&pTransformFilter->csFilter); EnterCriticalSection(&This->tf.csFilter);
if (pTransformFilter->state == State_Stopped) if (This->tf.state == State_Stopped)
{ {
LeaveCriticalSection(&pTransformFilter->csFilter); LeaveCriticalSection(&This->tf.csFilter);
return VFW_E_WRONG_STATE; return VFW_E_WRONG_STATE;
} }
if (pin->end_of_stream || pin->flushing) if (pin->end_of_stream || pin->flushing)
{ {
LeaveCriticalSection(&pTransformFilter->csFilter); LeaveCriticalSection(&This->tf.csFilter);
return S_FALSE; return S_FALSE;
} }
@ -84,7 +83,7 @@ static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilte
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("Cannot get pointer to sample data (%x)\n", hr); ERR("Cannot get pointer to sample data (%x)\n", hr);
LeaveCriticalSection(&pTransformFilter->csFilter); LeaveCriticalSection(&This->tf.csFilter);
return hr; return hr;
} }
@ -112,7 +111,7 @@ static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilte
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("Unable to retrieve media type\n"); ERR("Unable to retrieve media type\n");
LeaveCriticalSection(&pTransformFilter->csFilter); LeaveCriticalSection(&This->tf.csFilter);
return hr; return hr;
} }
@ -125,7 +124,7 @@ static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilte
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("Unable to get delivery buffer (%x)\n", hr); ERR("Unable to get delivery buffer (%x)\n", hr);
LeaveCriticalSection(&pTransformFilter->csFilter); LeaveCriticalSection(&This->tf.csFilter);
return hr; return hr;
} }
IMediaSample_SetPreroll(pOutSample, preroll); IMediaSample_SetPreroll(pOutSample, preroll);
@ -231,13 +230,13 @@ error:
This->lasttime_real = tStop; This->lasttime_real = tStop;
This->lasttime_sent = tMed; This->lasttime_sent = tMed;
LeaveCriticalSection(&pTransformFilter->csFilter); LeaveCriticalSection(&This->tf.csFilter);
return hr; return hr;
} }
static HRESULT ACMWrapper_ConnectInput(TransformFilterImpl* pTransformFilter, const AM_MEDIA_TYPE * pmt) static HRESULT ACMWrapper_ConnectInput(InputPin *pin, const AM_MEDIA_TYPE * pmt)
{ {
ACMWrapperImpl* This = (ACMWrapperImpl*)pTransformFilter; ACMWrapperImpl* This = (ACMWrapperImpl *)pin->pin.pinInfo.pFilter;
MMRESULT res; MMRESULT res;
TRACE("(%p)->(%p)\n", This, pmt); TRACE("(%p)->(%p)\n", This, pmt);
@ -287,14 +286,14 @@ static HRESULT ACMWrapper_ConnectInput(TransformFilterImpl* pTransformFilter, co
return VFW_E_TYPE_NOT_ACCEPTED; return VFW_E_TYPE_NOT_ACCEPTED;
} }
static HRESULT ACMWrapper_Cleanup(TransformFilterImpl* pTransformFilter) static HRESULT ACMWrapper_Cleanup(InputPin *pin)
{ {
ACMWrapperImpl* This = (ACMWrapperImpl*)pTransformFilter; ACMWrapperImpl *This = (ACMWrapperImpl *)pin->pin.pinInfo.pFilter;
TRACE("(%p)->()\n", This); TRACE("(%p)->()\n", This);
if (This->has) if (This->has)
acmStreamClose(This->has, 0); acmStreamClose(This->has, 0);
This->has = 0; This->has = 0;
This->lasttime_real = This->lasttime_sent = -1; This->lasttime_real = This->lasttime_sent = -1;

View File

@ -42,8 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(quartz); WINE_DEFAULT_DEBUG_CHANNEL(quartz);
static HRESULT AVIDec_Cleanup(TransformFilterImpl* pTransformFilter);
typedef struct AVIDecImpl typedef struct AVIDecImpl
{ {
TransformFilterImpl tf; TransformFilterImpl tf;
@ -68,9 +66,9 @@ static HRESULT AVIDec_ProcessBegin(TransformFilterImpl* pTransformFilter)
return S_OK; return S_OK;
} }
static HRESULT AVIDec_ProcessSampleData(TransformFilterImpl* pTransformFilter, IMediaSample *pSample) static HRESULT AVIDec_ProcessSampleData(InputPin *pin, IMediaSample *pSample)
{ {
AVIDecImpl* This = (AVIDecImpl*)pTransformFilter; AVIDecImpl* This = (AVIDecImpl *)pin->pin.pinInfo.pFilter;
AM_MEDIA_TYPE amt; AM_MEDIA_TYPE amt;
HRESULT hr; HRESULT hr;
DWORD res; DWORD res;
@ -80,7 +78,6 @@ static HRESULT AVIDec_ProcessSampleData(TransformFilterImpl* pTransformFilter, I
DWORD cbSrcStream; DWORD cbSrcStream;
LPBYTE pbSrcStream; LPBYTE pbSrcStream;
LONGLONG tStart, tStop; LONGLONG tStart, tStop;
InputPin *pin = (InputPin *)pTransformFilter->ppPins[0];
EnterCriticalSection(&This->tf.csFilter); EnterCriticalSection(&This->tf.csFilter);
if (This->tf.state == State_Stopped) if (This->tf.state == State_Stopped)
@ -185,15 +182,13 @@ static HRESULT AVIDec_ProcessEnd(TransformFilterImpl* pTransformFilter)
return S_OK; return S_OK;
} }
static HRESULT AVIDec_ConnectInput(TransformFilterImpl* pTransformFilter, const AM_MEDIA_TYPE * pmt) static HRESULT AVIDec_ConnectInput(InputPin *pin, const AM_MEDIA_TYPE * pmt)
{ {
AVIDecImpl* This = (AVIDecImpl*)pTransformFilter; AVIDecImpl* This = (AVIDecImpl*)pin->pin.pinInfo.pFilter;
HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED; HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
TRACE("(%p)->(%p)\n", This, pmt); TRACE("(%p)->(%p)\n", This, pmt);
AVIDec_Cleanup(pTransformFilter);
/* Check root (GUID w/o FOURCC) */ /* Check root (GUID w/o FOURCC) */
if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) && if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) &&
(!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Video)+4, sizeof(GUID)-4))) (!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Video)+4, sizeof(GUID)-4)))
@ -283,15 +278,14 @@ static HRESULT AVIDec_ConnectInput(TransformFilterImpl* pTransformFilter, const
} }
failed: failed:
AVIDec_Cleanup(pTransformFilter);
TRACE("Connection refused\n"); TRACE("Connection refused\n");
return hr; return hr;
} }
static HRESULT AVIDec_Cleanup(TransformFilterImpl* pTransformFilter) static HRESULT AVIDec_Cleanup(InputPin *pin)
{ {
AVIDecImpl* This = (AVIDecImpl*)pTransformFilter; AVIDecImpl *This = (AVIDecImpl *)pin->pin.pinInfo.pFilter;
TRACE("(%p)->()\n", This); TRACE("(%p)->()\n", This);

View File

@ -50,7 +50,7 @@ static const IPinVtbl TransformFilter_OutputPin_Vtbl;
static HRESULT TransformFilter_Input_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt) static HRESULT TransformFilter_Input_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
{ {
TransformFilterImpl* This = (TransformFilterImpl*)iface; TransformFilterImpl* This = (TransformFilterImpl *)((IPinImpl *)iface)->pinInfo.pFilter;
TRACE("%p\n", iface); TRACE("%p\n", iface);
dump_AM_MEDIA_TYPE(pmt); dump_AM_MEDIA_TYPE(pmt);
@ -68,7 +68,8 @@ static HRESULT TransformFilter_Output_QueryAccept(LPVOID iface, const AM_MEDIA_T
AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt; AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt;
TRACE("%p\n", iface); TRACE("%p\n", iface);
if (IsEqualIID(&pmt->majortype, &outpmt->majortype) && IsEqualIID(&pmt->subtype, &outpmt->subtype)) if (IsEqualIID(&pmt->majortype, &outpmt->majortype)
&& (IsEqualIID(&pmt->subtype, &outpmt->subtype) || IsEqualIID(&outpmt->subtype, &GUID_NULL)))
return S_OK; return S_OK;
return S_FALSE; return S_FALSE;
} }
@ -165,6 +166,7 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
pTransformFilter->pClock = NULL; pTransformFilter->pClock = NULL;
ZeroMemory(&pTransformFilter->filterInfo, sizeof(FILTER_INFO)); ZeroMemory(&pTransformFilter->filterInfo, sizeof(FILTER_INFO));
ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt)); ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt));
pTransformFilter->npins = 2;
pTransformFilter->ppPins = CoTaskMemAlloc(2 * sizeof(IPin *)); pTransformFilter->ppPins = CoTaskMemAlloc(2 * sizeof(IPin *));
@ -176,7 +178,7 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
piOutput.pFilter = (IBaseFilter *)pTransformFilter; piOutput.pFilter = (IBaseFilter *)pTransformFilter;
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0])); lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
hr = InputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, (SAMPLEPROC_PUSH)pFuncsTable->pfnProcessSampleData, pTransformFilter, TransformFilter_Input_QueryAccept, NULL, &pTransformFilter->csFilter, NULL, &pTransformFilter->ppPins[0]); hr = InputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, (SAMPLEPROC_PUSH)pFuncsTable->pfnProcessSampleData, NULL, TransformFilter_Input_QueryAccept, NULL, &pTransformFilter->csFilter, NULL, &pTransformFilter->ppPins[0]);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
@ -186,6 +188,8 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
props.cbBuffer = 0; /* Will be updated at connection time */ props.cbBuffer = 0; /* Will be updated at connection time */
props.cBuffers = 1; props.cBuffers = 1;
((InputPin *)pTransformFilter->ppPins[0])->pin.pUserData = pTransformFilter->ppPins[0];
hr = OutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(OutputPin), &piOutput, &props, pTransformFilter, TransformFilter_Output_QueryAccept, &pTransformFilter->csFilter, &pTransformFilter->ppPins[1]); hr = OutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(OutputPin), &piOutput, &props, pTransformFilter, TransformFilter_Output_QueryAccept, &pTransformFilter->csFilter, &pTransformFilter->ppPins[1]);
if (FAILED(hr)) if (FAILED(hr))
@ -268,7 +272,7 @@ static ULONG WINAPI TransformFilter_Release(IBaseFilter * iface)
if (This->pClock) if (This->pClock)
IReferenceClock_Release(This->pClock); IReferenceClock_Release(This->pClock);
for (i = 0; i < 2; i++) for (i = 0; i < This->npins; i++)
{ {
IPin *pConnectedTo; IPin *pConnectedTo;
@ -442,7 +446,7 @@ static HRESULT TransformFilter_GetPin(IBaseFilter *iface, ULONG pos, IPin **pin,
/* Our pins are static, not changing so setting static tick count is ok */ /* Our pins are static, not changing so setting static tick count is ok */
*lastsynctick = 0; *lastsynctick = 0;
if (pos >= 2) if (pos >= This->npins)
return S_FALSE; return S_FALSE;
*pin = This->ppPins[pos]; *pin = This->ppPins[pos];
@ -565,12 +569,12 @@ static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, I
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter; pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter;
hr = pTransform->pFuncsTable->pfnConnectInput(pTransform, pmt); hr = pTransform->pFuncsTable->pfnConnectInput(This, pmt);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = InputPin_ReceiveConnection(iface, pReceivePin, pmt); hr = InputPin_ReceiveConnection(iface, pReceivePin, pmt);
if (FAILED(hr)) if (FAILED(hr))
pTransform->pFuncsTable->pfnCleanup(pTransform); pTransform->pFuncsTable->pfnCleanup(This);
} }
return hr; return hr;
@ -584,7 +588,7 @@ static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
TRACE("(%p)->()\n", iface); TRACE("(%p)->()\n", iface);
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter; pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter;
pTransform->pFuncsTable->pfnCleanup(pTransform); pTransform->pFuncsTable->pfnCleanup(This);
return IPinImpl_Disconnect(iface); return IPinImpl_Disconnect(iface);
} }

View File

@ -23,12 +23,12 @@
typedef struct TransformFilterImpl TransformFilterImpl; typedef struct TransformFilterImpl TransformFilterImpl;
typedef struct TransformFuncsTable { typedef struct TransformFuncsTable {
HRESULT (*pfnProcessBegin) (TransformFilterImpl* This); HRESULT (*pfnProcessBegin) (TransformFilterImpl *This);
HRESULT (*pfnProcessSampleData) (TransformFilterImpl* This, IMediaSample *pSample); HRESULT (*pfnProcessSampleData) (InputPin *pin, IMediaSample *pSample);
HRESULT (*pfnProcessEnd) (TransformFilterImpl* This); HRESULT (*pfnProcessEnd) (TransformFilterImpl *This);
HRESULT (*pfnQueryConnect) (TransformFilterImpl* This, const AM_MEDIA_TYPE * pmt); HRESULT (*pfnQueryConnect) (TransformFilterImpl *This, const AM_MEDIA_TYPE * pmt);
HRESULT (*pfnConnectInput) (TransformFilterImpl* This, const AM_MEDIA_TYPE * pmt); HRESULT (*pfnConnectInput) (InputPin *pin, const AM_MEDIA_TYPE * pmt);
HRESULT (*pfnCleanup) (TransformFilterImpl* This); HRESULT (*pfnCleanup) (InputPin *pin);
} TransformFuncsTable; } TransformFuncsTable;
struct TransformFilterImpl struct TransformFilterImpl
@ -44,7 +44,8 @@ struct TransformFilterImpl
CLSID clsid; CLSID clsid;
struct MediaSeekingImpl mediaSeeking; struct MediaSeekingImpl mediaSeeking;
IPin ** ppPins; IPin **ppPins;
ULONG npins;
AM_MEDIA_TYPE pmt; AM_MEDIA_TYPE pmt;
const TransformFuncsTable * pFuncsTable; const TransformFuncsTable * pFuncsTable;