Commit 28a51155 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

strmbase: Store the filter as a strmbase_filter pointer in the BasePin structure.

parent 85e559fa
......@@ -64,7 +64,7 @@ static inline AVICompressor *impl_from_IBaseFilter(IBaseFilter *iface)
static inline AVICompressor *impl_from_BasePin(BasePin *pin)
{
return impl_from_IBaseFilter(pin->pinInfo.pFilter);
return impl_from_strmbase_filter(pin->filter);
}
static HRESULT ensure_driver(AVICompressor *This)
......@@ -315,8 +315,7 @@ static const IPersistPropertyBagVtbl PersistPropertyBagVtbl = {
static inline AVICompressor *impl_from_IPin(IPin *iface)
{
BasePin *bp = CONTAINING_RECORD(iface, BasePin, IPin_iface);
return impl_from_IBaseFilter(bp->pinInfo.pFilter);
return impl_from_strmbase_filter(CONTAINING_RECORD(iface, BasePin, IPin_iface)->filter);
}
static HRESULT WINAPI AVICompressorIn_QueryInterface(IPin *iface, REFIID riid, void **ppv)
......@@ -536,7 +535,7 @@ static const IPinVtbl AVICompressorOutputPinVtbl = {
static HRESULT WINAPI AVICompressorOut_GetMediaType(BasePin *base, int iPosition, AM_MEDIA_TYPE *amt)
{
AVICompressor *This = impl_from_IBaseFilter(base->pinInfo.pFilter);
AVICompressor *This = impl_from_strmbase_filter(base->filter);
TRACE("(%p)->(%d %p)\n", base, iPosition, amt);
......@@ -591,8 +590,8 @@ static const BaseOutputPinFuncTable AVICompressorBaseOutputPinVtbl = {
IUnknown* WINAPI QCAP_createAVICompressor(IUnknown *outer, HRESULT *phr)
{
PIN_INFO in_pin_info = {NULL, PINDIR_INPUT, {'I','n',0}};
PIN_INFO out_pin_info = {NULL, PINDIR_OUTPUT, {'O','u','t',0}};
static const WCHAR source_name[] = {'O','u','t',0};
static const WCHAR sink_name[] = {'I','n',0};
AVICompressor *compressor;
compressor = heap_alloc_zero(sizeof(*compressor));
......@@ -605,13 +604,10 @@ IUnknown* WINAPI QCAP_createAVICompressor(IUnknown *outer, HRESULT *phr)
compressor->IPersistPropertyBag_iface.lpVtbl = &PersistPropertyBagVtbl;
in_pin_info.pFilter = &compressor->filter.IBaseFilter_iface;
strmbase_sink_init(&compressor->sink, &AVICompressorInputPinVtbl, &in_pin_info,
&AVICompressorBaseInputPinVtbl, &compressor->filter.csFilter, NULL);
out_pin_info.pFilter = &compressor->filter.IBaseFilter_iface;
strmbase_source_init(&compressor->source, &AVICompressorOutputPinVtbl, &out_pin_info,
&AVICompressorBaseOutputPinVtbl, &compressor->filter.csFilter);
strmbase_sink_init(&compressor->sink, &AVICompressorInputPinVtbl,
&compressor->filter, sink_name, &AVICompressorBaseInputPinVtbl, NULL);
strmbase_source_init(&compressor->source, &AVICompressorOutputPinVtbl,
&compressor->filter, source_name, &AVICompressorBaseOutputPinVtbl);
*phr = S_OK;
return &compressor->filter.IUnknown_inner;
......
......@@ -54,13 +54,12 @@ static inline SmartTeeFilter *impl_from_IBaseFilter(IBaseFilter *iface)
static inline SmartTeeFilter *impl_from_BasePin(BasePin *pin)
{
return impl_from_IBaseFilter(pin->pinInfo.pFilter);
return impl_from_strmbase_filter(pin->filter);
}
static inline SmartTeeFilter *impl_from_IPin(IPin *iface)
{
BasePin *bp = CONTAINING_RECORD(iface, BasePin, IPin_iface);
return impl_from_IBaseFilter(bp->pinInfo.pFilter);
return impl_from_strmbase_filter(CONTAINING_RECORD(iface, BasePin, IPin_iface)->filter);
}
static HRESULT WINAPI SmartTeeFilter_Stop(IBaseFilter *iface)
......@@ -471,41 +470,36 @@ static const BaseOutputPinFuncTable SmartTeeFilterPreviewFuncs = {
};
IUnknown* WINAPI QCAP_createSmartTeeFilter(IUnknown *outer, HRESULT *phr)
{
PIN_INFO inputPinInfo = {NULL, PINDIR_INPUT, {'I','n','p','u','t',0}};
PIN_INFO capturePinInfo = {NULL, PINDIR_OUTPUT, {'C','a','p','t','u','r','e',0}};
PIN_INFO previewPinInfo = {NULL, PINDIR_OUTPUT, {'P','r','e','v','i','e','w',0}};
static const WCHAR captureW[] = {'C','a','p','t','u','r','e',0};
static const WCHAR previewW[] = {'P','r','e','v','i','e','w',0};
static const WCHAR inputW[] = {'I','n','p','u','t',0};
SmartTeeFilter *object;
HRESULT hr;
SmartTeeFilter *This = NULL;
This = CoTaskMemAlloc(sizeof(*This));
if (This == NULL) {
if (!(object = CoTaskMemAlloc(sizeof(*object))))
{
*phr = E_OUTOFMEMORY;
return NULL;
}
memset(This, 0, sizeof(*This));
strmbase_filter_init(&This->filter, &SmartTeeFilterVtbl, outer, &CLSID_SmartTee, &filter_ops);
memset(object, 0, sizeof(*object));
inputPinInfo.pFilter = &This->filter.IBaseFilter_iface;
strmbase_sink_init(&This->sink, &SmartTeeFilterInputVtbl, &inputPinInfo,
&SmartTeeFilterInputFuncs, &This->filter.csFilter, NULL);
strmbase_filter_init(&object->filter, &SmartTeeFilterVtbl, outer, &CLSID_SmartTee, &filter_ops);
strmbase_sink_init(&object->sink, &SmartTeeFilterInputVtbl, &object->filter,
inputW, &SmartTeeFilterInputFuncs, NULL);
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER,
&IID_IMemAllocator, (void**)&This->sink.pAllocator);
&IID_IMemAllocator, (void **)&object->sink.pAllocator);
if (FAILED(hr))
{
*phr = hr;
strmbase_filter_cleanup(&This->filter);
strmbase_filter_cleanup(&object->filter);
return NULL;
}
capturePinInfo.pFilter = &This->filter.IBaseFilter_iface;
strmbase_source_init(&This->capture, &SmartTeeFilterCaptureVtbl, &capturePinInfo,
&SmartTeeFilterCaptureFuncs, &This->filter.csFilter);
previewPinInfo.pFilter = &This->filter.IBaseFilter_iface;
strmbase_source_init(&This->preview, &SmartTeeFilterPreviewVtbl, &previewPinInfo,
&SmartTeeFilterPreviewFuncs, &This->filter.csFilter);
strmbase_source_init(&object->capture, &SmartTeeFilterCaptureVtbl,
&object->filter, captureW, &SmartTeeFilterCaptureFuncs);
strmbase_source_init(&object->preview, &SmartTeeFilterPreviewVtbl,
&object->filter, previewW, &SmartTeeFilterPreviewFuncs);
*phr = S_OK;
return &This->filter.IUnknown_inner;
return &object->filter.IUnknown_inner;
}
......@@ -635,7 +635,6 @@ IUnknown * WINAPI QCAP_createVFWCaptureFilter(IUnknown *outer, HRESULT *phr)
{
static const WCHAR source_name[] = {'O','u','t','p','u','t',0};
VfwCapture *object;
PIN_INFO pin_info;
if (!(object = CoTaskMemAlloc(sizeof(*object))))
{
......@@ -650,11 +649,8 @@ IUnknown * WINAPI QCAP_createVFWCaptureFilter(IUnknown *outer, HRESULT *phr)
object->IPersistPropertyBag_iface.lpVtbl = &IPersistPropertyBag_VTable;
object->init = FALSE;
pin_info.dir = PINDIR_OUTPUT;
pin_info.pFilter = &object->filter.IBaseFilter_iface;
lstrcpyW(pin_info.achName, source_name);
strmbase_source_init(&object->source, &VfwPin_Vtbl, &pin_info,
&output_BaseOutputFuncTable, &object->filter.csFilter);
strmbase_source_init(&object->source, &VfwPin_Vtbl, &object->filter,
source_name, &output_BaseOutputFuncTable);
object->IKsPropertySet_iface.lpVtbl = &IKsPropertySet_VTable;
......
......@@ -675,7 +675,6 @@ static HRESULT AVISplitter_ProcessOldIndex(AVISplitterImpl *This)
static HRESULT AVISplitter_ProcessStreamList(AVISplitterImpl * This, const BYTE * pData, DWORD cb, ALLOCATOR_PROPERTIES *props)
{
PIN_INFO piOutput;
const RIFFCHUNK * pChunk;
HRESULT hr;
AM_MEDIA_TYPE amt;
......@@ -685,11 +684,9 @@ static HRESULT AVISplitter_ProcessStreamList(AVISplitterImpl * This, const BYTE
DWORD nstdindex = 0;
static const WCHAR wszStreamTemplate[] = {'S','t','r','e','a','m',' ','%','0','2','d',0};
StreamData *stream;
WCHAR name[18];
ZeroMemory(&amt, sizeof(amt));
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &This->Parser.filter.IBaseFilter_iface;
wsprintfW(piOutput.achName, wszStreamTemplate, This->Parser.cStreams);
This->streams = CoTaskMemRealloc(This->streams, sizeof(StreamData) * (This->Parser.cStreams+1));
stream = This->streams + This->Parser.cStreams;
ZeroMemory(stream, sizeof(*stream));
......@@ -792,7 +789,7 @@ static HRESULT AVISplitter_ProcessStreamList(AVISplitterImpl * This, const BYTE
case ckidSTREAMNAME:
TRACE("processing stream name\n");
/* FIXME: this doesn't exactly match native version (we omit the "##)" prefix), but hey... */
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)(pChunk + 1), pChunk->cb, piOutput.achName, ARRAY_SIZE(piOutput.achName));
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)(pChunk + 1), pChunk->cb, name, ARRAY_SIZE(name));
break;
case ckidSTREAMHANDLERDATA:
FIXME("process stream handler data\n");
......@@ -872,7 +869,8 @@ static HRESULT AVISplitter_ProcessStreamList(AVISplitterImpl * This, const BYTE
stream->dwLength = dwLength; /* TODO: Use this for mediaseeking */
stream->packet_queued = CreateEventW(NULL, 0, 0, NULL);
hr = Parser_AddPin(&(This->Parser), &piOutput, props, &amt);
swprintf(name, ARRAY_SIZE(name), wszStreamTemplate, This->Parser.cStreams);
hr = Parser_AddPin(&This->Parser, name, props, &amt);
CoTaskMemFree(amt.pbFormat);
......@@ -1023,7 +1021,7 @@ static HRESULT AVISplitter_Disconnect(LPVOID iface);
static HRESULT AVISplitter_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props)
{
PullPin *This = impl_PullPin_from_IPin(iface);
AVISplitterImpl *pAviSplit = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
AVISplitterImpl *pAviSplit = impl_from_IBaseFilter(&This->pin.filter->IBaseFilter_iface);
HRESULT hr;
RIFFLIST list;
LONGLONG pos = 0; /* in bytes */
......
......@@ -469,7 +469,6 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi
{
HANDLE hFile;
AsyncReader *This = impl_from_IFileSourceFilter(iface);
PIN_INFO pin_info;
TRACE("%p->(%s, %p)\n", This, debugstr_w(pszFileName), pmt);
......@@ -485,12 +484,8 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi
return HRESULT_FROM_WIN32(GetLastError());
}
/* create pin */
pin_info.dir = PINDIR_OUTPUT;
pin_info.pFilter = &This->filter.IBaseFilter_iface;
lstrcpyW(pin_info.achName, wszOutputPinName);
strmbase_source_init(&This->source, &FileAsyncReaderPin_Vtbl, &pin_info,
&output_BaseOutputFuncTable, &This->filter.csFilter);
strmbase_source_init(&This->source, &FileAsyncReaderPin_Vtbl, &This->filter,
wszOutputPinName, &output_BaseOutputFuncTable);
BaseFilterImpl_IncrementPinVersion(&This->filter);
This->file = hFile;
......
......@@ -355,7 +355,7 @@ static HRESULT MPEGSplitter_query_accept(LPVOID iface, const AM_MEDIA_TYPE *pmt)
}
static HRESULT MPEGSplitter_init_audio(MPEGSplitterImpl *This, const BYTE *header, PIN_INFO *ppiOutput, AM_MEDIA_TYPE *pamt)
static HRESULT MPEGSplitter_init_audio(MPEGSplitterImpl *This, const BYTE *header, AM_MEDIA_TYPE *pamt)
{
WAVEFORMATEX *format;
int bitrate_index;
......@@ -369,9 +369,6 @@ static HRESULT MPEGSplitter_init_audio(MPEGSplitterImpl *This, const BYTE *heade
int mode;
ZeroMemory(pamt, sizeof(*pamt));
ppiOutput->dir = PINDIR_OUTPUT;
ppiOutput->pFilter = &This->Parser.filter.IBaseFilter_iface;
wsprintfW(ppiOutput->achName, wszAudioStream);
pamt->formattype = FORMAT_WaveFormatEx;
pamt->majortype = MEDIATYPE_Audio;
......@@ -480,14 +477,13 @@ static HRESULT MPEGSplitter_init_audio(MPEGSplitterImpl *This, const BYTE *heade
static HRESULT MPEGSplitter_pre_connect(IPin *iface, IPin *pConnectPin, ALLOCATOR_PROPERTIES *props)
{
PullPin *pPin = impl_PullPin_from_IPin(iface);
MPEGSplitterImpl *This = impl_from_IBaseFilter(pPin->pin.pinInfo.pFilter);
MPEGSplitterImpl *This = impl_from_IBaseFilter(&pPin->pin.filter->IBaseFilter_iface);
HRESULT hr;
LONGLONG pos = 0; /* in bytes */
BYTE header[10];
int streamtype;
LONGLONG total, avail;
AM_MEDIA_TYPE amt;
PIN_INFO piOutput;
IAsyncReader_Length(pPin->pReader, &total, &avail);
This->EndOfFile = total;
......@@ -570,7 +566,7 @@ static HRESULT MPEGSplitter_pre_connect(IPin *iface, IPin *pConnectPin, ALLOCATO
LONGLONG duration = 0;
WAVEFORMATEX *format;
hr = MPEGSplitter_init_audio(This, header, &piOutput, &amt);
hr = MPEGSplitter_init_audio(This, header, &amt);
if (SUCCEEDED(hr))
{
format = (WAVEFORMATEX*)amt.pbFormat;
......@@ -581,7 +577,7 @@ static HRESULT MPEGSplitter_pre_connect(IPin *iface, IPin *pConnectPin, ALLOCATO
props->cbBuffer = 0x4000 / format->nBlockAlign *
format->nBlockAlign;
props->cBuffers = 3;
hr = Parser_AddPin(&(This->Parser), &piOutput, props, &amt);
hr = Parser_AddPin(&This->Parser, wszAudioStream, props, &amt);
}
if (FAILED(hr))
......
......@@ -80,7 +80,6 @@ HRESULT Parser_Create(ParserImpl *pParser, const IBaseFilterVtbl *vtbl, IUnknown
SourceSeeking_ChangeStart start, SourceSeeking_ChangeRate rate)
{
HRESULT hr;
PIN_INFO piInput;
strmbase_filter_init(&pParser->filter, vtbl, outer, clsid, func_table);
......@@ -89,11 +88,6 @@ HRESULT Parser_Create(ParserImpl *pParser, const IBaseFilterVtbl *vtbl, IUnknown
pParser->cStreams = 0;
pParser->sources = CoTaskMemAlloc(0 * sizeof(IPin *));
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = &pParser->filter.IBaseFilter_iface;
lstrcpynW(piInput.achName, sink_name, ARRAY_SIZE(piInput.achName));
if (!start)
start = Parser_ChangeStart;
......@@ -105,7 +99,9 @@ HRESULT Parser_Create(ParserImpl *pParser, const IBaseFilterVtbl *vtbl, IUnknown
SourceSeeking_Init(&pParser->sourceSeeking, &Parser_Seeking_Vtbl, stop, start, rate, &pParser->filter.csFilter);
hr = PullPin_Construct(&Parser_InputPin_Vtbl, &piInput, fnProcessSample, (LPVOID)pParser, fnQueryAccept, fnCleanup, fnRequest, fnDone, &pParser->filter.csFilter, (IPin **)&pParser->pInputPin);
hr = PullPin_Construct(&Parser_InputPin_Vtbl, &pParser->filter, sink_name,
fnProcessSample, (void *)pParser, fnQueryAccept, fnCleanup, fnRequest,
fnDone, (IPin **)&pParser->pInputPin);
if (SUCCEEDED(hr))
{
......@@ -346,7 +342,7 @@ static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
Parser_OutputPin_DecideAllocator,
};
HRESULT Parser_AddPin(ParserImpl *filter, const PIN_INFO *pin_info,
HRESULT Parser_AddPin(ParserImpl *filter, const WCHAR *name,
ALLOCATOR_PROPERTIES *props, const AM_MEDIA_TYPE *mt)
{
Parser_OutputPin **old_sources;
......@@ -361,14 +357,12 @@ HRESULT Parser_AddPin(ParserImpl *filter, const PIN_INFO *pin_info,
memcpy(filter->sources, old_sources, filter->cStreams * sizeof(filter->sources[0]));
filter->sources[filter->cStreams] = object;
strmbase_source_init(&object->pin, &Parser_OutputPin_Vtbl, pin_info,
&output_BaseOutputFuncTable, &filter->filter.csFilter);
strmbase_source_init(&object->pin, &Parser_OutputPin_Vtbl, &filter->filter,
name, &output_BaseOutputFuncTable);
object->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
CopyMediaType(object->pmt, mt);
object->dwSamplesProcessed = 0;
object->pin.pin.pinInfo.pFilter = &filter->filter.IBaseFilter_iface;
object->allocProps = *props;
filter->cStreams++;
BaseFilterImpl_IncrementPinVersion(&filter->filter);
......@@ -539,7 +533,7 @@ static HRESULT WINAPI Parser_OutputPin_QueryInterface(IPin * iface, REFIID riid,
*ppv = iface;
/* The Parser filter does not support querying IMediaSeeking, return it directly */
else if (IsEqualIID(riid, &IID_IMediaSeeking))
*ppv = &impl_from_IBaseFilter(This->pin.pin.pinInfo.pFilter)->sourceSeeking;
*ppv = &impl_from_IBaseFilter(&This->pin.pin.filter->IBaseFilter_iface)->sourceSeeking;
if (*ppv)
{
......@@ -555,7 +549,7 @@ static HRESULT WINAPI Parser_OutputPin_QueryInterface(IPin * iface, REFIID riid,
static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
{
Parser_OutputPin *This = unsafe_impl_Parser_OutputPin_from_IPin(iface);
ParserImpl *parser = impl_from_IBaseFilter(This->pin.pin.pinInfo.pFilter);
ParserImpl *parser = impl_from_IBaseFilter(&This->pin.pin.filter->IBaseFilter_iface);
/* Set the allocator to our input pin's */
EnterCriticalSection(This->pin.pin.pCritSec);
......@@ -610,7 +604,7 @@ static HRESULT WINAPI Parser_PullPin_QueryInterface(IPin * iface, REFIID riid, L
* querying IMediaSeeking
*/
if (IsEqualIID(riid, &IID_IMediaSeeking))
*ppv = &impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->sourceSeeking;
*ppv = &impl_from_IBaseFilter(&This->pin.filter->IBaseFilter_iface)->sourceSeeking;
if (*ppv)
{
......@@ -634,10 +628,10 @@ static HRESULT WINAPI Parser_PullPin_Disconnect(IPin * iface)
if (This->pin.pConnectedTo)
{
FILTER_STATE state;
ParserImpl *Parser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
ParserImpl *Parser = impl_from_IBaseFilter(&This->pin.filter->IBaseFilter_iface);
LeaveCriticalSection(This->pin.pCritSec);
hr = IBaseFilter_GetState(This->pin.pinInfo.pFilter, INFINITE, &state);
hr = IBaseFilter_GetState(&This->pin.filter->IBaseFilter_iface, INFINITE, &state);
EnterCriticalSection(This->pin.pCritSec);
if (SUCCEEDED(hr) && (state == State_Stopped) && SUCCEEDED(Parser->fnDisconnect(Parser)))
......@@ -645,7 +639,7 @@ static HRESULT WINAPI Parser_PullPin_Disconnect(IPin * iface)
LeaveCriticalSection(This->pin.pCritSec);
PullPin_Disconnect(iface);
EnterCriticalSection(This->pin.pCritSec);
hr = Parser_RemoveOutputPins(impl_from_IBaseFilter(This->pin.pinInfo.pFilter));
hr = Parser_RemoveOutputPins(impl_from_IBaseFilter(&This->pin.filter->IBaseFilter_iface));
}
else
hr = VFW_E_NOT_STOPPED;
......@@ -671,7 +665,7 @@ static HRESULT WINAPI Parser_PullPin_ReceiveConnection(IPin * iface, IPin * pRec
BasePin *This = (BasePin *)iface;
EnterCriticalSection(This->pCritSec);
Parser_RemoveOutputPins(impl_from_IBaseFilter(This->pinInfo.pFilter));
Parser_RemoveOutputPins(impl_from_IBaseFilter(&This->filter->IBaseFilter_iface));
LeaveCriticalSection(This->pCritSec);
}
......
......@@ -50,7 +50,8 @@ struct ParserImpl
SourceSeeking sourceSeeking;
};
extern HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PROPERTIES * props, const AM_MEDIA_TYPE * amt);
extern HRESULT Parser_AddPin(ParserImpl *filter, const WCHAR *name,
ALLOCATOR_PROPERTIES *props, const AM_MEDIA_TYPE *mt);
HRESULT Parser_Create(ParserImpl *parser, const IBaseFilterVtbl *vtbl, IUnknown *outer,
const CLSID *clsid, const struct strmbase_filter_ops *func_table, const WCHAR *sink_name,
......
......@@ -166,19 +166,18 @@ static HRESULT deliver_newsegment(IPin *pin, LPVOID data)
/*** PullPin implementation ***/
static HRESULT PullPin_Init(const IPinVtbl *PullPin_Vtbl, const PIN_INFO *info,
SAMPLEPROC_PULL pSampleProc, void *pUserData, QUERYACCEPTPROC pQueryAccept,
CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone,
LPCRITICAL_SECTION pCritSec, PullPin *pPinImpl)
static HRESULT PullPin_Init(const IPinVtbl *PullPin_Vtbl, struct strmbase_filter *filter,
const WCHAR *name, SAMPLEPROC_PULL pSampleProc, void *pUserData,
QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest,
STOPPROCESSPROC pDone, PullPin *pPinImpl)
{
/* Common attributes */
pPinImpl->pin.IPin_iface.lpVtbl = PullPin_Vtbl;
pPinImpl->pin.pConnectedTo = NULL;
pPinImpl->pin.pCritSec = pCritSec;
/* avoid copying uninitialized data */
wcscpy(pPinImpl->pin.pinInfo.achName, info->achName);
pPinImpl->pin.pinInfo.dir = info->dir;
pPinImpl->pin.pinInfo.pFilter = info->pFilter;
pPinImpl->pin.pCritSec = &filter->csFilter;
wcscpy(pPinImpl->pin.name, name);
pPinImpl->pin.dir = PINDIR_INPUT;
pPinImpl->pin.filter = filter;
ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
/* Input pin attributes */
......@@ -209,27 +208,22 @@ static HRESULT PullPin_Init(const IPinVtbl *PullPin_Vtbl, const PIN_INFO *info,
return S_OK;
}
HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo,
HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, struct strmbase_filter *filter, const WCHAR *name,
SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept,
CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone,
LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
IPin ** ppPin)
{
PullPin * pPinImpl;
*ppPin = NULL;
if (pPinInfo->dir != PINDIR_INPUT)
{
ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
return E_INVALIDARG;
}
pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
if (!pPinImpl)
return E_OUTOFMEMORY;
if (SUCCEEDED(PullPin_Init(PullPin_Vtbl, pPinInfo, pSampleProc, pUserData, pQueryAccept, pCleanUp, pCustomRequest, pDone, pCritSec, pPinImpl)))
if (SUCCEEDED(PullPin_Init(PullPin_Vtbl, filter, name, pSampleProc, pUserData,
pQueryAccept, pCleanUp, pCustomRequest, pDone, pPinImpl)))
{
*ppPin = &pPinImpl->pin.IPin_iface;
return S_OK;
......@@ -348,7 +342,7 @@ HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
else if (IsEqualIID(riid, &IID_IMediaSeeking) ||
IsEqualIID(riid, &IID_IQualityControl))
{
return IBaseFilter_QueryInterface(This->pin.pinInfo.pFilter, riid, ppv);
return IBaseFilter_QueryInterface(&This->pin.filter->IBaseFilter_iface, riid, ppv);
}
if (*ppv)
......@@ -525,7 +519,7 @@ static void PullPin_Thread_Stop(PullPin *This)
SetEvent(This->hEventStateChanged);
LeaveCriticalSection(This->pin.pCritSec);
IBaseFilter_Release(This->pin.pinInfo.pFilter);
IPin_Release(&This->pin.IPin_iface);
CoUninitialize();
ExitThread(0);
......@@ -576,16 +570,13 @@ static HRESULT PullPin_InitProcessing(PullPin * This)
assert(WaitForSingleObject(This->thread_sleepy, 0) == WAIT_TIMEOUT);
This->state = Req_Sleepy;
/* AddRef the filter to make sure it and its pins will be around
* as long as the thread */
IBaseFilter_AddRef(This->pin.pinInfo.pFilter);
IPin_AddRef(&This->pin.IPin_iface);
This->hThread = CreateThread(NULL, 0, PullPin_Thread_Main, This, 0, &dwThreadId);
if (!This->hThread)
{
hr = HRESULT_FROM_WIN32(GetLastError());
IBaseFilter_Release(This->pin.pinInfo.pFilter);
IPin_Release(&This->pin.IPin_iface);
}
if (SUCCEEDED(hr))
......@@ -769,7 +760,7 @@ HRESULT WINAPI PullPin_EndFlush(IPin * iface)
if (This->pReader)
IAsyncReader_EndFlush(This->pReader);
IBaseFilter_GetState(This->pin.pinInfo.pFilter, INFINITE, &state);
IBaseFilter_GetState(&This->pin.filter->IBaseFilter_iface, INFINITE, &state);
if (state != State_Stopped)
PullPin_StartProcessing(This);
......
......@@ -102,10 +102,10 @@ typedef struct PullPin
#define Req_Pause 3
/*** Constructors ***/
HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo,
HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, struct strmbase_filter *filter, const WCHAR *name,
SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept,
CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone,
LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
IPin **ppPin);
void PullPin_destroy(PullPin *pin) DECLSPEC_HIDDEN;
/**************************/
......
......@@ -51,9 +51,9 @@ static inline WAVEParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
return CONTAINING_RECORD(iface, WAVEParserImpl, Parser.sourceSeeking.IMediaSeeking_iface);
}
static inline WAVEParserImpl *impl_from_IBaseFilter( IBaseFilter *iface )
static inline WAVEParserImpl *impl_from_strmbase_filter(struct strmbase_filter *iface)
{
return CONTAINING_RECORD(iface, WAVEParserImpl, Parser.filter.IBaseFilter_iface);
return CONTAINING_RECORD(iface, WAVEParserImpl, Parser.filter);
}
static LONGLONG bytepos_to_duration(WAVEParserImpl *This, LONGLONG bytepos)
......@@ -246,13 +246,8 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin,
RIFFLIST list;
RIFFCHUNK chunk;
LONGLONG pos = 0; /* in bytes */
PIN_INFO piOutput;
AM_MEDIA_TYPE amt;
WAVEParserImpl * pWAVEParser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &pWAVEParser->Parser.filter.IBaseFilter_iface;
lstrcpynW(piOutput.achName, outputW, ARRAY_SIZE(piOutput.achName));
WAVEParserImpl *pWAVEParser = impl_from_strmbase_filter(This->pin.filter);
hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(list), (BYTE *)&list);
pos += sizeof(list);
......@@ -314,7 +309,7 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin,
props->cBuffers = 3;
pWAVEParser->nBlockAlign = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign;
pWAVEParser->nAvgBytesPerSec = ((WAVEFORMATEX*)amt.pbFormat)->nAvgBytesPerSec;
hr = Parser_AddPin(&(pWAVEParser->Parser), &piOutput, props, &amt);
hr = Parser_AddPin(&pWAVEParser->Parser, outputW, props, &amt);
CoTaskMemFree(amt.pbFormat);
pWAVEParser->Parser.sourceSeeking.llCurrent = 0;
......@@ -410,7 +405,7 @@ static const IBaseFilterVtbl WAVEParser_Vtbl =
static void wave_parser_destroy(struct strmbase_filter *iface)
{
WAVEParserImpl *filter = impl_from_IBaseFilter(&iface->IBaseFilter_iface);
WAVEParserImpl *filter = impl_from_strmbase_filter(iface);
Parser_Destroy(&filter->Parser);
}
......
......@@ -135,14 +135,6 @@ out:
return hr;
}
static void Copy_PinInfo(PIN_INFO * pDest, const PIN_INFO * pSrc)
{
/* avoid copying uninitialized data */
lstrcpyW(pDest->achName, pSrc->achName);
pDest->dir = pSrc->dir;
pDest->pFilter = pSrc->pFilter;
}
static void dump_AM_MEDIA_TYPE(const AM_MEDIA_TYPE * pmt)
{
if (!pmt)
......@@ -176,13 +168,13 @@ LONG WINAPI BasePinImpl_GetMediaTypeVersion(BasePin *iface)
ULONG WINAPI BasePinImpl_AddRef(IPin *iface)
{
BasePin *pin = impl_from_IPin(iface);
return IBaseFilter_AddRef(pin->pinInfo.pFilter);
return IBaseFilter_AddRef(&pin->filter->IBaseFilter_iface);
}
ULONG WINAPI BasePinImpl_Release(IPin *iface)
{
BasePin *pin = impl_from_IPin(iface);
return IBaseFilter_Release(pin->pinInfo.pFilter);
return IBaseFilter_Release(&pin->filter->IBaseFilter_iface);
}
HRESULT WINAPI BasePinImpl_Disconnect(IPin * iface)
......@@ -261,40 +253,40 @@ HRESULT WINAPI BasePinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt
return hr;
}
HRESULT WINAPI BasePinImpl_QueryPinInfo(IPin * iface, PIN_INFO * pInfo)
HRESULT WINAPI BasePinImpl_QueryPinInfo(IPin *iface, PIN_INFO *info)
{
BasePin *This = impl_from_IPin(iface);
BasePin *pin = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", This, pInfo);
TRACE("pin %p, info %p.\n", pin, info);
Copy_PinInfo(pInfo, &This->pinInfo);
IBaseFilter_AddRef(pInfo->pFilter);
info->dir = pin->dir;
IBaseFilter_AddRef(info->pFilter = &pin->filter->IBaseFilter_iface);
lstrcpyW(info->achName, pin->name);
return S_OK;
}
HRESULT WINAPI BasePinImpl_QueryDirection(IPin * iface, PIN_DIRECTION * pPinDir)
HRESULT WINAPI BasePinImpl_QueryDirection(IPin *iface, PIN_DIRECTION *dir)
{
BasePin *This = impl_from_IPin(iface);
BasePin *pin = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", This, pPinDir);
TRACE("pin %p, dir %p.\n", pin, dir);
*pPinDir = This->pinInfo.dir;
*dir = pin->dir;
return S_OK;
}
HRESULT WINAPI BasePinImpl_QueryId(IPin * iface, LPWSTR * Id)
HRESULT WINAPI BasePinImpl_QueryId(IPin *iface, WCHAR **id)
{
BasePin *This = impl_from_IPin(iface);
BasePin *pin = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", This, Id);
TRACE("pin %p, id %p.\n", pin, id);
*Id = CoTaskMemAlloc((lstrlenW(This->pinInfo.achName) + 1) * sizeof(WCHAR));
if (!*Id)
if (!(*id = CoTaskMemAlloc((lstrlenW(pin->name) + 1) * sizeof(WCHAR))))
return E_OUTOFMEMORY;
lstrcpyW(*Id, This->pinInfo.achName);
lstrcpyW(*id, pin->name);
return S_OK;
}
......@@ -362,7 +354,7 @@ HRESULT WINAPI BaseOutputPinImpl_QueryInterface(IPin * iface, REFIID riid, LPVOI
else if (IsEqualIID(riid, &IID_IMediaSeeking) ||
IsEqualIID(riid, &IID_IQualityControl))
{
return IBaseFilter_QueryInterface(This->pin.pinInfo.pFilter, riid, ppv);
return IBaseFilter_QueryInterface(&This->pin.filter->IBaseFilter_iface, riid, ppv);
}
if (*ppv)
......@@ -712,22 +704,17 @@ HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BaseOutputPin *This, IPin *pR
return hr;
}
static void strmbase_pin_init(BasePin *pin, const IPinVtbl *vtbl,
const BasePinFuncTable *func_table, const PIN_INFO *info, CRITICAL_SECTION *cs)
{
memset(pin, 0, sizeof(*pin));
pin->IPin_iface.lpVtbl = vtbl;
pin->pCritSec = cs;
pin->dRate = 1.0;
Copy_PinInfo(&pin->pinInfo, info);
pin->pFuncsTable = func_table;
}
void strmbase_source_init(BaseOutputPin *pin, const IPinVtbl *vtbl,
const PIN_INFO *info, const BaseOutputPinFuncTable *func_table, CRITICAL_SECTION *cs)
void strmbase_source_init(BaseOutputPin *pin, const IPinVtbl *vtbl, struct strmbase_filter *filter,
const WCHAR *name, const BaseOutputPinFuncTable *func_table)
{
memset(pin, 0, sizeof(*pin));
strmbase_pin_init(&pin->pin, vtbl, &func_table->base, info, cs);
pin->pin.IPin_iface.lpVtbl = vtbl;
pin->pin.pCritSec = &filter->csFilter;
pin->pin.dRate = 1.0;
pin->pin.filter = filter;
pin->pin.dir = PINDIR_OUTPUT;
lstrcpyW(pin->pin.name, name);
pin->pin.pFuncsTable = &func_table->base;
pin->pFuncsTable = func_table;
}
......@@ -762,7 +749,7 @@ HRESULT WINAPI BaseInputPinImpl_QueryInterface(IPin * iface, REFIID riid, LPVOID
*ppv = &This->IMemInputPin_iface;
else if (IsEqualIID(riid, &IID_IMediaSeeking))
{
return IBaseFilter_QueryInterface(This->pin.pinInfo.pFilter, &IID_IMediaSeeking, ppv);
return IBaseFilter_QueryInterface(&This->pin.filter->IBaseFilter_iface, &IID_IMediaSeeking, ppv);
}
if (*ppv)
......@@ -1045,12 +1032,17 @@ static const IMemInputPinVtbl MemInputPin_Vtbl =
MemInputPin_ReceiveCanBlock
};
void strmbase_sink_init(BaseInputPin *pin, const IPinVtbl *vtbl,
const PIN_INFO *info, const BaseInputPinFuncTable *func_table, CRITICAL_SECTION *cs,
IMemAllocator *allocator)
void strmbase_sink_init(BaseInputPin *pin, const IPinVtbl *vtbl, struct strmbase_filter *filter,
const WCHAR *name, const BaseInputPinFuncTable *func_table, IMemAllocator *allocator)
{
memset(pin, 0, sizeof(*pin));
strmbase_pin_init(&pin->pin, vtbl, &func_table->base, info, cs);
pin->pin.IPin_iface.lpVtbl = vtbl;
pin->pin.pCritSec = &filter->csFilter;
pin->pin.dRate = 1.0;
pin->pin.filter = filter;
pin->pin.dir = PINDIR_INPUT;
lstrcpyW(pin->pin.name, name);
pin->pin.pFuncsTable = &func_table->base;
pin->pFuncsTable = func_table;
pin->pAllocator = pin->preferred_allocator = allocator;
if (pin->preferred_allocator)
......
......@@ -236,7 +236,6 @@ HRESULT WINAPI strmbase_renderer_init(BaseRenderer *filter, const IBaseFilterVtb
IUnknown *outer, const CLSID *clsid, const WCHAR *sink_name,
const BaseRendererFuncTable *pBaseFuncsTable)
{
PIN_INFO piInput;
HRESULT hr;
memset(filter, 0, sizeof(*filter));
......@@ -244,13 +243,8 @@ HRESULT WINAPI strmbase_renderer_init(BaseRenderer *filter, const IBaseFilterVtb
filter->pFuncsTable = pBaseFuncsTable;
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = &filter->filter.IBaseFilter_iface;
lstrcpynW(piInput.achName, sink_name, ARRAY_SIZE(piInput.achName));
strmbase_sink_init(&filter->sink, &BaseRenderer_InputPin_Vtbl, &piInput,
&input_BaseInputFuncTable, &filter->filter.csFilter, NULL);
strmbase_sink_init(&filter->sink, &BaseRenderer_InputPin_Vtbl, &filter->filter,
sink_name, &input_BaseInputFuncTable, NULL);
hr = CreatePosPassThru(outer ? outer : (IUnknown *)&filter->filter.IBaseFilter_iface, TRUE,
&filter->sink.pin.IPin_iface, &filter->pPosition);
......
......@@ -275,8 +275,6 @@ static HRESULT strmbase_transform_init(IUnknown *outer, const CLSID *clsid,
{
ISeekingPassThru *passthru;
HRESULT hr;
PIN_INFO piInput;
PIN_INFO piOutput;
strmbase_filter_init(&filter->filter, &transform_vtbl, outer, clsid, &filter_ops);
......@@ -287,19 +285,11 @@ static HRESULT strmbase_transform_init(IUnknown *outer, const CLSID *clsid,
filter->pFuncsTable = func_table;
ZeroMemory(&filter->pmt, sizeof(filter->pmt));
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = &filter->filter.IBaseFilter_iface;
lstrcpynW(piInput.achName, wcsInputPinName, ARRAY_SIZE(piInput.achName));
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &filter->filter.IBaseFilter_iface;
lstrcpynW(piOutput.achName, wcsOutputPinName, ARRAY_SIZE(piOutput.achName));
strmbase_sink_init(&filter->sink, &TransformFilter_InputPin_Vtbl, &filter->filter,
wcsInputPinName, &tf_input_BaseInputFuncTable, NULL);
strmbase_sink_init(&filter->sink, &TransformFilter_InputPin_Vtbl, &piInput,
&tf_input_BaseInputFuncTable, &filter->filter.csFilter, NULL);
strmbase_source_init(&filter->source, &TransformFilter_OutputPin_Vtbl,
&piOutput, &tf_output_BaseOutputFuncTable, &filter->filter.csFilter);
strmbase_source_init(&filter->source, &TransformFilter_OutputPin_Vtbl, &filter->filter,
wcsOutputPinName, &tf_output_BaseOutputFuncTable);
QualityControlImpl_Create(&filter->sink.pin.IPin_iface,
&filter->filter.IBaseFilter_iface, &filter->qcimpl);
......
......@@ -95,6 +95,11 @@ static inline GSTImpl *impl_from_IBaseFilter(IBaseFilter *iface)
return CONTAINING_RECORD(iface, GSTImpl, filter.IBaseFilter_iface);
}
static inline GSTImpl *impl_from_strmbase_filter(struct strmbase_filter *iface)
{
return CONTAINING_RECORD(iface, GSTImpl, filter);
}
const char* media_quark_string = "media-sample";
static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
......@@ -104,7 +109,7 @@ static const IPinVtbl GST_InputPin_Vtbl;
static const IBaseFilterVtbl GST_Vtbl;
static const IQualityControlVtbl GSTOutPin_QualityControl_Vtbl;
static BOOL create_pin(GSTImpl *filter, const PIN_INFO *pin_info, const AM_MEDIA_TYPE *mt);
static BOOL create_pin(GSTImpl *filter, const WCHAR *name, const AM_MEDIA_TYPE *mt);
static HRESULT GST_RemoveOutputPins(GSTImpl *This);
static HRESULT WINAPI GST_ChangeCurrent(IMediaSeeking *iface);
static HRESULT WINAPI GST_ChangeStop(IMediaSeeking *iface);
......@@ -293,7 +298,7 @@ static gboolean accept_caps_sink(GstPad *pad, GstCaps *caps)
static gboolean setcaps_sink(GstPad *pad, GstCaps *caps)
{
GSTOutPin *pin = gst_pad_get_element_private(pad);
GSTImpl *This = impl_from_IBaseFilter(pin->pin.pin.pinInfo.pFilter);
GSTImpl *This = impl_from_strmbase_filter(pin->pin.pin.filter);
AM_MEDIA_TYPE amt;
GstStructure *arg;
const char *typename;
......@@ -471,7 +476,7 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event)
IPin_EndOfStream(pin->pin.pin.pConnectedTo);
return TRUE;
case GST_EVENT_FLUSH_START:
if (impl_from_IBaseFilter(pin->pin.pin.pinInfo.pFilter)->ignore_flush) {
if (impl_from_strmbase_filter(pin->pin.pin.filter)->ignore_flush) {
/* gst-plugins-base prior to 1.7 contains a bug which causes
* our sink pins to receive a flush-start event when the
* decodebin changes from PAUSED to READY (including
......@@ -606,7 +611,7 @@ static DWORD CALLBACK push_data(LPVOID iface)
static GstFlowReturn got_data_sink(GstPad *pad, GstObject *parent, GstBuffer *buf)
{
GSTOutPin *pin = gst_pad_get_element_private(pad);
GSTImpl *This = impl_from_IBaseFilter(pin->pin.pin.pinInfo.pFilter);
GSTImpl *This = impl_from_strmbase_filter(pin->pin.pin.filter);
HRESULT hr;
BYTE *ptr = NULL;
IMediaSample *sample;
......@@ -781,8 +786,6 @@ out:
static void init_new_decoded_pad(GstElement *bin, GstPad *pad, GSTImpl *This)
{
HRESULT hr;
PIN_INFO piOutput;
const char *typename;
char *name;
AM_MEDIA_TYPE amt = {{0}};
......@@ -793,18 +796,17 @@ static void init_new_decoded_pad(GstElement *bin, GstPad *pad, GSTImpl *This)
int ret;
BOOL isvid = FALSE, isaud = FALSE;
gchar my_name[1024];
WCHAR nameW[128];
TRACE("%p %p %p\n", This, bin, pad);
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &This->filter.IBaseFilter_iface;
name = gst_pad_get_name(pad);
MultiByteToWideChar(CP_UNIXCP, 0, name, -1, piOutput.achName, ARRAY_SIZE(piOutput.achName) - 1);
MultiByteToWideChar(CP_UNIXCP, 0, name, -1, nameW, ARRAY_SIZE(nameW) - 1);
nameW[ARRAY_SIZE(nameW) - 1] = 0;
TRACE("Name: %s\n", name);
strcpy(my_name, "qz_sink_");
strcat(my_name, name);
g_free(name);
piOutput.achName[ARRAY_SIZE(piOutput.achName) - 1] = 0;
caps = gst_pad_query_caps(pad, NULL);
caps = gst_caps_make_writable(caps);
......@@ -825,7 +827,7 @@ static void init_new_decoded_pad(GstElement *bin, GstPad *pad, GSTImpl *This)
return;
}
if (!create_pin(This, &piOutput, &amt))
if (!create_pin(This, nameW, &amt))
{
ERR("Failed to allocate memory.\n");
return;
......@@ -1098,7 +1100,7 @@ static void unknown_type(GstElement *bin, GstPad *pad, GstCaps *caps, gpointer u
static HRESULT GST_Connect(GSTInPin *pPin, IPin *pConnectPin, ALLOCATOR_PROPERTIES *props)
{
GSTImpl *This = impl_from_IBaseFilter(pPin->pin.pinInfo.pFilter);
GSTImpl *This = impl_from_strmbase_filter(pPin->pin.filter);
int ret, i;
LONGLONG avail, duration;
GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE(
......@@ -1198,7 +1200,7 @@ static inline GSTOutPin *impl_from_IMediaSeeking( IMediaSeeking *iface )
static IPin *gstdemux_get_pin(struct strmbase_filter *base, unsigned int index)
{
GSTImpl *filter = impl_from_IBaseFilter(&base->IBaseFilter_iface);
GSTImpl *filter = impl_from_strmbase_filter(base);
if (!index)
return &filter->pInputPin.pin.IPin_iface;
......@@ -1209,7 +1211,7 @@ static IPin *gstdemux_get_pin(struct strmbase_filter *base, unsigned int index)
static void gstdemux_destroy(struct strmbase_filter *iface)
{
GSTImpl *filter = impl_from_IBaseFilter(&iface->IBaseFilter_iface);
GSTImpl *filter = impl_from_strmbase_filter(iface);
IPin *connected = NULL;
HRESULT hr;
......@@ -1253,7 +1255,6 @@ static const struct strmbase_filter_ops filter_ops =
IUnknown * CALLBACK Gstreamer_Splitter_create(IUnknown *outer, HRESULT *phr)
{
PIN_INFO *piInput;
GSTImpl *This;
if (!init_gstreamer())
......@@ -1281,10 +1282,9 @@ IUnknown * CALLBACK Gstreamer_Splitter_create(IUnknown *outer, HRESULT *phr)
This->push_event = CreateEventW(NULL, 0, 0, NULL);
This->bus = NULL;
piInput = &This->pInputPin.pin.pinInfo;
piInput->dir = PINDIR_INPUT;
piInput->pFilter = &This->filter.IBaseFilter_iface;
lstrcpynW(piInput->achName, wcsInputPinName, ARRAY_SIZE(piInput->achName));
This->pInputPin.pin.dir = PINDIR_INPUT;
This->pInputPin.pin.filter = &This->filter;
lstrcpynW(This->pInputPin.pin.name, wcsInputPinName, ARRAY_SIZE(This->pInputPin.pin.name));
This->pInputPin.pin.IPin_iface.lpVtbl = &GST_InputPin_Vtbl;
This->pInputPin.pin.pConnectedTo = NULL;
This->pInputPin.pin.pCritSec = &This->filter.csFilter;
......@@ -1721,7 +1721,7 @@ static HRESULT WINAPI GSTOutPin_DecideBufferSize(BaseOutputPin *iface, IMemAlloc
static HRESULT WINAPI GSTOutPin_DecideAllocator(BaseOutputPin *base, IMemInputPin *pPin, IMemAllocator **pAlloc)
{
GSTOutPin *pin = impl_source_from_IPin(&base->pin.IPin_iface);
GSTImpl *GSTfilter = impl_from_IBaseFilter(pin->pin.pin.pinInfo.pFilter);
GSTImpl *GSTfilter = impl_from_strmbase_filter(pin->pin.pin.filter);
HRESULT hr;
TRACE("pin %p, peer %p, allocator %p.\n", pin, pPin, pAlloc);
......@@ -1810,7 +1810,7 @@ static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
GSTOutPin_DecideAllocator,
};
static BOOL create_pin(GSTImpl *filter, const PIN_INFO *pin_info, const AM_MEDIA_TYPE *mt)
static BOOL create_pin(GSTImpl *filter, const WCHAR *name, const AM_MEDIA_TYPE *mt)
{
GSTOutPin *pin, **new_array;
......@@ -1821,8 +1821,8 @@ static BOOL create_pin(GSTImpl *filter, const PIN_INFO *pin_info, const AM_MEDIA
if (!(pin = heap_alloc_zero(sizeof(*pin))))
return FALSE;
strmbase_source_init(&pin->pin, &GST_OutputPin_Vtbl, pin_info,
&output_BaseOutputFuncTable, &filter->filter.csFilter);
strmbase_source_init(&pin->pin, &GST_OutputPin_Vtbl, &filter->filter, name,
&output_BaseOutputFuncTable);
pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
CopyMediaType(pin->pmt, mt);
pin->caps_event = CreateEventW(NULL, FALSE, FALSE, NULL);
......@@ -1872,6 +1872,7 @@ static inline GSTInPin *impl_sink_from_IPin(IPin *iface)
static HRESULT WINAPI GSTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
{
GSTInPin *This = impl_sink_from_IPin(iface);
GSTImpl *filter = impl_from_strmbase_filter(This->pin.filter);
PIN_DIRECTION pindirReceive;
HRESULT hr = S_OK;
......@@ -1903,7 +1904,7 @@ static HRESULT WINAPI GSTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin,
This->pReader = NULL;
This->pAlloc = NULL;
ResetEvent(impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->push_event);
ResetEvent(filter->push_event);
if (SUCCEEDED(hr))
hr = IPin_QueryInterface(pReceivePin, &IID_IAsyncReader, (LPVOID *)&This->pReader);
if (SUCCEEDED(hr))
......@@ -1926,9 +1927,9 @@ static HRESULT WINAPI GSTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin,
This->pin.pConnectedTo = pReceivePin;
IPin_AddRef(pReceivePin);
hr = IMemAllocator_Commit(This->pAlloc);
SetEvent(impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->push_event);
SetEvent(filter->push_event);
} else {
GST_RemoveOutputPins(impl_from_IBaseFilter(This->pin.pinInfo.pFilter));
GST_RemoveOutputPins(filter);
if (This->pReader)
IAsyncReader_Release(This->pReader);
This->pReader = NULL;
......@@ -1953,10 +1954,10 @@ static HRESULT WINAPI GSTInPin_Disconnect(IPin *iface)
mark_wine_thread();
hr = IBaseFilter_GetState(This->pin.pinInfo.pFilter, INFINITE, &state);
hr = IBaseFilter_GetState(&This->pin.filter->IBaseFilter_iface, INFINITE, &state);
EnterCriticalSection(This->pin.pCritSec);
if (This->pin.pConnectedTo) {
GSTImpl *Parser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
GSTImpl *Parser = impl_from_strmbase_filter(This->pin.filter);
if (SUCCEEDED(hr) && state == State_Stopped) {
IMemAllocator_Decommit(This->pAlloc);
......@@ -2026,7 +2027,7 @@ static HRESULT WINAPI GSTInPin_QueryInterface(IPin * iface, REFIID riid, LPVOID
*ppv = iface;
else if (IsEqualIID(riid, &IID_IMediaSeeking))
{
return IBaseFilter_QueryInterface(This->pin.pinInfo.pFilter, &IID_IMediaSeeking, ppv);
return IBaseFilter_QueryInterface(&This->pin.filter->IBaseFilter_iface, &IID_IMediaSeeking, ppv);
}
if (*ppv)
......
......@@ -176,7 +176,7 @@ static const IPinVtbl QT_InputPin_Vtbl;
static const IBaseFilterVtbl QT_Vtbl;
static const IMediaSeekingVtbl QT_Seeking_Vtbl;
static HRESULT QT_AddPin(QTSplitter *This, const PIN_INFO *piOutput, const AM_MEDIA_TYPE *amt, BOOL video);
static HRESULT QT_AddPin(QTSplitter *filter, const WCHAR *name, const AM_MEDIA_TYPE *mt, BOOL video);
static HRESULT QT_RemoveOutputPins(QTSplitter *This);
static HRESULT WINAPI QTSplitter_ChangeStart(IMediaSeeking *iface);
......@@ -286,7 +286,6 @@ static const struct strmbase_filter_ops filter_ops =
IUnknown * CALLBACK QTSplitter_create(IUnknown *outer, HRESULT *phr)
{
PIN_INFO *piInput;
QTSplitter *This;
static const WCHAR wcsInputPinName[] = {'I','n','p','u','t',' ','P','i','n',0};
......@@ -313,10 +312,9 @@ IUnknown * CALLBACK QTSplitter_create(IUnknown *outer, HRESULT *phr)
This->aSession = NULL;
This->runEvent = CreateEventW(NULL, 0, 0, NULL);
piInput = &This->pInputPin.pin.pinInfo;
piInput->dir = PINDIR_INPUT;
piInput->pFilter = &This->filter.IBaseFilter_iface;
lstrcpynW(piInput->achName, wcsInputPinName, ARRAY_SIZE(piInput->achName));
This->pInputPin.pin.dir = PINDIR_INPUT;
This->pInputPin.pin.filter = &This->filter;
lstrcpynW(This->pInputPin.pin.name, wcsInputPinName, ARRAY_SIZE(This->pInputPin.pin.name));
This->pInputPin.pin.IPin_iface.lpVtbl = &QT_InputPin_Vtbl;
This->pInputPin.pin.pConnectedTo = NULL;
This->pInputPin.pin.pCritSec = &This->filter.csFilter;
......@@ -825,7 +823,6 @@ static HRESULT QT_Process_Video_Track(QTSplitter* filter, Track trk)
{
AM_MEDIA_TYPE amt;
VIDEOINFOHEADER * pvi;
PIN_INFO piOutput;
HRESULT hr = S_OK;
OSErr err;
static const WCHAR szwVideoOut[] = {'V','i','d','e','o',0};
......@@ -913,11 +910,7 @@ static HRESULT QT_Process_Video_Track(QTSplitter* filter, Track trk)
duration = GetMediaDisplayDuration(videoMedia);
pvi->AvgTimePerFrame = (100000.0 * sampleCount * timeScale) / duration;
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &filter->filter.IBaseFilter_iface;
lstrcpyW(piOutput.achName,szwVideoOut);
hr = QT_AddPin(filter, &piOutput, &amt, TRUE);
hr = QT_AddPin(filter, szwVideoOut, &amt, TRUE);
if (FAILED(hr))
ERR("Failed to add Video Track\n");
else
......@@ -930,7 +923,6 @@ static HRESULT QT_Process_Audio_Track(QTSplitter* filter, Track trk)
{
AM_MEDIA_TYPE amt;
WAVEFORMATEX* pvi;
PIN_INFO piOutput;
HRESULT hr = S_OK;
static const WCHAR szwAudioOut[] = {'A','u','d','i','o',0};
Media audioMedia;
......@@ -967,11 +959,7 @@ static HRESULT QT_Process_Audio_Track(QTSplitter* filter, Track trk)
DisposeHandle((Handle)aDesc);
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &filter->filter.IBaseFilter_iface;
lstrcpyW(piOutput.achName,szwAudioOut);
hr = QT_AddPin(filter, &piOutput, &amt, FALSE);
hr = QT_AddPin(filter, szwAudioOut, &amt, FALSE);
if (FAILED(hr))
ERR("Failed to add Audio Track\n");
else
......@@ -1051,6 +1039,7 @@ static HRESULT WINAPI QTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin,
HRESULT hr = S_OK;
ALLOCATOR_PROPERTIES props;
QTInPin *This = impl_from_IPin(iface);
QTSplitter *filter = impl_from_strmbase_filter(This->pin.filter);
IMemAllocator *pAlloc;
TRACE("(%p/%p)->(%p, %p)\n", This, iface, pReceivePin, pmt);
......@@ -1085,13 +1074,13 @@ static HRESULT WINAPI QTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin,
}
LeaveCriticalSection(This->pin.pCritSec);
EnterCriticalSection(&impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->filter.csFilter);
hr = QT_Process_Movie(impl_from_IBaseFilter(This->pin.pinInfo.pFilter));
EnterCriticalSection(&filter->filter.csFilter);
hr = QT_Process_Movie(filter);
if (FAILED(hr))
{
IAsyncReader_Release(This->pReader);
This->pReader = NULL;
LeaveCriticalSection(&impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->filter.csFilter);
LeaveCriticalSection(&filter->filter.csFilter);
TRACE("Unable to process movie\n");
return hr;
}
......@@ -1099,7 +1088,7 @@ static HRESULT WINAPI QTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin,
This->pAlloc = NULL;
props.cBuffers = 8;
props.cbAlign = 1;
props.cbBuffer = impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->outputSize + props.cbAlign;
props.cbBuffer = filter->outputSize + props.cbAlign;
props.cbPrefix = 0;
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC,
&IID_IMemAllocator, (LPVOID *)&pAlloc);
......@@ -1122,7 +1111,7 @@ static HRESULT WINAPI QTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin,
}
else
{
QT_RemoveOutputPins(impl_from_IBaseFilter(This->pin.pinInfo.pFilter));
QT_RemoveOutputPins(filter);
if (This->pReader)
IAsyncReader_Release(This->pReader);
This->pReader = NULL;
......@@ -1131,7 +1120,7 @@ static HRESULT WINAPI QTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin,
This->pAlloc = NULL;
}
TRACE("Size: %i\n", props.cbBuffer);
LeaveCriticalSection(&impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->filter.csFilter);
LeaveCriticalSection(&filter->filter.csFilter);
return hr;
}
......@@ -1143,11 +1132,11 @@ static HRESULT WINAPI QTInPin_Disconnect(IPin *iface)
FILTER_STATE state;
TRACE("()\n");
hr = IBaseFilter_GetState(This->pin.pinInfo.pFilter, INFINITE, &state);
hr = IBaseFilter_GetState(&This->pin.filter->IBaseFilter_iface, INFINITE, &state);
EnterCriticalSection(This->pin.pCritSec);
if (This->pin.pConnectedTo)
{
QTSplitter *Parser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
QTSplitter *Parser = impl_from_strmbase_filter(This->pin.filter);
if (SUCCEEDED(hr) && state == State_Stopped)
{
......@@ -1182,38 +1171,26 @@ static HRESULT WINAPI QTInPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *pmt)
static HRESULT WINAPI QTInPin_EndOfStream(IPin *iface)
{
QTInPin *pin = impl_from_IPin(iface);
QTSplitter *This = impl_from_IBaseFilter(pin->pin.pinInfo.pFilter);
FIXME("Propagate message on %p\n", This);
FIXME("iface %p, stub!\n", iface);
return S_OK;
}
static HRESULT WINAPI QTInPin_BeginFlush(IPin *iface)
{
QTInPin *pin = impl_from_IPin(iface);
QTSplitter *This = impl_from_IBaseFilter(pin->pin.pinInfo.pFilter);
FIXME("Propagate message on %p\n", This);
FIXME("iface %p, stub!\n", iface);
return S_OK;
}
static HRESULT WINAPI QTInPin_EndFlush(IPin *iface)
{
QTInPin *pin = impl_from_IPin(iface);
QTSplitter *This = impl_from_IBaseFilter(pin->pin.pinInfo.pFilter);
FIXME("Propagate message on %p\n", This);
FIXME("iface %p, stub!\n", iface);
return S_OK;
}
static HRESULT WINAPI QTInPin_NewSegment(IPin *iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
QTInPin *pin = impl_from_IPin(iface);
QTSplitter *This = impl_from_IBaseFilter(pin->pin.pinInfo.pFilter);
BasePinImpl_NewSegment(iface, tStart, tStop, dRate);
FIXME("Propagate message on %p\n", This);
FIXME("iface %p, stub!\n", iface);
return S_OK;
}
......@@ -1230,7 +1207,7 @@ static HRESULT WINAPI QTInPin_QueryInterface(IPin * iface, REFIID riid, LPVOID *
else if (IsEqualIID(riid, &IID_IPin))
*ppv = iface;
else if (IsEqualIID(riid, &IID_IMediaSeeking))
return IBaseFilter_QueryInterface(This->pin.pinInfo.pFilter, &IID_IMediaSeeking, ppv);
return IBaseFilter_QueryInterface(&This->pin.filter->IBaseFilter_iface, &IID_IMediaSeeking, ppv);
if (*ppv)
{
......@@ -1304,7 +1281,7 @@ static HRESULT WINAPI QTOutPin_QueryInterface(IPin *iface, REFIID riid, void **p
else if (IsEqualIID(riid, &IID_IPin))
*ppv = iface;
else if (IsEqualIID(riid, &IID_IMediaSeeking))
return IBaseFilter_QueryInterface(This->pin.pin.pinInfo.pFilter, &IID_IMediaSeeking, ppv);
return IBaseFilter_QueryInterface(&This->pin.pin.filter->IBaseFilter_iface, &IID_IMediaSeeking, ppv);
else if (IsEqualIID(riid, &IID_IQualityControl))
*ppv = &This->IQualityControl_iface;
......@@ -1345,7 +1322,7 @@ static HRESULT WINAPI QTOutPin_DecideAllocator(BaseOutputPin *iface, IMemInputPi
{
HRESULT hr;
QTOutPin *This = impl_QTOutPin_from_BaseOutputPin(iface);
QTSplitter *QTfilter = impl_from_IBaseFilter(This->pin.pin.pinInfo.pFilter);
QTSplitter *QTfilter = impl_from_strmbase_filter(This->pin.pin.filter);
*pAlloc = NULL;
if (QTfilter->pInputPin.pAlloc)
......@@ -1444,7 +1421,7 @@ static const OutputQueueFuncTable output_OutputQueueFuncTable = {
OutputQueueImpl_ThreadProc
};
static HRESULT QT_AddPin(QTSplitter *filter, const PIN_INFO *pin_info,
static HRESULT QT_AddPin(QTSplitter *filter, const WCHAR *name,
const AM_MEDIA_TYPE *mt, BOOL video)
{
QTOutPin *pin;
......@@ -1457,8 +1434,8 @@ static HRESULT QT_AddPin(QTSplitter *filter, const PIN_INFO *pin_info,
else
filter->pAudio_Pin = pin;
strmbase_source_init(&pin->pin, &QT_OutputPin_Vtbl, piOutput,
&output_BaseOutputFuncTable, &filter->filter.csFilter);
strmbase_source_init(&pin->pin, &QT_OutputPin_Vtbl, &filter->filter, name,
&output_BaseOutputFuncTable);
pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
CopyMediaType(pin->pmt, mt);
pin->IQualityControl_iface.lpVtbl = &QTOutPin_QualityControl_Vtbl;
......
......@@ -30,16 +30,17 @@ void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType);
typedef struct BasePin
{
IPin IPin_iface;
LPCRITICAL_SECTION pCritSec;
PIN_INFO pinInfo;
IPin * pConnectedTo;
AM_MEDIA_TYPE mtCurrent;
REFERENCE_TIME tStart;
REFERENCE_TIME tStop;
double dRate;
const struct BasePinFuncTable* pFuncsTable;
IPin IPin_iface;
CRITICAL_SECTION *pCritSec;
struct strmbase_filter *filter;
PIN_DIRECTION dir;
WCHAR name[128];
IPin *pConnectedTo;
AM_MEDIA_TYPE mtCurrent;
REFERENCE_TIME tStart, tStop;
double dRate;
const struct BasePinFuncTable* pFuncsTable;
} BasePin;
typedef HRESULT (WINAPI *BasePin_CheckMediaType)(BasePin *This, const AM_MEDIA_TYPE *pmt);
......@@ -133,8 +134,8 @@ HRESULT WINAPI BaseOutputPinImpl_DecideAllocator(BaseOutputPin *This, IMemInputP
HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BaseOutputPin *pin, IPin *peer, const AM_MEDIA_TYPE *mt);
void strmbase_source_cleanup(BaseOutputPin *pin);
void strmbase_source_init(BaseOutputPin *pin, const IPinVtbl *vtbl, const PIN_INFO *info,
const BaseOutputPinFuncTable *func_table, CRITICAL_SECTION *cs);
void strmbase_source_init(BaseOutputPin *pin, const IPinVtbl *vtbl, struct strmbase_filter *filter,
const WCHAR *name, const BaseOutputPinFuncTable *func_table);
/* Base Input Pin */
HRESULT WINAPI BaseInputPinImpl_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
......@@ -146,8 +147,8 @@ HRESULT WINAPI BaseInputPinImpl_BeginFlush(IPin * iface);
HRESULT WINAPI BaseInputPinImpl_EndFlush(IPin * iface);
HRESULT WINAPI BaseInputPinImpl_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
void strmbase_sink_init(BaseInputPin *pin, const IPinVtbl *vtbl, const PIN_INFO *info,
const BaseInputPinFuncTable *func_table, CRITICAL_SECTION *cs, IMemAllocator *allocator);
void strmbase_sink_init(BaseInputPin *pin, const IPinVtbl *vtbl, struct strmbase_filter *filter,
const WCHAR *name, const BaseInputPinFuncTable *func_table, IMemAllocator *allocator);
void strmbase_sink_cleanup(BaseInputPin *pin);
struct strmbase_filter
......
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