From: R��mi Bernon rbernon@codeweavers.com
--- dlls/mf/tests/mf.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index eccf4f51e4c..888cea8c4aa 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2550,6 +2550,15 @@ static void test_topology_loader(void) hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL); ok(hr == MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED, "Unexpected hr %#lx.\n", hr);
+ hr = IMFTopologyNode_SetObject(sink_node, NULL); + ok(hr == S_OK, "Failed to set object, hr %#lx.\n", hr); + + hr = IMFActivate_ShutdownObject(sink_activate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ref = IMFActivate_Release(sink_activate); + ok(ref == 0, "Release returned %ld\n", ref); + + hr = MFCreateMediaType(&input_type); ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr);
@@ -2575,9 +2584,6 @@ static void test_topology_loader(void) else handler.invalid_type = NULL;
- hr = MFCreateSampleGrabberSinkActivate(output_type, &test_grabber_callback, &sink_activate); - ok(hr == S_OK, "Failed to create grabber sink, hr %#lx.\n", hr); - init_source_node(source, test->source_method, src_node, 1, &input_type, test->current_input); init_sink_node(&stream_sink.IMFStreamSink_iface, test->sink_method, sink_node);
@@ -2733,11 +2739,6 @@ todo_wine { ok(hr == S_OK, "Failed to get attribute count, hr %#lx.\n", hr); ok(!count, "Unexpected count %u.\n", count);
- hr = IMFActivate_ShutdownObject(sink_activate); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ref = IMFActivate_Release(sink_activate); - ok(ref == 0, "Release returned %ld\n", ref); - winetest_pop_context(); }
From: R��mi Bernon rbernon@codeweavers.com
--- dlls/mf/tests/mf.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 888cea8c4aa..eb320af92fe 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -1305,6 +1305,10 @@ struct test_handler IMFMediaTypeHandler IMFMediaTypeHandler_iface; IMFMediaType *current_type; IMFMediaType *invalid_type; + + ULONG enum_count; + ULONG media_types_count; + IMFMediaType **media_types; };
static struct test_handler *impl_from_IMFMediaTypeHandler(IMFMediaTypeHandler *iface) @@ -1367,7 +1371,19 @@ static HRESULT WINAPI test_handler_GetMediaTypeCount(IMFMediaTypeHandler *iface, static HRESULT WINAPI test_handler_GetMediaTypeByIndex(IMFMediaTypeHandler *iface, DWORD index, IMFMediaType **type) { - todo_wine + struct test_handler *impl = impl_from_IMFMediaTypeHandler(iface); + + if (impl->media_types) + { + impl->enum_count++; + + if (index >= impl->media_types_count) + return MF_E_NO_MORE_TYPES; + + IMFMediaType_AddRef((*type = impl->media_types[index])); + return S_OK; + } + ok(0, "Unexpected call.\n"); return E_NOTIMPL; } @@ -1386,7 +1402,7 @@ static HRESULT WINAPI test_handler_GetCurrentMediaType(IMFMediaTypeHandler *ifac HRESULT hr;
if (!impl->current_type) - return E_NOTIMPL; + return impl->media_types ? MF_E_NOT_INITIALIZED : E_FAIL;
if (FAILED(hr = MFCreateMediaType(media_type))) return hr; @@ -2188,6 +2204,7 @@ enum loader_test_flags LOADER_SET_ENUMERATE_SOURCE_TYPES = 0x10, LOADER_NO_CURRENT_OUTPUT = 0x20, LOADER_SET_INVALID_INPUT = 0x40, + LOADER_SET_MEDIA_TYPES = 0x80, };
static void test_topology_loader(void) @@ -2434,6 +2451,12 @@ static void test_topology_loader(void) .expected_result = S_OK, .flags = LOADER_NO_CURRENT_OUTPUT | LOADER_SET_INVALID_INPUT | LOADER_EXPECTED_CONVERTER, }, + { + /* RGB32 -> Any Video, no current output type, refuse input type */ + .input_type = &video_i420_1280, .output_type = &video_video_processor_rgb32, .sink_method = -1, .source_method = -1, + .expected_result = S_OK, + .flags = LOADER_NO_CURRENT_OUTPUT | LOADER_SET_INVALID_INPUT | LOADER_SET_MEDIA_TYPES | LOADER_EXPECTED_CONVERTER, + }, };
IMFSampleGrabberSinkCallback test_grabber_callback = { &test_grabber_callback_vtbl }; @@ -2584,6 +2607,18 @@ static void test_topology_loader(void) else handler.invalid_type = NULL;
+ handler.enum_count = 0; + if (test->flags & LOADER_SET_MEDIA_TYPES) + { + handler.media_types_count = 1; + handler.media_types = &output_type; + } + else + { + handler.media_types_count = 0; + handler.media_types = NULL; + } + init_source_node(source, test->source_method, src_node, 1, &input_type, test->current_input); init_sink_node(&stream_sink.IMFStreamSink_iface, test->sink_method, sink_node);
@@ -2711,6 +2746,7 @@ todo_wine {
hr = IMFMediaType_Compare(output_type, (IMFAttributes *)media_type, MF_ATTRIBUTES_MATCH_OUR_ITEMS, &ret); ok(hr == S_OK, "Failed to compare media types, hr %#lx.\n", hr); + todo_wine_if(test->flags & LOADER_SET_MEDIA_TYPES) ok(ret, "Output type of last transform doesn't match sink node type.\n");
IMFTopologyNode_Release(mft_node); @@ -2739,6 +2775,12 @@ todo_wine { ok(hr == S_OK, "Failed to get attribute count, hr %#lx.\n", hr); ok(!count, "Unexpected count %u.\n", count);
+ if (test->flags & LOADER_SET_MEDIA_TYPES) + todo_wine + ok(handler.enum_count, "got %lu GetMediaTypeByIndex\n", handler.enum_count); + else + ok(!handler.enum_count, "got %lu GetMediaTypeByIndex\n", handler.enum_count); + winetest_pop_context(); }
@@ -4458,6 +4500,9 @@ if (SUCCEEDED(hr)) hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, count, &mediatype); ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr);
+ hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype); + ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, 0, &mediatype); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &rate);
From: R��mi Bernon rbernon@codeweavers.com
--- dlls/mf/tests/mf.c | 2 -- dlls/mf/topology_loader.c | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index eb320af92fe..af611fac814 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -2746,7 +2746,6 @@ todo_wine {
hr = IMFMediaType_Compare(output_type, (IMFAttributes *)media_type, MF_ATTRIBUTES_MATCH_OUR_ITEMS, &ret); ok(hr == S_OK, "Failed to compare media types, hr %#lx.\n", hr); - todo_wine_if(test->flags & LOADER_SET_MEDIA_TYPES) ok(ret, "Output type of last transform doesn't match sink node type.\n");
IMFTopologyNode_Release(mft_node); @@ -2776,7 +2775,6 @@ todo_wine { ok(!count, "Unexpected count %u.\n", count);
if (test->flags & LOADER_SET_MEDIA_TYPES) - todo_wine ok(handler.enum_count, "got %lu GetMediaTypeByIndex\n", handler.enum_count); else ok(!handler.enum_count, "got %lu GetMediaTypeByIndex\n", handler.enum_count); diff --git a/dlls/mf/topology_loader.c b/dlls/mf/topology_loader.c index eb652f526dd..ab694379237 100644 --- a/dlls/mf/topology_loader.c +++ b/dlls/mf/topology_loader.c @@ -335,6 +335,30 @@ static HRESULT topology_branch_connect_indirect(IMFTopology *topology, MF_CONNEC return hr; }
+static HRESULT topology_branch_get_current_type(IMFMediaTypeHandler *handler, IMFMediaType **type) +{ + IMFMediaType *media_type; + HRESULT hr; + DWORD i; + + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, type); + if (hr != MF_E_NOT_INITIALIZED) + return hr; + + for (i = 0; SUCCEEDED(hr = IMFMediaTypeHandler_GetMediaTypeByIndex(handler, i, &media_type)); i++) + { + if (SUCCEEDED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type, NULL))) + { + *type = media_type; + return hr; + } + + IMFMediaType_Release(media_type); + } + + return hr; +} + static HRESULT topology_branch_connect_down(IMFTopology *topology, MF_CONNECT_METHOD method_mask, struct topology_branch *branch, IMFMediaType *up_type) { @@ -353,7 +377,7 @@ static HRESULT topology_branch_connect_down(IMFTopology *topology, MF_CONNECT_ME if (FAILED(hr = topology_node_get_type_handler(branch->down.node, branch->down.stream, FALSE, &down_handler))) return hr;
- if (SUCCEEDED(hr = IMFMediaTypeHandler_GetCurrentMediaType(down_handler, &down_type)) + if (SUCCEEDED(hr = topology_branch_get_current_type(down_handler, &down_type)) && IMFMediaType_IsEqual(up_type, down_type, &flags) == S_OK) { TRACE("Connecting branch %s with current type %p.\n", debugstr_topology_branch(branch), up_type);
Anything I should do here? It's somehow related to https://gitlab.winehq.org/wine/wine/-/merge_requests/607, as I intend to add tests showing that setting the session topology should set media types, not the topology loader as Wine currently does.
No, looking good. Sorry for the delay.
This merge request was approved by Nikolay Sivov.