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

@ -23,7 +23,7 @@
#include "pinos/client/enumtypes.h"
#include "pinos/server/source.h"
#include "pinos/server/daemon.h"
#include "pinos/server/node.h"
#include "pinos/dbus/org-pinos.h"
@ -33,9 +33,8 @@
struct _PinosSourcePrivate
{
PinosDaemon *daemon;
PinosNode *node;
PinosSource1 *iface;
gchar *object_path;
gchar *name;
PinosProperties *properties;
@ -52,8 +51,7 @@ G_DEFINE_ABSTRACT_TYPE (PinosSource, pinos_source, G_TYPE_OBJECT);
enum
{
PROP_0,
PROP_DAEMON,
PROP_OBJECT_PATH,
PROP_NODE,
PROP_NAME,
PROP_STATE,
PROP_PROPERTIES
@ -69,12 +67,8 @@ pinos_source_get_property (GObject *_object,
PinosSourcePrivate *priv = source->priv;
switch (prop_id) {
case PROP_DAEMON:
g_value_set_object (value, priv->daemon);
break;
case PROP_OBJECT_PATH:
g_value_set_string (value, priv->object_path);
case PROP_NODE:
g_value_set_object (value, priv->node);
break;
case PROP_NAME:
@ -105,13 +99,8 @@ pinos_source_set_property (GObject *_object,
PinosSourcePrivate *priv = source->priv;
switch (prop_id) {
case PROP_DAEMON:
priv->daemon = g_value_dup_object (value);
break;
case PROP_OBJECT_PATH:
g_free (priv->object_path);
priv->object_path = g_value_dup_string (value);
case PROP_NODE:
priv->node = g_value_dup_object (value);
break;
case PROP_NAME:
@ -140,15 +129,11 @@ static void
source_register_object (PinosSource *source)
{
PinosSourcePrivate *priv = source->priv;
PinosDaemon *daemon = priv->daemon;
PinosObjectSkeleton *skel;
GBytes *formats;
GVariant *variant;
formats = pinos_source_get_formats (source, NULL, NULL);
skel = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_SOURCE);
if (priv->properties)
variant = pinos_properties_to_variant (priv->properties);
else
@ -160,12 +145,9 @@ source_register_object (PinosSource *source)
"properties", variant,
"possible-formats", g_bytes_get_data (formats, NULL),
NULL);
pinos_object_skeleton_set_source1 (skel, priv->iface);
g_bytes_unref (formats);
g_free (priv->object_path);
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
pinos_daemon_add_source (daemon, source);
pinos_node_set_source (priv->node, source, G_OBJECT (priv->iface));
return;
}
@ -175,8 +157,7 @@ source_unregister_object (PinosSource *source)
{
PinosSourcePrivate *priv = source->priv;
pinos_daemon_remove_source (priv->daemon, source);
pinos_daemon_unexport (priv->daemon, priv->object_path);
pinos_node_set_source (priv->node, NULL, NULL);
g_clear_object (&priv->iface);
}
@ -215,7 +196,6 @@ pinos_source_finalize (GObject * object)
PinosSource *source = PINOS_SOURCE (object);
PinosSourcePrivate *priv = source->priv;
g_free (priv->object_path);
g_free (priv->name);
if (priv->properties)
pinos_properties_free (priv->properties);
@ -256,10 +236,10 @@ default_create_channel (PinosSource *source,
if (possible_formats == NULL)
return NULL;
channel = g_object_new (PINOS_TYPE_CHANNEL, "daemon", priv->daemon,
channel = g_object_new (PINOS_TYPE_CHANNEL, "daemon", pinos_node_get_daemon (priv->node),
"object-path", prefix,
"client-path", client_path,
"owner-path", priv->object_path,
"owner-path", pinos_node_get_object_path (priv->node),
"possible-formats", possible_formats,
"properties", props,
NULL);
@ -319,21 +299,11 @@ pinos_source_class_init (PinosSourceClass * klass)
gobject_class->get_property = pinos_source_get_property;
g_object_class_install_property (gobject_class,
PROP_DAEMON,
g_param_spec_object ("daemon",
"Daemon",
"The Daemon",
PINOS_TYPE_DAEMON,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_OBJECT_PATH,
g_param_spec_string ("object-path",
"Object Path",
"The object path",
NULL,
PROP_NODE,
g_param_spec_object ("node",
"Node",
"The Node",
PINOS_TYPE_NODE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@ -674,22 +644,3 @@ pinos_source_release_channel (PinosSource *source,
return res;
}
/**
* pinos_source_get_object_path:
* @source: a #PinosSource
*
* Get the object path of @source.
*
* Returns: the object path of @source.
*/
const gchar *
pinos_source_get_object_path (PinosSource *source)
{
PinosSourcePrivate *priv;
g_return_val_if_fail (PINOS_IS_SOURCE (source), NULL);
priv = source->priv;
return priv->object_path;
}