gstreamer_net/auto/net_time_provider.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 /// This object exposes the time of a [`gst::Clock`][crate::gst::Clock] on the network.
16 ///
17 /// A [`NetTimeProvider`][crate::NetTimeProvider] is created with [`new()`][Self::new()] which
18 /// takes a [`gst::Clock`][crate::gst::Clock], an address and a port number as arguments.
19 ///
20 /// After creating the object, a client clock such as [`NetClientClock`][crate::NetClientClock] can
21 /// query the exposed clock over the network for its values.
22 ///
23 /// The [`NetTimeProvider`][crate::NetTimeProvider] typically wraps the clock used by a [`gst::Pipeline`][crate::gst::Pipeline].
24 ///
25 /// ## Properties
26 ///
27 ///
28 /// #### `active`
29 /// Readable | Writeable
30 ///
31 ///
32 /// #### `address`
33 /// Readable | Writeable | Construct Only
34 ///
35 ///
36 /// #### `clock`
37 /// Readable | Writeable | Construct Only
38 ///
39 ///
40 /// #### `port`
41 /// Readable | Writeable | Construct Only
42 ///
43 ///
44 /// #### `qos-dscp`
45 /// Readable | Writeable
46 /// <details><summary><h4>Object</h4></summary>
47 ///
48 ///
49 /// #### `name`
50 /// Readable | Writeable | Construct
51 ///
52 ///
53 /// #### `parent`
54 /// The parent of the object. Please note, that when changing the 'parent'
55 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
56 /// signals due to locking issues. In some cases one can use
57 /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
58 /// achieve a similar effect.
59 ///
60 /// Readable | Writeable
61 /// </details>
62 ///
63 /// # Implements
64 ///
65 /// [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
66 #[doc(alias = "GstNetTimeProvider")]
67 pub struct NetTimeProvider(Object<ffi::GstNetTimeProvider, ffi::GstNetTimeProviderClass>) @extends gst::Object;
68
69 match fn {
70 type_ => || ffi::gst_net_time_provider_get_type(),
71 }
72}
73
74impl NetTimeProvider {
75 /// Allows network clients to get the current time of `clock`.
76 /// ## `clock`
77 /// a [`gst::Clock`][crate::gst::Clock] to export over the network
78 /// ## `address`
79 /// an address to bind on as a dotted quad
80 /// (xxx.xxx.xxx.xxx), IPv6 address, or NULL to bind to all addresses
81 /// ## `port`
82 /// a port to bind on, or 0 to let the kernel choose
83 ///
84 /// # Returns
85 ///
86 /// the new [`NetTimeProvider`][crate::NetTimeProvider], or NULL on error
87 #[doc(alias = "gst_net_time_provider_new")]
88 pub fn new(
89 clock: &impl IsA<gst::Clock>,
90 address: Option<&str>,
91 port: i32,
92 ) -> Result<NetTimeProvider, glib::BoolError> {
93 assert_initialized_main_thread!();
94 unsafe {
95 Option::<_>::from_glib_full(ffi::gst_net_time_provider_new(
96 clock.as_ref().to_glib_none().0,
97 address.to_glib_none().0,
98 port,
99 ))
100 .ok_or_else(|| glib::bool_error!("Failed to create NetTimeProvider"))
101 }
102 }
103
104 pub fn is_active(&self) -> bool {
105 ObjectExt::property(self, "active")
106 }
107
108 pub fn set_active(&self, active: bool) {
109 ObjectExt::set_property(self, "active", active)
110 }
111
112 pub fn address(&self) -> Option<glib::GString> {
113 ObjectExt::property(self, "address")
114 }
115
116 pub fn clock(&self) -> Option<gst::Clock> {
117 ObjectExt::property(self, "clock")
118 }
119
120 pub fn port(&self) -> i32 {
121 ObjectExt::property(self, "port")
122 }
123
124 #[doc(alias = "qos-dscp")]
125 pub fn qos_dscp(&self) -> i32 {
126 ObjectExt::property(self, "qos-dscp")
127 }
128
129 #[doc(alias = "qos-dscp")]
130 pub fn set_qos_dscp(&self, qos_dscp: i32) {
131 ObjectExt::set_property(self, "qos-dscp", qos_dscp)
132 }
133
134 #[doc(alias = "active")]
135 pub fn connect_active_notify<F: Fn(&Self) + Send + Sync + 'static>(
136 &self,
137 f: F,
138 ) -> SignalHandlerId {
139 unsafe extern "C" fn notify_active_trampoline<
140 F: Fn(&NetTimeProvider) + Send + Sync + 'static,
141 >(
142 this: *mut ffi::GstNetTimeProvider,
143 _param_spec: glib::ffi::gpointer,
144 f: glib::ffi::gpointer,
145 ) {
146 let f: &F = &*(f as *const F);
147 f(&from_glib_borrow(this))
148 }
149 unsafe {
150 let f: Box_<F> = Box_::new(f);
151 connect_raw(
152 self.as_ptr() as *mut _,
153 c"notify::active".as_ptr() as *const _,
154 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
155 notify_active_trampoline::<F> as *const (),
156 )),
157 Box_::into_raw(f),
158 )
159 }
160 }
161
162 #[doc(alias = "qos-dscp")]
163 pub fn connect_qos_dscp_notify<F: Fn(&Self) + Send + Sync + 'static>(
164 &self,
165 f: F,
166 ) -> SignalHandlerId {
167 unsafe extern "C" fn notify_qos_dscp_trampoline<
168 F: Fn(&NetTimeProvider) + Send + Sync + 'static,
169 >(
170 this: *mut ffi::GstNetTimeProvider,
171 _param_spec: glib::ffi::gpointer,
172 f: glib::ffi::gpointer,
173 ) {
174 let f: &F = &*(f as *const F);
175 f(&from_glib_borrow(this))
176 }
177 unsafe {
178 let f: Box_<F> = Box_::new(f);
179 connect_raw(
180 self.as_ptr() as *mut _,
181 c"notify::qos-dscp".as_ptr() as *const _,
182 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
183 notify_qos_dscp_trampoline::<F> as *const (),
184 )),
185 Box_::into_raw(f),
186 )
187 }
188 }
189}
190
191unsafe impl Send for NetTimeProvider {}
192unsafe impl Sync for NetTimeProvider {}