From 8baf53bc077820f01bf7a5913cd1ea8b5a17753e Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 5 Mar 2020 20:04:37 -0600 Subject: [PATCH] qedit/samplegrabber: Correctly implement sample_grabber_sink_get_media_type(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/qedit/samplegrabber.c | 18 ++++++++++++++++-- dlls/qedit/tests/samplegrabber.c | 17 +++++++++++------ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/dlls/qedit/samplegrabber.c b/dlls/qedit/samplegrabber.c index 898b67fc9a5..9492620d045 100644 --- a/dlls/qedit/samplegrabber.c +++ b/dlls/qedit/samplegrabber.c @@ -511,12 +511,26 @@ static HRESULT sample_grabber_sink_get_media_type(struct strmbase_pin *iface, unsigned int index, AM_MEDIA_TYPE *mt) { SG_Impl *filter = impl_from_sink_pin(iface); + IEnumMediaTypes *enummt; + AM_MEDIA_TYPE *pmt; + HRESULT hr; - if (!index) + if (!filter->source.pin.peer) + return VFW_E_NOT_CONNECTED; + + if (FAILED(hr = IPin_EnumMediaTypes(filter->source.pin.peer, &enummt))) + return hr; + + if ((!index || IEnumMediaTypes_Skip(enummt, index) == S_OK) + && IEnumMediaTypes_Next(enummt, 1, &pmt, NULL) == S_OK) { - CopyMediaType(mt, &filter->filter_mt); + CopyMediaType(mt, pmt); + DeleteMediaType(pmt); + IEnumMediaTypes_Release(enummt); return S_OK; } + + IEnumMediaTypes_Release(enummt); return VFW_S_NO_MORE_ITEMS; } diff --git a/dlls/qedit/tests/samplegrabber.c b/dlls/qedit/tests/samplegrabber.c index 5436700d17d..8e68e3efae1 100644 --- a/dlls/qedit/tests/samplegrabber.c +++ b/dlls/qedit/tests/samplegrabber.c @@ -482,8 +482,7 @@ static void test_media_types(void) IBaseFilter_FindPin(filter, L"Out", &source); hr = IPin_EnumMediaTypes(sink, &enummt); - todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); - if (hr == S_OK) IEnumMediaTypes_Release(enummt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); hr = IPin_EnumMediaTypes(source, &enummt); ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); @@ -497,8 +496,7 @@ static void test_media_types(void) ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IPin_EnumMediaTypes(sink, &enummt); - todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); - if (hr == S_OK) IEnumMediaTypes_Release(enummt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); hr = IPin_EnumMediaTypes(source, &enummt); ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); @@ -824,8 +822,7 @@ static void test_connect_pin(void) ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n"); hr = IPin_EnumMediaTypes(sink, &enummt); - todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); - if (hr == S_OK) IEnumMediaTypes_Release(enummt); + ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); hr = IPin_EnumMediaTypes(source, &enummt); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL); @@ -1000,6 +997,14 @@ static void test_connect_pin(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(compare_media_types(&testsink.sink.pin.mt, &req_mt), "Media types didn't match.\n"); ok(compare_media_types(&testsource.source.pin.mt, &testsink.sink.pin.mt), "Media types didn't match.\n"); + + hr = IPin_EnumMediaTypes(sink, &enummt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(compare_media_types(pmt, testsink.sink_mt), "Media types didn't match.\n"); + IEnumMediaTypes_Release(enummt); + IFilterGraph2_Disconnect(graph, source); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);