[mutter] screen-cast-session: Allow stand alone screen cast sessions



commit 921b18f7131342c1d90dc94db073b263cf53afed
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Aug 15 15:25:09 2017 +0800

    screen-cast-session: Allow stand alone screen cast sessions
    
    When a screen cast session is stand-alone, i.e. not created given a
    remote desktop session managing it, allow calling the Start/Stop
    methods to start and stop it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784199

 src/backends/meta-screen-cast-session.c |   48 +++++++++++++++++++++++++++----
 1 files changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/src/backends/meta-screen-cast-session.c b/src/backends/meta-screen-cast-session.c
index e53f78d..907e645 100644
--- a/src/backends/meta-screen-cast-session.c
+++ b/src/backends/meta-screen-cast-session.c
@@ -105,9 +105,32 @@ static gboolean
 handle_start (MetaDBusScreenCastSession *skeleton,
               GDBusMethodInvocation     *invocation)
 {
-  g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                         G_DBUS_ERROR_FAILED,
-                                         "Stand alone screen casting not yet implemented");
+  MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (skeleton);
+  GError *error = NULL;
+
+  switch (session->session_type)
+    {
+    case META_SCREEN_CAST_SESSION_TYPE_NORMAL:
+      break;
+    case META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP:
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+                                             G_DBUS_ERROR_FAILED,
+                                             "Must be started from remote desktop session");
+      return TRUE;
+    }
+
+  if (!meta_screen_cast_session_start (session, &error))
+    {
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+                                             G_DBUS_ERROR_FAILED,
+                                             "Failed to start screen cast: %s",
+                                             error->message);
+      g_error_free (error);
+
+      return TRUE;
+    }
+
+  meta_dbus_screen_cast_session_complete_start (skeleton, invocation);
 
   return TRUE;
 }
@@ -116,9 +139,22 @@ static gboolean
 handle_stop (MetaDBusScreenCastSession *skeleton,
              GDBusMethodInvocation     *invocation)
 {
-  g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
-                                         G_DBUS_ERROR_FAILED,
-                                         "Stand alone screen casting not yet implemented");
+  MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (skeleton);
+
+  switch (session->session_type)
+    {
+    case META_SCREEN_CAST_SESSION_TYPE_NORMAL:
+      break;
+    case META_SCREEN_CAST_SESSION_TYPE_REMOTE_DESKTOP:
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+                                             G_DBUS_ERROR_FAILED,
+                                             "Must be stopped from remote desktop session");
+      return TRUE;
+    }
+
+  meta_screen_cast_session_close (session);
+
+  meta_dbus_screen_cast_session_complete_stop (skeleton, invocation);
 
   return TRUE;
 }


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