2005-05-27 21:22:39 +02:00
|
|
|
/* Video For Windows Steering structure
|
|
|
|
*
|
|
|
|
* Copyright 2005 Maarten Lankhorst
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-05-27 21:22:39 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-06-29 17:26:15 +02:00
|
|
|
#include "qcap_private.h"
|
2005-05-27 21:22:39 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(qcap);
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
static const struct video_capture_funcs *capture_funcs;
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2019-08-29 03:24:30 +02:00
|
|
|
struct strmbase_filter filter;
|
2010-12-21 11:31:10 +01:00
|
|
|
IAMStreamConfig IAMStreamConfig_iface;
|
2020-05-13 18:27:51 +02:00
|
|
|
IAMVideoControl IAMVideoControl_iface;
|
2010-12-21 11:31:10 +01:00
|
|
|
IAMVideoProcAmp IAMVideoProcAmp_iface;
|
2020-05-13 18:27:50 +02:00
|
|
|
IAMFilterMiscFlags IAMFilterMiscFlags_iface;
|
2010-12-21 11:31:10 +01:00
|
|
|
IPersistPropertyBag IPersistPropertyBag_iface;
|
2005-05-27 21:22:39 +02:00
|
|
|
BOOL init;
|
2020-06-29 17:26:16 +02:00
|
|
|
|
2019-09-12 21:28:25 +02:00
|
|
|
struct strmbase_source source;
|
2019-06-26 03:38:11 +02:00
|
|
|
IKsPropertySet IKsPropertySet_iface;
|
2020-11-25 03:11:16 +01:00
|
|
|
|
|
|
|
struct video_capture_device *device;
|
|
|
|
|
|
|
|
/* FIXME: It would be nice to avoid duplicating this variable with strmbase.
|
|
|
|
* However, synchronization is tricky; we need access to be protected by a
|
|
|
|
* separate lock. */
|
|
|
|
FILTER_STATE state;
|
|
|
|
CONDITION_VARIABLE state_cv;
|
|
|
|
CRITICAL_SECTION state_cs;
|
|
|
|
|
|
|
|
HANDLE thread;
|
2020-11-24 07:18:03 +01:00
|
|
|
};
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static inline struct vfw_capture *impl_from_strmbase_filter(struct strmbase_filter *iface)
|
2015-06-26 05:52:26 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct vfw_capture, filter);
|
2015-06-26 05:52:26 +02:00
|
|
|
}
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static inline struct vfw_capture *impl_from_IAMStreamConfig(IAMStreamConfig *iface)
|
2010-12-21 11:31:10 +01:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct vfw_capture, IAMStreamConfig_iface);
|
2010-12-21 11:31:10 +01:00
|
|
|
}
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static inline struct vfw_capture *impl_from_IAMVideoControl(IAMVideoControl *iface)
|
2020-05-13 18:27:51 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct vfw_capture, IAMVideoControl_iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
}
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static inline struct vfw_capture *impl_from_IAMVideoProcAmp(IAMVideoProcAmp *iface)
|
2010-12-21 11:31:10 +01:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct vfw_capture, IAMVideoProcAmp_iface);
|
2010-12-21 11:31:10 +01:00
|
|
|
}
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static inline struct vfw_capture *impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags *iface)
|
2020-05-13 18:27:50 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct vfw_capture, IAMFilterMiscFlags_iface);
|
2020-05-13 18:27:50 +02:00
|
|
|
}
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static inline struct vfw_capture *impl_from_IPersistPropertyBag(IPersistPropertyBag *iface)
|
2010-12-21 11:31:10 +01:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct vfw_capture, IPersistPropertyBag_iface);
|
2010-12-21 11:31:10 +01:00
|
|
|
}
|
|
|
|
|
2019-11-23 04:13:59 +01:00
|
|
|
static struct strmbase_pin *vfw_capture_get_pin(struct strmbase_filter *iface, unsigned int index)
|
2015-07-28 11:03:23 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_filter(iface);
|
2015-07-28 11:03:23 +02:00
|
|
|
|
2019-06-05 00:54:24 +02:00
|
|
|
if (index >= 1)
|
|
|
|
return NULL;
|
2015-07-28 11:03:23 +02:00
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
return &filter->source.pin;
|
2015-07-28 11:03:23 +02:00
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static void vfw_capture_destroy(struct strmbase_filter *iface)
|
2015-07-28 11:03:23 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_filter(iface);
|
2015-07-28 11:03:23 +02:00
|
|
|
|
2019-06-05 00:54:24 +02:00
|
|
|
if (filter->init)
|
2015-07-28 11:03:23 +02:00
|
|
|
{
|
2019-06-05 00:54:24 +02:00
|
|
|
if (filter->filter.state != State_Stopped)
|
2020-11-25 03:11:15 +01:00
|
|
|
capture_funcs->cleanup_stream(filter->device);
|
|
|
|
capture_funcs->destroy(filter->device);
|
2015-07-28 11:03:23 +02:00
|
|
|
}
|
2019-06-26 03:38:11 +02:00
|
|
|
|
2019-09-27 04:40:53 +02:00
|
|
|
if (filter->source.pin.peer)
|
2019-06-05 00:54:24 +02:00
|
|
|
{
|
2019-09-27 04:40:53 +02:00
|
|
|
IPin_Disconnect(filter->source.pin.peer);
|
2019-06-26 03:38:11 +02:00
|
|
|
IPin_Disconnect(&filter->source.pin.IPin_iface);
|
2019-06-05 00:54:24 +02:00
|
|
|
}
|
2020-11-25 03:11:16 +01:00
|
|
|
filter->state_cs.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&filter->state_cs);
|
2019-06-26 03:38:11 +02:00
|
|
|
strmbase_source_cleanup(&filter->source);
|
2019-06-05 00:54:24 +02:00
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
|
|
|
CoTaskMemFree(filter);
|
|
|
|
ObjectRefCount(FALSE);
|
2015-07-28 11:03:23 +02:00
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static HRESULT vfw_capture_query_interface(struct strmbase_filter *iface, REFIID iid, void **out)
|
2010-10-07 21:48:01 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_filter(iface);
|
2010-10-07 21:48:01 +02:00
|
|
|
|
2019-06-05 00:54:24 +02:00
|
|
|
if (IsEqualGUID(iid, &IID_IPersistPropertyBag))
|
|
|
|
*out = &filter->IPersistPropertyBag_iface;
|
2020-05-13 18:27:51 +02:00
|
|
|
else if (IsEqualGUID(iid, &IID_IAMVideoControl))
|
|
|
|
*out = &filter->IAMVideoControl_iface;
|
2019-06-05 00:54:24 +02:00
|
|
|
else if (IsEqualGUID(iid, &IID_IAMVideoProcAmp))
|
|
|
|
*out = &filter->IAMVideoProcAmp_iface;
|
2020-05-13 18:27:50 +02:00
|
|
|
else if (IsEqualGUID(iid, &IID_IAMFilterMiscFlags))
|
|
|
|
*out = &filter->IAMFilterMiscFlags_iface;
|
2019-06-05 00:54:24 +02:00
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
2010-10-07 21:48:01 +02:00
|
|
|
|
2019-06-05 00:54:24 +02:00
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
2010-10-07 21:48:01 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 03:11:16 +01:00
|
|
|
static DWORD WINAPI stream_thread(void *arg)
|
|
|
|
{
|
|
|
|
struct vfw_capture *filter = arg;
|
|
|
|
const VIDEOINFOHEADER *format = (const VIDEOINFOHEADER *)filter->source.pin.mt.pbFormat;
|
|
|
|
const unsigned int image_size = format->bmiHeader.biWidth
|
|
|
|
* format->bmiHeader.biHeight * format->bmiHeader.biBitCount / 8;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
IMediaSample *sample;
|
|
|
|
HRESULT hr;
|
|
|
|
BYTE *data;
|
|
|
|
|
|
|
|
EnterCriticalSection(&filter->state_cs);
|
|
|
|
|
|
|
|
while (filter->state == State_Paused)
|
|
|
|
SleepConditionVariableCS(&filter->state_cv, &filter->state_cs, INFINITE);
|
|
|
|
|
|
|
|
if (filter->state == State_Stopped)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&filter->state_cs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&filter->state_cs);
|
|
|
|
|
|
|
|
if (FAILED(hr = BaseOutputPinImpl_GetDeliveryBuffer(&filter->source, &sample, NULL, NULL, 0)))
|
|
|
|
{
|
|
|
|
ERR("Failed to get sample, hr %#x.\n", hr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMediaSample_SetActualDataLength(sample, image_size);
|
|
|
|
IMediaSample_GetPointer(sample, &data);
|
|
|
|
|
|
|
|
if (!capture_funcs->read_frame(filter->device, data))
|
|
|
|
{
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMemInputPin_Receive(filter->source.pMemInputPin, sample);
|
|
|
|
IMediaSample_Release(sample);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("IMemInputPin::Receive() returned %#x.\n", hr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-05 06:03:30 +01:00
|
|
|
static HRESULT vfw_capture_init_stream(struct strmbase_filter *iface)
|
2019-08-29 03:24:29 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_filter(iface);
|
2010-10-13 18:02:01 +02:00
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
capture_funcs->init_stream(filter->device);
|
2020-11-25 03:11:16 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&filter->state_cs);
|
|
|
|
filter->state = State_Paused;
|
|
|
|
LeaveCriticalSection(&filter->state_cs);
|
|
|
|
|
|
|
|
filter->thread = CreateThread(NULL, 0, stream_thread, filter, 0, NULL);
|
|
|
|
|
2020-07-22 00:49:58 +02:00
|
|
|
return S_OK;
|
2019-12-05 06:03:30 +01:00
|
|
|
}
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2019-12-05 06:03:30 +01:00
|
|
|
static HRESULT vfw_capture_start_stream(struct strmbase_filter *iface, REFERENCE_TIME time)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_filter(iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-11-25 03:11:16 +01:00
|
|
|
EnterCriticalSection(&filter->state_cs);
|
|
|
|
filter->state = State_Running;
|
|
|
|
LeaveCriticalSection(&filter->state_cs);
|
|
|
|
WakeConditionVariable(&filter->state_cv);
|
2019-12-05 06:03:30 +01:00
|
|
|
return S_OK;
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 06:03:30 +01:00
|
|
|
static HRESULT vfw_capture_stop_stream(struct strmbase_filter *iface)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_filter(iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-11-25 03:11:16 +01:00
|
|
|
EnterCriticalSection(&filter->state_cs);
|
|
|
|
filter->state = State_Paused;
|
|
|
|
LeaveCriticalSection(&filter->state_cs);
|
2020-07-22 00:49:58 +02:00
|
|
|
return S_OK;
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 06:03:30 +01:00
|
|
|
static HRESULT vfw_capture_cleanup_stream(struct strmbase_filter *iface)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_filter(iface);
|
2019-12-05 06:03:30 +01:00
|
|
|
|
2020-11-25 03:11:16 +01:00
|
|
|
EnterCriticalSection(&filter->state_cs);
|
|
|
|
filter->state = State_Stopped;
|
|
|
|
LeaveCriticalSection(&filter->state_cs);
|
|
|
|
WakeConditionVariable(&filter->state_cv);
|
|
|
|
|
|
|
|
WaitForSingleObject(filter->thread, INFINITE);
|
|
|
|
CloseHandle(filter->thread);
|
|
|
|
filter->thread = NULL;
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
capture_funcs->cleanup_stream(filter->device);
|
2019-12-05 06:03:30 +01:00
|
|
|
return S_OK;
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2020-07-22 00:49:58 +02:00
|
|
|
static HRESULT vfw_capture_wait_state(struct strmbase_filter *iface, DWORD timeout)
|
|
|
|
{
|
|
|
|
return iface->state == State_Paused ? VFW_S_CANT_CUE : S_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-05 06:03:30 +01:00
|
|
|
static const struct strmbase_filter_ops filter_ops =
|
|
|
|
{
|
|
|
|
.filter_get_pin = vfw_capture_get_pin,
|
|
|
|
.filter_destroy = vfw_capture_destroy,
|
|
|
|
.filter_query_interface = vfw_capture_query_interface,
|
|
|
|
.filter_init_stream = vfw_capture_init_stream,
|
|
|
|
.filter_start_stream = vfw_capture_start_stream,
|
|
|
|
.filter_stop_stream = vfw_capture_stop_stream,
|
|
|
|
.filter_cleanup_stream = vfw_capture_cleanup_stream,
|
2020-07-22 00:49:58 +02:00
|
|
|
.filter_wait_state = vfw_capture_wait_state,
|
2019-12-05 06:03:30 +01:00
|
|
|
};
|
|
|
|
|
2019-06-26 03:38:12 +02:00
|
|
|
static HRESULT WINAPI AMStreamConfig_QueryInterface(IAMStreamConfig *iface, REFIID iid, void **out)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMStreamConfig(iface);
|
2019-06-26 03:38:12 +02:00
|
|
|
return IPin_QueryInterface(&filter->source.pin.IPin_iface, iid, out);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 03:38:12 +02:00
|
|
|
static ULONG WINAPI AMStreamConfig_AddRef(IAMStreamConfig *iface)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMStreamConfig(iface);
|
2019-06-26 03:38:12 +02:00
|
|
|
return IPin_AddRef(&filter->source.pin.IPin_iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2019-06-26 03:38:12 +02:00
|
|
|
static ULONG WINAPI AMStreamConfig_Release(IAMStreamConfig *iface)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMStreamConfig(iface);
|
2019-06-26 03:38:12 +02:00
|
|
|
return IPin_Release(&filter->source.pin.IPin_iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
AMStreamConfig_SetFormat(IAMStreamConfig *iface, AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *This = impl_from_IAMStreamConfig(iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-10-06 02:18:52 +02:00
|
|
|
TRACE("filter %p, mt %p.\n", This, pmt);
|
|
|
|
strmbase_dump_media_type(pmt);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
if (This->filter.state != State_Stopped)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
|
|
|
TRACE("Returning not stopped error\n");
|
|
|
|
return VFW_E_NOT_STOPPED;
|
|
|
|
}
|
|
|
|
|
2008-09-16 22:54:20 +02:00
|
|
|
if (!pmt)
|
|
|
|
{
|
|
|
|
TRACE("pmt is NULL\n");
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
|
2020-04-28 18:55:17 +02:00
|
|
|
if (!IsEqualGUID(&pmt->majortype, &MEDIATYPE_Video))
|
|
|
|
return E_FAIL;
|
|
|
|
|
2019-09-27 04:40:53 +02:00
|
|
|
if (This->source.pin.peer)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2019-09-27 04:40:53 +02:00
|
|
|
hr = IPin_QueryAccept(This->source.pin.peer, pmt);
|
2006-10-08 19:36:31 +02:00
|
|
|
TRACE("Would accept: %d\n", hr);
|
2005-05-27 21:22:39 +02:00
|
|
|
if (hr == S_FALSE)
|
|
|
|
return VFW_E_INVALIDMEDIATYPE;
|
|
|
|
}
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
hr = capture_funcs->set_format(This->device, pmt);
|
2020-01-31 02:05:18 +01:00
|
|
|
if (SUCCEEDED(hr) && This->filter.graph && This->source.pin.peer)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-01-31 02:05:18 +01:00
|
|
|
hr = IFilterGraph_Reconnect(This->filter.graph, &This->source.pin.IPin_iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
TRACE("Reconnection completed, with new media format..\n");
|
|
|
|
}
|
2006-10-08 19:36:31 +02:00
|
|
|
TRACE("Returning: %d\n", hr);
|
2005-05-27 21:22:39 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2020-06-29 17:26:17 +02:00
|
|
|
static HRESULT WINAPI AMStreamConfig_GetFormat(IAMStreamConfig *iface, AM_MEDIA_TYPE **mt)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMStreamConfig(iface);
|
2019-10-06 02:18:52 +02:00
|
|
|
HRESULT hr;
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-06-29 17:26:17 +02:00
|
|
|
TRACE("filter %p, mt %p.\n", filter, mt);
|
2020-06-29 17:26:16 +02:00
|
|
|
|
2020-06-29 17:26:17 +02:00
|
|
|
if (!(*mt = CoTaskMemAlloc(sizeof(**mt))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
if (SUCCEEDED(hr = capture_funcs->get_format(filter->device, *mt)))
|
2020-06-29 17:26:17 +02:00
|
|
|
strmbase_dump_media_type(*mt);
|
2019-10-06 02:18:52 +02:00
|
|
|
return hr;
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2020-04-28 18:55:19 +02:00
|
|
|
static HRESULT WINAPI AMStreamConfig_GetNumberOfCapabilities(IAMStreamConfig *iface,
|
|
|
|
int *count, int *size)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMStreamConfig(iface);
|
2020-04-28 18:55:19 +02:00
|
|
|
|
|
|
|
TRACE("filter %p, count %p, size %p.\n", filter, count, size);
|
|
|
|
|
|
|
|
if (!count || !size)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
*count = capture_funcs->get_caps_count(filter->device);
|
2020-04-28 18:55:19 +02:00
|
|
|
*size = sizeof(VIDEO_STREAM_CONFIG_CAPS);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2020-04-28 18:55:20 +02:00
|
|
|
static HRESULT WINAPI AMStreamConfig_GetStreamCaps(IAMStreamConfig *iface,
|
|
|
|
int index, AM_MEDIA_TYPE **pmt, BYTE *vscc)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMStreamConfig(iface);
|
2020-04-28 18:55:20 +02:00
|
|
|
|
|
|
|
TRACE("filter %p, index %d, pmt %p, vscc %p.\n", filter, index, pmt, vscc);
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
return capture_funcs->get_caps(filter->device, index, pmt, (VIDEO_STREAM_CONFIG_CAPS *)vscc);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IAMStreamConfigVtbl IAMStreamConfig_VTable =
|
|
|
|
{
|
|
|
|
AMStreamConfig_QueryInterface,
|
|
|
|
AMStreamConfig_AddRef,
|
|
|
|
AMStreamConfig_Release,
|
|
|
|
AMStreamConfig_SetFormat,
|
|
|
|
AMStreamConfig_GetFormat,
|
|
|
|
AMStreamConfig_GetNumberOfCapabilities,
|
|
|
|
AMStreamConfig_GetStreamCaps
|
|
|
|
};
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static HRESULT WINAPI AMVideoProcAmp_QueryInterface(IAMVideoProcAmp *iface, REFIID iid, void **out)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoProcAmp(iface);
|
|
|
|
return IUnknown_QueryInterface(filter->filter.outer_unk, iid, out);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AMVideoProcAmp_AddRef(IAMVideoProcAmp * iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoProcAmp(iface);
|
|
|
|
return IUnknown_AddRef(filter->filter.outer_unk);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AMVideoProcAmp_Release(IAMVideoProcAmp * iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoProcAmp(iface);
|
|
|
|
return IUnknown_Release(filter->filter.outer_unk);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2020-06-29 17:26:16 +02:00
|
|
|
static HRESULT WINAPI AMVideoProcAmp_GetRange(IAMVideoProcAmp *iface, LONG property,
|
|
|
|
LONG *min, LONG *max, LONG *step, LONG *default_value, LONG *flags)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoProcAmp(iface);
|
2020-06-29 17:26:16 +02:00
|
|
|
|
|
|
|
TRACE("filter %p, property %#x, min %p, max %p, step %p, default_value %p, flags %p.\n",
|
|
|
|
filter, property, min, max, step, default_value, flags);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
return capture_funcs->get_prop_range(filter->device, property, min,
|
2020-06-29 17:26:16 +02:00
|
|
|
max, step, default_value, flags);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2020-06-29 17:26:16 +02:00
|
|
|
static HRESULT WINAPI AMVideoProcAmp_Set(IAMVideoProcAmp *iface, LONG property,
|
|
|
|
LONG value, LONG flags)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoProcAmp(iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-06-29 17:26:16 +02:00
|
|
|
TRACE("filter %p, property %#x, value %d, flags %#x.\n", filter, property, value, flags);
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
return capture_funcs->set_prop(filter->device, property, value, flags);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
2020-06-29 17:26:16 +02:00
|
|
|
static HRESULT WINAPI AMVideoProcAmp_Get(IAMVideoProcAmp *iface, LONG property,
|
|
|
|
LONG *value, LONG *flags)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoProcAmp(iface);
|
2020-06-29 17:26:16 +02:00
|
|
|
|
|
|
|
TRACE("filter %p, property %#x, value %p, flags %p.\n", filter, property, value, flags);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
return capture_funcs->get_prop(filter->device, property, value, flags);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IAMVideoProcAmpVtbl IAMVideoProcAmp_VTable =
|
|
|
|
{
|
|
|
|
AMVideoProcAmp_QueryInterface,
|
|
|
|
AMVideoProcAmp_AddRef,
|
|
|
|
AMVideoProcAmp_Release,
|
|
|
|
AMVideoProcAmp_GetRange,
|
|
|
|
AMVideoProcAmp_Set,
|
|
|
|
AMVideoProcAmp_Get,
|
|
|
|
};
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static HRESULT WINAPI PPB_QueryInterface(IPersistPropertyBag *iface, REFIID iid, void **out)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IPersistPropertyBag(iface);
|
|
|
|
return IUnknown_QueryInterface(filter->filter.outer_unk, iid, out);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PPB_AddRef(IPersistPropertyBag * iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IPersistPropertyBag(iface);
|
|
|
|
return IUnknown_AddRef(filter->filter.outer_unk);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI PPB_Release(IPersistPropertyBag * iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IPersistPropertyBag(iface);
|
|
|
|
return IUnknown_Release(filter->filter.outer_unk);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
PPB_GetClassID( IPersistPropertyBag * iface, CLSID * pClassID )
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *This = impl_from_IPersistPropertyBag(iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
|
|
|
FIXME("%p - stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PPB_InitNew(IPersistPropertyBag * iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *This = impl_from_IPersistPropertyBag(iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
|
|
|
FIXME("%p - stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
static HRESULT WINAPI PPB_Load(IPersistPropertyBag *iface, IPropertyBag *bag, IErrorLog *error_log)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2018-12-04 05:42:58 +01:00
|
|
|
static const OLECHAR VFWIndex[] = {'V','F','W','I','n','d','e','x',0};
|
2020-11-25 03:11:15 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IPersistPropertyBag(iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
HRESULT hr;
|
|
|
|
VARIANT var;
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
TRACE("filter %p, bag %p, error_log %p.\n", filter, bag, error_log);
|
2005-05-27 21:22:39 +02:00
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
2020-11-25 03:11:15 +01:00
|
|
|
if (FAILED(hr = IPropertyBag_Read(bag, VFWIndex, &var, error_log)))
|
|
|
|
return hr;
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
if (!(filter->device = capture_funcs->create(&filter->source, V_I4(&var))))
|
|
|
|
return E_FAIL;
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
filter->init = TRUE;
|
|
|
|
return S_OK;
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
PPB_Save( IPersistPropertyBag * iface, IPropertyBag *pPropBag,
|
|
|
|
BOOL fClearDirty, BOOL fSaveAllProperties )
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *This = impl_from_IPersistPropertyBag(iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
FIXME("%p - stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPersistPropertyBagVtbl IPersistPropertyBag_VTable =
|
|
|
|
{
|
|
|
|
PPB_QueryInterface,
|
|
|
|
PPB_AddRef,
|
|
|
|
PPB_Release,
|
|
|
|
PPB_GetClassID,
|
|
|
|
PPB_InitNew,
|
|
|
|
PPB_Load,
|
|
|
|
PPB_Save
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IKsPropertySet interface */
|
2020-11-24 07:18:03 +01:00
|
|
|
static inline struct vfw_capture *impl_from_IKsPropertySet(IKsPropertySet *iface)
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct vfw_capture, IKsPropertySet_iface);
|
2015-08-03 23:28:41 +02:00
|
|
|
}
|
2005-05-27 21:22:39 +02:00
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static HRESULT WINAPI KSP_QueryInterface(IKsPropertySet *iface, REFIID iid, void **out)
|
2015-08-03 23:28:41 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IKsPropertySet(iface);
|
|
|
|
return IPin_QueryInterface(&filter->source.pin.IPin_iface, iid, out);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI KSP_AddRef(IKsPropertySet * iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IKsPropertySet(iface);
|
2019-06-26 03:38:11 +02:00
|
|
|
return IPin_AddRef(&filter->source.pin.IPin_iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI KSP_Release(IKsPropertySet * iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IKsPropertySet(iface);
|
2019-06-26 03:38:11 +02:00
|
|
|
return IPin_Release(&filter->source.pin.IPin_iface);
|
2005-05-27 21:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
KSP_Set( IKsPropertySet * iface, REFGUID guidPropSet, DWORD dwPropID,
|
|
|
|
LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData,
|
|
|
|
DWORD cbPropData )
|
|
|
|
{
|
|
|
|
FIXME("%p: stub\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
KSP_Get( IKsPropertySet * iface, REFGUID guidPropSet, DWORD dwPropID,
|
|
|
|
LPVOID pInstanceData, DWORD cbInstanceData, LPVOID pPropData,
|
|
|
|
DWORD cbPropData, DWORD *pcbReturned )
|
|
|
|
{
|
|
|
|
LPGUID pGuid;
|
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
if (!IsEqualIID(guidPropSet, &ROPSETID_Pin))
|
|
|
|
return E_PROP_SET_UNSUPPORTED;
|
|
|
|
if (pPropData == NULL && pcbReturned == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
if (pcbReturned)
|
|
|
|
*pcbReturned = sizeof(GUID);
|
|
|
|
if (pPropData == NULL)
|
|
|
|
return S_OK;
|
|
|
|
if (cbPropData < sizeof(GUID))
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
pGuid = pPropData;
|
2015-05-31 20:13:35 +02:00
|
|
|
*pGuid = PIN_CATEGORY_CAPTURE;
|
|
|
|
FIXME("() Not adding a pin with PIN_CATEGORY_PREVIEW\n");
|
2005-05-27 21:22:39 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
KSP_QuerySupported( IKsPropertySet * iface, REFGUID guidPropSet,
|
|
|
|
DWORD dwPropID, DWORD *pTypeSupport )
|
|
|
|
{
|
|
|
|
FIXME("%p: stub\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2015-08-03 23:28:41 +02:00
|
|
|
static const IKsPropertySetVtbl IKsPropertySet_VTable =
|
2005-05-27 21:22:39 +02:00
|
|
|
{
|
|
|
|
KSP_QueryInterface,
|
|
|
|
KSP_AddRef,
|
|
|
|
KSP_Release,
|
|
|
|
KSP_Set,
|
|
|
|
KSP_Get,
|
|
|
|
KSP_QuerySupported
|
|
|
|
};
|
|
|
|
|
2020-11-24 07:18:03 +01:00
|
|
|
static inline struct vfw_capture *impl_from_strmbase_pin(struct strmbase_pin *pin)
|
2010-10-05 21:37:30 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
return CONTAINING_RECORD(pin, struct vfw_capture, source.pin);
|
2015-08-03 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2019-09-25 02:10:10 +02:00
|
|
|
static HRESULT source_query_accept(struct strmbase_pin *pin, const AM_MEDIA_TYPE *mt)
|
2018-05-04 06:47:13 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_pin(pin);
|
2020-11-25 03:11:15 +01:00
|
|
|
return capture_funcs->check_format(filter->device, mt);
|
2018-05-04 06:47:13 +02:00
|
|
|
}
|
|
|
|
|
2019-09-25 02:10:12 +02:00
|
|
|
static HRESULT source_get_media_type(struct strmbase_pin *pin,
|
2020-09-08 18:15:10 +02:00
|
|
|
unsigned int index, AM_MEDIA_TYPE *mt)
|
2015-08-03 23:24:18 +02:00
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_pin(pin);
|
2020-11-25 03:11:15 +01:00
|
|
|
return capture_funcs->get_media_type(filter->device, index, mt);
|
2010-10-05 21:37:30 +02:00
|
|
|
}
|
|
|
|
|
2019-09-26 05:36:25 +02:00
|
|
|
static HRESULT source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_strmbase_pin(iface);
|
2019-09-26 05:36:25 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IKsPropertySet))
|
|
|
|
*out = &filter->IKsPropertySet_iface;
|
|
|
|
else if (IsEqualGUID(iid, &IID_IAMStreamConfig))
|
|
|
|
*out = &filter->IAMStreamConfig_iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:25 +02:00
|
|
|
static HRESULT WINAPI VfwPin_DecideBufferSize(struct strmbase_source *iface,
|
|
|
|
IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
|
2010-10-13 17:46:27 +02:00
|
|
|
{
|
|
|
|
ALLOCATOR_PROPERTIES actual;
|
|
|
|
|
|
|
|
/* What we put here doesn't matter, the
|
|
|
|
driver function should override it then commit */
|
|
|
|
if (!ppropInputRequest->cBuffers)
|
|
|
|
ppropInputRequest->cBuffers = 3;
|
|
|
|
if (!ppropInputRequest->cbBuffer)
|
|
|
|
ppropInputRequest->cbBuffer = 230400;
|
|
|
|
if (!ppropInputRequest->cbAlign)
|
|
|
|
ppropInputRequest->cbAlign = 1;
|
|
|
|
|
|
|
|
return IMemAllocator_SetProperties(pAlloc, ppropInputRequest, &actual);
|
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:26 +02:00
|
|
|
static const struct strmbase_source_ops source_ops =
|
|
|
|
{
|
2019-09-25 02:10:10 +02:00
|
|
|
.base.pin_query_accept = source_query_accept,
|
2019-09-25 02:10:11 +02:00
|
|
|
.base.pin_get_media_type = source_get_media_type,
|
2019-09-26 05:36:25 +02:00
|
|
|
.base.pin_query_interface = source_query_interface,
|
2019-09-25 02:10:10 +02:00
|
|
|
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
|
|
|
|
.pfnDecideBufferSize = VfwPin_DecideBufferSize,
|
|
|
|
.pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator,
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
2020-05-13 18:27:50 +02:00
|
|
|
static HRESULT WINAPI misc_flags_QueryInterface(IAMFilterMiscFlags *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMFilterMiscFlags(iface);
|
2020-05-13 18:27:50 +02:00
|
|
|
return IUnknown_QueryInterface(filter->filter.outer_unk, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI misc_flags_AddRef(IAMFilterMiscFlags *iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMFilterMiscFlags(iface);
|
2020-05-13 18:27:50 +02:00
|
|
|
return IUnknown_AddRef(filter->filter.outer_unk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI misc_flags_Release(IAMFilterMiscFlags *iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMFilterMiscFlags(iface);
|
2020-05-13 18:27:50 +02:00
|
|
|
return IUnknown_Release(filter->filter.outer_unk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI misc_flags_GetMiscFlags(IAMFilterMiscFlags *iface)
|
|
|
|
{
|
|
|
|
return AM_FILTER_MISC_FLAGS_IS_SOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_VTable =
|
|
|
|
{
|
|
|
|
misc_flags_QueryInterface,
|
|
|
|
misc_flags_AddRef,
|
|
|
|
misc_flags_Release,
|
|
|
|
misc_flags_GetMiscFlags
|
|
|
|
};
|
|
|
|
|
2020-05-13 18:27:51 +02:00
|
|
|
static HRESULT WINAPI video_control_QueryInterface(IAMVideoControl *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
return IUnknown_QueryInterface(filter->filter.outer_unk, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI video_control_AddRef(IAMVideoControl *iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
return IUnknown_AddRef(filter->filter.outer_unk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI video_control_Release(IAMVideoControl *iface)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
return IUnknown_Release(filter->filter.outer_unk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI video_control_GetCaps(IAMVideoControl *iface, IPin *pin, LONG *flags)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
|
|
|
|
FIXME("filter %p, pin %p, flags %p: stub.\n", filter, pin, flags);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI video_control_SetMode(IAMVideoControl *iface, IPin *pin, LONG mode)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
|
|
|
|
FIXME("filter %p, pin %p, mode %d: stub.\n", filter, pin, mode);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI video_control_GetMode(IAMVideoControl *iface, IPin *pin, LONG *mode)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
|
|
|
|
FIXME("filter %p, pin %p, mode %p: stub.\n", filter, pin, mode);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI video_control_GetCurrentActualFrameRate(IAMVideoControl *iface, IPin *pin,
|
|
|
|
LONGLONG *frame_rate)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
|
|
|
|
FIXME("filter %p, pin %p, frame rate %p: stub.\n", filter, pin, frame_rate);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI video_control_GetMaxAvailableFrameRate(IAMVideoControl *iface, IPin *pin,
|
|
|
|
LONG index, SIZE dimensions, LONGLONG *frame_rate)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
|
|
|
|
FIXME("filter %p, pin %p, index %d, dimensions (%dx%d), frame rate %p: stub.\n",
|
|
|
|
filter, pin, index, dimensions.cx, dimensions.cy, frame_rate);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI video_control_GetFrameRateList(IAMVideoControl *iface, IPin *pin, LONG index,
|
|
|
|
SIZE dimensions, LONG *list_size, LONGLONG **frame_rate)
|
|
|
|
{
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *filter = impl_from_IAMVideoControl(iface);
|
2020-05-13 18:27:51 +02:00
|
|
|
|
|
|
|
FIXME("filter %p, pin %p, index %d, dimensions (%dx%d), list size %p, frame rate: %p: stub.\n",
|
|
|
|
filter, pin, index, dimensions.cx, dimensions.cy, list_size, frame_rate);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IAMVideoControlVtbl IAMVideoControl_VTable =
|
|
|
|
{
|
|
|
|
video_control_QueryInterface,
|
|
|
|
video_control_AddRef,
|
|
|
|
video_control_Release,
|
|
|
|
video_control_GetCaps,
|
|
|
|
video_control_SetMode,
|
|
|
|
video_control_GetMode,
|
|
|
|
video_control_GetCurrentActualFrameRate,
|
|
|
|
video_control_GetMaxAvailableFrameRate,
|
|
|
|
video_control_GetFrameRateList
|
|
|
|
};
|
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
static BOOL WINAPI load_capture_funcs(INIT_ONCE *once, void *param, void **context)
|
|
|
|
{
|
|
|
|
capture_funcs = &v4l_funcs;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
|
|
|
|
|
2020-03-08 20:05:08 +01:00
|
|
|
HRESULT vfw_capture_create(IUnknown *outer, IUnknown **out)
|
2019-06-26 03:38:11 +02:00
|
|
|
{
|
|
|
|
static const WCHAR source_name[] = {'O','u','t','p','u','t',0};
|
2020-11-24 07:18:03 +01:00
|
|
|
struct vfw_capture *object;
|
2019-06-26 03:38:11 +02:00
|
|
|
|
2020-11-25 03:11:15 +01:00
|
|
|
if (!InitOnceExecuteOnce(&init_once, load_capture_funcs, NULL, NULL))
|
|
|
|
return E_FAIL;
|
|
|
|
|
2019-06-26 03:38:11 +02:00
|
|
|
if (!(object = CoTaskMemAlloc(sizeof(*object))))
|
2020-03-08 20:05:08 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2019-06-26 03:38:11 +02:00
|
|
|
|
2019-12-05 06:03:31 +01:00
|
|
|
strmbase_filter_init(&object->filter, outer, &CLSID_VfwCapture, &filter_ops);
|
2019-06-26 03:38:11 +02:00
|
|
|
|
|
|
|
object->IAMStreamConfig_iface.lpVtbl = &IAMStreamConfig_VTable;
|
2020-05-13 18:27:51 +02:00
|
|
|
object->IAMVideoControl_iface.lpVtbl = &IAMVideoControl_VTable;
|
2019-06-26 03:38:11 +02:00
|
|
|
object->IAMVideoProcAmp_iface.lpVtbl = &IAMVideoProcAmp_VTable;
|
2020-05-13 18:27:50 +02:00
|
|
|
object->IAMFilterMiscFlags_iface.lpVtbl = &IAMFilterMiscFlags_VTable;
|
2019-06-26 03:38:11 +02:00
|
|
|
object->IPersistPropertyBag_iface.lpVtbl = &IPersistPropertyBag_VTable;
|
|
|
|
object->init = FALSE;
|
|
|
|
|
2019-12-08 05:20:38 +01:00
|
|
|
strmbase_source_init(&object->source, &object->filter, source_name, &source_ops);
|
2019-06-26 03:38:11 +02:00
|
|
|
|
|
|
|
object->IKsPropertySet_iface.lpVtbl = &IKsPropertySet_VTable;
|
|
|
|
|
2020-11-25 03:11:16 +01:00
|
|
|
object->state = State_Stopped;
|
|
|
|
InitializeConditionVariable(&object->state_cv);
|
|
|
|
InitializeCriticalSection(&object->state_cs);
|
|
|
|
object->state_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": vfw_capture.state_cs");
|
|
|
|
|
2019-06-26 03:38:11 +02:00
|
|
|
TRACE("Created VFW capture filter %p.\n", object);
|
|
|
|
ObjectRefCount(TRUE);
|
2020-03-08 20:05:08 +01:00
|
|
|
*out = &object->filter.IUnknown_inner;
|
|
|
|
return S_OK;
|
2019-06-26 03:38:11 +02:00
|
|
|
}
|