device.rs 3.29 KB
Newer Older
1
// This file was generated by gir (ef05cf1) from gir-files (???)
2 3
// DO NOT EDIT

Sebastian Dröge's avatar
Sebastian Dröge committed
4
use Caps;
5 6
use Element;
use Object;
Sebastian Dröge's avatar
Sebastian Dröge committed
7
use Structure;
8 9 10 11 12 13 14 15 16
use ffi;
use glib;
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_;
17
use std::mem;
18
use std::mem::transmute;
19
use std::ptr;
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

glib_wrapper! {
    pub struct Device(Object<ffi::GstDevice>): Object;

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

unsafe impl Send for Device {}
unsafe impl Sync for Device {}

pub trait DeviceExt {
    fn create_element<'a, P: Into<Option<&'a str>>>(&self, name: P) -> Option<Element>;

Sebastian Dröge's avatar
Sebastian Dröge committed
35
    fn get_caps(&self) -> Option<Caps>;
36 37 38 39 40

    fn get_device_class(&self) -> Option<String>;

    fn get_display_name(&self) -> Option<String>;

Sebastian Dröge's avatar
Sebastian Dröge committed
41 42
    fn get_properties(&self) -> Option<Structure>;

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    fn has_classes(&self, classes: &str) -> bool;

    fn has_classesv(&self, classes: &[&str]) -> bool;

    fn reconfigure_element<P: IsA<Element>>(&self, element: &P) -> bool;

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

impl<O: IsA<Device> + IsA<glib::object::Object>> DeviceExt for O {
    fn create_element<'a, P: Into<Option<&'a str>>>(&self, name: P) -> Option<Element> {
        let name = name.into();
        let name = name.to_glib_none();
        unsafe {
            from_glib_full(ffi::gst_device_create_element(self.to_glib_none().0, name.0))
        }
    }

Sebastian Dröge's avatar
Sebastian Dröge committed
61 62 63 64 65
    fn get_caps(&self) -> Option<Caps> {
        unsafe {
            from_glib_full(ffi::gst_device_get_caps(self.to_glib_none().0))
        }
    }
66 67 68 69 70 71 72 73 74 75 76 77 78

    fn get_device_class(&self) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gst_device_get_device_class(self.to_glib_none().0))
        }
    }

    fn get_display_name(&self) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gst_device_get_display_name(self.to_glib_none().0))
        }
    }

Sebastian Dröge's avatar
Sebastian Dröge committed
79 80 81 82 83 84
    fn get_properties(&self) -> Option<Structure> {
        unsafe {
            from_glib_full(ffi::gst_device_get_properties(self.to_glib_none().0))
        }
    }

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
    fn has_classes(&self, classes: &str) -> bool {
        unsafe {
            from_glib(ffi::gst_device_has_classes(self.to_glib_none().0, classes.to_glib_none().0))
        }
    }

    fn has_classesv(&self, classes: &[&str]) -> bool {
        unsafe {
            from_glib(ffi::gst_device_has_classesv(self.to_glib_none().0, classes.to_glib_none().0))
        }
    }

    fn reconfigure_element<P: IsA<Element>>(&self, element: &P) -> bool {
        unsafe {
            from_glib(ffi::gst_device_reconfigure_element(self.to_glib_none().0, element.to_glib_none().0))
        }
    }

    fn connect_removed<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, "removed",
                transmute(removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn removed_trampoline<P>(this: *mut ffi::GstDevice, f: glib_ffi::gpointer)
where P: IsA<Device> {
    callback_guard!();
    let f: &Box_<Fn(&P) + Send + Sync + 'static> = transmute(f);
    f(&Device::from_glib_none(this).downcast_unchecked())
}