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
6use crate::{ChildProxy, Element, ElementFlags, Object, Pad, PadDirection};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::{boxed::Box as Box_, mem::transmute};
13
14glib::wrapper! {
15 #[doc(alias = "GstBin")]
16 pub struct Bin(Object<ffi::GstBin, ffi::GstBinClass>) @extends Element, Object, @implements ChildProxy;
17
18 match fn {
19 type_ => || ffi::gst_bin_get_type(),
20 }
21}
22
23impl Bin {
24 pub const NONE: Option<&'static Bin> = None;
25}
26
27unsafe impl Send for Bin {}
28unsafe impl Sync for Bin {}
29
30mod sealed {
31 pub trait Sealed {}
32 impl<T: super::IsA<super::Bin>> Sealed for T {}
33}
34
35pub trait GstBinExt: IsA<Bin> + sealed::Sealed + 'static {
36 #[doc(alias = "gst_bin_add")]
37 fn add(&self, element: &impl IsA<Element>) -> Result<(), glib::error::BoolError> {
38 unsafe {
39 glib::result_from_gboolean!(
40 ffi::gst_bin_add(
41 self.as_ref().to_glib_none().0,
42 element.as_ref().to_glib_none().0
43 ),
44 "Failed to add element"
45 )
46 }
47 }
48
49 #[doc(alias = "gst_bin_find_unlinked_pad")]
50 fn find_unlinked_pad(&self, direction: PadDirection) -> Option<Pad> {
51 unsafe {
52 from_glib_full(ffi::gst_bin_find_unlinked_pad(
53 self.as_ref().to_glib_none().0,
54 direction.into_glib(),
55 ))
56 }
57 }
58
59 #[doc(alias = "gst_bin_get_by_interface")]
60 #[doc(alias = "get_by_interface")]
61 fn by_interface(&self, iface: glib::types::Type) -> Option<Element> {
62 unsafe {
63 from_glib_full(ffi::gst_bin_get_by_interface(
64 self.as_ref().to_glib_none().0,
65 iface.into_glib(),
66 ))
67 }
68 }
69
70 #[doc(alias = "gst_bin_get_by_name")]
71 #[doc(alias = "get_by_name")]
72 fn by_name(&self, name: &str) -> Option<Element> {
73 unsafe {
74 from_glib_full(ffi::gst_bin_get_by_name(
75 self.as_ref().to_glib_none().0,
76 name.to_glib_none().0,
77 ))
78 }
79 }
80
81 #[doc(alias = "gst_bin_get_by_name_recurse_up")]
82 #[doc(alias = "get_by_name_recurse_up")]
83 fn by_name_recurse_up(&self, name: &str) -> Option<Element> {
84 unsafe {
85 from_glib_full(ffi::gst_bin_get_by_name_recurse_up(
86 self.as_ref().to_glib_none().0,
87 name.to_glib_none().0,
88 ))
89 }
90 }
91
92 #[doc(alias = "gst_bin_get_suppressed_flags")]
93 #[doc(alias = "get_suppressed_flags")]
94 fn suppressed_flags(&self) -> ElementFlags {
95 unsafe {
96 from_glib(ffi::gst_bin_get_suppressed_flags(
97 self.as_ref().to_glib_none().0,
98 ))
99 }
100 }
101
102 #[doc(alias = "gst_bin_recalculate_latency")]
103 fn recalculate_latency(&self) -> Result<(), glib::error::BoolError> {
104 unsafe {
105 glib::result_from_gboolean!(
106 ffi::gst_bin_recalculate_latency(self.as_ref().to_glib_none().0),
107 "Failed to recalculate latency"
108 )
109 }
110 }
111
112 #[doc(alias = "gst_bin_remove")]
113 fn remove(&self, element: &impl IsA<Element>) -> Result<(), glib::error::BoolError> {
114 unsafe {
115 glib::result_from_gboolean!(
116 ffi::gst_bin_remove(
117 self.as_ref().to_glib_none().0,
118 element.as_ref().to_glib_none().0
119 ),
120 "Failed to remove element"
121 )
122 }
123 }
124
125 #[doc(alias = "gst_bin_set_suppressed_flags")]
126 fn set_suppressed_flags(&self, flags: ElementFlags) {
127 unsafe {
128 ffi::gst_bin_set_suppressed_flags(self.as_ref().to_glib_none().0, flags.into_glib());
129 }
130 }
131
132 #[doc(alias = "gst_bin_sync_children_states")]
133 fn sync_children_states(&self) -> Result<(), glib::error::BoolError> {
134 unsafe {
135 glib::result_from_gboolean!(
136 ffi::gst_bin_sync_children_states(self.as_ref().to_glib_none().0),
137 "Failed to sync children states"
138 )
139 }
140 }
141
142 #[doc(alias = "async-handling")]
143 fn is_async_handling(&self) -> bool {
144 ObjectExt::property(self.as_ref(), "async-handling")
145 }
146
147 #[doc(alias = "async-handling")]
148 fn set_async_handling(&self, async_handling: bool) {
149 ObjectExt::set_property(self.as_ref(), "async-handling", async_handling)
150 }
151
152 #[doc(alias = "message-forward")]
153 fn is_message_forward(&self) -> bool {
154 ObjectExt::property(self.as_ref(), "message-forward")
155 }
156
157 #[doc(alias = "message-forward")]
158 fn set_message_forward(&self, message_forward: bool) {
159 ObjectExt::set_property(self.as_ref(), "message-forward", message_forward)
160 }
161
162 #[doc(alias = "deep-element-added")]
163 fn connect_deep_element_added<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(
164 &self,
165 f: F,
166 ) -> SignalHandlerId {
167 unsafe extern "C" fn deep_element_added_trampoline<
168 P: IsA<Bin>,
169 F: Fn(&P, &Bin, &Element) + Send + Sync + 'static,
170 >(
171 this: *mut ffi::GstBin,
172 sub_bin: *mut ffi::GstBin,
173 element: *mut ffi::GstElement,
174 f: glib::ffi::gpointer,
175 ) {
176 let f: &F = &*(f as *const F);
177 f(
178 Bin::from_glib_borrow(this).unsafe_cast_ref(),
179 &from_glib_borrow(sub_bin),
180 &from_glib_borrow(element),
181 )
182 }
183 unsafe {
184 let f: Box_<F> = Box_::new(f);
185 connect_raw(
186 self.as_ptr() as *mut _,
187 b"deep-element-added\0".as_ptr() as *const _,
188 Some(transmute::<_, unsafe extern "C" fn()>(
189 deep_element_added_trampoline::<Self, F> as *const (),
190 )),
191 Box_::into_raw(f),
192 )
193 }
194 }
195
196 #[doc(alias = "deep-element-removed")]
197 fn connect_deep_element_removed<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(
198 &self,
199 f: F,
200 ) -> SignalHandlerId {
201 unsafe extern "C" fn deep_element_removed_trampoline<
202 P: IsA<Bin>,
203 F: Fn(&P, &Bin, &Element) + Send + Sync + 'static,
204 >(
205 this: *mut ffi::GstBin,
206 sub_bin: *mut ffi::GstBin,
207 element: *mut ffi::GstElement,
208 f: glib::ffi::gpointer,
209 ) {
210 let f: &F = &*(f as *const F);
211 f(
212 Bin::from_glib_borrow(this).unsafe_cast_ref(),
213 &from_glib_borrow(sub_bin),
214 &from_glib_borrow(element),
215 )
216 }
217 unsafe {
218 let f: Box_<F> = Box_::new(f);
219 connect_raw(
220 self.as_ptr() as *mut _,
221 b"deep-element-removed\0".as_ptr() as *const _,
222 Some(transmute::<_, unsafe extern "C" fn()>(
223 deep_element_removed_trampoline::<Self, F> as *const (),
224 )),
225 Box_::into_raw(f),
226 )
227 }
228 }
229
230 #[doc(alias = "element-added")]
231 fn connect_element_added<F: Fn(&Self, &Element) + Send + Sync + 'static>(
232 &self,
233 f: F,
234 ) -> SignalHandlerId {
235 unsafe extern "C" fn element_added_trampoline<
236 P: IsA<Bin>,
237 F: Fn(&P, &Element) + Send + Sync + 'static,
238 >(
239 this: *mut ffi::GstBin,
240 element: *mut ffi::GstElement,
241 f: glib::ffi::gpointer,
242 ) {
243 let f: &F = &*(f as *const F);
244 f(
245 Bin::from_glib_borrow(this).unsafe_cast_ref(),
246 &from_glib_borrow(element),
247 )
248 }
249 unsafe {
250 let f: Box_<F> = Box_::new(f);
251 connect_raw(
252 self.as_ptr() as *mut _,
253 b"element-added\0".as_ptr() as *const _,
254 Some(transmute::<_, unsafe extern "C" fn()>(
255 element_added_trampoline::<Self, F> as *const (),
256 )),
257 Box_::into_raw(f),
258 )
259 }
260 }
261
262 #[doc(alias = "element-removed")]
263 fn connect_element_removed<F: Fn(&Self, &Element) + Send + Sync + 'static>(
264 &self,
265 f: F,
266 ) -> SignalHandlerId {
267 unsafe extern "C" fn element_removed_trampoline<
268 P: IsA<Bin>,
269 F: Fn(&P, &Element) + Send + Sync + 'static,
270 >(
271 this: *mut ffi::GstBin,
272 element: *mut ffi::GstElement,
273 f: glib::ffi::gpointer,
274 ) {
275 let f: &F = &*(f as *const F);
276 f(
277 Bin::from_glib_borrow(this).unsafe_cast_ref(),
278 &from_glib_borrow(element),
279 )
280 }
281 unsafe {
282 let f: Box_<F> = Box_::new(f);
283 connect_raw(
284 self.as_ptr() as *mut _,
285 b"element-removed\0".as_ptr() as *const _,
286 Some(transmute::<_, unsafe extern "C" fn()>(
287 element_removed_trampoline::<Self, F> as *const (),
288 )),
289 Box_::into_raw(f),
290 )
291 }
292 }
293
294 #[doc(alias = "async-handling")]
295 fn connect_async_handling_notify<F: Fn(&Self) + Send + Sync + 'static>(
296 &self,
297 f: F,
298 ) -> SignalHandlerId {
299 unsafe extern "C" fn notify_async_handling_trampoline<
300 P: IsA<Bin>,
301 F: Fn(&P) + Send + Sync + 'static,
302 >(
303 this: *mut ffi::GstBin,
304 _param_spec: glib::ffi::gpointer,
305 f: glib::ffi::gpointer,
306 ) {
307 let f: &F = &*(f as *const F);
308 f(Bin::from_glib_borrow(this).unsafe_cast_ref())
309 }
310 unsafe {
311 let f: Box_<F> = Box_::new(f);
312 connect_raw(
313 self.as_ptr() as *mut _,
314 b"notify::async-handling\0".as_ptr() as *const _,
315 Some(transmute::<_, unsafe extern "C" fn()>(
316 notify_async_handling_trampoline::<Self, F> as *const (),
317 )),
318 Box_::into_raw(f),
319 )
320 }
321 }
322
323 #[doc(alias = "message-forward")]
324 fn connect_message_forward_notify<F: Fn(&Self) + Send + Sync + 'static>(
325 &self,
326 f: F,
327 ) -> SignalHandlerId {
328 unsafe extern "C" fn notify_message_forward_trampoline<
329 P: IsA<Bin>,
330 F: Fn(&P) + Send + Sync + 'static,
331 >(
332 this: *mut ffi::GstBin,
333 _param_spec: glib::ffi::gpointer,
334 f: glib::ffi::gpointer,
335 ) {
336 let f: &F = &*(f as *const F);
337 f(Bin::from_glib_borrow(this).unsafe_cast_ref())
338 }
339 unsafe {
340 let f: Box_<F> = Box_::new(f);
341 connect_raw(
342 self.as_ptr() as *mut _,
343 b"notify::message-forward\0".as_ptr() as *const _,
344 Some(transmute::<_, unsafe extern "C" fn()>(
345 notify_message_forward_trampoline::<Self, F> as *const (),
346 )),
347 Box_::into_raw(f),
348 )
349 }
350 }
351}
352
353impl<O: IsA<Bin>> GstBinExt for O {}
354