Creating Source Nodes
A source node represents one stream from a media source. The source node must contain pointers to the media source, the presentation descriptor, and the stream descriptor.
To add a source node to a topology, do the following:
- Call MFCreateTopologyNode with the MF_TOPOLOGY_SOURCESTREAM_NODE flag to create the source node.
- Set the MF_TOPONODE_SOURCE attribute on the node, with a pointer to the media source.
- Set the MF_TOPONODE_PRESENTATION_DESCRIPTOR attribute on the node, with a pointer to the presentation descriptor of the media source.
- Set the MF_TOPONODE_STREAM_DESCRIPTOR attribute on the node, with a pointer to the stream descriptor for the stream.
- Call IMFTopology::AddNode to add the node to the topology.
The following example creates and initializes a source node.
// Add a source node to a topology. HRESULT AddSourceNode( IMFTopology *pTopology, // Topology. IMFMediaSource *pSource, // Media source. IMFPresentationDescriptor *pPD, // Presentation descriptor. IMFStreamDescriptor *pSD, // Stream descriptor. IMFTopologyNode **ppNode) // Receives the node pointer. { IMFTopologyNode *pNode = NULL; // Create the node. HRESULT hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &pNode); if (FAILED(hr)) { goto done; } // Set the attributes. hr = pNode->SetUnknown(MF_TOPONODE_SOURCE, pSource); if (FAILED(hr)) { goto done; } hr = pNode->SetUnknown(MF_TOPONODE_PRESENTATION_DESCRIPTOR, pPD); if (FAILED(hr)) { goto done; } hr = pNode->SetUnknown(MF_TOPONODE_STREAM_DESCRIPTOR, pSD); if (FAILED(hr)) { goto done; } // Add the node to the topology. hr = pTopology->AddNode(pNode); if (FAILED(hr)) { goto done; } // Return the pointer to the caller. *ppNode = pNode; (*ppNode)->AddRef(); done: SafeRelease(&pNode); return hr; }
Related topics
Show: