gstreamer_controller/auto/
direct_control_binding.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 = "GstDirectControlBinding")]
16 pub struct DirectControlBinding(Object<ffi::GstDirectControlBinding, ffi::GstDirectControlBindingClass>) @extends gst::ControlBinding, gst::Object;
17
18 match fn {
19 type_ => || ffi::gst_direct_control_binding_get_type(),
20 }
21}
22
23impl DirectControlBinding {
24 pub const NONE: Option<&'static DirectControlBinding> = None;
25
26 #[doc(alias = "gst_direct_control_binding_new")]
27 pub fn new(
28 object: &impl IsA<gst::Object>,
29 property_name: &str,
30 cs: &impl IsA<gst::ControlSource>,
31 ) -> DirectControlBinding {
32 assert_initialized_main_thread!();
33 unsafe {
34 gst::ControlBinding::from_glib_none(ffi::gst_direct_control_binding_new(
35 object.as_ref().to_glib_none().0,
36 property_name.to_glib_none().0,
37 cs.as_ref().to_glib_none().0,
38 ))
39 .unsafe_cast()
40 }
41 }
42
43 #[doc(alias = "gst_direct_control_binding_new_absolute")]
44 pub fn new_absolute(
45 object: &impl IsA<gst::Object>,
46 property_name: &str,
47 cs: &impl IsA<gst::ControlSource>,
48 ) -> DirectControlBinding {
49 assert_initialized_main_thread!();
50 unsafe {
51 gst::ControlBinding::from_glib_none(ffi::gst_direct_control_binding_new_absolute(
52 object.as_ref().to_glib_none().0,
53 property_name.to_glib_none().0,
54 cs.as_ref().to_glib_none().0,
55 ))
56 .unsafe_cast()
57 }
58 }
59}
60
61unsafe impl Send for DirectControlBinding {}
62unsafe impl Sync for DirectControlBinding {}
63
64pub trait DirectControlBindingExt: IsA<DirectControlBinding> + 'static {
65 fn is_absolute(&self) -> bool {
66 ObjectExt::property(self.as_ref(), "absolute")
67 }
68
69 #[doc(alias = "control-source")]
70 fn control_source(&self) -> Option<gst::ControlSource> {
71 ObjectExt::property(self.as_ref(), "control-source")
72 }
73
74 #[doc(alias = "control-source")]
75 fn set_control_source<P: IsA<gst::ControlSource>>(&self, control_source: Option<&P>) {
76 ObjectExt::set_property(self.as_ref(), "control-source", control_source)
77 }
78
79 #[doc(alias = "control-source")]
80 fn connect_control_source_notify<F: Fn(&Self) + Send + Sync + 'static>(
81 &self,
82 f: F,
83 ) -> SignalHandlerId {
84 unsafe extern "C" fn notify_control_source_trampoline<
85 P: IsA<DirectControlBinding>,
86 F: Fn(&P) + Send + Sync + 'static,
87 >(
88 this: *mut ffi::GstDirectControlBinding,
89 _param_spec: glib::ffi::gpointer,
90 f: glib::ffi::gpointer,
91 ) {
92 let f: &F = &*(f as *const F);
93 f(DirectControlBinding::from_glib_borrow(this).unsafe_cast_ref())
94 }
95 unsafe {
96 let f: Box_<F> = Box_::new(f);
97 connect_raw(
98 self.as_ptr() as *mut _,
99 c"notify::control-source".as_ptr() as *const _,
100 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
101 notify_control_source_trampoline::<Self, F> as *const (),
102 )),
103 Box_::into_raw(f),
104 )
105 }
106 }
107}
108
109impl<O: IsA<DirectControlBinding>> DirectControlBindingExt for O {}