From e8259f3773e02a03feb52681ab1ac1ae870bc2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Mon, 10 Jan 2022 14:17:08 +0100 Subject: [PATCH] pipeline: fix multiple input pads Can now generate a pipeline with multiple input pads such as a compositor. --- src/pipeline.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/pipeline.rs b/src/pipeline.rs index ab1fd32..9d07743 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -372,12 +372,14 @@ impl Pipeline { &self, graphview: &GraphView, node: &Node, + elements: &mut HashMap, mut description: String, ) -> String { let unique_name = node.unique_name(); - description.push_str(&format!("{} name={}", node.name(), unique_name)); + description.push_str(&format!("{} name={} ", node.name(), unique_name)); + elements.insert(unique_name.clone(), unique_name.clone()); for (name, value) in node.properties().iter() { - description.push_str(&format!(" {}={}", name, value)); + description.push_str(&format!("{}={}", name, value)); } let ports = node.all_ports(PortDirection::Output); @@ -385,12 +387,17 @@ impl Pipeline { for port in ports { if let Some((_port_to, node_to)) = graphview.port_connected_to(port.id()) { if n_ports > 1 { - description.push_str(&format!(" {}. ! ", unique_name)); + description.push_str(&format!("{}. ! ", unique_name)); } else { - description.push_str(" ! "); + description.push_str("! "); } if let Some(node) = graphview.node(&node_to) { - description = self.process_node(graphview, &node, description.clone()); + if elements.contains_key(&node.unique_name()) { + description.push_str(&format!("{}. ", node.unique_name())); + } else { + description = + self.process_node(graphview, &node, elements, description.clone()); + } } } } @@ -398,10 +405,12 @@ impl Pipeline { } pub fn render_gst_launch(&self, graphview: &GraphView) -> String { - let nodes = graphview.all_nodes(NodeType::Source); + let source_nodes = graphview.all_nodes(NodeType::Source); + let mut elements: HashMap = HashMap::new(); let mut description = String::from(""); - for node in nodes { - description = self.process_node(graphview, &node, description.clone()); + for source_node in source_nodes { + description = + self.process_node(graphview, &source_node, &mut elements, description.clone()); } description }