[gnome-remote-desktop] session: Port record behaviour to new API



commit 5342ef6e9ce2cabbde5d65583637a753946c6ea9
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Sun Dec 5 12:35:22 2021 +0100

    session: Port record behaviour to new API
    
    With the new method in the screencast API to start streams on-the-fly
    being implemented, gnome-remote-desktop can now adopt to this API.
    This unifies the path for remote assistance and headless sessions, as
    headless sessions have the ability to let the client change the monitor
    configuration during a session without having the client side to
    reconnect and that configuration change requires this new API.

 src/grd-session-rdp.c |  8 +++++
 src/grd-session-vnc.c |  8 +++++
 src/grd-session.c     | 94 +--------------------------------------------------
 3 files changed, 17 insertions(+), 93 deletions(-)
---
diff --git a/src/grd-session-rdp.c b/src/grd-session-rdp.c
index c58be259..809ce2d4 100644
--- a/src/grd-session-rdp.c
+++ b/src/grd-session-rdp.c
@@ -2111,6 +2111,12 @@ grd_session_rdp_remote_desktop_session_ready (GrdSession *session)
                                                            session_rdp->stop_event);
 }
 
+static void
+grd_session_rdp_remote_desktop_session_started (GrdSession *session)
+{
+  grd_session_record_monitor (session, NULL, GRD_SCREEN_CAST_CURSOR_MODE_METADATA);
+}
+
 static void
 on_pipewire_stream_closed (GrdRdpPipeWireStream *stream,
                            GrdSessionRdp        *session_rdp)
@@ -2298,6 +2304,8 @@ grd_session_rdp_class_init (GrdSessionRdpClass *klass)
 
   session_class->remote_desktop_session_ready =
     grd_session_rdp_remote_desktop_session_ready;
+  session_class->remote_desktop_session_started =
+    grd_session_rdp_remote_desktop_session_started;
   session_class->stop = grd_session_rdp_stop;
   session_class->stream_ready = grd_session_rdp_stream_ready;
   session_class->on_caps_lock_state_changed =
diff --git a/src/grd-session-vnc.c b/src/grd-session-vnc.c
index f6b541ed..a4cb9589 100644
--- a/src/grd-session-vnc.c
+++ b/src/grd-session-vnc.c
@@ -721,6 +721,12 @@ close_session_idle (gpointer user_data)
   return G_SOURCE_REMOVE;
 }
 
+static void
+grd_session_vnc_remote_desktop_session_started (GrdSession *session)
+{
+  grd_session_record_monitor (session, NULL, GRD_SCREEN_CAST_CURSOR_MODE_METADATA);
+}
+
 static void
 on_pipewire_stream_closed (GrdVncPipeWireStream *stream,
                            GrdSessionVnc        *session_vnc)
@@ -772,5 +778,7 @@ grd_session_vnc_class_init (GrdSessionVncClass *klass)
   object_class->dispose = grd_session_vnc_dispose;
 
   session_class->stop = grd_session_vnc_stop;
+  session_class->remote_desktop_session_started =
+    grd_session_vnc_remote_desktop_session_started;
   session_class->stream_ready = grd_session_vnc_stream_ready;
 }
diff --git a/src/grd-session.c b/src/grd-session.c
index c09aded7..e1bd68f5 100644
--- a/src/grd-session.c
+++ b/src/grd-session.c
@@ -74,7 +74,6 @@ typedef struct _GrdSessionPrivate
   GrdDBusRemoteDesktopSession *remote_desktop_session;
   GrdDBusScreenCastSession *screen_cast_session;
 
-  GrdStream *stream;
   GHashTable *stream_table;
 
   GrdClipboard *clipboard;
@@ -133,9 +132,6 @@ grd_session_stop (GrdSession *session)
   g_clear_signal_handler (&priv->num_lock_state_changed_id,
                           priv->remote_desktop_session);
 
-  if (priv->stream)
-    grd_stream_disconnect_proxy_signals (priv->stream);
-
   g_clear_object (&priv->remote_desktop_session);
   g_clear_object (&priv->screen_cast_session);
 
@@ -692,80 +688,6 @@ start_session (GrdSession *session)
                                               session);
 }
 
-static void
-on_screen_cast_stream_proxy_acquired_ex (GObject      *object,
-                                         GAsyncResult *result,
-                                         gpointer      user_data)
-{
-  GrdDBusScreenCastStream *stream_proxy;
-  GrdSession *session;
-  GrdSessionPrivate *priv;
-  g_autoptr (GError) error = NULL;
-  GrdStream *stream;
-
-  stream_proxy = grd_dbus_screen_cast_stream_proxy_new_finish (result, &error);
-  if (!stream_proxy)
-    {
-      if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
-        return;
-
-      g_warning ("Failed to acquire stream proxy: %s", error->message);
-      grd_session_stop (GRD_SESSION (user_data));
-      return;
-    }
-
-  session = GRD_SESSION (user_data);
-  priv = grd_session_get_instance_private (session);
-
-  stream = grd_stream_new (priv->context, stream_proxy);
-  g_signal_connect (stream, "ready", G_CALLBACK (on_stream_ready),
-                    session);
-  g_signal_connect (stream, "closed", G_CALLBACK (on_stream_closed),
-                    session);
-  priv->stream = stream;
-
-  start_session (session);
-}
-
-static void
-on_record_monitor_finished (GObject      *object,
-                            GAsyncResult *result,
-                            gpointer      user_data)
-{
-  GrdDBusScreenCastSession *proxy;
-  GrdSession *session;
-  GrdSessionPrivate *priv;
-  GDBusConnection *connection;
-  g_autofree char *stream_path = NULL;
-  g_autoptr (GError) error = NULL;
-
-  proxy = GRD_DBUS_SCREEN_CAST_SESSION (object);
-  if (!grd_dbus_screen_cast_session_call_record_monitor_finish (proxy,
-                                                                &stream_path,
-                                                                result,
-                                                                &error))
-    {
-      if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
-        return;
-
-      g_warning ("Failed to record monitor: %s", error->message);
-      grd_session_stop (GRD_SESSION (user_data));
-      return;
-    }
-
-  session = GRD_SESSION (user_data);
-  priv = grd_session_get_instance_private (session);
-
-  connection = g_dbus_proxy_get_connection (G_DBUS_PROXY (proxy));
-  grd_dbus_screen_cast_stream_proxy_new (connection,
-                                         G_DBUS_PROXY_FLAGS_NONE,
-                                         MUTTER_SCREEN_CAST_BUS_NAME,
-                                         stream_path,
-                                         priv->cancellable,
-                                         on_screen_cast_stream_proxy_acquired_ex,
-                                         session);
-}
-
 static void
 on_screen_cast_session_proxy_acquired (GObject      *object,
                                        GAsyncResult *result,
@@ -774,7 +696,6 @@ on_screen_cast_session_proxy_acquired (GObject      *object,
   GrdDBusScreenCastSession *session_proxy;
   GrdSession *session;
   GrdSessionPrivate *priv;
-  GVariantBuilder properties_builder;
   g_autoptr (GError) error = NULL;
 
   session_proxy =
@@ -795,18 +716,7 @@ on_screen_cast_session_proxy_acquired (GObject      *object,
 
   priv->screen_cast_session = session_proxy;
 
-  g_variant_builder_init (&properties_builder, G_VARIANT_TYPE ("a{sv}"));
-  g_variant_builder_add (&properties_builder, "{sv}",
-                         "cursor-mode",
-                         g_variant_new_uint32 (GRD_SCREEN_CAST_CURSOR_MODE_METADATA));
-
-  /* TODO: Support something other than primary monitor */
-  grd_dbus_screen_cast_session_call_record_monitor (session_proxy,
-                                                    "",
-                                                    g_variant_builder_end (&properties_builder),
-                                                    priv->cancellable,
-                                                    on_record_monitor_finished,
-                                                    session);
+  start_session (session);
 }
 
 static void
@@ -1100,8 +1010,6 @@ grd_session_dispose (GObject *object)
   GrdSession *session = GRD_SESSION (object);
   GrdSessionPrivate *priv = grd_session_get_instance_private (session);
 
-  g_clear_object (&priv->stream);
-
   g_hash_table_remove_all (priv->stream_table);
 
   G_OBJECT_CLASS (grd_session_parent_class)->dispose (object);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]