gstreamer_net/auto/ptp_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::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// 1024 and thus requires special
16 /// privileges. Once this helper process is started, the main process will
17 /// synchronize to all PTP domains that are detected on the selected
18 /// interfaces.
19 ///
20 /// [`new()`][Self::new()] then allows to create a GstClock that provides the PTP
21 /// time from a master clock inside a specific PTP domain. This clock will only
22 /// return valid timestamps once the timestamps in the PTP domain are known. To
23 /// check this, you can use [`ClockExtManual::wait_for_sync()`][crate::gst::prelude::ClockExtManual::wait_for_sync()], the GstClock::synced
24 /// signal and [`ClockExtManual::is_synced()`][crate::gst::prelude::ClockExtManual::is_synced()].
25 ///
26 /// To gather statistics about the PTP clock synchronization,
27 /// `gst_ptp_statistics_callback_add()` can be used. This gives the application
28 /// the possibility to collect all kinds of statistics from the clock
29 /// synchronization.
30 ///
31 /// ## Properties
32 ///
33 ///
34 /// #### `domain`
35 /// Readable | Writable | Construct Only
36 ///
37 ///
38 /// #### `grandmaster-clock-id`
39 /// Readable
40 ///
41 ///
42 /// #### `internal-clock`
43 /// Readable
44 ///
45 ///
46 /// #### `master-clock-id`
47 /// Readable
48 /// <details><summary><h4>SystemClock</h4></summary>
49 ///
50 ///
51 /// #### `clock-type`
52 /// Readable | Writable
53 /// </details>
54 /// <details><summary><h4>Clock</h4></summary>
55 ///
56 ///
57 /// #### `timeout`
58 /// Readable | Writable
59 ///
60 ///
61 /// #### `window-size`
62 /// Readable | Writable
63 ///
64 ///
65 /// #### `window-threshold`
66 /// Readable | Writable
67 /// </details>
68 /// <details><summary><h4>Object</h4></summary>
69 ///
70 ///
71 /// #### `name`
72 /// Readable | Writable | Construct
73 ///
74 ///
75 /// #### `parent`
76 /// The parent of the object. Please note, that when changing the 'parent'
77 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
78 /// signals due to locking issues. In some cases one can use
79 /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
80 /// achieve a similar effect.
81 ///
82 /// Readable | Writable
83 /// </details>
84 ///
85 /// # Implements
86 ///
87 /// [`trait@gst::prelude::ClockExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
88 #[doc(alias = "GstPtpClock")]
89 pub struct PtpClock(Object<ffi::GstPtpClock, ffi::GstPtpClockClass>) @extends gst::Clock, gst::Object;
90
91 match fn {
92 type_ => || ffi::gst_ptp_clock_get_type(),
93 }
94}
95
96impl PtpClock {
97 /// Creates a new PTP clock instance that exports the PTP time of the master
98 /// clock in `domain`. This clock can be slaved to other clocks as needed.
99 ///
100 /// If `gst_ptp_init()` was not called before, this will call `gst_ptp_init()` with
101 /// default parameters.
102 ///
103 /// This clock only returns valid timestamps after it received the first
104 /// times from the PTP master clock on the network. Once this happens the
105 /// GstPtpClock::internal-clock property will become non-NULL. You can
106 /// check this with [`ClockExtManual::wait_for_sync()`][crate::gst::prelude::ClockExtManual::wait_for_sync()], the GstClock::synced signal and
107 /// [`ClockExtManual::is_synced()`][crate::gst::prelude::ClockExtManual::is_synced()].
108 /// ## `name`
109 /// Name of the clock
110 /// ## `domain`
111 /// PTP domain
112 ///
113 /// # Returns
114 ///
115 /// A new [`gst::Clock`][crate::gst::Clock]
116 #[doc(alias = "gst_ptp_clock_new")]
117 pub fn new(name: Option<&str>, domain: u32) -> Result<PtpClock, glib::BoolError> {
118 assert_initialized_main_thread!();
119 unsafe {
120 Option::<gst::Clock>::from_glib_full(ffi::gst_ptp_clock_new(
121 name.to_glib_none().0,
122 domain,
123 ))
124 .map(|o| o.unsafe_cast())
125 .ok_or_else(|| glib::bool_error!("Can't create gst::PtpClock"))
126 }
127 }
128
129 pub fn domain(&self) -> u32 {
130 ObjectExt::property(self, "domain")
131 }
132
133 #[doc(alias = "grandmaster-clock-id")]
134 pub fn grandmaster_clock_id(&self) -> u64 {
135 ObjectExt::property(self, "grandmaster-clock-id")
136 }
137
138 #[doc(alias = "internal-clock")]
139 pub fn internal_clock(&self) -> Option<gst::Clock> {
140 ObjectExt::property(self, "internal-clock")
141 }
142
143 #[doc(alias = "master-clock-id")]
144 pub fn master_clock_id(&self) -> u64 {
145 ObjectExt::property(self, "master-clock-id")
146 }
147
148 #[doc(alias = "grandmaster-clock-id")]
149 pub fn connect_grandmaster_clock_id_notify<F: Fn(&Self) + Send + Sync + 'static>(
150 &self,
151 f: F,
152 ) -> SignalHandlerId {
153 unsafe extern "C" fn notify_grandmaster_clock_id_trampoline<
154 F: Fn(&PtpClock) + Send + Sync + 'static,
155 >(
156 this: *mut ffi::GstPtpClock,
157 _param_spec: glib::ffi::gpointer,
158 f: glib::ffi::gpointer,
159 ) {
160 unsafe {
161 let f: &F = &*(f as *const F);
162 f(&from_glib_borrow(this))
163 }
164 }
165 unsafe {
166 let f: Box_<F> = Box_::new(f);
167 connect_raw(
168 self.as_ptr() as *mut _,
169 c"notify::grandmaster-clock-id".as_ptr(),
170 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
171 notify_grandmaster_clock_id_trampoline::<F> as *const (),
172 )),
173 Box_::into_raw(f),
174 )
175 }
176 }
177
178 #[doc(alias = "internal-clock")]
179 pub fn connect_internal_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
180 &self,
181 f: F,
182 ) -> SignalHandlerId {
183 unsafe extern "C" fn notify_internal_clock_trampoline<
184 F: Fn(&PtpClock) + Send + Sync + 'static,
185 >(
186 this: *mut ffi::GstPtpClock,
187 _param_spec: glib::ffi::gpointer,
188 f: glib::ffi::gpointer,
189 ) {
190 unsafe {
191 let f: &F = &*(f as *const F);
192 f(&from_glib_borrow(this))
193 }
194 }
195 unsafe {
196 let f: Box_<F> = Box_::new(f);
197 connect_raw(
198 self.as_ptr() as *mut _,
199 c"notify::internal-clock".as_ptr(),
200 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
201 notify_internal_clock_trampoline::<F> as *const (),
202 )),
203 Box_::into_raw(f),
204 )
205 }
206 }
207
208 #[doc(alias = "master-clock-id")]
209 pub fn connect_master_clock_id_notify<F: Fn(&Self) + Send + Sync + 'static>(
210 &self,
211 f: F,
212 ) -> SignalHandlerId {
213 unsafe extern "C" fn notify_master_clock_id_trampoline<
214 F: Fn(&PtpClock) + Send + Sync + 'static,
215 >(
216 this: *mut ffi::GstPtpClock,
217 _param_spec: glib::ffi::gpointer,
218 f: glib::ffi::gpointer,
219 ) {
220 unsafe {
221 let f: &F = &*(f as *const F);
222 f(&from_glib_borrow(this))
223 }
224 }
225 unsafe {
226 let f: Box_<F> = Box_::new(f);
227 connect_raw(
228 self.as_ptr() as *mut _,
229 c"notify::master-clock-id".as_ptr(),
230 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
231 notify_master_clock_id_trampoline::<F> as *const (),
232 )),
233 Box_::into_raw(f),
234 )
235 }
236 }
237}
238
239unsafe impl Send for PtpClock {}
240unsafe impl Sync for PtpClock {}