Commit 8baf53bc authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

qedit/samplegrabber: Correctly implement sample_grabber_sink_get_media_type().

parent 1196f4df
...@@ -511,12 +511,26 @@ static HRESULT sample_grabber_sink_get_media_type(struct strmbase_pin *iface, ...@@ -511,12 +511,26 @@ static HRESULT sample_grabber_sink_get_media_type(struct strmbase_pin *iface,
unsigned int index, AM_MEDIA_TYPE *mt) unsigned int index, AM_MEDIA_TYPE *mt)
{ {
SG_Impl *filter = impl_from_sink_pin(iface); SG_Impl *filter = impl_from_sink_pin(iface);
IEnumMediaTypes *enummt;
AM_MEDIA_TYPE *pmt;
HRESULT hr;
if (!filter->source.pin.peer)
return VFW_E_NOT_CONNECTED;
if (FAILED(hr = IPin_EnumMediaTypes(filter->source.pin.peer, &enummt)))
return hr;
if (!index) 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; return S_OK;
} }
IEnumMediaTypes_Release(enummt);
return VFW_S_NO_MORE_ITEMS; return VFW_S_NO_MORE_ITEMS;
} }
......
...@@ -482,8 +482,7 @@ static void test_media_types(void) ...@@ -482,8 +482,7 @@ static void test_media_types(void)
IBaseFilter_FindPin(filter, L"Out", &source); IBaseFilter_FindPin(filter, L"Out", &source);
hr = IPin_EnumMediaTypes(sink, &enummt); hr = IPin_EnumMediaTypes(sink, &enummt);
todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
if (hr == S_OK) IEnumMediaTypes_Release(enummt);
hr = IPin_EnumMediaTypes(source, &enummt); hr = IPin_EnumMediaTypes(source, &enummt);
ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
...@@ -497,8 +496,7 @@ static void test_media_types(void) ...@@ -497,8 +496,7 @@ static void test_media_types(void)
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EnumMediaTypes(sink, &enummt); hr = IPin_EnumMediaTypes(sink, &enummt);
todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
if (hr == S_OK) IEnumMediaTypes_Release(enummt);
hr = IPin_EnumMediaTypes(source, &enummt); hr = IPin_EnumMediaTypes(source, &enummt);
ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
...@@ -824,8 +822,7 @@ static void test_connect_pin(void) ...@@ -824,8 +822,7 @@ static void test_connect_pin(void)
ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n"); ok(compare_media_types(&mt, &req_mt), "Media types didn't match.\n");
hr = IPin_EnumMediaTypes(sink, &enummt); hr = IPin_EnumMediaTypes(sink, &enummt);
todo_wine ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr); ok(hr == VFW_E_NOT_CONNECTED, "Got hr %#x.\n", hr);
if (hr == S_OK) IEnumMediaTypes_Release(enummt);
hr = IPin_EnumMediaTypes(source, &enummt); hr = IPin_EnumMediaTypes(source, &enummt);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL); hr = IEnumMediaTypes_Next(enummt, 1, &pmt, NULL);
...@@ -1000,6 +997,14 @@ static void test_connect_pin(void) ...@@ -1000,6 +997,14 @@ static void test_connect_pin(void)
ok(hr == S_OK, "Got hr %#x.\n", hr); 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(&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"); 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, source);
IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface); IFilterGraph2_Disconnect(graph, &testsink.sink.pin.IPin_iface);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment