From ce28fed070470ae46234f9498331d21adfdb1bf5 Mon Sep 17 00:00:00 2001 From: fengalin Date: Mon, 29 Jan 2018 15:26:01 +0100 Subject: [PATCH] Tutorials: message handlers: invoke generic Message method from the concrete message Generic methods for events, messages and queries can now be invoked from the concrete type. --- tutorials/src/bin/basic-tutorial-1.rs | 2 +- tutorials/src/bin/basic-tutorial-2.rs | 2 +- tutorials/src/bin/basic-tutorial-3.rs | 10 +++++----- tutorials/src/bin/basic-tutorial-4.rs | 8 ++++---- tutorials/src/bin/basic-tutorial-5.rs | 12 ++++++------ tutorials/src/bin/basic-tutorial-6.rs | 10 +++++----- tutorials/src/bin/basic-tutorial-7.rs | 2 +- tutorials/src/bin/basic-tutorial-8.rs | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tutorials/src/bin/basic-tutorial-1.rs b/tutorials/src/bin/basic-tutorial-1.rs index 0de814a77..2bbee8999 100644 --- a/tutorials/src/bin/basic-tutorial-1.rs +++ b/tutorials/src/bin/basic-tutorial-1.rs @@ -27,7 +27,7 @@ fn tutorial_main() { MessageView::Error(err) => { println!( "Error from {:?}: {} ({:?})", - msg.get_src().map(|s| s.get_path_string()), + err.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); diff --git a/tutorials/src/bin/basic-tutorial-2.rs b/tutorials/src/bin/basic-tutorial-2.rs index 1d12b60c6..11637b375 100644 --- a/tutorials/src/bin/basic-tutorial-2.rs +++ b/tutorials/src/bin/basic-tutorial-2.rs @@ -40,7 +40,7 @@ fn tutorial_main() { MessageView::Error(err) => { eprintln!( "Error received from element {:?}: {}", - msg.get_src().map(|s| s.get_path_string()), + err.get_src().map(|s| s.get_path_string()), err.get_error() ); eprintln!("Debugging information: {:?}", err.get_debug()); diff --git a/tutorials/src/bin/basic-tutorial-3.rs b/tutorials/src/bin/basic-tutorial-3.rs index 36991defa..d36efba98 100644 --- a/tutorials/src/bin/basic-tutorial-3.rs +++ b/tutorials/src/bin/basic-tutorial-3.rs @@ -93,18 +93,18 @@ fn tutorial_main() { MessageView::Error(err) => { eprintln!( "Error received from element {:?} {}", - msg.get_src().map(|s| s.get_path_string()), + err.get_src().map(|s| s.get_path_string()), err.get_error() ); eprintln!("Debugging information: {:?}", err.get_debug()); break; } - MessageView::StateChanged(s) => { - if msg.get_src().map(|s| s == pipeline).unwrap_or(false) { + MessageView::StateChanged(state_changed) => { + if state_changed.get_src().map(|s| s == pipeline).unwrap_or(false) { println!( "Pipeline state changed from {:?} to {:?}", - s.get_old(), - s.get_current() + state_changed.get_old(), + state_changed.get_current() ); } } diff --git a/tutorials/src/bin/basic-tutorial-4.rs b/tutorials/src/bin/basic-tutorial-4.rs index 8f93e2a0d..ecaeaa7a2 100644 --- a/tutorials/src/bin/basic-tutorial-4.rs +++ b/tutorials/src/bin/basic-tutorial-4.rs @@ -100,7 +100,7 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc { println!( "Error received from element {:?}: {} ({:?})", - msg.get_src().map(|s| s.get_path_string()), + err.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); @@ -114,12 +114,12 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc if msg.get_src() + MessageView::StateChanged(state_changed) => if state_changed.get_src() .map(|s| s == custom_data.playbin) .unwrap_or(false) { - let new_state = state.get_current(); - let old_state = state.get_old(); + let new_state = state_changed.get_current(); + let old_state = state_changed.get_old(); println!( "Pipeline state changed from {:?} to {:?}", diff --git a/tutorials/src/bin/basic-tutorial-5.rs b/tutorials/src/bin/basic-tutorial-5.rs index 25170eaaf..1df2a3804 100644 --- a/tutorials/src/bin/basic-tutorial-5.rs +++ b/tutorials/src/bin/basic-tutorial-5.rs @@ -238,8 +238,8 @@ mod tutorial5 { .get_bus() .unwrap() .connect_message(move |_, msg| match msg.view() { - gst::MessageView::Application(_) => { - if msg.get_structure().map(|s| s.get_name()) == Some("tags-changed") { + gst::MessageView::Application(application) => { + if application.get_structure().map(|s| s.get_name()) == Some("tags-changed") { analyze_streams(&pipeline, &textbuf); } } @@ -339,16 +339,16 @@ mod tutorial5 { gst::MessageView::Error(err) => { println!( "Error from {:?}: {} ({:?})", - msg.get_src().map(|s| s.get_path_string()), + err.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); } // This is called when the pipeline changes states. We use it to // keep track of the current state. - gst::MessageView::StateChanged(view) => { - if msg.get_src().map(|s| s == pipeline).unwrap_or(false) { - println!("State set to {:?}", view.get_current()); + gst::MessageView::StateChanged(state_changed) => { + if state_changed.get_src().map(|s| s == pipeline).unwrap_or(false) { + println!("State set to {:?}", state_changed.get_current()); } } _ => (), diff --git a/tutorials/src/bin/basic-tutorial-6.rs b/tutorials/src/bin/basic-tutorial-6.rs index b6351aee7..271a5bab7 100644 --- a/tutorials/src/bin/basic-tutorial-6.rs +++ b/tutorials/src/bin/basic-tutorial-6.rs @@ -126,7 +126,7 @@ fn tutorial_main() { MessageView::Error(err) => { println!( "Error received from element {:?}: {} ({:?})", - msg.get_src().map(|s| s.get_path_string()), + err.get_src().map(|s| s.get_path_string()), err.get_error(), err.get_debug() ); @@ -136,11 +136,11 @@ fn tutorial_main() { println!("End-Of-Stream reached."); break; } - MessageView::StateChanged(state) => + MessageView::StateChanged(state_changed) => // We are only interested in state-changed messages from the pipeline - if msg.get_src().map(|s| s == pipeline).unwrap_or(false) { - let new_state = state.get_current(); - let old_state = state.get_old(); + if state_changed.get_src().map(|s| s == pipeline).unwrap_or(false) { + let new_state = state_changed.get_current(); + let old_state = state_changed.get_old(); println!( "Pipeline state changed from {:?} to {:?}", diff --git a/tutorials/src/bin/basic-tutorial-7.rs b/tutorials/src/bin/basic-tutorial-7.rs index 02feba5bd..b7d7b44a7 100644 --- a/tutorials/src/bin/basic-tutorial-7.rs +++ b/tutorials/src/bin/basic-tutorial-7.rs @@ -74,7 +74,7 @@ fn tutorial_main() { MessageView::Error(err) => { eprintln!( "Error received from element {:?}: {}", - msg.get_src().map(|s| s.get_path_string()), + err.get_src().map(|s| s.get_path_string()), err.get_error() ); eprintln!("Debugging information: {:?}", err.get_debug()); diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index 847815a05..0b8a593b4 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -242,7 +242,7 @@ fn main() { let main_loop = &main_loop_clone; eprintln!( "Error received from element {:?}: {}", - msg.get_src().map(|s| s.get_path_string()), + err.get_src().map(|s| s.get_path_string()), err.get_error() ); eprintln!("Debugging information: {:?}", err.get_debug());