rework: make client and server nodes

work on making nodes and ports on the client.
This commit is contained in:
Wim Taymans 2016-05-12 17:03:28 +02:00
parent c67d3d7f04
commit 8407430891
34 changed files with 1500 additions and 3844 deletions

View file

@ -65,7 +65,7 @@ device_added (PinosGstManager *manager,
PinosGstManagerPrivate *priv = manager->priv;
gchar *name, *klass;
GstElement *element;
PinosNode *node = NULL;
PinosServerNode *node = NULL;
GstStructure *p;
PinosProperties *properties;
GstCaps *caps;
@ -108,7 +108,7 @@ device_added (PinosGstManager *manager,
caps);
}
if (node)
g_object_set_data (G_OBJECT (device), "PinosNode", node);
g_object_set_data (G_OBJECT (device), "PinosServerNode", node);
pinos_properties_free (properties);
gst_caps_unref (caps);
@ -121,7 +121,7 @@ device_removed (PinosGstManager *manager,
GstDevice *device)
{
gchar *name;
PinosNode *node;
PinosServerNode *node;
name = gst_device_get_display_name (device);
if (strcmp (name, "gst") == 0)
@ -129,7 +129,7 @@ device_removed (PinosGstManager *manager,
g_print("Device removed: %s\n", name);
node = g_object_steal_data (G_OBJECT (device), "PinosNode");
node = g_object_steal_data (G_OBJECT (device), "PinosServerNode");
g_object_unref (node);
g_free (name);
}

View file

@ -41,8 +41,6 @@ struct _PinosGstSinkPrivate
GstNetTimeProvider *provider;
PinosProperties *props;
gint n_channels;
};
enum {
@ -51,7 +49,7 @@ enum {
PROP_POSSIBLE_FORMATS
};
G_DEFINE_TYPE (PinosGstSink, pinos_gst_sink, PINOS_TYPE_NODE);
G_DEFINE_TYPE (PinosGstSink, pinos_gst_sink, PINOS_TYPE_SERVER_NODE);
static gboolean
bus_handler (GstBus *bus,
@ -143,6 +141,7 @@ setup_pipeline (PinosGstSink *sink, GError **error)
return TRUE;
}
#if 0
static gboolean
start_pipeline (PinosGstSink *sink, GError **error)
{
@ -186,6 +185,7 @@ ready_failed:
return FALSE;
}
}
#endif
static void
stop_pipeline (PinosGstSink *sink)
@ -240,11 +240,13 @@ set_state (PinosNode *node,
return TRUE;
}
#if 0
static void
on_socket_notify (GObject *gobject,
GParamSpec *pspec,
gpointer user_data)
{
PinosNode *node = user_data;
PinosGstSink *sink = user_data;
PinosGstSinkPrivate *priv = sink->priv;
GSocket *socket;
@ -268,7 +270,7 @@ on_socket_notify (GObject *gobject,
}
if (num_handles == 0) {
pinos_node_report_idle (PINOS_NODE (sink));
pinos_node_report_idle (node);
g_object_set (priv->depay, "caps", NULL, NULL);
str = gst_caps_to_string (priv->possible_formats);
@ -298,7 +300,7 @@ on_socket_notify (GObject *gobject,
}
/* this is what we use as the final format for the output */
g_object_set (gobject, "format", format, NULL);
pinos_node_report_busy (PINOS_NODE (sink));
pinos_node_report_busy (node);
g_object_unref (socket);
}
@ -310,31 +312,7 @@ on_socket_notify (GObject *gobject,
g_object_set (gobject, "properties", props, NULL);
pinos_properties_free (props);
}
static void
on_channel_added (PinosPort *port, PinosChannel *channel, PinosGstSink *sink)
{
PinosGstSinkPrivate *priv = sink->priv;
GError *error = NULL;
if (priv->n_channels == 0) {
if (!start_pipeline (sink, &error))
return;
}
g_signal_connect (channel, "notify::socket", (GCallback) on_socket_notify, sink);
priv->n_channels++;
}
static void
on_channel_removed (PinosPort *port, PinosChannel *channel, PinosGstSink *sink)
{
PinosGstSinkPrivate *priv = sink->priv;
priv->n_channels--;
if (priv->n_channels == 0)
stop_pipeline (sink);
}
#endif
static void
get_property (GObject *object,
@ -384,10 +362,23 @@ set_property (GObject *object,
}
}
static void
on_input_port_created (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
PinosNode *node = PINOS_NODE (source_object);
PinosGstSinkPrivate *priv = PINOS_GST_SINK (node)->priv;
priv->input = pinos_node_create_port_finish (node, res, NULL);
}
static void
sink_constructed (GObject * object)
{
PinosNode *node = PINOS_NODE (object);
PinosServerNode *node = PINOS_SERVER_NODE (object);
PinosGstSink *sink = PINOS_GST_SINK (object);
PinosGstSinkPrivate *priv = sink->priv;
gchar *str;
@ -398,19 +389,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_get_daemon (node),
pinos_node_get_object_path (node),
PINOS_DIRECTION_INPUT,
"input",
format,
NULL);
pinos_node_create_port (PINOS_NODE (node),
PINOS_DIRECTION_INPUT,
"input",
format,
NULL,
NULL,
on_input_port_created,
node);
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);
setup_pipeline (sink, NULL);
}
@ -471,14 +459,14 @@ pinos_gst_sink_init (PinosGstSink * sink)
priv->props = pinos_properties_new (NULL, NULL);
}
PinosNode *
PinosServerNode *
pinos_gst_sink_new (PinosDaemon *daemon,
const gchar *name,
PinosProperties *properties,
GstElement *element,
GstCaps *caps)
{
PinosNode *node;
PinosServerNode *node;
node = g_object_new (PINOS_TYPE_GST_SINK,
"daemon", daemon,

View file

@ -23,7 +23,7 @@
#include <glib-object.h>
#include <client/pinos.h>
#include <server/node.h>
#include <server/server-node.h>
G_BEGIN_DECLS
@ -41,22 +41,22 @@ typedef struct _PinosGstSinkClass PinosGstSinkClass;
typedef struct _PinosGstSinkPrivate PinosGstSinkPrivate;
struct _PinosGstSink {
PinosNode object;
PinosServerNode object;
PinosGstSinkPrivate *priv;
};
struct _PinosGstSinkClass {
PinosNodeClass parent_class;
PinosServerNodeClass parent_class;
};
GType pinos_gst_sink_get_type (void);
GType pinos_gst_sink_get_type (void);
PinosNode * pinos_gst_sink_new (PinosDaemon *daemon,
const gchar *name,
PinosProperties *properties,
GstElement *element,
GstCaps *caps);
PinosServerNode * pinos_gst_sink_new (PinosDaemon *daemon,
const gchar *name,
PinosProperties *properties,
GstElement *element,
GstCaps *caps);
G_END_DECLS

View file

@ -41,8 +41,6 @@ struct _PinosGstSourcePrivate
GstNetTimeProvider *provider;
PinosProperties *props;
gint n_channels;
};
enum {
@ -51,7 +49,7 @@ enum {
PROP_POSSIBLE_FORMATS
};
G_DEFINE_TYPE (PinosGstSource, pinos_gst_source, PINOS_TYPE_NODE);
G_DEFINE_TYPE (PinosGstSource, pinos_gst_source, PINOS_TYPE_SERVER_NODE);
static gboolean
bus_handler (GstBus *bus,
@ -144,6 +142,7 @@ setup_pipeline (PinosGstSource *source, GError **error)
return TRUE;
}
#if 0
static gboolean
start_pipeline (PinosGstSource *source, GError **error)
{
@ -183,6 +182,7 @@ ready_failed:
return FALSE;
}
}
#endif
static void
stop_pipeline (PinosGstSource *source)
@ -286,6 +286,7 @@ set_state (PinosNode *node,
return TRUE;
}
#if 0
static void
on_socket_notify (GObject *gobject,
GParamSpec *pspec,
@ -363,31 +364,7 @@ on_socket_notify (GObject *gobject,
g_object_set (gobject, "properties", props, NULL);
pinos_properties_free (props);
}
static void
on_channel_added (PinosPort *port, PinosChannel *channel, PinosGstSource *source)
{
PinosGstSourcePrivate *priv = source->priv;
GError *error = NULL;
if (priv->n_channels == 0) {
if (!start_pipeline (source, &error))
return;
}
g_signal_connect (channel, "notify::socket", (GCallback) on_socket_notify, source);
priv->n_channels++;
}
static void
on_channel_removed (PinosPort *port, PinosChannel *channel, PinosGstSource *source)
{
PinosGstSourcePrivate *priv = source->priv;
priv->n_channels--;
if (priv->n_channels == 0)
stop_pipeline (source);
}
#endif
static void
get_property (GObject *object,
@ -437,10 +414,21 @@ set_property (GObject *object,
}
}
static void
on_output_port_created (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
PinosNode *node = PINOS_NODE (source_object);
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (node)->priv;
priv->output = pinos_node_create_port_finish (node, res, NULL);
}
static void
source_constructed (GObject * object)
{
PinosNode *node = PINOS_NODE (object);
PinosServerNode *node = PINOS_SERVER_NODE (object);
PinosGstSource *source = PINOS_GST_SOURCE (object);
PinosGstSourcePrivate *priv = source->priv;
gchar *str;
@ -451,30 +439,27 @@ 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_get_daemon (node),
pinos_node_get_object_path (node),
PINOS_DIRECTION_OUTPUT,
"output",
format,
NULL);
pinos_node_create_port (PINOS_NODE (node),
PINOS_DIRECTION_OUTPUT,
"output",
format,
NULL,
NULL,
on_output_port_created,
node);
g_bytes_unref (format);
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);
PinosServerNode *node = PINOS_SERVER_NODE (object);
PinosGstSource *source = PINOS_GST_SOURCE (object);
PinosGstSourcePrivate *priv = source->priv;
pinos_node_remove_port (node, priv->output);
pinos_node_remove_port (PINOS_NODE (node), priv->output);
destroy_pipeline (source);
g_clear_pointer (&priv->possible_formats, gst_caps_unref);
pinos_properties_free (priv->props);
@ -526,14 +511,14 @@ pinos_gst_source_init (PinosGstSource * source)
priv->props = pinos_properties_new (NULL, NULL);
}
PinosNode *
PinosServerNode *
pinos_gst_source_new (PinosDaemon *daemon,
const gchar *name,
PinosProperties *properties,
GstElement *element,
GstCaps *caps)
{
PinosNode *node;
PinosServerNode *node;
node = g_object_new (PINOS_TYPE_GST_SOURCE,
"daemon", daemon,

View file

@ -23,7 +23,7 @@
#include <glib-object.h>
#include <client/pinos.h>
#include <server/node.h>
#include <server/server-node.h>
G_BEGIN_DECLS
@ -41,22 +41,22 @@ typedef struct _PinosGstSourceClass PinosGstSourceClass;
typedef struct _PinosGstSourcePrivate PinosGstSourcePrivate;
struct _PinosGstSource {
PinosNode object;
PinosServerNode object;
PinosGstSourcePrivate *priv;
};
struct _PinosGstSourceClass {
PinosNodeClass parent_class;
PinosServerNodeClass parent_class;
};
GType pinos_gst_source_get_type (void);
GType pinos_gst_source_get_type (void);
PinosNode * pinos_gst_source_new (PinosDaemon *daemon,
const gchar *name,
PinosProperties *properties,
GstElement *element,
GstCaps *caps);
PinosServerNode * pinos_gst_source_new (PinosDaemon *daemon,
const gchar *name,
PinosProperties *properties,
GstElement *element,
GstCaps *caps);
G_END_DECLS