app_sink.rs 11.9 KB
Newer Older
1 2
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
3 4
// DO NOT EDIT

Sebastian Dröge's avatar
Sebastian Dröge committed
5
use glib::object::ObjectType as ObjectType_;
6
use glib::signal::connect_raw;
7
use glib::signal::SignalHandlerId;
8
use glib::translate::*;
9 10
use glib::StaticType;
use glib::Value;
11 12
use glib_sys;
use gobject_sys;
13
use gst;
14
use gst_app_sys;
15
use gst_base;
16 17 18 19
use std::boxed::Box as Box_;
use std::mem::transmute;

glib_wrapper! {
20
    pub struct AppSink(Object<gst_app_sys::GstAppSink, gst_app_sys::GstAppSinkClass, AppSinkClass>) @extends gst_base::BaseSink, gst::Element, gst::Object, @implements gst::URIHandler;
21 22

    match fn {
23
        get_type => || gst_app_sys::gst_app_sink_get_type(),
24 25 26
    }
}

27
impl AppSink {
Sebastian Dröge's avatar
Sebastian Dröge committed
28
    #[cfg(any(feature = "v1_12", feature = "dox"))]
29
    pub fn get_buffer_list_support(&self) -> bool {
30
        unsafe {
31 32 33
            from_glib(gst_app_sys::gst_app_sink_get_buffer_list_support(
                self.to_glib_none().0,
            ))
34 35 36
        }
    }

37
    pub fn get_caps(&self) -> Option<gst::Caps> {
38
        unsafe { from_glib_full(gst_app_sys::gst_app_sink_get_caps(self.to_glib_none().0)) }
39 40
    }

41
    pub fn get_drop(&self) -> bool {
42
        unsafe { from_glib(gst_app_sys::gst_app_sink_get_drop(self.to_glib_none().0)) }
43 44
    }

45
    pub fn get_emit_signals(&self) -> bool {
46
        unsafe {
47 48 49
            from_glib(gst_app_sys::gst_app_sink_get_emit_signals(
                self.to_glib_none().0,
            ))
50 51 52
        }
    }

53
    pub fn get_max_buffers(&self) -> u32 {
54
        unsafe { gst_app_sys::gst_app_sink_get_max_buffers(self.to_glib_none().0) }
55 56
    }

57
    pub fn get_wait_on_eos(&self) -> bool {
58
        unsafe {
59 60 61
            from_glib(gst_app_sys::gst_app_sink_get_wait_on_eos(
                self.to_glib_none().0,
            ))
62 63 64
        }
    }

65
    pub fn is_eos(&self) -> bool {
66
        unsafe { from_glib(gst_app_sys::gst_app_sink_is_eos(self.to_glib_none().0)) }
67 68
    }

69
    pub fn pull_preroll(&self) -> Option<gst::Sample> {
70
        unsafe {
71 72 73
            from_glib_full(gst_app_sys::gst_app_sink_pull_preroll(
                self.to_glib_none().0,
            ))
74 75 76
        }
    }

77
    pub fn pull_sample(&self) -> Option<gst::Sample> {
78
        unsafe { from_glib_full(gst_app_sys::gst_app_sink_pull_sample(self.to_glib_none().0)) }
79 80
    }

Sebastian Dröge's avatar
Sebastian Dröge committed
81
    #[cfg(any(feature = "v1_12", feature = "dox"))]
82
    pub fn set_buffer_list_support(&self, enable_lists: bool) {
83
        unsafe {
84 85 86 87
            gst_app_sys::gst_app_sink_set_buffer_list_support(
                self.to_glib_none().0,
                enable_lists.to_glib(),
            );
88 89 90
        }
    }

Sebastian Dröge's avatar
Sebastian Dröge committed
91
    //pub fn set_callbacks(&self, callbacks: /*Ignored*/&mut AppSinkCallbacks, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) {
92
    //    unsafe { TODO: call gst_app_sys:gst_app_sink_set_callbacks() }
93 94
    //}

95
    pub fn set_caps(&self, caps: Option<&gst::Caps>) {
96
        unsafe {
97
            gst_app_sys::gst_app_sink_set_caps(self.to_glib_none().0, caps.to_glib_none().0);
98 99 100
        }
    }

101
    pub fn set_drop(&self, drop: bool) {
102
        unsafe {
103
            gst_app_sys::gst_app_sink_set_drop(self.to_glib_none().0, drop.to_glib());
104 105 106
        }
    }

107
    pub fn set_emit_signals(&self, emit: bool) {
108
        unsafe {
109
            gst_app_sys::gst_app_sink_set_emit_signals(self.to_glib_none().0, emit.to_glib());
110 111 112
        }
    }

113
    pub fn set_max_buffers(&self, max: u32) {
114
        unsafe {
115
            gst_app_sys::gst_app_sink_set_max_buffers(self.to_glib_none().0, max);
116 117 118
        }
    }

119
    pub fn set_wait_on_eos(&self, wait: bool) {
120
        unsafe {
121
            gst_app_sys::gst_app_sink_set_wait_on_eos(self.to_glib_none().0, wait.to_glib());
122 123 124
        }
    }

Sebastian Dröge's avatar
Sebastian Dröge committed
125
    #[cfg(any(feature = "v1_10", feature = "dox"))]
126
    pub fn try_pull_preroll(&self, timeout: gst::ClockTime) -> Option<gst::Sample> {
127
        unsafe {
128 129 130 131
            from_glib_full(gst_app_sys::gst_app_sink_try_pull_preroll(
                self.to_glib_none().0,
                timeout.to_glib(),
            ))
132 133 134
        }
    }

Sebastian Dröge's avatar
Sebastian Dröge committed
135
    #[cfg(any(feature = "v1_10", feature = "dox"))]
136
    pub fn try_pull_sample(&self, timeout: gst::ClockTime) -> Option<gst::Sample> {
137
        unsafe {
138 139 140 141
            from_glib_full(gst_app_sys::gst_app_sink_try_pull_sample(
                self.to_glib_none().0,
                timeout.to_glib(),
            ))
142 143 144
        }
    }

145 146
    pub fn get_property_buffer_list(&self) -> bool {
        unsafe {
147
            let mut value = Value::from_type(<bool as StaticType>::static_type());
148 149 150 151 152
            gobject_sys::g_object_get_property(
                self.as_ptr() as *mut gobject_sys::GObject,
                b"buffer-list\0".as_ptr() as *const _,
                value.to_glib_none_mut().0,
            );
François Laignel's avatar
Regen  
François Laignel committed
153 154 155 156
            value
                .get()
                .expect("Return Value for property `buffer-list` getter")
                .unwrap()
157 158 159 160 161
        }
    }

    pub fn set_property_buffer_list(&self, buffer_list: bool) {
        unsafe {
162 163 164 165 166
            gobject_sys::g_object_set_property(
                self.as_ptr() as *mut gobject_sys::GObject,
                b"buffer-list\0".as_ptr() as *const _,
                Value::from(&buffer_list).to_glib_none().0,
            );
167 168 169 170 171
        }
    }

    pub fn get_property_eos(&self) -> bool {
        unsafe {
172
            let mut value = Value::from_type(<bool as StaticType>::static_type());
173 174 175 176 177
            gobject_sys::g_object_get_property(
                self.as_ptr() as *mut gobject_sys::GObject,
                b"eos\0".as_ptr() as *const _,
                value.to_glib_none_mut().0,
            );
François Laignel's avatar
Regen  
François Laignel committed
178 179 180 181
            value
                .get()
                .expect("Return Value for property `eos` getter")
                .unwrap()
182 183 184
        }
    }

185
    pub fn connect_eos<F: Fn(&AppSink) + Send + 'static>(&self, f: F) -> SignalHandlerId {
186 187 188 189
        unsafe extern "C" fn eos_trampoline<F: Fn(&AppSink) + Send + 'static>(
            this: *mut gst_app_sys::GstAppSink,
            f: glib_sys::gpointer,
        ) {
Sebastian Dröge's avatar
Sebastian Dröge committed
190 191 192
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
193
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
194
            let f: Box_<F> = Box_::new(f);
195 196 197 198 199 200
            connect_raw(
                self.as_ptr() as *mut _,
                b"eos\0".as_ptr() as *const _,
                Some(transmute(eos_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
201 202 203
        }
    }

204 205 206 207 208 209 210 211 212 213 214
    pub fn connect_property_buffer_list_notify<F: Fn(&AppSink) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_buffer_list_trampoline<
            F: Fn(&AppSink) + Send + Sync + 'static,
        >(
            this: *mut gst_app_sys::GstAppSink,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
Sebastian Dröge's avatar
Sebastian Dröge committed
215 216 217
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
218
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
219
            let f: Box_<F> = Box_::new(f);
220 221 222 223 224 225
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::buffer-list\0".as_ptr() as *const _,
                Some(transmute(notify_buffer_list_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
226 227 228
        }
    }

229 230 231 232 233 234 235 236 237
    pub fn connect_property_caps_notify<F: Fn(&AppSink) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_caps_trampoline<F: Fn(&AppSink) + Send + Sync + 'static>(
            this: *mut gst_app_sys::GstAppSink,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
Sebastian Dröge's avatar
Sebastian Dröge committed
238 239 240
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
241
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
242
            let f: Box_<F> = Box_::new(f);
243 244 245 246 247 248
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::caps\0".as_ptr() as *const _,
                Some(transmute(notify_caps_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
249 250 251
        }
    }

252 253 254 255 256 257 258 259 260
    pub fn connect_property_drop_notify<F: Fn(&AppSink) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_drop_trampoline<F: Fn(&AppSink) + Send + Sync + 'static>(
            this: *mut gst_app_sys::GstAppSink,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
Sebastian Dröge's avatar
Sebastian Dröge committed
261 262 263
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
264
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
265
            let f: Box_<F> = Box_::new(f);
266 267 268 269 270 271
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::drop\0".as_ptr() as *const _,
                Some(transmute(notify_drop_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
272 273 274
        }
    }

275 276 277 278 279 280 281 282 283 284 285
    pub fn connect_property_emit_signals_notify<F: Fn(&AppSink) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_emit_signals_trampoline<
            F: Fn(&AppSink) + Send + Sync + 'static,
        >(
            this: *mut gst_app_sys::GstAppSink,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
Sebastian Dröge's avatar
Sebastian Dröge committed
286 287 288
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
289
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
290
            let f: Box_<F> = Box_::new(f);
291 292 293 294 295 296
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::emit-signals\0".as_ptr() as *const _,
                Some(transmute(notify_emit_signals_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
297 298 299
        }
    }

300 301 302 303 304 305 306 307 308
    pub fn connect_property_eos_notify<F: Fn(&AppSink) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_eos_trampoline<F: Fn(&AppSink) + Send + Sync + 'static>(
            this: *mut gst_app_sys::GstAppSink,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
Sebastian Dröge's avatar
Sebastian Dröge committed
309 310 311
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
312
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
313
            let f: Box_<F> = Box_::new(f);
314 315 316 317 318 319
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::eos\0".as_ptr() as *const _,
                Some(transmute(notify_eos_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
320 321 322
        }
    }

323 324 325 326 327 328 329 330 331 332 333
    pub fn connect_property_max_buffers_notify<F: Fn(&AppSink) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_max_buffers_trampoline<
            F: Fn(&AppSink) + Send + Sync + 'static,
        >(
            this: *mut gst_app_sys::GstAppSink,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
Sebastian Dröge's avatar
Sebastian Dröge committed
334 335 336
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
337
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
338
            let f: Box_<F> = Box_::new(f);
339 340 341 342 343 344
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::max-buffers\0".as_ptr() as *const _,
                Some(transmute(notify_max_buffers_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
345 346 347
        }
    }

348 349 350 351 352 353 354 355 356 357 358
    pub fn connect_property_wait_on_eos_notify<F: Fn(&AppSink) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_wait_on_eos_trampoline<
            F: Fn(&AppSink) + Send + Sync + 'static,
        >(
            this: *mut gst_app_sys::GstAppSink,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) {
Sebastian Dröge's avatar
Sebastian Dröge committed
359 360 361
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
362
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
363
            let f: Box_<F> = Box_::new(f);
364 365 366 367 368 369
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::wait-on-eos\0".as_ptr() as *const _,
                Some(transmute(notify_wait_on_eos_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
370 371
        }
    }
372 373
}

374 375
unsafe impl Send for AppSink {}
unsafe impl Sync for AppSink {}