[PATCH 0/4] MR10717: mf/topology_loader: Always call IsMediaTypeSupported() on downstream when connecting a branch.
Split from !10645 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10717
From: Conor McCarthy <cmccarthy@codeweavers.com> --- dlls/mf/tests/topology.c | 74 +++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/dlls/mf/tests/topology.c b/dlls/mf/tests/topology.c index 6d433b3e1c2..57178486fd5 100644 --- a/dlls/mf/tests/topology.c +++ b/dlls/mf/tests/topology.c @@ -2446,6 +2446,19 @@ static void test_topology_loader(void) ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1), ATTR_UINT32(MF_MT_INTERLACE_MODE, 7), }; + static const media_type_desc video_yuy2_1280 = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_YUY2), + ATTR_RATIO(MF_MT_FRAME_RATE, 30000, 1001), + ATTR_RATIO(MF_MT_FRAME_SIZE, 1280, 720), + ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1), + ATTR_UINT32(MF_MT_SAMPLE_SIZE, 1280 * 720 * 3 / 2), + ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1), + ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 1280), + ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1), + ATTR_UINT32(MF_MT_INTERLACE_MODE, 7), + }; static const media_type_desc video_dummy = { ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), @@ -2455,7 +2468,7 @@ static void test_topology_loader(void) { const media_type_desc *input_types[2]; const media_type_desc *output_types[2]; - const media_type_desc *mft_input_type; + const media_type_desc *mft_input_types[3]; const media_type_desc *mft_output_types[5]; const media_type_desc *current_input; const media_type_desc *mft_current_output; @@ -2464,6 +2477,7 @@ static void test_topology_loader(void) MF_CONNECT_METHOD source_method; MF_CONNECT_METHOD sink_method; HRESULT expected_result; + unsigned int mft_current_input_1based_index; unsigned int expected_output_index; unsigned int flags; GUID decoder_class; @@ -2681,17 +2695,17 @@ static void test_topology_loader(void) .flags = LOADER_ADD_TEST_MFT | LOADER_NO_CURRENT_OUTPUT, }, { - /* MP3 -> PCM, different enumerated bps, add test MFT, configure MFT */ + /* MP3 -> PCM, different enumerated bps, add test MFT */ .input_types = {&audio_mp3_44100}, .output_types = {&audio_pcm_48000}, .sink_method = MF_CONNECT_DIRECT, .source_method = MF_CONNECT_DIRECT, - .mft_input_type = &audio_pcm_44100, .mft_output_types = {&audio_pcm_48000}, + .mft_input_types = {&audio_pcm_44100}, .mft_output_types = {&audio_pcm_48000}, .decoded_type = &audio_pcm_44100, .expected_result = S_OK, .decoder_class = CLSID_CMP3DecMediaObject, .flags = LOADER_ADD_TEST_MFT | LOADER_EXPECT_MFT_INPUT_ENUMERATED, }, { - /* MP3 -> PCM, different enumerated bps, add incompatible test MFT, configure MFT */ + /* MP3 -> PCM, different enumerated bps, add incompatible test MFT */ .input_types = {&audio_mp3_44100}, .output_types = {&audio_pcm_48000}, .sink_method = MF_CONNECT_DIRECT, .source_method = MF_CONNECT_DIRECT, - .mft_input_type = &audio_aac_44100, .mft_output_types = {&audio_pcm_48000}, + .mft_input_types = {&audio_aac_44100}, .mft_output_types = {&audio_pcm_48000}, .expected_result = MF_E_TOPO_CODEC_NOT_FOUND, .flags = LOADER_ADD_TEST_MFT | LOADER_EXPECT_MFT_INPUT_ENUMERATED, }, @@ -2822,24 +2836,33 @@ static void test_topology_loader(void) { /* H264 -> RGB32, Color Convert media type, add test MFT */ .input_types = {&video_h264_1280}, .output_types = {&video_color_convert_1280_rgb32}, .sink_method = -1, .source_method = -1, - .mft_input_type = &video_color_convert_1280_rgb32, .mft_output_types = {&video_color_convert_1280_rgb32}, + .mft_input_types = {&video_color_convert_1280_rgb32}, .mft_output_types = {&video_color_convert_1280_rgb32}, .expected_result = MF_E_TOPO_CODEC_NOT_FOUND, .decoder_class = CLSID_CMSH264DecoderMFT, .flags = LOADER_ADD_TEST_MFT | LOADER_EXPECT_MFT_INPUT_ENUMERATED, }, { /* H264 -> RGB32, Video Processor media type, add test MFT */ .input_types = {&video_h264_1280}, .output_types = {&video_video_processor_1280_rgb32}, .sink_method = -1, .source_method = -1, - .mft_input_type = &video_video_processor_1280_rgb32, .mft_output_types = {&video_video_processor_1280_rgb32}, + .mft_input_types = {&video_video_processor_1280_rgb32}, .mft_output_types = {&video_video_processor_1280_rgb32}, .expected_result = S_OK, .decoder_class = CLSID_CMSH264DecoderMFT, .converter_class = CLSID_CColorConvertDMO, .flags = LOADER_ADD_TEST_MFT | LOADER_TEST_MFT_EXPECT_CONVERTER | LOADER_EXPECT_MFT_INPUT_ENUMERATED, }, { /* H264 -> NV12, add test MFT */ .input_types = {&video_h264_1280}, .output_types = {&video_nv12_1280}, .sink_method = -1, .source_method = -1, - .mft_input_type = &video_nv12_1280, .mft_output_types = {&video_nv12_1280}, + .mft_input_types = {&video_nv12_1280}, .mft_output_types = {&video_nv12_1280}, .expected_result = S_OK, .decoder_class = CLSID_CMSH264DecoderMFT, .flags = LOADER_ADD_TEST_MFT | LOADER_EXPECT_MFT_INPUT_ENUMERATED, }, + + { + /* NV12 -> NV12, add test MFT, set unsupported MFT input */ + .input_types = {&video_nv12_1280}, .output_types = {&video_nv12_1280}, .sink_method = MF_CONNECT_DIRECT, .source_method = -1, + .mft_input_types = {&video_nv12_1280, &video_yuy2_1280}, .mft_output_types = {&video_nv12_1280}, + .mft_current_input_1based_index = 2, + .expected_result = S_OK, + .flags = LOADER_ADD_TEST_MFT, + }, }; IMFTopologyNode *src_node, *sink_node, *src_node2, *sink_node2, *mft_node; @@ -2987,7 +3010,7 @@ static void test_topology_loader(void) const struct loader_test *test = &loader_tests[i]; struct test_transform *test_transform = NULL; IMFMediaType *mft_output_types[4] = {0}; - IMFMediaType *mft_input_type = NULL; + IMFMediaType *mft_input_types[2] = {0}; winetest_push_context("%u", i); @@ -3042,21 +3065,25 @@ static void test_topology_loader(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); if (test->flags & LOADER_ADD_TEST_MFT) { - mft_input_type = input_types[0]; + UINT input_count, output_count; - if (test->mft_input_type) + for (input_count = 0; test->mft_input_types[input_count]; ++input_count) { - hr = MFCreateMediaType(&mft_input_type); + hr = MFCreateMediaType(&mft_input_types[input_count]); ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); - init_media_type(mft_input_type, *test->mft_input_type, -1); + init_media_type(mft_input_types[input_count], *test->mft_input_types[input_count], -1); } - for (j = 0; test->mft_output_types[j]; ++j) + if (!input_count) + IMFMediaType_AddRef(mft_input_types[input_count++] = input_types[0]); + + for (output_count = 0; test->mft_output_types[output_count]; ++output_count) { - hr = MFCreateMediaType(&mft_output_types[j]); + hr = MFCreateMediaType(&mft_output_types[output_count]); ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); - init_media_type(mft_output_types[j], *test->mft_output_types[j], -1); + init_media_type(mft_output_types[output_count], *test->mft_output_types[output_count], -1); } - test_transform_create(1, &mft_input_type, j, mft_output_types, FALSE, &transform); + + test_transform_create(input_count, mft_input_types, output_count, mft_output_types, FALSE, &transform); test_transform = test_transform_from_IMFTransform(transform); IMFTransform_AddRef(transform); } @@ -3082,7 +3109,13 @@ static void test_topology_loader(void) } else { - IMFTransform_SetInputType(transform, 0, NULL, 0); + if (test->mft_current_input_1based_index) + { + hr = IMFTransform_SetInputType(transform, 0, mft_input_types[test->mft_current_input_1based_index - 1], 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + } + else + IMFTransform_SetInputType(transform, 0, NULL, 0); IMFTransform_SetOutputType(transform, 0, NULL, 0); } IMFTransform_Release(transform); @@ -3176,6 +3209,7 @@ todo_wine { hr = IMFTopology_GetNodeCount(full_topology, &node_count); ok(hr == S_OK, "Failed to get node count, hr %#lx.\n", hr); + todo_wine_if(test->mft_current_input_1based_index) ok(node_count == count, "Unexpected node count %u.\n", node_count); hr = IMFTopologyNode_GetTopoNodeID(src_node, &node_id); @@ -3396,8 +3430,8 @@ todo_wine { ok(ref == 0, "Release returned %ld\n", ref); ref = IMFStreamDescriptor_Release(sd); ok(ref == 0, "Release returned %ld\n", ref); - if (mft_input_type && test->mft_input_type) - IMFMediaType_Release(mft_input_type); + for (j = 0; j < ARRAY_SIZE(mft_input_types) && mft_input_types[j]; ++j) + IMFMediaType_Release(mft_input_types[j]); for (j = 0; j < ARRAY_SIZE(mft_output_types) && mft_output_types[j]; ++j) IMFMediaType_Release(mft_output_types[j]); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10717
From: Conor McCarthy <cmccarthy@codeweavers.com> This may be the rule for indirect connection too, but it's not clear if we need it. --- dlls/mf/tests/topology.c | 1 - dlls/mf/topology_loader.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/mf/tests/topology.c b/dlls/mf/tests/topology.c index 57178486fd5..74529a53f3d 100644 --- a/dlls/mf/tests/topology.c +++ b/dlls/mf/tests/topology.c @@ -3209,7 +3209,6 @@ todo_wine { hr = IMFTopology_GetNodeCount(full_topology, &node_count); ok(hr == S_OK, "Failed to get node count, hr %#lx.\n", hr); - todo_wine_if(test->mft_current_input_1based_index) ok(node_count == count, "Unexpected node count %u.\n", node_count); hr = IMFTopologyNode_GetTopoNodeID(src_node, &node_id); diff --git a/dlls/mf/topology_loader.c b/dlls/mf/topology_loader.c index 9cf4ee0b28c..c24f8bd72cb 100644 --- a/dlls/mf/topology_loader.c +++ b/dlls/mf/topology_loader.c @@ -599,7 +599,8 @@ static HRESULT topology_branch_connect_direct(IMFTopology *topology, struct topo if (SUCCEEDED(hr = IMFMediaTypeHandler_GetCurrentMediaType(branch->down.handler, &down_type))) { - if (IMFMediaType_IsEqual(up_type, down_type, &flags) == S_OK) + if (topology_node_get_type(branch->down.node) != MF_TOPOLOGY_OUTPUT_NODE + || IMFMediaType_IsEqual(up_type, down_type, &flags) == S_OK) hr = topology_branch_connect_with_type(topology, branch, up_type); else { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10717
From: Conor McCarthy <cmccarthy@codeweavers.com> --- dlls/mf/tests/topology.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dlls/mf/tests/topology.c b/dlls/mf/tests/topology.c index 74529a53f3d..f8dc5d62d6c 100644 --- a/dlls/mf/tests/topology.c +++ b/dlls/mf/tests/topology.c @@ -1739,6 +1739,7 @@ struct test_handler ULONG media_types_count; IMFMediaType **media_types; BOOL enum_complete; + BOOL is_supported_called; }; static struct test_handler *impl_from_IMFMediaTypeHandler(IMFMediaTypeHandler *iface) @@ -1776,6 +1777,8 @@ static HRESULT WINAPI test_handler_IsMediaTypeSupported(IMFMediaTypeHandler *ifa BOOL result; ULONG i; + impl->is_supported_called = TRUE; + if (out_type) *out_type = NULL; @@ -3157,6 +3160,8 @@ static void test_topology_loader(void) ok(hr == S_OK, "Failed to get attribute count, hr %#lx.\n", hr); ok(!count, "Unexpected count %u.\n", count); + handler.is_supported_called = FALSE; + if (test->flags & LOADER_SET_ENUMERATE_SOURCE_TYPES) IMFTopology_SetUINT32(topology, &MF_TOPOLOGY_ENUMERATE_SOURCE_TYPES, 1); if (test->flags & LOADER_SET_XVP_FOR_PLAYBACK) @@ -3234,6 +3239,9 @@ todo_wine { if (hr == S_OK) IMFMediaType_Release(media_type); + todo_wine_if(!handler.is_supported_called) + ok(handler.is_supported_called, "Sink input support not checked.\n"); + if (!IsEqualGUID(&test->decoder_class, &GUID_NULL)) { GUID class_id; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10717
From: Conor McCarthy <cmccarthy@codeweavers.com> --- dlls/mf/tests/topology.c | 4 +--- dlls/mf/topology_loader.c | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dlls/mf/tests/topology.c b/dlls/mf/tests/topology.c index f8dc5d62d6c..2270d7d6b0e 100644 --- a/dlls/mf/tests/topology.c +++ b/dlls/mf/tests/topology.c @@ -2498,7 +2498,6 @@ static void test_topology_loader(void) .input_types = {&audio_pcm_44100}, .output_types = {&audio_pcm_44100}, .sink_method = MF_CONNECT_DIRECT, .source_method = -1, .current_input = &audio_pcm_44100_incomplete, .expected_result = MF_E_INVALIDMEDIATYPE, - .flags = LOADER_TODO, }, { /* PCM -> PCM, same enumerated bps, different current bps */ @@ -2525,7 +2524,7 @@ static void test_topology_loader(void) .input_types = {&audio_pcm_44100_incomplete}, .output_types = {&audio_pcm_44100}, .sink_method = MF_CONNECT_DIRECT, .source_method = -1, .current_input = &audio_pcm_44100, .expected_result = MF_E_NO_MORE_TYPES, - .flags = LOADER_SET_ENUMERATE_SOURCE_TYPES | LOADER_TODO, + .flags = LOADER_SET_ENUMERATE_SOURCE_TYPES, }, { @@ -3239,7 +3238,6 @@ todo_wine { if (hr == S_OK) IMFMediaType_Release(media_type); - todo_wine_if(!handler.is_supported_called) ok(handler.is_supported_called, "Sink input support not checked.\n"); if (!IsEqualGUID(&test->decoder_class, &GUID_NULL)) diff --git a/dlls/mf/topology_loader.c b/dlls/mf/topology_loader.c index c24f8bd72cb..08557d354a8 100644 --- a/dlls/mf/topology_loader.c +++ b/dlls/mf/topology_loader.c @@ -442,7 +442,8 @@ static HRESULT topology_branch_connect_with_type(IMFTopology *topology, struct t } if (topology_node_get_type(branch->down.node) == MF_TOPOLOGY_TRANSFORM_NODE - && FAILED(hr = IMFMediaTypeHandler_SetCurrentMediaType(branch->down.handler, type))) + ? FAILED(hr = IMFMediaTypeHandler_SetCurrentMediaType(branch->down.handler, type)) + : FAILED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(branch->down.handler, type, NULL))) { WARN("Failed to set transform node media type, hr %#lx\n", hr); return hr; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10717
participants (2)
-
Conor McCarthy -
Rémi Bernon (@rbernon)