Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/qasf/dmowrapper.c | 166 +++++++++++ dlls/qasf/tests/Makefile.in | 2 +- dlls/qasf/tests/dmowrapper.c | 518 ++++++++++++++++++++++++++++++++++- 3 files changed, 677 insertions(+), 9 deletions(-)
diff --git a/dlls/qasf/dmowrapper.c b/dlls/qasf/dmowrapper.c index 1f11c9ff7ef..6e703e90d0c 100644 --- a/dlls/qasf/dmowrapper.c +++ b/dlls/qasf/dmowrapper.c @@ -22,12 +22,21 @@
WINE_DEFAULT_DEBUG_CHANNEL(qasf);
+struct dmo_wrapper_source +{ + struct strmbase_source pin; +}; + struct dmo_wrapper { struct strmbase_filter filter; IDMOWrapperFilter IDMOWrapperFilter_iface;
IUnknown *dmo; + + DWORD sink_count, source_count; + struct strmbase_sink *sinks; + struct dmo_wrapper_source *sources; };
static inline struct dmo_wrapper *impl_from_strmbase_filter(struct strmbase_filter *iface) @@ -35,6 +44,106 @@ static inline struct dmo_wrapper *impl_from_strmbase_filter(struct strmbase_filt return CONTAINING_RECORD(iface, struct dmo_wrapper, filter); }
+static inline struct strmbase_sink *impl_sink_from_strmbase_pin(struct strmbase_pin *iface) +{ + return CONTAINING_RECORD(iface, struct strmbase_sink, pin); +} + +static HRESULT dmo_wrapper_sink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out) +{ + struct strmbase_sink *sink = impl_sink_from_strmbase_pin(iface); + + if (IsEqualGUID(iid, &IID_IMemInputPin)) + *out = &sink->IMemInputPin_iface; + else + return E_NOINTERFACE; + + IUnknown_AddRef((IUnknown *)*out); + return S_OK; +} + +static HRESULT dmo_wrapper_sink_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface->filter); + IMediaObject *dmo; + HRESULT hr; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + hr = IMediaObject_SetInputType(dmo, impl_sink_from_strmbase_pin(iface) - filter->sinks, + (const DMO_MEDIA_TYPE *)mt, DMO_SET_TYPEF_TEST_ONLY); + + IMediaObject_Release(dmo); + + return hr; +} + +static HRESULT dmo_wrapper_sink_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface->filter); + IMediaObject *dmo; + HRESULT hr; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + hr = IMediaObject_GetInputType(dmo, impl_sink_from_strmbase_pin(iface) - filter->sinks, + index, (DMO_MEDIA_TYPE *)mt); + + IMediaObject_Release(dmo); + + return hr == S_OK ? S_OK : VFW_S_NO_MORE_ITEMS; +} + +static const struct strmbase_sink_ops sink_ops = +{ + .base.pin_query_interface = dmo_wrapper_sink_query_interface, + .base.pin_query_accept = dmo_wrapper_sink_query_accept, + .base.pin_get_media_type = dmo_wrapper_sink_get_media_type, +}; + +static inline struct dmo_wrapper_source *impl_source_from_strmbase_pin(struct strmbase_pin *iface) +{ + return CONTAINING_RECORD(iface, struct dmo_wrapper_source, pin.pin); +} + +static HRESULT dmo_wrapper_source_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface->filter); + IMediaObject *dmo; + HRESULT hr; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + hr = IMediaObject_SetOutputType(dmo, impl_source_from_strmbase_pin(iface) - filter->sources, + (const DMO_MEDIA_TYPE *)mt, DMO_SET_TYPEF_TEST_ONLY); + + IMediaObject_Release(dmo); + + return hr; +} + +static HRESULT dmo_wrapper_source_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface->filter); + IMediaObject *dmo; + HRESULT hr; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + hr = IMediaObject_GetOutputType(dmo, impl_source_from_strmbase_pin(iface) - filter->sources, + index, (DMO_MEDIA_TYPE *)mt); + + IMediaObject_Release(dmo); + + return hr == S_OK ? S_OK : VFW_S_NO_MORE_ITEMS; +} + +static const struct strmbase_source_ops source_ops = +{ + .base.pin_query_accept = dmo_wrapper_source_query_accept, + .base.pin_get_media_type = dmo_wrapper_source_get_media_type, +}; + static inline struct dmo_wrapper *impl_from_IDMOWrapperFilter(IDMOWrapperFilter *iface) { return CONTAINING_RECORD(iface, struct dmo_wrapper, IDMOWrapperFilter_iface); @@ -61,8 +170,14 @@ static ULONG WINAPI dmo_wrapper_filter_Release(IDMOWrapperFilter *iface) static HRESULT WINAPI dmo_wrapper_filter_Init(IDMOWrapperFilter *iface, REFCLSID clsid, REFCLSID category) { struct dmo_wrapper *filter = impl_from_IDMOWrapperFilter(iface); + struct dmo_wrapper_source *sources; + DWORD input_count, output_count; + struct strmbase_sink *sinks; + IMediaObject *dmo; IUnknown *unk; + WCHAR id[14]; HRESULT hr; + DWORD i;
TRACE("filter %p, clsid %s, category %s.\n", filter, debugstr_guid(clsid), debugstr_guid(category));
@@ -70,12 +185,50 @@ static HRESULT WINAPI dmo_wrapper_filter_Init(IDMOWrapperFilter *iface, REFCLSID CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk))) return hr;
+ if (FAILED(hr = IUnknown_QueryInterface(unk, &IID_IMediaObject, (void **)&dmo))) + { + IUnknown_Release(unk); + return hr; + } + + if (FAILED(IMediaObject_GetStreamCount(dmo, &input_count, &output_count))) + input_count = output_count = 0; + + sinks = calloc(sizeof(*sinks), input_count); + sources = calloc(sizeof(*sources), output_count); + if (!sinks || !sources) + { + free(sinks); + free(sources); + IMediaObject_Release(dmo); + IUnknown_Release(unk); + return hr; + } + + for (i = 0; i < input_count; ++i) + { + swprintf(id, ARRAY_SIZE(id), L"in%u", i); + strmbase_sink_init(&sinks[i], &filter->filter, id, &sink_ops, NULL); + } + + for (i = 0; i < output_count; ++i) + { + swprintf(id, ARRAY_SIZE(id), L"out%u", i); + strmbase_source_init(&sources[i].pin, &filter->filter, id, &source_ops); + } + EnterCriticalSection(&filter->filter.csFilter);
filter->dmo = unk; + filter->sink_count = input_count; + filter->source_count = output_count; + filter->sinks = sinks; + filter->sources = sources;
LeaveCriticalSection(&filter->filter.csFilter);
+ IMediaObject_Release(dmo); + return S_OK; }
@@ -89,15 +242,28 @@ static const IDMOWrapperFilterVtbl dmo_wrapper_filter_vtbl =
static struct strmbase_pin *dmo_wrapper_get_pin(struct strmbase_filter *iface, unsigned int index) { + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface); + + if (index < filter->sink_count) + return &filter->sinks[index].pin; + else if (index < filter->sink_count + filter->source_count) + return &filter->sources[index - filter->sink_count].pin.pin; return NULL; }
static void dmo_wrapper_destroy(struct strmbase_filter *iface) { struct dmo_wrapper *filter = impl_from_strmbase_filter(iface); + DWORD i;
if (filter->dmo) IUnknown_Release(filter->dmo); + for (i = 0; i < filter->sink_count; ++i) + strmbase_sink_cleanup(&filter->sinks[i]); + for (i = 0; i < filter->source_count; ++i) + strmbase_source_cleanup(&filter->sources[i].pin); + free(filter->sinks); + free(filter->sources); strmbase_filter_cleanup(&filter->filter); free(filter); } diff --git a/dlls/qasf/tests/Makefile.in b/dlls/qasf/tests/Makefile.in index 47bb22e78ab..793f0d2c4b2 100644 --- a/dlls/qasf/tests/Makefile.in +++ b/dlls/qasf/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = qasf.dll -IMPORTS = dmoguids strmiids uuid msdmo ole32 +IMPORTS = strmbase dmoguids strmiids uuid msdmo ole32
C_SRCS = \ dmowrapper.c diff --git a/dlls/qasf/tests/dmowrapper.c b/dlls/qasf/tests/dmowrapper.c index 9345b91a178..59cd50d39e3 100644 --- a/dlls/qasf/tests/dmowrapper.c +++ b/dlls/qasf/tests/dmowrapper.c @@ -22,11 +22,40 @@ #include "dshow.h" #include "dmo.h" #include "dmodshow.h" +#include "wine/strmbase.h" #include "wine/test.h"
static const GUID testdmo_clsid = {0x1234}; static const GUID test_iid = {0x33333333};
+static int mt1_format = 0xdeadbeef; +static const AM_MEDIA_TYPE mt1 = +{ + .majortype = {0x123}, + .subtype = {0x456}, + .lSampleSize = 789, + .formattype = {0xabc}, + .cbFormat = sizeof(mt1_format), + .pbFormat = (BYTE *)&mt1_format, +}; + +static int mt2_format = 0xdeadf00d; +static const AM_MEDIA_TYPE mt2 = +{ + .majortype = {0x987}, + .subtype = {0x654}, + .lSampleSize = 321, + .formattype = {0xcba}, + .cbFormat = sizeof(mt2_format), + .pbFormat = (BYTE *)&mt2_format, +}; + +static inline BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TYPE *b) +{ + return !memcmp(a, b, offsetof(AM_MEDIA_TYPE, pbFormat)) + && !memcmp(a->pbFormat, b->pbFormat, a->cbFormat); +} + static const IMediaObjectVtbl dmo_vtbl;
static IMediaObject testdmo = {&dmo_vtbl}; @@ -105,26 +134,44 @@ static HRESULT WINAPI dmo_GetOutputStreamInfo(IMediaObject *iface, DWORD index,
static HRESULT WINAPI dmo_GetInputType(IMediaObject *iface, DWORD index, DWORD type_index, DMO_MEDIA_TYPE *type) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("GetInputType(index %u, type_index %u)\n", index, type_index); + if (!type_index) + { + memset(type, 0, sizeof(*type)); /* cover up the holes */ + MoCopyMediaType(type, (const DMO_MEDIA_TYPE *)&mt1); + return S_OK; + } + return E_OUTOFMEMORY; }
static HRESULT WINAPI dmo_GetOutputType(IMediaObject *iface, DWORD index, DWORD type_index, DMO_MEDIA_TYPE *type) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("GetOutputType(index %u, type_index %u)\n", index, type_index); + if (!type_index) + { + memset(type, 0, sizeof(*type)); /* cover up the holes */ + MoCopyMediaType(type, (const DMO_MEDIA_TYPE *)&mt2); + return S_OK; + } + return E_OUTOFMEMORY; }
static HRESULT WINAPI dmo_SetInputType(IMediaObject *iface, DWORD index, const DMO_MEDIA_TYPE *type, DWORD flags) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("SetInputType(index %u, flags %#x)\n", index, flags); + strmbase_dump_media_type((AM_MEDIA_TYPE *)type); + if (flags & DMO_SET_TYPEF_TEST_ONLY) + return type->lSampleSize == 123 ? S_OK : S_FALSE; + return S_OK; }
static HRESULT WINAPI dmo_SetOutputType(IMediaObject *iface, DWORD index, const DMO_MEDIA_TYPE *type, DWORD flags) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("SetOutputType(index %u, flags %#x)\n", index, flags); + strmbase_dump_media_type((AM_MEDIA_TYPE *)type); + if (flags & DMO_SET_TYPEF_TEST_ONLY) + return type->lSampleSize == 321 ? S_OK : S_FALSE; + return S_OK; }
static HRESULT WINAPI dmo_GetInputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) @@ -332,6 +379,7 @@ static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOO static void test_interfaces(void) { IBaseFilter *filter = create_dmo_wrapper(); + IPin *pin;
check_interface(filter, &IID_IBaseFilter, TRUE); check_interface(filter, &IID_IDMOWrapperFilter, TRUE); @@ -353,6 +401,32 @@ static void test_interfaces(void) check_interface(filter, &IID_IReferenceClock, FALSE); check_interface(filter, &IID_IVideoWindow, FALSE);
+ IBaseFilter_FindPin(filter, L"in0", &pin); + + check_interface(pin, &IID_IMemInputPin, TRUE); + check_interface(pin, &IID_IPin, TRUE); + todo_wine check_interface(pin, &IID_IQualityControl, TRUE); + check_interface(pin, &IID_IUnknown, TRUE); + + check_interface(pin, &IID_IKsPropertySet, FALSE); + check_interface(pin, &IID_IMediaPosition, FALSE); + check_interface(pin, &IID_IMediaSeeking, FALSE); + + IPin_Release(pin); + + IBaseFilter_FindPin(filter, L"out0", &pin); + + todo_wine check_interface(pin, &IID_IMediaPosition, TRUE); + todo_wine check_interface(pin, &IID_IMediaSeeking, TRUE); + check_interface(pin, &IID_IPin, TRUE); + todo_wine check_interface(pin, &IID_IQualityControl, TRUE); + check_interface(pin, &IID_IUnknown, TRUE); + + check_interface(pin, &IID_IAsyncReader, FALSE); + check_interface(pin, &IID_IKsPropertySet, FALSE); + + IPin_Release(pin); + IBaseFilter_Release(filter); }
@@ -460,6 +534,429 @@ static void test_aggregation(void) ok(!ref, "Got unexpected refcount %d.\n", ref); }
+static void test_enum_pins(void) +{ + IBaseFilter *filter = create_dmo_wrapper(); + IEnumPins *enum1, *enum2; + ULONG count, ref; + IPin *pins[4]; + HRESULT hr; + + ref = get_refcount(filter); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + + hr = IBaseFilter_EnumPins(filter, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IBaseFilter_EnumPins(filter, &enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + + hr = IEnumPins_Next(enum1, 1, NULL, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pins[0]); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + IPin_Release(pins[0]); + ref = get_refcount(filter); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pins[0]); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + IPin_Release(pins[0]); + ref = get_refcount(filter); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pins[0]); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + IPin_Release(pins[0]); + ref = get_refcount(filter); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + IPin_Release(pins[0]); + + hr = IEnumPins_Next(enum1, 1, pins, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + IPin_Release(pins[0]); + + hr = IEnumPins_Next(enum1, 1, pins, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + IPin_Release(pins[0]); + + hr = IEnumPins_Next(enum1, 1, pins, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 2, pins, NULL); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 2, pins, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 2, "Got count %u.\n", count); + IPin_Release(pins[0]); + IPin_Release(pins[1]); + + hr = IEnumPins_Next(enum1, 2, pins, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + IPin_Release(pins[0]); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 4, pins, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(count == 3, "Got count %u.\n", count); + IPin_Release(pins[0]); + IPin_Release(pins[1]); + IPin_Release(pins[2]); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Clone(enum1, &enum2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 4); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 1); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum2, 1, pins, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IPin_Release(pins[0]); + + IEnumPins_Release(enum2); + IEnumPins_Release(enum1); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + +static void test_find_pin(void) +{ + IBaseFilter *filter = create_dmo_wrapper(); + IEnumPins *enum_pins; + IPin *pin, *pin2; + HRESULT hr; + ULONG ref; + + hr = IBaseFilter_EnumPins(filter, &enum_pins); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IBaseFilter_FindPin(filter, L"in0", &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IEnumPins_Next(enum_pins, 1, &pin2, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(pin2 == pin, "Expected pin %p, got %p.\n", pin, pin2); + IPin_Release(pin2); + IPin_Release(pin); + + hr = IBaseFilter_FindPin(filter, L"out0", &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IEnumPins_Next(enum_pins, 1, &pin2, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(pin2 == pin, "Expected pin %p, got %p.\n", pin, pin2); + IPin_Release(pin2); + IPin_Release(pin); + + hr = IBaseFilter_FindPin(filter, L"out1", &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IEnumPins_Next(enum_pins, 1, &pin2, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(pin2 == pin, "Expected pin %p, got %p.\n", pin, pin2); + IPin_Release(pin2); + IPin_Release(pin); + + IEnumPins_Release(enum_pins); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + +static void test_pin_info(void) +{ + IBaseFilter *filter = create_dmo_wrapper(); + PIN_DIRECTION dir; + PIN_INFO info; + ULONG count; + HRESULT hr; + WCHAR *id; + ULONG ref; + IPin *pin; + + hr = IBaseFilter_FindPin(filter, L"in0", &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pin); + ok(ref == 2, "Got unexpected refcount %d.\n", ref); + + hr = IPin_QueryPinInfo(pin, &info); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(info.pFilter == filter, "Expected filter %p, got %p.\n", filter, info.pFilter); + ok(info.dir == PINDIR_INPUT, "Got direction %d.\n", info.dir); + ok(!wcscmp(info.achName, L"in0"), "Got name %s.\n", wine_dbgstr_w(info.achName)); + ref = get_refcount(filter); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pin); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + IBaseFilter_Release(info.pFilter); + + hr = IPin_QueryDirection(pin, &dir); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(dir == PINDIR_INPUT, "Got direction %d.\n", dir); + + hr = IPin_QueryId(pin, &id); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!wcscmp(id, L"in0"), "Got id %s.\n", wine_dbgstr_w(id)); + CoTaskMemFree(id); + + hr = IPin_QueryInternalConnections(pin, NULL, &count); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + IPin_Release(pin); + + hr = IBaseFilter_FindPin(filter, L"out0", &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_QueryPinInfo(pin, &info); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(info.pFilter == filter, "Expected filter %p, got %p.\n", filter, info.pFilter); + ok(info.dir == PINDIR_OUTPUT, "Got direction %d.\n", info.dir); + ok(!wcscmp(info.achName, L"out0"), "Got name %s.\n", wine_dbgstr_w(info.achName)); + ref = get_refcount(filter); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pin); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + IBaseFilter_Release(info.pFilter); + + hr = IPin_QueryDirection(pin, &dir); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(dir == PINDIR_OUTPUT, "Got direction %d.\n", dir); + + hr = IPin_QueryId(pin, &id); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!wcscmp(id, L"out0"), "Got id %s.\n", wine_dbgstr_w(id)); + CoTaskMemFree(id); + + hr = IPin_QueryInternalConnections(pin, NULL, &count); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + IPin_Release(pin); + + hr = IBaseFilter_FindPin(filter, L"out1", &pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_QueryPinInfo(pin, &info); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(info.pFilter == filter, "Expected filter %p, got %p.\n", filter, info.pFilter); + ok(info.dir == PINDIR_OUTPUT, "Got direction %d.\n", info.dir); + ok(!wcscmp(info.achName, L"out1"), "Got name %s.\n", wine_dbgstr_w(info.achName)); + ref = get_refcount(filter); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pin); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + IBaseFilter_Release(info.pFilter); + + hr = IPin_QueryDirection(pin, &dir); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(dir == PINDIR_OUTPUT, "Got direction %d.\n", dir); + + hr = IPin_QueryId(pin, &id); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!wcscmp(id, L"out1"), "Got id %s.\n", wine_dbgstr_w(id)); + CoTaskMemFree(id); + + hr = IPin_QueryInternalConnections(pin, NULL, &count); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + IPin_Release(pin); + + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + +static void test_media_types(void) +{ + IBaseFilter *filter = create_dmo_wrapper(); + AM_MEDIA_TYPE *mt, req_mt = {}; + IEnumMediaTypes *enummt; + HRESULT hr; + ULONG ref; + IPin *pin; + + IBaseFilter_FindPin(filter, L"in0", &pin); + + hr = IPin_EnumMediaTypes(pin, &enummt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enummt, 1, &mt, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(mt, &mt1), "Media types didn't match.\n"); + DeleteMediaType(mt); + + hr = IEnumMediaTypes_Next(enummt, 1, &mt, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumMediaTypes_Release(enummt); + + hr = IPin_QueryAccept(pin, &req_mt); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + req_mt.lSampleSize = 123; + hr = IPin_QueryAccept(pin, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IPin_Release(pin); + + IBaseFilter_FindPin(filter, L"out0", &pin); + + hr = IPin_EnumMediaTypes(pin, &enummt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enummt, 1, &mt, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(mt, &mt2), "Media types didn't match.\n"); + DeleteMediaType(mt); + + hr = IEnumMediaTypes_Next(enummt, 1, &mt, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumMediaTypes_Release(enummt); + + hr = IPin_QueryAccept(pin, &req_mt); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + req_mt.lSampleSize = 321; + hr = IPin_QueryAccept(pin, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IPin_Release(pin); + + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + +static void test_enum_media_types(void) +{ + IBaseFilter *filter = create_dmo_wrapper(); + IEnumMediaTypes *enum1, *enum2; + AM_MEDIA_TYPE *mts[2]; + ULONG ref, count; + HRESULT hr; + IPin *pin; + + IBaseFilter_FindPin(filter, L"in0", &pin); + + hr = IPin_EnumMediaTypes(pin, &enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + CoTaskMemFree(mts[0]->pbFormat); + CoTaskMemFree(mts[0]); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + CoTaskMemFree(mts[0]->pbFormat); + CoTaskMemFree(mts[0]); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(!count, "Got count %u.\n", count); + + hr = IEnumMediaTypes_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 2, mts, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + CoTaskMemFree(mts[0]->pbFormat); + CoTaskMemFree(mts[0]); + + hr = IEnumMediaTypes_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Clone(enum1, &enum2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Skip(enum1, 2); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Skip(enum1, 1); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Skip(enum1, 1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Skip(enum1, 1); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum1, 1, mts, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumMediaTypes_Next(enum2, 1, mts, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + CoTaskMemFree(mts[0]->pbFormat); + CoTaskMemFree(mts[0]); + + IEnumMediaTypes_Release(enum1); + IEnumMediaTypes_Release(enum2); + IPin_Release(pin); + + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(dmowrapper) { DWORD cookie; @@ -481,6 +978,11 @@ START_TEST(dmowrapper)
test_interfaces(); test_aggregation(); + test_enum_pins(); + test_find_pin(); + test_pin_info(); + test_media_types(); + test_enum_media_types();
CoRevokeClassObject(cookie); DMOUnregister(&testdmo_clsid, &DMOCATEGORY_AUDIO_DECODER);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/qasf/dmowrapper.c | 28 ++++ dlls/qasf/tests/dmowrapper.c | 275 ++++++++++++++++++++++++++++++++++- 2 files changed, 298 insertions(+), 5 deletions(-)
diff --git a/dlls/qasf/dmowrapper.c b/dlls/qasf/dmowrapper.c index 6e703e90d0c..28d8e82175c 100644 --- a/dlls/qasf/dmowrapper.c +++ b/dlls/qasf/dmowrapper.c @@ -94,11 +94,39 @@ static HRESULT dmo_wrapper_sink_get_media_type(struct strmbase_pin *iface, unsig return hr == S_OK ? S_OK : VFW_S_NO_MORE_ITEMS; }
+static HRESULT dmo_wrapper_sink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *mt) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface->pin.filter); + IMediaObject *dmo; + HRESULT hr; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + hr = IMediaObject_SetInputType(dmo, iface - filter->sinks, (const DMO_MEDIA_TYPE *)mt, 0); + + IMediaObject_Release(dmo); + return hr; +} + +static void dmo_wrapper_sink_disconnect(struct strmbase_sink *iface) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface->pin.filter); + IMediaObject *dmo; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + IMediaObject_SetInputType(dmo, iface - filter->sinks, NULL, DMO_SET_TYPEF_CLEAR); + + IMediaObject_Release(dmo); +} + static const struct strmbase_sink_ops sink_ops = { .base.pin_query_interface = dmo_wrapper_sink_query_interface, .base.pin_query_accept = dmo_wrapper_sink_query_accept, .base.pin_get_media_type = dmo_wrapper_sink_get_media_type, + .sink_connect = dmo_wrapper_sink_connect, + .sink_disconnect = dmo_wrapper_sink_disconnect, };
static inline struct dmo_wrapper_source *impl_source_from_strmbase_pin(struct strmbase_pin *iface) diff --git a/dlls/qasf/tests/dmowrapper.c b/dlls/qasf/tests/dmowrapper.c index 59cd50d39e3..641fa689042 100644 --- a/dlls/qasf/tests/dmowrapper.c +++ b/dlls/qasf/tests/dmowrapper.c @@ -61,6 +61,10 @@ static const IMediaObjectVtbl dmo_vtbl; static IMediaObject testdmo = {&dmo_vtbl}; static IUnknown *testdmo_outer_unk; static LONG testdmo_refcount = 1; +static AM_MEDIA_TYPE testdmo_input_mt; +static BOOL testdmo_input_mt_set; + +static HRESULT testdmo_GetInputSizeInfo_hr = E_NOTIMPL;
static HRESULT WINAPI dmo_inner_QueryInterface(IUnknown *iface, REFIID iid, void **out) { @@ -121,8 +125,9 @@ static HRESULT WINAPI dmo_GetStreamCount(IMediaObject *iface, DWORD *input, DWOR
static HRESULT WINAPI dmo_GetInputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("GetInputStreamInfo(%u)\n", index); + *flags = 0; + return S_OK; }
static HRESULT WINAPI dmo_GetOutputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags) @@ -162,6 +167,13 @@ static HRESULT WINAPI dmo_SetInputType(IMediaObject *iface, DWORD index, const D strmbase_dump_media_type((AM_MEDIA_TYPE *)type); if (flags & DMO_SET_TYPEF_TEST_ONLY) return type->lSampleSize == 123 ? S_OK : S_FALSE; + if (flags & DMO_SET_TYPEF_CLEAR) + { + testdmo_input_mt_set = FALSE; + return S_OK; + } + MoCopyMediaType((DMO_MEDIA_TYPE *)&testdmo_input_mt, type); + testdmo_input_mt_set = TRUE; return S_OK; }
@@ -187,10 +199,13 @@ static HRESULT WINAPI dmo_GetOutputCurrentType(IMediaObject *iface, DWORD index, }
static HRESULT WINAPI dmo_GetInputSizeInfo(IMediaObject *iface, DWORD index, - DWORD *size, DWORD *lookahead, DWORD *align) + DWORD *size, DWORD *lookahead, DWORD *alignment) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("GetInputSizeInfo(%u)\n", index); + *size = 321; + *alignment = 64; + *lookahead = 0; + return testdmo_GetInputSizeInfo_hr; }
static HRESULT WINAPI dmo_GetOutputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *alignment) @@ -957,6 +972,255 @@ static void test_enum_media_types(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+struct testfilter +{ + struct strmbase_filter filter; + struct strmbase_source source; + struct strmbase_sink sink; + const AM_MEDIA_TYPE *sink_mt; +}; + +static inline struct testfilter *impl_from_strmbase_filter(struct strmbase_filter *iface) +{ + return CONTAINING_RECORD(iface, struct testfilter, filter); +} + +static struct strmbase_pin *testfilter_get_pin(struct strmbase_filter *iface, unsigned int index) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface); + if (!index) + return &filter->source.pin; + else if (index == 1) + return &filter->sink.pin; + return NULL; +} + +static void testfilter_destroy(struct strmbase_filter *iface) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface); + strmbase_source_cleanup(&filter->source); + strmbase_sink_cleanup(&filter->sink); + strmbase_filter_cleanup(&filter->filter); +} + +static const struct strmbase_filter_ops testfilter_ops = +{ + .filter_get_pin = testfilter_get_pin, + .filter_destroy = testfilter_destroy, +}; + +static HRESULT testsource_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt) +{ + return S_OK; +} + +static HRESULT WINAPI testsource_DecideAllocator(struct strmbase_source *iface, + IMemInputPin *input, IMemAllocator **allocator) +{ + return S_OK; +} + +static const struct strmbase_source_ops testsource_ops = +{ + .base.pin_query_accept = testsource_query_accept, + .base.pin_get_media_type = strmbase_pin_get_media_type, + .pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection, + .pfnDecideAllocator = testsource_DecideAllocator, +}; + +static HRESULT testsink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface->filter); + + if (IsEqualGUID(iid, &IID_IMemInputPin)) + *out = &filter->sink.IMemInputPin_iface; + else + return E_NOINTERFACE; + + IUnknown_AddRef((IUnknown *)*out); + return S_OK; +} + +static HRESULT testsink_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *mt) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface->filter); + if (filter->sink_mt && !compare_media_types(mt, filter->sink_mt)) + return S_FALSE; + return S_OK; +} + +static HRESULT testsink_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt) +{ + struct testfilter *filter = impl_from_strmbase_filter(iface->filter); + if (!index && filter->sink_mt) + { + CopyMediaType(mt, filter->sink_mt); + return S_OK; + } + return VFW_S_NO_MORE_ITEMS; +} + +static HRESULT WINAPI testsink_Receive(struct strmbase_sink *iface, IMediaSample *sample) +{ + return S_OK; +} + +static const struct strmbase_sink_ops testsink_ops = +{ + .base.pin_query_interface = testsink_query_interface, + .base.pin_query_accept = testsink_query_accept, + .base.pin_get_media_type = testsink_get_media_type, + .pfnReceive = testsink_Receive, +}; + +static void testfilter_init(struct testfilter *filter) +{ + static const GUID clsid = {0xabacab}; + memset(filter, 0, sizeof(*filter)); + strmbase_filter_init(&filter->filter, NULL, &clsid, &testfilter_ops); + strmbase_source_init(&filter->source, &filter->filter, L"source", &testsource_ops); + strmbase_sink_init(&filter->sink, &filter->filter, L"sink", &testsink_ops, NULL); +} + +static void test_sink_allocator(IMemInputPin *input) +{ + IMemAllocator *req_allocator, *ret_allocator; + ALLOCATOR_PROPERTIES props; + HRESULT hr; + + hr = IMemInputPin_GetAllocatorRequirements(input, &props); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + memset(&props, 0xcc, sizeof(props)); + testdmo_GetInputSizeInfo_hr = S_OK; + hr = IMemInputPin_GetAllocatorRequirements(input, &props); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + if (hr == S_OK) + { + ok(props.cBuffers == 1, "Got %d buffers.\n", props.cBuffers); + ok(props.cbBuffer == 321, "Got size %d.\n", props.cbBuffer); + ok(props.cbAlign == 64, "Got alignment %d.\n", props.cbAlign); + ok(props.cbPrefix == 0xcccccccc, "Got prefix %d.\n", props.cbPrefix); + } + + hr = IMemInputPin_GetAllocator(input, &ret_allocator); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + if (hr == S_OK) + { + hr = IMemAllocator_GetProperties(ret_allocator, &props); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!props.cBuffers, "Got %d buffers.\n", props.cBuffers); + ok(!props.cbBuffer, "Got size %d.\n", props.cbBuffer); + ok(!props.cbAlign, "Got alignment %d.\n", props.cbAlign); + ok(!props.cbPrefix, "Got prefix %d.\n", props.cbPrefix); + + hr = IMemInputPin_NotifyAllocator(input, ret_allocator, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IMemAllocator_Release(ret_allocator); + } + + hr = IMemInputPin_NotifyAllocator(input, NULL, TRUE); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, + &IID_IMemAllocator, (void **)&req_allocator); + + hr = IMemInputPin_NotifyAllocator(input, req_allocator, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMemInputPin_GetAllocator(input, &ret_allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ret_allocator == req_allocator, "Allocators didn't match.\n"); + + IMemAllocator_Release(req_allocator); + IMemAllocator_Release(ret_allocator); +} + +static void test_connect_pin(void) +{ + AM_MEDIA_TYPE req_mt = + { + .majortype = MEDIATYPE_Stream, + .subtype = MEDIASUBTYPE_Avi, + .formattype = FORMAT_None, + }; + IBaseFilter *filter = create_dmo_wrapper(); + struct testfilter testsource; + IMemInputPin *meminput; + IFilterGraph2 *graph; + IPin *sink, *peer; + AM_MEDIA_TYPE mt; + HRESULT hr; + ULONG ref; + + testfilter_init(&testsource); + CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, + &IID_IFilterGraph2, (void **)&graph); + IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source"); + IFilterGraph2_AddFilter(graph, filter, L"DMO wrapper"); + IBaseFilter_FindPin(filter, L"in0", &sink); + IPin_QueryInterface(sink, &IID_IMemInputPin, (void **)&meminput); + + /* Test sink connection. */ + peer = (IPin *)0xdeadbeef; + hr = IPin_ConnectedTo(sink, &peer); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + ok(!peer, "Got peer %p.\n", peer); + + hr = IPin_ConnectionMediaType(sink, &mt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + + ok(!testdmo_input_mt_set, "Input type should not be set.\n"); + + req_mt.lSampleSize = 123; + hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_ConnectedTo(sink, &peer); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(peer == &testsource.source.pin.IPin_iface, "Got peer %p.\n", peer); + IPin_Release(peer); + + hr = IPin_ConnectionMediaType(sink, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n"); + + ok(testdmo_input_mt_set, "Input type should be set.\n"); + ok(compare_media_types(&testdmo_input_mt, &req_mt), "Media types didn't match.\n"); + + test_sink_allocator(meminput); + + hr = IFilterGraph2_Disconnect(graph, sink); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_Disconnect(graph, sink); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(testsource.source.pin.peer == sink, "Got peer %p.\n", testsource.source.pin.peer); + IFilterGraph2_Disconnect(graph, &testsource.sink.pin.IPin_iface); + + peer = (IPin *)0xdeadbeef; + hr = IPin_ConnectedTo(sink, &peer); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + ok(!peer, "Got peer %p.\n", peer); + + hr = IPin_ConnectionMediaType(sink, &mt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + ok(!testdmo_input_mt_set, "Input type should not be set.\n"); + + IPin_Release(sink); + IMemInputPin_Release(meminput); + ref = IFilterGraph2_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IBaseFilter_Release(&testsource.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(dmowrapper) { DWORD cookie; @@ -983,6 +1247,7 @@ START_TEST(dmowrapper) test_pin_info(); test_media_types(); test_enum_media_types(); + test_connect_pin();
CoRevokeClassObject(cookie); DMOUnregister(&testdmo_clsid, &DMOCATEGORY_AUDIO_DECODER);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/qasf/dmowrapper.c | 46 +++++++ dlls/qasf/tests/dmowrapper.c | 240 ++++++++++++++++++++++++++++++++++- dlls/strmbase/pin.c | 3 + include/wine/strmbase.h | 2 + 4 files changed, 285 insertions(+), 6 deletions(-)
diff --git a/dlls/qasf/dmowrapper.c b/dlls/qasf/dmowrapper.c index 28d8e82175c..7a18d0ba079 100644 --- a/dlls/qasf/dmowrapper.c +++ b/dlls/qasf/dmowrapper.c @@ -166,10 +166,56 @@ static HRESULT dmo_wrapper_source_get_media_type(struct strmbase_pin *iface, uns return hr == S_OK ? S_OK : VFW_S_NO_MORE_ITEMS; }
+static HRESULT WINAPI dmo_wrapper_source_DecideBufferSize(struct strmbase_source *iface, + IMemAllocator *allocator, ALLOCATOR_PROPERTIES *props) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface->pin.filter); + DWORD index = impl_source_from_strmbase_pin(&iface->pin) - filter->sources; + ALLOCATOR_PROPERTIES ret_props; + DWORD size = 0, alignment = 0; + IMediaObject *dmo; + HRESULT hr; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + if (SUCCEEDED(hr = IMediaObject_SetOutputType(dmo, index, + (const DMO_MEDIA_TYPE *)&iface->pin.mt, 0))) + hr = IMediaObject_GetOutputSizeInfo(dmo, index, &size, &alignment); + + if (SUCCEEDED(hr)) + { + props->cBuffers = max(props->cBuffers, 1); + props->cbBuffer = max(max(props->cbBuffer, size), 16384); + props->cbAlign = max(props->cbAlign, alignment); + hr = IMemAllocator_SetProperties(allocator, props, &ret_props); + } + + IMediaObject_Release(dmo); + + return hr; +} + +static void dmo_wrapper_source_disconnect(struct strmbase_source *iface) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface->pin.filter); + IMediaObject *dmo; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + IMediaObject_SetOutputType(dmo, impl_source_from_strmbase_pin(&iface->pin) - filter->sources, + NULL, DMO_SET_TYPEF_CLEAR); + + IMediaObject_Release(dmo); +} + static const struct strmbase_source_ops source_ops = { .base.pin_query_accept = dmo_wrapper_source_query_accept, .base.pin_get_media_type = dmo_wrapper_source_get_media_type, + .pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection, + .pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator, + .pfnDecideBufferSize = dmo_wrapper_source_DecideBufferSize, + .source_disconnect = dmo_wrapper_source_disconnect, };
static inline struct dmo_wrapper *impl_from_IDMOWrapperFilter(IDMOWrapperFilter *iface) diff --git a/dlls/qasf/tests/dmowrapper.c b/dlls/qasf/tests/dmowrapper.c index 641fa689042..dbb9d9d17f3 100644 --- a/dlls/qasf/tests/dmowrapper.c +++ b/dlls/qasf/tests/dmowrapper.c @@ -61,10 +61,13 @@ static const IMediaObjectVtbl dmo_vtbl; static IMediaObject testdmo = {&dmo_vtbl}; static IUnknown *testdmo_outer_unk; static LONG testdmo_refcount = 1; -static AM_MEDIA_TYPE testdmo_input_mt; -static BOOL testdmo_input_mt_set; +static AM_MEDIA_TYPE testdmo_input_mt, testdmo_output_mt; +static BOOL testdmo_input_mt_set, testdmo_output_mt_set;
static HRESULT testdmo_GetInputSizeInfo_hr = E_NOTIMPL; +static HRESULT testdmo_GetOutputSizeInfo_hr = S_OK; +static DWORD testdmo_output_size = 123; +static DWORD testdmo_output_alignment = 1;
static HRESULT WINAPI dmo_inner_QueryInterface(IUnknown *iface, REFIID iid, void **out) { @@ -183,6 +186,13 @@ static HRESULT WINAPI dmo_SetOutputType(IMediaObject *iface, DWORD index, const strmbase_dump_media_type((AM_MEDIA_TYPE *)type); if (flags & DMO_SET_TYPEF_TEST_ONLY) return type->lSampleSize == 321 ? S_OK : S_FALSE; + if (flags & DMO_SET_TYPEF_CLEAR) + { + testdmo_output_mt_set = FALSE; + return S_OK; + } + MoCopyMediaType((DMO_MEDIA_TYPE *)&testdmo_output_mt, type); + testdmo_output_mt_set = TRUE; return S_OK; }
@@ -210,8 +220,10 @@ static HRESULT WINAPI dmo_GetInputSizeInfo(IMediaObject *iface, DWORD index,
static HRESULT WINAPI dmo_GetOutputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *alignment) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("GetOutputSizeInfo(%u)\n", index); + *size = testdmo_output_size; + *alignment = testdmo_output_alignment; + return testdmo_GetOutputSizeInfo_hr; }
static HRESULT WINAPI dmo_GetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME *latency) @@ -1137,6 +1149,71 @@ static void test_sink_allocator(IMemInputPin *input) IMemAllocator_Release(ret_allocator); }
+static void test_source_allocator(IFilterGraph2 *graph, IPin *source, struct testfilter *testsink) +{ + ALLOCATOR_PROPERTIES props, req_props = {2, 30000, 32, 0}; + IMemAllocator *allocator; + HRESULT hr; + + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &mt2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(!!testsink->sink.pAllocator, "Expected an allocator.\n"); + hr = IMemAllocator_GetProperties(testsink->sink.pAllocator, &props); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(props.cBuffers == 1, "Got %d buffers.\n", props.cBuffers); + ok(props.cbBuffer == 16384, "Got size %d.\n", props.cbBuffer); + ok(props.cbAlign == 1, "Got alignment %d.\n", props.cbAlign); + ok(!props.cbPrefix, "Got prefix %d.\n", props.cbPrefix); + + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); + + testdmo_output_alignment = 16; + testdmo_output_size = 20000; + + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &mt2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(!!testsink->sink.pAllocator, "Expected an allocator.\n"); + hr = IMemAllocator_GetProperties(testsink->sink.pAllocator, &props); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(props.cBuffers == 1, "Got %d buffers.\n", props.cBuffers); + ok(props.cbBuffer == 20000, "Got size %d.\n", props.cbBuffer); + ok(props.cbAlign == 16, "Got alignment %d.\n", props.cbAlign); + ok(!props.cbPrefix, "Got prefix %d.\n", props.cbPrefix); + + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); + + testdmo_GetOutputSizeInfo_hr = E_NOTIMPL; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &mt2); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + testdmo_GetOutputSizeInfo_hr = S_OK; + + CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, + &IID_IMemAllocator, (void **)&allocator); + testsink->sink.pAllocator = allocator; + + hr = IMemAllocator_SetProperties(allocator, &req_props, &props); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &mt2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(testsink->sink.pAllocator == allocator, "Expected an allocator.\n"); + hr = IMemAllocator_GetProperties(testsink->sink.pAllocator, &props); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(props.cBuffers == 1, "Got %d buffers.\n", props.cBuffers); + ok(props.cbBuffer == 20000, "Got size %d.\n", props.cbBuffer); + ok(props.cbAlign == 16, "Got alignment %d.\n", props.cbAlign); + ok(!props.cbPrefix, "Got prefix %d.\n", props.cbPrefix); + + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface); + +} + static void test_connect_pin(void) { AM_MEDIA_TYPE req_mt = @@ -1146,20 +1223,23 @@ static void test_connect_pin(void) .formattype = FORMAT_None, }; IBaseFilter *filter = create_dmo_wrapper(); - struct testfilter testsource; + struct testfilter testsource, testsink; + IPin *sink, *source, *peer; IMemInputPin *meminput; IFilterGraph2 *graph; - IPin *sink, *peer; AM_MEDIA_TYPE mt; HRESULT hr; ULONG ref;
testfilter_init(&testsource); + testfilter_init(&testsink); CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterGraph2, (void **)&graph); IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source"); + IFilterGraph2_AddFilter(graph, &testsink.filter.IBaseFilter_iface, L"sink"); IFilterGraph2_AddFilter(graph, filter, L"DMO wrapper"); IBaseFilter_FindPin(filter, L"in0", &sink); + IBaseFilter_FindPin(filter, L"out0", &source); IPin_QueryInterface(sink, &IID_IMemInputPin, (void **)&meminput);
/* Test sink connection. */ @@ -1194,6 +1274,149 @@ static void test_connect_pin(void)
test_sink_allocator(meminput);
+ /* Test source connection. */ + peer = (IPin *)0xdeadbeef; + hr = IPin_ConnectedTo(source, &peer); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + ok(!peer, "Got peer %p.\n", peer); + + hr = IPin_ConnectionMediaType(source, &mt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + ok(!testdmo_output_mt_set, "Output type should not be set.\n"); + + /* Exact connection. */ + + req_mt = mt2; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_ConnectedTo(source, &peer); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(peer == &testsink.sink.pin.IPin_iface, "Got peer %p.\n", peer); + IPin_Release(peer); + + hr = IPin_ConnectionMediaType(source, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n"); + + ok(testdmo_output_mt_set, "Ouput type should be set.\n"); + ok(compare_media_types(&testdmo_output_mt, &req_mt), "Media types didn't match.\n"); + + hr = IFilterGraph2_Disconnect(graph, source); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_Disconnect(graph, source); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(testsink.sink.pin.peer == source, "Got peer %p.\n", testsink.sink.pin.peer); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + + peer = (IPin *)0xdeadbeef; + hr = IPin_ConnectedTo(source, &peer); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + ok(!peer, "Got peer %p.\n", peer); + + hr = IPin_ConnectionMediaType(source, &mt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); + + ok(!testdmo_output_mt_set, "Output type should not be set.\n"); + + req_mt.lSampleSize = 0; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); + + /* Connection with wildcards. */ + + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &mt2), "Media types didn't match.\n"); + ok(testdmo_output_mt_set, "Ouput type should be set.\n"); + ok(compare_media_types(&testdmo_output_mt, &mt2), "Media types didn't match.\n"); + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + + req_mt.majortype = GUID_NULL; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &mt2), "Media types didn't match.\n"); + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + + req_mt.subtype = MEDIASUBTYPE_RGB32; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + + req_mt.subtype = GUID_NULL; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &mt2), "Media types didn't match.\n"); + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + + req_mt.formattype = FORMAT_WaveFormatEx; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + + req_mt = mt2; + req_mt.formattype = GUID_NULL; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &mt2), "Media types didn't match.\n"); + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + + req_mt.subtype = MEDIASUBTYPE_RGB32; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + + req_mt.subtype = GUID_NULL; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &mt2), "Media types didn't match.\n"); + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + + req_mt.majortype = MEDIATYPE_Audio; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + + mt = req_mt; + testsink.sink_mt = &mt; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &mt), "Media types didn't match.\n"); + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + + mt.lSampleSize = 1; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + mt.lSampleSize = 321; + + mt.majortype = mt.subtype = mt.formattype = GUID_NULL; + req_mt = mt; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(&testsink.sink.pin.mt, &mt), "Media types didn't match.\n"); + IFilterGraph2_Disconnect(graph, source); + IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); + + req_mt.majortype = mt2.majortype; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + req_mt.majortype = GUID_NULL; + + req_mt.subtype = mt2.subtype; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + req_mt.subtype = GUID_NULL; + + req_mt.formattype = mt2.formattype; + hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); + ok(hr == VFW_E_NO_ACCEPTABLE_TYPES, "Got hr %#x.\n", hr); + req_mt.formattype = GUID_NULL; + + testsink.sink_mt = NULL; + hr = IFilterGraph2_Disconnect(graph, sink); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IFilterGraph2_Disconnect(graph, sink); @@ -1211,7 +1434,10 @@ static void test_connect_pin(void)
ok(!testdmo_input_mt_set, "Input type should not be set.\n");
+ test_source_allocator(graph, source, &testsink); + IPin_Release(sink); + IPin_Release(source); IMemInputPin_Release(meminput); ref = IFilterGraph2_Release(graph); ok(!ref, "Got outstanding refcount %d.\n", ref); @@ -1219,6 +1445,8 @@ static void test_connect_pin(void) ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IBaseFilter_Release(&testsource.filter.IBaseFilter_iface); ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IBaseFilter_Release(&testsink.filter.IBaseFilter_iface); + ok(!ref, "Got outstanding refcount %d.\n", ref); }
START_TEST(dmowrapper) diff --git a/dlls/strmbase/pin.c b/dlls/strmbase/pin.c index 8a565b536e2..4676c9d82b0 100644 --- a/dlls/strmbase/pin.c +++ b/dlls/strmbase/pin.c @@ -555,6 +555,9 @@ static HRESULT WINAPI source_Disconnect(IPin *iface) return VFW_E_NOT_STOPPED; }
+ if (This->pFuncsTable->source_disconnect) + This->pFuncsTable->source_disconnect(This); + if (This->pMemInputPin) { IMemInputPin_Release(This->pMemInputPin); diff --git a/include/wine/strmbase.h b/include/wine/strmbase.h index 5151e68644b..0e0f73afa3c 100644 --- a/include/wine/strmbase.h +++ b/include/wine/strmbase.h @@ -74,6 +74,8 @@ struct strmbase_source_ops BaseOutputPin_DecideBufferSize pfnDecideBufferSize; /* Required for BaseOutputPinImpl_AttemptConnection */ BaseOutputPin_DecideAllocator pfnDecideAllocator; + + void (*source_disconnect)(struct strmbase_source *pin); };
struct strmbase_sink
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/qasf/tests/dmowrapper.c | 78 +++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 6 deletions(-)
diff --git a/dlls/qasf/tests/dmowrapper.c b/dlls/qasf/tests/dmowrapper.c index dbb9d9d17f3..fe00536364c 100644 --- a/dlls/qasf/tests/dmowrapper.c +++ b/dlls/qasf/tests/dmowrapper.c @@ -69,6 +69,8 @@ static HRESULT testdmo_GetOutputSizeInfo_hr = S_OK; static DWORD testdmo_output_size = 123; static DWORD testdmo_output_alignment = 1;
+static unsigned int got_Flush; + static HRESULT WINAPI dmo_inner_QueryInterface(IUnknown *iface, REFIID iid, void **out) { if (winetest_debug > 1) trace("QueryInterface(%s)\n", wine_dbgstr_guid(iid)); @@ -240,8 +242,9 @@ static HRESULT WINAPI dmo_SetInputMaxLatency(IMediaObject *iface, DWORD index, R
static HRESULT WINAPI dmo_Flush(IMediaObject *iface) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("Flush()\n"); + ++got_Flush; + return S_OK; }
static HRESULT WINAPI dmo_Discontinuity(IMediaObject *iface, DWORD index) @@ -252,14 +255,14 @@ static HRESULT WINAPI dmo_Discontinuity(IMediaObject *iface, DWORD index)
static HRESULT WINAPI dmo_AllocateStreamingResources(IMediaObject *iface) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("AllocateStreamingResources()\n"); + return S_OK; }
static HRESULT WINAPI dmo_FreeStreamingResources(IMediaObject *iface) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + if (winetest_debug > 1) trace("FreeStreamingResources()\n"); + return S_OK; }
static HRESULT WINAPI dmo_GetInputStatus(IMediaObject *iface, DWORD index, DWORD *flags) @@ -1214,6 +1217,64 @@ static void test_source_allocator(IFilterGraph2 *graph, IPin *source, struct tes
}
+static void test_filter_state(IMediaControl *control) +{ + OAFilterState state; + HRESULT hr; + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %u.\n", state); + + hr = IMediaControl_Pause(control); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %u.\n", state); + + hr = IMediaControl_Run(control); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Running, "Got state %u.\n", state); + + hr = IMediaControl_Pause(control); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %u.\n", state); + + ok(!got_Flush, "Unexpected IMediaObject::Flush().\n"); + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(got_Flush, "Expected IMediaObject::Flush().\n"); + got_Flush = 0; + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %u.\n", state); + + hr = IMediaControl_Run(control); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Running, "Got state %u.\n", state); + + ok(!got_Flush, "Unexpected IMediaObject::Flush().\n"); + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(got_Flush, "Expected IMediaObject::Flush().\n"); + got_Flush = 0; + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %u.\n", state); +} + static void test_connect_pin(void) { AM_MEDIA_TYPE req_mt = @@ -1225,6 +1286,7 @@ static void test_connect_pin(void) IBaseFilter *filter = create_dmo_wrapper(); struct testfilter testsource, testsink; IPin *sink, *source, *peer; + IMediaControl *control; IMemInputPin *meminput; IFilterGraph2 *graph; AM_MEDIA_TYPE mt; @@ -1235,6 +1297,7 @@ static void test_connect_pin(void) testfilter_init(&testsink); CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterGraph2, (void **)&graph); + IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control); IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source"); IFilterGraph2_AddFilter(graph, &testsink.filter.IBaseFilter_iface, L"sink"); IFilterGraph2_AddFilter(graph, filter, L"DMO wrapper"); @@ -1320,6 +1383,8 @@ static void test_connect_pin(void)
ok(!testdmo_output_mt_set, "Output type should not be set.\n");
+ test_filter_state(control); + req_mt.lSampleSize = 0; hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); ok(hr == VFW_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr); @@ -1439,6 +1504,7 @@ static void test_connect_pin(void) IPin_Release(sink); IPin_Release(source); IMemInputPin_Release(meminput); + IMediaControl_Release(control); ref = IFilterGraph2_Release(graph); ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IBaseFilter_Release(filter);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- The tests do not pass yet due to filter graph insufficiencies.
dlls/qasf/dmowrapper.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/dlls/qasf/dmowrapper.c b/dlls/qasf/dmowrapper.c index 7a18d0ba079..9480d3b95bb 100644 --- a/dlls/qasf/dmowrapper.c +++ b/dlls/qasf/dmowrapper.c @@ -358,11 +358,25 @@ static HRESULT dmo_wrapper_query_interface(struct strmbase_filter *iface, REFIID return E_NOINTERFACE; }
+static HRESULT dmo_wrapper_cleanup_stream(struct strmbase_filter *iface) +{ + struct dmo_wrapper *filter = impl_from_strmbase_filter(iface); + IMediaObject *dmo; + + IUnknown_QueryInterface(filter->dmo, &IID_IMediaObject, (void **)&dmo); + + IMediaObject_Flush(dmo); + + IMediaObject_Release(dmo); + return S_OK; +} + static struct strmbase_filter_ops filter_ops = { .filter_get_pin = dmo_wrapper_get_pin, .filter_destroy = dmo_wrapper_destroy, .filter_query_interface = dmo_wrapper_query_interface, + .filter_cleanup_stream = dmo_wrapper_cleanup_stream, };
HRESULT dmo_wrapper_create(IUnknown *outer, IUnknown **out)