Commit 89f4eeec authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

quartz: Pass InputPin as parameter to transform filter.

parent 2b452ced
......@@ -52,9 +52,9 @@ typedef struct ACMWrapperImpl
LONGLONG lasttime_sent;
} 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;
IMediaSample* pOutSample = NULL;
DWORD cbDstStream, cbSrcStream;
......@@ -65,18 +65,17 @@ static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilte
MMRESULT res;
HRESULT hr;
LONGLONG tStart = -1, tStop = -1, tMed;
InputPin *pin = (InputPin *)pTransformFilter->ppPins[0];
EnterCriticalSection(&pTransformFilter->csFilter);
if (pTransformFilter->state == State_Stopped)
EnterCriticalSection(&This->tf.csFilter);
if (This->tf.state == State_Stopped)
{
LeaveCriticalSection(&pTransformFilter->csFilter);
LeaveCriticalSection(&This->tf.csFilter);
return VFW_E_WRONG_STATE;
}
if (pin->end_of_stream || pin->flushing)
{
LeaveCriticalSection(&pTransformFilter->csFilter);
LeaveCriticalSection(&This->tf.csFilter);
return S_FALSE;
}
......@@ -84,7 +83,7 @@ static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilte
if (FAILED(hr))
{
ERR("Cannot get pointer to sample data (%x)\n", hr);
LeaveCriticalSection(&pTransformFilter->csFilter);
LeaveCriticalSection(&This->tf.csFilter);
return hr;
}
......@@ -112,7 +111,7 @@ static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilte
if (FAILED(hr))
{
ERR("Unable to retrieve media type\n");
LeaveCriticalSection(&pTransformFilter->csFilter);
LeaveCriticalSection(&This->tf.csFilter);
return hr;
}
......@@ -125,7 +124,7 @@ static HRESULT ACMWrapper_ProcessSampleData(TransformFilterImpl* pTransformFilte
if (FAILED(hr))
{
ERR("Unable to get delivery buffer (%x)\n", hr);
LeaveCriticalSection(&pTransformFilter->csFilter);
LeaveCriticalSection(&This->tf.csFilter);
return hr;
}
IMediaSample_SetPreroll(pOutSample, preroll);
......@@ -231,13 +230,13 @@ error:
This->lasttime_real = tStop;
This->lasttime_sent = tMed;
LeaveCriticalSection(&pTransformFilter->csFilter);
LeaveCriticalSection(&This->tf.csFilter);
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;
TRACE("(%p)->(%p)\n", This, pmt);
......@@ -287,14 +286,14 @@ static HRESULT ACMWrapper_ConnectInput(TransformFilterImpl* pTransformFilter, co
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);
if (This->has)
acmStreamClose(This->has, 0);
acmStreamClose(This->has, 0);
This->has = 0;
This->lasttime_real = This->lasttime_sent = -1;
......
......@@ -42,8 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
static HRESULT AVIDec_Cleanup(TransformFilterImpl* pTransformFilter);
typedef struct AVIDecImpl
{
TransformFilterImpl tf;
......@@ -68,9 +66,9 @@ static HRESULT AVIDec_ProcessBegin(TransformFilterImpl* pTransformFilter)
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;
HRESULT hr;
DWORD res;
......@@ -80,7 +78,6 @@ static HRESULT AVIDec_ProcessSampleData(TransformFilterImpl* pTransformFilter, I
DWORD cbSrcStream;
LPBYTE pbSrcStream;
LONGLONG tStart, tStop;
InputPin *pin = (InputPin *)pTransformFilter->ppPins[0];
EnterCriticalSection(&This->tf.csFilter);
if (This->tf.state == State_Stopped)
......@@ -185,15 +182,13 @@ static HRESULT AVIDec_ProcessEnd(TransformFilterImpl* pTransformFilter)
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;
TRACE("(%p)->(%p)\n", This, pmt);
AVIDec_Cleanup(pTransformFilter);
/* Check root (GUID w/o FOURCC) */
if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) &&
(!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:
AVIDec_Cleanup(pTransformFilter);
TRACE("Connection refused\n");
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);
......
......@@ -50,7 +50,7 @@ static const IPinVtbl TransformFilter_OutputPin_Vtbl;
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);
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;
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_FALSE;
}
......@@ -165,6 +166,7 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
pTransformFilter->pClock = NULL;
ZeroMemory(&pTransformFilter->filterInfo, sizeof(FILTER_INFO));
ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt));
pTransformFilter->npins = 2;
pTransformFilter->ppPins = CoTaskMemAlloc(2 * sizeof(IPin *));
......@@ -176,7 +178,7 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
piOutput.pFilter = (IBaseFilter *)pTransformFilter;
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))
{
......@@ -186,6 +188,8 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
props.cbBuffer = 0; /* Will be updated at connection time */
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]);
if (FAILED(hr))
......@@ -268,7 +272,7 @@ static ULONG WINAPI TransformFilter_Release(IBaseFilter * iface)
if (This->pClock)
IReferenceClock_Release(This->pClock);
for (i = 0; i < 2; i++)
for (i = 0; i < This->npins; i++)
{
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 */
*lastsynctick = 0;
if (pos >= 2)
if (pos >= This->npins)
return S_FALSE;
*pin = This->ppPins[pos];
......@@ -565,12 +569,12 @@ static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, I
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter;
hr = pTransform->pFuncsTable->pfnConnectInput(pTransform, pmt);
hr = pTransform->pFuncsTable->pfnConnectInput(This, pmt);
if (SUCCEEDED(hr))
{
hr = InputPin_ReceiveConnection(iface, pReceivePin, pmt);
if (FAILED(hr))
pTransform->pFuncsTable->pfnCleanup(pTransform);
pTransform->pFuncsTable->pfnCleanup(This);
}
return hr;
......@@ -584,7 +588,7 @@ static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
TRACE("(%p)->()\n", iface);
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter;
pTransform->pFuncsTable->pfnCleanup(pTransform);
pTransform->pFuncsTable->pfnCleanup(This);
return IPinImpl_Disconnect(iface);
}
......
......@@ -23,12 +23,12 @@
typedef struct TransformFilterImpl TransformFilterImpl;
typedef struct TransformFuncsTable {
HRESULT (*pfnProcessBegin) (TransformFilterImpl* This);
HRESULT (*pfnProcessSampleData) (TransformFilterImpl* This, IMediaSample *pSample);
HRESULT (*pfnProcessEnd) (TransformFilterImpl* This);
HRESULT (*pfnQueryConnect) (TransformFilterImpl* This, const AM_MEDIA_TYPE * pmt);
HRESULT (*pfnConnectInput) (TransformFilterImpl* This, const AM_MEDIA_TYPE * pmt);
HRESULT (*pfnCleanup) (TransformFilterImpl* This);
HRESULT (*pfnProcessBegin) (TransformFilterImpl *This);
HRESULT (*pfnProcessSampleData) (InputPin *pin, IMediaSample *pSample);
HRESULT (*pfnProcessEnd) (TransformFilterImpl *This);
HRESULT (*pfnQueryConnect) (TransformFilterImpl *This, const AM_MEDIA_TYPE * pmt);
HRESULT (*pfnConnectInput) (InputPin *pin, const AM_MEDIA_TYPE * pmt);
HRESULT (*pfnCleanup) (InputPin *pin);
} TransformFuncsTable;
struct TransformFilterImpl
......@@ -44,7 +44,8 @@ struct TransformFilterImpl
CLSID clsid;
struct MediaSeekingImpl mediaSeeking;
IPin ** ppPins;
IPin **ppPins;
ULONG npins;
AM_MEDIA_TYPE pmt;
const TransformFuncsTable * pFuncsTable;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment