diff --git a/TODO.md b/TODO.md index b141f7a..e49989d 100644 --- a/TODO.md +++ b/TODO.md @@ -32,6 +32,10 @@ - [x] add a css class for pad (presence always or sometimes) - [ ] Add property to port to store some specific value(Caps) +### GStreamer: + +- [ ] Implement pipeline unit test + ### app - [x] check that a node accept to create a port on request (input/output) @@ -41,20 +45,19 @@ - [x] unable to connect a port which is already connected - [ ] Create a window for the video output - [ ] Add multiple graphviews with tabs. -- [ ] Property window in the main window +- [x] Property window in the main window - [ ] Connect the GPS status to GST status - [ ] Implement graph dot render/load - [ ] Implement a command line parser to graph -- [ ] Render the parse launch line in a message box -- [ ] Prevent to create a pad in an element without the template -- [ ] Check the pipeline validity -- [ ] Implement pipeline unit test +- [x] Render the parse launch line in a message box +- [x] Prevent to create a pad in an element without the template +- [x] Check the pipeline validity - [x] Save node position in XML - [x] Autosave the graph - [x] Logger in file/app all over the app - [ ] handle the caps setter element - [ ] Add probes on each pad to monitor the pipeline -- [ ] Display pad properties with tooltip hover +- [x] Display pad properties with tooltip hover - [ ] Render a media file - [ ] Offer compatible element to a pad (autorender) - [ ] Display tags/meta/message detected diff --git a/src/app.rs b/src/app.rs index 23a62d4..aa1658d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -537,7 +537,11 @@ impl GPSApp { move |_,_| { let app = upgrade_weak!(app_weak); let render_parse_launch = app.pipeline.borrow().render_gst_launch(&app.graphview.borrow()); - GPSUI::message::display_message_dialog(&render_parse_launch,gtk::MessageType::Info, |_| {}); + if app.pipeline.borrow().create_pipeline(&render_parse_launch).is_ok() { + GPSUI::message::display_message_dialog(&render_parse_launch,gtk::MessageType::Info, |_| {}); + } else { + GPSUI::message::display_error_dialog(false, &format!("Unable to render:\n\n{}", render_parse_launch)); + } } ); pop_menu.show(); diff --git a/src/gps/pipeline.rs b/src/gps/pipeline.rs index c0f8ed8..048f7a5 100644 --- a/src/gps/pipeline.rs +++ b/src/gps/pipeline.rs @@ -80,12 +80,34 @@ impl Pipeline { Ok(pipeline) } - pub fn create_pipeline(&self, description: &str) -> anyhow::Result<()> { + pub fn create_pipeline(&self, description: &str) -> anyhow::Result { GPS_INFO!("Creating pipeline {}", description); // Create pipeline from the description let pipeline = gst::parse_launch(&description.to_string())?; - if let Ok(pipeline) = pipeline.downcast::() { + let pipeline = pipeline.downcast::(); + /* start playing */ + if pipeline.is_err() { + GPS_ERROR!("Can not create a proper pipeline from gstreamer parse_launch"); + return Err(anyhow::anyhow!( + "Unable to create a pipeline from the given parse launch {" + )); + } + Ok(pipeline.unwrap()) + } + + pub fn start_pipeline( + &self, + graphview: &GraphView, + new_state: PipelineState, + ) -> anyhow::Result { + if self.state() == PipelineState::Stopped { + let pipeline = self + .create_pipeline(&self.render_gst_launch(graphview)) + .map_err(|err| { + GPS_ERROR!("Unable to start a pipeline: {}", err); + err + })?; let bus = pipeline.bus().expect("Pipeline had no bus"); let pipeline_weak = self.downgrade(); bus.add_watch_local(move |_bus, msg| { @@ -95,24 +117,6 @@ impl Pipeline { })?; *self.pipeline.borrow_mut() = Some(pipeline); - /* start playing */ - } else { - GPS_ERROR!("Can not create a proper pipeline from gstreamer parse_launch"); - } - Ok(()) - } - - pub fn start_pipeline( - &self, - graphview: &GraphView, - new_state: PipelineState, - ) -> anyhow::Result { - if self.state() == PipelineState::Stopped { - self.create_pipeline(&self.render_gst_launch(graphview)) - .map_err(|err| { - GPS_ERROR!("Unable to start a pipeline: {}", err); - err - })?; } self.set_state(new_state).map_err(|error| { diff --git a/src/ui/message.rs b/src/ui/message.rs index 539fdff..8741ef9 100644 --- a/src/ui/message.rs +++ b/src/ui/message.rs @@ -63,9 +63,13 @@ pub fn display_message_dialog( #[allow(dead_code)] pub fn display_error_dialog(fatal: bool, message: &str) { - display_message_dialog(message, gtk::MessageType::Error, move |app| { - if fatal { - app.quit(); - } - }); + display_message_dialog( + &format!("Error: {}", message), + gtk::MessageType::Error, + move |app| { + if fatal { + app.quit(); + } + }, + ); }