ScreenCast: Pass PipeWire stream node ID directly
As of commit 5f5ef3de2cdc816dab82cb7eb5d7171bee0ad2c5 in pipewire the stream creator can find out the node ID of the stream it created. So instead of using a special purpose entry to the info property box to let the application discover stream by monitoring added nodes searching for the given special purpose entry, just pass the node directly. https://bugzilla.gnome.org/show_bug.cgi?id=784199
This commit is contained in:
parent
920541fa26
commit
53175e8788
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ struct _MetaScreenCastStreamClass
|
||||
MetaDBusScreenCastStreamSkeletonClass parent_class;
|
||||
|
||||
MetaScreenCastStreamSrc * (* create_src) (MetaScreenCastStream *stream,
|
||||
const char *stream_id,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
|
@ -99,7 +99,7 @@
|
||||
-->
|
||||
<signal name="PipeWireStreamAdded">
|
||||
<annotation name="org.gtk.GDBus.C.Name" value="pipewire-stream-added"/>
|
||||
<arg name="stream_id" type="s" direction="out" />
|
||||
<arg name="node_id" type="u" direction="out" />
|
||||
</signal>
|
||||
|
||||
</interface>
|
||||
|
Loading…
Reference in New Issue
Block a user