Rémi Bernon : mf: Allow resolving topology with missing downstream current type.
Alexandre Julliard
julliard at winehq.org
Tue Aug 16 16:00:59 CDT 2022
Module: wine
Branch: master
Commit: 346c2d8d7cfb4cd8e5d510b232c0938ad0fee574
URL: https://gitlab.winehq.org/wine/wine/-/commit/346c2d8d7cfb4cd8e5d510b232c0938ad0fee574
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Thu Aug 11 13:49:44 2022 +0200
mf: Allow resolving topology with missing downstream current type.
And without enumerating the downstream types either.
---
dlls/mf/tests/mf.c | 6 ++++--
dlls/mf/topology_loader.c | 53 +++++++++++++++++++++++------------------------
2 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c
index 5d95b092002..dd61a10fc77 100644
--- a/dlls/mf/tests/mf.c
+++ b/dlls/mf/tests/mf.c
@@ -1374,8 +1374,10 @@ static HRESULT WINAPI test_handler_GetMediaTypeByIndex(IMFMediaTypeHandler *ifac
static HRESULT WINAPI test_handler_SetCurrentMediaType(IMFMediaTypeHandler *iface, IMFMediaType *media_type)
{
+ /* FIXME: Wine sets downstream media type when resolving topology, native doesn't */
+ todo_wine
ok(0, "Unexpected call.\n");
- return E_NOTIMPL;
+ return S_OK;
}
static HRESULT WINAPI test_handler_GetCurrentMediaType(IMFMediaTypeHandler *iface, IMFMediaType **media_type)
@@ -2424,7 +2426,7 @@ static void test_topology_loader(void)
/* RGB32 -> Any Video, no current output type */
.input_type = &video_i420_1280, .output_type = &video_dummy, .sink_method = -1, .source_method = -1,
.expected_result = S_OK,
- .flags = LOADER_NO_CURRENT_OUTPUT | LOADER_TODO,
+ .flags = LOADER_NO_CURRENT_OUTPUT,
},
{
/* RGB32 -> Any Video, no current output type, refuse input type */
diff --git a/dlls/mf/topology_loader.c b/dlls/mf/topology_loader.c
index 08ee7922094..09fb9322261 100644
--- a/dlls/mf/topology_loader.c
+++ b/dlls/mf/topology_loader.c
@@ -253,7 +253,6 @@ static HRESULT topology_branch_connect_indirect(IMFTopology *topology, MF_CONNEC
IMFTopologyNode *node;
unsigned int i, count;
GUID category, guid;
- DWORD flags;
HRESULT hr;
TRACE("topology %p, method_mask %#x, branch %s, up_type %p, down_type %p.\n",
@@ -263,13 +262,15 @@ static HRESULT topology_branch_connect_indirect(IMFTopology *topology, MF_CONNEC
return hr;
if (FAILED(hr = IMFMediaType_GetGUID(up_type, &MF_MT_SUBTYPE, &input_info.guidSubtype)))
return hr;
- if (FAILED(hr = IMFMediaType_GetMajorType(down_type, &output_info.guidMajorType)))
- return hr;
- if (FAILED(hr = IMFMediaType_GetGUID(down_type, &MF_MT_SUBTYPE, &output_info.guidSubtype)))
- return hr;
- if (FAILED(hr = IMFMediaType_IsEqual(up_type, down_type, &flags))
- || !(flags & MF_MEDIATYPE_EQUAL_MAJOR_TYPES))
- return MF_E_INVALIDMEDIATYPE;
+ if (!down_type)
+ output_info = input_info;
+ else
+ {
+ if (FAILED(hr = IMFMediaType_GetMajorType(down_type, &output_info.guidMajorType)))
+ return hr;
+ if (FAILED(hr = IMFMediaType_GetGUID(down_type, &MF_MT_SUBTYPE, &output_info.guidSubtype)))
+ return hr;
+ }
if (IsEqualGUID(&input_info.guidMajorType, &MFMediaType_Audio))
category = decoder ? MFT_CATEGORY_AUDIO_DECODER : MFT_CATEGORY_AUDIO_EFFECT;
@@ -300,10 +301,13 @@ static HRESULT topology_branch_connect_indirect(IMFTopology *topology, MF_CONNEC
IMFTopologyNode_SetGUID(node, &MF_TOPONODE_TRANSFORM_OBJECTID, &guid);
hr = topology_branch_connect_down(topology, MF_CONNECT_DIRECT, &up_branch, up_type);
- if (SUCCEEDED(hr))
- hr = topology_branch_fill_media_type(up_type, down_type);
- if (SUCCEEDED(hr))
- hr = IMFTransform_SetOutputType(transform, 0, down_type, 0);
+ if (down_type)
+ {
+ if (SUCCEEDED(hr))
+ hr = topology_branch_fill_media_type(up_type, down_type);
+ if (SUCCEEDED(hr))
+ hr = IMFTransform_SetOutputType(transform, 0, down_type, 0);
+ }
IMFTransform_Release(transform);
if (SUCCEEDED(hr))
@@ -328,8 +332,8 @@ static HRESULT topology_branch_connect_down(IMFTopology *topology, MF_CONNECT_ME
struct topology_branch *branch, IMFMediaType *up_type)
{
IMFMediaTypeHandler *down_handler;
+ IMFMediaType *down_type = NULL;
MF_CONNECT_METHOD method;
- IMFMediaType *down_type;
DWORD flags;
HRESULT hr;
@@ -346,27 +350,18 @@ static HRESULT topology_branch_connect_down(IMFTopology *topology, MF_CONNECT_ME
&& IMFMediaType_IsEqual(up_type, down_type, &flags) == S_OK)
{
TRACE("Connecting branch %s with current type %p.\n", debugstr_topology_branch(branch), up_type);
- IMFMediaTypeHandler_Release(down_handler);
- IMFMediaType_Release(down_type);
-
- return IMFTopologyNode_ConnectOutput(branch->up.node, branch->up.stream, branch->down.node, branch->down.stream);
+ hr = IMFTopologyNode_ConnectOutput(branch->up.node, branch->up.stream, branch->down.node, branch->down.stream);
+ goto done;
}
- if (FAILED(hr) && FAILED(hr = IMFMediaTypeHandler_GetMediaTypeByIndex(down_handler, 0, &down_type)))
- return hr;
-
if (SUCCEEDED(hr = IMFMediaTypeHandler_IsMediaTypeSupported(down_handler, up_type, NULL))
&& SUCCEEDED(hr = IMFMediaTypeHandler_SetCurrentMediaType(down_handler, up_type)))
{
TRACE("Connected branch %s with upstream type %p.\n", debugstr_topology_branch(branch), up_type);
- IMFMediaTypeHandler_Release(down_handler);
- IMFMediaType_Release(down_type);
-
- return IMFTopologyNode_ConnectOutput(branch->up.node, branch->up.stream, branch->down.node, branch->down.stream);
+ hr = IMFTopologyNode_ConnectOutput(branch->up.node, branch->up.stream, branch->down.node, branch->down.stream);
+ goto done;
}
- IMFMediaTypeHandler_Release(down_handler);
-
if (FAILED(hr) && (method & method_mask & MF_CONNECT_ALLOW_CONVERTER) == MF_CONNECT_ALLOW_CONVERTER)
hr = topology_branch_connect_indirect(topology, MF_CONNECT_ALLOW_CONVERTER,
branch, up_type, down_type);
@@ -375,7 +370,11 @@ static HRESULT topology_branch_connect_down(IMFTopology *topology, MF_CONNECT_ME
hr = topology_branch_connect_indirect(topology, MF_CONNECT_ALLOW_DECODER,
branch, up_type, down_type);
- IMFMediaType_Release(down_type);
+done:
+ if (down_type)
+ IMFMediaType_Release(down_type);
+ IMFMediaTypeHandler_Release(down_handler);
+
return hr;
}
More information about the wine-cvs
mailing list