gstreamer_net/auto/
ntp_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, NetClientClock};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    ///
11    ///
12    /// # Implements
13    ///
14    /// [`trait@gst::prelude::ClockExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
15    #[doc(alias = "GstNtpClock")]
16    pub struct NtpClock(Object<ffi::GstNtpClock, ffi::GstNtpClockClass>) @extends NetClientClock, gst::Clock, gst::Object;
17
18    match fn {
19        type_ => || ffi::gst_ntp_clock_get_type(),
20    }
21}
22
23impl NtpClock {
24    /// Create a new [`NtpClock`][crate::NtpClock] that will report the time provided by
25    /// the NTPv4 server on `remote_address` and `remote_port`.
26    /// ## `name`
27    /// a name for the clock
28    /// ## `remote_address`
29    /// the address or hostname of the remote clock provider
30    /// ## `remote_port`
31    /// the port of the remote clock provider
32    /// ## `base_time`
33    /// initial time of the clock
34    ///
35    /// # Returns
36    ///
37    /// a new [`gst::Clock`][crate::gst::Clock] that receives a time from the remote
38    /// clock.
39    #[doc(alias = "gst_ntp_clock_new")]
40    pub fn new(
41        name: Option<&str>,
42        remote_address: &str,
43        remote_port: i32,
44        base_time: impl Into<Option<gst::ClockTime>>,
45    ) -> NtpClock {
46        assert_initialized_main_thread!();
47        unsafe {
48            gst::Clock::from_glib_full(ffi::gst_ntp_clock_new(
49                name.to_glib_none().0,
50                remote_address.to_glib_none().0,
51                remote_port,
52                base_time.into().into_glib(),
53            ))
54            .unsafe_cast()
55        }
56    }
57}
58
59unsafe impl Send for NtpClock {}
60unsafe impl Sync for NtpClock {}