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 | |
6 | use crate::{ClockTime, Object}; |
7 | use glib::{ |
8 | prelude::*, |
9 | signal::{connect_raw, SignalHandlerId}, |
10 | translate::*, |
11 | }; |
12 | use std::{boxed::Box as Box_, mem, mem::transmute}; |
13 | |
14 | glib::wrapper! { |
15 | #[doc (alias = "GstClock" )] |
16 | pub struct Clock(Object<ffi::GstClock, ffi::GstClockClass>) @extends Object; |
17 | |
18 | match fn { |
19 | type_ => || ffi::gst_clock_get_type(), |
20 | } |
21 | } |
22 | |
23 | impl Clock { |
24 | pub const NONE: Option<&'static Clock> = None; |
25 | |
26 | //#[doc(alias = "gst_clock_id_compare_func")] |
27 | //pub fn id_compare_func(id1: /*Unimplemented*/Option<Basic: Pointer>, id2: /*Unimplemented*/Option<Basic: Pointer>) -> i32 { |
28 | // unsafe { TODO: call ffi:gst_clock_id_compare_func() } |
29 | //} |
30 | |
31 | //#[cfg(feature = "v1_16")] |
32 | //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] |
33 | //#[doc(alias = "gst_clock_id_get_clock")] |
34 | //pub fn id_get_clock(id: /*Unimplemented*/ClockID) -> Option<Clock> { |
35 | // unsafe { TODO: call ffi:gst_clock_id_get_clock() } |
36 | //} |
37 | |
38 | //#[doc(alias = "gst_clock_id_get_time")] |
39 | //pub fn id_get_time(id: /*Unimplemented*/ClockID) -> Option<ClockTime> { |
40 | // unsafe { TODO: call ffi:gst_clock_id_get_time() } |
41 | //} |
42 | |
43 | //#[doc(alias = "gst_clock_id_ref")] |
44 | //pub fn id_ref(id: /*Unimplemented*/ClockID) -> /*Unimplemented*/ClockID { |
45 | // unsafe { TODO: call ffi:gst_clock_id_ref() } |
46 | //} |
47 | |
48 | //#[doc(alias = "gst_clock_id_unref")] |
49 | //pub fn id_unref(id: /*Unimplemented*/ClockID) { |
50 | // unsafe { TODO: call ffi:gst_clock_id_unref() } |
51 | //} |
52 | |
53 | //#[doc(alias = "gst_clock_id_unschedule")] |
54 | //pub fn id_unschedule(id: /*Unimplemented*/ClockID) { |
55 | // unsafe { TODO: call ffi:gst_clock_id_unschedule() } |
56 | //} |
57 | |
58 | //#[cfg(feature = "v1_16")] |
59 | //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] |
60 | //#[doc(alias = "gst_clock_id_uses_clock")] |
61 | //pub fn id_uses_clock(id: /*Unimplemented*/ClockID, clock: &impl IsA<Clock>) -> bool { |
62 | // unsafe { TODO: call ffi:gst_clock_id_uses_clock() } |
63 | //} |
64 | |
65 | //#[doc(alias = "gst_clock_id_wait")] |
66 | //pub fn id_wait(id: /*Unimplemented*/ClockID) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff) { |
67 | // unsafe { TODO: call ffi:gst_clock_id_wait() } |
68 | //} |
69 | |
70 | //#[doc(alias = "gst_clock_id_wait_async")] |
71 | //pub fn id_wait_async(id: /*Unimplemented*/ClockID, func: /*Unimplemented*/Fn(&Clock, impl Into<Option<ClockTime>>, /*Unimplemented*/ClockID) -> bool, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> Result<ClockSuccess, ClockError> { |
72 | // unsafe { TODO: call ffi:gst_clock_id_wait_async() } |
73 | //} |
74 | } |
75 | |
76 | unsafe impl Send for Clock {} |
77 | unsafe impl Sync for Clock {} |
78 | |
79 | mod sealed { |
80 | pub trait Sealed {} |
81 | impl<T: super::IsA<super::Clock>> Sealed for T {} |
82 | } |
83 | |
84 | pub trait ClockExt: IsA<Clock> + sealed::Sealed + 'static { |
85 | #[doc (alias = "gst_clock_add_observation" )] |
86 | fn add_observation(&self, slave: ClockTime, master: ClockTime) -> Option<f64> { |
87 | unsafe { |
88 | let mut r_squared = mem::MaybeUninit::uninit(); |
89 | let ret = from_glib(ffi::gst_clock_add_observation( |
90 | self.as_ref().to_glib_none().0, |
91 | slave.into_glib(), |
92 | master.into_glib(), |
93 | r_squared.as_mut_ptr(), |
94 | )); |
95 | if ret { |
96 | Some(r_squared.assume_init()) |
97 | } else { |
98 | None |
99 | } |
100 | } |
101 | } |
102 | |
103 | #[doc (alias = "gst_clock_add_observation_unapplied" )] |
104 | fn add_observation_unapplied( |
105 | &self, |
106 | slave: ClockTime, |
107 | master: ClockTime, |
108 | ) -> Option<(f64, ClockTime, ClockTime, ClockTime, ClockTime)> { |
109 | unsafe { |
110 | let mut r_squared = mem::MaybeUninit::uninit(); |
111 | let mut internal = mem::MaybeUninit::uninit(); |
112 | let mut external = mem::MaybeUninit::uninit(); |
113 | let mut rate_num = mem::MaybeUninit::uninit(); |
114 | let mut rate_denom = mem::MaybeUninit::uninit(); |
115 | let ret = from_glib(ffi::gst_clock_add_observation_unapplied( |
116 | self.as_ref().to_glib_none().0, |
117 | slave.into_glib(), |
118 | master.into_glib(), |
119 | r_squared.as_mut_ptr(), |
120 | internal.as_mut_ptr(), |
121 | external.as_mut_ptr(), |
122 | rate_num.as_mut_ptr(), |
123 | rate_denom.as_mut_ptr(), |
124 | )); |
125 | if ret { |
126 | Some(( |
127 | r_squared.assume_init(), |
128 | try_from_glib(internal.assume_init()).expect("mandatory glib value is None" ), |
129 | try_from_glib(external.assume_init()).expect("mandatory glib value is None" ), |
130 | try_from_glib(rate_num.assume_init()).expect("mandatory glib value is None" ), |
131 | try_from_glib(rate_denom.assume_init()).expect("mandatory glib value is None" ), |
132 | )) |
133 | } else { |
134 | None |
135 | } |
136 | } |
137 | } |
138 | |
139 | #[doc (alias = "gst_clock_adjust_unlocked" )] |
140 | fn adjust_unlocked(&self, internal: ClockTime) -> Option<ClockTime> { |
141 | unsafe { |
142 | from_glib(ffi::gst_clock_adjust_unlocked( |
143 | self.as_ref().to_glib_none().0, |
144 | internal.into_glib(), |
145 | )) |
146 | } |
147 | } |
148 | |
149 | #[doc (alias = "gst_clock_get_calibration" )] |
150 | #[doc (alias = "get_calibration" )] |
151 | fn calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime) { |
152 | unsafe { |
153 | let mut internal = mem::MaybeUninit::uninit(); |
154 | let mut external = mem::MaybeUninit::uninit(); |
155 | let mut rate_num = mem::MaybeUninit::uninit(); |
156 | let mut rate_denom = mem::MaybeUninit::uninit(); |
157 | ffi::gst_clock_get_calibration( |
158 | self.as_ref().to_glib_none().0, |
159 | internal.as_mut_ptr(), |
160 | external.as_mut_ptr(), |
161 | rate_num.as_mut_ptr(), |
162 | rate_denom.as_mut_ptr(), |
163 | ); |
164 | ( |
165 | try_from_glib(internal.assume_init()).expect("mandatory glib value is None" ), |
166 | try_from_glib(external.assume_init()).expect("mandatory glib value is None" ), |
167 | try_from_glib(rate_num.assume_init()).expect("mandatory glib value is None" ), |
168 | try_from_glib(rate_denom.assume_init()).expect("mandatory glib value is None" ), |
169 | ) |
170 | } |
171 | } |
172 | |
173 | #[doc (alias = "gst_clock_get_internal_time" )] |
174 | #[doc (alias = "get_internal_time" )] |
175 | fn internal_time(&self) -> ClockTime { |
176 | unsafe { |
177 | try_from_glib(ffi::gst_clock_get_internal_time( |
178 | self.as_ref().to_glib_none().0, |
179 | )) |
180 | .expect("mandatory glib value is None" ) |
181 | } |
182 | } |
183 | |
184 | #[doc (alias = "gst_clock_get_master" )] |
185 | #[doc (alias = "get_master" )] |
186 | #[must_use ] |
187 | fn master(&self) -> Option<Clock> { |
188 | unsafe { from_glib_full(ffi::gst_clock_get_master(self.as_ref().to_glib_none().0)) } |
189 | } |
190 | |
191 | #[doc (alias = "gst_clock_get_resolution" )] |
192 | #[doc (alias = "get_resolution" )] |
193 | fn resolution(&self) -> ClockTime { |
194 | unsafe { |
195 | try_from_glib(ffi::gst_clock_get_resolution( |
196 | self.as_ref().to_glib_none().0, |
197 | )) |
198 | .expect("mandatory glib value is None" ) |
199 | } |
200 | } |
201 | |
202 | #[doc (alias = "gst_clock_get_time" )] |
203 | #[doc (alias = "get_time" )] |
204 | fn time(&self) -> Option<ClockTime> { |
205 | unsafe { from_glib(ffi::gst_clock_get_time(self.as_ref().to_glib_none().0)) } |
206 | } |
207 | |
208 | #[doc (alias = "gst_clock_get_timeout" )] |
209 | #[doc (alias = "get_timeout" )] |
210 | fn timeout(&self) -> Option<ClockTime> { |
211 | unsafe { from_glib(ffi::gst_clock_get_timeout(self.as_ref().to_glib_none().0)) } |
212 | } |
213 | |
214 | #[doc (alias = "gst_clock_is_synced" )] |
215 | fn is_synced(&self) -> bool { |
216 | unsafe { from_glib(ffi::gst_clock_is_synced(self.as_ref().to_glib_none().0)) } |
217 | } |
218 | |
219 | #[doc (alias = "gst_clock_set_calibration" )] |
220 | fn set_calibration( |
221 | &self, |
222 | internal: ClockTime, |
223 | external: ClockTime, |
224 | rate_num: ClockTime, |
225 | rate_denom: ClockTime, |
226 | ) { |
227 | unsafe { |
228 | ffi::gst_clock_set_calibration( |
229 | self.as_ref().to_glib_none().0, |
230 | internal.into_glib(), |
231 | external.into_glib(), |
232 | rate_num.into_glib(), |
233 | rate_denom.into_glib(), |
234 | ); |
235 | } |
236 | } |
237 | |
238 | #[doc (alias = "gst_clock_set_master" )] |
239 | fn set_master(&self, master: Option<&impl IsA<Clock>>) -> Result<(), glib::error::BoolError> { |
240 | unsafe { |
241 | glib::result_from_gboolean!( |
242 | ffi::gst_clock_set_master( |
243 | self.as_ref().to_glib_none().0, |
244 | master.map(|p| p.as_ref()).to_glib_none().0 |
245 | ), |
246 | "Failed to set master clock" |
247 | ) |
248 | } |
249 | } |
250 | |
251 | #[doc (alias = "gst_clock_set_resolution" )] |
252 | fn set_resolution(&self, resolution: ClockTime) -> ClockTime { |
253 | unsafe { |
254 | try_from_glib(ffi::gst_clock_set_resolution( |
255 | self.as_ref().to_glib_none().0, |
256 | resolution.into_glib(), |
257 | )) |
258 | .expect("mandatory glib value is None" ) |
259 | } |
260 | } |
261 | |
262 | #[doc (alias = "gst_clock_set_synced" )] |
263 | fn set_synced(&self, synced: bool) { |
264 | unsafe { |
265 | ffi::gst_clock_set_synced(self.as_ref().to_glib_none().0, synced.into_glib()); |
266 | } |
267 | } |
268 | |
269 | #[doc (alias = "gst_clock_set_timeout" )] |
270 | fn set_timeout(&self, timeout: impl Into<Option<ClockTime>>) { |
271 | unsafe { |
272 | ffi::gst_clock_set_timeout(self.as_ref().to_glib_none().0, timeout.into().into_glib()); |
273 | } |
274 | } |
275 | |
276 | #[doc (alias = "gst_clock_unadjust_unlocked" )] |
277 | fn unadjust_unlocked(&self, external: ClockTime) -> Option<ClockTime> { |
278 | unsafe { |
279 | from_glib(ffi::gst_clock_unadjust_unlocked( |
280 | self.as_ref().to_glib_none().0, |
281 | external.into_glib(), |
282 | )) |
283 | } |
284 | } |
285 | |
286 | #[doc (alias = "gst_clock_wait_for_sync" )] |
287 | fn wait_for_sync( |
288 | &self, |
289 | timeout: impl Into<Option<ClockTime>>, |
290 | ) -> Result<(), glib::error::BoolError> { |
291 | unsafe { |
292 | glib::result_from_gboolean!( |
293 | ffi::gst_clock_wait_for_sync( |
294 | self.as_ref().to_glib_none().0, |
295 | timeout.into().into_glib() |
296 | ), |
297 | "Timed out waiting for sync" |
298 | ) |
299 | } |
300 | } |
301 | |
302 | #[doc (alias = "window-size" )] |
303 | fn window_size(&self) -> i32 { |
304 | ObjectExt::property(self.as_ref(), "window-size" ) |
305 | } |
306 | |
307 | #[doc (alias = "window-size" )] |
308 | fn set_window_size(&self, window_size: i32) { |
309 | ObjectExt::set_property(self.as_ref(), "window-size" , window_size) |
310 | } |
311 | |
312 | #[doc (alias = "window-threshold" )] |
313 | fn window_threshold(&self) -> i32 { |
314 | ObjectExt::property(self.as_ref(), "window-threshold" ) |
315 | } |
316 | |
317 | #[doc (alias = "window-threshold" )] |
318 | fn set_window_threshold(&self, window_threshold: i32) { |
319 | ObjectExt::set_property(self.as_ref(), "window-threshold" , window_threshold) |
320 | } |
321 | |
322 | #[doc (alias = "synced" )] |
323 | fn connect_synced<F: Fn(&Self, bool) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { |
324 | unsafe extern "C" fn synced_trampoline< |
325 | P: IsA<Clock>, |
326 | F: Fn(&P, bool) + Send + Sync + 'static, |
327 | >( |
328 | this: *mut ffi::GstClock, |
329 | synced: glib::ffi::gboolean, |
330 | f: glib::ffi::gpointer, |
331 | ) { |
332 | let f: &F = &*(f as *const F); |
333 | f( |
334 | Clock::from_glib_borrow(this).unsafe_cast_ref(), |
335 | from_glib(synced), |
336 | ) |
337 | } |
338 | unsafe { |
339 | let f: Box_<F> = Box_::new(f); |
340 | connect_raw( |
341 | self.as_ptr() as *mut _, |
342 | b"synced \0" .as_ptr() as *const _, |
343 | Some(transmute::<_, unsafe extern "C" fn()>( |
344 | synced_trampoline::<Self, F> as *const (), |
345 | )), |
346 | Box_::into_raw(f), |
347 | ) |
348 | } |
349 | } |
350 | |
351 | #[doc (alias = "timeout" )] |
352 | fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>( |
353 | &self, |
354 | f: F, |
355 | ) -> SignalHandlerId { |
356 | unsafe extern "C" fn notify_timeout_trampoline< |
357 | P: IsA<Clock>, |
358 | F: Fn(&P) + Send + Sync + 'static, |
359 | >( |
360 | this: *mut ffi::GstClock, |
361 | _param_spec: glib::ffi::gpointer, |
362 | f: glib::ffi::gpointer, |
363 | ) { |
364 | let f: &F = &*(f as *const F); |
365 | f(Clock::from_glib_borrow(this).unsafe_cast_ref()) |
366 | } |
367 | unsafe { |
368 | let f: Box_<F> = Box_::new(f); |
369 | connect_raw( |
370 | self.as_ptr() as *mut _, |
371 | b"notify::timeout \0" .as_ptr() as *const _, |
372 | Some(transmute::<_, unsafe extern "C" fn()>( |
373 | notify_timeout_trampoline::<Self, F> as *const (), |
374 | )), |
375 | Box_::into_raw(f), |
376 | ) |
377 | } |
378 | } |
379 | |
380 | #[doc (alias = "window-size" )] |
381 | fn connect_window_size_notify<F: Fn(&Self) + Send + Sync + 'static>( |
382 | &self, |
383 | f: F, |
384 | ) -> SignalHandlerId { |
385 | unsafe extern "C" fn notify_window_size_trampoline< |
386 | P: IsA<Clock>, |
387 | F: Fn(&P) + Send + Sync + 'static, |
388 | >( |
389 | this: *mut ffi::GstClock, |
390 | _param_spec: glib::ffi::gpointer, |
391 | f: glib::ffi::gpointer, |
392 | ) { |
393 | let f: &F = &*(f as *const F); |
394 | f(Clock::from_glib_borrow(this).unsafe_cast_ref()) |
395 | } |
396 | unsafe { |
397 | let f: Box_<F> = Box_::new(f); |
398 | connect_raw( |
399 | self.as_ptr() as *mut _, |
400 | b"notify::window-size \0" .as_ptr() as *const _, |
401 | Some(transmute::<_, unsafe extern "C" fn()>( |
402 | notify_window_size_trampoline::<Self, F> as *const (), |
403 | )), |
404 | Box_::into_raw(f), |
405 | ) |
406 | } |
407 | } |
408 | |
409 | #[doc (alias = "window-threshold" )] |
410 | fn connect_window_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>( |
411 | &self, |
412 | f: F, |
413 | ) -> SignalHandlerId { |
414 | unsafe extern "C" fn notify_window_threshold_trampoline< |
415 | P: IsA<Clock>, |
416 | F: Fn(&P) + Send + Sync + 'static, |
417 | >( |
418 | this: *mut ffi::GstClock, |
419 | _param_spec: glib::ffi::gpointer, |
420 | f: glib::ffi::gpointer, |
421 | ) { |
422 | let f: &F = &*(f as *const F); |
423 | f(Clock::from_glib_borrow(this).unsafe_cast_ref()) |
424 | } |
425 | unsafe { |
426 | let f: Box_<F> = Box_::new(f); |
427 | connect_raw( |
428 | self.as_ptr() as *mut _, |
429 | b"notify::window-threshold \0" .as_ptr() as *const _, |
430 | Some(transmute::<_, unsafe extern "C" fn()>( |
431 | notify_window_threshold_trampoline::<Self, F> as *const (), |
432 | )), |
433 | Box_::into_raw(f), |
434 | ) |
435 | } |
436 | } |
437 | } |
438 | |
439 | impl<O: IsA<Clock>> ClockExt for O {} |
440 | |