diff --git a/examples/src/bin/overlay-composition.rs b/examples/src/bin/overlay-composition.rs index 324384745..65d130824 100644 --- a/examples/src/bin/overlay-composition.rs +++ b/examples/src/bin/overlay-composition.rs @@ -89,7 +89,7 @@ fn create_pipeline() -> Result { // The videotestsrc supports multiple test patterns. In this example, we will use the // pattern with a white ball moving around the video's center point. - src.set_property_from_str("pattern", "ball").unwrap(); + src.set_property_from_str("pattern", "ball"); // The PangoFontMap represents the set of fonts available for a particular rendering system. let fontmap = pangocairo::FontMap::new().unwrap(); diff --git a/examples/src/bin/pango-cairo.rs b/examples/src/bin/pango-cairo.rs index b5f558de2..28c9fed6f 100644 --- a/examples/src/bin/pango-cairo.rs +++ b/examples/src/bin/pango-cairo.rs @@ -87,7 +87,7 @@ fn create_pipeline() -> Result { // The videotestsrc supports multiple test patterns. In this example, we will use the // pattern with a white ball moving around the video's center point. - src.set_property_from_str("pattern", "ball").unwrap(); + src.set_property_from_str("pattern", "ball"); // The PangoFontMap represents the set of fonts available for a particular rendering system. let fontmap = pangocairo::FontMap::new().unwrap(); diff --git a/examples/src/bin/rtpfecclient.rs b/examples/src/bin/rtpfecclient.rs index 653241507..cbb48516b 100644 --- a/examples/src/bin/rtpfecclient.rs +++ b/examples/src/bin/rtpfecclient.rs @@ -134,7 +134,7 @@ fn example_main() -> Result<(), Error> { pipeline.add_many(&[&enc, &mux, &sink])?; gst::Element::link_many(&[&filter, &enc, &mux, &sink])?; sink.set_property("location", "out.mkv"); - enc.set_property_from_str("tune", "zerolatency")?; + enc.set_property_from_str("tune", "zerolatency"); eprintln!("Recording to out.mkv"); } _ => return Err(Error::from(UsageError(args[0].clone()))), diff --git a/examples/src/bin/rtpfecserver.rs b/examples/src/bin/rtpfecserver.rs index 273cf845e..74e9d9f8d 100644 --- a/examples/src/bin/rtpfecserver.rs +++ b/examples/src/bin/rtpfecserver.rs @@ -151,14 +151,14 @@ fn example_main() -> Result<(), Error> { let video_caps = gst::Caps::builder("video/x-raw").build(); - src.set_property_from_str("pattern", "ball")?; + src.set_property_from_str("pattern", "ball"); sink.set_property("host", "127.0.0.1"); sink.set_property("sync", true); enc.set_property("keyframe-max-dist", 30i32); enc.set_property("threads", 12i32); enc.set_property("cpu-used", -16i32); enc.set_property("deadline", 1i64); - enc.set_property_from_str("error-resilient", "default")?; + enc.set_property_from_str("error-resilient", "default"); src.set_property("expose-all-streams", false); src.set_property("caps", video_caps); src.set_property("uri", uri); diff --git a/examples/src/bin/subclass.rs b/examples/src/bin/subclass.rs index c3c86ba60..9294ed439 100644 --- a/examples/src/bin/subclass.rs +++ b/examples/src/bin/subclass.rs @@ -272,7 +272,7 @@ fn create_pipeline() -> Result { filter.link(&conv)?; conv.link(&sink)?; - src.set_property_from_str("wave", "white-noise").unwrap(); + src.set_property_from_str("wave", "white-noise"); // Create a windowed sinc lowpass filter at 1/64 sample rate, // i.e. 689Hz for 44.1kHz sample rate diff --git a/gstreamer/src/gobject.rs b/gstreamer/src/gobject.rs index d873d6bd9..c651badd9 100644 --- a/gstreamer/src/gobject.rs +++ b/gstreamer/src/gobject.rs @@ -5,11 +5,14 @@ use glib::prelude::*; pub trait GObjectExtManualGst: 'static { #[doc(alias = "gst_util_set_object_arg")] - fn set_property_from_str(&self, name: &str, value: &str) -> Result<(), glib::BoolError>; + fn try_set_property_from_str(&self, name: &str, value: &str) -> Result<(), glib::BoolError>; + + #[doc(alias = "gst_util_set_object_arg")] + fn set_property_from_str(&self, name: &str, value: &str); } impl> GObjectExtManualGst for O { - fn set_property_from_str(&self, name: &str, value: &str) -> Result<(), glib::BoolError> { + fn try_set_property_from_str(&self, name: &str, value: &str) -> Result<(), glib::BoolError> { let pspec = self.find_property(name).ok_or_else(|| { glib::bool_error!("property '{}' of type '{}' not found", name, self.type_()) })?; @@ -31,6 +34,10 @@ impl> GObjectExtManualGst for O { self.try_set_property_from_value(name, &value) } + + fn set_property_from_str(&self, name: &str, value: &str) { + self.try_set_property_from_str(name, value).unwrap() + } } #[cfg(test)] @@ -42,9 +49,7 @@ mod tests { crate::init().unwrap(); let fakesink = crate::ElementFactory::make("fakesink", None).unwrap(); - fakesink - .set_property_from_str("state-error", "ready-to-paused") - .unwrap(); + fakesink.set_property_from_str("state-error", "ready-to-paused"); let v = fakesink.property_value("state-error"); let e = glib::EnumValue::from_value(&v).unwrap(); assert_eq!(e.nick(), "ready-to-paused"); diff --git a/tutorials/src/bin/basic-tutorial-2.rs b/tutorials/src/bin/basic-tutorial-2.rs index ce70b09e4..0cb0a8067 100644 --- a/tutorials/src/bin/basic-tutorial-2.rs +++ b/tutorials/src/bin/basic-tutorial-2.rs @@ -21,7 +21,7 @@ fn tutorial_main() { source.link(&sink).expect("Elements could not be linked."); // Modify the source's properties - source.set_property_from_str("pattern", "smpte").unwrap(); + source.set_property_from_str("pattern", "smpte"); // Start playing pipeline diff --git a/tutorials/src/bin/basic-tutorial-7.rs b/tutorials/src/bin/basic-tutorial-7.rs index 567a2062f..d1113d570 100644 --- a/tutorials/src/bin/basic-tutorial-7.rs +++ b/tutorials/src/bin/basic-tutorial-7.rs @@ -25,8 +25,8 @@ fn tutorial_main() { let pipeline = gst::Pipeline::new(Some("test-pipeline")); audio_source.set_property("freq", 215.0); - visual.set_property_from_str("shader", "none").unwrap(); - visual.set_property_from_str("style", "lines").unwrap(); + visual.set_property_from_str("shader", "none"); + visual.set_property_from_str("style", "lines"); pipeline .add_many(&[ diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index 7178b047b..be5c220cd 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -64,8 +64,8 @@ fn main() { let pipeline = gst::Pipeline::new(Some("test-pipeline")); - visual.set_property_from_str("shader", "none").unwrap(); - visual.set_property_from_str("style", "lines").unwrap(); + visual.set_property_from_str("shader", "none"); + visual.set_property_from_str("style", "lines"); pipeline .add_many(&[