gstreamer_controller/auto/
timed_value_control_source.rs1#![allow(deprecated)]
6
7use crate::{ffi, ControlPoint};
8use glib::{
9 object::ObjectType as _,
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 #[doc(alias = "GstTimedValueControlSource")]
18 pub struct TimedValueControlSource(Object<ffi::GstTimedValueControlSource, ffi::GstTimedValueControlSourceClass>) @extends gst::ControlSource, gst::Object;
19
20 match fn {
21 type_ => || ffi::gst_timed_value_control_source_get_type(),
22 }
23}
24
25impl TimedValueControlSource {
26 pub const NONE: Option<&'static TimedValueControlSource> = None;
27}
28
29unsafe impl Send for TimedValueControlSource {}
30unsafe impl Sync for TimedValueControlSource {}
31
32pub trait TimedValueControlSourceExt: IsA<TimedValueControlSource> + 'static {
33 #[doc(alias = "gst_timed_value_control_source_get_count")]
39 #[doc(alias = "get_count")]
40 fn count(&self) -> i32 {
41 unsafe { ffi::gst_timed_value_control_source_get_count(self.as_ref().to_glib_none().0) }
42 }
43
44 #[doc(alias = "gst_timed_value_control_source_set")]
45 fn set(&self, timestamp: gst::ClockTime, value: f64) -> bool {
46 unsafe {
47 from_glib(ffi::gst_timed_value_control_source_set(
48 self.as_ref().to_glib_none().0,
49 timestamp.into_glib(),
50 value,
51 ))
52 }
53 }
54
55 #[doc(alias = "gst_timed_value_control_source_unset")]
61 fn unset(&self, timestamp: gst::ClockTime) -> bool {
62 unsafe {
63 from_glib(ffi::gst_timed_value_control_source_unset(
64 self.as_ref().to_glib_none().0,
65 timestamp.into_glib(),
66 ))
67 }
68 }
69
70 #[doc(alias = "gst_timed_value_control_source_unset_all")]
71 fn unset_all(&self) {
72 unsafe {
73 ffi::gst_timed_value_control_source_unset_all(self.as_ref().to_glib_none().0);
74 }
75 }
76
77 #[doc(alias = "value-added")]
78 fn connect_value_added<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
79 &self,
80 f: F,
81 ) -> SignalHandlerId {
82 unsafe extern "C" fn value_added_trampoline<
83 P: IsA<TimedValueControlSource>,
84 F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
85 >(
86 this: *mut ffi::GstTimedValueControlSource,
87 timed_value: *mut ffi::GstControlPoint,
88 f: glib::ffi::gpointer,
89 ) {
90 let f: &F = &*(f as *const F);
91 f(
92 TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
93 &from_glib_borrow(timed_value),
94 )
95 }
96 unsafe {
97 let f: Box_<F> = Box_::new(f);
98 connect_raw(
99 self.as_ptr() as *mut _,
100 c"value-added".as_ptr() as *const _,
101 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
102 value_added_trampoline::<Self, F> as *const (),
103 )),
104 Box_::into_raw(f),
105 )
106 }
107 }
108
109 #[doc(alias = "value-changed")]
110 fn connect_value_changed<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
111 &self,
112 f: F,
113 ) -> SignalHandlerId {
114 unsafe extern "C" fn value_changed_trampoline<
115 P: IsA<TimedValueControlSource>,
116 F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
117 >(
118 this: *mut ffi::GstTimedValueControlSource,
119 timed_value: *mut ffi::GstControlPoint,
120 f: glib::ffi::gpointer,
121 ) {
122 let f: &F = &*(f as *const F);
123 f(
124 TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
125 &from_glib_borrow(timed_value),
126 )
127 }
128 unsafe {
129 let f: Box_<F> = Box_::new(f);
130 connect_raw(
131 self.as_ptr() as *mut _,
132 c"value-changed".as_ptr() as *const _,
133 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
134 value_changed_trampoline::<Self, F> as *const (),
135 )),
136 Box_::into_raw(f),
137 )
138 }
139 }
140
141 #[doc(alias = "value-removed")]
142 fn connect_value_removed<F: Fn(&Self, &ControlPoint) + Send + Sync + 'static>(
143 &self,
144 f: F,
145 ) -> SignalHandlerId {
146 unsafe extern "C" fn value_removed_trampoline<
147 P: IsA<TimedValueControlSource>,
148 F: Fn(&P, &ControlPoint) + Send + Sync + 'static,
149 >(
150 this: *mut ffi::GstTimedValueControlSource,
151 timed_value: *mut ffi::GstControlPoint,
152 f: glib::ffi::gpointer,
153 ) {
154 let f: &F = &*(f as *const F);
155 f(
156 TimedValueControlSource::from_glib_borrow(this).unsafe_cast_ref(),
157 &from_glib_borrow(timed_value),
158 )
159 }
160 unsafe {
161 let f: Box_<F> = Box_::new(f);
162 connect_raw(
163 self.as_ptr() as *mut _,
164 c"value-removed".as_ptr() as *const _,
165 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
166 value_removed_trampoline::<Self, F> as *const (),
167 )),
168 Box_::into_raw(f),
169 )
170 }
171 }
172}
173
174impl<O: IsA<TimedValueControlSource>> TimedValueControlSourceExt for O {}