device.rs 8.44 KB
Newer Older
1
// This file was generated by gir (d50d839) 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
use ffi;
use glib;
10
use glib::StaticType;
11
use glib::Value;
12 13
use glib::object::Downcast;
use glib::object::IsA;
14
use glib::signal::SignalHandlerId;
15 16 17 18 19
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
20
use std::mem;
21
use std::mem::transmute;
22
use std::ptr;
23 24

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

    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
38
    fn get_caps(&self) -> Option<Caps>;
39

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

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

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

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

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

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

52 53 54 55 56 57 58 59
    fn get_property_caps(&self) -> Option<Caps>;

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

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

    fn get_property_properties(&self) -> Option<Structure>;

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

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

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

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

68
    fn connect_property_properties_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
69 70 71 72 73 74 75 76 77 78 79
}

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
80 81 82 83 84
    fn get_caps(&self) -> Option<Caps> {
        unsafe {
            from_glib_full(ffi::gst_device_get_caps(self.to_glib_none().0))
        }
    }
85

86
    fn get_device_class(&self) -> String {
87 88 89 90 91
        unsafe {
            from_glib_full(ffi::gst_device_get_device_class(self.to_glib_none().0))
        }
    }

92
    fn get_display_name(&self) -> String {
93 94 95 96 97
        unsafe {
            from_glib_full(ffi::gst_device_get_display_name(self.to_glib_none().0))
        }
    }

Sebastian Dröge's avatar
Sebastian Dröge committed
98 99 100 101 102 103
    fn get_properties(&self) -> Option<Structure> {
        unsafe {
            from_glib_full(ffi::gst_device_get_properties(self.to_glib_none().0))
        }
    }

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    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))
        }
    }

122 123
    fn get_property_caps(&self) -> Option<Caps> {
        unsafe {
124 125
            let mut value = Value::uninitialized();
            gobject_ffi::g_value_init(value.to_glib_none_mut().0, <Caps as StaticType>::static_type().to_glib());
126
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "caps".to_glib_none().0, value.to_glib_none_mut().0);
127
            value.get()
128 129 130 131 132
        }
    }

    fn get_property_device_class(&self) -> Option<String> {
        unsafe {
133 134
            let mut value = Value::uninitialized();
            gobject_ffi::g_value_init(value.to_glib_none_mut().0, <String as StaticType>::static_type().to_glib());
135
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "device-class".to_glib_none().0, value.to_glib_none_mut().0);
136
            value.get()
137 138 139 140 141
        }
    }

    fn get_property_display_name(&self) -> Option<String> {
        unsafe {
142 143
            let mut value = Value::uninitialized();
            gobject_ffi::g_value_init(value.to_glib_none_mut().0, <String as StaticType>::static_type().to_glib());
144
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "display-name".to_glib_none().0, value.to_glib_none_mut().0);
145
            value.get()
146 147 148 149 150
        }
    }

    fn get_property_properties(&self) -> Option<Structure> {
        unsafe {
151 152
            let mut value = Value::uninitialized();
            gobject_ffi::g_value_init(value.to_glib_none_mut().0, <Structure as StaticType>::static_type().to_glib());
153
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "properties".to_glib_none().0, value.to_glib_none_mut().0);
154
            value.get()
155 156 157
        }
    }

158
    fn connect_removed<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
159 160 161 162 163 164
        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 _)
        }
    }
165

166
    fn connect_property_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
167 168 169 170 171 172 173
        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 _)
        }
    }

174
    fn connect_property_device_class_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
175 176 177 178 179 180 181
        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 _)
        }
    }

182
    fn connect_property_display_name_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
183 184 185 186 187 188 189
        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 _)
        }
    }

190
    fn connect_property_properties_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
191 192 193 194 195 196
        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 _)
        }
    }
197 198 199 200 201
}

unsafe extern "C" fn removed_trampoline<P>(this: *mut ffi::GstDevice, f: glib_ffi::gpointer)
where P: IsA<Device> {
    callback_guard!();
202
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
203
    f(&Device::from_glib_borrow(this).downcast_unchecked())
204
}
205 206 207 208 209

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> {
    callback_guard!();
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
210
    f(&Device::from_glib_borrow(this).downcast_unchecked())
211 212 213 214 215 216
}

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> {
    callback_guard!();
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
217
    f(&Device::from_glib_borrow(this).downcast_unchecked())
218 219 220 221 222 223
}

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> {
    callback_guard!();
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
224
    f(&Device::from_glib_borrow(this).downcast_unchecked())
225 226 227 228 229 230
}

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