[mutter] tests/screen-cast: Also make it a remote desktop session
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tests/screen-cast: Also make it a remote desktop session
- Date: Fri, 4 Mar 2022 19:04:53 +0000 (UTC)
commit d649445bb7e97b891a13406a014a0d45b8f7c4a0
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Feb 14 18:06:41 2022 +0100
tests/screen-cast: Also make it a remote desktop session
This will allow emitting input events / remote control too.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
src/tests/meson.build | 1 +
src/tests/screen-cast-client.c | 141 +++++++++++++++++++++++++++++++----------
2 files changed, 110 insertions(+), 32 deletions(-)
---
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 340d33c1a4..a19703288a 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -191,6 +191,7 @@ if have_native_tests
screen_cast_client = executable('mutter-screen-cast-client',
sources: [
'screen-cast-client.c',
+ dbus_remote_desktop_built_sources,
dbus_screen_cast_built_sources,
],
include_directories: tests_includes,
diff --git a/src/tests/screen-cast-client.c b/src/tests/screen-cast-client.c
index b408e80fa2..84ce891320 100644
--- a/src/tests/screen-cast-client.c
+++ b/src/tests/screen-cast-client.c
@@ -28,6 +28,7 @@
#include <stdint.h>
#include <sys/mman.h>
+#include "meta-dbus-remote-desktop.h"
#include "meta-dbus-screen-cast.h"
typedef struct _Stream
@@ -46,9 +47,15 @@ typedef struct _Stream
typedef struct _Session
{
- MetaDBusScreenCastSession *proxy;
+ MetaDBusScreenCastSession *screen_cast_session_proxy;
+ MetaDBusRemoteDesktopSession *remote_desktop_session_proxy;
} Session;
+typedef struct _RemoteDesktop
+{
+ MetaDBusRemoteDesktop *proxy;
+} RemoteDesktop;
+
typedef struct _ScreenCast
{
MetaDBusScreenCast *proxy;
@@ -453,9 +460,10 @@ session_start (Session *session)
{
GError *error = NULL;
- if (!meta_dbus_screen_cast_session_call_start_sync (session->proxy,
- NULL,
- &error))
+ if (!meta_dbus_remote_desktop_session_call_start_sync (
+ session->remote_desktop_session_proxy,
+ NULL,
+ &error))
g_error ("Failed to start session: %s", error->message);
}
@@ -464,9 +472,10 @@ session_stop (Session *session)
{
GError *error = NULL;
- if (!meta_dbus_screen_cast_session_call_stop_sync (session->proxy,
- NULL,
- &error))
+ if (!meta_dbus_remote_desktop_session_call_stop_sync (
+ session->remote_desktop_session_proxy,
+ NULL,
+ &error))
g_error ("Failed to stop session: %s", error->message);
}
@@ -485,7 +494,7 @@ session_record_virtual (Session *session,
properties_variant = g_variant_builder_end (&properties_builder);
if (!meta_dbus_screen_cast_session_call_record_virtual_sync (
- session->proxy,
+ session->screen_cast_session_proxy,
properties_variant,
&stream_path,
NULL,
@@ -498,21 +507,14 @@ session_record_virtual (Session *session,
}
static Session *
-session_new (const char *path)
+session_new (MetaDBusRemoteDesktopSession *remote_desktop_session_proxy,
+ MetaDBusScreenCastSession *screen_cast_session_proxy)
{
Session *session;
- GError *error = NULL;
session = g_new0 (Session, 1);
- session->proxy = meta_dbus_screen_cast_session_proxy_new_for_bus_sync (
- G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.gnome.Mutter.ScreenCast",
- path,
- NULL,
- &error);
- if (!session->proxy)
- g_error ("Failed to acquire proxy: %s", error->message);
+ session->remote_desktop_session_proxy = remote_desktop_session_proxy;
+ session->screen_cast_session_proxy = screen_cast_session_proxy;
return session;
}
@@ -520,34 +522,103 @@ session_new (const char *path)
static void
session_free (Session *session)
{
- g_clear_object (&session->proxy);
+ g_clear_object (&session->screen_cast_session_proxy);
+ g_clear_object (&session->remote_desktop_session_proxy);
g_free (session);
}
static Session *
-screen_cast_create_session (ScreenCast *screen_cast)
+screen_cast_create_session (RemoteDesktop *remote_desktop,
+ ScreenCast *screen_cast)
{
GVariantBuilder properties_builder;
- GVariant *properties_variant;
GError *error = NULL;
- g_autofree char *session_path = NULL;
+ g_autofree char *remote_desktop_session_path = NULL;
+ MetaDBusRemoteDesktopSession *remote_desktop_session_proxy;
+ g_autofree char *screen_cast_session_path = NULL;
+ MetaDBusScreenCastSession *screen_cast_session_proxy;
+ const char *session_id;
Session *session;
- g_variant_builder_init (&properties_builder, G_VARIANT_TYPE ("a{sv}"));
- properties_variant = g_variant_builder_end (&properties_builder);
+ if (!meta_dbus_remote_desktop_call_create_session_sync (
+ remote_desktop->proxy,
+ &remote_desktop_session_path,
+ NULL,
+ &error))
+ g_error ("Failed to create session: %s", error->message);
+
+ remote_desktop_session_proxy =
+ meta_dbus_remote_desktop_session_proxy_new_for_bus_sync (
+ G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+ "org.gnome.Mutter.RemoteDesktop",
+ remote_desktop_session_path,
+ NULL,
+ &error);
+ if (!remote_desktop_session_proxy)
+ g_error ("Failed to acquire proxy: %s", error->message);
+
+ session_id =
+ meta_dbus_remote_desktop_session_get_session_id (
+ remote_desktop_session_proxy);
- if (!meta_dbus_screen_cast_call_create_session_sync (screen_cast->proxy,
- properties_variant,
- &session_path,
- NULL,
- &error))
+ g_variant_builder_init (&properties_builder, G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add (&properties_builder, "{sv}",
+ "remote-desktop-session-id",
+ g_variant_new_string (session_id));
+
+ if (!meta_dbus_screen_cast_call_create_session_sync (
+ screen_cast->proxy,
+ g_variant_builder_end (&properties_builder),
+ &screen_cast_session_path,
+ NULL,
+ &error))
g_error ("Failed to create session: %s", error->message);
- session = session_new (session_path);
+ screen_cast_session_proxy =
+ meta_dbus_screen_cast_session_proxy_new_for_bus_sync (
+ G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+ "org.gnome.Mutter.ScreenCast",
+ screen_cast_session_path,
+ NULL,
+ &error);
+ if (!screen_cast_session_proxy)
+ g_error ("Failed to acquire proxy: %s", error->message);
+
+ session = session_new (remote_desktop_session_proxy,
+ screen_cast_session_proxy);
g_assert_nonnull (session);
return session;
}
+static RemoteDesktop *
+remote_desktop_new (void)
+{
+ RemoteDesktop *remote_desktop;
+ GError *error = NULL;
+
+ remote_desktop = g_new0 (RemoteDesktop, 1);
+ remote_desktop->proxy = meta_dbus_remote_desktop_proxy_new_for_bus_sync (
+ G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+ "org.gnome.Mutter.RemoteDesktop",
+ "/org/gnome/Mutter/RemoteDesktop",
+ NULL,
+ &error);
+ if (!remote_desktop->proxy)
+ g_error ("Failed to acquire proxy: %s", error->message);
+
+ return remote_desktop;
+}
+
+static void
+remote_desktop_free (RemoteDesktop *remote_desktop)
+{
+ g_clear_object (&remote_desktop->proxy);
+ g_free (remote_desktop);
+}
+
static ScreenCast *
screen_cast_new (void)
{
@@ -579,14 +650,16 @@ int
main (int argc,
char **argv)
{
+ RemoteDesktop *remote_desktop;
ScreenCast *screen_cast;
Session *session;
Stream *stream;
init_pipewire ();
+ remote_desktop = remote_desktop_new ();
screen_cast = screen_cast_new ();
- session = screen_cast_create_session (screen_cast);
+ session = screen_cast_create_session (remote_desktop, screen_cast);
stream = session_record_virtual (session, 50, 40);
session_start (session);
@@ -613,11 +686,15 @@ main (int argc,
g_assert_cmpint (stream->spa_format.size.height, ==, 40);
}
+ /* Check that resizing works */
+ stream_resize (stream, 60, 60);
+
session_stop (session);
stream_free (stream);
session_free (session);
screen_cast_free (screen_cast);
+ remote_desktop_free (remote_desktop);
release_pipewire ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]