Commit ce28fed0 authored by François Laignel's avatar François Laignel Committed by Sebastian Dröge

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.
parent 21c687f2
......@@ -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()
);
......
......@@ -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());
......
......@@ -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()
);
}
}
......
......@@ -100,7 +100,7 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc<gst::MessageRef
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()
);
......@@ -114,12 +114,12 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc<gst::MessageRef
// The duration has changed, mark the current one as invalid
custom_data.duration = gst::CLOCK_TIME_NONE;
}
MessageView::StateChanged(state) => 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 {:?}",
......
......@@ -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());
}
}
_ => (),
......
......@@ -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 {:?}",
......
......@@ -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());
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment