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

5
use Caps;
6 7
use Element;
use Object;
8
use Structure;
9 10 11 12
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
13
use glib::signal::SignalHandlerId;
14 15 16 17 18
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
19
use std::mem;
20
use std::mem::transmute;
21
use std::ptr;
22 23

glib_wrapper! {
24
    pub struct Device(Object<ffi::GstDevice, ffi::GstDeviceClass>): Object;
25 26 27 28 29 30 31 32 33 34 35 36

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

37
    fn get_caps(&self) -> Option<Caps>;
38

39
    fn get_device_class(&self) -> String;
40

41
    fn get_display_name(&self) -> String;
42

43 44
    fn get_properties(&self) -> Option<Structure>;

45 46 47 48 49 50
    fn has_classes(&self, classes: &str) -> bool;

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

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

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

53
    fn connect_property_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
54

55
    fn connect_property_device_class_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
56

57
    fn connect_property_display_name_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
58

59
    fn connect_property_properties_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
60 61 62 63 64 65 66 67 68 69 70
}

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

71 72 73 74 75
    fn get_caps(&self) -> Option<Caps> {
        unsafe {
            from_glib_full(ffi::gst_device_get_caps(self.to_glib_none().0))
        }
    }
76

77
    fn get_device_class(&self) -> String {
78 79 80 81 82
        unsafe {
            from_glib_full(ffi::gst_device_get_device_class(self.to_glib_none().0))
        }
    }

83
    fn get_display_name(&self) -> String {
84 85 86 87 88
        unsafe {
            from_glib_full(ffi::gst_device_get_display_name(self.to_glib_none().0))
        }
    }

89 90 91 92 93 94
    fn get_properties(&self) -> Option<Structure> {
        unsafe {
            from_glib_full(ffi::gst_device_get_properties(self.to_glib_none().0))
        }
    }

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
    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))
        }
    }

113
    fn connect_removed<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
114 115 116 117 118 119
        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 _)
        }
    }
120

121
    fn connect_property_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
122 123 124 125 126 127 128
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::caps",
                transmute(notify_caps_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

129
    fn connect_property_device_class_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
130 131 132 133 134 135 136
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::device-class",
                transmute(notify_device_class_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

137
    fn connect_property_display_name_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
138 139 140 141 142 143 144
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::display-name",
                transmute(notify_display_name_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

145
    fn connect_property_properties_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
146 147 148 149 150 151
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::properties",
                transmute(notify_properties_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
152 153 154 155
}

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

unsafe extern "C" fn notify_caps_trampoline<P>(this: *mut ffi::GstDevice, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Device> {
163
    callback_guard!();
164
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
165
    f(&Device::from_glib_borrow(this).downcast_unchecked())
166 167 168 169
}

unsafe extern "C" fn notify_device_class_trampoline<P>(this: *mut ffi::GstDevice, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Device> {
170
    callback_guard!();
171
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
172
    f(&Device::from_glib_borrow(this).downcast_unchecked())
173 174 175 176
}

unsafe extern "C" fn notify_display_name_trampoline<P>(this: *mut ffi::GstDevice, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Device> {
177
    callback_guard!();
178
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
179
    f(&Device::from_glib_borrow(this).downcast_unchecked())
180 181 182 183
}

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