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