object.rs 9.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 @ ???)
Sebastian Dröge's avatar
Sebastian Dröge committed
3 4 5 6 7
// DO NOT EDIT

use ClockTime;
use Error;
use ffi;
8
use glib;
9
use glib::object::Downcast;
Sebastian Dröge's avatar
Sebastian Dröge committed
10
use glib::object::IsA;
11
use glib::signal::SignalHandlerId;
12
use glib::signal::connect;
Sebastian Dröge's avatar
Sebastian Dröge committed
13
use glib::translate::*;
14 15
use glib_ffi;
use gobject_ffi;
16
use std::boxed::Box as Box_;
17
use std::mem;
18
use std::mem::transmute;
19
use std::ptr;
Sebastian Dröge's avatar
Sebastian Dröge committed
20 21

glib_wrapper! {
22
    pub struct Object(Object<ffi::GstObject, ffi::GstObjectClass>);
Sebastian Dröge's avatar
Sebastian Dröge committed
23 24 25 26 27 28 29 30

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

impl Object {
    pub fn check_uniqueness(list: &[Object], name: &str) -> bool {
31
        assert_initialized_main_thread!();
Sebastian Dröge's avatar
Sebastian Dröge committed
32 33 34 35 36
        unsafe {
            from_glib(ffi::gst_object_check_uniqueness(list.to_glib_none().0, name.to_glib_none().0))
        }
    }

37
    //pub fn default_deep_notify<P: IsA<glib::Object>, Q: IsA<Object>, R: IsA</*Ignored*/glib::ParamSpec>>(object: &P, orig: &Q, pspec: &R, excluded_props: &[&str]) {
Sebastian Dröge's avatar
Sebastian Dröge committed
38 39 40 41 42 43 44 45 46 47 48 49
    //    unsafe { TODO: call ffi::gst_object_default_deep_notify() }
    //}

    //pub fn ref_sink<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(object: P) -> /*Unimplemented*/Option<Fundamental: Pointer> {
    //    unsafe { TODO: call ffi::gst_object_ref_sink() }
    //}

    //pub fn replace<'a, 'b, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>, R: IsA<Object> + 'b, S: Into<Option<&'b R>>>(oldobj: Q, newobj: S) -> bool {
    //    unsafe { TODO: call ffi::gst_object_replace() }
    //}
}

50 51 52
unsafe impl Send for Object {}
unsafe impl Sync for Object {}

53
pub trait GstObjectExt {
Sebastian Dröge's avatar
Sebastian Dröge committed
54 55 56 57 58 59 60 61
    //fn add_control_binding(&self, binding: /*Ignored*/&ControlBinding) -> bool;

    fn default_error<'a, P: Into<Option<&'a str>>>(&self, error: &Error, debug: P);

    //fn get_control_binding(&self, property_name: &str) -> /*Ignored*/Option<ControlBinding>;

    fn get_control_rate(&self) -> ClockTime;

62
    //fn get_g_value_array(&self, property_name: &str, timestamp: ClockTime, interval: ClockTime, values: /*Ignored*/&[&glib::Value]) -> bool;
Sebastian Dröge's avatar
Sebastian Dröge committed
63

64
    fn get_name(&self) -> String;
Sebastian Dröge's avatar
Sebastian Dröge committed
65 66 67

    fn get_parent(&self) -> Option<Object>;

68
    fn get_path_string(&self) -> String;
Sebastian Dröge's avatar
Sebastian Dröge committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89

    //fn get_value(&self, property_name: &str, timestamp: ClockTime) -> /*Ignored*/Option<glib::Value>;

    //fn get_value_array<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, property_name: &str, timestamp: ClockTime, interval: ClockTime, n_values: u32, values: P) -> bool;

    fn has_active_control_bindings(&self) -> bool;

    fn has_ancestor<P: IsA<Object>>(&self, ancestor: &P) -> bool;

    fn has_as_ancestor<P: IsA<Object>>(&self, ancestor: &P) -> bool;

    fn has_as_parent<P: IsA<Object>>(&self, parent: &P) -> bool;

    //fn remove_control_binding(&self, binding: /*Ignored*/&ControlBinding) -> bool;

    fn set_control_binding_disabled(&self, property_name: &str, disabled: bool);

    fn set_control_bindings_disabled(&self, disabled: bool);

    fn set_control_rate(&self, control_rate: ClockTime);

90
    fn set_name(&self, name: &str) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
91

92
    fn set_parent<P: IsA<Object>>(&self, parent: &P) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
93 94 95

    fn suggest_next_sync(&self) -> ClockTime;

96
    fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError>;
Sebastian Dröge's avatar
Sebastian Dröge committed
97 98 99

    fn unparent(&self);

100
    //fn connect_deep_notify<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId;
101

102
    fn connect_property_name_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
103

104
    fn connect_property_parent_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
Sebastian Dröge's avatar
Sebastian Dröge committed
105 106
}

107
impl<O: IsA<Object> + IsA<glib::object::Object>> GstObjectExt for O {
Sebastian Dröge's avatar
Sebastian Dröge committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
    //fn add_control_binding(&self, binding: /*Ignored*/&ControlBinding) -> bool {
    //    unsafe { TODO: call ffi::gst_object_add_control_binding() }
    //}

    fn default_error<'a, P: Into<Option<&'a str>>>(&self, error: &Error, debug: P) {
        let debug = debug.into();
        let debug = debug.to_glib_none();
        unsafe {
            ffi::gst_object_default_error(self.to_glib_none().0, error.to_glib_none().0, debug.0);
        }
    }

    //fn get_control_binding(&self, property_name: &str) -> /*Ignored*/Option<ControlBinding> {
    //    unsafe { TODO: call ffi::gst_object_get_control_binding() }
    //}

    fn get_control_rate(&self) -> ClockTime {
        unsafe {
126
            from_glib(ffi::gst_object_get_control_rate(self.to_glib_none().0))
Sebastian Dröge's avatar
Sebastian Dröge committed
127 128 129
        }
    }

130
    //fn get_g_value_array(&self, property_name: &str, timestamp: ClockTime, interval: ClockTime, values: /*Ignored*/&[&glib::Value]) -> bool {
Sebastian Dröge's avatar
Sebastian Dröge committed
131 132 133
    //    unsafe { TODO: call ffi::gst_object_get_g_value_array() }
    //}

134
    fn get_name(&self) -> String {
Sebastian Dröge's avatar
Sebastian Dröge committed
135 136 137 138 139 140 141 142 143 144 145
        unsafe {
            from_glib_full(ffi::gst_object_get_name(self.to_glib_none().0))
        }
    }

    fn get_parent(&self) -> Option<Object> {
        unsafe {
            from_glib_full(ffi::gst_object_get_parent(self.to_glib_none().0))
        }
    }

146
    fn get_path_string(&self) -> String {
Sebastian Dröge's avatar
Sebastian Dröge committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
        unsafe {
            from_glib_full(ffi::gst_object_get_path_string(self.to_glib_none().0))
        }
    }

    //fn get_value(&self, property_name: &str, timestamp: ClockTime) -> /*Ignored*/Option<glib::Value> {
    //    unsafe { TODO: call ffi::gst_object_get_value() }
    //}

    //fn get_value_array<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, property_name: &str, timestamp: ClockTime, interval: ClockTime, n_values: u32, values: P) -> bool {
    //    unsafe { TODO: call ffi::gst_object_get_value_array() }
    //}

    fn has_active_control_bindings(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_object_has_active_control_bindings(self.to_glib_none().0))
        }
    }

    fn has_ancestor<P: IsA<Object>>(&self, ancestor: &P) -> bool {
        unsafe {
            from_glib(ffi::gst_object_has_ancestor(self.to_glib_none().0, ancestor.to_glib_none().0))
        }
    }

    fn has_as_ancestor<P: IsA<Object>>(&self, ancestor: &P) -> bool {
        unsafe {
            from_glib(ffi::gst_object_has_as_ancestor(self.to_glib_none().0, ancestor.to_glib_none().0))
        }
    }

    fn has_as_parent<P: IsA<Object>>(&self, parent: &P) -> bool {
        unsafe {
            from_glib(ffi::gst_object_has_as_parent(self.to_glib_none().0, parent.to_glib_none().0))
        }
    }

    //fn remove_control_binding(&self, binding: /*Ignored*/&ControlBinding) -> bool {
    //    unsafe { TODO: call ffi::gst_object_remove_control_binding() }
    //}

    fn set_control_binding_disabled(&self, property_name: &str, disabled: bool) {
        unsafe {
            ffi::gst_object_set_control_binding_disabled(self.to_glib_none().0, property_name.to_glib_none().0, disabled.to_glib());
        }
    }

    fn set_control_bindings_disabled(&self, disabled: bool) {
        unsafe {
            ffi::gst_object_set_control_bindings_disabled(self.to_glib_none().0, disabled.to_glib());
        }
    }

    fn set_control_rate(&self, control_rate: ClockTime) {
        unsafe {
202
            ffi::gst_object_set_control_rate(self.to_glib_none().0, control_rate.to_glib());
Sebastian Dröge's avatar
Sebastian Dröge committed
203 204 205
        }
    }

206
    fn set_name(&self, name: &str) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
207
        unsafe {
208
            glib::error::BoolError::from_glib(ffi::gst_object_set_name(self.to_glib_none().0, name.to_glib_none().0), "Failed to set object name")
Sebastian Dröge's avatar
Sebastian Dröge committed
209 210 211
        }
    }

212
    fn set_parent<P: IsA<Object>>(&self, parent: &P) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
213
        unsafe {
214
            glib::error::BoolError::from_glib(ffi::gst_object_set_parent(self.to_glib_none().0, parent.to_glib_none().0), "Failed to set parent object")
Sebastian Dröge's avatar
Sebastian Dröge committed
215 216 217 218 219
        }
    }

    fn suggest_next_sync(&self) -> ClockTime {
        unsafe {
220
            from_glib(ffi::gst_object_suggest_next_sync(self.to_glib_none().0))
Sebastian Dröge's avatar
Sebastian Dröge committed
221 222 223
        }
    }

224
    fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError> {
Sebastian Dröge's avatar
Sebastian Dröge committed
225
        unsafe {
226
            glib::error::BoolError::from_glib(ffi::gst_object_sync_values(self.to_glib_none().0, timestamp.to_glib()), "Failed to sync values")
Sebastian Dröge's avatar
Sebastian Dröge committed
227 228 229 230 231 232 233 234 235
        }
    }

    fn unparent(&self) {
        unsafe {
            ffi::gst_object_unparent(self.to_glib_none().0);
        }
    }

236
    //fn connect_deep_notify<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
Sebastian Dröge's avatar
Sebastian Dröge committed
237 238
    //    Ignored prop: GObject.ParamSpec
    //}
239

240
    fn connect_property_name_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
241 242 243 244 245 246 247
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::name",
                transmute(notify_name_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

248
    fn connect_property_parent_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
249 250 251 252 253 254 255 256 257 258
        unsafe {
            let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::parent",
                transmute(notify_parent_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn notify_name_trampoline<P>(this: *mut ffi::GstObject, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Object> {
259
    callback_guard!();
260
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
261
    f(&Object::from_glib_borrow(this).downcast_unchecked())
262 263 264 265
}

unsafe extern "C" fn notify_parent_trampoline<P>(this: *mut ffi::GstObject, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Object> {
266
    callback_guard!();
267
    let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
268
    f(&Object::from_glib_borrow(this).downcast_unchecked())
Sebastian Dröge's avatar
Sebastian Dröge committed
269
}