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
83mod sealed {
84 pub trait Sealed {}
85 impl<T: super::IsA<super::TriggerControlSource>> Sealed for T {}
86}
87
88/// Trait containing all [`struct@TriggerControlSource`] methods.
89///
90/// # Implementors
91///
92/// [`TriggerControlSource`][struct@crate::TriggerControlSource]
93pub trait TriggerControlSourceExt: IsA<TriggerControlSource> + sealed::Sealed + 'static {
94 fn tolerance(&self) -> i64 {
95 ObjectExt::property(self.as_ref(), "tolerance")
96 }
97
98 fn set_tolerance(&self, tolerance: i64) {
99 ObjectExt::set_property(self.as_ref(), "tolerance", tolerance)
100 }
101
102 #[doc(alias = "tolerance")]
103 fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
104 &self,
105 f: F,
106 ) -> SignalHandlerId {
107 unsafe extern "C" fn notify_tolerance_trampoline<
108 P: IsA<TriggerControlSource>,
109 F: Fn(&P) + Send + Sync + 'static,
110 >(
111 this: *mut ffi::GstTriggerControlSource,
112 _param_spec: glib::ffi::gpointer,
113 f: glib::ffi::gpointer,
114 ) {
115 let f: &F = &*(f as *const F);
116 f(TriggerControlSource::from_glib_borrow(this).unsafe_cast_ref())
117 }
118 unsafe {
119 let f: Box_<F> = Box_::new(f);
120 connect_raw(
121 self.as_ptr() as *mut _,
122 b"notify::tolerance\0".as_ptr() as *const _,
123 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
124 notify_tolerance_trampoline::<Self, F> as *const (),
125 )),
126 Box_::into_raw(f),
127 )
128 }
129 }
130}
131
132impl<O: IsA<TriggerControlSource>> TriggerControlSourceExt for O {}