1use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstNetClientClock")]
16 pub struct NetClientClock(Object<ffi::GstNetClientClock, ffi::GstNetClientClockClass>) @extends gst::Clock, gst::Object;
17
18 match fn {
19 type_ => || ffi::gst_net_client_clock_get_type(),
20 }
21}
22
23impl NetClientClock {
24 #[doc(alias = "gst_net_client_clock_new")]
25 pub fn new(
26 name: Option<&str>,
27 remote_address: &str,
28 remote_port: i32,
29 base_time: impl Into<Option<gst::ClockTime>>,
30 ) -> NetClientClock {
31 assert_initialized_main_thread!();
32 unsafe {
33 gst::Clock::from_glib_full(ffi::gst_net_client_clock_new(
34 name.to_glib_none().0,
35 remote_address.to_glib_none().0,
36 remote_port,
37 base_time.into().into_glib(),
38 ))
39 .unsafe_cast()
40 }
41 }
42
43 pub fn address(&self) -> Option<glib::GString> {
44 ObjectExt::property(self, "address")
45 }
46
47 pub fn set_address(&self, address: Option<&str>) {
48 ObjectExt::set_property(self, "address", address)
49 }
50
51 #[doc(alias = "base-time")]
52 pub fn base_time(&self) -> u64 {
53 ObjectExt::property(self, "base-time")
54 }
55
56 pub fn bus(&self) -> Option<gst::Bus> {
57 ObjectExt::property(self, "bus")
58 }
59
60 pub fn set_bus<P: IsA<gst::Bus>>(&self, bus: Option<&P>) {
61 ObjectExt::set_property(self, "bus", bus)
62 }
63
64 #[doc(alias = "internal-clock")]
65 pub fn internal_clock(&self) -> Option<gst::Clock> {
66 ObjectExt::property(self, "internal-clock")
67 }
68
69 #[doc(alias = "minimum-update-interval")]
70 pub fn minimum_update_interval(&self) -> u64 {
71 ObjectExt::property(self, "minimum-update-interval")
72 }
73
74 #[doc(alias = "minimum-update-interval")]
75 pub fn set_minimum_update_interval(&self, minimum_update_interval: u64) {
76 ObjectExt::set_property(self, "minimum-update-interval", minimum_update_interval)
77 }
78
79 pub fn port(&self) -> i32 {
80 ObjectExt::property(self, "port")
81 }
82
83 pub fn set_port(&self, port: i32) {
84 ObjectExt::set_property(self, "port", port)
85 }
86
87 #[doc(alias = "qos-dscp")]
88 pub fn qos_dscp(&self) -> i32 {
89 ObjectExt::property(self, "qos-dscp")
90 }
91
92 #[doc(alias = "qos-dscp")]
93 pub fn set_qos_dscp(&self, qos_dscp: i32) {
94 ObjectExt::set_property(self, "qos-dscp", qos_dscp)
95 }
96
97 #[doc(alias = "round-trip-limit")]
98 pub fn round_trip_limit(&self) -> u64 {
99 ObjectExt::property(self, "round-trip-limit")
100 }
101
102 #[doc(alias = "round-trip-limit")]
103 pub fn set_round_trip_limit(&self, round_trip_limit: u64) {
104 ObjectExt::set_property(self, "round-trip-limit", round_trip_limit)
105 }
106
107 #[cfg(feature = "v1_28")]
108 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
109 #[doc(alias = "gst_net_client_clock_deinit")]
110 pub fn deinit() {
111 assert_initialized_main_thread!();
112 unsafe {
113 ffi::gst_net_client_clock_deinit();
114 }
115 }
116
117 #[doc(alias = "address")]
118 pub fn connect_address_notify<F: Fn(&Self) + Send + Sync + 'static>(
119 &self,
120 f: F,
121 ) -> SignalHandlerId {
122 unsafe extern "C" fn notify_address_trampoline<
123 F: Fn(&NetClientClock) + Send + Sync + 'static,
124 >(
125 this: *mut ffi::GstNetClientClock,
126 _param_spec: glib::ffi::gpointer,
127 f: glib::ffi::gpointer,
128 ) {
129 let f: &F = &*(f as *const F);
130 f(&from_glib_borrow(this))
131 }
132 unsafe {
133 let f: Box_<F> = Box_::new(f);
134 connect_raw(
135 self.as_ptr() as *mut _,
136 c"notify::address".as_ptr() as *const _,
137 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
138 notify_address_trampoline::<F> as *const (),
139 )),
140 Box_::into_raw(f),
141 )
142 }
143 }
144
145 #[doc(alias = "bus")]
146 pub fn connect_bus_notify<F: Fn(&Self) + Send + Sync + 'static>(
147 &self,
148 f: F,
149 ) -> SignalHandlerId {
150 unsafe extern "C" fn notify_bus_trampoline<
151 F: Fn(&NetClientClock) + Send + Sync + 'static,
152 >(
153 this: *mut ffi::GstNetClientClock,
154 _param_spec: glib::ffi::gpointer,
155 f: glib::ffi::gpointer,
156 ) {
157 let f: &F = &*(f as *const F);
158 f(&from_glib_borrow(this))
159 }
160 unsafe {
161 let f: Box_<F> = Box_::new(f);
162 connect_raw(
163 self.as_ptr() as *mut _,
164 c"notify::bus".as_ptr() as *const _,
165 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
166 notify_bus_trampoline::<F> as *const (),
167 )),
168 Box_::into_raw(f),
169 )
170 }
171 }
172
173 #[doc(alias = "internal-clock")]
174 pub fn connect_internal_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
175 &self,
176 f: F,
177 ) -> SignalHandlerId {
178 unsafe extern "C" fn notify_internal_clock_trampoline<
179 F: Fn(&NetClientClock) + Send + Sync + 'static,
180 >(
181 this: *mut ffi::GstNetClientClock,
182 _param_spec: glib::ffi::gpointer,
183 f: glib::ffi::gpointer,
184 ) {
185 let f: &F = &*(f as *const F);
186 f(&from_glib_borrow(this))
187 }
188 unsafe {
189 let f: Box_<F> = Box_::new(f);
190 connect_raw(
191 self.as_ptr() as *mut _,
192 c"notify::internal-clock".as_ptr() as *const _,
193 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
194 notify_internal_clock_trampoline::<F> as *const (),
195 )),
196 Box_::into_raw(f),
197 )
198 }
199 }
200
201 #[doc(alias = "minimum-update-interval")]
202 pub fn connect_minimum_update_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
203 &self,
204 f: F,
205 ) -> SignalHandlerId {
206 unsafe extern "C" fn notify_minimum_update_interval_trampoline<
207 F: Fn(&NetClientClock) + Send + Sync + 'static,
208 >(
209 this: *mut ffi::GstNetClientClock,
210 _param_spec: glib::ffi::gpointer,
211 f: glib::ffi::gpointer,
212 ) {
213 let f: &F = &*(f as *const F);
214 f(&from_glib_borrow(this))
215 }
216 unsafe {
217 let f: Box_<F> = Box_::new(f);
218 connect_raw(
219 self.as_ptr() as *mut _,
220 c"notify::minimum-update-interval".as_ptr() as *const _,
221 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
222 notify_minimum_update_interval_trampoline::<F> as *const (),
223 )),
224 Box_::into_raw(f),
225 )
226 }
227 }
228
229 #[doc(alias = "port")]
230 pub fn connect_port_notify<F: Fn(&Self) + Send + Sync + 'static>(
231 &self,
232 f: F,
233 ) -> SignalHandlerId {
234 unsafe extern "C" fn notify_port_trampoline<
235 F: Fn(&NetClientClock) + Send + Sync + 'static,
236 >(
237 this: *mut ffi::GstNetClientClock,
238 _param_spec: glib::ffi::gpointer,
239 f: glib::ffi::gpointer,
240 ) {
241 let f: &F = &*(f as *const F);
242 f(&from_glib_borrow(this))
243 }
244 unsafe {
245 let f: Box_<F> = Box_::new(f);
246 connect_raw(
247 self.as_ptr() as *mut _,
248 c"notify::port".as_ptr() as *const _,
249 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
250 notify_port_trampoline::<F> as *const (),
251 )),
252 Box_::into_raw(f),
253 )
254 }
255 }
256
257 #[doc(alias = "qos-dscp")]
258 pub fn connect_qos_dscp_notify<F: Fn(&Self) + Send + Sync + 'static>(
259 &self,
260 f: F,
261 ) -> SignalHandlerId {
262 unsafe extern "C" fn notify_qos_dscp_trampoline<
263 F: Fn(&NetClientClock) + Send + Sync + 'static,
264 >(
265 this: *mut ffi::GstNetClientClock,
266 _param_spec: glib::ffi::gpointer,
267 f: glib::ffi::gpointer,
268 ) {
269 let f: &F = &*(f as *const F);
270 f(&from_glib_borrow(this))
271 }
272 unsafe {
273 let f: Box_<F> = Box_::new(f);
274 connect_raw(
275 self.as_ptr() as *mut _,
276 c"notify::qos-dscp".as_ptr() as *const _,
277 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
278 notify_qos_dscp_trampoline::<F> as *const (),
279 )),
280 Box_::into_raw(f),
281 )
282 }
283 }
284
285 #[doc(alias = "round-trip-limit")]
286 pub fn connect_round_trip_limit_notify<F: Fn(&Self) + Send + Sync + 'static>(
287 &self,
288 f: F,
289 ) -> SignalHandlerId {
290 unsafe extern "C" fn notify_round_trip_limit_trampoline<
291 F: Fn(&NetClientClock) + Send + Sync + 'static,
292 >(
293 this: *mut ffi::GstNetClientClock,
294 _param_spec: glib::ffi::gpointer,
295 f: glib::ffi::gpointer,
296 ) {
297 let f: &F = &*(f as *const F);
298 f(&from_glib_borrow(this))
299 }
300 unsafe {
301 let f: Box_<F> = Box_::new(f);
302 connect_raw(
303 self.as_ptr() as *mut _,
304 c"notify::round-trip-limit".as_ptr() as *const _,
305 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
306 notify_round_trip_limit_trampoline::<F> as *const (),
307 )),
308 Box_::into_raw(f),
309 )
310 }
311 }
312}
313
314unsafe impl Send for NetClientClock {}
315unsafe impl Sync for NetClientClock {}