Skip to main content

Crate oximedia_graph

Crate oximedia_graph 

Source
Expand description

Filter graph pipeline for OxiMedia.

This crate provides a filter graph implementation for processing media data through a pipeline of operations. The graph connects nodes (filters) together to form a processing pipeline.

§Architecture

The filter graph consists of:

  • Nodes: Processing units that implement the node::Node trait
  • Ports: Connection points for data flow between nodes
  • Connections: Links between output and input ports
  • Frames: Data units passed through the graph

§Example

use oximedia_graph::graph::GraphBuilder;
use oximedia_graph::filters::video::{PassthroughFilter, NullSink};
use oximedia_graph::node::NodeId;
use oximedia_graph::port::PortId;

fn build_graph() -> Result<(), Box<dyn std::error::Error>> {
    // Create a simple graph: source -> sink
    let source = PassthroughFilter::new_source(NodeId(0), "source");
    let sink = NullSink::new(NodeId(0), "sink");

    let (builder, source_id) = GraphBuilder::new().add_node(Box::new(source));
    let (builder, sink_id) = builder.add_node(Box::new(sink));

    let graph = builder
        .connect(source_id, PortId(0), sink_id, PortId(0))?
        .build()?;

    assert_eq!(graph.node_count(), 2);
    Ok(())
}

build_graph().expect("graph construction should succeed");

§Node Types

Nodes are classified into three types:

  • Source: Entry points that produce frames (e.g., decoders)
  • Filter: Transform frames (e.g., scalers, color converters)
  • Sink: Consume frames (e.g., encoders, displays)

§Frame Flow

Frames flow through the graph following the connections. The graph automatically computes a topological order for execution to ensure correct data flow.

Re-exports§

pub use context::GraphContext;
pub use context::ProcessingStats;
pub use error::GraphError;
pub use error::GraphResult;
pub use frame::simd_copy_frame;
pub use frame::FilterFrame;
pub use frame::FramePool;
pub use frame::FramePoolConfig;
pub use frame::FrameRef;
pub use frame::SharedFrame;
pub use frame::ZeroCopyPort;
pub use graph::FilterGraph;
pub use graph::GraphBuilder;
pub use graph_stats::LatencyHistogram;
pub use graph_stats::NodeLatencyStats;
pub use lock_free_ring::spsc_channel;
pub use lock_free_ring::SpscConsumer;
pub use lock_free_ring::SpscProducer;
pub use lock_free_ring::SpscRingBuffer;
pub use node::Node;
pub use node::NodeConfig;
pub use node::NodeId;
pub use node::NodeState;
pub use node::NodeType;
pub use port::Connection;
pub use port::InputPort;
pub use port::OutputPort;
pub use port::PortFormat;
pub use port::PortId;
pub use port::PortType;
pub use processing_graph::RetryPolicy;
pub use topological::CycleError;
pub use topological::FastTopoSorter;

Modules§

async_exec
Async graph execution mode using tokio tasks for I/O-bound source/sink nodes.
context
Execution context for filter graphs.
cycle_detect
Cycle detection algorithms for directed graphs.
data_flow
Graph data flow management: buffered port queues with backpressure.
dependency_graph
Dependency analysis for graph nodes.
dsl
Graph DSL parser for describing filter pipelines as text.
edge_weight
Edge weight types for the filter graph pipeline.
error
Error types for the filter graph.
filters
Filter implementations for the filter graph.
frame
Frame types for passing through the filter graph.
graph
Filter graph builder and execution.
graph_evaluator
Graph evaluation: topological execution, cycle detection facade, dynamic editing, serialization helpers, conditional routing, gain node, and multi-input node.
graph_merge
Graph merging utilities for combining multiple filter graphs.
graph_partition
Graph partitioning for parallel execution.
graph_rewrite
Graph rewriting and transformation rules.
graph_stats
Graph statistics and complexity analysis for the filter graph pipeline.
graph_validation
Validation of filter/pipeline graphs.
hot_swap
Dynamic graph reconfiguration: hot-swap nodes without disrupting connections.
layout
Graph layout algorithms.
lock_free_ring
Lock-free single-producer single-consumer (SPSC) ring buffer.
metrics_graph
Graph metrics: diameter, clustering coefficient, and betweenness centrality approximation.
node
Node types for the filter graph.
node_cache
Caching system for graph node outputs.
node_priority
Node priority and scheduling weight assignment.
node_registry
Node registry for the filter graph pipeline.
optimization
Graph optimization passes.
pipeline_graph
Pipeline-centric graph for media processing.
port
Port types for connecting nodes in the filter graph.
port_buffer
Port buffering strategies for graph connections.
processing_graph
Media processing graph with nodes, edges, topological execution ordering, and retry-with-exponential-backoff for transient node failures.
profiling
Graph execution profiling.
scheduler
Graph execution scheduler.
serialize
Graph serialization: DOT format output, adjacency list, and edge list export.
subgraph
Subgraph extraction from a larger pipeline/filter graph.
topological
Topological sorting for directed acyclic graphs.
visualization
Graph visualization: layout computation and ASCII art rendering.