Directed acyclic graph of MediaNodes connected by MediaLinks. More...
#include <mediagraph.h>


Public Member Functions | |
| MediaGraph (ObjectBase *parent=nullptr) | |
| Constructs an empty graph. | |
| virtual | ~MediaGraph () |
| Destructor. Deletes all owned nodes. | |
| Error | addNode (MediaNode *node) |
| Adds a node to the graph. Takes ownership. | |
| Error | removeNode (MediaNode *node) |
| Removes a node from the graph. | |
| const List< MediaNode * > & | nodes () const |
| Returns all nodes in the graph. | |
| MediaNode * | node (const String &name) const |
| Finds a node by name. | |
| MediaLink::Ptr | connect (MediaPort::Ptr output, MediaPort::Ptr input) |
| Connects an output port to an input port. | |
| MediaLink::Ptr | connect (MediaNode *source, int outputIndex, MediaNode *sink, int inputIndex) |
| Connects nodes by port index. | |
| MediaLink::Ptr | connect (MediaNode *source, const String &outputName, MediaNode *sink, const String &inputName) |
| Connects nodes by port name. | |
| Error | disconnect (MediaLink::Ptr link) |
| Disconnects a link. | |
| Error | disconnect (MediaPort::Ptr output, MediaPort::Ptr input) |
| Disconnects the link between two specific ports. | |
| const MediaLink::PtrList & | links () const |
| Returns all links in the graph. | |
| Error | validate () const |
| Validates the graph topology. | |
| List< MediaNode * > | topologicalSort () const |
| Returns nodes in topological order (dependencies first). | |
| List< MediaNode * > | sourceNodes () const |
| Returns nodes with no input connections (source nodes). | |
| List< MediaNode * > | sinkNodes () const |
| Returns nodes with no output connections (sink nodes). | |
| void | clear () |
| Removes all nodes and links. | |
Public Member Functions inherited from ObjectBase | |
| ObjectBase (ObjectBase *p=nullptr) | |
| Default ObjectBase constructor. | |
| virtual | ~ObjectBase () |
| Destructor. Emits aboutToDestroy, detaches from parent, and destroys children. | |
| ObjectBase * | parent () const |
| Returns the parent object, if one. nullptr if none. | |
| void | setParent (ObjectBase *p) |
| Sets the parent of this object. If the object already has a parent, it will be removed as a child from the old parent and added as a child to the new one. | |
| const ObjectBaseList & | childList () const |
| Returns a list of children of this object. | |
| template<typename... Args> | |
| int | registerSlot (Slot< Args... > *slot) |
| Registers a slot with this object and assigns it an ID. | |
| EventLoop * | eventLoop () const |
| Returns the EventLoop this object is affiliated with. | |
| void | moveToThread (EventLoop *loop) |
| Changes the EventLoop affinity of this object. | |
| int | startTimer (unsigned int intervalMs, bool singleShot=false) |
| Starts a timer on this object's EventLoop. | |
| void | stopTimer (int timerId) |
| Stops a timer previously started with startTimer(). | |
| template<typename... Args> | |
| PROMEKI_NAMESPACE_BEGIN void | connect (Signal< Args... > *signal, Slot< Args... > *slot) |
Additional Inherited Members | |
Public Types inherited from ObjectBase | |
| using | SlotVariantFunc = std::function< void(const VariantList &)> |
| Function type for invoking a slot with a list of Variants. | |
Static Public Member Functions inherited from ObjectBase | |
| static const MetaInfo & | metaInfo () |
| Returns the MetaInfo for the ObjectBase class. | |
| template<typename... Args> | |
| static void | connect (Signal< Args... > *signal, Slot< Args... > *slot) |
| connects a signal and slot together. This function assumes both the signal and slot exist in a ObjectBase or derived object | |
Public Attributes inherited from ObjectBase | |
| Signal< ObjectBase * > | aboutToDestroySignal = Signal< ObjectBase * >(this, aboutToDestroySignalName) |
Static Public Attributes inherited from ObjectBase | |
| static constexpr const char * | aboutToDestroySignalName = PROMEKI_STRINGIFY( aboutToDestroy ) "(" PROMEKI_STRINGIFY_ARGS( ObjectBase * ) ")" |
| static SignalMeta | aboutToDestroySignalMeta = SignalMeta(metaInfo(), aboutToDestroySignalName) |
Protected Member Functions inherited from ObjectBase | |
| ObjectBase * | signalSender () |
| Returns the ObjectBase that emitted the signal currently being handled. | |
| virtual void | event (Event *e) |
| Called by EventLoop to deliver events to this object. | |
| virtual void | timerEvent (TimerEvent *e) |
| Called when a timer fires for this object. | |
Directed acyclic graph of MediaNodes connected by MediaLinks.
MediaGraph manages the topology of a media processing pipeline. Nodes are added to the graph, then connected via their ports. The graph validates the topology (no cycles, compatible formats, all required ports connected) and provides topological ordering for processing.
An output port may be connected to multiple input ports (fan-out). The same frame is delivered to all connected links.
| MediaGraph::MediaGraph | ( | ObjectBase * | parent = nullptr | ) |
Constructs an empty graph.
| parent | Optional parent object. |
Adds a node to the graph. Takes ownership.
| node | The node to add. |
| void MediaGraph::clear | ( | ) |
Removes all nodes and links.
Deletes all owned nodes.
| MediaLink::Ptr MediaGraph::connect | ( | MediaNode * | source, |
| const String & | outputName, | ||
| MediaNode * | sink, | ||
| const String & | inputName | ||
| ) |
Connects nodes by port name.
| source | The source node. |
| outputName | Output port name on the source node. |
| sink | The sink node. |
| inputName | Input port name on the sink node. |
| MediaLink::Ptr MediaGraph::connect | ( | MediaNode * | source, |
| int | outputIndex, | ||
| MediaNode * | sink, | ||
| int | inputIndex | ||
| ) |
Connects nodes by port index.
| source | The source node. |
| outputIndex | Output port index on the source node. |
| sink | The sink node. |
| inputIndex | Input port index on the sink node. |
| MediaLink::Ptr MediaGraph::connect | ( | MediaPort::Ptr | output, |
| MediaPort::Ptr | input | ||
| ) |
Connects an output port to an input port.
| output | The source output port. |
| input | The sink input port. |
| Error MediaGraph::disconnect | ( | MediaLink::Ptr | link | ) |
| Error MediaGraph::disconnect | ( | MediaPort::Ptr | output, |
| MediaPort::Ptr | input | ||
| ) |
Disconnects the link between two specific ports.
| output | The output port. |
| input | The input port. |
Finds a node by name.
| name | The node name. |
Removes a node from the graph.
Disconnects all links involving this node first. The caller regains ownership and must delete the node.
| node | The node to remove. |
Returns nodes with no output connections (sink nodes).
Returns nodes with no input connections (source nodes).
Returns nodes in topological order (dependencies first).
Source nodes appear first, sink nodes last.
| Error MediaGraph::validate | ( | ) | const |
Validates the graph topology.
Checks for cycles (DAG requirement), format compatibility on all links, and that the graph is non-empty.