Use Object::set_property() instead of unsafe code for setting filesrc location

This commit is contained in:
Sebastian Dröge 2017-07-05 15:18:25 +03:00
parent 291f329fc3
commit 8f8ba45588

View file

@ -1,7 +1,9 @@
extern crate gstreamer as gst; extern crate gstreamer as gst;
use gst::*; use gst::*;
use gst::ObjectExt as GstObjectExt;
extern crate glib; extern crate glib;
use glib::ObjectExt;
use glib::translate::{from_glib_none, ToGlibPtr}; use glib::translate::{from_glib_none, ToGlibPtr};
extern crate gstreamer_sys as gst_ffi; extern crate gstreamer_sys as gst_ffi;
@ -24,11 +26,7 @@ fn main() {
let src = gst::ElementFactory::make("filesrc", None).unwrap(); let src = gst::ElementFactory::make("filesrc", None).unwrap();
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap(); let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
// FIXME: https://github.com/gtk-rs/glib/pull/189 src.set_property("location", &Value::from(uri)).unwrap();
unsafe {
let uri = Value::from(uri);
gobject_ffi::g_object_set_property(src.to_glib_none().0, "location".to_glib_none().0, uri.to_glib_none().0);
}
pipeline.add_many(&[&src, &decodebin]).unwrap(); pipeline.add_many(&[&src, &decodebin]).unwrap();
gst::Element::link_many(&[&src, &decodebin]).unwrap(); gst::Element::link_many(&[&src, &decodebin]).unwrap();