diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index e5a681b37..382d7d4a2 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -147,13 +147,9 @@ meta_screen_cast_monitor_stream_src_record_frame (MetaScreenCastStreamSrc *src, MetaScreenCastMonitorStreamSrc * meta_screen_cast_monitor_stream_src_new (MetaScreenCastMonitorStream *monitor_stream, - const char *stream_id, GError **error) { - return g_initable_new (META_TYPE_SCREEN_CAST_MONITOR_STREAM_SRC, - NULL, - error, - "stream-id", stream_id, + return g_initable_new (META_TYPE_SCREEN_CAST_MONITOR_STREAM_SRC, NULL, error, "stream", monitor_stream, NULL); } diff --git a/src/backends/meta-screen-cast-monitor-stream-src.h b/src/backends/meta-screen-cast-monitor-stream-src.h index 26a0d9150..7417a81e0 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.h +++ b/src/backends/meta-screen-cast-monitor-stream-src.h @@ -35,7 +35,6 @@ G_DECLARE_FINAL_TYPE (MetaScreenCastMonitorStreamSrc, MetaScreenCastStreamSrc) MetaScreenCastMonitorStreamSrc * meta_screen_cast_monitor_stream_src_new (MetaScreenCastMonitorStream *monitor_stream, - const char *stream_id, GError **error); #endif /* META_SCREEN_CAST_MONITOR_STREAM_SRC_H */ diff --git a/src/backends/meta-screen-cast-monitor-stream.c b/src/backends/meta-screen-cast-monitor-stream.c index e97a17356..1630b8eea 100644 --- a/src/backends/meta-screen-cast-monitor-stream.c +++ b/src/backends/meta-screen-cast-monitor-stream.c @@ -135,7 +135,6 @@ meta_screen_cast_monitor_stream_new (GDBusConnection *connection, static MetaScreenCastStreamSrc * meta_screen_cast_monitor_stream_create_src (MetaScreenCastStream *stream, - const char *stream_id, GError **error) { MetaScreenCastMonitorStream *monitor_stream = @@ -143,7 +142,6 @@ meta_screen_cast_monitor_stream_create_src (MetaScreenCastStream *stream, MetaScreenCastMonitorStreamSrc *monitor_stream_src; monitor_stream_src = meta_screen_cast_monitor_stream_src_new (monitor_stream, - stream_id, error); if (!monitor_stream_src) return NULL; diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c index 9204635a8..7f8217712 100644 --- a/src/backends/meta-screen-cast-stream-src.c +++ b/src/backends/meta-screen-cast-stream-src.c @@ -47,11 +47,11 @@ enum PROP_0, PROP_STREAM, - PROP_STREAM_ID, }; enum { + READY, CLOSED, N_SIGNALS @@ -81,7 +81,6 @@ typedef struct _MetaPipeWireSource typedef struct _MetaScreenCastStreamSrcPrivate { MetaScreenCastStream *stream; - char *stream_id; struct pw_core *pipewire_core; struct pw_remote *pipewire_remote; @@ -243,6 +242,9 @@ on_stream_state_changed (void *data, const char *error_message) { MetaScreenCastStreamSrc *src = data; + MetaScreenCastStreamSrcPrivate *priv = + meta_screen_cast_stream_src_get_instance_private (src); + uint32_t node_id; switch (state) { @@ -250,9 +252,12 @@ on_stream_state_changed (void *data, g_warning ("pipewire stream error: %s", error_message); meta_screen_cast_stream_src_notify_closed (src); break; + case PW_STREAM_STATE_CONFIGURE: + node_id = pw_stream_get_node_id (priv->pipewire_stream); + g_signal_emit (src, signals[READY], 0, (unsigned int) node_id); + break; case PW_STREAM_STATE_UNCONNECTED: case PW_STREAM_STATE_CONNECTING: - case PW_STREAM_STATE_CONFIGURE: case PW_STREAM_STATE_READY: case PW_STREAM_STATE_PAUSED: if (meta_screen_cast_stream_src_is_enabled (src)) @@ -585,7 +590,6 @@ meta_screen_cast_stream_src_finalize (GObject *object) pw_remote_destroy (priv->pipewire_remote); pw_core_destroy (priv->pipewire_core); g_source_destroy (&priv->pipewire_source->base); - g_clear_pointer (&priv->stream_id, g_free); G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object); } @@ -605,9 +609,6 @@ meta_screen_cast_stream_src_set_property (GObject *object, case PROP_STREAM: priv->stream = g_value_get_object (value); break;; - case PROP_STREAM_ID: - priv->stream_id = g_strdup (g_value_get_string (value)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -628,9 +629,6 @@ meta_screen_cast_stream_src_get_property (GObject *object, case PROP_STREAM: g_value_set_object (value, priv->stream); break; - case PROP_STREAM_ID: - g_value_set_string (value, priv->stream_id); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -659,16 +657,14 @@ meta_screen_cast_stream_src_class_init (MetaScreenCastStreamSrcClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (object_class, - PROP_STREAM_ID, - g_param_spec_string ("stream-id", - "stream-id", - "Unique stream ID", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + signals[READY] = g_signal_new ("ready", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 1, + G_TYPE_UINT); signals[CLOSED] = g_signal_new ("closed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, diff --git a/src/backends/meta-screen-cast-stream.c b/src/backends/meta-screen-cast-stream.c index 047f2877e..1a8ef6b8d 100644 --- a/src/backends/meta-screen-cast-stream.c +++ b/src/backends/meta-screen-cast-stream.c @@ -62,11 +62,9 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStream, static MetaScreenCastStreamSrc * meta_screen_cast_stream_create_src (MetaScreenCastStream *stream, - const char *stream_id, GError **error) { return META_SCREEN_CAST_STREAM_GET_CLASS (stream)->create_src (stream, - stream_id, error); } @@ -81,27 +79,32 @@ on_stream_src_closed (MetaScreenCastStreamSrc *src, meta_screen_cast_stream_close (stream); } +static void +on_stream_src_ready (MetaScreenCastStreamSrc *src, + uint32_t node_id, + MetaScreenCastStream *stream) +{ + MetaDBusScreenCastStream *skeleton = META_DBUS_SCREEN_CAST_STREAM (stream); + + meta_dbus_screen_cast_stream_emit_pipewire_stream_added (skeleton, node_id); +} + gboolean meta_screen_cast_stream_start (MetaScreenCastStream *stream, GError **error) { - MetaDBusScreenCastStream *skeleton = META_DBUS_SCREEN_CAST_STREAM (stream); MetaScreenCastStreamPrivate *priv = meta_screen_cast_stream_get_instance_private (stream); - g_autofree char *stream_id = NULL; MetaScreenCastStreamSrc *src; - static unsigned int global_stream_id = 0; - stream_id = g_strdup_printf ("%u", ++global_stream_id); - src = meta_screen_cast_stream_create_src (stream, stream_id, error); + src = meta_screen_cast_stream_create_src (stream, error); if (!src) return FALSE; priv->src = src; + g_signal_connect (src, "ready", G_CALLBACK (on_stream_src_ready), stream); g_signal_connect (src, "closed", G_CALLBACK (on_stream_src_closed), stream); - meta_dbus_screen_cast_stream_emit_pipewire_stream_added (skeleton, stream_id); - return TRUE; } diff --git a/src/backends/meta-screen-cast-stream.h b/src/backends/meta-screen-cast-stream.h index b8366aebb..1ed1a837c 100644 --- a/src/backends/meta-screen-cast-stream.h +++ b/src/backends/meta-screen-cast-stream.h @@ -38,7 +38,6 @@ struct _MetaScreenCastStreamClass MetaDBusScreenCastStreamSkeletonClass parent_class; MetaScreenCastStreamSrc * (* create_src) (MetaScreenCastStream *stream, - const char *stream_id, GError **error); }; diff --git a/src/org.gnome.Mutter.ScreenCast.xml b/src/org.gnome.Mutter.ScreenCast.xml index bab3fea20..f774091d8 100644 --- a/src/org.gnome.Mutter.ScreenCast.xml +++ b/src/org.gnome.Mutter.ScreenCast.xml @@ -99,7 +99,7 @@ --> - +