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);