1 | // This file was generated by gir (https://github.com/gtk-rs/gir) |
2 | // from gir-files (https://github.com/gtk-rs/gir-files) |
3 | // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) |
4 | // DO NOT EDIT |
5 | |
6 | use crate::{Bus, Device, DeviceProviderFactory, Object}; |
7 | use glib::{ |
8 | prelude::*, |
9 | signal::{connect_raw, SignalHandlerId}, |
10 | translate::*, |
11 | }; |
12 | use std::{boxed::Box as Box_, mem::transmute}; |
13 | |
14 | glib::wrapper! { |
15 | #[doc (alias = "GstDeviceProvider" )] |
16 | pub struct DeviceProvider(Object<ffi::GstDeviceProvider, ffi::GstDeviceProviderClass>) @extends Object; |
17 | |
18 | match fn { |
19 | type_ => || ffi::gst_device_provider_get_type(), |
20 | } |
21 | } |
22 | |
23 | impl DeviceProvider { |
24 | pub const NONE: Option<&'static DeviceProvider> = None; |
25 | } |
26 | |
27 | unsafe impl Send for DeviceProvider {} |
28 | unsafe impl Sync for DeviceProvider {} |
29 | |
30 | mod sealed { |
31 | pub trait Sealed {} |
32 | impl<T: super::IsA<super::DeviceProvider>> Sealed for T {} |
33 | } |
34 | |
35 | pub trait DeviceProviderExt: IsA<DeviceProvider> + sealed::Sealed + 'static { |
36 | #[doc (alias = "gst_device_provider_can_monitor" )] |
37 | fn can_monitor(&self) -> bool { |
38 | unsafe { |
39 | from_glib(ffi::gst_device_provider_can_monitor( |
40 | self.as_ref().to_glib_none().0, |
41 | )) |
42 | } |
43 | } |
44 | |
45 | #[doc (alias = "gst_device_provider_device_add" )] |
46 | fn device_add(&self, device: &impl IsA<Device>) { |
47 | unsafe { |
48 | ffi::gst_device_provider_device_add( |
49 | self.as_ref().to_glib_none().0, |
50 | device.as_ref().to_glib_none().0, |
51 | ); |
52 | } |
53 | } |
54 | |
55 | #[cfg (feature = "v1_16" )] |
56 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_16" )))] |
57 | #[doc (alias = "gst_device_provider_device_changed" )] |
58 | fn device_changed(&self, device: &impl IsA<Device>, changed_device: &impl IsA<Device>) { |
59 | unsafe { |
60 | ffi::gst_device_provider_device_changed( |
61 | self.as_ref().to_glib_none().0, |
62 | device.as_ref().to_glib_none().0, |
63 | changed_device.as_ref().to_glib_none().0, |
64 | ); |
65 | } |
66 | } |
67 | |
68 | #[doc (alias = "gst_device_provider_device_remove" )] |
69 | fn device_remove(&self, device: &impl IsA<Device>) { |
70 | unsafe { |
71 | ffi::gst_device_provider_device_remove( |
72 | self.as_ref().to_glib_none().0, |
73 | device.as_ref().to_glib_none().0, |
74 | ); |
75 | } |
76 | } |
77 | |
78 | #[doc (alias = "gst_device_provider_get_bus" )] |
79 | #[doc (alias = "get_bus" )] |
80 | fn bus(&self) -> Bus { |
81 | unsafe { |
82 | from_glib_full(ffi::gst_device_provider_get_bus( |
83 | self.as_ref().to_glib_none().0, |
84 | )) |
85 | } |
86 | } |
87 | |
88 | #[doc (alias = "gst_device_provider_get_factory" )] |
89 | #[doc (alias = "get_factory" )] |
90 | fn factory(&self) -> Option<DeviceProviderFactory> { |
91 | unsafe { |
92 | from_glib_none(ffi::gst_device_provider_get_factory( |
93 | self.as_ref().to_glib_none().0, |
94 | )) |
95 | } |
96 | } |
97 | |
98 | #[doc (alias = "gst_device_provider_get_hidden_providers" )] |
99 | #[doc (alias = "get_hidden_providers" )] |
100 | fn hidden_providers(&self) -> Vec<glib::GString> { |
101 | unsafe { |
102 | FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_get_hidden_providers( |
103 | self.as_ref().to_glib_none().0, |
104 | )) |
105 | } |
106 | } |
107 | |
108 | #[doc (alias = "gst_device_provider_hide_provider" )] |
109 | fn hide_provider(&self, name: &str) { |
110 | unsafe { |
111 | ffi::gst_device_provider_hide_provider( |
112 | self.as_ref().to_glib_none().0, |
113 | name.to_glib_none().0, |
114 | ); |
115 | } |
116 | } |
117 | |
118 | #[cfg (feature = "v1_20" )] |
119 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_20" )))] |
120 | #[doc (alias = "gst_device_provider_is_started" )] |
121 | fn is_started(&self) -> bool { |
122 | unsafe { |
123 | from_glib(ffi::gst_device_provider_is_started( |
124 | self.as_ref().to_glib_none().0, |
125 | )) |
126 | } |
127 | } |
128 | |
129 | #[doc (alias = "gst_device_provider_start" )] |
130 | fn start(&self) -> Result<(), glib::error::BoolError> { |
131 | unsafe { |
132 | glib::result_from_gboolean!( |
133 | ffi::gst_device_provider_start(self.as_ref().to_glib_none().0), |
134 | "Failed to start" |
135 | ) |
136 | } |
137 | } |
138 | |
139 | #[doc (alias = "gst_device_provider_stop" )] |
140 | fn stop(&self) { |
141 | unsafe { |
142 | ffi::gst_device_provider_stop(self.as_ref().to_glib_none().0); |
143 | } |
144 | } |
145 | |
146 | #[doc (alias = "gst_device_provider_unhide_provider" )] |
147 | fn unhide_provider(&self, name: &str) { |
148 | unsafe { |
149 | ffi::gst_device_provider_unhide_provider( |
150 | self.as_ref().to_glib_none().0, |
151 | name.to_glib_none().0, |
152 | ); |
153 | } |
154 | } |
155 | |
156 | #[doc (alias = "provider-hidden" )] |
157 | fn connect_provider_hidden<F: Fn(&Self, &str) + Send + Sync + 'static>( |
158 | &self, |
159 | f: F, |
160 | ) -> SignalHandlerId { |
161 | unsafe extern "C" fn provider_hidden_trampoline< |
162 | P: IsA<DeviceProvider>, |
163 | F: Fn(&P, &str) + Send + Sync + 'static, |
164 | >( |
165 | this: *mut ffi::GstDeviceProvider, |
166 | object: *mut libc::c_char, |
167 | f: glib::ffi::gpointer, |
168 | ) { |
169 | let f: &F = &*(f as *const F); |
170 | f( |
171 | DeviceProvider::from_glib_borrow(this).unsafe_cast_ref(), |
172 | &glib::GString::from_glib_borrow(object), |
173 | ) |
174 | } |
175 | unsafe { |
176 | let f: Box_<F> = Box_::new(f); |
177 | connect_raw( |
178 | self.as_ptr() as *mut _, |
179 | b"provider-hidden \0" .as_ptr() as *const _, |
180 | Some(transmute::<_, unsafe extern "C" fn()>( |
181 | provider_hidden_trampoline::<Self, F> as *const (), |
182 | )), |
183 | Box_::into_raw(f), |
184 | ) |
185 | } |
186 | } |
187 | |
188 | #[doc (alias = "provider-unhidden" )] |
189 | fn connect_provider_unhidden<F: Fn(&Self, &str) + Send + Sync + 'static>( |
190 | &self, |
191 | f: F, |
192 | ) -> SignalHandlerId { |
193 | unsafe extern "C" fn provider_unhidden_trampoline< |
194 | P: IsA<DeviceProvider>, |
195 | F: Fn(&P, &str) + Send + Sync + 'static, |
196 | >( |
197 | this: *mut ffi::GstDeviceProvider, |
198 | object: *mut libc::c_char, |
199 | f: glib::ffi::gpointer, |
200 | ) { |
201 | let f: &F = &*(f as *const F); |
202 | f( |
203 | DeviceProvider::from_glib_borrow(this).unsafe_cast_ref(), |
204 | &glib::GString::from_glib_borrow(object), |
205 | ) |
206 | } |
207 | unsafe { |
208 | let f: Box_<F> = Box_::new(f); |
209 | connect_raw( |
210 | self.as_ptr() as *mut _, |
211 | b"provider-unhidden \0" .as_ptr() as *const _, |
212 | Some(transmute::<_, unsafe extern "C" fn()>( |
213 | provider_unhidden_trampoline::<Self, F> as *const (), |
214 | )), |
215 | Box_::into_raw(f), |
216 | ) |
217 | } |
218 | } |
219 | } |
220 | |
221 | impl<O: IsA<DeviceProvider>> DeviceProviderExt for O {} |
222 | |