gstreamer_check/auto/
test_clock.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;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GstTestClock")]
16    pub struct TestClock(Object<ffi::GstTestClock, ffi::GstTestClockClass>) @extends gst::Clock, gst::Object;
17
18    match fn {
19        type_ => || ffi::gst_test_clock_get_type(),
20    }
21}
22
23impl TestClock {
24    #[doc(alias = "gst_test_clock_new")]
25    pub fn new() -> TestClock {
26        assert_initialized_main_thread!();
27        unsafe { gst::Clock::from_glib_full(ffi::gst_test_clock_new()).unsafe_cast() }
28    }
29
30    #[doc(alias = "gst_test_clock_new_with_start_time")]
31    #[doc(alias = "new_with_start_time")]
32    pub fn with_start_time(start_time: gst::ClockTime) -> TestClock {
33        assert_initialized_main_thread!();
34        unsafe {
35            gst::Clock::from_glib_full(ffi::gst_test_clock_new_with_start_time(
36                start_time.into_glib(),
37            ))
38            .unsafe_cast()
39        }
40    }
41
42    #[doc(alias = "gst_test_clock_advance_time")]
43    pub fn advance_time(&self, delta: gst::ClockTimeDiff) {
44        unsafe {
45            ffi::gst_test_clock_advance_time(self.to_glib_none().0, delta);
46        }
47    }
48
49    #[doc(alias = "gst_test_clock_crank")]
50    pub fn crank(&self) -> bool {
51        unsafe { from_glib(ffi::gst_test_clock_crank(self.to_glib_none().0)) }
52    }
53
54    #[doc(alias = "gst_test_clock_get_next_entry_time")]
55    #[doc(alias = "get_next_entry_time")]
56    pub fn next_entry_time(&self) -> Option<gst::ClockTime> {
57        unsafe {
58            from_glib(ffi::gst_test_clock_get_next_entry_time(
59                self.to_glib_none().0,
60            ))
61        }
62    }
63
64    #[doc(alias = "gst_test_clock_peek_id_count")]
65    pub fn peek_id_count(&self) -> u32 {
66        unsafe { ffi::gst_test_clock_peek_id_count(self.to_glib_none().0) }
67    }
68
69    #[doc(alias = "gst_test_clock_set_time")]
70    pub fn set_time(&self, new_time: gst::ClockTime) {
71        unsafe {
72            ffi::gst_test_clock_set_time(self.to_glib_none().0, new_time.into_glib());
73        }
74    }
75
76    #[doc(alias = "gst_test_clock_wait_for_pending_id_count")]
77    pub fn wait_for_pending_id_count(&self, count: u32) {
78        unsafe {
79            ffi::gst_test_clock_wait_for_pending_id_count(self.to_glib_none().0, count);
80        }
81    }
82
83    #[doc(alias = "clock-type")]
84    pub fn clock_type(&self) -> gst::ClockType {
85        ObjectExt::property(self, "clock-type")
86    }
87
88    #[doc(alias = "clock-type")]
89    pub fn set_clock_type(&self, clock_type: gst::ClockType) {
90        ObjectExt::set_property(self, "clock-type", clock_type)
91    }
92
93    #[doc(alias = "start-time")]
94    pub fn start_time(&self) -> u64 {
95        ObjectExt::property(self, "start-time")
96    }
97
98    //#[doc(alias = "gst_test_clock_id_list_get_latest_time")]
99    //pub fn id_list_get_latest_time(pending_list: /*Unimplemented*/&[&gst::ClockID]) -> Option<gst::ClockTime> {
100    //    unsafe { TODO: call ffi:gst_test_clock_id_list_get_latest_time() }
101    //}
102
103    #[doc(alias = "clock-type")]
104    pub fn connect_clock_type_notify<F: Fn(&Self) + Send + Sync + 'static>(
105        &self,
106        f: F,
107    ) -> SignalHandlerId {
108        unsafe extern "C" fn notify_clock_type_trampoline<
109            F: Fn(&TestClock) + Send + Sync + 'static,
110        >(
111            this: *mut ffi::GstTestClock,
112            _param_spec: glib::ffi::gpointer,
113            f: glib::ffi::gpointer,
114        ) {
115            let f: &F = &*(f as *const F);
116            f(&from_glib_borrow(this))
117        }
118        unsafe {
119            let f: Box_<F> = Box_::new(f);
120            connect_raw(
121                self.as_ptr() as *mut _,
122                c"notify::clock-type".as_ptr() as *const _,
123                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
124                    notify_clock_type_trampoline::<F> as *const (),
125                )),
126                Box_::into_raw(f),
127            )
128        }
129    }
130}
131
132impl Default for TestClock {
133    fn default() -> Self {
134        Self::new()
135    }
136}
137
138unsafe impl Send for TestClock {}
139unsafe impl Sync for TestClock {}