gstreamer_validate/auto/
monitor.rs1use crate::{ffi, Reporter, Runner};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstValidateMonitor")]
16 pub struct Monitor(Object<ffi::GstValidateMonitor, ffi::GstValidateMonitorClass>) @extends gst::Object, @implements Reporter;
17
18 match fn {
19 type_ => || ffi::gst_validate_monitor_get_type(),
20 }
21}
22
23impl Monitor {
24 pub const NONE: Option<&'static Monitor> = None;
25
26 #[doc(alias = "gst_validate_monitor_factory_create")]
27 pub fn factory_create(
28 target: &impl IsA<gst::Object>,
29 runner: &impl IsA<Runner>,
30 parent: Option<&impl IsA<Monitor>>,
31 ) -> Monitor {
32 skip_assert_initialized!();
33 unsafe {
34 from_glib_full(ffi::gst_validate_monitor_factory_create(
35 target.as_ref().to_glib_none().0,
36 runner.as_ref().to_glib_none().0,
37 parent.map(|p| p.as_ref()).to_glib_none().0,
38 ))
39 }
40 }
41}
42
43unsafe impl Send for Monitor {}
44unsafe impl Sync for Monitor {}
45
46mod sealed {
47 pub trait Sealed {}
48 impl<T: super::IsA<super::Monitor>> Sealed for T {}
49}
50
51pub trait MonitorExt: IsA<Monitor> + sealed::Sealed + 'static {
52 #[doc(alias = "gst_validate_monitor_get_element")]
58 #[doc(alias = "get_element")]
59 fn element(&self) -> Option<gst::Element> {
60 unsafe {
61 from_glib_none(ffi::gst_validate_monitor_get_element(
62 self.as_ref().to_glib_none().0,
63 ))
64 }
65 }
66
67 #[doc(alias = "gst_validate_monitor_get_element_name")]
68 #[doc(alias = "get_element_name")]
69 fn element_name(&self) -> Option<glib::GString> {
70 unsafe {
71 from_glib_full(ffi::gst_validate_monitor_get_element_name(
72 self.as_ref().to_glib_none().0,
73 ))
74 }
75 }
76
77 #[doc(alias = "gst_validate_monitor_get_pipeline")]
78 #[doc(alias = "get_pipeline")]
79 fn pipeline(&self) -> Option<gst::Pipeline> {
80 unsafe {
81 from_glib_full(ffi::gst_validate_monitor_get_pipeline(
82 self.as_ref().to_glib_none().0,
83 ))
84 }
85 }
86
87 #[doc(alias = "gst_validate_monitor_get_target")]
88 #[doc(alias = "get_target")]
89 fn target(&self) -> Option<gst::Object> {
90 unsafe {
91 from_glib_full(ffi::gst_validate_monitor_get_target(
92 self.as_ref().to_glib_none().0,
93 ))
94 }
95 }
96
97 fn object(&self) -> Option<glib::Object> {
103 ObjectExt::property(self.as_ref(), "object")
104 }
105
106 fn set_pipeline<P: IsA<gst::Pipeline>>(&self, pipeline: Option<&P>) {
107 ObjectExt::set_property(self.as_ref(), "pipeline", pipeline)
108 }
109
110 #[doc(alias = "validate-parent")]
111 fn validate_parent(&self) -> Option<Monitor> {
112 ObjectExt::property(self.as_ref(), "validate-parent")
113 }
114
115 #[doc(alias = "pipeline")]
124 fn connect_pipeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
125 &self,
126 f: F,
127 ) -> SignalHandlerId {
128 unsafe extern "C" fn notify_pipeline_trampoline<
129 P: IsA<Monitor>,
130 F: Fn(&P) + Send + Sync + 'static,
131 >(
132 this: *mut ffi::GstValidateMonitor,
133 _param_spec: glib::ffi::gpointer,
134 f: glib::ffi::gpointer,
135 ) {
136 let f: &F = &*(f as *const F);
137 f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
138 }
139 unsafe {
140 let f: Box_<F> = Box_::new(f);
141 connect_raw(
142 self.as_ptr() as *mut _,
143 b"notify::pipeline\0".as_ptr() as *const _,
144 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
145 notify_pipeline_trampoline::<Self, F> as *const (),
146 )),
147 Box_::into_raw(f),
148 )
149 }
150 }
151
152 #[doc(alias = "verbosity")]
153 fn connect_verbosity_notify<F: Fn(&Self) + Send + Sync + 'static>(
154 &self,
155 f: F,
156 ) -> SignalHandlerId {
157 unsafe extern "C" fn notify_verbosity_trampoline<
158 P: IsA<Monitor>,
159 F: Fn(&P) + Send + Sync + 'static,
160 >(
161 this: *mut ffi::GstValidateMonitor,
162 _param_spec: glib::ffi::gpointer,
163 f: glib::ffi::gpointer,
164 ) {
165 let f: &F = &*(f as *const F);
166 f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
167 }
168 unsafe {
169 let f: Box_<F> = Box_::new(f);
170 connect_raw(
171 self.as_ptr() as *mut _,
172 b"notify::verbosity\0".as_ptr() as *const _,
173 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
174 notify_verbosity_trampoline::<Self, F> as *const (),
175 )),
176 Box_::into_raw(f),
177 )
178 }
179 }
180}
181
182impl<O: IsA<Monitor>> MonitorExt for O {}