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