app_sink.rs 11.3 KB
Newer Older
1
// This file was generated by gir (94e079d) from gir-files (???)
2 3 4
// DO NOT EDIT

use ffi;
5
use glib::Value;
6
use glib::signal::SignalHandlerId;
7 8 9 10 11
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
12 13
use gst_base;
use gst_base_ffi;
14 15 16 17 18 19 20
use gst_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
21
    pub struct AppSink(Object<ffi::GstAppSink>): [
22
        gst_base::BaseSink => gst_base_ffi::GstBaseSink,
23 24
        gst::Element => gst_ffi::GstElement,
        gst::Object => gst_ffi::GstObject,
25
        gst::URIHandler => gst_ffi::GstURIHandler,
26
    ];
27 28 29 30 31 32

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

33
impl AppSink {
34
    #[cfg(any(feature = "v1_12", feature = "dox"))]
35
    pub fn get_buffer_list_support(&self) -> bool {
36 37 38 39 40
        unsafe {
            from_glib(ffi::gst_app_sink_get_buffer_list_support(self.to_glib_none().0))
        }
    }

41
    pub fn get_caps(&self) -> Option<gst::Caps> {
42 43 44 45 46
        unsafe {
            from_glib_full(ffi::gst_app_sink_get_caps(self.to_glib_none().0))
        }
    }

47
    pub fn get_drop(&self) -> bool {
48 49 50 51 52
        unsafe {
            from_glib(ffi::gst_app_sink_get_drop(self.to_glib_none().0))
        }
    }

53
    pub fn get_emit_signals(&self) -> bool {
54 55 56 57 58
        unsafe {
            from_glib(ffi::gst_app_sink_get_emit_signals(self.to_glib_none().0))
        }
    }

59
    pub fn get_max_buffers(&self) -> u32 {
60 61 62 63 64
        unsafe {
            ffi::gst_app_sink_get_max_buffers(self.to_glib_none().0)
        }
    }

65
    pub fn get_wait_on_eos(&self) -> bool {
66 67 68 69 70
        unsafe {
            from_glib(ffi::gst_app_sink_get_wait_on_eos(self.to_glib_none().0))
        }
    }

71
    pub fn is_eos(&self) -> bool {
72 73 74 75 76
        unsafe {
            from_glib(ffi::gst_app_sink_is_eos(self.to_glib_none().0))
        }
    }

77
    pub fn pull_preroll(&self) -> Option<gst::Sample> {
78 79 80 81 82
        unsafe {
            from_glib_full(ffi::gst_app_sink_pull_preroll(self.to_glib_none().0))
        }
    }

83
    pub fn pull_sample(&self) -> Option<gst::Sample> {
84 85 86 87 88
        unsafe {
            from_glib_full(ffi::gst_app_sink_pull_sample(self.to_glib_none().0))
        }
    }

89
    #[cfg(any(feature = "v1_12", feature = "dox"))]
90
    pub fn set_buffer_list_support(&self, enable_lists: bool) {
91 92 93 94 95
        unsafe {
            ffi::gst_app_sink_set_buffer_list_support(self.to_glib_none().0, enable_lists.to_glib());
        }
    }

96
    //pub fn set_callbacks<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, callbacks: /*Ignored*/&mut AppSinkCallbacks, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) {
97 98 99
    //    unsafe { TODO: call ffi::gst_app_sink_set_callbacks() }
    //}

100
    pub fn set_caps(&self, caps: &gst::Caps) {
101 102 103 104 105
        unsafe {
            ffi::gst_app_sink_set_caps(self.to_glib_none().0, caps.to_glib_none().0);
        }
    }

106
    pub fn set_drop(&self, drop: bool) {
107 108 109 110 111
        unsafe {
            ffi::gst_app_sink_set_drop(self.to_glib_none().0, drop.to_glib());
        }
    }

112
    pub fn set_emit_signals(&self, emit: bool) {
113 114 115 116 117
        unsafe {
            ffi::gst_app_sink_set_emit_signals(self.to_glib_none().0, emit.to_glib());
        }
    }

118
    pub fn set_max_buffers(&self, max: u32) {
119 120 121 122 123
        unsafe {
            ffi::gst_app_sink_set_max_buffers(self.to_glib_none().0, max);
        }
    }

124
    pub fn set_wait_on_eos(&self, wait: bool) {
125 126 127 128 129
        unsafe {
            ffi::gst_app_sink_set_wait_on_eos(self.to_glib_none().0, wait.to_glib());
        }
    }

130
    #[cfg(any(feature = "v1_10", feature = "dox"))]
131
    pub fn try_pull_preroll(&self, timeout: gst::ClockTime) -> Option<gst::Sample> {
132 133 134 135 136
        unsafe {
            from_glib_full(ffi::gst_app_sink_try_pull_preroll(self.to_glib_none().0, timeout))
        }
    }

137
    #[cfg(any(feature = "v1_10", feature = "dox"))]
138
    pub fn try_pull_sample(&self, timeout: gst::ClockTime) -> Option<gst::Sample> {
139 140 141 142 143
        unsafe {
            from_glib_full(ffi::gst_app_sink_try_pull_sample(self.to_glib_none().0, timeout))
        }
    }

144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
    pub fn get_property_buffer_list(&self) -> bool {
        let mut value = Value::from(&false);
        unsafe {
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "buffer-list".to_glib_none().0, value.to_glib_none_mut().0);
        }
        value.get().unwrap()
    }

    pub fn set_property_buffer_list(&self, buffer_list: bool) {
        unsafe {
            gobject_ffi::g_object_set_property(self.to_glib_none().0, "buffer-list".to_glib_none().0, Value::from(&buffer_list).to_glib_none().0);
        }
    }

    pub fn get_property_eos(&self) -> bool {
        let mut value = Value::from(&false);
        unsafe {
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "eos".to_glib_none().0, value.to_glib_none_mut().0);
        }
        value.get().unwrap()
    }

166
    pub fn connect_eos<F: Fn(&AppSink) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
167
        unsafe {
168
            let f: Box_<Box_<Fn(&AppSink) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
169
            connect(self.to_glib_none().0, "eos",
170
                transmute(eos_trampoline as usize), Box_::into_raw(f) as *mut _)
171 172 173
        }
    }

174
    pub fn connect_new_preroll<F: Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
175
        unsafe {
176
            let f: Box_<Box_<Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static>> = Box_::new(Box_::new(f));
177
            connect(self.to_glib_none().0, "new-preroll",
178
                transmute(new_preroll_trampoline as usize), Box_::into_raw(f) as *mut _)
179 180 181
        }
    }

182
    pub fn connect_new_sample<F: Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
183
        unsafe {
184
            let f: Box_<Box_<Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static>> = Box_::new(Box_::new(f));
185
            connect(self.to_glib_none().0, "new-sample",
186
                transmute(new_sample_trampoline as usize), Box_::into_raw(f) as *mut _)
187 188
        }
    }
189

190
    pub fn connect_property_buffer_list_notify<F: Fn(&AppSink) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
191 192 193 194 195 196 197
        unsafe {
            let f: Box_<Box_<Fn(&AppSink) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::buffer-list",
                transmute(notify_buffer_list_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

198
    pub fn connect_property_caps_notify<F: Fn(&AppSink) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
199 200 201 202 203 204 205
        unsafe {
            let f: Box_<Box_<Fn(&AppSink) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::caps",
                transmute(notify_caps_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

206
    pub fn connect_property_drop_notify<F: Fn(&AppSink) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
207 208 209 210 211 212 213
        unsafe {
            let f: Box_<Box_<Fn(&AppSink) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::drop",
                transmute(notify_drop_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

214
    pub fn connect_property_emit_signals_notify<F: Fn(&AppSink) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
215 216 217 218 219 220 221
        unsafe {
            let f: Box_<Box_<Fn(&AppSink) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::emit-signals",
                transmute(notify_emit_signals_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

222
    pub fn connect_property_eos_notify<F: Fn(&AppSink) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
223 224 225 226 227 228 229
        unsafe {
            let f: Box_<Box_<Fn(&AppSink) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::eos",
                transmute(notify_eos_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

230
    pub fn connect_property_max_buffers_notify<F: Fn(&AppSink) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
231 232 233 234 235 236 237
        unsafe {
            let f: Box_<Box_<Fn(&AppSink) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::max-buffers",
                transmute(notify_max_buffers_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }

238
    pub fn connect_property_wait_on_eos_notify<F: Fn(&AppSink) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
239 240 241 242 243 244
        unsafe {
            let f: Box_<Box_<Fn(&AppSink) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::wait-on-eos",
                transmute(notify_wait_on_eos_trampoline as usize), Box_::into_raw(f) as *mut _)
        }
    }
245 246
}

247 248 249 250
unsafe impl Send for AppSink {}
unsafe impl Sync for AppSink {}

unsafe extern "C" fn eos_trampoline(this: *mut ffi::GstAppSink, f: glib_ffi::gpointer) {
251
    callback_guard!();
252
    let f: &&(Fn(&AppSink) + Send + Sync + 'static) = transmute(f);
253
    f(&from_glib_borrow(this))
254 255
}

256
unsafe extern "C" fn new_preroll_trampoline(this: *mut ffi::GstAppSink, f: glib_ffi::gpointer) -> gst_ffi::GstFlowReturn {
257
    callback_guard!();
258
    let f: &&(Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static) = transmute(f);
259
    f(&from_glib_borrow(this)).to_glib()
260 261
}

262
unsafe extern "C" fn new_sample_trampoline(this: *mut ffi::GstAppSink, f: glib_ffi::gpointer) -> gst_ffi::GstFlowReturn {
263
    callback_guard!();
264
    let f: &&(Fn(&AppSink) -> gst::FlowReturn + Send + Sync + 'static) = transmute(f);
265
    f(&from_glib_borrow(this)).to_glib()
266
}
267 268 269 270

unsafe extern "C" fn notify_buffer_list_trampoline(this: *mut ffi::GstAppSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    callback_guard!();
    let f: &&(Fn(&AppSink) + Send + Sync + 'static) = transmute(f);
271
    f(&from_glib_borrow(this))
272 273 274 275 276
}

unsafe extern "C" fn notify_caps_trampoline(this: *mut ffi::GstAppSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    callback_guard!();
    let f: &&(Fn(&AppSink) + Send + Sync + 'static) = transmute(f);
277
    f(&from_glib_borrow(this))
278 279 280 281 282
}

unsafe extern "C" fn notify_drop_trampoline(this: *mut ffi::GstAppSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    callback_guard!();
    let f: &&(Fn(&AppSink) + Send + Sync + 'static) = transmute(f);
283
    f(&from_glib_borrow(this))
284 285 286 287 288
}

unsafe extern "C" fn notify_emit_signals_trampoline(this: *mut ffi::GstAppSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    callback_guard!();
    let f: &&(Fn(&AppSink) + Send + Sync + 'static) = transmute(f);
289
    f(&from_glib_borrow(this))
290 291 292 293 294
}

unsafe extern "C" fn notify_eos_trampoline(this: *mut ffi::GstAppSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    callback_guard!();
    let f: &&(Fn(&AppSink) + Send + Sync + 'static) = transmute(f);
295
    f(&from_glib_borrow(this))
296 297 298 299 300
}

unsafe extern "C" fn notify_max_buffers_trampoline(this: *mut ffi::GstAppSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    callback_guard!();
    let f: &&(Fn(&AppSink) + Send + Sync + 'static) = transmute(f);
301
    f(&from_glib_borrow(this))
302 303 304 305 306
}

unsafe extern "C" fn notify_wait_on_eos_trampoline(this: *mut ffi::GstAppSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
    callback_guard!();
    let f: &&(Fn(&AppSink) + Send + Sync + 'static) = transmute(f);
307
    f(&from_glib_borrow(this))
308
}