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::{connect_raw, SignalHandlerId},
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            let f: &F = &*(f as *const F);
245            f(&from_glib_borrow(this))
246        }
247        unsafe {
248            let f: Box_<F> = Box_::new(f);
249            connect_raw(
250                self.as_ptr() as *mut _,
251                c"notify::address".as_ptr() as *const _,
252                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
253                    notify_address_trampoline::<F> as *const (),
254                )),
255                Box_::into_raw(f),
256            )
257        }
258    }
259
260    #[doc(alias = "bus")]
261    pub fn connect_bus_notify<F: Fn(&Self) + Send + Sync + 'static>(
262        &self,
263        f: F,
264    ) -> SignalHandlerId {
265        unsafe extern "C" fn notify_bus_trampoline<
266            F: Fn(&NetClientClock) + Send + Sync + 'static,
267        >(
268            this: *mut ffi::GstNetClientClock,
269            _param_spec: glib::ffi::gpointer,
270            f: glib::ffi::gpointer,
271        ) {
272            let f: &F = &*(f as *const F);
273            f(&from_glib_borrow(this))
274        }
275        unsafe {
276            let f: Box_<F> = Box_::new(f);
277            connect_raw(
278                self.as_ptr() as *mut _,
279                c"notify::bus".as_ptr() as *const _,
280                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
281                    notify_bus_trampoline::<F> as *const (),
282                )),
283                Box_::into_raw(f),
284            )
285        }
286    }
287
288    #[doc(alias = "internal-clock")]
289    pub fn connect_internal_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
290        &self,
291        f: F,
292    ) -> SignalHandlerId {
293        unsafe extern "C" fn notify_internal_clock_trampoline<
294            F: Fn(&NetClientClock) + Send + Sync + 'static,
295        >(
296            this: *mut ffi::GstNetClientClock,
297            _param_spec: glib::ffi::gpointer,
298            f: glib::ffi::gpointer,
299        ) {
300            let f: &F = &*(f as *const F);
301            f(&from_glib_borrow(this))
302        }
303        unsafe {
304            let f: Box_<F> = Box_::new(f);
305            connect_raw(
306                self.as_ptr() as *mut _,
307                c"notify::internal-clock".as_ptr() as *const _,
308                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
309                    notify_internal_clock_trampoline::<F> as *const (),
310                )),
311                Box_::into_raw(f),
312            )
313        }
314    }
315
316    #[doc(alias = "minimum-update-interval")]
317    pub fn connect_minimum_update_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
318        &self,
319        f: F,
320    ) -> SignalHandlerId {
321        unsafe extern "C" fn notify_minimum_update_interval_trampoline<
322            F: Fn(&NetClientClock) + Send + Sync + 'static,
323        >(
324            this: *mut ffi::GstNetClientClock,
325            _param_spec: glib::ffi::gpointer,
326            f: glib::ffi::gpointer,
327        ) {
328            let f: &F = &*(f as *const F);
329            f(&from_glib_borrow(this))
330        }
331        unsafe {
332            let f: Box_<F> = Box_::new(f);
333            connect_raw(
334                self.as_ptr() as *mut _,
335                c"notify::minimum-update-interval".as_ptr() as *const _,
336                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
337                    notify_minimum_update_interval_trampoline::<F> as *const (),
338                )),
339                Box_::into_raw(f),
340            )
341        }
342    }
343
344    #[doc(alias = "port")]
345    pub fn connect_port_notify<F: Fn(&Self) + Send + Sync + 'static>(
346        &self,
347        f: F,
348    ) -> SignalHandlerId {
349        unsafe extern "C" fn notify_port_trampoline<
350            F: Fn(&NetClientClock) + Send + Sync + 'static,
351        >(
352            this: *mut ffi::GstNetClientClock,
353            _param_spec: glib::ffi::gpointer,
354            f: glib::ffi::gpointer,
355        ) {
356            let f: &F = &*(f as *const F);
357            f(&from_glib_borrow(this))
358        }
359        unsafe {
360            let f: Box_<F> = Box_::new(f);
361            connect_raw(
362                self.as_ptr() as *mut _,
363                c"notify::port".as_ptr() as *const _,
364                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
365                    notify_port_trampoline::<F> as *const (),
366                )),
367                Box_::into_raw(f),
368            )
369        }
370    }
371
372    #[doc(alias = "qos-dscp")]
373    pub fn connect_qos_dscp_notify<F: Fn(&Self) + Send + Sync + 'static>(
374        &self,
375        f: F,
376    ) -> SignalHandlerId {
377        unsafe extern "C" fn notify_qos_dscp_trampoline<
378            F: Fn(&NetClientClock) + Send + Sync + 'static,
379        >(
380            this: *mut ffi::GstNetClientClock,
381            _param_spec: glib::ffi::gpointer,
382            f: glib::ffi::gpointer,
383        ) {
384            let f: &F = &*(f as *const F);
385            f(&from_glib_borrow(this))
386        }
387        unsafe {
388            let f: Box_<F> = Box_::new(f);
389            connect_raw(
390                self.as_ptr() as *mut _,
391                c"notify::qos-dscp".as_ptr() as *const _,
392                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
393                    notify_qos_dscp_trampoline::<F> as *const (),
394                )),
395                Box_::into_raw(f),
396            )
397        }
398    }
399
400    #[doc(alias = "round-trip-limit")]
401    pub fn connect_round_trip_limit_notify<F: Fn(&Self) + Send + Sync + 'static>(
402        &self,
403        f: F,
404    ) -> SignalHandlerId {
405        unsafe extern "C" fn notify_round_trip_limit_trampoline<
406            F: Fn(&NetClientClock) + Send + Sync + 'static,
407        >(
408            this: *mut ffi::GstNetClientClock,
409            _param_spec: glib::ffi::gpointer,
410            f: glib::ffi::gpointer,
411        ) {
412            let f: &F = &*(f as *const F);
413            f(&from_glib_borrow(this))
414        }
415        unsafe {
416            let f: Box_<F> = Box_::new(f);
417            connect_raw(
418                self.as_ptr() as *mut _,
419                c"notify::round-trip-limit".as_ptr() as *const _,
420                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
421                    notify_round_trip_limit_trampoline::<F> as *const (),
422                )),
423                Box_::into_raw(f),
424            )
425        }
426    }
427}
428
429unsafe impl Send for NetClientClock {}
430unsafe impl Sync for NetClientClock {}