/* IPin - output pin */ static HRESULT WINAPI SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE *type) { SG_Pin *This = impl_from_IPin(iface); HRESULT hr; TRACE("(%p)->(%p, %p)\n", This, receiver, type); if (!receiver) return E_POINTER; if (This->pair) return VFW_E_ALREADY_CONNECTED; if (This->sg->filter.state != State_Stopped) return VFW_E_NOT_STOPPED; if (type) { TRACE("Media type: %s/%s ssize: %u format: %s (%u bytes)\n", debugstr_guid(&type->majortype), debugstr_guid(&type->subtype), type->lSampleSize, debugstr_guid(&type->formattype), type->cbFormat); if (!IsEqualGUID(&This->sg->mtype.majortype,&GUID_NULL) && !IsEqualGUID(&This->sg->mtype.majortype,&type->majortype)) return VFW_E_TYPE_NOT_ACCEPTED; if (!IsEqualGUID(&This->sg->mtype.subtype,&MEDIASUBTYPE_None) && !IsEqualGUID(&This->sg->mtype.subtype,&type->subtype)) return VFW_E_TYPE_NOT_ACCEPTED; if (!IsEqualGUID(&This->sg->mtype.formattype,&GUID_NULL) && !IsEqualGUID(&This->sg->mtype.formattype,&FORMAT_None) && !IsEqualGUID(&This->sg->mtype.formattype,&type->formattype)) return VFW_E_TYPE_NOT_ACCEPTED; } else type = &This->sg->mtype; if (!IsEqualGUID(&type->formattype, &FORMAT_None) && !IsEqualGUID(&type->formattype, &GUID_NULL) && !type->pbFormat) return VFW_E_TYPE_NOT_ACCEPTED; hr = IPin_ReceiveConnection(receiver, &This->IPin_iface, type); if (FAILED(hr)) return hr; This->pair = receiver; if (This->sg->memOutput) { IMemInputPin_Release(This->sg->memOutput); This->sg->memOutput = NULL; } IPin_QueryInterface(receiver,&IID_IMemInputPin,(void **)&(This->sg->memOutput)); TRACE("(%p) Accepted IPin %p, IMemInputPin %p\n", This, receiver, This->sg->memOutput); return S_OK; }
/* IPin - input pin */ static HRESULT WINAPI SampleGrabber_In_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_MEDIA_TYPE *type) { SG_Pin *This = impl_from_IPin(iface); TRACE("(%p)->(%p, %p)\n", This, connector, type); if (!connector) return E_POINTER; if (This->pair) return VFW_E_ALREADY_CONNECTED; if (This->sg->filter.state != State_Stopped) return VFW_E_NOT_STOPPED; if (type) { TRACE("Media type: %s/%s ssize: %u format: %s (%u bytes)\n", debugstr_guid(&type->majortype), debugstr_guid(&type->subtype), type->lSampleSize, debugstr_guid(&type->formattype), type->cbFormat); if (!IsEqualGUID(&type->formattype, &FORMAT_None) && !IsEqualGUID(&type->formattype, &GUID_NULL) && !type->pbFormat) return VFW_E_INVALIDMEDIATYPE; if (!IsEqualGUID(&This->sg->mtype.majortype,&GUID_NULL) && !IsEqualGUID(&This->sg->mtype.majortype,&type->majortype)) return VFW_E_TYPE_NOT_ACCEPTED; if (!IsEqualGUID(&This->sg->mtype.subtype,&MEDIASUBTYPE_None) && !IsEqualGUID(&This->sg->mtype.subtype,&type->subtype)) return VFW_E_TYPE_NOT_ACCEPTED; if (!IsEqualGUID(&This->sg->mtype.formattype,&GUID_NULL) && !IsEqualGUID(&This->sg->mtype.formattype,&FORMAT_None) && !IsEqualGUID(&This->sg->mtype.formattype,&type->formattype)) return VFW_E_TYPE_NOT_ACCEPTED; if (This->sg->mtype.pbFormat) CoTaskMemFree(This->sg->mtype.pbFormat); This->sg->mtype = *type; This->sg->mtype.pUnk = NULL; if (type->cbFormat) { This->sg->mtype.pbFormat = CoTaskMemAlloc(type->cbFormat); CopyMemory(This->sg->mtype.pbFormat, type->pbFormat, type->cbFormat); } else This->sg->mtype.pbFormat = NULL; } This->pair = connector; TRACE("(%p) Accepted IPin %p\n", This, connector); return S_OK; }
/* IPin */ static HRESULT WINAPI SampleGrabber_IPin_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *mtype) { SG_Pin *This = impl_from_IPin(iface); TRACE("(%p)->(%p)\n", This, mtype); if (!mtype) return E_POINTER; if (!This->pair) return VFW_E_NOT_CONNECTED; *mtype = This->sg->mtype; if (mtype->cbFormat) { mtype->pbFormat = CoTaskMemAlloc(mtype->cbFormat); CopyMemory(mtype->pbFormat, This->sg->mtype.pbFormat, mtype->cbFormat); } return S_OK; }
static HRESULT WINAPI Pin_QueryInterface(IPin *iface, REFIID riid, void **ppv) { test_filter *This = impl_from_IPin(iface); if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin)) { *ppv = iface; return S_OK; } if(IsEqualIID(riid, &IID_IKsPropertySet)) { *ppv = &This->IKsPropertySet_iface; return S_OK; } ok(0, "unexpected call\n"); *ppv = NULL; return E_NOINTERFACE; }
static ULONG WINAPI QTInPin_Release(IPin *iface) { QTInPin *This = impl_from_IPin(iface); ULONG refCount = InterlockedDecrement(&This->pin.refCount); TRACE("(%p)->() Release from %d\n", iface, refCount + 1); if (!refCount) { FreeMediaType(&This->pin.mtCurrent); if (This->pAlloc) IMemAllocator_Release(This->pAlloc); This->pAlloc = NULL; This->pin.IPin_iface.lpVtbl = NULL; return 0; } else return refCount; }
/* IPin - output pin */ static HRESULT WINAPI SampleGrabber_Out_IPin_Disconnect(IPin *iface) { SG_Pin *This = impl_from_IPin(iface); TRACE("(%p)->() pair = %p\n", This, This->pair); if (This->sg->filter.state != State_Stopped) return VFW_E_NOT_STOPPED; if (This->pair) { This->pair = NULL; if (This->sg->memOutput) { IMemInputPin_Release(This->sg->memOutput); This->sg->memOutput = NULL; } return S_OK; } return S_FALSE; }
static HRESULT WINAPI AVICompressorIn_ReceiveConnection(IPin *iface, IPin *pConnector, const AM_MEDIA_TYPE *pmt) { AVICompressor *This = impl_from_IPin(iface); HRESULT hres; TRACE("(%p)->(%p AM_MEDIA_TYPE(%p))\n", This, pConnector, pmt); dump_AM_MEDIA_TYPE(pmt); hres = BaseInputPinImpl_ReceiveConnection(iface, pConnector, pmt); if(FAILED(hres)) return hres; hres = fill_format_info(This, (VIDEOINFOHEADER*)pmt->pbFormat); if(FAILED(hres)) BasePinImpl_Disconnect(iface); return hres; }
/* IPin - input pin */ static HRESULT WINAPI SampleGrabber_In_IPin_QueryInternalConnections(IPin *iface, IPin **pins, ULONG *nPins) { SG_Pin *This = impl_from_IPin(iface); TRACE("(%p)->(%p, %p) size = %u\n", This, pins, nPins, (nPins ? *nPins : 0)); if (!nPins) return E_POINTER; if (*nPins) { if (!pins) return E_POINTER; IPin_AddRef(&This->sg->pin_out.IPin_iface); *pins = &This->sg->pin_out.IPin_iface; *nPins = 1; return S_OK; } *nPins = 1; return S_FALSE; }
/* IUnknown */ static HRESULT WINAPI SampleGrabber_IPin_QueryInterface(IPin *iface, REFIID riid, void **ppv) { SG_Pin *This = impl_from_IPin(iface); TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); *ppv = NULL; if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin)) *ppv = iface; else if (IsEqualIID(riid, &IID_IMemInputPin)) *ppv = &This->sg->IMemInputPin_iface; else if (IsEqualIID(riid, &IID_IMediaSeeking)) return IUnknown_QueryInterface(&This->sg->IUnknown_inner, riid, ppv); else if (IsEqualIID(riid, &IID_IMediaPosition)) return IUnknown_QueryInterface(&This->sg->IUnknown_inner, riid, ppv); else { WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppv); return E_NOINTERFACE; } IUnknown_AddRef((IUnknown*)*ppv); return S_OK; }
static HRESULT WINAPI VfwPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv) { VfwPinImpl *This = impl_from_IPin(iface); TRACE("%s %p\n", debugstr_guid(riid), ppv); *ppv = NULL; if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin)) *ppv = This; else if (IsEqualIID(riid, &IID_IKsPropertySet)) *ppv = &This->IKsPropertySet_iface; else if (IsEqualIID(riid, &IID_IAMStreamConfig)) return IUnknown_QueryInterface((IUnknown *)This->parent, riid, ppv); if (*ppv) { IUnknown_AddRef((IUnknown *)(*ppv)); return S_OK; } FIXME("No interface for %s!\n", debugstr_guid(riid)); return E_NOINTERFACE; }
static HRESULT WINAPI Pin_QueryPinInfo(IPin *iface, PIN_INFO *pInfo) { test_filter *This = impl_from_IPin(iface); check_calls_list("Pin_QueryPinInfo", PIN_QUERYPININFO, This->filter_type); return E_NOTIMPL; }
static HRESULT WINAPI QTInPin_ReceiveConnection(IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) { HRESULT hr = S_OK; ALLOCATOR_PROPERTIES props; QTInPin *This = impl_from_IPin(iface); TRACE("(%p/%p)->(%p, %p)\n", This, iface, pReceivePin, pmt); EnterCriticalSection(This->pin.pCritSec); This->pReader = NULL; if (This->pin.pConnectedTo) hr = VFW_E_ALREADY_CONNECTED; else if (IPin_QueryAccept(iface, pmt) != S_OK) hr = VFW_E_TYPE_NOT_ACCEPTED; else { PIN_DIRECTION pindirReceive; IPin_QueryDirection(pReceivePin, &pindirReceive); if (pindirReceive != PINDIR_OUTPUT) hr = VFW_E_INVALID_DIRECTION; } if (FAILED(hr)) { LeaveCriticalSection(This->pin.pCritSec); return hr; } hr = IPin_QueryInterface(pReceivePin, &IID_IAsyncReader, (LPVOID *)&This->pReader); if (FAILED(hr)) { LeaveCriticalSection(This->pin.pCritSec); TRACE("Input source is not an AsyncReader\n"); return hr; } 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)); if (FAILED(hr)) { LeaveCriticalSection(&impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->filter.csFilter); TRACE("Unable to process movie\n"); return hr; } This->pAlloc = NULL; props.cBuffers = 8; props.cbAlign = 1; props.cbBuffer = impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->outputSize + props.cbAlign; props.cbPrefix = 0; hr = IAsyncReader_RequestAllocator(This->pReader, NULL, &props, &This->pAlloc); if (SUCCEEDED(hr)) { CopyMediaType(&This->pin.mtCurrent, pmt); This->pin.pConnectedTo = pReceivePin; IPin_AddRef(pReceivePin); hr = IMemAllocator_Commit(This->pAlloc); } else { QT_RemoveOutputPins(impl_from_IBaseFilter(This->pin.pinInfo.pFilter)); if (This->pReader) IAsyncReader_Release(This->pReader); This->pReader = NULL; if (This->pAlloc) IMemAllocator_Release(This->pAlloc); This->pAlloc = NULL; } TRACE("Size: %i\n", props.cbBuffer); LeaveCriticalSection(&impl_from_IBaseFilter(This->pin.pinInfo.pFilter)->filter.csFilter); return hr; }
/* IUnknown */ static ULONG WINAPI SampleGrabber_IPin_Release(IPin *iface) { SG_Pin *This = impl_from_IPin(iface); return ISampleGrabber_Release(&This->sg->ISampleGrabber_iface); }
static ULONG WINAPI AVICompressorOut_Release(IPin *iface) { AVICompressor *This = impl_from_IPin(iface); return IBaseFilter_Release(&This->filter.IBaseFilter_iface); }
static ULONG WINAPI AVICompressorIn_AddRef(IPin *iface) { AVICompressor *This = impl_from_IPin(iface); return IBaseFilter_AddRef(&This->filter.IBaseFilter_iface); }