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

113 lines
3.5 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::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;
use TimedValueControlSource;
glib_wrapper! {
pub struct TriggerControlSource(Object<gst_controller_sys::GstTriggerControlSource, gst_controller_sys::GstTriggerControlSourceClass, TriggerControlSourceClass>) @extends TimedValueControlSource, gst::ControlSource, gst::Object;
match fn {
get_type => || gst_controller_sys::gst_trigger_control_source_get_type(),
}
}
impl TriggerControlSource {
pub fn new() -> TriggerControlSource {
assert_initialized_main_thread!();
unsafe {
gst::ControlSource::from_glib_full(gst_controller_sys::gst_trigger_control_source_new())
.unsafe_cast()
}
}
}
impl Default for TriggerControlSource {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for TriggerControlSource {}
unsafe impl Sync for TriggerControlSource {}
pub const NONE_TRIGGER_CONTROL_SOURCE: Option<&TriggerControlSource> = None;
pub trait TriggerControlSourceExt: 'static {
fn get_property_tolerance(&self) -> i64;
fn set_property_tolerance(&self, tolerance: i64);
fn connect_property_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
}
impl<O: IsA<TriggerControlSource>> TriggerControlSourceExt for O {
fn get_property_tolerance(&self) -> i64 {
unsafe {
let mut value = Value::from_type(<i64 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"tolerance\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `tolerance` getter")
.unwrap()
}
}
fn set_property_tolerance(&self, tolerance: i64) {
unsafe {
gobject_sys::g_object_set_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"tolerance\0".as_ptr() as *const _,
Value::from(&tolerance).to_glib_none().0,
);
}
}
fn connect_property_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_tolerance_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_controller_sys::GstTriggerControlSource,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<TriggerControlSource>,
{
let f: &F = &*(f as *const F);
f(&TriggerControlSource::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::tolerance\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_tolerance_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}