mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-21 07:00:08 -05:00
Add provide mode to pinossink
Add a mode to provide a stream to pinossink Small improvements, leak fixes.
This commit is contained in:
parent
ba4ef9b5d9
commit
20c50772fa
20 changed files with 309 additions and 212 deletions
|
|
@ -182,16 +182,16 @@ pinos_channel_set_property (GObject *_object,
|
|||
if (priv->properties)
|
||||
pinos_properties_free (priv->properties);
|
||||
priv->properties = g_value_dup_boxed (value);
|
||||
g_object_set (priv->iface, "properties",
|
||||
pinos_properties_to_variant (priv->properties), NULL);
|
||||
g_object_set (priv->iface, "properties", priv->properties ?
|
||||
pinos_properties_to_variant (priv->properties) : NULL, NULL);
|
||||
break;
|
||||
|
||||
case PROP_FORMAT:
|
||||
if (priv->format)
|
||||
g_bytes_unref (priv->format);
|
||||
priv->format = g_value_dup_boxed (value);
|
||||
g_object_set (priv->iface, "format",
|
||||
g_bytes_get_data (priv->format, NULL), NULL);
|
||||
g_object_set (priv->iface, "format", priv->format ?
|
||||
g_bytes_get_data (priv->format, NULL) : NULL, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -346,6 +346,8 @@ channel_register_object (PinosChannel *channel)
|
|||
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = pinos_daemon_export_uniquely (priv->daemon, G_DBUS_OBJECT_SKELETON (skel));
|
||||
g_object_unref (skel);
|
||||
|
||||
g_debug ("channel %p: register object %s", channel, priv->object_path);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@
|
|||
struct _PinosClientPrivate
|
||||
{
|
||||
PinosDaemon *daemon;
|
||||
PinosClient1 *iface;
|
||||
|
||||
gchar *sender;
|
||||
gchar *object_path;
|
||||
PinosProperties *properties;
|
||||
|
||||
PinosClient1 *client1;
|
||||
|
||||
PinosFdManager *fdmanager;
|
||||
GList *channels;
|
||||
};
|
||||
|
|
@ -108,16 +108,15 @@ pinos_client_set_property (GObject *_object,
|
|||
|
||||
case PROP_SENDER:
|
||||
priv->sender = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_PATH:
|
||||
priv->object_path = g_value_dup_string (value);
|
||||
pinos_client1_set_sender (priv->iface, priv->sender);
|
||||
break;
|
||||
|
||||
case PROP_PROPERTIES:
|
||||
if (priv->properties)
|
||||
pinos_properties_free (priv->properties);
|
||||
priv->properties = g_value_dup_boxed (value);
|
||||
pinos_client1_set_properties (priv->iface, priv->properties ?
|
||||
pinos_properties_to_variant (priv->properties) : NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -324,34 +323,20 @@ handle_disconnect (PinosClient1 *interface,
|
|||
}
|
||||
|
||||
static void
|
||||
client_register_object (PinosClient *client,
|
||||
const gchar *prefix)
|
||||
client_register_object (PinosClient *client)
|
||||
{
|
||||
PinosClientPrivate *priv = client->priv;
|
||||
PinosDaemon *daemon = priv->daemon;
|
||||
PinosObjectSkeleton *skel;
|
||||
gchar *name;
|
||||
|
||||
name = g_strdup_printf ("%s/client", prefix);
|
||||
skel = pinos_object_skeleton_new (name);
|
||||
g_free (name);
|
||||
skel = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_CLIENT);
|
||||
|
||||
priv->client1 = pinos_client1_skeleton_new ();
|
||||
pinos_client1_set_name (priv->client1, priv->sender);
|
||||
pinos_client1_set_properties (priv->client1, pinos_properties_to_variant (priv->properties));
|
||||
g_signal_connect (priv->client1, "handle-create-channel",
|
||||
(GCallback) handle_create_channel,
|
||||
client);
|
||||
g_signal_connect (priv->client1, "handle-create-upload-channel",
|
||||
(GCallback) handle_create_upload_channel,
|
||||
client);
|
||||
g_signal_connect (priv->client1, "handle-disconnect",
|
||||
(GCallback) handle_disconnect,
|
||||
client);
|
||||
pinos_object_skeleton_set_client1 (skel, priv->client1);
|
||||
pinos_object_skeleton_set_client1 (skel, priv->iface);
|
||||
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
|
||||
g_object_unref (skel);
|
||||
|
||||
g_debug ("client %p: register %s", client, priv->object_path);
|
||||
}
|
||||
|
||||
|
|
@ -362,18 +347,7 @@ client_unregister_object (PinosClient *client)
|
|||
PinosDaemon *daemon = priv->daemon;
|
||||
|
||||
g_debug ("client %p: unregister", client);
|
||||
g_clear_object (&priv->client1);
|
||||
|
||||
pinos_daemon_unexport (daemon, priv->object_path);
|
||||
g_clear_pointer (&priv->object_path, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
do_remove_channel (PinosChannel *channel,
|
||||
PinosClient *client)
|
||||
{
|
||||
g_debug ("client %p: remove channel %p", client, channel);
|
||||
pinos_channel_remove (channel);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -381,14 +355,14 @@ pinos_client_dispose (GObject * object)
|
|||
{
|
||||
PinosClient *client = PINOS_CLIENT (object);
|
||||
PinosClientPrivate *priv = client->priv;
|
||||
GList *copy;
|
||||
|
||||
g_debug ("client %p: dispose", client);
|
||||
if (priv->object_path)
|
||||
pinos_fd_manager_remove_all (priv->fdmanager, priv->object_path);
|
||||
pinos_fd_manager_remove_all (priv->fdmanager, priv->object_path);
|
||||
|
||||
g_list_foreach (priv->channels, (GFunc) do_remove_channel, client);
|
||||
copy = g_list_copy (priv->channels);
|
||||
g_list_free_full (copy, (GDestroyNotify) pinos_channel_remove);
|
||||
client_unregister_object (client);
|
||||
g_clear_object (&priv->daemon);
|
||||
|
||||
G_OBJECT_CLASS (pinos_client_parent_class)->dispose (object);
|
||||
}
|
||||
|
|
@ -400,7 +374,10 @@ pinos_client_finalize (GObject * object)
|
|||
PinosClientPrivate *priv = client->priv;
|
||||
|
||||
g_debug ("client %p: finalize", client);
|
||||
g_clear_object (&priv->daemon);
|
||||
g_clear_object (&priv->iface);
|
||||
g_free (priv->sender);
|
||||
g_free (priv->object_path);
|
||||
if (priv->properties)
|
||||
pinos_properties_free (priv->properties);
|
||||
g_clear_object (&priv->fdmanager);
|
||||
|
|
@ -412,11 +389,9 @@ static void
|
|||
pinos_client_constructed (GObject * object)
|
||||
{
|
||||
PinosClient *client = PINOS_CLIENT (object);
|
||||
PinosClientPrivate *priv = client->priv;
|
||||
|
||||
g_debug ("client %p: constructed", client);
|
||||
|
||||
client_register_object (client, priv->object_path);
|
||||
client_register_object (client);
|
||||
|
||||
G_OBJECT_CLASS (pinos_client_parent_class)->constructed (object);
|
||||
}
|
||||
|
|
@ -460,8 +435,7 @@ pinos_client_class_init (PinosClientClass * klass)
|
|||
"Object Path",
|
||||
"The object path",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PROPERTIES,
|
||||
|
|
@ -491,6 +465,17 @@ pinos_client_init (PinosClient * client)
|
|||
{
|
||||
PinosClientPrivate *priv = client->priv = PINOS_CLIENT_GET_PRIVATE (client);
|
||||
|
||||
priv->iface = pinos_client1_skeleton_new ();
|
||||
g_signal_connect (priv->iface, "handle-create-channel",
|
||||
(GCallback) handle_create_channel,
|
||||
client);
|
||||
g_signal_connect (priv->iface, "handle-create-upload-channel",
|
||||
(GCallback) handle_create_upload_channel,
|
||||
client);
|
||||
g_signal_connect (priv->iface, "handle-disconnect",
|
||||
(GCallback) handle_disconnect,
|
||||
client);
|
||||
|
||||
g_debug ("client %p: new", client);
|
||||
priv->fdmanager = pinos_fd_manager_get (PINOS_FD_MANAGER_DEFAULT);
|
||||
}
|
||||
|
|
@ -510,15 +495,12 @@ pinos_client_init (PinosClient * client)
|
|||
PinosClient *
|
||||
pinos_client_new (PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
const gchar *prefix,
|
||||
PinosProperties *properties)
|
||||
{
|
||||
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
||||
g_return_val_if_fail (g_variant_is_object_path (prefix), NULL);
|
||||
|
||||
return g_object_new (PINOS_TYPE_CLIENT, "daemon", daemon,
|
||||
"sender", sender,
|
||||
"object-path", prefix,
|
||||
"properties", properties,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ GType pinos_client_get_type (void);
|
|||
|
||||
PinosClient * pinos_client_new (PinosDaemon *daemon,
|
||||
const gchar *sender,
|
||||
const gchar *prefix,
|
||||
PinosProperties *properties);
|
||||
|
||||
const gchar * pinos_client_get_sender (PinosClient *client);
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ handle_connect_client (PinosDaemon1 *interface,
|
|||
g_debug ("daemon %p: connect client: %s", daemon, sender);
|
||||
|
||||
props = pinos_properties_from_variant (arg_properties);
|
||||
client = pinos_client_new (daemon, sender, PINOS_DBUS_OBJECT_PREFIX, props);
|
||||
client = pinos_client_new (daemon, sender, props);
|
||||
pinos_properties_free (props);
|
||||
|
||||
g_signal_connect (client, "disconnect", (GCallback) handle_disconnect_client, daemon);
|
||||
|
|
|
|||
|
|
@ -112,14 +112,14 @@ pinos_node_set_property (GObject *_object,
|
|||
|
||||
case PROP_NAME:
|
||||
priv->name = g_value_dup_string (value);
|
||||
pinos_node1_set_name (priv->iface, priv->name);
|
||||
break;
|
||||
|
||||
case PROP_PROPERTIES:
|
||||
if (priv->properties)
|
||||
pinos_properties_free (priv->properties);
|
||||
priv->properties = g_value_dup_boxed (value);
|
||||
if (priv->iface)
|
||||
pinos_node1_set_properties (priv->iface,
|
||||
pinos_node1_set_properties (priv->iface,
|
||||
priv->properties ? pinos_properties_to_variant (priv->properties) : NULL);
|
||||
break;
|
||||
|
||||
|
|
@ -138,17 +138,13 @@ node_register_object (PinosNode *node)
|
|||
|
||||
skel = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_NODE);
|
||||
|
||||
priv->iface = pinos_node1_skeleton_new ();
|
||||
pinos_node1_set_name (priv->iface, priv->name);
|
||||
if (priv->properties)
|
||||
pinos_node1_set_properties (priv->iface, pinos_properties_to_variant (priv->properties));
|
||||
pinos_node1_set_state (priv->iface, priv->state);
|
||||
pinos_object_skeleton_set_node1 (skel, priv->iface);
|
||||
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
|
||||
g_object_unref (skel);
|
||||
|
||||
g_debug ("node %p: register object %s", node, priv->object_path);
|
||||
pinos_daemon_add_node (daemon, node);
|
||||
|
||||
return;
|
||||
|
|
@ -159,9 +155,9 @@ node_unregister_object (PinosNode *node)
|
|||
{
|
||||
PinosNodePrivate *priv = node->priv;
|
||||
|
||||
g_debug ("node %p: unregister object %s", node, priv->object_path);
|
||||
pinos_daemon_unexport (priv->daemon, priv->object_path);
|
||||
pinos_daemon_remove_node (priv->daemon, node);
|
||||
g_clear_object (&priv->iface);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -169,6 +165,7 @@ pinos_node_constructed (GObject * obj)
|
|||
{
|
||||
PinosNode *node = PINOS_NODE (obj);
|
||||
|
||||
g_debug ("node %p: constructed", node);
|
||||
node_register_object (node);
|
||||
|
||||
G_OBJECT_CLASS (pinos_node_parent_class)->constructed (obj);
|
||||
|
|
@ -178,7 +175,11 @@ static void
|
|||
pinos_node_dispose (GObject * obj)
|
||||
{
|
||||
PinosNode *node = PINOS_NODE (obj);
|
||||
PinosNodePrivate *priv = node->priv;
|
||||
|
||||
g_debug ("node %p: dispose", node);
|
||||
g_list_free_full (priv->ports, (GDestroyNotify) g_object_unref);
|
||||
priv->ports = NULL;
|
||||
node_unregister_object (node);
|
||||
|
||||
G_OBJECT_CLASS (pinos_node_parent_class)->dispose (obj);
|
||||
|
|
@ -190,7 +191,14 @@ pinos_node_finalize (GObject * obj)
|
|||
PinosNode *node = PINOS_NODE (obj);
|
||||
PinosNodePrivate *priv = node->priv;
|
||||
|
||||
g_debug ("node %p: finalize", node);
|
||||
g_clear_object (&priv->daemon);
|
||||
g_clear_object (&priv->iface);
|
||||
g_free (priv->name);
|
||||
g_free (priv->object_path);
|
||||
g_clear_error (&priv->error);
|
||||
if (priv->properties)
|
||||
pinos_properties_free (priv->properties);
|
||||
|
||||
G_OBJECT_CLASS (pinos_node_parent_class)->finalize (obj);
|
||||
}
|
||||
|
|
@ -262,7 +270,13 @@ pinos_node_class_init (PinosNodeClass * klass)
|
|||
static void
|
||||
pinos_node_init (PinosNode * node)
|
||||
{
|
||||
node->priv = PINOS_NODE_GET_PRIVATE (node);
|
||||
PinosNodePrivate *priv = node->priv = PINOS_NODE_GET_PRIVATE (node);
|
||||
|
||||
g_debug ("node %p: new", node);
|
||||
priv->state = PINOS_NODE_STATE_SUSPENDED;
|
||||
|
||||
priv->iface = pinos_node1_skeleton_new ();
|
||||
pinos_node1_set_state (priv->iface, priv->state);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -306,7 +320,7 @@ pinos_node_get_object_path (PinosNode *node)
|
|||
/**
|
||||
* pinos_node_add_port:
|
||||
* @node: a #PinosNode
|
||||
* @port: a #PinosPort
|
||||
* @port: (transfer full): a #PinosPort
|
||||
*
|
||||
* Add the #PinosPort to @node
|
||||
*/
|
||||
|
|
@ -325,7 +339,7 @@ pinos_node_add_port (PinosNode *node, PinosPort *port)
|
|||
/**
|
||||
* pinos_node_remove_port:
|
||||
* @node: a #PinosNode
|
||||
* @port: a #PinosPort
|
||||
* @port: (transfer full): a #PinosPort
|
||||
*
|
||||
* Remove the #PinosPort from @node
|
||||
*/
|
||||
|
|
@ -333,12 +347,17 @@ void
|
|||
pinos_node_remove_port (PinosNode *node, PinosPort *port)
|
||||
{
|
||||
PinosNodePrivate *priv;
|
||||
GList *find;
|
||||
|
||||
g_return_if_fail (PINOS_IS_NODE (node));
|
||||
g_return_if_fail (PINOS_IS_PORT (port));
|
||||
priv = node->priv;
|
||||
|
||||
priv->ports = g_list_remove (priv->ports, port);
|
||||
find = g_list_find (priv->ports, port);
|
||||
if (find) {
|
||||
priv->ports = g_list_delete_link (priv->ports, find);
|
||||
g_object_unref (port);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -498,8 +517,6 @@ pinos_node_report_busy (PinosNode *node)
|
|||
pinos_node_set_state (node, PINOS_NODE_STATE_RUNNING);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* pinos_node_new:
|
||||
* @daemon: a #PinosDaemon
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@
|
|||
|
||||
struct _PinosPortPrivate
|
||||
{
|
||||
PinosNode *node;
|
||||
PinosDaemon *daemon;
|
||||
PinosPort1 *iface;
|
||||
gchar *node_path;
|
||||
gchar *object_path;
|
||||
|
||||
gchar *name;
|
||||
|
|
@ -52,7 +53,8 @@ G_DEFINE_TYPE (PinosPort, pinos_port, G_TYPE_OBJECT);
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_NODE,
|
||||
PROP_DAEMON,
|
||||
PROP_NODE_PATH,
|
||||
PROP_OBJECT_PATH,
|
||||
PROP_NAME,
|
||||
PROP_DIRECTION,
|
||||
|
|
@ -80,14 +82,18 @@ pinos_port_get_property (GObject *_object,
|
|||
PinosPortPrivate *priv = port->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_NODE:
|
||||
g_value_set_object (value, priv->node);
|
||||
case PROP_DAEMON:
|
||||
g_value_set_object (value, priv->daemon);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, priv->name);
|
||||
break;
|
||||
|
||||
case PROP_NODE_PATH:
|
||||
g_value_set_string (value, priv->node_path);
|
||||
break;
|
||||
|
||||
case PROP_OBJECT_PATH:
|
||||
g_value_set_string (value, priv->object_path);
|
||||
break;
|
||||
|
|
@ -110,28 +116,6 @@ pinos_port_get_property (GObject *_object,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_possible_formats (PinosPort *port, GBytes *formats)
|
||||
{
|
||||
PinosPortPrivate *priv;
|
||||
GList *walk;
|
||||
|
||||
g_return_if_fail (PINOS_IS_PORT (port));
|
||||
priv = port->priv;
|
||||
|
||||
if (priv->possible_formats)
|
||||
g_bytes_unref (priv->possible_formats);
|
||||
priv->possible_formats = formats ? g_bytes_ref (formats) : NULL;
|
||||
|
||||
if (priv->iface)
|
||||
g_object_set (priv->iface, "possible-formats",
|
||||
g_bytes_get_data (formats, NULL),
|
||||
NULL);
|
||||
|
||||
for (walk = priv->channels; walk; walk = g_list_next (walk))
|
||||
g_object_set (walk->data, "possible-formats", formats, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
pinos_port_set_property (GObject *_object,
|
||||
guint prop_id,
|
||||
|
|
@ -142,31 +126,51 @@ pinos_port_set_property (GObject *_object,
|
|||
PinosPortPrivate *priv = port->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_NODE:
|
||||
priv->node = g_value_dup_object (value);
|
||||
case PROP_DAEMON:
|
||||
priv->daemon = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
priv->name = g_value_dup_string (value);
|
||||
g_object_set (priv->iface, "name", priv->name, NULL);
|
||||
break;
|
||||
|
||||
case PROP_NODE_PATH:
|
||||
priv->node_path = g_value_dup_string (value);
|
||||
g_object_set (priv->iface, "node", priv->name, NULL);
|
||||
break;
|
||||
|
||||
case PROP_DIRECTION:
|
||||
priv->direction = g_value_get_enum (value);
|
||||
g_object_set (priv->iface, "direction", priv->direction, NULL);
|
||||
break;
|
||||
|
||||
case PROP_POSSIBLE_FORMATS:
|
||||
set_possible_formats (port, g_value_get_boxed (value));
|
||||
{
|
||||
GList *walk;
|
||||
|
||||
if (priv->possible_formats)
|
||||
g_bytes_unref (priv->possible_formats);
|
||||
priv->possible_formats = g_value_dup_boxed (value);
|
||||
|
||||
g_object_set (priv->iface, "possible-formats", priv->possible_formats ?
|
||||
g_bytes_get_data (priv->possible_formats, NULL) : NULL,
|
||||
NULL);
|
||||
|
||||
for (walk = priv->channels; walk; walk = g_list_next (walk))
|
||||
g_object_set (walk->data, "possible-formats", priv->possible_formats, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
case PROP_PROPERTIES:
|
||||
if (priv->properties)
|
||||
pinos_properties_free (priv->properties);
|
||||
priv->properties = g_value_dup_boxed (value);
|
||||
if (priv->iface)
|
||||
g_object_set (priv->iface,
|
||||
"properties", priv->properties ?
|
||||
pinos_properties_to_variant (priv->properties) : NULL,
|
||||
NULL);
|
||||
|
||||
g_object_set (priv->iface,
|
||||
"properties", priv->properties ?
|
||||
pinos_properties_to_variant (priv->properties) : NULL,
|
||||
NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -179,39 +183,20 @@ static void
|
|||
port_register_object (PinosPort *port)
|
||||
{
|
||||
PinosPortPrivate *priv = port->priv;
|
||||
GBytes *formats;
|
||||
GVariant *variant;
|
||||
PinosObjectSkeleton *skel;
|
||||
gchar *name;
|
||||
|
||||
name = g_strdup_printf ("%s/port", pinos_node_get_object_path (priv->node));
|
||||
name = g_strdup_printf ("%s/port", priv->node_path);
|
||||
skel = pinos_object_skeleton_new (name);
|
||||
g_free (name);
|
||||
|
||||
formats = pinos_port_get_formats (port, NULL, NULL);
|
||||
|
||||
if (priv->properties)
|
||||
variant = pinos_properties_to_variant (priv->properties);
|
||||
else
|
||||
variant = NULL;
|
||||
|
||||
priv->iface = pinos_port1_skeleton_new ();
|
||||
g_object_set (priv->iface, "name", priv->name,
|
||||
"node", pinos_node_get_object_path (priv->node),
|
||||
"direction", priv->direction,
|
||||
"properties", variant,
|
||||
"possible-formats", g_bytes_get_data (formats, NULL),
|
||||
NULL);
|
||||
g_bytes_unref (formats);
|
||||
pinos_object_skeleton_set_port1 (skel, priv->iface);
|
||||
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = pinos_daemon_export_uniquely (pinos_node_get_daemon (priv->node),
|
||||
priv->object_path = pinos_daemon_export_uniquely (priv->daemon,
|
||||
G_DBUS_OBJECT_SKELETON (skel));
|
||||
|
||||
g_object_unref (skel);
|
||||
|
||||
pinos_node_add_port (priv->node, port);
|
||||
g_debug ("port %p: register object %s", port, priv->object_path);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -221,8 +206,8 @@ port_unregister_object (PinosPort *port)
|
|||
{
|
||||
PinosPortPrivate *priv = port->priv;
|
||||
|
||||
pinos_node_remove_port (priv->node, port);
|
||||
g_clear_object (&priv->iface);
|
||||
g_debug ("port %p: unregister object %s", port, priv->object_path);
|
||||
pinos_daemon_unexport (priv->daemon, priv->object_path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -235,20 +220,17 @@ pinos_port_constructed (GObject * object)
|
|||
G_OBJECT_CLASS (pinos_port_parent_class)->constructed (object);
|
||||
}
|
||||
|
||||
static void
|
||||
do_remove_channel (PinosChannel *channel,
|
||||
gpointer user_data)
|
||||
{
|
||||
pinos_channel_remove (channel);
|
||||
}
|
||||
|
||||
static void
|
||||
pinos_port_dispose (GObject * object)
|
||||
{
|
||||
PinosPort *port = PINOS_PORT (object);
|
||||
PinosPortPrivate *priv = port->priv;
|
||||
GList *copy;
|
||||
|
||||
g_list_foreach (priv->channels, (GFunc) do_remove_channel, port);
|
||||
g_debug ("port %p: dispose", port);
|
||||
|
||||
copy = g_list_copy (priv->channels);
|
||||
g_list_free_full (copy, (GDestroyNotify) pinos_channel_remove);
|
||||
port_unregister_object (port);
|
||||
|
||||
G_OBJECT_CLASS (pinos_port_parent_class)->dispose (object);
|
||||
|
|
@ -260,11 +242,16 @@ pinos_port_finalize (GObject * object)
|
|||
PinosPort *port = PINOS_PORT (object);
|
||||
PinosPortPrivate *priv = port->priv;
|
||||
|
||||
g_debug ("port %p: finalize", port);
|
||||
g_free (priv->name);
|
||||
g_free (priv->object_path);
|
||||
g_free (priv->node_path);
|
||||
if (priv->possible_formats)
|
||||
g_bytes_unref (priv->possible_formats);
|
||||
if (priv->properties)
|
||||
pinos_properties_free (priv->properties);
|
||||
g_clear_object (&priv->iface);
|
||||
g_clear_object (&priv->daemon);
|
||||
|
||||
G_OBJECT_CLASS (pinos_port_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -293,10 +280,10 @@ default_create_channel (PinosPort *port,
|
|||
if (possible_formats == NULL)
|
||||
return NULL;
|
||||
|
||||
channel = g_object_new (PINOS_TYPE_CHANNEL, "daemon", pinos_node_get_daemon (priv->node),
|
||||
channel = g_object_new (PINOS_TYPE_CHANNEL, "daemon", priv->daemon,
|
||||
"client-path", client_path,
|
||||
"direction", priv->direction,
|
||||
"port-path", pinos_port_get_object_path (port),
|
||||
"port-path", priv->object_path,
|
||||
"possible-formats", possible_formats,
|
||||
"properties", props,
|
||||
NULL);
|
||||
|
|
@ -356,11 +343,20 @@ pinos_port_class_init (PinosPortClass * klass)
|
|||
gobject_class->get_property = pinos_port_get_property;
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_NODE,
|
||||
g_param_spec_object ("node",
|
||||
"Node",
|
||||
"The Node",
|
||||
PINOS_TYPE_NODE,
|
||||
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_NODE_PATH,
|
||||
g_param_spec_string ("node-path",
|
||||
"Node path",
|
||||
"The Node Path",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
|
@ -457,6 +453,8 @@ pinos_port_init (PinosPort * port)
|
|||
{
|
||||
PinosPortPrivate *priv = port->priv = PINOS_PORT_GET_PRIVATE (port);
|
||||
|
||||
priv->iface = pinos_port1_skeleton_new ();
|
||||
|
||||
priv->direction = PINOS_DIRECTION_INVALID;
|
||||
}
|
||||
|
||||
|
|
@ -467,17 +465,20 @@ pinos_port_init (PinosPort * port)
|
|||
* Returns: a new #PinosPort
|
||||
*/
|
||||
PinosPort *
|
||||
pinos_port_new (PinosNode *node,
|
||||
pinos_port_new (PinosDaemon *daemon,
|
||||
const gchar *node_path,
|
||||
PinosDirection direction,
|
||||
const gchar *name,
|
||||
GBytes *possible_formats,
|
||||
PinosProperties *props)
|
||||
{
|
||||
g_return_val_if_fail (PINOS_IS_NODE (node), NULL);
|
||||
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
||||
g_return_val_if_fail (node_path != NULL, NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return g_object_new (PINOS_TYPE_PORT,
|
||||
"node", node,
|
||||
"daemon", daemon,
|
||||
"node-path", node_path,
|
||||
"direction", direction,
|
||||
"name", name,
|
||||
"possible-formats", possible_formats,
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ struct _PinosPortClass {
|
|||
/* normal GObject stuff */
|
||||
GType pinos_port_get_type (void);
|
||||
|
||||
PinosPort * pinos_port_new (PinosNode *node,
|
||||
PinosPort * pinos_port_new (PinosDaemon *daemon,
|
||||
const gchar *node_path,
|
||||
PinosDirection direction,
|
||||
const gchar *name,
|
||||
GBytes *possible_formats,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,8 @@ upload_node_set_property (GObject *_object,
|
|||
if (priv->possible_formats)
|
||||
g_bytes_unref (priv->possible_formats);
|
||||
priv->possible_formats = g_value_dup_boxed (value);
|
||||
g_object_set (priv->output, "possible-formats", priv->possible_formats, NULL);
|
||||
if (priv->output)
|
||||
g_object_set (priv->output, "possible-formats", priv->possible_formats, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -152,6 +153,7 @@ setup_pipeline (PinosUploadNode *node)
|
|||
PinosUploadNodePrivate *priv = node->priv;
|
||||
GstBus *bus;
|
||||
|
||||
g_debug ("upload-node %p: setup pipeline", node);
|
||||
priv->pipeline = gst_parse_launch ("socketsrc "
|
||||
"name=src "
|
||||
"caps=application/x-pinos "
|
||||
|
|
@ -167,7 +169,6 @@ setup_pipeline (PinosUploadNode *node)
|
|||
priv->id = gst_bus_add_watch (bus, bus_handler, node);
|
||||
gst_object_unref (bus);
|
||||
|
||||
g_debug ("upload-node %p: setup pipeline", node);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -385,6 +386,37 @@ pinos_upload_node_get_channel (PinosUploadNode *node,
|
|||
return g_object_ref (priv->channel);
|
||||
}
|
||||
|
||||
static void
|
||||
upload_node_constructed (GObject * object)
|
||||
{
|
||||
PinosNode *node = PINOS_NODE (object);
|
||||
PinosUploadNode *upload = PINOS_UPLOAD_NODE (object);
|
||||
PinosUploadNodePrivate *priv = upload->priv;
|
||||
|
||||
G_OBJECT_CLASS (pinos_upload_node_parent_class)->constructed (object);
|
||||
|
||||
g_debug ("upload-node %p: constructed", upload);
|
||||
priv->input = pinos_port_new (pinos_node_get_daemon (node),
|
||||
pinos_node_get_object_path (node),
|
||||
PINOS_DIRECTION_INPUT,
|
||||
"input",
|
||||
priv->possible_formats,
|
||||
NULL);
|
||||
priv->output = pinos_port_new (pinos_node_get_daemon (node),
|
||||
pinos_node_get_object_path (node),
|
||||
PINOS_DIRECTION_OUTPUT,
|
||||
"output",
|
||||
priv->possible_formats,
|
||||
NULL);
|
||||
g_signal_connect (priv->output, "channel-added", (GCallback) on_channel_added, upload);
|
||||
g_signal_connect (priv->output, "channel-removed", (GCallback) on_channel_removed, upload);
|
||||
|
||||
pinos_node_add_port (node, priv->input);
|
||||
pinos_node_add_port (node, priv->output);
|
||||
|
||||
setup_pipeline (upload);
|
||||
}
|
||||
|
||||
static void
|
||||
pinos_upload_node_class_init (PinosUploadNodeClass * klass)
|
||||
{
|
||||
|
|
@ -393,6 +425,7 @@ pinos_upload_node_class_init (PinosUploadNodeClass * klass)
|
|||
|
||||
g_type_class_add_private (klass, sizeof (PinosUploadNodePrivate));
|
||||
|
||||
gobject_class->constructed = upload_node_constructed;
|
||||
gobject_class->dispose = upload_node_dispose;
|
||||
gobject_class->finalize = upload_node_finalize;
|
||||
|
||||
|
|
@ -415,23 +448,8 @@ pinos_upload_node_class_init (PinosUploadNodeClass * klass)
|
|||
static void
|
||||
pinos_upload_node_init (PinosUploadNode * node)
|
||||
{
|
||||
PinosUploadNodePrivate *priv = node->priv = PINOS_UPLOAD_NODE_GET_PRIVATE (node);
|
||||
|
||||
node->priv = PINOS_UPLOAD_NODE_GET_PRIVATE (node);
|
||||
g_debug ("upload-node %p: new", node);
|
||||
priv->input = pinos_port_new (PINOS_NODE (node),
|
||||
PINOS_DIRECTION_INPUT,
|
||||
"input",
|
||||
priv->possible_formats,
|
||||
NULL);
|
||||
priv->output = pinos_port_new (PINOS_NODE (node),
|
||||
PINOS_DIRECTION_OUTPUT,
|
||||
"output",
|
||||
priv->possible_formats,
|
||||
NULL);
|
||||
g_signal_connect (priv->output, "channel-added", (GCallback) on_channel_added, node);
|
||||
g_signal_connect (priv->output, "channel-removed", (GCallback) on_channel_removed, node);
|
||||
|
||||
setup_pipeline (node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue