From: Rémi Bernon <rbernon@codeweavers.com> Based on patches from Conor McCarthy. --- dlls/mf/topology_loader.c | 76 ++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 16 deletions(-) diff --git a/dlls/mf/topology_loader.c b/dlls/mf/topology_loader.c index 4fcd7f9279b..be2a38fd987 100644 --- a/dlls/mf/topology_loader.c +++ b/dlls/mf/topology_loader.c @@ -581,41 +581,85 @@ HRESULT topology_node_init_media_type(IMFTopologyNode *node, DWORD stream, BOOL return hr; } -static HRESULT topology_branch_connect_down(IMFTopology *topology, enum connect_method method, - struct topology_branch *branch, IMFMediaType *up_type) +static HRESULT topology_branch_connect_direct(IMFTopology *topology, struct topology_branch *branch, IMFMediaType *up_type) { - HRESULT hr = MF_E_INVALIDMEDIATYPE; - IMFMediaType *down_type = NULL; + IMFMediaType *down_type, *type; DWORD flags; + HRESULT hr; - TRACE("topology %p, method %#x, branch %s, up_type %s.\n", topology, method, - debugstr_topology_branch(branch), debugstr_media_type(up_type)); - - get_first_supported_media_type(branch->down.handler, &down_type); + TRACE("topology %p, branch %s, up_type %s.\n", topology, debugstr_topology_branch(branch), + debugstr_media_type(up_type)); - if (method & CONNECT_DIRECT) + if (SUCCEEDED(hr = IMFMediaTypeHandler_GetCurrentMediaType(branch->down.handler, &down_type))) { - if (down_type && IMFMediaType_IsEqual(up_type, down_type, &flags) == S_OK) - { + if (IMFMediaType_IsEqual(up_type, down_type, &flags) == S_OK) hr = topology_branch_connect_with_type(topology, branch, up_type); - goto done; + else + { + TRACE("current type %s differs from up type %s, hr %#lx\n", debugstr_media_type(down_type), + debugstr_media_type(up_type), hr); + hr = MF_E_INVALIDMEDIATYPE; } + IMFMediaType_Release(down_type); + TRACE("returning %#lx\n", hr); + return hr; + } - if (SUCCEEDED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(branch->down.handler, up_type, NULL))) + IMFMediaType_AddRef((type = up_type)); + + if (hr == MF_E_NOT_INITIALIZED) + { + for (UINT i = 0; SUCCEEDED(hr = IMFMediaTypeHandler_GetMediaTypeByIndex(branch->down.handler, i, &down_type)); i++) { - hr = topology_branch_connect_with_type(topology, branch, up_type); - goto done; + if ((hr = IMFMediaType_IsEqual(up_type, down_type, &flags)) != S_OK) + TRACE("down type %s differs from up type %s, hr %#lx flags %#lx\n", debugstr_media_type(down_type), + debugstr_media_type(up_type), hr, flags); + else if (FAILED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(branch->down.handler, down_type, NULL))) + TRACE("down type %s not supported by downstream, hr %#lx\n", debugstr_media_type(down_type), hr); + else if (FAILED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(branch->up.handler, down_type, NULL))) + TRACE("down type %s not supported by upstream, hr %#lx\n", debugstr_media_type(down_type), hr); + else + { + TRACE("selecting down type %s\n", debugstr_media_type(down_type)); + IMFMediaType_Release(type); + type = down_type; + continue; + } + IMFMediaType_Release(down_type); } } + if (FAILED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(branch->down.handler, type, NULL))) + TRACE("type %s not supported by downstream, hr %#lx\n", debugstr_media_type(type), hr); + else + hr = topology_branch_connect_with_type(topology, branch, type); + + IMFMediaType_Release(type); + TRACE("returning %#lx\n", hr); + return hr; +} + +static HRESULT topology_branch_connect_down(IMFTopology *topology, enum connect_method method, + struct topology_branch *branch, IMFMediaType *up_type) +{ + HRESULT hr = MF_E_INVALIDMEDIATYPE; + IMFMediaType *down_type = NULL; + + TRACE("topology %p, method %#x, branch %s, up_type %s.\n", topology, method, + debugstr_topology_branch(branch), debugstr_media_type(up_type)); + + get_first_supported_media_type(branch->down.handler, &down_type); + + if (FAILED(hr) && (method & CONNECT_DIRECT)) + hr = topology_branch_connect_direct(topology, branch, up_type); if (FAILED(hr) && (method & CONNECT_CONVERTER)) hr = topology_branch_connect_indirect(topology, FALSE, branch, up_type, down_type); if (FAILED(hr) && (method & CONNECT_DECODER)) hr = topology_branch_connect_indirect(topology, TRUE, branch, up_type, down_type); -done: if (down_type) IMFMediaType_Release(down_type); + TRACE("returning %#lx\n", hr); return hr; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10596