gstreamer_net/auto/
ptp_clock.rs1use 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 = "GstPtpClock")]
16 pub struct PtpClock(Object<ffi::GstPtpClock, ffi::GstPtpClockClass>) @extends gst::Clock, gst::Object;
17
18 match fn {
19 type_ => || ffi::gst_ptp_clock_get_type(),
20 }
21}
22
23impl PtpClock {
24 #[doc(alias = "gst_ptp_clock_new")]
25 pub fn new(name: Option<&str>, domain: u32) -> Result<PtpClock, glib::BoolError> {
26 assert_initialized_main_thread!();
27 unsafe {
28 Option::<gst::Clock>::from_glib_full(ffi::gst_ptp_clock_new(
29 name.to_glib_none().0,
30 domain,
31 ))
32 .map(|o| o.unsafe_cast())
33 .ok_or_else(|| glib::bool_error!("Can't create gst::PtpClock"))
34 }
35 }
36
37 pub fn domain(&self) -> u32 {
38 ObjectExt::property(self, "domain")
39 }
40
41 #[doc(alias = "grandmaster-clock-id")]
42 pub fn grandmaster_clock_id(&self) -> u64 {
43 ObjectExt::property(self, "grandmaster-clock-id")
44 }
45
46 #[doc(alias = "internal-clock")]
47 pub fn internal_clock(&self) -> Option<gst::Clock> {
48 ObjectExt::property(self, "internal-clock")
49 }
50
51 #[doc(alias = "master-clock-id")]
52 pub fn master_clock_id(&self) -> u64 {
53 ObjectExt::property(self, "master-clock-id")
54 }
55
56 #[doc(alias = "grandmaster-clock-id")]
57 pub fn connect_grandmaster_clock_id_notify<F: Fn(&Self) + Send + Sync + 'static>(
58 &self,
59 f: F,
60 ) -> SignalHandlerId {
61 unsafe extern "C" fn notify_grandmaster_clock_id_trampoline<
62 F: Fn(&PtpClock) + Send + Sync + 'static,
63 >(
64 this: *mut ffi::GstPtpClock,
65 _param_spec: glib::ffi::gpointer,
66 f: glib::ffi::gpointer,
67 ) {
68 unsafe {
69 let f: &F = &*(f as *const F);
70 f(&from_glib_borrow(this))
71 }
72 }
73 unsafe {
74 let f: Box_<F> = Box_::new(f);
75 connect_raw(
76 self.as_ptr() as *mut _,
77 c"notify::grandmaster-clock-id".as_ptr(),
78 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
79 notify_grandmaster_clock_id_trampoline::<F> as *const (),
80 )),
81 Box_::into_raw(f),
82 )
83 }
84 }
85
86 #[doc(alias = "internal-clock")]
87 pub fn connect_internal_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
88 &self,
89 f: F,
90 ) -> SignalHandlerId {
91 unsafe extern "C" fn notify_internal_clock_trampoline<
92 F: Fn(&PtpClock) + Send + Sync + 'static,
93 >(
94 this: *mut ffi::GstPtpClock,
95 _param_spec: glib::ffi::gpointer,
96 f: glib::ffi::gpointer,
97 ) {
98 unsafe {
99 let f: &F = &*(f as *const F);
100 f(&from_glib_borrow(this))
101 }
102 }
103 unsafe {
104 let f: Box_<F> = Box_::new(f);
105 connect_raw(
106 self.as_ptr() as *mut _,
107 c"notify::internal-clock".as_ptr(),
108 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
109 notify_internal_clock_trampoline::<F> as *const (),
110 )),
111 Box_::into_raw(f),
112 )
113 }
114 }
115
116 #[doc(alias = "master-clock-id")]
117 pub fn connect_master_clock_id_notify<F: Fn(&Self) + Send + Sync + 'static>(
118 &self,
119 f: F,
120 ) -> SignalHandlerId {
121 unsafe extern "C" fn notify_master_clock_id_trampoline<
122 F: Fn(&PtpClock) + Send + Sync + 'static,
123 >(
124 this: *mut ffi::GstPtpClock,
125 _param_spec: glib::ffi::gpointer,
126 f: glib::ffi::gpointer,
127 ) {
128 unsafe {
129 let f: &F = &*(f as *const F);
130 f(&from_glib_borrow(this))
131 }
132 }
133 unsafe {
134 let f: Box_<F> = Box_::new(f);
135 connect_raw(
136 self.as_ptr() as *mut _,
137 c"notify::master-clock-id".as_ptr(),
138 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
139 notify_master_clock_id_trampoline::<F> as *const (),
140 )),
141 Box_::into_raw(f),
142 )
143 }
144 }
145}
146
147unsafe impl Send for PtpClock {}
148unsafe impl Sync for PtpClock {}