From 72aa5aed88b6c8fbda6ba7f1a40c011cd97cd893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 2 Apr 2019 15:27:37 +0200 Subject: [PATCH] Add GLDisplayX11 for gstreamer-gl --- Gir_GstGL.toml | 6 +++ gir-files/GstGL-1.0.gir | 63 ++++++++++++++++++++++++- gir-files/fix.sh | 14 ++++-- gstreamer-gl/Cargo.toml | 1 + gstreamer-gl/src/auto/gl_display_x11.rs | 33 +++++++++++++ gstreamer-gl/src/auto/mod.rs | 5 ++ gstreamer-gl/src/gl_display_x11.rs | 21 +++++++++ gstreamer-gl/src/lib.rs | 2 + 8 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 gstreamer-gl/src/auto/gl_display_x11.rs create mode 100644 gstreamer-gl/src/gl_display_x11.rs diff --git a/Gir_GstGL.toml b/Gir_GstGL.toml index 896f31b08..903de96b4 100644 --- a/Gir_GstGL.toml +++ b/Gir_GstGL.toml @@ -192,6 +192,12 @@ status = "generate" final_type = true cfg_condition = "feature = \"egl\"" +[[object]] +name = "GstGL.GLDisplayX11" +status = "generate" +final_type = true +cfg_condition = "feature = \"x11\"" + [[object]] name = "GstGL.GLWindow" status = "generate" diff --git a/gir-files/GstGL-1.0.gir b/gir-files/GstGL-1.0.gir index e72653c4d..c7a90c57a 100644 --- a/gir-files/GstGL-1.0.gir +++ b/gir-files/GstGL-1.0.gir @@ -2658,8 +2658,67 @@ through the provided API - - + + the contents of a #GstGLDisplayX11 are private and should only be accessed +through the provided API + + Create a new #GstGLDisplayX11 from the x11 display name. See XOpenDisplay() +for details on what is a valid name. + + a new #GstGLDisplayX11 or %NULL + + + + + a display name + + + + + + Creates a new display connection from a X11 Display. + + a new #GstGLDisplayX11 + + + + + an existing, x11 display + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #GstGLFilter helps to implement simple OpenGL filter elements taking a single input and producing a single output with a #GstGLFramebuffer diff --git a/gir-files/fix.sh b/gir-files/fix.sh index 9f3788827..a7ce4fe8e 100755 --- a/gir-files/fix.sh +++ b/gir-files/fix.sh @@ -33,11 +33,17 @@ xmlstarlet ed --pf --inplace \ --delete '//_:record[@name="GLDisplayWaylandClass"]' \ GstGL-1.0.gir -# Remove GstDisplayX11 +# Change X11's Display* and xcb_connection_t* pointers to gpointer xmlstarlet ed --pf --inplace \ - --delete '//_:class[@name="GLDisplayX11"]' \ - --delete '//_:record[@name="GLDisplayX11Class"]' \ - GstGL-1.0.gir + --insert '//_:type[@c:type="Display*"]' \ + --type attr --name 'name' --value 'gpointer' \ + --insert '//_:type[@c:type="xcb_connection_t*"]' \ + --type attr --name 'name' --value 'gpointer' \ + --update '//*[@c:type="Display*"]/@c:type' \ + --value gpointer \ + --update '//*[@c:type="xcb_connection_t*"]/@c:type' \ + --value gpointer \ + GstGL-1.0.gir # Remove GstMemoryEGL xmlstarlet ed --pf --inplace \ diff --git a/gstreamer-gl/Cargo.toml b/gstreamer-gl/Cargo.toml index 9ce63a6d5..fe1e05594 100644 --- a/gstreamer-gl/Cargo.toml +++ b/gstreamer-gl/Cargo.toml @@ -37,5 +37,6 @@ optional = true default = [] dox = ["gstreamer-gl-sys/dox", "glib/dox", "gstreamer/dox", "gstreamer-base/dox"] egl = ["gstreamer-gl-sys/egl"] +x11 = ["gstreamer-gl-sys/x11"] embed-lgpl-docs = ["rustdoc-stripper"] purge-lgpl-docs = ["rustdoc-stripper"] diff --git a/gstreamer-gl/src/auto/gl_display_x11.rs b/gstreamer-gl/src/auto/gl_display_x11.rs new file mode 100644 index 000000000..556cc7dd0 --- /dev/null +++ b/gstreamer-gl/src/auto/gl_display_x11.rs @@ -0,0 +1,33 @@ +// 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 GLDisplay; +use ffi; +use glib::translate::*; +use gst; + +glib_wrapper! { + pub struct GLDisplayX11(Object) @extends GLDisplay, gst::Object; + + match fn { + get_type => || ffi::gst_gl_display_x11_get_type(), + } +} + +impl GLDisplayX11 { + pub fn new<'a, P: Into>>(name: P) -> GLDisplayX11 { + assert_initialized_main_thread!(); + let name = name.into(); + unsafe { + from_glib_full(ffi::gst_gl_display_x11_new(name.to_glib_none().0)) + } + } + + //pub fn new_with_display(display: /*Unimplemented*/Fundamental: Pointer) -> GLDisplayX11 { + // unsafe { TODO: call ffi::gst_gl_display_x11_new_with_display() } + //} +} + +unsafe impl Send for GLDisplayX11 {} +unsafe impl Sync for GLDisplayX11 {} diff --git a/gstreamer-gl/src/auto/mod.rs b/gstreamer-gl/src/auto/mod.rs index 460cf8730..335ce1499 100644 --- a/gstreamer-gl/src/auto/mod.rs +++ b/gstreamer-gl/src/auto/mod.rs @@ -22,6 +22,11 @@ mod gl_display_egl; #[cfg(any(feature = "egl", feature = "dox"))] pub use self::gl_display_egl::{GLDisplayEGL, GLDisplayEGLClass}; +#[cfg(any(feature = "x11", feature = "dox"))] +mod gl_display_x11; +#[cfg(any(feature = "x11", feature = "dox"))] +pub use self::gl_display_x11::{GLDisplayX11, GLDisplayX11Class}; + mod gl_framebuffer; pub use self::gl_framebuffer::{GLFramebuffer, GLFramebufferClass, NONE_GL_FRAMEBUFFER}; pub use self::gl_framebuffer::GLFramebufferExt; diff --git a/gstreamer-gl/src/gl_display_x11.rs b/gstreamer-gl/src/gl_display_x11.rs new file mode 100644 index 000000000..00e77039d --- /dev/null +++ b/gstreamer-gl/src/gl_display_x11.rs @@ -0,0 +1,21 @@ +// Copyright (C) 2019 Víctor Jáquez +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use ffi; +use glib::translate::*; +use glib_ffi::gpointer; +use libc::uintptr_t; +use GLDisplayX11; + +impl GLDisplayX11 { + pub unsafe fn new_with_display(display: uintptr_t) -> Option { + from_glib_full(ffi::gst_gl_display_x11_new_with_display( + display as gpointer, + )) + } +} diff --git a/gstreamer-gl/src/lib.rs b/gstreamer-gl/src/lib.rs index ec50b96f2..e27077dc2 100644 --- a/gstreamer-gl/src/lib.rs +++ b/gstreamer-gl/src/lib.rs @@ -55,6 +55,8 @@ mod gl_display; pub use gl_display::GL_DISPLAY_CONTEXT_TYPE; #[cfg(any(feature = "egl", feature = "dox"))] mod gl_display_egl; +#[cfg(any(feature = "x11", feature = "dox"))] +mod gl_display_x11; mod gl_video_frame; pub use gl_video_frame::VideoFrameGLExt; mod gl_sync_meta;