Fix examples and tutorials for GString support

This commit is contained in:
Philippe Normand 2018-12-09 16:09:20 +00:00 committed by Sebastian Dröge
parent 9534416760
commit bef6d741d3
11 changed files with 41 additions and 40 deletions

View file

@ -173,12 +173,12 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
MessageView::Error(err) => {
pipeline.set_state(gst::State::Null).into_result()?;
Err(ErrorMessage {
src: err
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
})?;
}

View file

@ -155,12 +155,12 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
MessageView::Error(err) => {
pipeline.set_state(gst::State::Null).into_result()?;
Err(ErrorMessage {
src: err
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
})?;
}

View file

@ -33,7 +33,6 @@
extern crate gstreamer as gst;
use gst::prelude::*;
#[macro_use]
extern crate glib;
use std::env;
@ -275,12 +274,12 @@ fn example_main() -> Result<(), Error> {
.map(Result::Err)
.expect("error-details message without actual error"),
_ => Err(ErrorMessage {
src: err
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
}
.into()),
@ -289,12 +288,12 @@ fn example_main() -> Result<(), Error> {
#[cfg(not(feature = "v1_10"))]
{
Err(ErrorMessage {
src: err
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
})?;
}

View file

@ -19,7 +19,6 @@ use gst::prelude::*;
extern crate gstreamer_pbutils as gst_pbutils;
use gst_pbutils::prelude::*;
#[macro_use]
extern crate glib;
use std::env;
@ -304,12 +303,12 @@ fn example_main() -> Result<(), Error> {
.map(Result::Err)
.expect("error-details message without actual error"),
_ => Err(ErrorMessage {
src: err
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
}
.into()),
@ -318,12 +317,12 @@ fn example_main() -> Result<(), Error> {
#[cfg(not(feature = "v1_10"))]
{
Err(ErrorMessage {
src: err
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
})?;
}

View file

@ -509,10 +509,10 @@ impl App {
Err(ErrorMessage {
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
})?;
}

View file

@ -29,6 +29,8 @@ use std::sync::{Arc, Mutex};
extern crate failure;
use failure::Error;
use glib::GString;
#[macro_use]
extern crate failure_derive;
@ -249,12 +251,12 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
MessageView::Error(err) => {
pipeline.set_state(gst::State::Null).into_result()?;
Err(ErrorMessage {
src: err
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
})?;
}

View file

@ -60,7 +60,7 @@ fn get_static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst:
Some(pad) => Ok(pad),
None => {
let element_name = element.get_name();
Err(Error::from(NoSuchPad(pad_name, element_name)))
Err(Error::from(NoSuchPad(pad_name, element_name.to_string())))
}
}
}
@ -70,7 +70,7 @@ fn get_request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst
Some(pad) => Ok(pad),
None => {
let element_name = element.get_name();
Err(Error::from(NoSuchPad(pad_name, element_name)))
Err(Error::from(NoSuchPad(pad_name, element_name.to_string())))
}
}
}
@ -261,10 +261,10 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
}
.into());

View file

@ -57,7 +57,7 @@ fn get_static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst:
Some(pad) => Ok(pad),
None => {
let element_name = element.get_name();
Err(Error::from(NoSuchPad(pad_name, element_name)))
Err(Error::from(NoSuchPad(pad_name, element_name.to_string())))
}
}
}
@ -67,7 +67,7 @@ fn get_request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst
Some(pad) => Ok(pad),
None => {
let element_name = element.get_name();
Err(Error::from(NoSuchPad(pad_name, element_name)))
Err(Error::from(NoSuchPad(pad_name, element_name.to_string())))
}
}
}
@ -192,10 +192,10 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
}
.into());

View file

@ -64,7 +64,7 @@ fn example_main() -> Result<(), Error> {
Ok(pipeline) => pipeline,
Err(err) => {
if let Some(gst::ParseError::NoSuchElement) = err.kind::<gst::ParseError>() {
return Err(MissingElement(context.get_missing_elements().join(",")).into());
return Err(MissingElement(context.get_missing_elements().join(",".into())).into());
} else {
return Err(err.into());
}
@ -106,9 +106,10 @@ fn example_main() -> Result<(), Error> {
src: err
.get_src()
.map(|s| s.get_path_string())
.unwrap_or_else(|| String::from("None")),
.unwrap_or_else(|| "None".into())
.to_string(),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
})?;
break;

View file

@ -168,12 +168,12 @@ fn example_main() -> Result<(), Error> {
pipeline.set_state(gst::State::Null).into_result()?;
Err(ErrorMessage {
src: err
src: msg
.get_src()
.map(|s| s.get_path_string())
.map(|s| String::from(s.get_path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
debug: Some(err.get_debug().unwrap().to_string()),
cause: err.get_error(),
})?;
break;

View file

@ -18,7 +18,7 @@ fn send_value_as_str(v: &glib::SendValue) -> Option<String> {
if let Some(s) = v.get::<&str>() {
Some(s.to_string())
} else if let Some(serialized) = v.serialize() {
Some(serialized)
Some(serialized.into())
} else {
None
}