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
44mod sealed {
45 pub trait Sealed {}
46 impl<T: super::IsA<super::TriggerControlSource>> Sealed for T {}
47}
48
49pub trait TriggerControlSourceExt: IsA<TriggerControlSource> + sealed::Sealed + 'static {
50 fn tolerance(&self) -> i64 {
51 ObjectExt::property(self.as_ref(), "tolerance")
52 }
53
54 fn set_tolerance(&self, tolerance: i64) {
55 ObjectExt::set_property(self.as_ref(), "tolerance", tolerance)
56 }
57
58 #[doc(alias = "tolerance")]
59 fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
60 &self,
61 f: F,
62 ) -> SignalHandlerId {
63 unsafe extern "C" fn notify_tolerance_trampoline<
64 P: IsA<TriggerControlSource>,
65 F: Fn(&P) + Send + Sync + 'static,
66 >(
67 this: *mut ffi::GstTriggerControlSource,
68 _param_spec: glib::ffi::gpointer,
69 f: glib::ffi::gpointer,
70 ) {
71 let f: &F = &*(f as *const F);
72 f(TriggerControlSource::from_glib_borrow(this).unsafe_cast_ref())
73 }
74 unsafe {
75 let f: Box_<F> = Box_::new(f);
76 connect_raw(
77 self.as_ptr() as *mut _,
78 b"notify::tolerance\0".as_ptr() as *const _,
79 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
80 notify_tolerance_trampoline::<Self, F> as *const (),
81 )),
82 Box_::into_raw(f),
83 )
84 }
85 }
86}
87
88impl<O: IsA<TriggerControlSource>> TriggerControlSourceExt for O {}