From 47b788d44b9c719aa7f119032396fce469718fb5 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Fri, 26 Apr 2024 13:48:05 +0200 Subject: [PATCH 1/3] gtk4paintablesink: Add env var to fullscreen window For testing purposes with e.g. gst-launch. Part-of: --- video/gtk4/src/sink/imp.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/video/gtk4/src/sink/imp.rs b/video/gtk4/src/sink/imp.rs index 8b98c4cb..4ba43bda 100644 --- a/video/gtk4/src/sink/imp.rs +++ b/video/gtk4/src/sink/imp.rs @@ -713,6 +713,9 @@ impl PaintableSink { window.set_child(Some(&picture)); } window.set_default_size(640, 480); + if std::env::var("GST_GTK4_WINDOW_FULLSCREEN").as_deref() == Ok("1") { + window.set_fullscreened(true); + } window.connect_close_request({ let self_ = self_.clone(); From 4326c3bfcefdbd4eeb5d83a581f9e5e79dd47019 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Mon, 29 Apr 2024 22:17:46 +0200 Subject: [PATCH 2/3] gtk4paintablesink: Also create window for gst-play So it can be easily tested with ``` gst-play-1.0 --videosink=gtk4paintablesink ... ``` Part-of: --- video/gtk4/src/sink/imp.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/video/gtk4/src/sink/imp.rs b/video/gtk4/src/sink/imp.rs index 4ba43bda..8b4f2048 100644 --- a/video/gtk4/src/sink/imp.rs +++ b/video/gtk4/src/sink/imp.rs @@ -297,6 +297,7 @@ impl ElementImpl for PaintableSink { match transition { gst::StateChange::NullToReady => { let create_window = glib::program_name().as_deref() == Some("gst-launch-1.0") + || glib::program_name().as_deref() == Some("gst-play-1.0") || std::env::var("GST_GTK4_WINDOW").as_deref() == Ok("1"); if create_window { From 8e675de690108b09e4e39976dea6e102e255e6f1 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Mon, 29 Apr 2024 22:42:09 +0200 Subject: [PATCH 3/3] gtk4paintablesink: Add some documentation And sync with `README.md` in order to make the environment variables `GST_GTK4_WINDOW` and `GST_GTK4_WINDOW_FULLSCREEN` discoverable - and because it's generally useful. Part-of: --- video/gtk4/README.md | 5 +++++ video/gtk4/src/sink/mod.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/video/gtk4/README.md b/video/gtk4/README.md index aaf66f33..5e4d4b3e 100644 --- a/video/gtk4/README.md +++ b/video/gtk4/README.md @@ -16,6 +16,11 @@ new features or more efficient processing can be opted in with the `gtk_v4_10`, sink is GTK 4.4 on Linux without GL support, and 4.6 on Windows and macOS, and on Linux with GL support. +The sink will provides a simple test window when launched via `gst-launch-1.0` +or `gst-play-1.0` or if the environment variable `GST_GTK4_WINDOW=1` is set. +Setting `GST_GTK4_WINDOW_FULLSCREEN=1` will make the window launch in fullscreen +mode. + # Flatpak Integration To build and include the plugin in a Flatpak manifest, you can add the following snippet to your json manifest: diff --git a/video/gtk4/src/sink/mod.rs b/video/gtk4/src/sink/mod.rs index 5008ed00..06c263a6 100644 --- a/video/gtk4/src/sink/mod.rs +++ b/video/gtk4/src/sink/mod.rs @@ -9,6 +9,32 @@ // // SPDX-License-Identifier: MPL-2.0 +/** + * SECTION:element-gtk4paintablesink + * + * GTK 4 provides `gtk::Video` & `gtk::Picture` for rendering media such as videos. As the default + * `gtk::Video` widget doesn't offer the possibility to use a custom `gst::Pipeline`. The plugin + * provides a `gst_video::VideoSink` along with a `gdk::Paintable` that's capable of rendering the + * sink's frames. + * + * The sink can generate GL Textures if the system is capable of it, but it needs to be compiled + * with either `wayland`, `x11glx` or `x11egl` cargo features. On Windows and macOS this is enabled + * by default. + * + * Additionally, the sink can render DMABufs directly on Linux if GTK 4.14 or newer is used. For + * this the `dmabuf` feature needs to be enabled. + * + * Depending on the GTK version that is used and should be supported as minimum, new features or + * more efficient processing can be opted in with the `gtk_v4_10`, `gtk_v4_12` and `gtk_v4_14` + * features. The minimum GTK version required by the sink is GTK 4.4 on Linux without GL support, + * and 4.6 on Windows and macOS, and on Linux with GL support. + * + * The sink will provides a simple test window when launched via `gst-launch-1.0` or `gst-play-1.0` + * or if the environment variable `GST_GTK4_WINDOW=1` is set. Setting `GST_GTK4_WINDOW_FULLSCREEN=1` + * will make the window launch in fullscreen mode. + * + * {{ videos/gtk4/examples/gtksink.rs }} + */ use gtk::glib; use gtk::glib::prelude::*;