track.rs 9.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use Timeline;
use TrackElement;
use TrackType;
use ffi;
use glib;
use glib::StaticType;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
15
use glib::signal::connect_raw;
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use std::boxed::Box as Box_;
use std::mem::transmute;

glib_wrapper! {
    pub struct Track(Object<ffi::GESTrack, ffi::GESTrackClass>): [
        gst::Element => gst_ffi::GstElement,
        gst::Object => gst_ffi::GstObject,
    ];

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

impl Track {
    pub fn new(type_: TrackType, caps: &gst::Caps) -> Track {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_none(ffi::ges_track_new(type_.to_glib(), caps.to_glib_full()))
        }
    }
}

44
pub trait GESTrackExt: 'static {
45
    fn add_element<P: IsA<TrackElement>>(&self, object: &P) -> Result<(), glib::error::BoolError>;
46 47 48 49 50 51 52 53 54 55 56

    fn commit(&self) -> bool;

    fn get_caps(&self) -> Option<gst::Caps>;

    fn get_elements(&self) -> Vec<TrackElement>;

    fn get_mixing(&self) -> bool;

    fn get_timeline(&self) -> Option<Timeline>;

57
    fn remove_element<P: IsA<TrackElement>>(&self, object: &P) -> Result<(), glib::error::BoolError>;
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

    //fn set_create_element_for_gap_func(&self, func: /*Unknown conversion*//*Unimplemented*/CreateElementForGapFunc);

    fn set_mixing(&self, mixing: bool);

    fn set_restriction_caps(&self, caps: &gst::Caps);

    fn set_timeline(&self, timeline: &Timeline);

    fn update_restriction_caps(&self, caps: &gst::Caps);

    fn get_property_duration(&self) -> u64;

    fn get_property_restriction_caps(&self) -> Option<gst::Caps>;

    fn get_property_track_type(&self) -> TrackType;

    fn connect_commited<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_track_element_added<F: Fn(&Self, &TrackElement) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_track_element_removed<F: Fn(&Self, &TrackElement) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_mixing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_restriction_caps_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

88
impl<O: IsA<Track>> GESTrackExt for O {
89
    fn add_element<P: IsA<TrackElement>>(&self, object: &P) -> Result<(), glib::error::BoolError> {
90
        unsafe {
François Laignel's avatar
François Laignel committed
91
            glib_result_from_gboolean!(ffi::ges_track_add_element(self.to_glib_none().0, object.to_glib_none().0), "Failed to add element")
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 118 119 120 121 122 123 124
        }
    }

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

    fn get_caps(&self) -> Option<gst::Caps> {
        unsafe {
            from_glib_none(ffi::ges_track_get_caps(self.to_glib_none().0))
        }
    }

    fn get_elements(&self) -> Vec<TrackElement> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_track_get_elements(self.to_glib_none().0))
        }
    }

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

    fn get_timeline(&self) -> Option<Timeline> {
        unsafe {
            from_glib_none(ffi::ges_track_get_timeline(self.to_glib_none().0))
        }
    }

125
    fn remove_element<P: IsA<TrackElement>>(&self, object: &P) -> Result<(), glib::error::BoolError> {
126
        unsafe {
François Laignel's avatar
François Laignel committed
127
            glib_result_from_gboolean!(ffi::ges_track_remove_element(self.to_glib_none().0, object.to_glib_none().0), "Failed to remove element")
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
        }
    }

    //fn set_create_element_for_gap_func(&self, func: /*Unknown conversion*//*Unimplemented*/CreateElementForGapFunc) {
    //    unsafe { TODO: call ffi::ges_track_set_create_element_for_gap_func() }
    //}

    fn set_mixing(&self, mixing: bool) {
        unsafe {
            ffi::ges_track_set_mixing(self.to_glib_none().0, mixing.to_glib());
        }
    }

    fn set_restriction_caps(&self, caps: &gst::Caps) {
        unsafe {
            ffi::ges_track_set_restriction_caps(self.to_glib_none().0, caps.to_glib_none().0);
        }
    }

    fn set_timeline(&self, timeline: &Timeline) {
        unsafe {
            ffi::ges_track_set_timeline(self.to_glib_none().0, timeline.to_glib_none().0);
        }
    }

    fn update_restriction_caps(&self, caps: &gst::Caps) {
        unsafe {
            ffi::ges_track_update_restriction_caps(self.to_glib_none().0, caps.to_glib_none().0);
        }
    }

    fn get_property_duration(&self) -> u64 {
        unsafe {
            let mut value = Value::from_type(<u64 as StaticType>::static_type());
162
            gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"duration\0".as_ptr() as *const _, value.to_glib_none_mut().0);
163 164 165 166 167 168 169
            value.get().unwrap()
        }
    }

    fn get_property_restriction_caps(&self) -> Option<gst::Caps> {
        unsafe {
            let mut value = Value::from_type(<gst::Caps as StaticType>::static_type());
170
            gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"restriction-caps\0".as_ptr() as *const _, value.to_glib_none_mut().0);
171 172 173 174 175 176 177
            value.get()
        }
    }

    fn get_property_track_type(&self) -> TrackType {
        unsafe {
            let mut value = Value::from_type(<TrackType as StaticType>::static_type());
178
            gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"track-type\0".as_ptr() as *const _, value.to_glib_none_mut().0);
179 180 181 182 183 184 185
            value.get().unwrap()
        }
    }

    fn connect_commited<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
186
            connect_raw(self.to_glib_none().0 as *mut _, b"commited\0".as_ptr() as *const _,
187 188 189 190 191 192 193
                transmute(commited_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_track_element_added<F: Fn(&Self, &TrackElement) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TrackElement) + 'static>> = Box_::new(Box_::new(f));
194
            connect_raw(self.to_glib_none().0 as *mut _, b"track-element-added\0".as_ptr() as *const _,
195 196 197 198 199 200 201
                transmute(track_element_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_track_element_removed<F: Fn(&Self, &TrackElement) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TrackElement) + 'static>> = Box_::new(Box_::new(f));
202
            connect_raw(self.to_glib_none().0 as *mut _, b"track-element-removed\0".as_ptr() as *const _,
203 204 205 206 207 208 209
                transmute(track_element_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_duration_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
210
            connect_raw(self.to_glib_none().0 as *mut _, b"notify::duration\0".as_ptr() as *const _,
211 212 213 214 215 216 217
                transmute(notify_duration_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_mixing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
218
            connect_raw(self.to_glib_none().0 as *mut _, b"notify::mixing\0".as_ptr() as *const _,
219 220 221 222 223 224 225
                transmute(notify_mixing_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_restriction_caps_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
226
            connect_raw(self.to_glib_none().0 as *mut _, b"notify::restriction-caps\0".as_ptr() as *const _,
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
                transmute(notify_restriction_caps_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn commited_trampoline<P>(this: *mut ffi::GESTrack, f: glib_ffi::gpointer)
where P: IsA<Track> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&Track::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn track_element_added_trampoline<P>(this: *mut ffi::GESTrack, effect: *mut ffi::GESTrackElement, f: glib_ffi::gpointer)
where P: IsA<Track> {
    let f: &&(Fn(&P, &TrackElement) + 'static) = transmute(f);
    f(&Track::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(effect))
}

unsafe extern "C" fn track_element_removed_trampoline<P>(this: *mut ffi::GESTrack, effect: *mut ffi::GESTrackElement, f: glib_ffi::gpointer)
where P: IsA<Track> {
    let f: &&(Fn(&P, &TrackElement) + 'static) = transmute(f);
    f(&Track::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(effect))
}

unsafe extern "C" fn notify_duration_trampoline<P>(this: *mut ffi::GESTrack, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Track> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&Track::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_mixing_trampoline<P>(this: *mut ffi::GESTrack, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Track> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&Track::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_restriction_caps_trampoline<P>(this: *mut ffi::GESTrack, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Track> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&Track::from_glib_borrow(this).downcast_unchecked())
}