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