gstreamer_net/auto/
ptp_clock.rs1use 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 = "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 let f: &F = &*(f as *const F);
69 f(&from_glib_borrow(this))
70 }
71 unsafe {
72 let f: Box_<F> = Box_::new(f);
73 connect_raw(
74 self.as_ptr() as *mut _,
75 c"notify::grandmaster-clock-id".as_ptr() as *const _,
76 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
77 notify_grandmaster_clock_id_trampoline::<F> as *const (),
78 )),
79 Box_::into_raw(f),
80 )
81 }
82 }
83
84 #[doc(alias = "internal-clock")]
85 pub fn connect_internal_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
86 &self,
87 f: F,
88 ) -> SignalHandlerId {
89 unsafe extern "C" fn notify_internal_clock_trampoline<
90 F: Fn(&PtpClock) + Send + Sync + 'static,
91 >(
92 this: *mut ffi::GstPtpClock,
93 _param_spec: glib::ffi::gpointer,
94 f: glib::ffi::gpointer,
95 ) {
96 let f: &F = &*(f as *const F);
97 f(&from_glib_borrow(this))
98 }
99 unsafe {
100 let f: Box_<F> = Box_::new(f);
101 connect_raw(
102 self.as_ptr() as *mut _,
103 c"notify::internal-clock".as_ptr() as *const _,
104 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
105 notify_internal_clock_trampoline::<F> as *const (),
106 )),
107 Box_::into_raw(f),
108 )
109 }
110 }
111
112 #[doc(alias = "master-clock-id")]
113 pub fn connect_master_clock_id_notify<F: Fn(&Self) + Send + Sync + 'static>(
114 &self,
115 f: F,
116 ) -> SignalHandlerId {
117 unsafe extern "C" fn notify_master_clock_id_trampoline<
118 F: Fn(&PtpClock) + Send + Sync + 'static,
119 >(
120 this: *mut ffi::GstPtpClock,
121 _param_spec: glib::ffi::gpointer,
122 f: glib::ffi::gpointer,
123 ) {
124 let f: &F = &*(f as *const F);
125 f(&from_glib_borrow(this))
126 }
127 unsafe {
128 let f: Box_<F> = Box_::new(f);
129 connect_raw(
130 self.as_ptr() as *mut _,
131 c"notify::master-clock-id".as_ptr() as *const _,
132 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
133 notify_master_clock_id_trampoline::<F> as *const (),
134 )),
135 Box_::into_raw(f),
136 )
137 }
138 }
139}
140
141unsafe impl Send for PtpClock {}
142unsafe impl Sync for PtpClock {}