2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2017-07-29 14:10:10 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
use crate::ChildProxy;
|
2021-04-26 12:15:53 +00:00
|
|
|
use glib::prelude::*;
|
2017-07-29 14:10:10 +00:00
|
|
|
use glib::translate::*;
|
|
|
|
use std::ptr;
|
|
|
|
|
2018-12-08 09:22:42 +00:00
|
|
|
pub trait ChildProxyExtManual: 'static {
|
2021-04-20 10:23:24 +00:00
|
|
|
fn child_property(&self, name: &str) -> Option<glib::Value>;
|
2019-06-06 06:09:34 +00:00
|
|
|
fn set_child_property(
|
|
|
|
&self,
|
|
|
|
name: &str,
|
|
|
|
value: &dyn glib::ToValue,
|
|
|
|
) -> Result<(), glib::BoolError>;
|
2017-07-29 14:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
|
2021-04-20 10:23:24 +00:00
|
|
|
fn child_property(&self, name: &str) -> Option<glib::Value> {
|
2017-07-29 14:10:10 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let found: bool = from_glib(ffi::gst_child_proxy_lookup(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.as_ref().to_glib_none().0,
|
2017-07-31 11:16:42 +00:00
|
|
|
name.to_glib_none().0,
|
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
));
|
2017-07-29 14:10:10 +00:00
|
|
|
if !found {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut value = glib::Value::uninitialized();
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_child_proxy_get_property(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.as_ref().to_glib_none().0,
|
2017-07-31 11:16:42 +00:00
|
|
|
name.to_glib_none().0,
|
|
|
|
value.to_glib_none_mut().0,
|
|
|
|
);
|
2017-07-29 14:10:10 +00:00
|
|
|
Some(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 06:09:34 +00:00
|
|
|
fn set_child_property(
|
|
|
|
&self,
|
|
|
|
name: &str,
|
|
|
|
value: &dyn glib::ToValue,
|
|
|
|
) -> Result<(), glib::BoolError> {
|
2017-07-29 14:10:10 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let found: bool = from_glib(ffi::gst_child_proxy_lookup(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.as_ref().to_glib_none().0,
|
2017-07-31 11:16:42 +00:00
|
|
|
name.to_glib_none().0,
|
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
));
|
2017-07-29 14:10:10 +00:00
|
|
|
if !found {
|
2020-12-17 22:38:06 +00:00
|
|
|
return Err(glib::bool_error!("Child property not found"));
|
2017-07-29 14:10:10 +00:00
|
|
|
}
|
|
|
|
|
2017-12-16 13:24:18 +00:00
|
|
|
let value = value.to_value();
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_child_proxy_set_property(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.as_ref().to_glib_none().0,
|
2017-07-31 11:16:42 +00:00
|
|
|
name.to_glib_none().0,
|
|
|
|
value.to_glib_none().0,
|
|
|
|
);
|
2017-07-29 14:10:10 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|