mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-06-05 15:59:26 +00:00
186 lines
5.8 KiB
Rust
186 lines
5.8 KiB
Rust
// 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 GLContext;
|
|
use GLDisplay;
|
|
use ffi;
|
|
use glib;
|
|
use glib::GString;
|
|
use glib::object::Cast;
|
|
use glib::object::IsA;
|
|
use glib::signal::SignalHandlerId;
|
|
use glib::signal::connect_raw;
|
|
use glib::translate::*;
|
|
use glib_ffi;
|
|
use gst;
|
|
use libc;
|
|
use std::boxed::Box as Box_;
|
|
use std::mem;
|
|
use std::mem::transmute;
|
|
|
|
glib_wrapper! {
|
|
pub struct GLWindow(Object<ffi::GstGLWindow, ffi::GstGLWindowClass, GLWindowClass>) @extends gst::Object;
|
|
|
|
match fn {
|
|
get_type => || ffi::gst_gl_window_get_type(),
|
|
}
|
|
}
|
|
|
|
impl GLWindow {
|
|
pub fn new<P: IsA<GLDisplay>>(display: &P) -> GLWindow {
|
|
skip_assert_initialized!();
|
|
unsafe {
|
|
from_glib_full(ffi::gst_gl_window_new(display.as_ref().to_glib_none().0))
|
|
}
|
|
}
|
|
}
|
|
|
|
unsafe impl Send for GLWindow {}
|
|
unsafe impl Sync for GLWindow {}
|
|
|
|
pub const NONE_GL_WINDOW: Option<&GLWindow> = None;
|
|
|
|
pub trait GLWindowExt: 'static {
|
|
fn draw(&self);
|
|
|
|
fn get_context(&self) -> Option<GLContext>;
|
|
|
|
fn get_surface_dimensions(&self) -> (u32, u32);
|
|
|
|
fn handle_events(&self, handle_events: bool);
|
|
|
|
fn queue_resize(&self);
|
|
|
|
fn quit(&self);
|
|
|
|
fn resize(&self, width: u32, height: u32);
|
|
|
|
fn run(&self);
|
|
|
|
fn send_key_event(&self, event_type: &str, key_str: &str);
|
|
|
|
fn send_mouse_event(&self, event_type: &str, button: i32, posx: f64, posy: f64);
|
|
|
|
fn set_preferred_size(&self, width: i32, height: i32);
|
|
|
|
fn set_render_rectangle(&self, x: i32, y: i32, width: i32, height: i32) -> Result<(), glib::error::BoolError>;
|
|
|
|
fn show(&self);
|
|
|
|
fn connect_key_event<F: Fn(&Self, &str, &str) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
|
|
|
|
fn connect_mouse_event<F: Fn(&Self, &str, i32, f64, f64) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
|
|
}
|
|
|
|
impl<O: IsA<GLWindow>> GLWindowExt for O {
|
|
fn draw(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_window_draw(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
|
|
fn get_context(&self) -> Option<GLContext> {
|
|
unsafe {
|
|
from_glib_full(ffi::gst_gl_window_get_context(self.as_ref().to_glib_none().0))
|
|
}
|
|
}
|
|
|
|
fn get_surface_dimensions(&self) -> (u32, u32) {
|
|
unsafe {
|
|
let mut width = mem::uninitialized();
|
|
let mut height = mem::uninitialized();
|
|
ffi::gst_gl_window_get_surface_dimensions(self.as_ref().to_glib_none().0, &mut width, &mut height);
|
|
(width, height)
|
|
}
|
|
}
|
|
|
|
fn handle_events(&self, handle_events: bool) {
|
|
unsafe {
|
|
ffi::gst_gl_window_handle_events(self.as_ref().to_glib_none().0, handle_events.to_glib());
|
|
}
|
|
}
|
|
|
|
fn queue_resize(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_window_queue_resize(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
|
|
fn quit(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_window_quit(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
|
|
fn resize(&self, width: u32, height: u32) {
|
|
unsafe {
|
|
ffi::gst_gl_window_resize(self.as_ref().to_glib_none().0, width, height);
|
|
}
|
|
}
|
|
|
|
fn run(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_window_run(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
|
|
fn send_key_event(&self, event_type: &str, key_str: &str) {
|
|
unsafe {
|
|
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);
|
|
}
|
|
}
|
|
|
|
fn send_mouse_event(&self, event_type: &str, button: i32, posx: f64, posy: f64) {
|
|
unsafe {
|
|
ffi::gst_gl_window_send_mouse_event(self.as_ref().to_glib_none().0, event_type.to_glib_none().0, button, posx, posy);
|
|
}
|
|
}
|
|
|
|
fn set_preferred_size(&self, width: i32, height: i32) {
|
|
unsafe {
|
|
ffi::gst_gl_window_set_preferred_size(self.as_ref().to_glib_none().0, width, height);
|
|
}
|
|
}
|
|
|
|
fn set_render_rectangle(&self, x: i32, y: i32, width: i32, height: i32) -> Result<(), glib::error::BoolError> {
|
|
unsafe {
|
|
glib_result_from_gboolean!(ffi::gst_gl_window_set_render_rectangle(self.as_ref().to_glib_none().0, x, y, width, height), "Failed to set the specified region")
|
|
}
|
|
}
|
|
|
|
fn show(&self) {
|
|
unsafe {
|
|
ffi::gst_gl_window_show(self.as_ref().to_glib_none().0);
|
|
}
|
|
}
|
|
|
|
fn connect_key_event<F: Fn(&Self, &str, &str) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
|
|
unsafe {
|
|
let f: Box_<F> = Box_::new(f);
|
|
connect_raw(self.as_ptr() as *mut _, b"key-event\0".as_ptr() as *const _,
|
|
Some(transmute(key_event_trampoline::<Self, F> as usize)), Box_::into_raw(f))
|
|
}
|
|
}
|
|
|
|
fn connect_mouse_event<F: Fn(&Self, &str, i32, f64, f64) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
|
|
unsafe {
|
|
let f: Box_<F> = Box_::new(f);
|
|
connect_raw(self.as_ptr() as *mut _, b"mouse-event\0".as_ptr() as *const _,
|
|
Some(transmute(mouse_event_trampoline::<Self, F> as usize)), Box_::into_raw(f))
|
|
}
|
|
}
|
|
}
|
|
|
|
unsafe extern "C" fn key_event_trampoline<P, F: Fn(&P, &str, &str) + Send + Sync + 'static>(this: *mut ffi::GstGLWindow, id: *mut libc::c_char, key: *mut libc::c_char, f: glib_ffi::gpointer)
|
|
where P: IsA<GLWindow> {
|
|
let f: &F = transmute(f);
|
|
f(&GLWindow::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(id), &GString::from_glib_borrow(key))
|
|
}
|
|
|
|
unsafe extern "C" fn mouse_event_trampoline<P, F: Fn(&P, &str, i32, f64, f64) + Send + Sync + 'static>(this: *mut ffi::GstGLWindow, id: *mut libc::c_char, button: libc::c_int, x: libc::c_double, y: libc::c_double, f: glib_ffi::gpointer)
|
|
where P: IsA<GLWindow> {
|
|
let f: &F = transmute(f);
|
|
f(&GLWindow::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(id), button, x, y)
|
|
}
|