bin.rs 13.9 KB
Newer Older
1 2
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
Sebastian Dröge's avatar
Sebastian Dröge committed
3 4
// DO NOT EDIT

Sebastian Dröge's avatar
Sebastian Dröge committed
5
use BinClass;
6
use ChildProxy;
Sebastian Dröge's avatar
Sebastian Dröge committed
7
use Element;
8
#[cfg(any(feature = "v1_10", feature = "dox"))]
9
use ElementFlags;
Sebastian Dröge's avatar
Sebastian Dröge committed
10 11 12 13 14
use Object;
use Pad;
use PadDirection;
use ffi;
use glib;
15
use glib::StaticType;
Sebastian Dröge's avatar
Sebastian Dröge committed
16 17 18
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
19
use glib::signal::SignalHandlerId;
20
use glib::signal::connect_raw;
Sebastian Dröge's avatar
Sebastian Dröge committed
21 22 23 24 25 26 27
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem::transmute;

glib_wrapper! {
Sebastian Dröge's avatar
Sebastian Dröge committed
28
    pub struct Bin(Object<ffi::GstBin, ffi::GstBinClass, BinClass>): Element, Object, ChildProxy;
Sebastian Dröge's avatar
Sebastian Dröge committed
29 30 31 32 33 34 35 36

    match fn {
        get_type => || ffi::gst_bin_get_type(),
    }
}

impl Bin {
    pub fn new<'a, P: Into<Option<&'a str>>>(name: P) -> Bin {
37
        assert_initialized_main_thread!();
Sebastian Dröge's avatar
Sebastian Dröge committed
38 39 40 41 42 43 44 45
        let name = name.into();
        let name = name.to_glib_none();
        unsafe {
            Element::from_glib_none(ffi::gst_bin_new(name.0)).downcast_unchecked()
        }
    }
}

46 47 48
unsafe impl Send for Bin {}
unsafe impl Sync for Bin {}

49
pub trait GstBinExt: 'static {
50
    fn add<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
51 52 53 54 55 56 57 58 59 60 61

    //fn add_many<P: IsA<Element>>(&self, element_1: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    fn find_unlinked_pad(&self, direction: PadDirection) -> Option<Pad>;

    fn get_by_interface(&self, iface: glib::types::Type) -> Option<Element>;

    fn get_by_name(&self, name: &str) -> Option<Element>;

    fn get_by_name_recurse_up(&self, name: &str) -> Option<Element>;

62
    #[cfg(any(feature = "v1_10", feature = "dox"))]
63
    fn get_suppressed_flags(&self) -> ElementFlags;
Sebastian Dröge's avatar
Sebastian Dröge committed
64

65
    //fn iterate_all_by_interface(&self, iface: glib::types::Type) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
66

67
    //fn iterate_elements(&self) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
68

69
    //fn iterate_recurse(&self) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
70

71
    //fn iterate_sinks(&self) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
72

73
    //fn iterate_sorted(&self) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
74

75
    //fn iterate_sources(&self) -> /*Ignored*/Option<Iterator>;
Sebastian Dröge's avatar
Sebastian Dröge committed
76

77
    fn recalculate_latency(&self) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
78

79
    fn remove<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
80 81 82

    //fn remove_many<P: IsA<Element>>(&self, element_1: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

83
    #[cfg(any(feature = "v1_10", feature = "dox"))]
84
    fn set_suppressed_flags(&self, flags: ElementFlags);
Sebastian Dröge's avatar
Sebastian Dröge committed
85

86
    fn sync_children_states(&self) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
87 88 89 90 91 92 93 94 95

    fn get_property_async_handling(&self) -> bool;

    fn set_property_async_handling(&self, async_handling: bool);

    fn get_property_message_forward(&self) -> bool;

    fn set_property_message_forward(&self, message_forward: bool);

96
    #[cfg(any(feature = "v1_10", feature = "dox"))]
97
    fn connect_deep_element_added<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
98

99
    #[cfg(any(feature = "v1_10", feature = "dox"))]
100
    fn connect_deep_element_removed<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
101

102
    fn connect_do_latency<F: Fn(&Self) -> bool + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
103

104
    fn connect_element_added<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
105

106
    fn connect_element_removed<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
107

108
    fn connect_property_async_handling_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
109

110
    fn connect_property_message_forward_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
111 112
}

113
impl<O: IsA<Bin>> GstBinExt for O {
114
    fn add<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
115
        unsafe {
François Laignel's avatar
François Laignel committed
116
            glib_result_from_gboolean!(ffi::gst_bin_add(self.to_glib_none().0, element.to_glib_none().0), "Failed to add element")
Sebastian Dröge's avatar
Sebastian Dröge committed
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
        }
    }

    //fn add_many<P: IsA<Element>>(&self, element_1: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi::gst_bin_add_many() }
    //}

    fn find_unlinked_pad(&self, direction: PadDirection) -> Option<Pad> {
        unsafe {
            from_glib_full(ffi::gst_bin_find_unlinked_pad(self.to_glib_none().0, direction.to_glib()))
        }
    }

    fn get_by_interface(&self, iface: glib::types::Type) -> Option<Element> {
        unsafe {
            from_glib_full(ffi::gst_bin_get_by_interface(self.to_glib_none().0, iface.to_glib()))
        }
    }

    fn get_by_name(&self, name: &str) -> Option<Element> {
        unsafe {
            from_glib_full(ffi::gst_bin_get_by_name(self.to_glib_none().0, name.to_glib_none().0))
        }
    }

    fn get_by_name_recurse_up(&self, name: &str) -> Option<Element> {
        unsafe {
            from_glib_full(ffi::gst_bin_get_by_name_recurse_up(self.to_glib_none().0, name.to_glib_none().0))
        }
    }

148
    #[cfg(any(feature = "v1_10", feature = "dox"))]
149 150 151 152 153
    fn get_suppressed_flags(&self) -> ElementFlags {
        unsafe {
            from_glib(ffi::gst_bin_get_suppressed_flags(self.to_glib_none().0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
154

155 156 157
    //fn iterate_all_by_interface(&self, iface: glib::types::Type) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_all_by_interface() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
158

159 160 161
    //fn iterate_elements(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_elements() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
162

163 164 165
    //fn iterate_recurse(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_recurse() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
166

167 168 169
    //fn iterate_sinks(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_sinks() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
170

171 172 173
    //fn iterate_sorted(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_sorted() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
174

175 176 177
    //fn iterate_sources(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_sources() }
    //}
Sebastian Dröge's avatar
Sebastian Dröge committed
178

179
    fn recalculate_latency(&self) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
180
        unsafe {
François Laignel's avatar
François Laignel committed
181
            glib_result_from_gboolean!(ffi::gst_bin_recalculate_latency(self.to_glib_none().0), "Failed to recalculate latency")
Sebastian Dröge's avatar
Sebastian Dröge committed
182 183 184
        }
    }

185
    fn remove<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
186
        unsafe {
François Laignel's avatar
François Laignel committed
187
            glib_result_from_gboolean!(ffi::gst_bin_remove(self.to_glib_none().0, element.to_glib_none().0), "Failed to remove element")
Sebastian Dröge's avatar
Sebastian Dröge committed
188 189 190 191 192 193 194
        }
    }

    //fn remove_many<P: IsA<Element>>(&self, element_1: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi::gst_bin_remove_many() }
    //}

195
    #[cfg(any(feature = "v1_10", feature = "dox"))]
196 197 198 199 200
    fn set_suppressed_flags(&self, flags: ElementFlags) {
        unsafe {
            ffi::gst_bin_set_suppressed_flags(self.to_glib_none().0, flags.to_glib());
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
201

202
    fn sync_children_states(&self) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
203
        unsafe {
François Laignel's avatar
François Laignel committed
204
            glib_result_from_gboolean!(ffi::gst_bin_sync_children_states(self.to_glib_none().0), "Failed to sync children states")
Sebastian Dröge's avatar
Sebastian Dröge committed
205 206 207 208 209
        }
    }

    fn get_property_async_handling(&self) -> bool {
        unsafe {
210
            let mut value = Value::from_type(<bool as StaticType>::static_type());
211
            gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"async-handling\0".as_ptr() as *const _, value.to_glib_none_mut().0);
212
            value.get().unwrap()
Sebastian Dröge's avatar
Sebastian Dröge committed
213 214 215 216 217
        }
    }

    fn set_property_async_handling(&self, async_handling: bool) {
        unsafe {
218
            gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"async-handling\0".as_ptr() as *const _, Value::from(&async_handling).to_glib_none().0);
Sebastian Dröge's avatar
Sebastian Dröge committed
219 220 221 222 223
        }
    }

    fn get_property_message_forward(&self) -> bool {
        unsafe {
224
            let mut value = Value::from_type(<bool as StaticType>::static_type());
225
            gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"message-forward\0".as_ptr() as *const _, value.to_glib_none_mut().0);
226
            value.get().unwrap()
Sebastian Dröge's avatar
Sebastian Dröge committed
227 228 229 230 231
        }
    }

    fn set_property_message_forward(&self, message_forward: bool) {
        unsafe {
232
            gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"message-forward\0".as_ptr() as *const _, Value::from(&message_forward).to_glib_none().0);
Sebastian Dröge's avatar
Sebastian Dröge committed
233 234 235
        }
    }

236
    #[cfg(any(feature = "v1_10", feature = "dox"))]
237
    fn connect_deep_element_added<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
238
        unsafe {
239
            let f: Box_<Box_<Fn(&Self, &Bin, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
240
            connect_raw(self.to_glib_none().0 as *mut _, b"deep-element-added\0".as_ptr() as *const _,
Sebastian Dröge's avatar
Sebastian Dröge committed
241 242 243 244
                transmute(deep_element_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

245
    #[cfg(any(feature = "v1_10", feature = "dox"))]
246
    fn connect_deep_element_removed<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
247
        unsafe {
248
            let f: Box_<Box_<Fn(&Self, &Bin, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
249
            connect_raw(self.to_glib_none().0 as *mut _, b"deep-element-removed\0".as_ptr() as *const _,
Sebastian Dröge's avatar
Sebastian Dröge committed
250 251 252 253
                transmute(deep_element_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

254
    fn connect_do_latency<F: Fn(&Self) -> bool + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
255
        unsafe {
256
            let f: Box_<Box_<Fn(&Self) -> bool + Send + Sync + 'static>> = Box_::new(Box_::new(f));
257
            connect_raw(self.to_glib_none().0 as *mut _, b"do-latency\0".as_ptr() as *const _,
Sebastian Dröge's avatar
Sebastian Dröge committed
258 259 260 261
                transmute(do_latency_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

262
    fn connect_element_added<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
263
        unsafe {
264
            let f: Box_<Box_<Fn(&Self, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
265
            connect_raw(self.to_glib_none().0 as *mut _, b"element-added\0".as_ptr() as *const _,
Sebastian Dröge's avatar
Sebastian Dröge committed
266 267 268 269
                transmute(element_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

270
    fn connect_element_removed<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
271
        unsafe {
272
            let f: Box_<Box_<Fn(&Self, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
273
            connect_raw(self.to_glib_none().0 as *mut _, b"element-removed\0".as_ptr() as *const _,
Sebastian Dröge's avatar
Sebastian Dröge committed
274 275 276
                transmute(element_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
277

278
    fn connect_property_async_handling_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
279 280
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
281
            connect_raw(self.to_glib_none().0 as *mut _, b"notify::async-handling\0".as_ptr() as *const _,
282 283 284 285
                transmute(notify_async_handling_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

286
    fn connect_property_message_forward_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
287 288
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
289
            connect_raw(self.to_glib_none().0 as *mut _, b"notify::message-forward\0".as_ptr() as *const _,
290 291 292
                transmute(notify_message_forward_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
293 294
}

295
#[cfg(any(feature = "v1_10", feature = "dox"))]
Sebastian Dröge's avatar
Sebastian Dröge committed
296 297
unsafe extern "C" fn deep_element_added_trampoline<P>(this: *mut ffi::GstBin, sub_bin: *mut ffi::GstBin, element: *mut ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<Bin> {
298
    let f: &&(Fn(&P, &Bin, &Element) + Send + Sync + 'static) = transmute(f);
299
    f(&Bin::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(sub_bin), &from_glib_borrow(element))
Sebastian Dröge's avatar
Sebastian Dröge committed
300 301
}

302
#[cfg(any(feature = "v1_10", feature = "dox"))]
Sebastian Dröge's avatar
Sebastian Dröge committed
303 304
unsafe extern "C" fn deep_element_removed_trampoline<P>(this: *mut ffi::GstBin, sub_bin: *mut ffi::GstBin, element: *mut ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<Bin> {
305
    let f: &&(Fn(&P, &Bin, &Element) + Send + Sync + 'static) = transmute(f);
306
    f(&Bin::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(sub_bin), &from_glib_borrow(element))
Sebastian Dröge's avatar
Sebastian Dröge committed
307 308 309 310
}

unsafe extern "C" fn do_latency_trampoline<P>(this: *mut ffi::GstBin, f: glib_ffi::gpointer) -> glib_ffi::gboolean
where P: IsA<Bin> {
311
    let f: &&(Fn(&P) -> bool + Send + Sync + 'static) = transmute(f);
312
    f(&Bin::from_glib_borrow(this).downcast_unchecked()).to_glib()
Sebastian Dröge's avatar
Sebastian Dröge committed
313 314 315 316
}

unsafe extern "C" fn element_added_trampoline<P>(this: *mut ffi::GstBin, element: *mut ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<Bin> {
317
    let f: &&(Fn(&P, &Element) + Send + Sync + 'static) = transmute(f);
318
    f(&Bin::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(element))
Sebastian Dröge's avatar
Sebastian Dröge committed
319 320 321 322
}

unsafe extern "C" fn element_removed_trampoline<P>(this: *mut ffi::GstBin, element: *mut ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<Bin> {
323
    let f: &&(Fn(&P, &Element) + Send + Sync + 'static) = transmute(f);
324
    f(&Bin::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(element))
Sebastian Dröge's avatar
Sebastian Dröge committed
325
}
326 327 328 329

unsafe extern "C" fn notify_async_handling_trampoline<P>(this: *mut ffi::GstBin, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Bin> {
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
330
    f(&Bin::from_glib_borrow(this).downcast_unchecked())
331 332 333 334 335
}

unsafe extern "C" fn notify_message_forward_trampoline<P>(this: *mut ffi::GstBin, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Bin> {
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
336
    f(&Bin::from_glib_borrow(this).downcast_unchecked())
337
}