bin.rs 11.4 KB
Newer Older
1
// This file was generated by gir (33e9567) from gir-files (???)
Sebastian Dröge's avatar
Sebastian Dröge committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
// DO NOT EDIT

use Element;
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_;
use std::mem::transmute;

glib_wrapper! {
    pub struct Bin(Object<ffi::GstBin>): Element, Object;

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

impl Bin {
    pub fn new<'a, P: Into<Option<&'a str>>>(name: P) -> Bin {
        let name = name.into();
        let name = name.to_glib_none();
        unsafe {
            Element::from_glib_none(ffi::gst_bin_new(name.0)).downcast_unchecked()
        }
    }
}

38 39 40
unsafe impl Send for Bin {}
unsafe impl Sync for Bin {}

Sebastian Dröge's avatar
Sebastian Dröge committed
41
pub trait BinExt {
42
    fn add<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

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

    //#[cfg(feature = "v1_10")]
    //fn get_suppressed_flags(&self) -> /*Ignored*/ElementFlags;

    //fn iterate_all_by_interface(&self, iface: glib::types::Type) -> /*Ignored*/Option<Iterator>;

    //fn iterate_elements(&self) -> /*Ignored*/Option<Iterator>;

    //fn iterate_recurse(&self) -> /*Ignored*/Option<Iterator>;

    //fn iterate_sinks(&self) -> /*Ignored*/Option<Iterator>;

    //fn iterate_sorted(&self) -> /*Ignored*/Option<Iterator>;

    //fn iterate_sources(&self) -> /*Ignored*/Option<Iterator>;

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

71
    fn remove<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
72 73 74 75 76 77

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

    //#[cfg(feature = "v1_10")]
    //fn set_suppressed_flags(&self, flags: /*Ignored*/ElementFlags);

78
    fn sync_children_states(&self) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
79 80 81 82 83 84 85 86 87 88

    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")]
89
    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
90 91

    #[cfg(feature = "v1_10")]
92
    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
93

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

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

98
    fn connect_element_removed<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> u64;
Sebastian Dröge's avatar
Sebastian Dröge committed
99 100 101
}

impl<O: IsA<Bin> + IsA<glib::object::Object>> BinExt for O {
102
    fn add<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
103
        unsafe {
104
            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
105 106 107 108 109 110 111 112 113 114 115 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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
        }
    }

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

    //#[cfg(feature = "v1_10")]
    //fn get_suppressed_flags(&self) -> /*Ignored*/ElementFlags {
    //    unsafe { TODO: call ffi::gst_bin_get_suppressed_flags() }
    //}

    //fn iterate_all_by_interface(&self, iface: glib::types::Type) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_all_by_interface() }
    //}

    //fn iterate_elements(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_elements() }
    //}

    //fn iterate_recurse(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_recurse() }
    //}

    //fn iterate_sinks(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_sinks() }
    //}

    //fn iterate_sorted(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_sorted() }
    //}

    //fn iterate_sources(&self) -> /*Ignored*/Option<Iterator> {
    //    unsafe { TODO: call ffi::gst_bin_iterate_sources() }
    //}

165
    fn recalculate_latency(&self) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
166
        unsafe {
167
            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
168 169 170
        }
    }

171
    fn remove<P: IsA<Element>>(&self, element: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
172
        unsafe {
173
            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
174 175 176 177 178 179 180 181 182 183 184 185
        }
    }

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

    //#[cfg(feature = "v1_10")]
    //fn set_suppressed_flags(&self, flags: /*Ignored*/ElementFlags) {
    //    unsafe { TODO: call ffi::gst_bin_set_suppressed_flags() }
    //}

186
    fn sync_children_states(&self) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
187
        unsafe {
188
            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
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
        }
    }

    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")]
221
    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
222
        unsafe {
223
            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
224 225 226 227 228 229
            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")]
230
    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
231
        unsafe {
232
            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
233 234 235 236 237
            connect(self.to_glib_none().0, "deep-element-removed",
                transmute(deep_element_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

238
    fn connect_do_latency<F: Fn(&Self) -> bool + Send + Sync + 'static>(&self, f: F) -> u64 {
Sebastian Dröge's avatar
Sebastian Dröge committed
239
        unsafe {
240
            let f: Box_<Box_<Fn(&Self) -> bool + Send + Sync + 'static>> = Box_::new(Box_::new(f));
Sebastian Dröge's avatar
Sebastian Dröge committed
241 242 243 244 245
            connect(self.to_glib_none().0, "do-latency",
                transmute(do_latency_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

246
    fn connect_element_added<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> u64 {
Sebastian Dröge's avatar
Sebastian Dröge committed
247
        unsafe {
248
            let f: Box_<Box_<Fn(&Self, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
Sebastian Dröge's avatar
Sebastian Dröge committed
249 250 251 252 253
            connect(self.to_glib_none().0, "element-added",
                transmute(element_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

254
    fn connect_element_removed<F: Fn(&Self, &Element) + Send + Sync + 'static>(&self, f: F) -> u64 {
Sebastian Dröge's avatar
Sebastian Dröge committed
255
        unsafe {
256
            let f: Box_<Box_<Fn(&Self, &Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
Sebastian Dröge's avatar
Sebastian Dröge committed
257 258 259 260 261 262 263 264 265 266
            connect(self.to_glib_none().0, "element-removed",
                transmute(element_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

#[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!();
267
    let f: &Box_<Fn(&P, &Bin, &Element) + Send + Sync + 'static> = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
268 269 270 271 272 273 274
    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!();
275
    let f: &Box_<Fn(&P, &Bin, &Element) + Send + Sync + 'static> = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
276 277 278 279 280 281
    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!();
282
    let f: &Box_<Fn(&P) -> bool + Send + Sync + 'static> = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
283 284 285 286 287 288
    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!();
289
    let f: &Box_<Fn(&P, &Element) + Send + Sync + 'static> = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
290 291 292 293 294 295
    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!();
296
    let f: &Box_<Fn(&P, &Element) + Send + Sync + 'static> = transmute(f);
Sebastian Dröge's avatar
Sebastian Dröge committed
297 298
    f(&Bin::from_glib_none(this).downcast_unchecked(), &from_glib_none(element))
}