Commit 14a51f57 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

qcap/avimux: Use strmbase sink connection methods.

parent 88898cf5
...@@ -1410,41 +1410,15 @@ static HRESULT WINAPI AviMuxIn_Receive(struct strmbase_sink *base, IMediaSample ...@@ -1410,41 +1410,15 @@ static HRESULT WINAPI AviMuxIn_Receive(struct strmbase_sink *base, IMediaSample
return hr; return hr;
} }
static const struct strmbase_sink_ops sink_ops = static HRESULT avi_mux_sink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *pmt)
{
.base.pin_query_interface = sink_query_interface,
.base.pin_query_accept = sink_query_accept,
.base.pin_get_media_type = strmbase_pin_get_media_type,
.pfnReceive = AviMuxIn_Receive,
};
static inline AviMux* impl_from_in_IPin(IPin *iface)
{ {
struct strmbase_pin *pin = CONTAINING_RECORD(iface, struct strmbase_pin, IPin_iface); AviMuxIn *avimuxin = impl_sink_from_strmbase_pin(&iface->pin);
return impl_from_strmbase_filter(pin->filter); AviMux *This = impl_from_strmbase_filter(iface->pin.filter);
}
static inline AviMuxIn* AviMuxIn_from_IPin(IPin *iface)
{
return CONTAINING_RECORD(iface, AviMuxIn, pin.pin.IPin_iface);
}
static HRESULT WINAPI AviMuxIn_ReceiveConnection(IPin *iface,
IPin *pConnector, const AM_MEDIA_TYPE *pmt)
{
AviMux *This = impl_from_in_IPin(iface);
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface);
HRESULT hr; HRESULT hr;
TRACE("pin %p, pConnector %p, pmt %p.\n", avimuxin, pConnector, pmt);
if(!pmt) if(!pmt)
return E_POINTER; return E_POINTER;
hr = BaseInputPinImpl_ReceiveConnection(iface, pConnector, pmt);
if(FAILED(hr))
return hr;
if(IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) && if(IsEqualIID(&pmt->majortype, &MEDIATYPE_Video) &&
IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) { IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) {
ALLOCATOR_PROPERTIES req, act; ALLOCATOR_PROPERTIES req, act;
...@@ -1468,10 +1442,8 @@ static HRESULT WINAPI AviMuxIn_ReceiveConnection(IPin *iface, ...@@ -1468,10 +1442,8 @@ static HRESULT WINAPI AviMuxIn_ReceiveConnection(IPin *iface,
hr = IMemAllocator_SetProperties(avimuxin->samples_allocator, &req, &act); hr = IMemAllocator_SetProperties(avimuxin->samples_allocator, &req, &act);
if(SUCCEEDED(hr)) if(SUCCEEDED(hr))
hr = IMemAllocator_Commit(avimuxin->samples_allocator); hr = IMemAllocator_Commit(avimuxin->samples_allocator);
if(FAILED(hr)) { if (FAILED(hr))
BaseInputPinImpl_Disconnect(iface);
return hr; return hr;
}
size = pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader); size = pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
avimuxin->strf = CoTaskMemAlloc(sizeof(RIFFCHUNK) + ALIGN(FIELD_OFFSET(BITMAPINFO, bmiColors[vih->bmiHeader.biClrUsed]))); avimuxin->strf = CoTaskMemAlloc(sizeof(RIFFCHUNK) + ALIGN(FIELD_OFFSET(BITMAPINFO, bmiColors[vih->bmiHeader.biClrUsed])));
...@@ -1489,23 +1461,15 @@ static HRESULT WINAPI AviMuxIn_ReceiveConnection(IPin *iface, ...@@ -1489,23 +1461,15 @@ static HRESULT WINAPI AviMuxIn_ReceiveConnection(IPin *iface,
return create_input_pin(This); return create_input_pin(This);
} }
static HRESULT WINAPI AviMuxIn_Disconnect(IPin *iface) static void avi_mux_sink_disconnect(struct strmbase_sink *iface)
{ {
AviMuxIn *avimuxin = AviMuxIn_from_IPin(iface); AviMuxIn *avimuxin = impl_sink_from_strmbase_pin(&iface->pin);
IMediaSample **prev, *cur; IMediaSample **prev, *cur;
HRESULT hr;
TRACE("pin %p.\n", avimuxin);
hr = BaseInputPinImpl_Disconnect(iface);
if(FAILED(hr))
return hr;
IMemAllocator_Decommit(avimuxin->samples_allocator); IMemAllocator_Decommit(avimuxin->samples_allocator);
while(avimuxin->samples_head) { while(avimuxin->samples_head) {
cur = avimuxin->samples_head; cur = avimuxin->samples_head;
hr = IMediaSample_GetPointer(cur, (BYTE**)&prev); if (FAILED(IMediaSample_GetPointer(cur, (BYTE **)&prev)))
if(FAILED(hr))
break; break;
prev--; prev--;
...@@ -1518,7 +1482,22 @@ static HRESULT WINAPI AviMuxIn_Disconnect(IPin *iface) ...@@ -1518,7 +1482,22 @@ static HRESULT WINAPI AviMuxIn_Disconnect(IPin *iface)
} }
CoTaskMemFree(avimuxin->strf); CoTaskMemFree(avimuxin->strf);
avimuxin->strf = NULL; avimuxin->strf = NULL;
return hr; }
static const struct strmbase_sink_ops sink_ops =
{
.base.pin_query_interface = sink_query_interface,
.base.pin_query_accept = sink_query_accept,
.base.pin_get_media_type = strmbase_pin_get_media_type,
.pfnReceive = AviMuxIn_Receive,
.sink_connect = avi_mux_sink_connect,
.sink_disconnect = avi_mux_sink_disconnect,
};
static inline AviMux* impl_from_in_IPin(IPin *iface)
{
struct strmbase_pin *pin = CONTAINING_RECORD(iface, struct strmbase_pin, IPin_iface);
return impl_from_strmbase_filter(pin->filter);
} }
static const IPinVtbl AviMuxIn_PinVtbl = { static const IPinVtbl AviMuxIn_PinVtbl = {
...@@ -1526,8 +1505,8 @@ static const IPinVtbl AviMuxIn_PinVtbl = { ...@@ -1526,8 +1505,8 @@ static const IPinVtbl AviMuxIn_PinVtbl = {
BasePinImpl_AddRef, BasePinImpl_AddRef,
BasePinImpl_Release, BasePinImpl_Release,
BaseInputPinImpl_Connect, BaseInputPinImpl_Connect,
AviMuxIn_ReceiveConnection, BaseInputPinImpl_ReceiveConnection,
AviMuxIn_Disconnect, BaseInputPinImpl_Disconnect,
BasePinImpl_ConnectedTo, BasePinImpl_ConnectedTo,
BasePinImpl_ConnectionMediaType, BasePinImpl_ConnectionMediaType,
BasePinImpl_QueryPinInfo, BasePinImpl_QueryPinInfo,
......
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