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-11-19 08:45:04 +00:00
|
|
|
#[doc(alias = "gst_child_proxy_lookup")]
|
|
|
|
fn lookup(&self, name: &str) -> Result<(glib::Object, glib::ParamSpec), glib::BoolError>;
|
|
|
|
|
|
|
|
#[doc(alias = "get_child_property")]
|
|
|
|
#[doc(alias = "gst_child_proxy_get")]
|
|
|
|
fn child_property<V: for<'b> glib::value::FromValue<'b> + 'static>(&self, name: &str) -> V;
|
|
|
|
#[doc(alias = "get_child_property")]
|
|
|
|
#[doc(alias = "gst_child_proxy_get")]
|
|
|
|
fn child_property_value(&self, name: &str) -> glib::Value;
|
|
|
|
#[doc(alias = "get_child_property")]
|
|
|
|
#[doc(alias = "gst_child_proxy_get")]
|
|
|
|
fn try_child_property<V: for<'b> glib::value::FromValue<'b> + 'static>(
|
|
|
|
&self,
|
|
|
|
name: &str,
|
|
|
|
) -> Result<V, glib::BoolError>;
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_child_property")]
|
2021-11-19 08:45:04 +00:00
|
|
|
#[doc(alias = "gst_child_proxy_get")]
|
|
|
|
fn try_child_property_value(&self, name: &str) -> Result<glib::Value, glib::BoolError>;
|
|
|
|
|
|
|
|
#[doc(alias = "gst_child_proxy_set")]
|
|
|
|
fn set_child_property<V: glib::ToValue>(&self, name: &str, value: V);
|
|
|
|
#[doc(alias = "gst_child_proxy_set_property")]
|
|
|
|
fn set_child_property_from_value(&self, name: &str, value: &glib::Value);
|
|
|
|
#[doc(alias = "gst_child_proxy_set")]
|
|
|
|
fn try_set_child_property<V: glib::ToValue>(
|
2019-06-06 06:09:34 +00:00
|
|
|
&self,
|
|
|
|
name: &str,
|
2021-11-06 07:36:38 +00:00
|
|
|
value: V,
|
2019-06-06 06:09:34 +00:00
|
|
|
) -> Result<(), glib::BoolError>;
|
2021-11-19 08:45:04 +00:00
|
|
|
#[doc(alias = "gst_child_proxy_set_property")]
|
|
|
|
fn try_set_child_property_from_value(
|
|
|
|
&self,
|
|
|
|
name: &str,
|
|
|
|
value: &glib::Value,
|
|
|
|
) -> Result<(), glib::BoolError>;
|
2017-07-29 14:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
|
2021-11-19 08:45:04 +00:00
|
|
|
fn lookup(&self, name: &str) -> Result<(glib::Object, glib::ParamSpec), glib::BoolError> {
|
2017-07-29 14:10:10 +00:00
|
|
|
unsafe {
|
2021-11-19 08:45:04 +00:00
|
|
|
let mut target = ptr::null_mut();
|
|
|
|
let mut pspec = ptr::null_mut();
|
|
|
|
let ret = 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,
|
2021-11-19 08:45:04 +00:00
|
|
|
&mut target,
|
|
|
|
&mut pspec,
|
2017-07-31 11:16:42 +00:00
|
|
|
));
|
2021-11-19 08:45:04 +00:00
|
|
|
if ret {
|
|
|
|
Ok((from_glib_full(target), from_glib_none(pspec)))
|
|
|
|
} else {
|
|
|
|
Err(glib::bool_error!("Failed to find child property"))
|
2017-07-29 14:10:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-19 08:45:04 +00:00
|
|
|
fn child_property<V: for<'b> glib::value::FromValue<'b> + 'static>(&self, name: &str) -> V {
|
|
|
|
let (child, pspec) = self.lookup(name).unwrap();
|
|
|
|
child.property(pspec.name())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn child_property_value(&self, name: &str) -> glib::Value {
|
|
|
|
let (child, pspec) = self.lookup(name).unwrap();
|
|
|
|
child.property_value(pspec.name())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn try_child_property<V: for<'b> glib::value::FromValue<'b> + 'static>(
|
|
|
|
&self,
|
|
|
|
name: &str,
|
|
|
|
) -> Result<V, glib::BoolError> {
|
|
|
|
let (child, pspec) = self.lookup(name)?;
|
|
|
|
child.try_property(pspec.name())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn try_child_property_value(&self, name: &str) -> Result<glib::Value, glib::BoolError> {
|
|
|
|
let (child, pspec) = self.lookup(name)?;
|
|
|
|
child.try_property_value(pspec.name())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_child_property<V: glib::ToValue>(&self, name: &str, value: V) {
|
|
|
|
let (child, pspec) = self.lookup(name).unwrap();
|
|
|
|
child.set_property(pspec.name(), value)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_child_property_from_value(&self, name: &str, value: &glib::Value) {
|
|
|
|
let (child, pspec) = self.lookup(name).unwrap();
|
|
|
|
child.set_property_from_value(pspec.name(), value)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn try_set_child_property<V: glib::ToValue>(
|
2019-06-06 06:09:34 +00:00
|
|
|
&self,
|
|
|
|
name: &str,
|
2021-11-06 07:36:38 +00:00
|
|
|
value: V,
|
2019-06-06 06:09:34 +00:00
|
|
|
) -> Result<(), glib::BoolError> {
|
2021-11-19 08:45:04 +00:00
|
|
|
let (child, pspec) = self.lookup(name)?;
|
|
|
|
child.try_set_property(pspec.name(), value)
|
|
|
|
}
|
2017-07-29 14:10:10 +00:00
|
|
|
|
2021-11-19 08:45:04 +00:00
|
|
|
fn try_set_child_property_from_value(
|
|
|
|
&self,
|
|
|
|
name: &str,
|
|
|
|
value: &glib::Value,
|
|
|
|
) -> Result<(), glib::BoolError> {
|
|
|
|
let (child, pspec) = self.lookup(name)?;
|
|
|
|
child.try_set_property_from_value(pspec.name(), value)
|
2017-07-29 14:10:10 +00:00
|
|
|
}
|
|
|
|
}
|