test_clock.rs 5.06 KB
Newer Older
1 2 3 4 5 6 7
// 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 ffi;
use glib::StaticType;
use glib::Value;
8 9
use glib::object::Cast;
use glib::object::ObjectType;
10
use glib::signal::SignalHandlerId;
11
use glib::signal::connect_raw;
12 13 14 15 16 17 18 19
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use std::boxed::Box as Box_;
use std::mem::transmute;

glib_wrapper! {
20
    pub struct TestClock(Object<ffi::GstTestClock, ffi::GstTestClockClass, TestClockClass>) @extends gst::Clock, gst::Object;
21 22 23 24 25 26 27 28 29 30

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

impl TestClock {
    pub fn new() -> TestClock {
        assert_initialized_main_thread!();
        unsafe {
31
            gst::Clock::from_glib_full(ffi::gst_test_clock_new()).unsafe_cast()
32 33 34 35 36 37
        }
    }

    pub fn new_with_start_time(start_time: gst::ClockTime) -> TestClock {
        assert_initialized_main_thread!();
        unsafe {
38
            gst::Clock::from_glib_full(ffi::gst_test_clock_new_with_start_time(start_time.to_glib())).unsafe_cast()
39 40 41
        }
    }

42
    pub fn advance_time(&self, delta: gst::ClockTimeDiff) {
43 44 45 46 47
        unsafe {
            ffi::gst_test_clock_advance_time(self.to_glib_none().0, delta);
        }
    }

48
    pub fn crank(&self) -> bool {
49 50 51 52 53
        unsafe {
            from_glib(ffi::gst_test_clock_crank(self.to_glib_none().0))
        }
    }

54
    pub fn get_next_entry_time(&self) -> gst::ClockTime {
55 56 57 58 59
        unsafe {
            from_glib(ffi::gst_test_clock_get_next_entry_time(self.to_glib_none().0))
        }
    }

60
    //pub fn has_id(&self, id: /*Ignored*/gst::ClockID) -> bool {
61 62 63
    //    unsafe { TODO: call ffi::gst_test_clock_has_id() }
    //}

64
    pub fn peek_id_count(&self) -> u32 {
65 66 67 68 69
        unsafe {
            ffi::gst_test_clock_peek_id_count(self.to_glib_none().0)
        }
    }

70
    //pub fn peek_next_pending_id(&self, pending_id: /*Ignored*/&mut gst::ClockID) -> bool {
71 72 73
    //    unsafe { TODO: call ffi::gst_test_clock_peek_next_pending_id() }
    //}

74
    //pub fn process_id_list(&self, pending_list: /*Ignored*/&[&gst::ClockID]) -> u32 {
75 76 77
    //    unsafe { TODO: call ffi::gst_test_clock_process_id_list() }
    //}

78
    //pub fn process_next_clock_id(&self) -> /*Ignored*/Option<gst::ClockID> {
79 80 81
    //    unsafe { TODO: call ffi::gst_test_clock_process_next_clock_id() }
    //}

82
    pub fn set_time(&self, new_time: gst::ClockTime) {
83 84 85 86 87
        unsafe {
            ffi::gst_test_clock_set_time(self.to_glib_none().0, new_time.to_glib());
        }
    }

88
    //pub fn wait_for_multiple_pending_ids(&self, count: u32, pending_list: /*Unimplemented*/Vec<gst::ClockID>) {
89 90 91
    //    unsafe { TODO: call ffi::gst_test_clock_wait_for_multiple_pending_ids() }
    //}

92
    //pub fn wait_for_next_pending_id(&self, pending_id: /*Ignored*/&mut gst::ClockID) {
93 94 95
    //    unsafe { TODO: call ffi::gst_test_clock_wait_for_next_pending_id() }
    //}

96
    pub fn wait_for_pending_id_count(&self, count: u32) {
97 98 99 100 101
        unsafe {
            ffi::gst_test_clock_wait_for_pending_id_count(self.to_glib_none().0, count);
        }
    }

102
    pub fn get_property_clock_type(&self) -> gst::ClockType {
103 104
        unsafe {
            let mut value = Value::from_type(<gst::ClockType as StaticType>::static_type());
105
            gobject_ffi::g_object_get_property(self.as_ptr() as *mut gobject_ffi::GObject, b"clock-type\0".as_ptr() as *const _, value.to_glib_none_mut().0);
106 107 108 109
            value.get().unwrap()
        }
    }

110
    pub fn set_property_clock_type(&self, clock_type: gst::ClockType) {
111
        unsafe {
112
            gobject_ffi::g_object_set_property(self.as_ptr() as *mut gobject_ffi::GObject, b"clock-type\0".as_ptr() as *const _, Value::from(&clock_type).to_glib_none().0);
113 114 115
        }
    }

116
    pub fn get_property_start_time(&self) -> u64 {
117 118
        unsafe {
            let mut value = Value::from_type(<u64 as StaticType>::static_type());
119
            gobject_ffi::g_object_get_property(self.as_ptr() as *mut gobject_ffi::GObject, b"start-time\0".as_ptr() as *const _, value.to_glib_none_mut().0);
120 121 122 123
            value.get().unwrap()
        }
    }

124 125 126 127 128
    //pub fn id_list_get_latest_time(pending_list: /*Ignored*/&[&gst::ClockID]) -> gst::ClockTime {
    //    unsafe { TODO: call ffi::gst_test_clock_id_list_get_latest_time() }
    //}

    pub fn connect_property_clock_type_notify<F: Fn(&TestClock) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
129
        unsafe {
130
            let f: Box_<Box_<Fn(&TestClock) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
131
            connect_raw(self.as_ptr() as *mut _, b"notify::clock-type\0".as_ptr() as *const _,
132
                transmute(notify_clock_type_trampoline as usize), Box_::into_raw(f) as *mut _)
133 134 135 136
        }
    }
}

137 138 139 140 141 142 143 144 145 146 147 148
impl Default for TestClock {
    fn default() -> Self {
        Self::new()
    }
}

unsafe impl Send for TestClock {}
unsafe impl Sync for TestClock {}

unsafe extern "C" fn notify_clock_type_trampoline(this: *mut ffi::GstTestClock, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    let f: &&(Fn(&TestClock) + Send + Sync + 'static) = transmute(f);
    f(&from_glib_borrow(this))
149
}