qedit/samplegrabber: Correctly implement sample_grabber_sink_get_media_type().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-03-05 20:04:37 -06:00 committed by Alexandre Julliard
parent 1196f4dfe0
commit 8baf53bc07
2 changed files with 27 additions and 8 deletions

View File

@ -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;
}

View File

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