mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Move CreateSourceOutput to client object
Move the CreateSourceOutput method back to the client object so that we can leave the selection of the source in the server.
This commit is contained in:
parent
d9444ab360
commit
7bb3ae2562
10 changed files with 124 additions and 84 deletions
|
|
@ -614,18 +614,3 @@ pv_context_get_error (PvContext *context)
|
|||
|
||||
return priv->error;
|
||||
}
|
||||
|
||||
GDBusProxy *
|
||||
pv_context_find_source (PvContext *context, const gchar *name, GVariant *props)
|
||||
{
|
||||
PvContextPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (PV_IS_CONTEXT (context), NULL);
|
||||
priv = context->priv;
|
||||
|
||||
if (priv->sources == NULL)
|
||||
return NULL;
|
||||
|
||||
return priv->sources->data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,3 @@ struct _PvContextPrivate
|
|||
|
||||
GDBusObjectManagerServer *server_manager;
|
||||
};
|
||||
|
||||
GDBusProxy * pv_context_find_source (PvContext *context, const gchar *name, GVariant *props);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ struct _PvStreamPrivate
|
|||
GError *error;
|
||||
|
||||
gchar *source_output_path;
|
||||
GDBusProxy *source;
|
||||
GVariant *spec;
|
||||
GDBusProxy *source_output;
|
||||
|
||||
|
|
@ -380,7 +379,7 @@ on_source_output_created (GObject *source_object,
|
|||
|
||||
g_assert (g_main_context_get_thread_default () == priv->context->priv->context);
|
||||
|
||||
ret = g_dbus_proxy_call_finish (priv->source, res, &error);
|
||||
ret = g_dbus_proxy_call_finish (context->priv->client, res, &error);
|
||||
if (ret == NULL)
|
||||
goto create_failed;
|
||||
|
||||
|
|
@ -412,12 +411,15 @@ static gboolean
|
|||
do_connect_capture (PvStream *stream)
|
||||
{
|
||||
PvStreamPrivate *priv = stream->priv;
|
||||
PvContext *context = priv->context;
|
||||
|
||||
g_assert (g_main_context_get_thread_default () == priv->context->priv->context);
|
||||
|
||||
g_dbus_proxy_call (priv->source,
|
||||
g_dbus_proxy_call (context->priv->client,
|
||||
"CreateSourceOutput",
|
||||
g_variant_new ("(@a{sv})", priv->spec),
|
||||
g_variant_new ("(o@a{sv})",
|
||||
(priv->target ? priv->target : "/"),
|
||||
priv->spec),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
NULL, /* GCancellable *cancellable */
|
||||
|
|
@ -454,12 +456,6 @@ pv_stream_connect_capture (PvStream *stream,
|
|||
g_return_val_if_fail (pv_context_get_state (context) == PV_CONTEXT_STATE_READY, FALSE);
|
||||
|
||||
priv->target = g_strdup (source);
|
||||
|
||||
priv->source = pv_context_find_source (context, priv->target, NULL);
|
||||
if (priv->source == NULL) {
|
||||
g_warning ("can't find source");
|
||||
return FALSE;
|
||||
}
|
||||
priv->spec = spec;
|
||||
|
||||
stream_set_state (stream, PV_STREAM_STATE_CONNECTING);
|
||||
|
|
@ -481,7 +477,7 @@ on_source_output_removed (GObject *source_object,
|
|||
|
||||
g_assert (g_main_context_get_thread_default () == priv->context->priv->context);
|
||||
|
||||
ret = g_dbus_proxy_call_finish (priv->source, res, &error);
|
||||
ret = g_dbus_proxy_call_finish (priv->source_output, res, &error);
|
||||
if (ret == NULL) {
|
||||
priv->error = error;
|
||||
stream_set_state (stream, PV_STREAM_STATE_ERROR);
|
||||
|
|
|
|||
|
|
@ -104,6 +104,9 @@ gboolean pv_stream_connect_capture (PvStream *stream,
|
|||
const gchar *source,
|
||||
PvStreamFlags flags,
|
||||
GVariant *spec);
|
||||
gboolean pv_stream_connect_provide (PvStream *stream,
|
||||
PvStreamFlags flags,
|
||||
GVariant *spec);
|
||||
gboolean pv_stream_disconnect (PvStream *stream);
|
||||
|
||||
gboolean pv_stream_start (PvStream *stream, PvStreamMode mode);
|
||||
|
|
@ -111,6 +114,8 @@ gboolean pv_stream_stop (PvStream *stream);
|
|||
|
||||
gboolean pv_stream_capture_buffer (PvStream *stream,
|
||||
PvBufferInfo *info);
|
||||
gboolean pv_stream_provide_buffer (PvStream *stream,
|
||||
PvBufferInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,18 @@
|
|||
Disconnect the client from the server.
|
||||
-->
|
||||
<method name='Disconnect'/>
|
||||
<!-- CreateSourceOutput:
|
||||
@source: the Source1 object path or / for default
|
||||
@props: input properties
|
||||
@output: the SourceOutput1 object path
|
||||
|
||||
Create a new output for @source with given @props
|
||||
-->
|
||||
<method name='CreateSourceOutput'>
|
||||
<arg type='o' name='source' direction='in'/>
|
||||
<arg type='a{sv}' name='props' direction='in'/>
|
||||
<arg type='o' name='output' direction='out'/>
|
||||
</method>
|
||||
</interface>
|
||||
|
||||
<!--
|
||||
|
|
@ -111,16 +123,6 @@
|
|||
<arg type='a{sv}' name='props' direction='in'/>
|
||||
<arg type='aa{sv}' name='caps' direction='out'/>
|
||||
</method>
|
||||
<!-- CreateSourceOutput:
|
||||
@props: input properties
|
||||
@output: the SourceOutput1 object path
|
||||
|
||||
Create a new output for this source with given @props
|
||||
-->
|
||||
<method name='CreateSourceOutput'>
|
||||
<arg type='a{sv}' name='props' direction='in'/>
|
||||
<arg type='o' name='output' direction='out'/>
|
||||
</method>
|
||||
</interface>
|
||||
|
||||
<!--
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ on_socket_notify (GObject *gobject,
|
|||
|
||||
g_object_get (gobject, "socket", &socket, NULL);
|
||||
|
||||
g_print ("source socket %p\n", socket);
|
||||
|
||||
if (socket == NULL) {
|
||||
if (priv->socket)
|
||||
g_signal_emit_by_name (priv->sink, "remove", priv->socket);
|
||||
|
|
|
|||
|
|
@ -103,6 +103,53 @@ pv_client_set_property (GObject *_object,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_create_source_output (PvClient1 *interface,
|
||||
GDBusMethodInvocation *invocation,
|
||||
const gchar *arg_source,
|
||||
GVariant *arg_properties,
|
||||
gpointer user_data)
|
||||
{
|
||||
PvClient *client = user_data;
|
||||
PvClientPrivate *priv = client->priv;
|
||||
PvSource *source;
|
||||
PvSourceOutput *output;
|
||||
const gchar *object_path, *sender;
|
||||
|
||||
source = pv_daemon_find_source (priv->daemon, arg_source, arg_properties);
|
||||
if (source == NULL)
|
||||
goto no_source;
|
||||
|
||||
output = pv_source_create_source_output (source, arg_properties, priv->object_path);
|
||||
if (output == NULL)
|
||||
goto no_output;
|
||||
|
||||
sender = g_dbus_method_invocation_get_sender (invocation);
|
||||
|
||||
pv_daemon_track_object (priv->daemon, sender, G_OBJECT (output));
|
||||
|
||||
object_path = pv_source_output_get_object_path (output);
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(o)", object_path));
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
no_source:
|
||||
{
|
||||
g_dbus_method_invocation_return_dbus_error (invocation,
|
||||
"org.pulsevideo.Error", "Can't create sourc");
|
||||
return TRUE;
|
||||
}
|
||||
no_output:
|
||||
{
|
||||
g_dbus_method_invocation_return_dbus_error (invocation,
|
||||
"org.pulsevideo.Error", "Can't create output");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
client_register_object (PvClient *client, const gchar *prefix)
|
||||
{
|
||||
|
|
@ -117,6 +164,9 @@ client_register_object (PvClient *client, const gchar *prefix)
|
|||
|
||||
priv->client1 = pv_client1_skeleton_new ();
|
||||
pv_client1_set_name (priv->client1, priv->sender);
|
||||
g_signal_connect (priv->client1, "handle-create-source-output",
|
||||
(GCallback) handle_create_source_output,
|
||||
client);
|
||||
pv_object_skeleton_set_client1 (skel, priv->client1);
|
||||
|
||||
g_free (priv->object_path);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ struct _PvDaemonPrivate
|
|||
GDBusObjectManagerServer *server_manager;
|
||||
PvSubscribe *subscribe;
|
||||
|
||||
GList *sources;
|
||||
|
||||
GHashTable *senders;
|
||||
};
|
||||
|
||||
|
|
@ -62,14 +64,8 @@ on_server_subscription_event (PvSubscribe *subscribe,
|
|||
|
||||
g_print ("got event %d %d %s:%s\n", event, flags, name, object_path);
|
||||
|
||||
switch (event) {
|
||||
case PV_SUBSCRIPTION_EVENT_NEW:
|
||||
break;
|
||||
|
||||
case PV_SUBSCRIPTION_EVENT_CHANGE:
|
||||
break;
|
||||
|
||||
case PV_SUBSCRIPTION_EVENT_REMOVE:
|
||||
switch (flags) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -347,6 +343,44 @@ pv_daemon_track_object (PvDaemon *daemon,
|
|||
data->objects = g_list_prepend (data->objects, object);
|
||||
}
|
||||
|
||||
void
|
||||
pv_daemon_add_source (PvDaemon *daemon, PvSource *source)
|
||||
{
|
||||
PvDaemonPrivate *priv;
|
||||
|
||||
g_return_if_fail (PV_IS_DAEMON (daemon));
|
||||
g_return_if_fail (PV_IS_SOURCE (source));
|
||||
priv = daemon->priv;
|
||||
|
||||
priv->sources = g_list_prepend (priv->sources, source);
|
||||
}
|
||||
|
||||
void
|
||||
pv_daemon_remove_source (PvDaemon *daemon, PvSource *source)
|
||||
{
|
||||
PvDaemonPrivate *priv;
|
||||
|
||||
g_return_if_fail (PV_IS_DAEMON (daemon));
|
||||
g_return_if_fail (PV_IS_SOURCE (source));
|
||||
priv = daemon->priv;
|
||||
|
||||
priv->sources = g_list_remove (priv->sources, source);
|
||||
}
|
||||
|
||||
PvSource *
|
||||
pv_daemon_find_source (PvDaemon *daemon, const gchar *name, GVariant *props)
|
||||
{
|
||||
PvDaemonPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (PV_IS_DAEMON (daemon), NULL);
|
||||
priv = daemon->priv;
|
||||
|
||||
if (priv->sources == NULL)
|
||||
return NULL;
|
||||
|
||||
return priv->sources->data;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE (PvDaemon, pv_daemon, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -73,6 +73,10 @@ void pv_daemon_unexport (PvDaemon *daemon, const gchar *nam
|
|||
|
||||
void pv_daemon_track_object (PvDaemon *daemon, const gchar *sender, GObject *object);
|
||||
|
||||
void pv_daemon_add_source (PvDaemon *daemon, PvSource *source);
|
||||
void pv_daemon_remove_source (PvDaemon *daemon, PvSource *source);
|
||||
PvSource * pv_daemon_find_source (PvDaemon *daemon, const gchar *name, GVariant *props);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __PV_DAEMON_H__ */
|
||||
|
|
|
|||
|
|
@ -128,40 +128,6 @@ pv_source_set_property (GObject *_object,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_create_source_output (PvSource1 *interface,
|
||||
GDBusMethodInvocation *invocation,
|
||||
GVariant *arg_properties,
|
||||
gpointer user_data)
|
||||
{
|
||||
PvSource *source = user_data;
|
||||
PvSourcePrivate *priv = source->priv;
|
||||
PvSourceOutput *output;
|
||||
const gchar *object_path, *sender;
|
||||
|
||||
output = pv_source_create_source_output (source, arg_properties, priv->object_path);
|
||||
if (output == NULL)
|
||||
goto no_output;
|
||||
|
||||
sender = g_dbus_method_invocation_get_sender (invocation);
|
||||
|
||||
pv_daemon_track_object (priv->daemon, sender, G_OBJECT (output));
|
||||
|
||||
object_path = pv_source_output_get_object_path (output);
|
||||
g_dbus_method_invocation_return_value (invocation,
|
||||
g_variant_new ("(o)", object_path));
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
no_output:
|
||||
{
|
||||
g_dbus_method_invocation_return_dbus_error (invocation,
|
||||
"org.pulsevideo.Error", "Can't create output");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
handle_get_capabilities (PvSource1 *interface,
|
||||
GDBusMethodInvocation *invocation,
|
||||
|
|
@ -194,9 +160,6 @@ source_register_object (PvSource *source)
|
|||
"state", priv->state,
|
||||
"properties", priv->properties,
|
||||
NULL);
|
||||
g_signal_connect (priv->iface, "handle-create-source-output",
|
||||
(GCallback) handle_create_source_output,
|
||||
source);
|
||||
g_signal_connect (priv->iface, "handle-get-capabilities",
|
||||
(GCallback) handle_get_capabilities,
|
||||
source);
|
||||
|
|
@ -204,6 +167,7 @@ source_register_object (PvSource *source)
|
|||
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = pv_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
|
||||
pv_daemon_add_source (daemon, source);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -213,6 +177,7 @@ source_unregister_object (PvSource *source)
|
|||
{
|
||||
PvSourcePrivate *priv = source->priv;
|
||||
|
||||
pv_daemon_remove_source (priv->daemon, source);
|
||||
pv_daemon_unexport (priv->daemon, priv->object_path);
|
||||
g_clear_object (&priv->iface);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue