2015-05-28 19:04:29 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the SmartTee filter
|
|
|
|
*
|
|
|
|
* Copyright 2015 Damjan Jovanovic
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wtypes.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "dshow.h"
|
|
|
|
|
|
|
|
#include "qcap_main.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(qcap);
|
|
|
|
|
|
|
|
typedef struct {
|
2019-08-29 03:24:30 +02:00
|
|
|
struct strmbase_filter filter;
|
2019-06-13 01:58:38 +02:00
|
|
|
BaseInputPin sink;
|
2019-09-12 21:28:25 +02:00
|
|
|
struct strmbase_source capture, preview;
|
2015-05-28 19:04:29 +02:00
|
|
|
} SmartTeeFilter;
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static inline SmartTeeFilter *impl_from_strmbase_filter(struct strmbase_filter *filter)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(filter, SmartTeeFilter, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline SmartTeeFilter *impl_from_IBaseFilter(IBaseFilter *iface)
|
|
|
|
{
|
2019-08-29 03:24:30 +02:00
|
|
|
struct strmbase_filter *filter = CONTAINING_RECORD(iface, struct strmbase_filter, IBaseFilter_iface);
|
|
|
|
return impl_from_strmbase_filter(filter);
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
2019-09-24 02:33:24 +02:00
|
|
|
static inline SmartTeeFilter *impl_from_strmbase_pin(struct strmbase_pin *pin)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-09-06 02:02:15 +02:00
|
|
|
return impl_from_strmbase_filter(pin->filter);
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline SmartTeeFilter *impl_from_IPin(IPin *iface)
|
|
|
|
{
|
2019-09-24 02:33:24 +02:00
|
|
|
return impl_from_strmbase_filter(CONTAINING_RECORD(iface, struct strmbase_pin, IPin_iface)->filter);
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SmartTeeFilter_Stop(IBaseFilter *iface)
|
|
|
|
{
|
|
|
|
SmartTeeFilter *This = impl_from_IBaseFilter(iface);
|
2015-05-31 20:11:44 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2017-09-11 11:54:04 +02:00
|
|
|
This->filter.state = State_Stopped;
|
2015-05-31 20:11:44 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
|
|
|
return S_OK;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SmartTeeFilter_Pause(IBaseFilter *iface)
|
|
|
|
{
|
|
|
|
SmartTeeFilter *This = impl_from_IBaseFilter(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SmartTeeFilter_Run(IBaseFilter *iface, REFERENCE_TIME tStart)
|
|
|
|
{
|
2015-05-31 20:11:44 +02:00
|
|
|
SmartTeeFilter *This = impl_from_IBaseFilter(iface);
|
|
|
|
HRESULT hr = S_OK;
|
2017-08-18 22:12:18 +02:00
|
|
|
TRACE("(%p, %s)\n", This, wine_dbgstr_longlong(tStart));
|
2015-05-31 20:11:44 +02:00
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
|
|
|
if(This->filter.state != State_Running) {
|
|
|
|
/* We share an allocator among all pins, an allocator can only get committed
|
|
|
|
* once, state transitions occur in upstream order, and only output pins
|
|
|
|
* commit allocators, so let the filter attached to the input pin worry about it. */
|
2019-06-13 01:58:38 +02:00
|
|
|
if (This->sink.pin.pConnectedTo)
|
2015-05-31 20:11:44 +02:00
|
|
|
This->filter.state = State_Running;
|
|
|
|
else
|
|
|
|
hr = VFW_E_NOT_CONNECTED;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
|
|
|
return hr;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl SmartTeeFilterVtbl = {
|
2019-06-05 00:54:23 +02:00
|
|
|
BaseFilterImpl_QueryInterface,
|
|
|
|
BaseFilterImpl_AddRef,
|
|
|
|
BaseFilterImpl_Release,
|
2015-05-28 19:04:29 +02:00
|
|
|
BaseFilterImpl_GetClassID,
|
|
|
|
SmartTeeFilter_Stop,
|
|
|
|
SmartTeeFilter_Pause,
|
|
|
|
SmartTeeFilter_Run,
|
|
|
|
BaseFilterImpl_GetState,
|
|
|
|
BaseFilterImpl_SetSyncSource,
|
|
|
|
BaseFilterImpl_GetSyncSource,
|
|
|
|
BaseFilterImpl_EnumPins,
|
2018-07-05 00:34:43 +02:00
|
|
|
BaseFilterImpl_FindPin,
|
2015-05-28 19:04:29 +02:00
|
|
|
BaseFilterImpl_QueryFilterInfo,
|
|
|
|
BaseFilterImpl_JoinFilterGraph,
|
|
|
|
BaseFilterImpl_QueryVendorInfo
|
|
|
|
};
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static IPin *smart_tee_get_pin(struct strmbase_filter *iface, unsigned int index)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-08-29 03:24:30 +02:00
|
|
|
SmartTeeFilter *filter = impl_from_strmbase_filter(iface);
|
2015-05-28 19:04:29 +02:00
|
|
|
|
2019-05-24 00:06:30 +02:00
|
|
|
if (index == 0)
|
2019-06-13 01:58:38 +02:00
|
|
|
return &filter->sink.pin.IPin_iface;
|
2019-05-24 00:06:30 +02:00
|
|
|
else if (index == 1)
|
2019-06-14 01:09:22 +02:00
|
|
|
return &filter->capture.pin.IPin_iface;
|
2019-05-24 00:06:30 +02:00
|
|
|
else if (index == 2)
|
2019-06-14 01:09:23 +02:00
|
|
|
return &filter->preview.pin.IPin_iface;
|
2019-06-11 16:42:16 +02:00
|
|
|
return NULL;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static void smart_tee_destroy(struct strmbase_filter *iface)
|
2019-06-05 00:54:23 +02:00
|
|
|
{
|
2019-08-29 03:24:30 +02:00
|
|
|
SmartTeeFilter *filter = impl_from_strmbase_filter(iface);
|
2019-06-05 00:54:23 +02:00
|
|
|
|
2019-06-13 01:58:38 +02:00
|
|
|
strmbase_sink_cleanup(&filter->sink);
|
2019-06-14 01:09:22 +02:00
|
|
|
strmbase_source_cleanup(&filter->capture);
|
2019-06-14 01:09:23 +02:00
|
|
|
strmbase_source_cleanup(&filter->preview);
|
2019-06-05 00:54:23 +02:00
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
|
|
|
CoTaskMemFree(filter);
|
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:29 +02:00
|
|
|
static const struct strmbase_filter_ops filter_ops =
|
|
|
|
{
|
2019-05-24 00:06:31 +02:00
|
|
|
.filter_get_pin = smart_tee_get_pin,
|
2019-06-05 00:54:23 +02:00
|
|
|
.filter_destroy = smart_tee_destroy,
|
2015-05-28 19:04:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const IPinVtbl SmartTeeFilterInputVtbl = {
|
|
|
|
BaseInputPinImpl_QueryInterface,
|
2019-06-19 03:17:37 +02:00
|
|
|
BasePinImpl_AddRef,
|
|
|
|
BasePinImpl_Release,
|
2015-05-28 19:04:29 +02:00
|
|
|
BaseInputPinImpl_Connect,
|
|
|
|
BaseInputPinImpl_ReceiveConnection,
|
|
|
|
BasePinImpl_Disconnect,
|
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
|
|
|
BasePinImpl_QueryAccept,
|
|
|
|
BasePinImpl_EnumMediaTypes,
|
|
|
|
BasePinImpl_QueryInternalConnections,
|
|
|
|
BaseInputPinImpl_EndOfStream,
|
|
|
|
BaseInputPinImpl_BeginFlush,
|
|
|
|
BaseInputPinImpl_EndFlush,
|
|
|
|
BaseInputPinImpl_NewSegment
|
|
|
|
};
|
|
|
|
|
2019-09-24 02:33:24 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterInput_CheckMediaType(struct strmbase_pin *base, const AM_MEDIA_TYPE *pmt)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-09-24 02:33:24 +02:00
|
|
|
SmartTeeFilter *This = impl_from_strmbase_pin(base);
|
2015-05-28 19:04:34 +02:00
|
|
|
TRACE("(%p, AM_MEDIA_TYPE(%p))\n", This, pmt);
|
2015-05-28 19:04:29 +02:00
|
|
|
dump_AM_MEDIA_TYPE(pmt);
|
2015-05-28 19:04:34 +02:00
|
|
|
if (!pmt)
|
|
|
|
return VFW_E_TYPE_NOT_ACCEPTED;
|
|
|
|
/* We'll take any media type, but the output pins will later
|
|
|
|
* struggle to connect downstream. */
|
|
|
|
return S_OK;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
2019-09-24 02:33:24 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterInput_GetMediaType(struct strmbase_pin *base, int iPosition, AM_MEDIA_TYPE *amt)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-09-24 02:33:24 +02:00
|
|
|
SmartTeeFilter *This = impl_from_strmbase_pin(base);
|
2015-05-28 19:04:34 +02:00
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p)->(%d, %p)\n", This, iPosition, amt);
|
|
|
|
if (iPosition)
|
|
|
|
return S_FALSE;
|
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2019-06-13 01:58:38 +02:00
|
|
|
if (This->sink.pin.pConnectedTo)
|
|
|
|
{
|
|
|
|
CopyMediaType(amt, &This->sink.pin.mtCurrent);
|
2015-05-28 19:04:34 +02:00
|
|
|
hr = S_OK;
|
2019-06-13 01:58:38 +02:00
|
|
|
}
|
|
|
|
else
|
2015-05-28 19:04:34 +02:00
|
|
|
hr = S_FALSE;
|
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
|
|
|
return hr;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
2015-05-31 20:11:44 +02:00
|
|
|
static HRESULT copy_sample(IMediaSample *inputSample, IMemAllocator *allocator, IMediaSample **pOutputSample)
|
|
|
|
{
|
|
|
|
REFERENCE_TIME startTime, endTime;
|
|
|
|
BOOL haveStartTime = TRUE, haveEndTime = TRUE;
|
|
|
|
IMediaSample *outputSample = NULL;
|
|
|
|
BYTE *ptrIn, *ptrOut;
|
|
|
|
AM_MEDIA_TYPE *mediaType = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IMediaSample_GetTime(inputSample, &startTime, &endTime);
|
|
|
|
if (hr == S_OK)
|
|
|
|
;
|
|
|
|
else if (hr == VFW_S_NO_STOP_TIME)
|
|
|
|
haveEndTime = FALSE;
|
|
|
|
else if (hr == VFW_E_SAMPLE_TIME_NOT_SET)
|
|
|
|
haveStartTime = haveEndTime = FALSE;
|
|
|
|
else
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
hr = IMemAllocator_GetBuffer(allocator, &outputSample,
|
|
|
|
haveStartTime ? &startTime : NULL, haveEndTime ? &endTime : NULL, 0);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
if (IMediaSample_GetSize(outputSample) < IMediaSample_GetActualDataLength(inputSample)) {
|
|
|
|
ERR("insufficient space in sample\n");
|
|
|
|
hr = VFW_E_BUFFER_OVERFLOW;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMediaSample_SetTime(outputSample, haveStartTime ? &startTime : NULL, haveEndTime ? &endTime : NULL);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
|
|
|
|
hr = IMediaSample_GetPointer(inputSample, &ptrIn);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
hr = IMediaSample_GetPointer(outputSample, &ptrOut);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
memcpy(ptrOut, ptrIn, IMediaSample_GetActualDataLength(inputSample));
|
|
|
|
IMediaSample_SetActualDataLength(outputSample, IMediaSample_GetActualDataLength(inputSample));
|
|
|
|
|
|
|
|
hr = IMediaSample_SetDiscontinuity(outputSample, IMediaSample_IsDiscontinuity(inputSample) == S_OK);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
|
|
|
|
haveStartTime = haveEndTime = TRUE;
|
|
|
|
hr = IMediaSample_GetMediaTime(inputSample, &startTime, &endTime);
|
|
|
|
if (hr == S_OK)
|
|
|
|
;
|
|
|
|
else if (hr == VFW_S_NO_STOP_TIME)
|
|
|
|
haveEndTime = FALSE;
|
|
|
|
else if (hr == VFW_E_MEDIA_TIME_NOT_SET)
|
|
|
|
haveStartTime = haveEndTime = FALSE;
|
|
|
|
else
|
|
|
|
goto end;
|
|
|
|
hr = IMediaSample_SetMediaTime(outputSample, haveStartTime ? &startTime : NULL, haveEndTime ? &endTime : NULL);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
|
|
|
|
hr = IMediaSample_GetMediaType(inputSample, &mediaType);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
if (hr == S_OK) {
|
|
|
|
hr = IMediaSample_SetMediaType(outputSample, mediaType);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMediaSample_SetPreroll(outputSample, IMediaSample_IsPreroll(inputSample) == S_OK);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
|
|
|
|
hr = IMediaSample_SetSyncPoint(outputSample, IMediaSample_IsSyncPoint(inputSample) == S_OK);
|
|
|
|
if (FAILED(hr)) goto end;
|
|
|
|
|
|
|
|
end:
|
|
|
|
if (mediaType)
|
|
|
|
DeleteMediaType(mediaType);
|
|
|
|
if (FAILED(hr) && outputSample) {
|
|
|
|
IMediaSample_Release(outputSample);
|
|
|
|
outputSample = NULL;
|
|
|
|
}
|
|
|
|
*pOutputSample = outputSample;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SmartTeeFilterInput_Receive(BaseInputPin *base, IMediaSample *inputSample)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-09-24 02:33:24 +02:00
|
|
|
SmartTeeFilter *This = impl_from_strmbase_pin(&base->pin);
|
2015-05-31 20:11:44 +02:00
|
|
|
IMediaSample *captureSample = NULL;
|
|
|
|
IMediaSample *previewSample = NULL;
|
|
|
|
HRESULT hrCapture = VFW_E_NOT_CONNECTED, hrPreview = VFW_E_NOT_CONNECTED;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, inputSample);
|
|
|
|
|
|
|
|
/* Modifying the image coming out of one pin doesn't modify the image
|
|
|
|
* coming out of the other. MSDN claims the filter doesn't copy,
|
|
|
|
* but unless it somehow uses copy-on-write, I just don't see how
|
|
|
|
* that's possible. */
|
|
|
|
|
|
|
|
/* FIXME: we should ideally do each of these in a separate thread */
|
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2019-06-14 01:09:22 +02:00
|
|
|
if (This->capture.pin.pConnectedTo)
|
|
|
|
hrCapture = copy_sample(inputSample, This->capture.pAllocator, &captureSample);
|
2015-05-31 20:11:44 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
|
|
|
if (SUCCEEDED(hrCapture))
|
2019-06-14 01:09:22 +02:00
|
|
|
hrCapture = BaseOutputPinImpl_Deliver(&This->capture, captureSample);
|
2015-05-31 20:11:44 +02:00
|
|
|
if (captureSample)
|
|
|
|
IMediaSample_Release(captureSample);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2019-06-14 01:09:23 +02:00
|
|
|
if (This->preview.pin.pConnectedTo)
|
|
|
|
hrPreview = copy_sample(inputSample, This->preview.pAllocator, &previewSample);
|
2015-05-31 20:11:44 +02:00
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
|
|
|
/* No timestamps on preview stream: */
|
|
|
|
if (SUCCEEDED(hrPreview))
|
|
|
|
hrPreview = IMediaSample_SetTime(previewSample, NULL, NULL);
|
|
|
|
if (SUCCEEDED(hrPreview))
|
2019-06-14 01:09:23 +02:00
|
|
|
hrPreview = BaseOutputPinImpl_Deliver(&This->preview, previewSample);
|
2015-05-31 20:11:44 +02:00
|
|
|
if (previewSample)
|
|
|
|
IMediaSample_Release(previewSample);
|
|
|
|
|
|
|
|
/* FIXME: how to merge the HRESULTs from the 2 pins? */
|
|
|
|
if (SUCCEEDED(hrCapture))
|
|
|
|
return hrCapture;
|
|
|
|
else
|
|
|
|
return hrPreview;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const BaseInputPinFuncTable SmartTeeFilterInputFuncs = {
|
|
|
|
{
|
|
|
|
SmartTeeFilterInput_CheckMediaType,
|
|
|
|
SmartTeeFilterInput_GetMediaType
|
|
|
|
},
|
|
|
|
SmartTeeFilterInput_Receive
|
|
|
|
};
|
|
|
|
|
2015-05-28 19:04:34 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterCapture_EnumMediaTypes(IPin *iface, IEnumMediaTypes **ppEnum)
|
|
|
|
{
|
|
|
|
SmartTeeFilter *This = impl_from_IPin(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppEnum);
|
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2019-06-13 01:58:38 +02:00
|
|
|
if (This->sink.pin.pConnectedTo)
|
2015-05-28 19:04:34 +02:00
|
|
|
hr = BasePinImpl_EnumMediaTypes(iface, ppEnum);
|
2019-06-13 01:58:38 +02:00
|
|
|
else
|
2015-05-28 19:04:34 +02:00
|
|
|
hr = VFW_E_NOT_CONNECTED;
|
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-05-28 19:04:29 +02:00
|
|
|
static const IPinVtbl SmartTeeFilterCaptureVtbl = {
|
|
|
|
BaseOutputPinImpl_QueryInterface,
|
2019-06-19 03:17:37 +02:00
|
|
|
BasePinImpl_AddRef,
|
|
|
|
BasePinImpl_Release,
|
2015-05-28 19:04:29 +02:00
|
|
|
BaseOutputPinImpl_Connect,
|
|
|
|
BaseOutputPinImpl_ReceiveConnection,
|
|
|
|
BaseOutputPinImpl_Disconnect,
|
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
|
|
|
BasePinImpl_QueryAccept,
|
2015-05-28 19:04:34 +02:00
|
|
|
SmartTeeFilterCapture_EnumMediaTypes,
|
2015-05-28 19:04:29 +02:00
|
|
|
BasePinImpl_QueryInternalConnections,
|
|
|
|
BaseOutputPinImpl_EndOfStream,
|
|
|
|
BaseOutputPinImpl_BeginFlush,
|
|
|
|
BaseOutputPinImpl_EndFlush,
|
|
|
|
BasePinImpl_NewSegment
|
|
|
|
};
|
|
|
|
|
2019-09-24 02:33:24 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterCapture_CheckMediaType(struct strmbase_pin *base, const AM_MEDIA_TYPE *amt)
|
2018-05-04 06:47:13 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", base);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-24 02:33:24 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterCapture_GetMediaType(struct strmbase_pin *base, int iPosition, AM_MEDIA_TYPE *amt)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-09-24 02:33:24 +02:00
|
|
|
SmartTeeFilter *This = impl_from_strmbase_pin(base);
|
2015-05-28 19:04:34 +02:00
|
|
|
TRACE("(%p, %d, %p)\n", This, iPosition, amt);
|
|
|
|
if (iPosition == 0) {
|
2019-06-13 01:58:38 +02:00
|
|
|
CopyMediaType(amt, &This->sink.pin.mtCurrent);
|
2015-05-28 19:04:34 +02:00
|
|
|
return S_OK;
|
|
|
|
} else
|
|
|
|
return S_FALSE;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:25 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterCapture_DecideAllocator(struct strmbase_source *base,
|
|
|
|
IMemInputPin *pPin, IMemAllocator **pAlloc)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-09-24 02:33:24 +02:00
|
|
|
SmartTeeFilter *This = impl_from_strmbase_pin(&base->pin);
|
2015-05-31 20:10:30 +02:00
|
|
|
TRACE("(%p, %p, %p)\n", This, pPin, pAlloc);
|
2019-06-13 01:58:38 +02:00
|
|
|
*pAlloc = This->sink.pAllocator;
|
|
|
|
IMemAllocator_AddRef(This->sink.pAllocator);
|
|
|
|
return IMemInputPin_NotifyAllocator(pPin, This->sink.pAllocator, TRUE);
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:26 +02:00
|
|
|
static const struct strmbase_source_ops capture_ops =
|
|
|
|
{
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2018-05-04 06:47:13 +02:00
|
|
|
SmartTeeFilterCapture_CheckMediaType,
|
2015-05-28 19:04:29 +02:00
|
|
|
SmartTeeFilterCapture_GetMediaType
|
|
|
|
},
|
2019-05-09 17:12:33 +02:00
|
|
|
BaseOutputPinImpl_AttemptConnection,
|
2015-05-31 20:10:30 +02:00
|
|
|
NULL,
|
|
|
|
SmartTeeFilterCapture_DecideAllocator,
|
2015-05-28 19:04:29 +02:00
|
|
|
};
|
|
|
|
|
2015-05-28 19:04:34 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterPreview_EnumMediaTypes(IPin *iface, IEnumMediaTypes **ppEnum)
|
|
|
|
{
|
|
|
|
SmartTeeFilter *This = impl_from_IPin(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppEnum);
|
|
|
|
EnterCriticalSection(&This->filter.csFilter);
|
2019-06-13 01:58:38 +02:00
|
|
|
if (This->sink.pin.pConnectedTo)
|
2015-05-28 19:04:34 +02:00
|
|
|
hr = BasePinImpl_EnumMediaTypes(iface, ppEnum);
|
2019-06-13 01:58:38 +02:00
|
|
|
else
|
2015-05-28 19:04:34 +02:00
|
|
|
hr = VFW_E_NOT_CONNECTED;
|
|
|
|
LeaveCriticalSection(&This->filter.csFilter);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-05-28 19:04:29 +02:00
|
|
|
static const IPinVtbl SmartTeeFilterPreviewVtbl = {
|
|
|
|
BaseOutputPinImpl_QueryInterface,
|
2019-06-19 03:17:37 +02:00
|
|
|
BasePinImpl_AddRef,
|
|
|
|
BasePinImpl_Release,
|
2015-05-28 19:04:29 +02:00
|
|
|
BaseOutputPinImpl_Connect,
|
|
|
|
BaseOutputPinImpl_ReceiveConnection,
|
|
|
|
BaseOutputPinImpl_Disconnect,
|
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
|
|
|
BasePinImpl_QueryAccept,
|
2015-05-28 19:04:34 +02:00
|
|
|
SmartTeeFilterPreview_EnumMediaTypes,
|
2015-05-28 19:04:29 +02:00
|
|
|
BasePinImpl_QueryInternalConnections,
|
|
|
|
BaseOutputPinImpl_EndOfStream,
|
|
|
|
BaseOutputPinImpl_BeginFlush,
|
|
|
|
BaseOutputPinImpl_EndFlush,
|
|
|
|
BasePinImpl_NewSegment
|
|
|
|
};
|
|
|
|
|
2019-09-24 02:33:24 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterPreview_CheckMediaType(struct strmbase_pin *base, const AM_MEDIA_TYPE *amt)
|
2018-05-04 06:47:13 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p) stub\n", base);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-24 02:33:24 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterPreview_GetMediaType(struct strmbase_pin *base, int iPosition, AM_MEDIA_TYPE *amt)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-09-24 02:33:24 +02:00
|
|
|
SmartTeeFilter *This = impl_from_strmbase_pin(base);
|
2015-05-28 19:04:34 +02:00
|
|
|
TRACE("(%p, %d, %p)\n", This, iPosition, amt);
|
|
|
|
if (iPosition == 0) {
|
2019-06-13 01:58:38 +02:00
|
|
|
CopyMediaType(amt, &This->sink.pin.mtCurrent);
|
2015-05-28 19:04:34 +02:00
|
|
|
return S_OK;
|
|
|
|
} else
|
|
|
|
return S_FALSE;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:25 +02:00
|
|
|
static HRESULT WINAPI SmartTeeFilterPreview_DecideAllocator(struct strmbase_source *base,
|
|
|
|
IMemInputPin *pPin, IMemAllocator **pAlloc)
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2019-09-24 02:33:24 +02:00
|
|
|
SmartTeeFilter *This = impl_from_strmbase_pin(&base->pin);
|
2015-05-31 20:10:30 +02:00
|
|
|
TRACE("(%p, %p, %p)\n", This, pPin, pAlloc);
|
2019-06-13 01:58:38 +02:00
|
|
|
*pAlloc = This->sink.pAllocator;
|
|
|
|
IMemAllocator_AddRef(This->sink.pAllocator);
|
|
|
|
return IMemInputPin_NotifyAllocator(pPin, This->sink.pAllocator, TRUE);
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:26 +02:00
|
|
|
static const struct strmbase_source_ops preview_ops =
|
|
|
|
{
|
2015-05-28 19:04:29 +02:00
|
|
|
{
|
2018-05-04 06:47:13 +02:00
|
|
|
SmartTeeFilterPreview_CheckMediaType,
|
2015-05-28 19:04:29 +02:00
|
|
|
SmartTeeFilterPreview_GetMediaType
|
|
|
|
},
|
2019-05-09 17:12:33 +02:00
|
|
|
BaseOutputPinImpl_AttemptConnection,
|
2015-05-31 20:10:30 +02:00
|
|
|
NULL,
|
|
|
|
SmartTeeFilterPreview_DecideAllocator,
|
2015-05-28 19:04:29 +02:00
|
|
|
};
|
|
|
|
IUnknown* WINAPI QCAP_createSmartTeeFilter(IUnknown *outer, HRESULT *phr)
|
|
|
|
{
|
2019-09-06 02:02:15 +02:00
|
|
|
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;
|
2015-05-28 19:04:29 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-09-06 02:02:15 +02:00
|
|
|
if (!(object = CoTaskMemAlloc(sizeof(*object))))
|
|
|
|
{
|
2019-05-23 04:44:51 +02:00
|
|
|
*phr = E_OUTOFMEMORY;
|
|
|
|
return NULL;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|
2019-09-06 02:02:15 +02:00
|
|
|
memset(object, 0, sizeof(*object));
|
2015-05-28 19:04:29 +02:00
|
|
|
|
2019-09-06 02:02:15 +02:00
|
|
|
strmbase_filter_init(&object->filter, &SmartTeeFilterVtbl, outer, &CLSID_SmartTee, &filter_ops);
|
|
|
|
strmbase_sink_init(&object->sink, &SmartTeeFilterInputVtbl, &object->filter,
|
|
|
|
inputW, &SmartTeeFilterInputFuncs, NULL);
|
2015-05-31 20:10:30 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER,
|
2019-09-06 02:02:15 +02:00
|
|
|
&IID_IMemAllocator, (void **)&object->sink.pAllocator);
|
2015-05-31 20:10:30 +02:00
|
|
|
if (FAILED(hr))
|
2019-06-14 01:09:23 +02:00
|
|
|
{
|
|
|
|
*phr = hr;
|
2019-09-06 02:02:15 +02:00
|
|
|
strmbase_filter_cleanup(&object->filter);
|
2019-06-14 01:09:23 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2015-05-28 19:04:29 +02:00
|
|
|
|
2019-09-06 02:02:15 +02:00
|
|
|
strmbase_source_init(&object->capture, &SmartTeeFilterCaptureVtbl,
|
2019-09-12 21:28:26 +02:00
|
|
|
&object->filter, captureW, &capture_ops);
|
2019-09-06 02:02:15 +02:00
|
|
|
strmbase_source_init(&object->preview, &SmartTeeFilterPreviewVtbl,
|
2019-09-12 21:28:26 +02:00
|
|
|
&object->filter, previewW, &preview_ops);
|
2015-05-28 19:04:29 +02:00
|
|
|
|
2019-06-14 01:09:23 +02:00
|
|
|
*phr = S_OK;
|
2019-09-06 02:02:15 +02:00
|
|
|
return &object->filter.IUnknown_inner;
|
2015-05-28 19:04:29 +02:00
|
|
|
}
|