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