gstreamer: Return glib::GString for the error/warning/info message debug string

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1184>
This commit is contained in:
Sebastian Dröge 2023-01-05 17:28:48 +02:00
parent ba1d8c5ce6
commit 277d63601c
15 changed files with 81 additions and 118 deletions

View file

@ -23,10 +23,9 @@ mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
fn create_pipeline() -> Result<gst::Pipeline, Error> {
@ -135,11 +134,10 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -20,10 +20,9 @@ mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
const WIDTH: usize = 320;
@ -151,11 +150,10 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -44,10 +44,9 @@ mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
#[derive(Clone, Debug, glib::Boxed)]
@ -234,11 +233,10 @@ fn example_main() -> Result<(), Error> {
_ => Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into()),
}?;

View file

@ -28,10 +28,9 @@ mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
#[derive(Clone, Debug, glib::Boxed)]
@ -251,11 +250,10 @@ fn example_main() -> Result<(), Error> {
_ => Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into()),
}?;

View file

@ -20,7 +20,6 @@ use std::{
};
use anyhow::Error;
use derive_more::{Display, Error};
use futures::StreamExt;
use gst::{element_error, prelude::*};
use memmap2::MmapMut;
@ -29,15 +28,6 @@ use uds::UnixStreamExt;
#[path = "../examples-common.rs"]
mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
}
fn create_receiver_pipeline(
video_info: &gst_video::VideoInfo,
receiver: UnixStream,

View file

@ -24,10 +24,9 @@ mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
struct DrawingContext {
@ -275,11 +274,10 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -27,10 +27,9 @@ mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
struct DrawingContext {
@ -219,11 +218,10 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -23,10 +23,9 @@ struct UsageError(#[error(not(source))] String);
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
fn static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
@ -243,11 +242,10 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -19,10 +19,9 @@ struct UsageError(#[error(not(source))] String);
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
fn static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
@ -169,11 +168,10 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -231,10 +231,9 @@ mod fir_filter {
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
fn create_pipeline() -> Result<gst::Pipeline, Error> {
@ -303,11 +302,10 @@ fn main_loop(pipeline: gst::Pipeline) -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -32,10 +32,9 @@ struct MissingElement(#[error(not(source))] String);
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
fn example_main() -> Result<(), Error> {
@ -90,14 +89,12 @@ fn example_main() -> Result<(), Error> {
MessageView::Eos(..) => break,
MessageView::Error(err) => {
return Err(ErrorMessage {
src: err
src: msg
.src()
.map(|s| s.path_string())
.unwrap_or_else(|| "None".into())
.to_string(),
error: err.error().to_string(),
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -17,10 +17,9 @@ mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
fn create_pipeline(uri: String, out_path: std::path::PathBuf) -> Result<gst::Pipeline, Error> {
@ -202,11 +201,10 @@ fn main_loop(pipeline: gst::Pipeline, position: u64) -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -29,10 +29,9 @@ mod examples_common;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
fn example_main() -> Result<(), Error> {
@ -140,11 +139,10 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -14,10 +14,9 @@ use gst_gl::prelude::*;
#[derive(Debug, Display, Error)]
#[display(fmt = "Received error from {}: {} (debug: {:?})", src, error, debug)]
struct ErrorMessage {
src: String,
error: String,
debug: Option<String>,
source: glib::Error,
src: glib::GString,
error: glib::Error,
debug: Option<glib::GString>,
}
#[rustfmt::skip]
@ -587,11 +586,10 @@ impl App {
return Err(ErrorMessage {
src: msg
.src()
.map(|s| String::from(s.path_string()))
.unwrap_or_else(|| String::from("None")),
error: err.error().to_string(),
.map(|s| s.path_string())
.unwrap_or_else(|| glib::GString::from("UNKNOWN")),
error: err.error(),
debug: err.debug(),
source: err.error(),
}
.into());
}

View file

@ -339,7 +339,7 @@ impl Error {
#[doc(alias = "get_debug")]
#[doc(alias = "gst_message_parse_error")]
pub fn debug(&self) -> Option<String> {
pub fn debug(&self) -> Option<glib::GString> {
unsafe {
let mut debug = ptr::null_mut();
@ -409,7 +409,7 @@ impl Warning {
#[doc(alias = "get_debug")]
#[doc(alias = "gst_message_parse_warning")]
pub fn debug(&self) -> Option<String> {
pub fn debug(&self) -> Option<glib::GString> {
unsafe {
let mut debug = ptr::null_mut();
@ -479,7 +479,7 @@ impl Info {
#[doc(alias = "get_debug")]
#[doc(alias = "gst_message_parse_info")]
pub fn debug(&self) -> Option<String> {
pub fn debug(&self) -> Option<glib::GString> {
unsafe {
let mut debug = ptr::null_mut();