167 lines
6.9 KiB
Diff
167 lines
6.9 KiB
Diff
|
From c865ffdb24d1a945f36a1bf873fe0900cbbade14 Mon Sep 17 00:00:00 2001
|
||
|
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||
|
Date: Thu, 11 Nov 2021 00:05:27 -0300
|
||
|
Subject: [PATCH] screencast: Pass stream ids
|
||
|
|
||
|
The stream id is any string that can uniquely
|
||
|
identify a stream within a screencast session.
|
||
|
Add that to the list of stream properties.
|
||
|
|
||
|
For now, only use a simple positional integer
|
||
|
as id.
|
||
|
---
|
||
|
src/gnomescreencast.c | 21 ++++++++++++++++++---
|
||
|
src/screencast.c | 5 ++++-
|
||
|
src/screencast.h | 1 +
|
||
|
src/screencastwidget.c | 4 ++++
|
||
|
4 files changed, 27 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/src/gnomescreencast.c b/src/gnomescreencast.c
|
||
|
index 3f8539c..482fcd0 100644
|
||
|
--- a/src/gnomescreencast.c
|
||
|
+++ b/src/gnomescreencast.c
|
||
|
@@ -59,6 +59,7 @@ typedef struct _GnomeScreenCastStream
|
||
|
|
||
|
ScreenCastSourceType source_type;
|
||
|
|
||
|
+ uint32_t id;
|
||
|
char *path;
|
||
|
OrgGnomeMutterScreenCastStream *proxy;
|
||
|
|
||
|
@@ -219,6 +220,7 @@ void
|
||
|
gnome_screen_cast_session_add_stream_properties (GnomeScreenCastSession *gnome_screen_cast_session,
|
||
|
GVariantBuilder *streams_builder)
|
||
|
{
|
||
|
+ char id[64] = { 0, };
|
||
|
GList *streams;
|
||
|
GList *l;
|
||
|
|
||
|
@@ -234,6 +236,10 @@ gnome_screen_cast_session_add_stream_properties (GnomeScreenCastSession *gnome_s
|
||
|
|
||
|
g_variant_builder_init (&stream_properties_builder, G_VARIANT_TYPE_VARDICT);
|
||
|
|
||
|
+ g_snprintf (id, G_N_ELEMENTS (id), "%u", stream->id);
|
||
|
+ g_variant_builder_add (&stream_properties_builder, "{sv}",
|
||
|
+ "id",
|
||
|
+ g_variant_new ("s", id));
|
||
|
g_variant_builder_add (&stream_properties_builder, "{sv}",
|
||
|
"source_type",
|
||
|
g_variant_new ("u", stream->source_type));
|
||
|
@@ -275,6 +281,7 @@ cursor_mode_to_gnome_cursor_mode (ScreenCastCursorMode cursor_mode)
|
||
|
|
||
|
static gboolean
|
||
|
gnome_screen_cast_session_record_window (GnomeScreenCastSession *gnome_screen_cast_session,
|
||
|
+ uint32_t id,
|
||
|
Window *window,
|
||
|
ScreenCastSelection *select,
|
||
|
GError **error)
|
||
|
@@ -327,6 +334,7 @@ gnome_screen_cast_session_record_window (GnomeScreenCastSession *gnome_screen_c
|
||
|
stream->session = gnome_screen_cast_session;
|
||
|
stream->path = g_strdup (stream_path);
|
||
|
stream->proxy = stream_proxy;
|
||
|
+ stream->id = id;
|
||
|
|
||
|
parameters = org_gnome_mutter_screen_cast_stream_get_parameters (stream->proxy);
|
||
|
if (parameters)
|
||
|
@@ -357,6 +365,7 @@ gnome_screen_cast_session_record_window (GnomeScreenCastSession *gnome_screen_c
|
||
|
|
||
|
static gboolean
|
||
|
gnome_screen_cast_session_record_monitor (GnomeScreenCastSession *gnome_screen_cast_session,
|
||
|
+ uint32_t id,
|
||
|
Monitor *monitor,
|
||
|
ScreenCastSelection *select,
|
||
|
GError **error)
|
||
|
@@ -409,6 +418,7 @@ gnome_screen_cast_session_record_monitor (GnomeScreenCastSession *gnome_screen_
|
||
|
stream->session = gnome_screen_cast_session;
|
||
|
stream->path = g_strdup (stream_path);
|
||
|
stream->proxy = stream_proxy;
|
||
|
+ stream->id = id;
|
||
|
|
||
|
parameters = org_gnome_mutter_screen_cast_stream_get_parameters (stream->proxy);
|
||
|
if (parameters)
|
||
|
@@ -453,6 +463,7 @@ gnome_screen_cast_session_record_selections (GnomeScreenCastSession *gnome_scre
|
||
|
{
|
||
|
case SCREEN_CAST_SOURCE_TYPE_MONITOR:
|
||
|
if (!gnome_screen_cast_session_record_monitor (gnome_screen_cast_session,
|
||
|
+ info->id,
|
||
|
info->data.monitor,
|
||
|
select,
|
||
|
error))
|
||
|
@@ -460,6 +471,7 @@ gnome_screen_cast_session_record_selections (GnomeScreenCastSession *gnome_scre
|
||
|
break;
|
||
|
case SCREEN_CAST_SOURCE_TYPE_WINDOW:
|
||
|
if (!gnome_screen_cast_session_record_window (gnome_screen_cast_session,
|
||
|
+ info->id,
|
||
|
info->data.window,
|
||
|
select,
|
||
|
error))
|
||
|
diff --git a/src/screencast.c b/src/screencast.c
|
||
|
index 55a3e5c..3be8337 100644
|
||
|
--- a/src/screencast.c
|
||
|
+++ b/src/screencast.c
|
||
|
@@ -162,7 +162,7 @@ serialize_streams_as_restore_data (ScreenCastSession *screen_cast_session,
|
||
|
|
||
|
g_variant_builder_add (&impl_builder,
|
||
|
"(uuv)",
|
||
|
- i,
|
||
|
+ info->id,
|
||
|
info->type,
|
||
|
stream_variant);
|
||
|
}
|
||
|
@@ -502,6 +502,7 @@ restore_stream_from_data (ScreenCastSession *screen_cast_session)
|
||
|
info = g_new0 (ScreenCastStreamInfo, 1);
|
||
|
info->type = SCREEN_CAST_SOURCE_TYPE_MONITOR;
|
||
|
info->data.monitor = monitor;
|
||
|
+ info->id = id;
|
||
|
g_ptr_array_add (streams, info);
|
||
|
}
|
||
|
break;
|
||
|
@@ -526,6 +527,7 @@ restore_stream_from_data (ScreenCastSession *screen_cast_session)
|
||
|
info = g_new0 (ScreenCastStreamInfo, 1);
|
||
|
info->type = SCREEN_CAST_SOURCE_TYPE_WINDOW;
|
||
|
info->data.window = window;
|
||
|
+ info->id = id;
|
||
|
g_ptr_array_add (streams, info);
|
||
|
}
|
||
|
break;
|
||
|
diff --git a/src/screencast.h b/src/screencast.h
|
||
|
index d78066e..3d64b4a 100644
|
||
|
--- a/src/screencast.h
|
||
|
+++ b/src/screencast.h
|
||
|
@@ -55,6 +55,7 @@ typedef struct _ScreenCastSelection
|
||
|
typedef struct
|
||
|
{
|
||
|
ScreenCastSourceType type;
|
||
|
+ uint32_t id;
|
||
|
union {
|
||
|
Monitor *monitor;
|
||
|
Window *window;
|
||
|
diff --git a/src/screencastwidget.c b/src/screencastwidget.c
|
||
|
index c100ad9..20df194 100644
|
||
|
--- a/src/screencastwidget.c
|
||
|
+++ b/src/screencastwidget.c
|
||
|
@@ -597,6 +597,7 @@ screen_cast_widget_get_selected_streams (ScreenCastWidget *self)
|
||
|
g_autoptr(GPtrArray) streams = NULL;
|
||
|
g_autoptr(GList) selected_monitor_rows = NULL;
|
||
|
g_autoptr(GList) selected_window_rows = NULL;
|
||
|
+ uint32_t id = 0;
|
||
|
GList *l;
|
||
|
|
||
|
streams = g_ptr_array_new_with_free_func (g_free);
|
||
|
@@ -620,6 +621,7 @@ screen_cast_widget_get_selected_streams (ScreenCastWidget *self)
|
||
|
info = g_new0 (ScreenCastStreamInfo, 1);
|
||
|
info->type = SCREEN_CAST_SOURCE_TYPE_MONITOR;
|
||
|
info->data.monitor = monitor;
|
||
|
+ info->id = id++;
|
||
|
g_ptr_array_add (streams, info);
|
||
|
}
|
||
|
|
||
|
@@ -634,6 +636,7 @@ screen_cast_widget_get_selected_streams (ScreenCastWidget *self)
|
||
|
info = g_new0 (ScreenCastStreamInfo, 1);
|
||
|
info->type = SCREEN_CAST_SOURCE_TYPE_WINDOW;
|
||
|
info->data.window = window;
|
||
|
+ info->id = id++;
|
||
|
g_ptr_array_add (streams, info);
|
||
|
}
|
||
|
|