Skip to main content

gstreamer_net/auto/
net_client_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    /// [`NetClientClock`][crate::NetClientClock] implements a custom [`gst::Clock`][crate::gst::Clock] that synchronizes its time
16    /// to a remote time provider such as [`NetTimeProvider`][crate::NetTimeProvider]. [`NtpClock`][crate::NtpClock]
17    /// implements a [`gst::Clock`][crate::gst::Clock] that synchronizes its time to a remote NTPv4 server.
18    ///
19    /// A new clock is created with [`new()`][Self::new()] or
20    /// [`NtpClock::new()`][crate::NtpClock::new()], which takes the address and port of the remote time
21    /// provider along with a name and an initial time.
22    ///
23    /// This clock will poll the time provider and will update its calibration
24    /// parameters based on the local and remote observations.
25    ///
26    /// The "round-trip" property limits the maximum round trip packets can take.
27    ///
28    /// Various parameters of the clock can be configured with the parent [`gst::Clock`][crate::gst::Clock]
29    /// "timeout", "window-size" and "window-threshold" object properties.
30    ///
31    /// A [`NetClientClock`][crate::NetClientClock] and [`NtpClock`][crate::NtpClock] is typically set on a [`gst::Pipeline`][crate::gst::Pipeline] with
32    /// [`PipelineExtManual::use_clock()`][crate::gst::prelude::PipelineExtManual::use_clock()].
33    ///
34    /// If you set a [`gst::Bus`][crate::gst::Bus] on the clock via the "bus" object property, it will
35    /// send `GST_MESSAGE_ELEMENT` messages with an attached [`gst::Structure`][crate::gst::Structure] containing
36    /// statistics about clock accuracy and network traffic.
37    ///
38    /// ## Properties
39    ///
40    ///
41    /// #### `address`
42    ///  Readable | Writeable | Construct
43    ///
44    ///
45    /// #### `base-time`
46    ///  Readable | Writeable | Construct Only
47    ///
48    ///
49    /// #### `bus`
50    ///  Readable | Writeable
51    ///
52    ///
53    /// #### `internal-clock`
54    ///  Readable
55    ///
56    ///
57    /// #### `minimum-update-interval`
58    ///  Readable | Writeable
59    ///
60    ///
61    /// #### `port`
62    ///  Readable | Writeable | Construct
63    ///
64    ///
65    /// #### `qos-dscp`
66    ///  Readable | Writeable
67    ///
68    ///
69    /// #### `round-trip-limit`
70    ///  Readable | Writeable
71    /// <details><summary><h4>SystemClock</h4></summary>
72    ///
73    ///
74    /// #### `clock-type`
75    ///  Readable | Writeable
76    /// </details>
77    /// <details><summary><h4>Clock</h4></summary>
78    ///
79    ///
80    /// #### `timeout`
81    ///  Readable | Writeable
82    ///
83    ///
84    /// #### `window-size`
85    ///  Readable | Writeable
86    ///
87    ///
88    /// #### `window-threshold`
89    ///  Readable | Writeable
90    /// </details>
91    /// <details><summary><h4>Object</h4></summary>
92    ///
93    ///
94    /// #### `name`
95    ///  Readable | Writeable | Construct
96    ///
97    ///
98    /// #### `parent`
99    ///  The parent of the object. Please note, that when changing the 'parent'
100    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
101    /// signals due to locking issues. In some cases one can use
102    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
103    /// achieve a similar effect.
104    ///
105    /// Readable | Writeable
106    /// </details>
107    ///
108    /// # Implements
109    ///
110    /// [`trait@gst::prelude::ClockExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
111    #[doc(alias = "GstNetClientClock")]
112    pub struct NetClientClock(Object<ffi::GstNetClientClock, ffi::GstNetClientClockClass>) @extends gst::Clock, gst::Object;
113
114    match fn {
115        type_ => || ffi::gst_net_client_clock_get_type(),
116    }
117}
118
119impl NetClientClock {
120    /// Create a new [`NetClientClock`][crate::NetClientClock] that will report the time
121    /// provided by the [`NetTimeProvider`][crate::NetTimeProvider] on `remote_address` and
122    /// `remote_port`.
123    /// ## `name`
124    /// a name for the clock
125    /// ## `remote_address`
126    /// the address or hostname of the remote clock provider
127    /// ## `remote_port`
128    /// the port of the remote clock provider
129    /// ## `base_time`
130    /// initial time of the clock
131    ///
132    /// # Returns
133    ///
134    /// a new [`gst::Clock`][crate::gst::Clock] that receives a time from the remote
135    /// clock.
136    #[doc(alias = "gst_net_client_clock_new")]
137    pub fn new(
138        name: Option<&str>,
139        remote_address: &str,
140        remote_port: i32,
141        base_time: impl Into<Option<gst::ClockTime>>,
142    ) -> NetClientClock {
143        assert_initialized_main_thread!();
144        unsafe {
145            gst::Clock::from_glib_full(ffi::gst_net_client_clock_new(
146                name.to_glib_none().0,
147                remote_address.to_glib_none().0,
148                remote_port,
149                base_time.into().into_glib(),
150            ))
151            .unsafe_cast()
152        }
153    }
154
155    pub fn address(&self) -> Option<glib::GString> {
156        ObjectExt::property(self, "address")
157    }
158
159    pub fn set_address(&self, address: Option<&str>) {
160        ObjectExt::set_property(self, "address", address)
161    }
162
163    #[doc(alias = "base-time")]
164    pub fn base_time(&self) -> u64 {
165        ObjectExt::property(self, "base-time")
166    }
167
168    pub fn bus(&self) -> Option<gst::Bus> {
169        ObjectExt::property(self, "bus")
170    }
171
172    pub fn set_bus<P: IsA<gst::Bus>>(&self, bus: Option<&P>) {
173        ObjectExt::set_property(self, "bus", bus)
174    }
175
176    #[doc(alias = "internal-clock")]
177    pub fn internal_clock(&self) -> Option<gst::Clock> {
178        ObjectExt::property(self, "internal-clock")
179    }
180
181    #[doc(alias = "minimum-update-interval")]
182    pub fn minimum_update_interval(&self) -> u64 {
183        ObjectExt::property(self, "minimum-update-interval")
184    }
185
186    #[doc(alias = "minimum-update-interval")]
187    pub fn set_minimum_update_interval(&self, minimum_update_interval: u64) {
188        ObjectExt::set_property(self, "minimum-update-interval", minimum_update_interval)
189    }
190
191    pub fn port(&self) -> i32 {
192        ObjectExt::property(self, "port")
193    }
194
195    pub fn set_port(&self, port: i32) {
196        ObjectExt::set_property(self, "port", port)
197    }
198
199    #[doc(alias = "qos-dscp")]
200    pub fn qos_dscp(&self) -> i32 {
201        ObjectExt::property(self, "qos-dscp")
202    }
203
204    #[doc(alias = "qos-dscp")]
205    pub fn set_qos_dscp(&self, qos_dscp: i32) {
206        ObjectExt::set_property(self, "qos-dscp", qos_dscp)
207    }
208
209    #[doc(alias = "round-trip-limit")]
210    pub fn round_trip_limit(&self) -> u64 {
211        ObjectExt::property(self, "round-trip-limit")
212    }
213
214    #[doc(alias = "round-trip-limit")]
215    pub fn set_round_trip_limit(&self, round_trip_limit: u64) {
216        ObjectExt::set_property(self, "round-trip-limit", round_trip_limit)
217    }
218
219    /// Clears any cached [`NetClientClock`][crate::NetClientClock] clocks.
220    /// All references should be released beforehand.
221    /// Mainly used for testing.
222    #[cfg(feature = "v1_28")]
223    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
224    #[doc(alias = "gst_net_client_clock_deinit")]
225    pub fn deinit() {
226        assert_initialized_main_thread!();
227        unsafe {
228            ffi::gst_net_client_clock_deinit();
229        }
230    }
231
232    #[doc(alias = "address")]
233    pub fn connect_address_notify<F: Fn(&Self) + Send + Sync + 'static>(
234        &self,
235        f: F,
236    ) -> SignalHandlerId {
237        unsafe extern "C" fn notify_address_trampoline<
238            F: Fn(&NetClientClock) + Send + Sync + 'static,
239        >(
240            this: *mut ffi::GstNetClientClock,
241            _param_spec: glib::ffi::gpointer,
242            f: glib::ffi::gpointer,
243        ) {
244            unsafe {
245                let f: &F = &*(f as *const F);
246                f(&from_glib_borrow(this))
247            }
248        }
249        unsafe {
250            let f: Box_<F> = Box_::new(f);
251            connect_raw(
252                self.as_ptr() as *mut _,
253                c"notify::address".as_ptr(),
254                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
255                    notify_address_trampoline::<F> as *const (),
256                )),
257                Box_::into_raw(f),
258            )
259        }
260    }
261
262    #[doc(alias = "bus")]
263    pub fn connect_bus_notify<F: Fn(&Self) + Send + Sync + 'static>(
264        &self,
265        f: F,
266    ) -> SignalHandlerId {
267        unsafe extern "C" fn notify_bus_trampoline<
268            F: Fn(&NetClientClock) + Send + Sync + 'static,
269        >(
270            this: *mut ffi::GstNetClientClock,
271            _param_spec: glib::ffi::gpointer,
272            f: glib::ffi::gpointer,
273        ) {
274            unsafe {
275                let f: &F = &*(f as *const F);
276                f(&from_glib_borrow(this))
277            }
278        }
279        unsafe {
280            let f: Box_<F> = Box_::new(f);
281            connect_raw(
282                self.as_ptr() as *mut _,
283                c"notify::bus".as_ptr(),
284                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
285                    notify_bus_trampoline::<F> as *const (),
286                )),
287                Box_::into_raw(f),
288            )
289        }
290    }
291
292    #[doc(alias = "internal-clock")]
293    pub fn connect_internal_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
294        &self,
295        f: F,
296    ) -> SignalHandlerId {
297        unsafe extern "C" fn notify_internal_clock_trampoline<
298            F: Fn(&NetClientClock) + Send + Sync + 'static,
299        >(
300            this: *mut ffi::GstNetClientClock,
301            _param_spec: glib::ffi::gpointer,
302            f: glib::ffi::gpointer,
303        ) {
304            unsafe {
305                let f: &F = &*(f as *const F);
306                f(&from_glib_borrow(this))
307            }
308        }
309        unsafe {
310            let f: Box_<F> = Box_::new(f);
311            connect_raw(
312                self.as_ptr() as *mut _,
313                c"notify::internal-clock".as_ptr(),
314                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
315                    notify_internal_clock_trampoline::<F> as *const (),
316                )),
317                Box_::into_raw(f),
318            )
319        }
320    }
321
322    #[doc(alias = "minimum-update-interval")]
323    pub fn connect_minimum_update_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
324        &self,
325        f: F,
326    ) -> SignalHandlerId {
327        unsafe extern "C" fn notify_minimum_update_interval_trampoline<
328            F: Fn(&NetClientClock) + Send + Sync + 'static,
329        >(
330            this: *mut ffi::GstNetClientClock,
331            _param_spec: glib::ffi::gpointer,
332            f: glib::ffi::gpointer,
333        ) {
334            unsafe {
335                let f: &F = &*(f as *const F);
336                f(&from_glib_borrow(this))
337            }
338        }
339        unsafe {
340            let f: Box_<F> = Box_::new(f);
341            connect_raw(
342                self.as_ptr() as *mut _,
343                c"notify::minimum-update-interval".as_ptr(),
344                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
345                    notify_minimum_update_interval_trampoline::<F> as *const (),
346                )),
347                Box_::into_raw(f),
348            )
349        }
350    }
351
352    #[doc(alias = "port")]
353    pub fn connect_port_notify<F: Fn(&Self) + Send + Sync + 'static>(
354        &self,
355        f: F,
356    ) -> SignalHandlerId {
357        unsafe extern "C" fn notify_port_trampoline<
358            F: Fn(&NetClientClock) + Send + Sync + 'static,
359        >(
360            this: *mut ffi::GstNetClientClock,
361            _param_spec: glib::ffi::gpointer,
362            f: glib::ffi::gpointer,
363        ) {
364            unsafe {
365                let f: &F = &*(f as *const F);
366                f(&from_glib_borrow(this))
367            }
368        }
369        unsafe {
370            let f: Box_<F> = Box_::new(f);
371            connect_raw(
372                self.as_ptr() as *mut _,
373                c"notify::port".as_ptr(),
374                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
375                    notify_port_trampoline::<F> as *const (),
376                )),
377                Box_::into_raw(f),
378            )
379        }
380    }
381
382    #[doc(alias = "qos-dscp")]
383    pub fn connect_qos_dscp_notify<F: Fn(&Self) + Send + Sync + 'static>(
384        &self,
385        f: F,
386    ) -> SignalHandlerId {
387        unsafe extern "C" fn notify_qos_dscp_trampoline<
388            F: Fn(&NetClientClock) + Send + Sync + 'static,
389        >(
390            this: *mut ffi::GstNetClientClock,
391            _param_spec: glib::ffi::gpointer,
392            f: glib::ffi::gpointer,
393        ) {
394            unsafe {
395                let f: &F = &*(f as *const F);
396                f(&from_glib_borrow(this))
397            }
398        }
399        unsafe {
400            let f: Box_<F> = Box_::new(f);
401            connect_raw(
402                self.as_ptr() as *mut _,
403                c"notify::qos-dscp".as_ptr(),
404                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
405                    notify_qos_dscp_trampoline::<F> as *const (),
406                )),
407                Box_::into_raw(f),
408            )
409        }
410    }
411
412    #[doc(alias = "round-trip-limit")]
413    pub fn connect_round_trip_limit_notify<F: Fn(&Self) + Send + Sync + 'static>(
414        &self,
415        f: F,
416    ) -> SignalHandlerId {
417        unsafe extern "C" fn notify_round_trip_limit_trampoline<
418            F: Fn(&NetClientClock) + Send + Sync + 'static,
419        >(
420            this: *mut ffi::GstNetClientClock,
421            _param_spec: glib::ffi::gpointer,
422            f: glib::ffi::gpointer,
423        ) {
424            unsafe {
425                let f: &F = &*(f as *const F);
426                f(&from_glib_borrow(this))
427            }
428        }
429        unsafe {
430            let f: Box_<F> = Box_::new(f);
431            connect_raw(
432                self.as_ptr() as *mut _,
433                c"notify::round-trip-limit".as_ptr(),
434                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
435                    notify_round_trip_limit_trampoline::<F> as *const (),
436                )),
437                Box_::into_raw(f),
438            )
439        }
440    }
441}
442
443unsafe impl Send for NetClientClock {}
444unsafe impl Sync for NetClientClock {}