gstreamer_controller/auto/
trigger_control_source.rs1use crate::{ffi, TimedValueControlSource};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstTriggerControlSource")]
16 pub struct TriggerControlSource(Object<ffi::GstTriggerControlSource, ffi::GstTriggerControlSourceClass>) @extends TimedValueControlSource, gst::ControlSource, gst::Object;
17
18 match fn {
19 type_ => || ffi::gst_trigger_control_source_get_type(),
20 }
21}
22
23impl TriggerControlSource {
24 pub const NONE: Option<&'static TriggerControlSource> = None;
25
26 #[doc(alias = "gst_trigger_control_source_new")]
27 pub fn new() -> TriggerControlSource {
28 assert_initialized_main_thread!();
29 unsafe {
30 gst::ControlSource::from_glib_full(ffi::gst_trigger_control_source_new()).unsafe_cast()
31 }
32 }
33}
34
35impl Default for TriggerControlSource {
36 fn default() -> Self {
37 Self::new()
38 }
39}
40
41unsafe impl Send for TriggerControlSource {}
42unsafe impl Sync for TriggerControlSource {}
43
44pub trait TriggerControlSourceExt: IsA<TriggerControlSource> + 'static {
45 fn tolerance(&self) -> i64 {
46 ObjectExt::property(self.as_ref(), "tolerance")
47 }
48
49 fn set_tolerance(&self, tolerance: i64) {
50 ObjectExt::set_property(self.as_ref(), "tolerance", tolerance)
51 }
52
53 #[doc(alias = "tolerance")]
54 fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
55 &self,
56 f: F,
57 ) -> SignalHandlerId {
58 unsafe extern "C" fn notify_tolerance_trampoline<
59 P: IsA<TriggerControlSource>,
60 F: Fn(&P) + Send + Sync + 'static,
61 >(
62 this: *mut ffi::GstTriggerControlSource,
63 _param_spec: glib::ffi::gpointer,
64 f: glib::ffi::gpointer,
65 ) {
66 let f: &F = &*(f as *const F);
67 f(TriggerControlSource::from_glib_borrow(this).unsafe_cast_ref())
68 }
69 unsafe {
70 let f: Box_<F> = Box_::new(f);
71 connect_raw(
72 self.as_ptr() as *mut _,
73 c"notify::tolerance".as_ptr() as *const _,
74 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
75 notify_tolerance_trampoline::<Self, F> as *const (),
76 )),
77 Box_::into_raw(f),
78 )
79 }
80 }
81}
82
83impl<O: IsA<TriggerControlSource>> TriggerControlSourceExt for O {}