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