gstreamer-rs/gstreamer-gl/src/auto/gl_window.rs

416 lines
12 KiB
Rust
Raw Normal View History

2018-11-27 21:52:42 +00:00
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
2018-11-27 21:52:42 +00:00
// DO NOT EDIT
use crate::{GLContext, GLDisplay};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, mem, mem::transmute};
2018-11-27 21:52:42 +00:00
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[doc(alias = "GstGLWindow")]
2020-11-22 10:20:20 +00:00
pub struct GLWindow(Object<ffi::GstGLWindow, ffi::GstGLWindowClass>) @extends gst::Object;
2018-11-27 21:52:42 +00:00
match fn {
type_ => || ffi::gst_gl_window_get_type(),
2018-11-27 21:52:42 +00:00
}
}
impl GLWindow {
2021-11-16 14:02:58 +00:00
pub const NONE: Option<&'static GLWindow> = None;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_new")]
pub fn new(display: &impl IsA<GLDisplay>) -> GLWindow {
2018-11-27 21:52:42 +00:00
skip_assert_initialized!();
2020-11-22 10:20:20 +00:00
unsafe { from_glib_full(ffi::gst_gl_window_new(display.as_ref().to_glib_none().0)) }
2018-11-27 21:52:42 +00:00
}
}
unsafe impl Send for GLWindow {}
unsafe impl Sync for GLWindow {}
pub trait GLWindowExt: 'static {
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_controls_viewport")]
2019-04-23 14:32:09 +00:00
fn controls_viewport(&self) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_draw")]
2018-11-27 21:52:42 +00:00
fn draw(&self);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_get_context")]
#[doc(alias = "get_context")]
fn context(&self) -> GLContext;
2018-11-27 21:52:42 +00:00
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_get_surface_dimensions")]
#[doc(alias = "get_surface_dimensions")]
2021-04-11 19:38:18 +00:00
fn surface_dimensions(&self) -> (u32, u32);
2018-11-27 21:52:42 +00:00
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_handle_events")]
2018-11-27 21:52:42 +00:00
fn handle_events(&self, handle_events: bool);
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_has_output_surface")]
2020-04-30 16:51:41 +00:00
fn has_output_surface(&self) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_queue_resize")]
2018-11-27 21:52:42 +00:00
fn queue_resize(&self);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_quit")]
2018-11-27 21:52:42 +00:00
fn quit(&self);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_resize")]
2018-11-27 21:52:42 +00:00
fn resize(&self, width: u32, height: u32);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_run")]
2018-11-27 21:52:42 +00:00
fn run(&self);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_send_key_event")]
2018-11-27 21:52:42 +00:00
fn send_key_event(&self, event_type: &str, key_str: &str);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_send_mouse_event")]
2018-11-27 21:52:42 +00:00
fn send_mouse_event(&self, event_type: &str, button: i32, posx: f64, posy: f64);
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_send_scroll_event")]
2020-04-30 16:51:41 +00:00
fn send_scroll_event(&self, posx: f64, posy: f64, delta_x: f64, delta_y: f64);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_set_preferred_size")]
2018-11-27 21:52:42 +00:00
fn set_preferred_size(&self, width: i32, height: i32);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_set_render_rectangle")]
fn set_render_rectangle(
&self,
x: i32,
y: i32,
width: i32,
height: i32,
) -> Result<(), glib::error::BoolError>;
2018-11-27 21:52:42 +00:00
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_gl_window_show")]
2018-11-27 21:52:42 +00:00
fn show(&self);
#[doc(alias = "key-event")]
fn connect_key_event<F: Fn(&Self, &str, &str) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
2018-11-27 21:52:42 +00:00
#[doc(alias = "mouse-event")]
fn connect_mouse_event<F: Fn(&Self, &str, i32, f64, f64) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
2020-04-30 16:51:41 +00:00
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "scroll-event")]
2020-04-30 16:51:41 +00:00
fn connect_scroll_event<F: Fn(&Self, f64, f64, f64, f64) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
2021-09-19 08:04:08 +00:00
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
2021-09-19 08:04:08 +00:00
#[doc(alias = "window-handle-changed")]
fn connect_window_handle_changed<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
2018-11-27 21:52:42 +00:00
}
impl<O: IsA<GLWindow>> GLWindowExt for O {
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
2019-04-23 14:32:09 +00:00
fn controls_viewport(&self) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_window_controls_viewport(
self.as_ref().to_glib_none().0,
))
2019-04-23 14:32:09 +00:00
}
}
2018-11-27 21:52:42 +00:00
fn draw(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_draw(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
fn context(&self) -> GLContext {
2018-11-27 21:52:42 +00:00
unsafe {
2020-11-22 10:20:20 +00:00
from_glib_full(ffi::gst_gl_window_get_context(
self.as_ref().to_glib_none().0,
))
2018-11-27 21:52:42 +00:00
}
}
2021-04-11 19:38:18 +00:00
fn surface_dimensions(&self) -> (u32, u32) {
2018-11-27 21:52:42 +00:00
unsafe {
2019-07-10 08:21:28 +00:00
let mut width = mem::MaybeUninit::uninit();
let mut height = mem::MaybeUninit::uninit();
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_get_surface_dimensions(
self.as_ref().to_glib_none().0,
2019-07-10 08:21:28 +00:00
width.as_mut_ptr(),
height.as_mut_ptr(),
);
2022-05-18 20:27:53 +00:00
(width.assume_init(), height.assume_init())
2018-11-27 21:52:42 +00:00
}
}
fn handle_events(&self, handle_events: bool) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_handle_events(
self.as_ref().to_glib_none().0,
handle_events.into_glib(),
);
2018-11-27 21:52:42 +00:00
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2020-04-30 16:51:41 +00:00
fn has_output_surface(&self) -> bool {
unsafe {
2020-11-22 10:20:20 +00:00
from_glib(ffi::gst_gl_window_has_output_surface(
2020-04-30 16:51:41 +00:00
self.as_ref().to_glib_none().0,
))
}
}
2018-11-27 21:52:42 +00:00
fn queue_resize(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_queue_resize(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
fn quit(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_quit(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
fn resize(&self, width: u32, height: u32) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_resize(self.as_ref().to_glib_none().0, width, height);
2018-11-27 21:52:42 +00:00
}
}
fn run(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_run(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
fn send_key_event(&self, event_type: &str, key_str: &str) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_send_key_event(
self.as_ref().to_glib_none().0,
event_type.to_glib_none().0,
key_str.to_glib_none().0,
);
2018-11-27 21:52:42 +00:00
}
}
fn send_mouse_event(&self, event_type: &str, button: i32, posx: f64, posy: f64) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_send_mouse_event(
self.as_ref().to_glib_none().0,
event_type.to_glib_none().0,
button,
posx,
posy,
);
2018-11-27 21:52:42 +00:00
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2020-04-30 16:51:41 +00:00
fn send_scroll_event(&self, posx: f64, posy: f64, delta_x: f64, delta_y: f64) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_send_scroll_event(
2020-04-30 16:51:41 +00:00
self.as_ref().to_glib_none().0,
posx,
posy,
delta_x,
delta_y,
);
}
}
2018-11-27 21:52:42 +00:00
fn set_preferred_size(&self, width: i32, height: i32) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_set_preferred_size(self.as_ref().to_glib_none().0, width, height);
2018-11-27 21:52:42 +00:00
}
}
fn set_render_rectangle(
&self,
x: i32,
y: i32,
width: i32,
height: i32,
) -> Result<(), glib::error::BoolError> {
2018-11-27 21:52:42 +00:00
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_set_render_rectangle(
self.as_ref().to_glib_none().0,
x,
y,
width,
height
),
"Failed to set the specified region"
)
2018-11-27 21:52:42 +00:00
}
}
fn show(&self) {
unsafe {
2020-11-22 10:20:20 +00:00
ffi::gst_gl_window_show(self.as_ref().to_glib_none().0);
2018-11-27 21:52:42 +00:00
}
}
fn connect_key_event<F: Fn(&Self, &str, &str) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn key_event_trampoline<
P: IsA<GLWindow>,
F: Fn(&P, &str, &str) + Send + Sync + 'static,
>(
2020-11-22 10:20:20 +00:00
this: *mut ffi::GstGLWindow,
id: *mut libc::c_char,
key: *mut libc::c_char,
2020-11-22 10:20:20 +00:00
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
f(
2021-06-21 21:07:45 +00:00
GLWindow::from_glib_borrow(this).unsafe_cast_ref(),
2020-11-22 10:20:20 +00:00
&glib::GString::from_glib_borrow(id),
&glib::GString::from_glib_borrow(key),
)
2019-06-18 10:10:46 +00:00
}
2018-11-27 21:52:42 +00:00
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"key-event\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
key_event_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
2018-11-27 21:52:42 +00:00
}
}
fn connect_mouse_event<F: Fn(&Self, &str, i32, f64, f64) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn mouse_event_trampoline<
P: IsA<GLWindow>,
F: Fn(&P, &str, i32, f64, f64) + Send + Sync + 'static,
>(
2020-11-22 10:20:20 +00:00
this: *mut ffi::GstGLWindow,
id: *mut libc::c_char,
button: libc::c_int,
x: libc::c_double,
y: libc::c_double,
2020-11-22 10:20:20 +00:00
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
f(
2021-06-21 21:07:45 +00:00
GLWindow::from_glib_borrow(this).unsafe_cast_ref(),
2020-11-22 10:20:20 +00:00
&glib::GString::from_glib_borrow(id),
button,
x,
y,
)
2019-06-18 10:10:46 +00:00
}
2018-11-27 21:52:42 +00:00
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"mouse-event\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
mouse_event_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
2018-11-27 21:52:42 +00:00
}
}
2020-04-30 16:51:41 +00:00
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2020-04-30 16:51:41 +00:00
fn connect_scroll_event<F: Fn(&Self, f64, f64, f64, f64) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn scroll_event_trampoline<
P: IsA<GLWindow>,
2020-04-30 16:51:41 +00:00
F: Fn(&P, f64, f64, f64, f64) + Send + Sync + 'static,
>(
2020-11-22 10:20:20 +00:00
this: *mut ffi::GstGLWindow,
2020-04-30 16:51:41 +00:00
x: libc::c_double,
y: libc::c_double,
delta_x: libc::c_double,
delta_y: libc::c_double,
2020-11-22 10:20:20 +00:00
f: glib::ffi::gpointer,
) {
2020-04-30 16:51:41 +00:00
let f: &F = &*(f as *const F);
f(
2021-06-21 21:07:45 +00:00
GLWindow::from_glib_borrow(this).unsafe_cast_ref(),
2020-04-30 16:51:41 +00:00
x,
y,
delta_x,
delta_y,
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"scroll-event\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
scroll_event_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
2021-09-19 08:04:08 +00:00
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
2021-09-19 08:04:08 +00:00
fn connect_window_handle_changed<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn window_handle_changed_trampoline<
P: IsA<GLWindow>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstGLWindow,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(GLWindow::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"window-handle-changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
window_handle_changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
2018-11-27 21:52:42 +00:00
}