From: "Sergio Gómez Del Real" Subject: [PATCH 05/10] mf: Get max depth of branches in input topology in _Load(). Message-Id: <20200615014158.6836-5-sdelreal@codeweavers.com> Date: Sun, 14 Jun 2020 20:41:53 -0500 In-Reply-To: <20200615014158.6836-1-sdelreal@codeweavers.com> References: <20200615014158.6836-1-sdelreal@codeweavers.com> Signed-off-by: Sergio Gómez Del Real --- dlls/mf/topology.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/dlls/mf/topology.c b/dlls/mf/topology.c index 1f7e33f76b..03aa967d9e 100644 --- a/dlls/mf/topology.c +++ b/dlls/mf/topology.c @@ -1943,6 +1943,28 @@ struct topoloader_context unsigned int marker; }; +static int topology_loader_get_branch_depth(IMFTopologyNode *node, int level) +{ + IMFTopologyNode *current_node; + MF_TOPOLOGY_TYPE node_type; + static int max_level = 0; + + if (level > max_level) + max_level = level; + + IMFTopologyNode_GetNodeType(node, &node_type); + if (node_type == MF_TOPOLOGY_SOURCESTREAM_NODE || node_type == MF_TOPOLOGY_TRANSFORM_NODE) + { + int stream = 0; + DWORD input_stream; + + while (SUCCEEDED(IMFTopologyNode_GetOutput(node, stream++, ¤t_node, &input_stream))) + topology_loader_get_branch_depth(current_node, level + 1); + } + + return max_level; +} + static HRESULT topology_loader_clone_node(struct topoloader_context *context, IMFTopologyNode *node, IMFTopologyNode **ret, unsigned int marker) { @@ -1978,13 +2000,13 @@ static HRESULT WINAPI topology_loader_Load(IMFTopoLoader *iface, IMFTopology *in IMFTopology **output_topology, IMFTopology *current_topology) { struct topoloader_context context = { 0 }; + unsigned short i, max_branch_depth = 0; MF_TOPOLOGY_TYPE node_type; IMFTopologyNode *node; IMFStreamSink *sink; IUnknown *object; WORD count; HRESULT hr; - size_t i; FIXME("%p, %p, %p, %p.\n", iface, input_topology, output_topology, current_topology); @@ -2010,11 +2032,16 @@ static HRESULT WINAPI topology_loader_Load(IMFTopoLoader *iface, IMFTopology *in /* Clone and mark source nodes. */ if (node_type == MF_TOPOLOGY_SOURCESTREAM_NODE) { + unsigned int branch_depth; + if (FAILED(hr = topology_loader_clone_node(&context, node, NULL, 0))) { WARN("Failed to clone source node, hr %#x.\n", hr); continue; } + branch_depth = topology_loader_get_branch_depth(node, 0); + if (branch_depth > max_branch_depth) + max_branch_depth = branch_depth; } else if (node_type == MF_TOPOLOGY_OUTPUT_NODE) { -- 2.17.1