gstreamer-rs/gstreamer-controller/src/auto/direct_control_binding.rs
2020-09-30 16:28:51 +00:00

158 lines
5.1 KiB
Rust

// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::value::SetValueOptional;
use glib::StaticType;
use glib::Value;
use glib_sys;
use gobject_sys;
use gst;
use gst_controller_sys;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
pub struct DirectControlBinding(Object<gst_controller_sys::GstDirectControlBinding, gst_controller_sys::GstDirectControlBindingClass, DirectControlBindingClass>) @extends gst::ControlBinding, gst::Object;
match fn {
get_type => || gst_controller_sys::gst_direct_control_binding_get_type(),
}
}
impl DirectControlBinding {
pub fn new<P: IsA<gst::Object>, Q: IsA<gst::ControlSource>>(
object: &P,
property_name: &str,
cs: &Q,
) -> DirectControlBinding {
assert_initialized_main_thread!();
unsafe {
gst::ControlBinding::from_glib_none(gst_controller_sys::gst_direct_control_binding_new(
object.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
cs.as_ref().to_glib_none().0,
))
.unsafe_cast()
}
}
pub fn new_absolute<P: IsA<gst::Object>, Q: IsA<gst::ControlSource>>(
object: &P,
property_name: &str,
cs: &Q,
) -> DirectControlBinding {
assert_initialized_main_thread!();
unsafe {
gst::ControlBinding::from_glib_none(
gst_controller_sys::gst_direct_control_binding_new_absolute(
object.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
cs.as_ref().to_glib_none().0,
),
)
.unsafe_cast()
}
}
}
unsafe impl Send for DirectControlBinding {}
unsafe impl Sync for DirectControlBinding {}
pub const NONE_DIRECT_CONTROL_BINDING: Option<&DirectControlBinding> = None;
pub trait DirectControlBindingExt: 'static {
fn get_property_absolute(&self) -> bool;
fn get_property_control_source(&self) -> Option<gst::ControlSource>;
fn set_property_control_source<P: IsA<gst::ControlSource> + SetValueOptional>(
&self,
control_source: Option<&P>,
);
fn connect_property_control_source_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
}
impl<O: IsA<DirectControlBinding>> DirectControlBindingExt for O {
fn get_property_absolute(&self) -> bool {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"absolute\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `absolute` getter")
.unwrap()
}
}
fn get_property_control_source(&self) -> Option<gst::ControlSource> {
unsafe {
let mut value = Value::from_type(<gst::ControlSource as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"control-source\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `control-source` getter")
}
}
fn set_property_control_source<P: IsA<gst::ControlSource> + SetValueOptional>(
&self,
control_source: Option<&P>,
) {
unsafe {
gobject_sys::g_object_set_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"control-source\0".as_ptr() as *const _,
Value::from(control_source).to_glib_none().0,
);
}
}
fn connect_property_control_source_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_control_source_trampoline<
P,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut gst_controller_sys::GstDirectControlBinding,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<DirectControlBinding>,
{
let f: &F = &*(f as *const F);
f(&DirectControlBinding::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::control-source\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_control_source_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}