Introduce the concept of a Node

Make an object for a processing node.
Implement a sink node. Make it possible to implement Sink and Source
interfaces to provide input/output from the node.
Improve pinosdepay to track fds and handle format changes.
This commit is contained in:
Wim Taymans 2016-05-05 13:31:18 +02:00
parent 7597e48e02
commit b885d40390
27 changed files with 3150 additions and 160 deletions

View file

@ -148,6 +148,7 @@ handle_create_source_channel (PinosClient1 *interface,
{
PinosClient *client = user_data;
PinosClientPrivate *priv = client->priv;
PinosNode *node;
PinosSource *source;
PinosChannel *channel;
const gchar *object_path, *sender;
@ -162,11 +163,15 @@ handle_create_source_channel (PinosClient1 *interface,
formats = g_bytes_new (arg_accepted_formats, strlen (arg_accepted_formats) + 1);
props = pinos_properties_from_variant (arg_properties);
source = pinos_daemon_find_source (priv->daemon,
arg_source,
props,
formats,
&error);
node = pinos_daemon_find_node (priv->daemon,
arg_source,
props,
formats,
&error);
if (node == NULL)
goto no_node;
source = pinos_node_get_source (node);
if (source == NULL)
goto no_source;
@ -190,7 +195,7 @@ handle_create_source_channel (PinosClient1 *interface,
client);
object_path = pinos_channel_get_object_path (channel);
g_debug ("client %p: add channel %p, %s", client, channel, object_path);
g_debug ("client %p: add source channel %p, %s", client, channel, object_path);
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(o)", object_path));
@ -203,18 +208,124 @@ not_allowed:
"org.pinos.Error", "not client owner");
return TRUE;
}
no_source:
no_node:
{
g_debug ("client %p: could not find source %s, %s", client, arg_source, error->message);
g_debug ("client %p: could not find node %s, %s", client, arg_source, error->message);
g_dbus_method_invocation_return_gerror (invocation, error);
pinos_properties_free (props);
g_bytes_unref (formats);
g_clear_error (&error);
return TRUE;
}
no_source:
{
g_debug ("client %p: node %s is not a source", client, arg_source);
g_dbus_method_invocation_return_dbus_error (invocation,
"org.pinos.Error", "not node is not a source");
pinos_properties_free (props);
g_bytes_unref (formats);
return TRUE;
}
no_channel:
{
g_debug ("client %p: could not channel %s", client, error->message);
g_debug ("client %p: could not create source channel %s", client, error->message);
g_dbus_method_invocation_return_gerror (invocation, error);
g_clear_error (&error);
return TRUE;
}
}
static gboolean
handle_create_sink_channel (PinosClient1 *interface,
GDBusMethodInvocation *invocation,
const gchar *arg_sink,
const gchar *arg_accepted_formats,
GVariant *arg_properties,
gpointer user_data)
{
PinosClient *client = user_data;
PinosClientPrivate *priv = client->priv;
PinosNode *node;
PinosSink *sink;
PinosChannel *channel;
const gchar *object_path, *sender;
GBytes *formats;
PinosProperties *props;
GError *error = NULL;
sender = g_dbus_method_invocation_get_sender (invocation);
if (g_strcmp0 (pinos_client_get_sender (client), sender) != 0)
goto not_allowed;
formats = g_bytes_new (arg_accepted_formats, strlen (arg_accepted_formats) + 1);
props = pinos_properties_from_variant (arg_properties);
node = pinos_daemon_find_node (priv->daemon,
arg_sink,
props,
formats,
&error);
if (node == NULL)
goto no_node;
sink = pinos_node_get_sink (node);
if (sink == NULL)
goto no_sink;
channel = pinos_sink_create_channel (sink,
priv->object_path,
formats,
props,
priv->object_path,
&error);
pinos_properties_free (props);
g_bytes_unref (formats);
if (channel == NULL)
goto no_channel;
priv->channels = g_list_prepend (priv->channels, channel);
g_signal_connect (channel,
"remove",
(GCallback) handle_remove_channel,
client);
object_path = pinos_channel_get_object_path (channel);
g_debug ("client %p: add sink channel %p, %s", client, channel, object_path);
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(o)", object_path));
return TRUE;
/* ERRORS */
not_allowed:
{
g_dbus_method_invocation_return_dbus_error (invocation,
"org.pinos.Error", "not client owner");
return TRUE;
}
no_node:
{
g_debug ("client %p: could not find node %s, %s", client, arg_sink, error->message);
g_dbus_method_invocation_return_gerror (invocation, error);
pinos_properties_free (props);
g_bytes_unref (formats);
g_clear_error (&error);
return TRUE;
}
no_sink:
{
g_debug ("client %p: node %s is not a sink", client, arg_sink);
g_dbus_method_invocation_return_dbus_error (invocation,
"org.pinos.Error", "node is not a sink");
pinos_properties_free (props);
g_bytes_unref (formats);
return TRUE;
}
no_channel:
{
g_debug ("client %p: could not create sink channel %s", client, error->message);
g_dbus_method_invocation_return_gerror (invocation, error);
g_clear_error (&error);
return TRUE;
@ -298,7 +409,7 @@ no_source:
}
no_channel:
{
g_debug ("client %p: could not create channel %s", client, error->message);
g_debug ("client %p: could not create upload channel %s", client, error->message);
g_dbus_method_invocation_return_gerror (invocation, error);
g_object_unref (source);
g_clear_error (&error);
@ -340,6 +451,9 @@ client_register_object (PinosClient *client,
g_signal_connect (priv->client1, "handle-create-source-channel",
(GCallback) handle_create_source_channel,
client);
g_signal_connect (priv->client1, "handle-create-sink-channel",
(GCallback) handle_create_sink_channel,
client);
g_signal_connect (priv->client1, "handle-create-upload-channel",
(GCallback) handle_create_upload_channel,
client);