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")]
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 unsafe {
130 let f: &F = &*(f as *const F);
131 f(&from_glib_borrow(this))
132 }
133 }
134 unsafe {
135 let f: Box_<F> = Box_::new(f);
136 connect_raw(
137 self.as_ptr() as *mut _,
138 c"notify::address".as_ptr(),
139 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
140 notify_address_trampoline::<F> as *const (),
141 )),
142 Box_::into_raw(f),
143 )
144 }
145 }
146
147 #[doc(alias = "bus")]
148 pub fn connect_bus_notify<F: Fn(&Self) + Send + Sync + 'static>(
149 &self,
150 f: F,
151 ) -> SignalHandlerId {
152 unsafe extern "C" fn notify_bus_trampoline<
153 F: Fn(&NetClientClock) + Send + Sync + 'static,
154 >(
155 this: *mut ffi::GstNetClientClock,
156 _param_spec: glib::ffi::gpointer,
157 f: glib::ffi::gpointer,
158 ) {
159 unsafe {
160 let f: &F = &*(f as *const F);
161 f(&from_glib_borrow(this))
162 }
163 }
164 unsafe {
165 let f: Box_<F> = Box_::new(f);
166 connect_raw(
167 self.as_ptr() as *mut _,
168 c"notify::bus".as_ptr(),
169 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
170 notify_bus_trampoline::<F> as *const (),
171 )),
172 Box_::into_raw(f),
173 )
174 }
175 }
176
177 #[doc(alias = "internal-clock")]
178 pub fn connect_internal_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
179 &self,
180 f: F,
181 ) -> SignalHandlerId {
182 unsafe extern "C" fn notify_internal_clock_trampoline<
183 F: Fn(&NetClientClock) + Send + Sync + 'static,
184 >(
185 this: *mut ffi::GstNetClientClock,
186 _param_spec: glib::ffi::gpointer,
187 f: glib::ffi::gpointer,
188 ) {
189 unsafe {
190 let f: &F = &*(f as *const F);
191 f(&from_glib_borrow(this))
192 }
193 }
194 unsafe {
195 let f: Box_<F> = Box_::new(f);
196 connect_raw(
197 self.as_ptr() as *mut _,
198 c"notify::internal-clock".as_ptr(),
199 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
200 notify_internal_clock_trampoline::<F> as *const (),
201 )),
202 Box_::into_raw(f),
203 )
204 }
205 }
206
207 #[doc(alias = "minimum-update-interval")]
208 pub fn connect_minimum_update_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
209 &self,
210 f: F,
211 ) -> SignalHandlerId {
212 unsafe extern "C" fn notify_minimum_update_interval_trampoline<
213 F: Fn(&NetClientClock) + Send + Sync + 'static,
214 >(
215 this: *mut ffi::GstNetClientClock,
216 _param_spec: glib::ffi::gpointer,
217 f: glib::ffi::gpointer,
218 ) {
219 unsafe {
220 let f: &F = &*(f as *const F);
221 f(&from_glib_borrow(this))
222 }
223 }
224 unsafe {
225 let f: Box_<F> = Box_::new(f);
226 connect_raw(
227 self.as_ptr() as *mut _,
228 c"notify::minimum-update-interval".as_ptr(),
229 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
230 notify_minimum_update_interval_trampoline::<F> as *const (),
231 )),
232 Box_::into_raw(f),
233 )
234 }
235 }
236
237 #[doc(alias = "port")]
238 pub fn connect_port_notify<F: Fn(&Self) + Send + Sync + 'static>(
239 &self,
240 f: F,
241 ) -> SignalHandlerId {
242 unsafe extern "C" fn notify_port_trampoline<
243 F: Fn(&NetClientClock) + Send + Sync + 'static,
244 >(
245 this: *mut ffi::GstNetClientClock,
246 _param_spec: glib::ffi::gpointer,
247 f: glib::ffi::gpointer,
248 ) {
249 unsafe {
250 let f: &F = &*(f as *const F);
251 f(&from_glib_borrow(this))
252 }
253 }
254 unsafe {
255 let f: Box_<F> = Box_::new(f);
256 connect_raw(
257 self.as_ptr() as *mut _,
258 c"notify::port".as_ptr(),
259 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
260 notify_port_trampoline::<F> as *const (),
261 )),
262 Box_::into_raw(f),
263 )
264 }
265 }
266
267 #[doc(alias = "qos-dscp")]
268 pub fn connect_qos_dscp_notify<F: Fn(&Self) + Send + Sync + 'static>(
269 &self,
270 f: F,
271 ) -> SignalHandlerId {
272 unsafe extern "C" fn notify_qos_dscp_trampoline<
273 F: Fn(&NetClientClock) + Send + Sync + 'static,
274 >(
275 this: *mut ffi::GstNetClientClock,
276 _param_spec: glib::ffi::gpointer,
277 f: glib::ffi::gpointer,
278 ) {
279 unsafe {
280 let f: &F = &*(f as *const F);
281 f(&from_glib_borrow(this))
282 }
283 }
284 unsafe {
285 let f: Box_<F> = Box_::new(f);
286 connect_raw(
287 self.as_ptr() as *mut _,
288 c"notify::qos-dscp".as_ptr(),
289 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
290 notify_qos_dscp_trampoline::<F> as *const (),
291 )),
292 Box_::into_raw(f),
293 )
294 }
295 }
296
297 #[doc(alias = "round-trip-limit")]
298 pub fn connect_round_trip_limit_notify<F: Fn(&Self) + Send + Sync + 'static>(
299 &self,
300 f: F,
301 ) -> SignalHandlerId {
302 unsafe extern "C" fn notify_round_trip_limit_trampoline<
303 F: Fn(&NetClientClock) + Send + Sync + 'static,
304 >(
305 this: *mut ffi::GstNetClientClock,
306 _param_spec: glib::ffi::gpointer,
307 f: glib::ffi::gpointer,
308 ) {
309 unsafe {
310 let f: &F = &*(f as *const F);
311 f(&from_glib_borrow(this))
312 }
313 }
314 unsafe {
315 let f: Box_<F> = Box_::new(f);
316 connect_raw(
317 self.as_ptr() as *mut _,
318 c"notify::round-trip-limit".as_ptr(),
319 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
320 notify_round_trip_limit_trampoline::<F> as *const (),
321 )),
322 Box_::into_raw(f),
323 )
324 }
325 }
326}
327
328unsafe impl Send for NetClientClock {}
329unsafe impl Sync for NetClientClock {}