Signed-off-by: Sergio Gómez Del Real sdelreal@codeweavers.com --- dlls/mf/topology.c | 75 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/dlls/mf/topology.c b/dlls/mf/topology.c index c51a739aa8..802c26eab8 100644 --- a/dlls/mf/topology.c +++ b/dlls/mf/topology.c @@ -2016,6 +2016,79 @@ static HRESULT topology_loader_clone_node(struct topoloader_context *context, IM return hr; }
+static HRESULT topology_loader_connect_source(struct topoloader_context *context, IMFTopologyNode *source_node, + IMFTopologyNode *downstream_node, unsigned int input_index) +{ + IMFStreamDescriptor *strm_desc; + IMFMediaType **src_mediatypes; + UINT32 method, enum_src_types; + IMFMediaTypeHandler *mth_src; + struct topology_node *src; + IMFAttributes *attrs_src; + IMFMediaType *mtype_src; + DWORD num_media_types; + HRESULT hr; + int i; + + src = impl_from_IMFTopologyNode(source_node); + attrs_src = src->attributes; + if (FAILED(hr = IMFAttributes_GetUnknown(attrs_src, &MF_TOPONODE_STREAM_DESCRIPTOR, &IID_IMFStreamDescriptor, (void **)&strm_desc))) + return hr; + + if (FAILED(hr = IMFStreamDescriptor_GetMediaTypeHandler(strm_desc, &mth_src))) + { + IMFStreamDescriptor_Release(strm_desc); + return hr; + } + IMFStreamDescriptor_Release(strm_desc); + + if (FAILED(IMFTopology_GetUINT32(context->input_topology, &MF_TOPOLOGY_ENUMERATE_SOURCE_TYPES, &enum_src_types))) + enum_src_types = 0; + + if (!enum_src_types) + { + num_media_types = 1; + if (FAILED(hr = IMFMediaTypeHandler_GetCurrentMediaType(mth_src, &mtype_src))) + if (FAILED(hr = IMFMediaTypeHandler_GetMediaTypeByIndex(mth_src, 0, &mtype_src))) + { + IMFMediaTypeHandler_Release(mth_src); + return hr; + } + } + else + IMFMediaTypeHandler_GetMediaTypeCount(mth_src, &num_media_types); + + src_mediatypes = heap_alloc(sizeof(IMFMediaType *) * num_media_types); + if (!src_mediatypes) + { + if (!enum_src_types) + IMFMediaType_Release(mtype_src); + IMFMediaTypeHandler_Release(mth_src); + return E_OUTOFMEMORY; + } + + if (enum_src_types) + for (i = 0; i < num_media_types; i++) + IMFMediaTypeHandler_GetMediaTypeByIndex(mth_src, i, &src_mediatypes[i]); + else + src_mediatypes[0] = mtype_src; + + hr = IMFAttributes_GetUINT32(attrs_src, &MF_TOPONODE_CONNECT_METHOD, &method); + + for (i = 0; i < num_media_types; i++) + { + if (SUCCEEDED(hr = IMFMediaTypeHandler_SetCurrentMediaType(mth_src, src_mediatypes[i]))) + break; + } + + while (num_media_types--) + IMFMediaType_Release(src_mediatypes[num_media_types]); + IMFMediaTypeHandler_Release(mth_src); + heap_free(src_mediatypes); + + return hr; +} + static HRESULT topology_loader_resolve_nodes(struct topoloader_context *context) { IMFTopologyNode *node, *downstream_node, *orig_node, *orig_downstream_node; @@ -2042,7 +2115,7 @@ static HRESULT topology_loader_resolve_nodes(struct topoloader_context *context) switch (node_type) { case MF_TOPOLOGY_SOURCESTREAM_NODE: - hr = S_OK; + hr = topology_loader_connect_source(context, node, downstream_node, input_index); break; case MF_TOPOLOGY_TRANSFORM_NODE: hr = S_OK;