From 8e343024b577892bd4908304ded34b758579698d Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 15 Jul 2020 15:55:45 +0300 Subject: [PATCH] mf/topoloader: Switch to public interface for initial topology validation. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mf/topology.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/dlls/mf/topology.c b/dlls/mf/topology.c index abe66c45fd4..8522f569691 100644 --- a/dlls/mf/topology.c +++ b/dlls/mf/topology.c @@ -1936,38 +1936,50 @@ static ULONG WINAPI topology_loader_Release(IMFTopoLoader *iface) static HRESULT WINAPI topology_loader_Load(IMFTopoLoader *iface, IMFTopology *input_topology, IMFTopology **output_topology, IMFTopology *current_topology) { - struct topology *topology = unsafe_impl_from_IMFTopology(input_topology); + MF_TOPOLOGY_TYPE node_type; + IMFTopologyNode *node; + unsigned short i = 0; IMFStreamSink *sink; - HRESULT hr; - size_t i; + IUnknown *object; + HRESULT hr = E_FAIL; FIXME("%p, %p, %p, %p.\n", iface, input_topology, output_topology, current_topology); if (current_topology) FIXME("Current topology instance is ignored.\n"); - for (i = 0; i < topology->nodes.count; ++i) - { - struct topology_node *node = topology->nodes.nodes[i]; + /* Basic sanity checks for input topology: - switch (node->node_type) + - source nodes must have stream descriptor set; + - sink nodes must be resolved to stream sink objects; + */ + while (SUCCEEDED(IMFTopology_GetNode(input_topology, i++, &node))) + { + IMFTopologyNode_GetNodeType(node, &node_type); + + switch (node_type) { case MF_TOPOLOGY_OUTPUT_NODE: - if (node->object) + if (SUCCEEDED(hr = IMFTopologyNode_GetObject(node, &object))) { /* Sinks must be bound beforehand. */ - if (FAILED(IUnknown_QueryInterface(node->object, &IID_IMFStreamSink, (void **)&sink))) - return MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED; - IMFStreamSink_Release(sink); + if (FAILED(IUnknown_QueryInterface(object, &IID_IMFStreamSink, (void **)&sink))) + hr = MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED; + else if (sink) + IMFStreamSink_Release(sink); + IUnknown_Release(object); } break; case MF_TOPOLOGY_SOURCESTREAM_NODE: - if (FAILED(hr = IMFAttributes_GetItem(node->attributes, &MF_TOPONODE_STREAM_DESCRIPTOR, NULL))) - return hr; + hr = IMFTopologyNode_GetItem(node, &MF_TOPONODE_STREAM_DESCRIPTOR, NULL); break; default: ; } + + IMFTopologyNode_Release(node); + if (FAILED(hr)) + return hr; } if (FAILED(hr = MFCreateTopology(output_topology)))