bin.rs 13.2 KB
Newer Older
1
// This file was generated by gir (e43d6c3) from gir-files (???)
Sebastian Dröge's avatar
Sebastian Dröge committed
2 3
// DO NOT EDIT

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

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

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

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

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

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

    //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>;

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

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

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

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

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

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

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

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

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

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

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

85
    fn sync_children_states(&self) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
86 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);

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

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

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

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

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

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

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

impl<O: IsA<Bin> + IsA<glib::object::Object>> BinExt for O {
113
    fn add<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
114
        unsafe {
115
            glib::error::BoolError::from_glib(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
116 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
        }
    }

    //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))
        }
    }

147 148 149 150 151 152
    #[cfg(feature = "v1_10")]
    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
153

Sebastian Dröge's avatar
Sebastian Dröge committed
154 155 156 157 158
    fn iterate_all_by_interface(&self, iface: glib::types::Type) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::gst_bin_iterate_all_by_interface(self.to_glib_none().0, iface.to_glib()))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
159

Sebastian Dröge's avatar
Sebastian Dröge committed
160 161 162 163 164
    fn iterate_elements(&self) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::gst_bin_iterate_elements(self.to_glib_none().0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
165

Sebastian Dröge's avatar
Sebastian Dröge committed
166 167 168 169 170
    fn iterate_recurse(&self) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::gst_bin_iterate_recurse(self.to_glib_none().0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
171

Sebastian Dröge's avatar
Sebastian Dröge committed
172 173 174 175 176
    fn iterate_sinks(&self) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::gst_bin_iterate_sinks(self.to_glib_none().0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
177

Sebastian Dröge's avatar
Sebastian Dröge committed
178 179 180 181 182
    fn iterate_sorted(&self) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::gst_bin_iterate_sorted(self.to_glib_none().0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
183

Sebastian Dröge's avatar
Sebastian Dröge committed
184 185 186 187 188
    fn iterate_sources(&self) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::gst_bin_iterate_sources(self.to_glib_none().0))
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
189

190
    fn recalculate_latency(&self) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
191
        unsafe {
192
            glib::error::BoolError::from_glib(ffi::gst_bin_recalculate_latency(self.to_glib_none().0), "Failed to recalculate latency")
Sebastian Dröge's avatar
Sebastian Dröge committed
193 194 195
        }
    }

196
    fn remove<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
197
        unsafe {
198
            glib::error::BoolError::from_glib(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
199 200 201 202 203 204 205
        }
    }

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

206 207 208 209 210 211
    #[cfg(feature = "v1_10")]
    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
212

213
    fn sync_children_states(&self) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
214
        unsafe {
215
            glib::error::BoolError::from_glib(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
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
        }
    }

    fn get_property_async_handling(&self) -> bool {
        let mut value = Value::from(&false);
        unsafe {
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "async-handling".to_glib_none().0, value.to_glib_none_mut().0);
        }
        value.get().unwrap()
    }

    fn set_property_async_handling(&self, async_handling: bool) {
        unsafe {
            gobject_ffi::g_object_set_property(self.to_glib_none().0, "async-handling".to_glib_none().0, Value::from(&async_handling).to_glib_none().0);
        }
    }

    fn get_property_message_forward(&self) -> bool {
        let mut value = Value::from(&false);
        unsafe {
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "message-forward".to_glib_none().0, value.to_glib_none_mut().0);
        }
        value.get().unwrap()
    }

    fn set_property_message_forward(&self, message_forward: bool) {
        unsafe {
            gobject_ffi::g_object_set_property(self.to_glib_none().0, "message-forward".to_glib_none().0, Value::from(&message_forward).to_glib_none().0);
        }
    }

    #[cfg(feature = "v1_10")]
248
    fn connect_deep_element_added<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(&self, f: F) -> u64 {
Sebastian Dröge's avatar
Sebastian Dröge committed
249
        unsafe {
250
            let f: Box_<Box_<Fn(&Self, &Bin, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
Sebastian Dröge's avatar
Sebastian Dröge committed
251 252 253 254 255 256
            connect(self.to_glib_none().0, "deep-element-added",
                transmute(deep_element_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    #[cfg(feature = "v1_10")]
257
    fn connect_deep_element_removed<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(&self, f: F) -> u64 {
Sebastian Dröge's avatar
Sebastian Dröge committed
258
        unsafe {
259
            let f: Box_<Box_<Fn(&Self, &Bin, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
Sebastian Dröge's avatar
Sebastian Dröge committed
260 261 262 263 264
            connect(self.to_glib_none().0, "deep-element-removed",
                transmute(deep_element_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

265
    fn connect_do_latency<F: Fn(&Self) -> bool + Send + Sync + 'static>(&self, f: F) -> u64 {
Sebastian Dröge's avatar
Sebastian Dröge committed
266
        unsafe {
267
            let f: Box_<Box_<Fn(&Self) -> bool + Send + Sync + 'static>> = Box_::new(Box_::new(f));
Sebastian Dröge's avatar
Sebastian Dröge committed
268 269 270 271 272
            connect(self.to_glib_none().0, "do-latency",
                transmute(do_latency_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

273
    fn connect_element_added<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> u64 {
Sebastian Dröge's avatar
Sebastian Dröge committed
274
        unsafe {
275
            let f: Box_<Box_<Fn(&Self, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
Sebastian Dröge's avatar
Sebastian Dröge committed
276 277 278 279 280
            connect(self.to_glib_none().0, "element-added",
                transmute(element_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

281
    fn connect_element_removed<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> u64 {
Sebastian Dröge's avatar
Sebastian Dröge committed
282
        unsafe {
283
            let f: Box_<Box_<Fn(&Self, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
Sebastian Dröge's avatar
Sebastian Dröge committed
284 285 286 287
            connect(self.to_glib_none().0, "element-removed",
                transmute(element_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303

    fn connect_property_async_handling_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> u64 {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::async-handling",
                transmute(notify_async_handling_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_message_forward_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> u64 {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::message-forward",
                transmute(notify_message_forward_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
Sebastian Dröge's avatar
Sebastian Dröge committed
304 305 306 307 308 309
}

#[cfg(feature = "v1_10")]
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> {
    callback_guard!();
310
    let f: &&(Fn(&P, &Bin, &Element) + Send + Sync + 'static) = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
311 312 313 314 315 316 317
    f(&Bin::from_glib_none(this).downcast_unchecked(), &from_glib_none(sub_bin), &from_glib_none(element))
}

#[cfg(feature = "v1_10")]
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> {
    callback_guard!();
318
    let f: &&(Fn(&P, &Bin, &Element) + Send + Sync + 'static) = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
319 320 321 322 323 324
    f(&Bin::from_glib_none(this).downcast_unchecked(), &from_glib_none(sub_bin), &from_glib_none(element))
}

unsafe extern "C" fn do_latency_trampoline<P>(this: *mut ffi::GstBin, f: glib_ffi::gpointer) -> glib_ffi::gboolean
where P: IsA<Bin> {
    callback_guard!();
325
    let f: &&(Fn(&P) -> bool + Send + Sync + 'static) = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
326 327 328 329 330 331
    f(&Bin::from_glib_none(this).downcast_unchecked()).to_glib()
}

unsafe extern "C" fn element_added_trampoline<P>(this: *mut ffi::GstBin, element: *mut ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<Bin> {
    callback_guard!();
332
    let f: &&(Fn(&P, &Element) + Send + Sync + 'static) = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
333 334 335 336 337 338
    f(&Bin::from_glib_none(this).downcast_unchecked(), &from_glib_none(element))
}

unsafe extern "C" fn element_removed_trampoline<P>(this: *mut ffi::GstBin, element: *mut ffi::GstElement, f: glib_ffi::gpointer)
where P: IsA<Bin> {
    callback_guard!();
339
    let f: &&(Fn(&P, &Element) + Send + Sync + 'static) = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
340 341
    f(&Bin::from_glib_none(this).downcast_unchecked(), &from_glib_none(element))
}
342 343 344 345 346 347 348 349 350 351 352 353 354 355

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> {
    callback_guard!();
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
    f(&Bin::from_glib_none(this).downcast_unchecked())
}

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> {
    callback_guard!();
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
    f(&Bin::from_glib_none(this).downcast_unchecked())
}