From f0d15f335d18acc7e9dd1faa892a347058a8db7e Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Wed, 30 Aug 2023 10:56:19 -0600 Subject: [PATCH] gst-launch: accept option to set program name The option --prog-name="PROGRAM-NAME" can be passed to set the program name. The program name is used by gtk and gstreamer to set the class or app-id. Part-of: --- .../gst-libs/gst/vulkan/wayland/gstvkwindow_wayland.c | 5 +++++ .../gst-plugins-bad/gst-libs/gst/wayland/gstwlwindow.c | 5 +++++ .../gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c | 5 +++++ .../gst-libs/gst/vaapi/gstvaapiwindow_wayland.c | 5 +++++ subprojects/gstreamer/tools/gst-launch.c | 10 ++++++++++ 5 files changed, 30 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/wayland/gstvkwindow_wayland.c b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/wayland/gstvkwindow_wayland.c index 5317a739cf..ffc08bba46 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/wayland/gstvkwindow_wayland.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/vulkan/wayland/gstvkwindow_wayland.c @@ -122,6 +122,11 @@ create_xdg_surface (GstVulkanWindowWayland * window_wl) /* Then the XDG top-level */ xdg_toplevel = xdg_surface_get_toplevel (xdg_surface); + if (g_get_prgname ()) { + xdg_toplevel_set_app_id (xdg_toplevel, g_get_prgname ()); + } else { + xdg_toplevel_set_app_id (xdg_toplevel, "org.gstreamer.wayland"); + } xdg_toplevel_set_title (xdg_toplevel, "Vulkan Renderer"); xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, window_wl); diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlwindow.c b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlwindow.c index 08f53fe4e0..da5300facd 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlwindow.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/wayland/gstwlwindow.c @@ -307,6 +307,11 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info, } xdg_toplevel_add_listener (priv->xdg_toplevel, &xdg_toplevel_listener, self); + if (g_get_prgname ()) { + xdg_toplevel_set_app_id (priv->xdg_toplevel, g_get_prgname ()); + } else { + xdg_toplevel_set_app_id (priv->xdg_toplevel, "org.gstreamer.wayland"); + } gst_wl_window_ensure_fullscreen (self, fullscreen); diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c index ea68cc5b57..9883c2fa26 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c @@ -305,6 +305,11 @@ create_xdg_surface_and_toplevel (GstGLWindowWaylandEGL * window_egl) /* Then the XDG top-level */ xdg_toplevel = xdg_surface_get_toplevel (xdg_surface); + if (g_get_prgname ()) { + xdg_toplevel_set_app_id (xdg_toplevel, g_get_prgname ()); + } else { + xdg_toplevel_set_app_id (xdg_toplevel, "org.gstreamer.wayland"); + } xdg_toplevel_set_title (xdg_toplevel, "OpenGL Renderer"); xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, window_egl); diff --git a/subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c b/subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c index 6071245284..fc0f45a992 100644 --- a/subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c +++ b/subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c @@ -222,6 +222,11 @@ gst_vaapi_window_wayland_show (GstVaapiWindow * window) /* Create a toplevel window out of it */ priv->xdg_toplevel = xdg_surface_get_toplevel (priv->xdg_surface); g_return_val_if_fail (priv->xdg_toplevel, FALSE); + if (g_get_prgname ()) { + xdg_toplevel_set_app_id (priv->xdg_toplevel, g_get_prgname ()); + } else { + xdg_toplevel_set_app_id (priv->xdg_toplevel, "org.gstreamer.wayland"); + } xdg_toplevel_set_title (priv->xdg_toplevel, "VA-API Wayland window"); wl_proxy_set_queue ((struct wl_proxy *) priv->xdg_toplevel, priv->event_queue); diff --git a/subprojects/gstreamer/tools/gst-launch.c b/subprojects/gstreamer/tools/gst-launch.c index fafde85285..c27d5da539 100644 --- a/subprojects/gstreamer/tools/gst-launch.c +++ b/subprojects/gstreamer/tools/gst-launch.c @@ -80,6 +80,7 @@ static gboolean toc = FALSE; static gboolean messages = FALSE; static gboolean eos_on_shutdown = FALSE; static gchar **exclude_args = NULL; +static gchar *prog_name = NULL; /* pipeline status */ static gboolean is_live = FALSE; @@ -1102,6 +1103,9 @@ real_main (int argc, char *argv[]) N_("Do not output status information for the specified property " "if verbose output is enabled (can be used multiple times)"), N_("PROPERTY-NAME")}, + {"prog-name", 'p', 0, G_OPTION_ARG_STRING, &prog_name, + N_("Set the name of the program"), + N_("PROGRAM-NAME")}, {"no-fault", 'f', 0, G_OPTION_ARG_NONE, &no_fault, N_("Do not install a fault handler"), NULL}, {"eos-on-shutdown", 'e', 0, G_OPTION_ARG_NONE, &eos_on_shutdown, @@ -1178,6 +1182,12 @@ real_main (int argc, char *argv[]) gst_init (&argc, &argv); #endif + if (prog_name) { + g_set_prgname (prog_name); + } else if (!g_get_prgname ()) { + g_set_prgname ((const gchar *) argv[0]); + } + #ifdef G_OS_WIN32 argc = g_strv_length (argv); #endif