mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-11-22 00:50:59 +00:00
pipeline: move render_gst to this module
Remove render_gst from graphview and define it in pipeline. This will allow to isolate properly the graphmanager module.
This commit is contained in:
parent
368a5b83a4
commit
ee6b57dfae
4 changed files with 56 additions and 44 deletions
3
TODO.md
3
TODO.md
|
@ -28,7 +28,7 @@ TODO:
|
|||
|
||||
## bugs
|
||||
|
||||
- [] crash with x11 on contextual menu
|
||||
- [x] crash with x11 on contextual menu
|
||||
- [] check that element exists before creating it on file load.
|
||||
- [] open multiple times dialog (About) prevent to close it.
|
||||
|
||||
|
@ -36,3 +36,4 @@ TODO:
|
|||
|
||||
[] remove useless code from graphview
|
||||
[] Move render to a specific module
|
||||
[x] Move GST render to a specific module
|
||||
|
|
16
src/app.rs
16
src/app.rs
|
@ -302,7 +302,13 @@ impl GPSApp {
|
|||
let graph_view = app.graphview.borrow();
|
||||
let pipeline = app.pipeline.borrow();
|
||||
if pipeline.state() == PipelineState::Stopped {
|
||||
pipeline.create_pipeline(&graph_view.render_gst()).expect("Unable to create the pipeline");
|
||||
if let Err(err) = pipeline.create_pipeline(&pipeline.render_gst_launch(&graph_view)) {
|
||||
GPSApp::show_error_dialog(
|
||||
false,
|
||||
format!("Unable to start a pipeline: {}", err)
|
||||
.as_str(),
|
||||
);
|
||||
}
|
||||
pipeline.set_state(PipelineState::Playing).expect("Unable to change state");
|
||||
} else if pipeline.state() == PipelineState::Paused {
|
||||
pipeline.set_state(PipelineState::Playing).expect("Unable to change state");
|
||||
|
@ -320,7 +326,13 @@ impl GPSApp {
|
|||
let graph_view = app.graphview.borrow();
|
||||
let pipeline = app.pipeline.borrow();
|
||||
if pipeline.state() == PipelineState::Stopped {
|
||||
pipeline.create_pipeline(&graph_view.render_gst()).expect("Unable to create the pipeline");
|
||||
if let Err(err) = pipeline.create_pipeline(&pipeline.render_gst_launch(&graph_view)) {
|
||||
GPSApp::show_error_dialog(
|
||||
false,
|
||||
format!("Unable to start a pipeline: {}", err)
|
||||
.as_str(),
|
||||
);
|
||||
}
|
||||
pipeline.set_state(PipelineState::Paused).expect("Unable to change state");
|
||||
} else if pipeline.state() == PipelineState::Paused {
|
||||
pipeline.set_state(PipelineState::Playing).expect("Unable to change state");
|
||||
|
|
|
@ -733,36 +733,6 @@ impl GraphView {
|
|||
None
|
||||
}
|
||||
|
||||
// * filesrc location=obama_last_speech.mp4 ! decodebin name=bin bin. ! audioconvert ! audioresample ! autoaudiosink bin. ! autovideosink
|
||||
|
||||
// Render graph methods
|
||||
//TO BE MOVED
|
||||
pub fn process_node(&self, node: &Node, mut description: String) -> String {
|
||||
let private = imp::GraphView::from_instance(self);
|
||||
let unique_name = node.unique_name();
|
||||
description.push_str(&format!("{} name={}", node.name(), unique_name));
|
||||
for (name, value) in node.properties().iter() {
|
||||
description.push_str(&format!(" {}={}", name, value));
|
||||
}
|
||||
println!("{}", description);
|
||||
|
||||
let ports = node.all_ports(PortDirection::Output);
|
||||
let n_ports = ports.len();
|
||||
for port in ports {
|
||||
if let Some((_port_to, node_to)) = self.port_connected_to(port.id()) {
|
||||
if n_ports > 1 {
|
||||
description.push_str(&format!(" {}. ! ", unique_name));
|
||||
} else {
|
||||
description.push_str(" ! ");
|
||||
}
|
||||
if let Some(node) = private.nodes.borrow().get(&node_to) {
|
||||
description = self.process_node(node, description.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
description
|
||||
}
|
||||
|
||||
pub fn unselect_all(&self) {
|
||||
self.unselect_nodes();
|
||||
self.unselect_links();
|
||||
|
@ -792,16 +762,6 @@ impl GraphView {
|
|||
self.queue_draw();
|
||||
}
|
||||
|
||||
//TO BE MOVED
|
||||
pub fn render_gst(&self) -> String {
|
||||
let nodes = self.all_nodes(NodeType::Source);
|
||||
let mut description = String::from("");
|
||||
for node in nodes {
|
||||
description = self.process_node(&node, description.clone());
|
||||
}
|
||||
description
|
||||
}
|
||||
|
||||
pub fn render_xml(&self, filename: &str) -> anyhow::Result<(), Box<dyn error::Error>> {
|
||||
let mut file = File::create(filename).unwrap();
|
||||
let mut writer = EmitterConfig::new()
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
use crate::app::GPSApp;
|
||||
use crate::graphmanager::NodeType;
|
||||
use crate::graphmanager::{GraphView, Node, NodeType, PortDirection};
|
||||
use gst::prelude::*;
|
||||
use gstreamer as gst;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
@ -363,6 +363,45 @@ impl Pipeline {
|
|||
Err(_e) => false,
|
||||
}
|
||||
}
|
||||
|
||||
// Render graph methods
|
||||
pub fn process_node(
|
||||
&self,
|
||||
graphview: &GraphView,
|
||||
node: &Node,
|
||||
mut description: String,
|
||||
) -> String {
|
||||
let unique_name = node.unique_name();
|
||||
description.push_str(&format!("{} name={}", node.name(), unique_name));
|
||||
for (name, value) in node.properties().iter() {
|
||||
description.push_str(&format!(" {}={}", name, value));
|
||||
}
|
||||
|
||||
let ports = node.all_ports(PortDirection::Output);
|
||||
let n_ports = ports.len();
|
||||
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));
|
||||
} else {
|
||||
description.push_str(" ! ");
|
||||
}
|
||||
if let Some(node) = graphview.node(&node_to) {
|
||||
description = self.process_node(graphview, &node, description.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
description
|
||||
}
|
||||
|
||||
pub fn render_gst_launch(&self, graphview: &GraphView) -> String {
|
||||
let nodes = graphview.all_nodes(NodeType::Source);
|
||||
let mut description = String::from("");
|
||||
for node in nodes {
|
||||
description = self.process_node(graphview, &node, description.clone());
|
||||
}
|
||||
description
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for PipelineInner {
|
||||
|
|
Loading…
Reference in a new issue