gl_base_filter.rs 2.78 KB
Newer Older
1 2 3 4
// 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

5
use glib::object::Cast;
6
use glib::object::IsA;
7
use glib::signal::connect_raw;
8
use glib::signal::SignalHandlerId;
9
use glib::translate::*;
10 11
use glib::StaticType;
use glib::Value;
12 13
use glib_sys;
use gobject_sys;
14
use gst;
15
use gst_gl_sys;
16 17
use std::boxed::Box as Box_;
use std::mem::transmute;
18
use GLContext;
19 20

glib_wrapper! {
21
    pub struct GLBaseFilter(Object<gst_gl_sys::GstGLBaseFilter, gst_gl_sys::GstGLBaseFilterClass, GLBaseFilterClass>) @extends gst::Object;
22 23

    match fn {
24
        get_type => || gst_gl_sys::gst_gl_base_filter_get_type(),
25 26 27 28 29 30
    }
}

unsafe impl Send for GLBaseFilter {}
unsafe impl Sync for GLBaseFilter {}

31 32
pub const NONE_GL_BASE_FILTER: Option<&GLBaseFilter> = None;

33
pub trait GLBaseFilterExt: 'static {
34 35 36
    #[cfg(any(feature = "v1_16", feature = "dox"))]
    fn find_gl_context(&self) -> bool;

37 38
    fn get_property_context(&self) -> Option<GLContext>;

39 40 41 42
    fn connect_property_context_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;
43 44
}

45
impl<O: IsA<GLBaseFilter>> GLBaseFilterExt for O {
46 47 48
    #[cfg(any(feature = "v1_16", feature = "dox"))]
    fn find_gl_context(&self) -> bool {
        unsafe {
49 50 51
            from_glib(gst_gl_sys::gst_gl_base_filter_find_gl_context(
                self.as_ref().to_glib_none().0,
            ))
52 53 54
        }
    }

55 56 57
    fn get_property_context(&self) -> Option<GLContext> {
        unsafe {
            let mut value = Value::from_type(<GLContext as StaticType>::static_type());
58 59 60 61 62
            gobject_sys::g_object_get_property(
                self.to_glib_none().0 as *mut gobject_sys::GObject,
                b"context\0".as_ptr() as *const _,
                value.to_glib_none_mut().0,
            );
François Laignel's avatar
Regen  
François Laignel committed
63 64 65
            value
                .get()
                .expect("Return Value for property `context` getter")
66 67 68
        }
    }

69 70 71 72 73 74 75 76 77 78
    fn connect_property_context_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_context_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
            this: *mut gst_gl_sys::GstGLBaseFilter,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<GLBaseFilter>,
Sebastian Dröge's avatar
Sebastian Dröge committed
79 80 81 82
        {
            let f: &F = &*(f as *const F);
            f(&GLBaseFilter::from_glib_borrow(this).unsafe_cast())
        }
83
        unsafe {
Sebastian Dröge's avatar
Sebastian Dröge committed
84
            let f: Box_<F> = Box_::new(f);
85 86 87 88 89 90
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::context\0".as_ptr() as *const _,
                Some(transmute(notify_context_trampoline::<Self, F> as usize)),
                Box_::into_raw(f),
            )
91 92 93
        }
    }
}