gstreamer_controller/auto/
trigger_control_source.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use 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    /// [`TriggerControlSource`][crate::TriggerControlSource] is a [`gst::ControlSource`][crate::gst::ControlSource], that returns values from user-given
16    /// control points. It allows for a tolerance on the time-stamps.
17    ///
18    /// To use [`TriggerControlSource`][crate::TriggerControlSource] get a new instance by calling
19    /// [`new()`][Self::new()], bind it to a `GParamSpec` and set some
20    /// control points by calling [`TimedValueControlSourceExt::set()`][crate::prelude::TimedValueControlSourceExt::set()].
21    ///
22    /// All functions are MT-safe.
23    ///
24    /// ## Properties
25    ///
26    ///
27    /// #### `tolerance`
28    ///  Readable | Writeable
29    /// <details><summary><h4>Object</h4></summary>
30    ///
31    ///
32    /// #### `name`
33    ///  Readable | Writeable | Construct
34    ///
35    ///
36    /// #### `parent`
37    ///  The parent of the object. Please note, that when changing the 'parent'
38    /// property, we don't emit `GObject::notify` and [`deep-notify`][struct@crate::gst::Object#deep-notify]
39    /// signals due to locking issues. In some cases one can use
40    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
41    /// achieve a similar effect.
42    ///
43    /// Readable | Writeable
44    /// </details>
45    ///
46    /// # Implements
47    ///
48    /// [`TriggerControlSourceExt`][trait@crate::prelude::TriggerControlSourceExt], [`TimedValueControlSourceExt`][trait@crate::prelude::TimedValueControlSourceExt], [`trait@gst::prelude::ControlSourceExt`], [`trait@gst::prelude::ObjectExt`]
49    #[doc(alias = "GstTriggerControlSource")]
50    pub struct TriggerControlSource(Object<ffi::GstTriggerControlSource, ffi::GstTriggerControlSourceClass>) @extends TimedValueControlSource, gst::ControlSource, gst::Object;
51
52    match fn {
53        type_ => || ffi::gst_trigger_control_source_get_type(),
54    }
55}
56
57impl TriggerControlSource {
58    pub const NONE: Option<&'static TriggerControlSource> = None;
59
60    /// This returns a new, unbound [`TriggerControlSource`][crate::TriggerControlSource].
61    ///
62    /// # Returns
63    ///
64    /// a new, unbound [`TriggerControlSource`][crate::TriggerControlSource].
65    #[doc(alias = "gst_trigger_control_source_new")]
66    pub fn new() -> TriggerControlSource {
67        assert_initialized_main_thread!();
68        unsafe {
69            gst::ControlSource::from_glib_full(ffi::gst_trigger_control_source_new()).unsafe_cast()
70        }
71    }
72}
73
74impl Default for TriggerControlSource {
75    fn default() -> Self {
76        Self::new()
77    }
78}
79
80unsafe impl Send for TriggerControlSource {}
81unsafe impl Sync for TriggerControlSource {}
82
83/// Trait containing all [`struct@TriggerControlSource`] methods.
84///
85/// # Implementors
86///
87/// [`TriggerControlSource`][struct@crate::TriggerControlSource]
88pub trait TriggerControlSourceExt: IsA<TriggerControlSource> + 'static {
89    fn tolerance(&self) -> i64 {
90        ObjectExt::property(self.as_ref(), "tolerance")
91    }
92
93    fn set_tolerance(&self, tolerance: i64) {
94        ObjectExt::set_property(self.as_ref(), "tolerance", tolerance)
95    }
96
97    #[doc(alias = "tolerance")]
98    fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
99        &self,
100        f: F,
101    ) -> SignalHandlerId {
102        unsafe extern "C" fn notify_tolerance_trampoline<
103            P: IsA<TriggerControlSource>,
104            F: Fn(&P) + Send + Sync + 'static,
105        >(
106            this: *mut ffi::GstTriggerControlSource,
107            _param_spec: glib::ffi::gpointer,
108            f: glib::ffi::gpointer,
109        ) {
110            let f: &F = &*(f as *const F);
111            f(TriggerControlSource::from_glib_borrow(this).unsafe_cast_ref())
112        }
113        unsafe {
114            let f: Box_<F> = Box_::new(f);
115            connect_raw(
116                self.as_ptr() as *mut _,
117                c"notify::tolerance".as_ptr() as *const _,
118                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
119                    notify_tolerance_trampoline::<Self, F> as *const (),
120                )),
121                Box_::into_raw(f),
122            )
123        }
124    }
125}
126
127impl<O: IsA<TriggerControlSource>> TriggerControlSourceExt for O {}