From b99c582a886970c0130f25e4a3f5188dd349cecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 2 Apr 2019 16:50:52 +0200 Subject: [PATCH] Add GLDisplayWayland in gstreamer-gl --- Gir_GstGL.toml | 6 ++ gir-files/GstGL-1.0.gir | 69 ++++++++++++++++++++- gir-files/fix.sh | 16 +++-- gstreamer-gl/Cargo.toml | 1 + gstreamer-gl/src/auto/gl_display_wayland.rs | 33 ++++++++++ gstreamer-gl/src/auto/mod.rs | 5 ++ gstreamer-gl/src/gl_display_wayland.rs | 21 +++++++ gstreamer-gl/src/lib.rs | 2 + 8 files changed, 147 insertions(+), 6 deletions(-) create mode 100644 gstreamer-gl/src/auto/gl_display_wayland.rs create mode 100644 gstreamer-gl/src/gl_display_wayland.rs diff --git a/Gir_GstGL.toml b/Gir_GstGL.toml index 903de96b4..f31121dd9 100644 --- a/Gir_GstGL.toml +++ b/Gir_GstGL.toml @@ -198,6 +198,12 @@ status = "generate" final_type = true cfg_condition = "feature = \"x11\"" +[[object]] +name = "GstGL.GLDisplayWayland" +status = "generate" +final_type = true +cfg_condition = "feature = \"wayland\"" + [[object]] name = "GstGL.GLWindow" status = "generate" diff --git a/gir-files/GstGL-1.0.gir b/gir-files/GstGL-1.0.gir index c7a90c57a..94a9f72a8 100644 --- a/gir-files/GstGL-1.0.gir +++ b/gir-files/GstGL-1.0.gir @@ -2656,8 +2656,73 @@ through the provided API any display type - - + + the contents of a #GstGLDisplayWayland are private and should only be accessed +through the provided API + + Create a new #GstGLDisplayWayland from the wayland display name. See wl_display_connect() +for details on what is a valid name. + + a new #GstGLDisplayWayland or %NULL + + + + + a display name + + + + + + Creates a new display connection from a wl_display Display. + + a new #GstGLDisplayWayland + + + + + an existing, wayland display + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + the contents of a #GstGLDisplayX11 are private and should only be accessed through the provided API diff --git a/gir-files/fix.sh b/gir-files/fix.sh index a7ce4fe8e..714efef42 100755 --- a/gir-files/fix.sh +++ b/gir-files/fix.sh @@ -27,11 +27,19 @@ xmlstarlet ed --pf --inplace \ --value GST_GL_STEREO_DOWNMIX_ANAGLYPH_AMBER_BLUE_DUBOIS \ GstGL-1.0.gir -# Remove GstDisplayWayland +# replace wayland structures to gpointers xmlstarlet ed --pf --inplace \ - --delete '//_:class[@name="GLDisplayWayland"]' \ - --delete '//_:record[@name="GLDisplayWaylandClass"]' \ - GstGL-1.0.gir + --update '//*[@c:type="wl_display*"]/@c:type' \ + --value gpointer \ + --update '//*[@c:type="wl_registry*"]/@c:type' \ + --value gpointer \ + --update '//*[@c:type="wl_compositor*"]/@c:type' \ + --value gpointer \ + --update '//*[@c:type="wl_subcompositor*"]/@c:type' \ + --value gpointer \ + --update '//*[@c:type="wl_shell*"]/@c:type' \ + --value gpointer \ + GstGL-1.0.gir # Change X11's Display* and xcb_connection_t* pointers to gpointer xmlstarlet ed --pf --inplace \ diff --git a/gstreamer-gl/Cargo.toml b/gstreamer-gl/Cargo.toml index fe1e05594..4c9923315 100644 --- a/gstreamer-gl/Cargo.toml +++ b/gstreamer-gl/Cargo.toml @@ -38,5 +38,6 @@ default = [] dox = ["gstreamer-gl-sys/dox", "glib/dox", "gstreamer/dox", "gstreamer-base/dox"] egl = ["gstreamer-gl-sys/egl"] x11 = ["gstreamer-gl-sys/x11"] +wayland = ["gstreamer-gl-sys/wayland"] embed-lgpl-docs = ["rustdoc-stripper"] purge-lgpl-docs = ["rustdoc-stripper"] diff --git a/gstreamer-gl/src/auto/gl_display_wayland.rs b/gstreamer-gl/src/auto/gl_display_wayland.rs new file mode 100644 index 000000000..1225e2431 --- /dev/null +++ b/gstreamer-gl/src/auto/gl_display_wayland.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 GLDisplayWayland(Object) @extends GLDisplay, gst::Object; + + match fn { + get_type => || ffi::gst_gl_display_wayland_get_type(), + } +} + +impl GLDisplayWayland { + pub fn new<'a, P: Into>>(name: P) -> GLDisplayWayland { + assert_initialized_main_thread!(); + let name = name.into(); + unsafe { + from_glib_full(ffi::gst_gl_display_wayland_new(name.to_glib_none().0)) + } + } + + //pub fn new_with_display(display: /*Unimplemented*/Option) -> GLDisplayWayland { + // unsafe { TODO: call ffi::gst_gl_display_wayland_new_with_display() } + //} +} + +unsafe impl Send for GLDisplayWayland {} +unsafe impl Sync for GLDisplayWayland {} diff --git a/gstreamer-gl/src/auto/mod.rs b/gstreamer-gl/src/auto/mod.rs index 335ce1499..d2a21cf51 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 = "wayland", feature = "dox"))] +mod gl_display_wayland; +#[cfg(any(feature = "wayland", feature = "dox"))] +pub use self::gl_display_wayland::{GLDisplayWayland, GLDisplayWaylandClass}; + #[cfg(any(feature = "x11", feature = "dox"))] mod gl_display_x11; #[cfg(any(feature = "x11", feature = "dox"))] diff --git a/gstreamer-gl/src/gl_display_wayland.rs b/gstreamer-gl/src/gl_display_wayland.rs new file mode 100644 index 000000000..e1b7967cb --- /dev/null +++ b/gstreamer-gl/src/gl_display_wayland.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 GLDisplayWayland; + +impl GLDisplayWayland { + pub unsafe fn new_with_display(display: uintptr_t) -> Option { + from_glib_full(ffi::gst_gl_display_wayland_new_with_display( + display as gpointer, + )) + } +} diff --git a/gstreamer-gl/src/lib.rs b/gstreamer-gl/src/lib.rs index e27077dc2..67441e8f1 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 = "wayland", feature = "dox"))] +mod gl_display_wayland; #[cfg(any(feature = "x11", feature = "dox"))] mod gl_display_x11; mod gl_video_frame;