mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -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
|
|
@ -172,10 +172,10 @@ client_fill_info (PinosClientInfo *info, GDBusProxy *proxy)
|
|||
|
||||
info->id = proxy;
|
||||
info->client_path = g_dbus_proxy_get_object_path (proxy);
|
||||
SET_STRING ("Sender", sender, 0);
|
||||
|
||||
info->change_mask = 0;
|
||||
SET_STRING ("Name", name, 0);
|
||||
SET_PROPERTIES ("Properties", properties, 1);
|
||||
SET_PROPERTIES ("Properties", properties, 0);
|
||||
|
||||
if (changed)
|
||||
g_hash_table_remove_all (changed);
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ void pinos_context_get_daemon_info (PinosContext *context,
|
|||
* PinosClientInfo:
|
||||
* @id: generic id of the client
|
||||
* @client_path: unique path of the client
|
||||
* @sender: sender of client
|
||||
* @change_mask: bitfield of changed fields since last call
|
||||
* @name: name of client
|
||||
* @properties: extra properties
|
||||
*
|
||||
* The client information. Extra information can be added in later
|
||||
|
|
@ -101,8 +101,8 @@ void pinos_context_get_daemon_info (PinosContext *context,
|
|||
typedef struct {
|
||||
gpointer id;
|
||||
const char *client_path;
|
||||
const char *sender;
|
||||
guint64 change_mask;
|
||||
const char *name;
|
||||
PinosProperties *properties;
|
||||
} PinosClientInfo;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,8 @@
|
|||
#define PINOS_DBUS_SERVICE "org.pinos"
|
||||
#define PINOS_DBUS_OBJECT_PREFIX "/org/pinos"
|
||||
#define PINOS_DBUS_OBJECT_SERVER PINOS_DBUS_OBJECT_PREFIX "/server"
|
||||
#define PINOS_DBUS_OBJECT_NODE PINOS_DBUS_OBJECT_PREFIX "/node"
|
||||
#define PINOS_DBUS_OBJECT_PORT PINOS_DBUS_OBJECT_PREFIX "/port"
|
||||
#define PINOS_DBUS_OBJECT_CLIENT PINOS_DBUS_OBJECT_PREFIX "/client"
|
||||
#define PINOS_DBUS_OBJECT_NODE PINOS_DBUS_OBJECT_PREFIX "/node"
|
||||
|
||||
void pinos_init (int *argc, char **argv[]);
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ subscription_cb (PinosSubscribe *subscribe,
|
|||
PINOS_STREAM_STATE_ERROR,
|
||||
g_error_new_literal (G_IO_ERROR,
|
||||
G_IO_ERROR_CLOSED,
|
||||
"Output disappeared"));
|
||||
"Channel disappeared"));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -508,8 +508,8 @@ on_channel_proxy (GObject *source_object,
|
|||
if (priv->channel == NULL)
|
||||
goto channel_failed;
|
||||
|
||||
/* get the source we are connected to */
|
||||
v = g_dbus_proxy_get_cached_property (priv->channel, "Owner");
|
||||
/* get the port we are connected to */
|
||||
v = g_dbus_proxy_get_cached_property (priv->channel, "Port");
|
||||
if (v) {
|
||||
gsize len;
|
||||
str = g_variant_dup_string (v, &len);
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
obtaining an channel object from a source/sink.
|
||||
-->
|
||||
<interface name='org.pinos.Client1'>
|
||||
<!-- Name: Name of the client -->
|
||||
<property name='Name' type='s' access='read' />
|
||||
<!-- Sender: Sender of the client -->
|
||||
<property name='Sender' type='s' access='read' />
|
||||
<!-- Name: Properties of the client -->
|
||||
<property name='Properties' type='a{sv}' access='read' />
|
||||
<!-- Disconnect:
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* SECTION:element-pinossink
|
||||
* SECTION:element-pinosprovide
|
||||
*
|
||||
* <refsect2>
|
||||
* <title>Example launch line</title>
|
||||
* |[
|
||||
* gst-launch -v videotestsrc ! pinossink
|
||||
* gst-launch -v videotestsrc ! pinosprovide
|
||||
* ]| Sends a test video source to pinos
|
||||
* </refsect2>
|
||||
*/
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "gstpinossink.h"
|
||||
#include "gstpinosprovide.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_PINOS_SINK_H__
|
||||
#define __GST_PINOS_SINK_H__
|
||||
#ifndef __GST_PINOS_PROVIDE_H__
|
||||
#define __GST_PINOS_PROVIDE_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstbasesink.h>
|
||||
|
|
@ -27,28 +27,28 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_PINOS_SINK \
|
||||
(gst_pinos_sink_get_type())
|
||||
#define GST_PINOS_SINK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PINOS_SINK,GstPinosSink))
|
||||
#define GST_PINOS_SINK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PINOS_SINK,GstPinosSinkClass))
|
||||
#define GST_IS_PINOS_SINK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PINOS_SINK))
|
||||
#define GST_IS_PINOS_SINK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PINOS_SINK))
|
||||
#define GST_PINOS_SINK_CAST(obj) \
|
||||
((GstPinosSink *) (obj))
|
||||
#define GST_TYPE_PINOS_PROVIDE \
|
||||
(gst_pinos_provide_get_type())
|
||||
#define GST_PINOS_PROVIDE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PINOS_PROVIDE,GstPinosProvide))
|
||||
#define GST_PINOS_PROVIDE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PINOS_PROVIDE,GstPinosProvideClass))
|
||||
#define GST_IS_PINOS_PROVIDE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PINOS_PROVIDE))
|
||||
#define GST_IS_PINOS_PROVIDE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PINOS_PROVIDE))
|
||||
#define GST_PINOS_PROVIDE_CAST(obj) \
|
||||
((GstPinosProvide *) (obj))
|
||||
|
||||
typedef struct _GstPinosSink GstPinosSink;
|
||||
typedef struct _GstPinosSinkClass GstPinosSinkClass;
|
||||
typedef struct _GstPinosProvide GstPinosProvide;
|
||||
typedef struct _GstPinosProvideClass GstPinosProvideClass;
|
||||
|
||||
/**
|
||||
* GstPinosSink:
|
||||
* GstPinosProvide:
|
||||
*
|
||||
* Opaque data structure.
|
||||
*/
|
||||
struct _GstPinosSink {
|
||||
struct _GstPinosProvide {
|
||||
GstBaseSink element;
|
||||
|
||||
/*< private >*/
|
||||
|
|
@ -68,12 +68,12 @@ struct _GstPinosSink {
|
|||
GHashTable *fdids;
|
||||
};
|
||||
|
||||
struct _GstPinosSinkClass {
|
||||
struct _GstPinosProvideClass {
|
||||
GstBaseSinkClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_pinos_sink_get_type (void);
|
||||
GType gst_pinos_provide_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_PINOS_SINK_H__ */
|
||||
#endif /* __GST_PINOS_PROVIDE_H__ */
|
||||
|
|
|
|||
|
|
@ -49,14 +49,37 @@
|
|||
GST_DEBUG_CATEGORY_STATIC (pinos_sink_debug);
|
||||
#define GST_CAT_DEFAULT pinos_sink_debug
|
||||
|
||||
#define DEFAULT_PROP_MODE GST_PINOS_SINK_MODE_DEFAULT
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_PATH,
|
||||
PROP_CLIENT_NAME,
|
||||
PROP_STREAM_PROPERTIES
|
||||
PROP_STREAM_PROPERTIES,
|
||||
PROP_MODE
|
||||
};
|
||||
|
||||
GType
|
||||
gst_pinos_sink_mode_get_type (void)
|
||||
{
|
||||
static volatile gsize mode_type = 0;
|
||||
static const GEnumValue mode[] = {
|
||||
{GST_PINOS_SINK_MODE_DEFAULT, "GST_PINOS_SINK_MODE_DEFAULT", "default"},
|
||||
{GST_PINOS_SINK_MODE_RENDER, "GST_PINOS_SINK_MODE_RENDER", "render"},
|
||||
{GST_PINOS_SINK_MODE_PROVIDE, "GST_PINOS_SINK_MODE_PROVIDE", "provide"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (g_once_init_enter (&mode_type)) {
|
||||
GType tmp =
|
||||
g_enum_register_static ("GstPinosSinkMode", mode);
|
||||
g_once_init_leave (&mode_type, tmp);
|
||||
}
|
||||
|
||||
return (GType) mode_type;
|
||||
}
|
||||
|
||||
|
||||
#define PINOSS_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL)
|
||||
|
||||
|
|
@ -147,17 +170,27 @@ gst_pinos_sink_class_init (GstPinosSinkClass * klass)
|
|||
g_object_class_install_property (gobject_class,
|
||||
PROP_STREAM_PROPERTIES,
|
||||
g_param_spec_boxed ("stream-properties",
|
||||
"stream properties",
|
||||
"list of pinos stream properties",
|
||||
"Stream properties",
|
||||
"List of pinos stream properties",
|
||||
GST_TYPE_STRUCTURE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_MODE,
|
||||
g_param_spec_enum ("mode",
|
||||
"Mode",
|
||||
"The mode to operate in",
|
||||
GST_TYPE_PINOS_SINK_MODE,
|
||||
DEFAULT_PROP_MODE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gstelement_class->change_state = gst_pinos_sink_change_state;
|
||||
|
||||
gst_element_class_set_static_metadata (gstelement_class,
|
||||
"Pinos sink", "Sink/Video",
|
||||
"Send video to pinos", "Wim Taymans <wim.taymans@gmail.com>");
|
||||
"Send video to Pinos", "Wim Taymans <wim.taymans@gmail.com>");
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_pinos_sink_template));
|
||||
|
|
@ -178,6 +211,7 @@ gst_pinos_sink_init (GstPinosSink * sink)
|
|||
{
|
||||
sink->allocator = gst_tmpfile_allocator_new ();
|
||||
sink->client_name = pinos_client_name();
|
||||
sink->mode = DEFAULT_PROP_MODE;
|
||||
|
||||
sink->fdids = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
|
||||
(GDestroyNotify) gst_buffer_unref);
|
||||
|
|
@ -250,6 +284,10 @@ gst_pinos_sink_set_property (GObject * object, guint prop_id,
|
|||
gst_structure_copy (gst_value_get_structure (value));
|
||||
break;
|
||||
|
||||
case PROP_MODE:
|
||||
pinossink->mode = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -275,6 +313,10 @@ gst_pinos_sink_get_property (GObject * object, guint prop_id,
|
|||
gst_value_set_structure (value, pinossink->properties);
|
||||
break;
|
||||
|
||||
case PROP_MODE:
|
||||
g_value_set_enum (value, pinossink->mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -382,11 +424,17 @@ gst_pinos_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
|||
goto start_error;
|
||||
|
||||
if (state == PINOS_STREAM_STATE_UNCONNECTED) {
|
||||
pinos_stream_connect (pinossink->stream,
|
||||
PINOS_DIRECTION_INPUT,
|
||||
pinossink->path,
|
||||
0,
|
||||
g_bytes_ref (format));
|
||||
if (pinossink->mode == GST_PINOS_SINK_MODE_PROVIDE) {
|
||||
pinos_stream_connect_provide (pinossink->stream,
|
||||
0,
|
||||
g_bytes_ref (format));
|
||||
} else {
|
||||
pinos_stream_connect (pinossink->stream,
|
||||
PINOS_DIRECTION_INPUT,
|
||||
pinossink->path,
|
||||
0,
|
||||
g_bytes_ref (format));
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
state = pinos_stream_get_state (pinossink->stream);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,24 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstPinosSink GstPinosSink;
|
||||
typedef struct _GstPinosSinkClass GstPinosSinkClass;
|
||||
|
||||
|
||||
/**
|
||||
* GstPinosSinkMode:
|
||||
* @GST_PINOS_SINK_MODE_DEFAULT: the default mode as configured in the server
|
||||
* @GST_PINOS_SINK_MODE_RENDER: try to render the media
|
||||
* @GST_PINOS_SINK_MODE_PROVIDE: provide the media
|
||||
*
|
||||
* Different modes of operation.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GST_PINOS_SINK_MODE_DEFAULT,
|
||||
GST_PINOS_SINK_MODE_RENDER,
|
||||
GST_PINOS_SINK_MODE_PROVIDE,
|
||||
} GstPinosSinkMode;
|
||||
|
||||
#define GST_TYPE_PINOS_SINK_MODE (gst_pinos_sink_mode_get_type ())
|
||||
|
||||
/**
|
||||
* GstPinosSink:
|
||||
*
|
||||
|
|
@ -64,6 +82,7 @@ struct _GstPinosSink {
|
|||
PinosStream *stream;
|
||||
GstAllocator *allocator;
|
||||
GstStructure *properties;
|
||||
GstPinosSinkMode mode;
|
||||
|
||||
guint32 id_counter;
|
||||
GHashTable *fdids;
|
||||
|
|
@ -74,6 +93,7 @@ struct _GstPinosSinkClass {
|
|||
};
|
||||
|
||||
GType gst_pinos_sink_get_type (void);
|
||||
GType gst_pinos_sink_mode_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -387,6 +387,7 @@ set_property (GObject *object,
|
|||
static void
|
||||
sink_constructed (GObject * object)
|
||||
{
|
||||
PinosNode *node = PINOS_NODE (object);
|
||||
PinosGstSink *sink = PINOS_GST_SINK (object);
|
||||
PinosGstSinkPrivate *priv = sink->priv;
|
||||
gchar *str;
|
||||
|
|
@ -397,13 +398,16 @@ sink_constructed (GObject * object)
|
|||
str = gst_caps_to_string (priv->possible_formats);
|
||||
format = g_bytes_new_take (str, strlen (str) + 1);
|
||||
|
||||
priv->input = pinos_port_new (PINOS_NODE (sink),
|
||||
priv->input = pinos_port_new (pinos_node_get_daemon (node),
|
||||
pinos_node_get_object_path (node),
|
||||
PINOS_DIRECTION_INPUT,
|
||||
"input",
|
||||
format,
|
||||
NULL);
|
||||
g_bytes_unref (format);
|
||||
|
||||
pinos_node_add_port (node, priv->input);
|
||||
|
||||
g_signal_connect (priv->input, "channel-added", (GCallback) on_channel_added, sink);
|
||||
g_signal_connect (priv->input, "channel-removed", (GCallback) on_channel_removed, sink);
|
||||
|
||||
|
|
|
|||
|
|
@ -440,6 +440,7 @@ set_property (GObject *object,
|
|||
static void
|
||||
source_constructed (GObject * object)
|
||||
{
|
||||
PinosNode *node = PINOS_NODE (object);
|
||||
PinosGstSource *source = PINOS_GST_SOURCE (object);
|
||||
PinosGstSourcePrivate *priv = source->priv;
|
||||
gchar *str;
|
||||
|
|
@ -450,7 +451,8 @@ source_constructed (GObject * object)
|
|||
str = gst_caps_to_string (priv->possible_formats);
|
||||
format = g_bytes_new_take (str, strlen (str) + 1);
|
||||
|
||||
priv->output = pinos_port_new (PINOS_NODE (source),
|
||||
priv->output = pinos_port_new (pinos_node_get_daemon (node),
|
||||
pinos_node_get_object_path (node),
|
||||
PINOS_DIRECTION_OUTPUT,
|
||||
"output",
|
||||
format,
|
||||
|
|
@ -460,15 +462,19 @@ source_constructed (GObject * object)
|
|||
g_signal_connect (priv->output, "channel-added", (GCallback) on_channel_added, source);
|
||||
g_signal_connect (priv->output, "channel-removed", (GCallback) on_channel_removed, source);
|
||||
|
||||
pinos_node_add_port (node, priv->output);
|
||||
|
||||
setup_pipeline (source, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
source_finalize (GObject * object)
|
||||
{
|
||||
PinosNode *node = PINOS_NODE (object);
|
||||
PinosGstSource *source = PINOS_GST_SOURCE (object);
|
||||
PinosGstSourcePrivate *priv = source->priv;
|
||||
|
||||
pinos_node_remove_port (node, priv->output);
|
||||
destroy_pipeline (source);
|
||||
g_clear_pointer (&priv->possible_formats, gst_caps_unref);
|
||||
pinos_properties_free (priv->props);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ dump_daemon_info (PinosContext *c, const PinosDaemonInfo *info, gpointer user_da
|
|||
g_print ("%c\thost-name: \"%s\"\n", MARK_CHANGE (1), info->host_name);
|
||||
g_print ("%c\tversion: \"%s\"\n", MARK_CHANGE (2), info->version);
|
||||
g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (3), info->name);
|
||||
g_print ("%c\tcookie: %d\n", MARK_CHANGE (4), info->cookie);
|
||||
g_print ("%c\tcookie: %u\n", MARK_CHANGE (4), info->cookie);
|
||||
print_properties (info->properties, MARK_CHANGE (5));
|
||||
}
|
||||
}
|
||||
|
|
@ -131,8 +131,8 @@ dump_client_info (PinosContext *c, const PinosClientInfo *info, gpointer user_da
|
|||
g_print ("\tid: %p\n", info->id);
|
||||
g_print ("\tclient-path: \"%s\"\n", info->client_path);
|
||||
if (data->print_all) {
|
||||
g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name);
|
||||
print_properties (info->properties, MARK_CHANGE (1));
|
||||
g_print ("\tsender: \"%s\"\n", info->sender);
|
||||
print_properties (info->properties, MARK_CHANGE (0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue