mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
Introduce the concept of a Port
A port is an input or output on a Node. Channels are created from the ports and inherit the direction of the port. do automatic port selection based on the direction and caps and node/port name. Simplify stream_connect by passing the direction. Fix pinossink to connect in setcaps so that we know the format and can select a good sink to connect to.
This commit is contained in:
parent
b885d40390
commit
ba4ef9b5d9
35 changed files with 1939 additions and 2120 deletions
|
|
@ -206,9 +206,8 @@ libpinoscore_@PINOS_MAJORMINOR@_la_SOURCES = \
|
||||||
server/client.c server/client.h \
|
server/client.c server/client.h \
|
||||||
server/daemon.c server/daemon.h \
|
server/daemon.c server/daemon.h \
|
||||||
server/node.c server/node.h \
|
server/node.c server/node.h \
|
||||||
server/source.c server/source.h \
|
server/port.c server/port.h \
|
||||||
server/sink.c server/sink.h \
|
server/upload-node.c server/upload-node.h \
|
||||||
server/client-source.c server/client-source.h \
|
|
||||||
server/channel.c server/channel.h \
|
server/channel.c server/channel.h \
|
||||||
modules/gst/gst-manager.c modules/gst/gst-manager.h \
|
modules/gst/gst-manager.c modules/gst/gst-manager.h \
|
||||||
modules/gst/gst-source.c modules/gst/gst-source.h \
|
modules/gst/gst-source.c modules/gst/gst-source.h \
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ gboolean pinos_buffer_builder_add_release_fd_payload (PinosBufferBuil
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
guint8 id;
|
guint8 id;
|
||||||
gchar *format;
|
const gchar *format;
|
||||||
} PinosPacketFormatChange;
|
} PinosPacketFormatChange;
|
||||||
|
|
||||||
gboolean pinos_buffer_iter_parse_format_change (PinosBufferIter *iter,
|
gboolean pinos_buffer_iter_parse_format_change (PinosBufferIter *iter,
|
||||||
|
|
@ -207,8 +207,8 @@ gboolean pinos_buffer_builder_add_format_change (PinosBufferBuilder
|
||||||
* A new property change.
|
* A new property change.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *key;
|
const gchar *key;
|
||||||
gchar *value;
|
const gchar *value;
|
||||||
} PinosPacketPropertyChange;
|
} PinosPacketPropertyChange;
|
||||||
|
|
||||||
gboolean pinos_buffer_iter_parse_property_change (PinosBufferIter *iter,
|
gboolean pinos_buffer_iter_parse_property_change (PinosBufferIter *iter,
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,8 @@ pinos_context_finalize (GObject * object)
|
||||||
if (priv->properties)
|
if (priv->properties)
|
||||||
pinos_properties_free (priv->properties);
|
pinos_properties_free (priv->properties);
|
||||||
|
|
||||||
g_list_free (priv->sources);
|
g_list_free (priv->nodes);
|
||||||
g_list_free (priv->sinks);
|
g_list_free (priv->ports);
|
||||||
g_list_free (priv->clients);
|
g_list_free (priv->clients);
|
||||||
g_list_free (priv->channels);
|
g_list_free (priv->channels);
|
||||||
g_clear_object (&priv->subscribe);
|
g_clear_object (&priv->subscribe);
|
||||||
|
|
@ -488,18 +488,18 @@ subscription_cb (PinosSubscribe *subscribe,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SUBSCRIPTION_FLAG_SOURCE:
|
case PINOS_SUBSCRIPTION_FLAG_NODE:
|
||||||
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
|
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
|
||||||
priv->sources = g_list_prepend (priv->sources, object);
|
priv->nodes = g_list_prepend (priv->nodes, object);
|
||||||
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
|
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
|
||||||
priv->sources = g_list_remove (priv->sources, object);
|
priv->nodes = g_list_remove (priv->nodes, object);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SUBSCRIPTION_FLAG_SINK:
|
case PINOS_SUBSCRIPTION_FLAG_PORT:
|
||||||
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
|
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
|
||||||
priv->sinks = g_list_prepend (priv->sinks, object);
|
priv->ports = g_list_prepend (priv->ports, object);
|
||||||
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
|
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
|
||||||
priv->sinks = g_list_remove (priv->sinks, object);
|
priv->ports = g_list_remove (priv->ports, object);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SUBSCRIPTION_FLAG_CHANNEL:
|
case PINOS_SUBSCRIPTION_FLAG_CHANNEL:
|
||||||
|
|
|
||||||
|
|
@ -274,69 +274,66 @@ pinos_context_get_client_info_by_id (PinosContext *context,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_source_state_as_string:
|
* pinos_node_state_as_string:
|
||||||
* @state: a #PinosSourceState
|
* @state: a #PinosNodeeState
|
||||||
*
|
*
|
||||||
* Return the string representation of @state.
|
* Return the string representation of @state.
|
||||||
*
|
*
|
||||||
* Returns: the string representation of @state.
|
* Returns: the string representation of @state.
|
||||||
*/
|
*/
|
||||||
const gchar *
|
const gchar *
|
||||||
pinos_source_state_as_string (PinosSourceState state)
|
pinos_node_state_as_string (PinosNodeState state)
|
||||||
{
|
{
|
||||||
GEnumValue *val;
|
GEnumValue *val;
|
||||||
|
|
||||||
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_SOURCE_STATE)),
|
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_NODE_STATE)),
|
||||||
state);
|
state);
|
||||||
|
|
||||||
return val == NULL ? "invalid-state" : val->value_nick;
|
return val == NULL ? "invalid-state" : val->value_nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
source_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
|
node_fill_info (PinosNodeInfo *info, GDBusProxy *proxy)
|
||||||
{
|
{
|
||||||
GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties");
|
GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties");
|
||||||
|
|
||||||
info->id = proxy;
|
info->id = proxy;
|
||||||
info->source_path = g_dbus_proxy_get_object_path (proxy);
|
info->node_path = g_dbus_proxy_get_object_path (proxy);
|
||||||
|
|
||||||
info->change_mask = 0;
|
info->change_mask = 0;
|
||||||
SET_STRING ("Name", name, 0);
|
SET_STRING ("Name", name, 0);
|
||||||
SET_PROPERTIES ("Properties", properties, 1);
|
SET_PROPERTIES ("Properties", properties, 1);
|
||||||
SET_UINT32 ("State", state, 2, PINOS_SOURCE_STATE_ERROR);
|
SET_UINT32 ("State", state, 2, PINOS_NODE_STATE_ERROR);
|
||||||
SET_BYTES ("PossibleFormats", possible_formats, 3);
|
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
g_hash_table_remove_all (changed);
|
g_hash_table_remove_all (changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
source_clear_info (PinosSourceInfo *info)
|
node_clear_info (PinosNodeInfo *info)
|
||||||
{
|
{
|
||||||
if (info->properties)
|
if (info->properties)
|
||||||
pinos_properties_free (info->properties);
|
pinos_properties_free (info->properties);
|
||||||
if (info->possible_formats)
|
|
||||||
g_bytes_unref (info->possible_formats);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_context_list_source_info:
|
* pinos_context_list_node_info:
|
||||||
* @context: a connected #PinosContext
|
* @context: a connected #PinosContext
|
||||||
* @flags: extra #PinosSourceInfoFlags
|
* @flags: extra #PinosNodeInfoFlags
|
||||||
* @cb: a #PinosSourceInfoCallback
|
* @cb: a #PinosNodeInfoCallback
|
||||||
* @cancelable: a #GCancellable
|
* @cancelable: a #GCancellable
|
||||||
* @callback: a #GAsyncReadyCallback to call when the operation is finished
|
* @callback: a #GAsyncReadyCallback to call when the operation is finished
|
||||||
* @user_data: user data passed to @cb
|
* @user_data: user data passed to @cb
|
||||||
*
|
*
|
||||||
* Call @cb for each source.
|
* Call @cb for each node.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pinos_context_list_source_info (PinosContext *context,
|
pinos_context_list_node_info (PinosContext *context,
|
||||||
PinosSourceInfoFlags flags,
|
PinosNodeInfoFlags flags,
|
||||||
PinosSourceInfoCallback cb,
|
PinosNodeInfoCallback cb,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosContextPrivate *priv;
|
PinosContextPrivate *priv;
|
||||||
GList *walk;
|
GList *walk;
|
||||||
|
|
@ -349,13 +346,13 @@ pinos_context_list_source_info (PinosContext *context,
|
||||||
|
|
||||||
priv = context->priv;
|
priv = context->priv;
|
||||||
|
|
||||||
for (walk = priv->sources; walk; walk = g_list_next (walk)) {
|
for (walk = priv->nodes; walk; walk = g_list_next (walk)) {
|
||||||
GDBusProxy *proxy = walk->data;
|
GDBusProxy *proxy = walk->data;
|
||||||
PinosSourceInfo info;
|
PinosNodeInfo info;
|
||||||
|
|
||||||
source_fill_info (&info, proxy);
|
node_fill_info (&info, proxy);
|
||||||
cb (context, &info, user_data);
|
cb (context, &info, user_data);
|
||||||
source_clear_info (&info);
|
node_clear_info (&info);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
|
|
@ -363,27 +360,27 @@ pinos_context_list_source_info (PinosContext *context,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_context_get_source_info_by_id:
|
* pinos_context_get_node_info_by_id:
|
||||||
* @context: a connected #PinosContext
|
* @context: a connected #PinosContext
|
||||||
* @id: a source id
|
* @id: a node id
|
||||||
* @flags: extra #PinosSourceInfoFlags
|
* @flags: extra #PinosNodeInfoFlags
|
||||||
* @cb: a #PinosSourceInfoCallback
|
* @cb: a #PinosNodeInfoCallback
|
||||||
* @cancelable: a #GCancellable
|
* @cancelable: a #GCancellable
|
||||||
* @callback: a #GAsyncReadyCallback to call when the operation is finished
|
* @callback: a #GAsyncReadyCallback to call when the operation is finished
|
||||||
* @user_data: user data passed to @cb
|
* @user_data: user data passed to @cb
|
||||||
*
|
*
|
||||||
* Call @cb for the source with @id.
|
* Call @cb for the node with @id.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pinos_context_get_source_info_by_id (PinosContext *context,
|
pinos_context_get_node_info_by_id (PinosContext *context,
|
||||||
gpointer id,
|
gpointer id,
|
||||||
PinosSourceInfoFlags flags,
|
PinosNodeInfoFlags flags,
|
||||||
PinosSourceInfoCallback cb,
|
PinosNodeInfoCallback cb,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosSourceInfo info;
|
PinosNodeInfo info;
|
||||||
GDBusProxy *proxy;
|
GDBusProxy *proxy;
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
|
|
@ -395,53 +392,54 @@ pinos_context_get_source_info_by_id (PinosContext *context,
|
||||||
|
|
||||||
proxy = G_DBUS_PROXY (id);
|
proxy = G_DBUS_PROXY (id);
|
||||||
|
|
||||||
source_fill_info (&info, proxy);
|
node_fill_info (&info, proxy);
|
||||||
cb (context, &info, user_data);
|
cb (context, &info, user_data);
|
||||||
source_clear_info (&info);
|
node_clear_info (&info);
|
||||||
|
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_sink_state_as_string:
|
* pinos_direction_as_string:
|
||||||
* @state: a #PinosSinkState
|
* @direction: a #PinosDirection
|
||||||
*
|
*
|
||||||
* Return the string representation of @state.
|
* Return the string representation of @direction.
|
||||||
*
|
*
|
||||||
* Returns: the string representation of @state.
|
* Returns: the string representation of @direction.
|
||||||
*/
|
*/
|
||||||
const gchar *
|
const gchar *
|
||||||
pinos_sink_state_as_string (PinosSinkState state)
|
pinos_direction_as_string (PinosDirection direction)
|
||||||
{
|
{
|
||||||
GEnumValue *val;
|
GEnumValue *val;
|
||||||
|
|
||||||
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_SINK_STATE)),
|
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_DIRECTION)),
|
||||||
state);
|
direction);
|
||||||
|
|
||||||
return val == NULL ? "invalid-state" : val->value_nick;
|
return val == NULL ? "invalid-direction" : val->value_nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sink_fill_info (PinosSinkInfo *info, GDBusProxy *proxy)
|
port_fill_info (PinosPortInfo *info, GDBusProxy *proxy)
|
||||||
{
|
{
|
||||||
GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties");
|
GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties");
|
||||||
|
|
||||||
info->id = proxy;
|
info->id = proxy;
|
||||||
info->sink_path = g_dbus_proxy_get_object_path (proxy);
|
info->port_path = g_dbus_proxy_get_object_path (proxy);
|
||||||
|
SET_UINT32 ("Direction", direction, 0, PINOS_DIRECTION_INVALID);
|
||||||
|
SET_STRING ("Node", node_path, 0);
|
||||||
|
|
||||||
info->change_mask = 0;
|
info->change_mask = 0;
|
||||||
SET_STRING ("Name", name, 0);
|
SET_STRING ("Name", name, 0);
|
||||||
SET_PROPERTIES ("Properties", properties, 1);
|
SET_PROPERTIES ("Properties", properties, 1);
|
||||||
SET_UINT32 ("State", state, 2, PINOS_SINK_STATE_ERROR);
|
SET_BYTES ("PossibleFormats", possible_formats, 2);
|
||||||
SET_BYTES ("PossibleFormats", possible_formats, 3);
|
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
g_hash_table_remove_all (changed);
|
g_hash_table_remove_all (changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sink_clear_info (PinosSinkInfo *info)
|
port_clear_info (PinosPortInfo *info)
|
||||||
{
|
{
|
||||||
if (info->properties)
|
if (info->properties)
|
||||||
pinos_properties_free (info->properties);
|
pinos_properties_free (info->properties);
|
||||||
|
|
@ -450,20 +448,20 @@ sink_clear_info (PinosSinkInfo *info)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_context_list_sink_info:
|
* pinos_context_list_port_info:
|
||||||
* @context: a connected #PinosContext
|
* @context: a connected #PinosContext
|
||||||
* @flags: extra #PinosSinkInfoFlags
|
* @flags: extra #PinosPortInfoFlags
|
||||||
* @cb: a #PinosSinkInfoCallback
|
* @cb: a #PinosPortInfoCallback
|
||||||
* @cancelable: a #GCancellable
|
* @cancelable: a #GCancellable
|
||||||
* @callback: a #GAsyncReadyCallback to call when the operation is finished
|
* @callback: a #GAsyncReadyCallback to call when the operation is finished
|
||||||
* @user_data: user data passed to @cb
|
* @user_data: user data passed to @cb
|
||||||
*
|
*
|
||||||
* Call @cb for each sink.
|
* Call @cb for each port.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pinos_context_list_sink_info (PinosContext *context,
|
pinos_context_list_port_info (PinosContext *context,
|
||||||
PinosSinkInfoFlags flags,
|
PinosPortInfoFlags flags,
|
||||||
PinosSinkInfoCallback cb,
|
PinosPortInfoCallback cb,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
|
|
@ -479,13 +477,13 @@ pinos_context_list_sink_info (PinosContext *context,
|
||||||
|
|
||||||
priv = context->priv;
|
priv = context->priv;
|
||||||
|
|
||||||
for (walk = priv->sinks; walk; walk = g_list_next (walk)) {
|
for (walk = priv->ports; walk; walk = g_list_next (walk)) {
|
||||||
GDBusProxy *proxy = walk->data;
|
GDBusProxy *proxy = walk->data;
|
||||||
PinosSinkInfo info;
|
PinosPortInfo info;
|
||||||
|
|
||||||
sink_fill_info (&info, proxy);
|
port_fill_info (&info, proxy);
|
||||||
cb (context, &info, user_data);
|
cb (context, &info, user_data);
|
||||||
sink_clear_info (&info);
|
port_clear_info (&info);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
|
|
@ -493,27 +491,27 @@ pinos_context_list_sink_info (PinosContext *context,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_context_get_sink_info_by_id:
|
* pinos_context_get_port_info_by_id:
|
||||||
* @context: a connected #PinosContext
|
* @context: a connected #PinosContext
|
||||||
* @id: a sink id
|
* @id: a port id
|
||||||
* @flags: extra #PinosSinkInfoFlags
|
* @flags: extra #PinosPortInfoFlags
|
||||||
* @cb: a #PinosSinkInfoCallback
|
* @cb: a #PinosPortInfoCallback
|
||||||
* @cancelable: a #GCancellable
|
* @cancelable: a #GCancellable
|
||||||
* @callback: a #GAsyncReadyCallback to call when the operation is finished
|
* @callback: a #GAsyncReadyCallback to call when the operation is finished
|
||||||
* @user_data: user data passed to @cb
|
* @user_data: user data passed to @cb
|
||||||
*
|
*
|
||||||
* Call @cb for the sink with @id.
|
* Call @cb for the port with @id.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pinos_context_get_sink_info_by_id (PinosContext *context,
|
pinos_context_get_port_info_by_id (PinosContext *context,
|
||||||
gpointer id,
|
gpointer id,
|
||||||
PinosSinkInfoFlags flags,
|
PinosPortInfoFlags flags,
|
||||||
PinosSinkInfoCallback cb,
|
PinosPortInfoCallback cb,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosSinkInfo info;
|
PinosPortInfo info;
|
||||||
GDBusProxy *proxy;
|
GDBusProxy *proxy;
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
|
|
@ -525,9 +523,9 @@ pinos_context_get_sink_info_by_id (PinosContext *context,
|
||||||
|
|
||||||
proxy = G_DBUS_PROXY (id);
|
proxy = G_DBUS_PROXY (id);
|
||||||
|
|
||||||
sink_fill_info (&info, proxy);
|
port_fill_info (&info, proxy);
|
||||||
cb (context, &info, user_data);
|
cb (context, &info, user_data);
|
||||||
sink_clear_info (&info);
|
port_clear_info (&info);
|
||||||
|
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
|
|
@ -559,14 +557,15 @@ channel_fill_info (PinosChannelInfo *info, GDBusProxy *proxy)
|
||||||
|
|
||||||
info->id = proxy;
|
info->id = proxy;
|
||||||
info->channel_path = g_dbus_proxy_get_object_path (proxy);
|
info->channel_path = g_dbus_proxy_get_object_path (proxy);
|
||||||
|
SET_UINT32 ("Direction", direction, 2, PINOS_DIRECTION_INVALID);
|
||||||
|
SET_STRING ("Client", client_path, 0);
|
||||||
|
|
||||||
info->change_mask = 0;
|
info->change_mask = 0;
|
||||||
SET_STRING ("Client", client_path, 0);
|
SET_STRING ("Port", port_path, 0);
|
||||||
SET_STRING ("Owner", owner_path, 1);
|
SET_PROPERTIES ("Properties", properties, 1);
|
||||||
SET_BYTES ("PossibleFormats", possible_formats, 2);
|
SET_UINT32 ("State", state, 2, PINOS_CHANNEL_STATE_ERROR);
|
||||||
SET_UINT32 ("State", state, 3, PINOS_CHANNEL_STATE_ERROR);
|
SET_BYTES ("PossibleFormats", possible_formats, 3);
|
||||||
SET_BYTES ("Format", format, 4);
|
SET_BYTES ("Format", format, 4);
|
||||||
SET_PROPERTIES ("Properties", properties, 5);
|
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
g_hash_table_remove_all (changed);
|
g_hash_table_remove_all (changed);
|
||||||
|
|
@ -577,6 +576,8 @@ channel_clear_info (PinosChannelInfo *info)
|
||||||
{
|
{
|
||||||
if (info->possible_formats)
|
if (info->possible_formats)
|
||||||
g_bytes_unref (info->possible_formats);
|
g_bytes_unref (info->possible_formats);
|
||||||
|
if (info->format)
|
||||||
|
g_bytes_unref (info->format);
|
||||||
if (info->properties)
|
if (info->properties)
|
||||||
pinos_properties_free (info->properties);
|
pinos_properties_free (info->properties);
|
||||||
}
|
}
|
||||||
|
|
@ -627,7 +628,7 @@ pinos_context_list_channel_info (PinosContext *context,
|
||||||
/**
|
/**
|
||||||
* pinos_context_get_channel_info_by_id:
|
* pinos_context_get_channel_info_by_id:
|
||||||
* @context: a connected #PinosContext
|
* @context: a connected #PinosContext
|
||||||
* @id: a source output id
|
* @id: a channel id
|
||||||
* @flags: extra #PinosChannelInfoFlags
|
* @flags: extra #PinosChannelInfoFlags
|
||||||
* @cb: a #PinosChannelInfoCallback
|
* @cb: a #PinosChannelInfoCallback
|
||||||
* @cancelable: a #GCancellable
|
* @cancelable: a #GCancellable
|
||||||
|
|
|
||||||
|
|
@ -144,190 +144,167 @@ void pinos_context_get_client_info_by_id (PinosContext *context,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PinosSourceState:
|
* PinosNodeState:
|
||||||
* @PINOS_SOURCE_STATE_ERROR: the source is in error
|
* @PINOS_NODE_STATE_ERROR: the node is in error
|
||||||
* @PINOS_SOURCE_STATE_SUSPENDED: the source is suspended, the device might
|
* @PINOS_NODE_STATE_SUSPENDED: the node is suspended, the device might
|
||||||
* be closed
|
* be closed
|
||||||
* @PINOS_SOURCE_STATE_INITIALIZING: the source is initializing, the device is
|
* @PINOS_NODE_STATE_INITIALIZING: the node is initializing, the device is
|
||||||
* being opened and the capabilities are queried
|
* being opened and the capabilities are queried
|
||||||
* @PINOS_SOURCE_STATE_IDLE: the source is running but there is no active
|
* @PINOS_NODE_STATE_IDLE: the node is running but there is no active
|
||||||
* channel
|
|
||||||
* @PINOS_SOURCE_STATE_RUNNING: the source is running
|
|
||||||
*
|
|
||||||
* The different source states
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
PINOS_SOURCE_STATE_ERROR = -1,
|
|
||||||
PINOS_SOURCE_STATE_SUSPENDED = 0,
|
|
||||||
PINOS_SOURCE_STATE_INITIALIZING = 1,
|
|
||||||
PINOS_SOURCE_STATE_IDLE = 2,
|
|
||||||
PINOS_SOURCE_STATE_RUNNING = 3,
|
|
||||||
} PinosSourceState;
|
|
||||||
|
|
||||||
const gchar * pinos_source_state_as_string (PinosSourceState state);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PinosSourceInfo:
|
|
||||||
* @id: generic id of the source
|
|
||||||
* @source_path: the unique path of the source, suitable for connecting
|
|
||||||
* @change_mask: bitfield of changed fields since last call
|
|
||||||
* @name: name the source, suitable for display
|
|
||||||
* @properties: the properties of the source
|
|
||||||
* @state: the current state of the source
|
|
||||||
* @possible formats: the possible formats this source can produce
|
|
||||||
*
|
|
||||||
* The source information. Extra information can be added in later
|
|
||||||
* versions.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
gpointer id;
|
|
||||||
const char *source_path;
|
|
||||||
guint64 change_mask;
|
|
||||||
const char *name;
|
|
||||||
PinosProperties *properties;
|
|
||||||
PinosSourceState state;
|
|
||||||
GBytes *possible_formats;
|
|
||||||
} PinosSourceInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PinosSourceInfoFlags:
|
|
||||||
* @PINOS_SOURCE_INFO_FLAGS_NONE: no flags
|
|
||||||
* @PINOS_SOURCE_INFO_FLAGS_FORMATS: include formats
|
|
||||||
*
|
|
||||||
* Extra flags to pass to pinos_context_get_source_info_list.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
PINOS_SOURCE_INFO_FLAGS_NONE = 0,
|
|
||||||
PINOS_SOURCE_INFO_FLAGS_FORMATS = (1 << 0)
|
|
||||||
} PinosSourceInfoFlags;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PinosSourceInfoCallback:
|
|
||||||
* @c: a #PinosContext
|
|
||||||
* @info: a #PinosSourceInfo
|
|
||||||
* @user_data: user data
|
|
||||||
*
|
|
||||||
* Callback with information about the Pinos source in @info.
|
|
||||||
*/
|
|
||||||
typedef void (*PinosSourceInfoCallback) (PinosContext *c,
|
|
||||||
const PinosSourceInfo *info,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void pinos_context_list_source_info (PinosContext *context,
|
|
||||||
PinosSourceInfoFlags flags,
|
|
||||||
PinosSourceInfoCallback cb,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GAsyncReadyCallback callback,
|
|
||||||
gpointer user_data);
|
|
||||||
void pinos_context_get_source_info_by_id (PinosContext *context,
|
|
||||||
gpointer id,
|
|
||||||
PinosSourceInfoFlags flags,
|
|
||||||
PinosSourceInfoCallback cb,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GAsyncReadyCallback callback,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PinosSinkState:
|
|
||||||
* @PINOS_SINK_STATE_ERROR: the sink is in error
|
|
||||||
* @PINOS_SINK_STATE_SUSPENDED: the sink is suspended, the device might
|
|
||||||
* be closed
|
|
||||||
* @PINOS_SINK_STATE_INITIALIZING: the sink is initializing, the device is
|
|
||||||
* being opened and the capabilities are queried
|
|
||||||
* @PINOS_SINK_STATE_IDLE: the sink is running but there is no active
|
|
||||||
* channel
|
* channel
|
||||||
* @PINOS_SINK_STATE_RUNNING: the sink is running
|
* @PINOS_NODE_STATE_RUNNING: the node is running
|
||||||
*
|
*
|
||||||
* The different sink states
|
* The different node states
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PINOS_SINK_STATE_ERROR = -1,
|
PINOS_NODE_STATE_ERROR = -1,
|
||||||
PINOS_SINK_STATE_SUSPENDED = 0,
|
PINOS_NODE_STATE_SUSPENDED = 0,
|
||||||
PINOS_SINK_STATE_INITIALIZING = 1,
|
PINOS_NODE_STATE_INITIALIZING = 1,
|
||||||
PINOS_SINK_STATE_IDLE = 2,
|
PINOS_NODE_STATE_IDLE = 2,
|
||||||
PINOS_SINK_STATE_RUNNING = 3,
|
PINOS_NODE_STATE_RUNNING = 3,
|
||||||
} PinosSinkState;
|
} PinosNodeState;
|
||||||
|
|
||||||
const gchar * pinos_sink_state_as_string (PinosSinkState state);
|
const gchar * pinos_node_state_as_string (PinosNodeState state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PinosSinkInfo:
|
* PinosNodeInfo:
|
||||||
* @id: generic id of the sink
|
* @id: generic id of the node
|
||||||
* @sink_path: the unique path of the sink, suitable for connecting
|
* @node_path: the unique path of the node
|
||||||
* @change_mask: bitfield of changed fields since last call
|
* @change_mask: bitfield of changed fields since last call
|
||||||
* @name: name the sink, suitable for display
|
* @name: name the node, suitable for display
|
||||||
* @properties: the properties of the sink
|
* @properties: the properties of the node
|
||||||
* @state: the current state of the sink
|
* @state: the current state of the node
|
||||||
* @possible formats: the possible formats this sink can consume
|
|
||||||
*
|
*
|
||||||
* The sink information. Extra information can be added in later
|
* The node information. Extra information can be added in later
|
||||||
* versions.
|
* versions.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gpointer id;
|
gpointer id;
|
||||||
const char *sink_path;
|
const char *node_path;
|
||||||
guint64 change_mask;
|
guint64 change_mask;
|
||||||
const char *name;
|
const char *name;
|
||||||
PinosProperties *properties;
|
PinosProperties *properties;
|
||||||
PinosSinkState state;
|
PinosNodeState state;
|
||||||
GBytes *possible_formats;
|
} PinosNodeInfo;
|
||||||
} PinosSinkInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PinosSinkInfoFlags:
|
* PinosNodeInfoFlags:
|
||||||
* @PINOS_SINK_INFO_FLAGS_NONE: no flags
|
* @PINOS_NODE_INFO_FLAGS_NONE: no flags
|
||||||
* @PINOS_SINK_INFO_FLAGS_FORMATS: include formats
|
|
||||||
*
|
*
|
||||||
* Extra flags to pass to pinos_context_get_sink_info_list.
|
* Extra flags to pass to pinos_context_get_node_info_list.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PINOS_SINK_INFO_FLAGS_NONE = 0,
|
PINOS_NODE_INFO_FLAGS_NONE = 0,
|
||||||
PINOS_SINK_INFO_FLAGS_FORMATS = (1 << 0)
|
} PinosNodeInfoFlags;
|
||||||
} PinosSinkInfoFlags;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PinosSinkInfoCallback:
|
* PinosNodeInfoCallback:
|
||||||
* @c: a #PinosContext
|
* @c: a #PinosContext
|
||||||
* @info: a #PinosSinkInfo
|
* @info: a #PinosNodeInfo
|
||||||
* @user_data: user data
|
* @user_data: user data
|
||||||
*
|
*
|
||||||
* Callback with information about the Pinos sink in @info.
|
* Callback with information about the Pinos node in @info.
|
||||||
*/
|
*/
|
||||||
typedef void (*PinosSinkInfoCallback) (PinosContext *c,
|
typedef void (*PinosNodeInfoCallback) (PinosContext *c,
|
||||||
const PinosSinkInfo *info,
|
const PinosNodeInfo *info,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void pinos_context_list_sink_info (PinosContext *context,
|
void pinos_context_list_node_info (PinosContext *context,
|
||||||
PinosSinkInfoFlags flags,
|
PinosNodeInfoFlags flags,
|
||||||
PinosSinkInfoCallback cb,
|
PinosNodeInfoCallback cb,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
void pinos_context_get_sink_info_by_id (PinosContext *context,
|
void pinos_context_get_node_info_by_id (PinosContext *context,
|
||||||
gpointer id,
|
gpointer id,
|
||||||
PinosSinkInfoFlags flags,
|
PinosNodeInfoFlags flags,
|
||||||
PinosSinkInfoCallback cb,
|
PinosNodeInfoCallback cb,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PinosChannelType:
|
* PinosDirection:
|
||||||
* @PINOS_CHANNEL_TYPE_UNKNOWN: an unknown channel type
|
* @PINOS_DIRECTION_INVALID: invalid direction
|
||||||
* @PINOS_CHANNEL_TYPE_INPUT: an input channel type
|
* @PINOS_DIRECTION_INPUT: an input port/channel
|
||||||
* @PINOS_CHANNEL_TYPE_OUTPUT: an output channel type
|
* @PINOS_DIRECTION_OUTPUT: an output port/channel
|
||||||
*
|
*
|
||||||
* The different channel states
|
* The direction of a port or channel
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PINOS_CHANNEL_TYPE_UNKNOWN = 0,
|
PINOS_DIRECTION_INVALID = -1,
|
||||||
PINOS_CHANNEL_TYPE_INPUT = 1,
|
PINOS_DIRECTION_INPUT = 0,
|
||||||
PINOS_CHANNEL_TYPE_OUTPUT = 2,
|
PINOS_DIRECTION_OUTPUT = 1
|
||||||
} PinosChannelType;
|
} PinosDirection;
|
||||||
|
|
||||||
|
const gchar * pinos_direction_as_string (PinosDirection direction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PinosPortInfo:
|
||||||
|
* @id: generic id of the port
|
||||||
|
* @port_path: the unique path of the port, suitable for connecting
|
||||||
|
* @node_path: the node path of the port
|
||||||
|
* @direction: the direction of the port
|
||||||
|
* @change_mask: bitfield of changed fields since last call
|
||||||
|
* @name: name the port, suitable for display
|
||||||
|
* @properties: the properties of the port
|
||||||
|
* @possible formats: the possible formats this port can consume
|
||||||
|
*
|
||||||
|
* The port information. Extra information can be added in later
|
||||||
|
* versions.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
gpointer id;
|
||||||
|
const char *port_path;
|
||||||
|
const char *node_path;
|
||||||
|
PinosDirection direction;
|
||||||
|
guint64 change_mask;
|
||||||
|
const char *name;
|
||||||
|
PinosProperties *properties;
|
||||||
|
GBytes *possible_formats;
|
||||||
|
} PinosPortInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PinosPortInfoFlags:
|
||||||
|
* @PINOS_PORT_INFO_FLAGS_NONE: no flags
|
||||||
|
* @PINOS_PORT_INFO_FLAGS_FORMATS: include formats
|
||||||
|
*
|
||||||
|
* Extra flags to pass to pinos_context_get_port_info_list.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
PINOS_PORT_INFO_FLAGS_NONE = 0,
|
||||||
|
PINOS_PORT_INFO_FLAGS_FORMATS = (1 << 0)
|
||||||
|
} PinosPortInfoFlags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PinosPortInfoCallback:
|
||||||
|
* @c: a #PinosContext
|
||||||
|
* @info: a #PinosPortInfo
|
||||||
|
* @user_data: user data
|
||||||
|
*
|
||||||
|
* Callback with information about the Pinos port in @info.
|
||||||
|
*/
|
||||||
|
typedef void (*PinosPortInfoCallback) (PinosContext *c,
|
||||||
|
const PinosPortInfo *info,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void pinos_context_list_port_info (PinosContext *context,
|
||||||
|
PinosPortInfoFlags flags,
|
||||||
|
PinosPortInfoCallback cb,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
void pinos_context_get_port_info_by_id (PinosContext *context,
|
||||||
|
gpointer id,
|
||||||
|
PinosPortInfoFlags flags,
|
||||||
|
PinosPortInfoCallback cb,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
/**
|
/**
|
||||||
* PinosChannelState:
|
* PinosChannelState:
|
||||||
* @PINOS_CHANNEL_STATE_ERROR: the channel is in error
|
* @PINOS_CHANNEL_STATE_ERROR: the channel is in error
|
||||||
* @PINOS_CHANNEL_STATE_IDLE: the channel is idle
|
* @PINOS_CHANNEL_STATE_STOPPED: the channel is stopped
|
||||||
* @PINOS_CHANNEL_STATE_STARTING: the channel is starting
|
* @PINOS_CHANNEL_STATE_STARTING: the channel is starting
|
||||||
* @PINOS_CHANNEL_STATE_STREAMING: the channel is streaming
|
* @PINOS_CHANNEL_STATE_STREAMING: the channel is streaming
|
||||||
*
|
*
|
||||||
|
|
@ -335,7 +312,7 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PINOS_CHANNEL_STATE_ERROR = -1,
|
PINOS_CHANNEL_STATE_ERROR = -1,
|
||||||
PINOS_CHANNEL_STATE_IDLE = 0,
|
PINOS_CHANNEL_STATE_STOPPED = 0,
|
||||||
PINOS_CHANNEL_STATE_STARTING = 1,
|
PINOS_CHANNEL_STATE_STARTING = 1,
|
||||||
PINOS_CHANNEL_STATE_STREAMING = 2,
|
PINOS_CHANNEL_STATE_STREAMING = 2,
|
||||||
} PinosChannelState;
|
} PinosChannelState;
|
||||||
|
|
@ -346,14 +323,14 @@ const gchar * pinos_channel_state_as_string (PinosChannelState state);
|
||||||
* PinosChannelInfo:
|
* PinosChannelInfo:
|
||||||
* @id: generic id of the channel_
|
* @id: generic id of the channel_
|
||||||
* @channel_path: the unique path of the channel
|
* @channel_path: the unique path of the channel
|
||||||
* @change_mask: bitfield of changed fields since last call
|
* @direction: the channel direction
|
||||||
* @client_path: the owner client
|
* @client_path: the owner client
|
||||||
* @owner_path: the owner source or sink path
|
* @change_mask: bitfield of changed fields since last call
|
||||||
* @type: the channel type
|
* @port_path: the owner port
|
||||||
* @possible_formats: the possible formats
|
|
||||||
* @state: the state
|
|
||||||
* @format: when streaming, the current format
|
|
||||||
* @properties: the properties of the channel
|
* @properties: the properties of the channel
|
||||||
|
* @state: the state
|
||||||
|
* @possible_formats: the possible formats
|
||||||
|
* @format: when streaming, the current format
|
||||||
*
|
*
|
||||||
* The channel information. Extra information can be added in later
|
* The channel information. Extra information can be added in later
|
||||||
* versions.
|
* versions.
|
||||||
|
|
@ -361,29 +338,29 @@ const gchar * pinos_channel_state_as_string (PinosChannelState state);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gpointer id;
|
gpointer id;
|
||||||
const char *channel_path;
|
const char *channel_path;
|
||||||
guint64 change_mask;
|
PinosDirection direction;
|
||||||
const char *client_path;
|
const char *client_path;
|
||||||
const char *owner_path;
|
guint64 change_mask;
|
||||||
PinosChannelType type;
|
const char *port_path;
|
||||||
GBytes *possible_formats;
|
|
||||||
PinosChannelState state;
|
|
||||||
GBytes *format;
|
|
||||||
PinosProperties *properties;
|
PinosProperties *properties;
|
||||||
|
PinosChannelState state;
|
||||||
|
GBytes *possible_formats;
|
||||||
|
GBytes *format;
|
||||||
} PinosChannelInfo;
|
} PinosChannelInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PinosChannelInfoFlags:
|
* PinosChannelInfoFlags:
|
||||||
* @PINOS_CHANNEL_INFO_FLAGS_NONE: no flags
|
* @PINOS_CHANNEL_INFO_FLAGS_NONE: no flags
|
||||||
* @PINOS_CHANNEL_INFO_FLAGS_NO_SOURCE: don't list source channels
|
* @PINOS_CHANNEL_INFO_FLAGS_NO_INPUT: don't list input channels
|
||||||
* @PINOS_CHANNEL_INFO_FLAGS_NO_SINK: don't list sink channels
|
* @PINOS_CHANNEL_INFO_FLAGS_NO_OUTPUT: don't list output channels
|
||||||
*
|
*
|
||||||
* Extra flags to pass to pinos_context_list_channel_info() and
|
* Extra flags to pass to pinos_context_list_channel_info() and
|
||||||
* pinos_context_get_channel_info_by_id().
|
* pinos_context_get_channel_info_by_id().
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PINOS_CHANNEL_INFO_FLAGS_NONE = 0,
|
PINOS_CHANNEL_INFO_FLAGS_NONE = 0,
|
||||||
PINOS_CHANNEL_INFO_FLAGS_NO_SOURCE = (1 << 0),
|
PINOS_CHANNEL_INFO_FLAGS_NO_INPUT = (1 << 0),
|
||||||
PINOS_CHANNEL_INFO_FLAGS_NO_SINK = (1 << 1),
|
PINOS_CHANNEL_INFO_FLAGS_NO_OUTPUT = (1 << 1),
|
||||||
} PinosChannelInfoFlags;
|
} PinosChannelInfoFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#define PINOS_DBUS_OBJECT_PREFIX "/org/pinos"
|
#define PINOS_DBUS_OBJECT_PREFIX "/org/pinos"
|
||||||
#define PINOS_DBUS_OBJECT_SERVER PINOS_DBUS_OBJECT_PREFIX "/server"
|
#define PINOS_DBUS_OBJECT_SERVER PINOS_DBUS_OBJECT_PREFIX "/server"
|
||||||
#define PINOS_DBUS_OBJECT_NODE PINOS_DBUS_OBJECT_PREFIX "/node"
|
#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_CLIENT PINOS_DBUS_OBJECT_PREFIX "/client"
|
||||||
|
|
||||||
void pinos_init (int *argc, char **argv[]);
|
void pinos_init (int *argc, char **argv[]);
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ struct _PinosContextPrivate
|
||||||
PinosSubscribe *subscribe;
|
PinosSubscribe *subscribe;
|
||||||
|
|
||||||
GList *clients;
|
GList *clients;
|
||||||
GList *sources;
|
GList *nodes;
|
||||||
GList *sinks;
|
GList *ports;
|
||||||
GList *channels;
|
GList *channels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ struct _PinosStreamPrivate
|
||||||
PinosStreamState state;
|
PinosStreamState state;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
|
PinosDirection direction;
|
||||||
gchar *path;
|
gchar *path;
|
||||||
GBytes *possible_formats;
|
GBytes *possible_formats;
|
||||||
gboolean provide;
|
gboolean provide;
|
||||||
|
|
@ -596,14 +597,15 @@ create_failed:
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
do_connect_source (PinosStream *stream)
|
do_connect (PinosStream *stream)
|
||||||
{
|
{
|
||||||
PinosStreamPrivate *priv = stream->priv;
|
PinosStreamPrivate *priv = stream->priv;
|
||||||
PinosContext *context = priv->context;
|
PinosContext *context = priv->context;
|
||||||
|
|
||||||
g_dbus_proxy_call (context->priv->client,
|
g_dbus_proxy_call (context->priv->client,
|
||||||
"CreateSourceChannel",
|
"CreateChannel",
|
||||||
g_variant_new ("(ss@a{sv})",
|
g_variant_new ("(uss@a{sv})",
|
||||||
|
priv->direction,
|
||||||
(priv->path ? priv->path : ""),
|
(priv->path ? priv->path : ""),
|
||||||
g_bytes_get_data (priv->possible_formats, NULL),
|
g_bytes_get_data (priv->possible_formats, NULL),
|
||||||
pinos_properties_to_variant (priv->properties)),
|
pinos_properties_to_variant (priv->properties)),
|
||||||
|
|
@ -617,21 +619,23 @@ do_connect_source (PinosStream *stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_stream_connect_source:
|
* pinos_stream_connect:
|
||||||
* @stream: a #PinosStream
|
* @stream: a #PinosStream
|
||||||
* @source_path: the source path to connect to
|
* @direction: the stream direction
|
||||||
|
* @port_path: the port path to connect to or %NULL to get the default port
|
||||||
* @flags: a #PinosStreamFlags
|
* @flags: a #PinosStreamFlags
|
||||||
* @possible_formats: (transfer full): a #GBytes with possible accepted formats
|
* @possible_formats: (transfer full): a #GBytes with possible accepted formats
|
||||||
*
|
*
|
||||||
* Connect @stream for capturing from @source_path.
|
* Connect @stream for input or output on @port_path.
|
||||||
*
|
*
|
||||||
* Returns: %TRUE on success.
|
* Returns: %TRUE on success.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
pinos_stream_connect_source (PinosStream *stream,
|
pinos_stream_connect (PinosStream *stream,
|
||||||
const gchar *source_path,
|
PinosDirection direction,
|
||||||
PinosStreamFlags flags,
|
const gchar *port_path,
|
||||||
GBytes *possible_formats)
|
PinosStreamFlags flags,
|
||||||
|
GBytes *possible_formats)
|
||||||
{
|
{
|
||||||
PinosStreamPrivate *priv;
|
PinosStreamPrivate *priv;
|
||||||
PinosContext *context;
|
PinosContext *context;
|
||||||
|
|
@ -644,8 +648,9 @@ pinos_stream_connect_source (PinosStream *stream,
|
||||||
g_return_val_if_fail (pinos_context_get_state (context) == PINOS_CONTEXT_STATE_READY, FALSE);
|
g_return_val_if_fail (pinos_context_get_state (context) == PINOS_CONTEXT_STATE_READY, FALSE);
|
||||||
g_return_val_if_fail (pinos_stream_get_state (stream) == PINOS_STREAM_STATE_UNCONNECTED, FALSE);
|
g_return_val_if_fail (pinos_stream_get_state (stream) == PINOS_STREAM_STATE_UNCONNECTED, FALSE);
|
||||||
|
|
||||||
|
priv->direction = direction;
|
||||||
g_free (priv->path);
|
g_free (priv->path);
|
||||||
priv->path = g_strdup (source_path);
|
priv->path = g_strdup (port_path);
|
||||||
if (priv->possible_formats)
|
if (priv->possible_formats)
|
||||||
g_bytes_unref (priv->possible_formats);
|
g_bytes_unref (priv->possible_formats);
|
||||||
priv->possible_formats = possible_formats;
|
priv->possible_formats = possible_formats;
|
||||||
|
|
@ -654,72 +659,7 @@ pinos_stream_connect_source (PinosStream *stream,
|
||||||
stream_set_state (stream, PINOS_STREAM_STATE_CONNECTING, NULL);
|
stream_set_state (stream, PINOS_STREAM_STATE_CONNECTING, NULL);
|
||||||
|
|
||||||
g_main_context_invoke (context->priv->context,
|
g_main_context_invoke (context->priv->context,
|
||||||
(GSourceFunc) do_connect_source,
|
(GSourceFunc) do_connect,
|
||||||
g_object_ref (stream));
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
do_connect_sink (PinosStream *stream)
|
|
||||||
{
|
|
||||||
PinosStreamPrivate *priv = stream->priv;
|
|
||||||
PinosContext *context = priv->context;
|
|
||||||
|
|
||||||
g_dbus_proxy_call (context->priv->client,
|
|
||||||
"CreateSinkChannel",
|
|
||||||
g_variant_new ("(ss@a{sv})",
|
|
||||||
(priv->path ? priv->path : ""),
|
|
||||||
g_bytes_get_data (priv->possible_formats, NULL),
|
|
||||||
pinos_properties_to_variant (priv->properties)),
|
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
|
||||||
-1,
|
|
||||||
NULL, /* GCancellable *cancellable */
|
|
||||||
on_channel_created,
|
|
||||||
stream);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_stream_connect_sink:
|
|
||||||
* @stream: a #PinosStream
|
|
||||||
* @sink_path: the sink path to connect to
|
|
||||||
* @flags: a #PinosStreamFlags
|
|
||||||
* @possible_formats: (transfer full): a #GBytes with possible accepted formats
|
|
||||||
*
|
|
||||||
* Connect @stream for playback to @sink_path.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE on success.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
pinos_stream_connect_sink (PinosStream *stream,
|
|
||||||
const gchar *sink_path,
|
|
||||||
PinosStreamFlags flags,
|
|
||||||
GBytes *possible_formats)
|
|
||||||
{
|
|
||||||
PinosStreamPrivate *priv;
|
|
||||||
PinosContext *context;
|
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
|
|
||||||
g_return_val_if_fail (possible_formats != NULL, FALSE);
|
|
||||||
|
|
||||||
priv = stream->priv;
|
|
||||||
context = priv->context;
|
|
||||||
g_return_val_if_fail (pinos_context_get_state (context) == PINOS_CONTEXT_STATE_READY, FALSE);
|
|
||||||
g_return_val_if_fail (pinos_stream_get_state (stream) == PINOS_STREAM_STATE_UNCONNECTED, FALSE);
|
|
||||||
|
|
||||||
g_free (priv->path);
|
|
||||||
priv->path = g_strdup (sink_path);
|
|
||||||
if (priv->possible_formats)
|
|
||||||
g_bytes_unref (priv->possible_formats);
|
|
||||||
priv->possible_formats = possible_formats;
|
|
||||||
priv->provide = FALSE;
|
|
||||||
|
|
||||||
stream_set_state (stream, PINOS_STREAM_STATE_CONNECTING, NULL);
|
|
||||||
|
|
||||||
g_main_context_invoke (context->priv->context,
|
|
||||||
(GSourceFunc) do_connect_sink,
|
|
||||||
g_object_ref (stream));
|
g_object_ref (stream));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
||||||
|
|
@ -91,12 +91,9 @@ PinosStream * pinos_stream_new (PinosContext *context,
|
||||||
PinosStreamState pinos_stream_get_state (PinosStream *stream);
|
PinosStreamState pinos_stream_get_state (PinosStream *stream);
|
||||||
const GError * pinos_stream_get_error (PinosStream *stream);
|
const GError * pinos_stream_get_error (PinosStream *stream);
|
||||||
|
|
||||||
gboolean pinos_stream_connect_source (PinosStream *stream,
|
gboolean pinos_stream_connect (PinosStream *stream,
|
||||||
const gchar *source_path,
|
PinosDirection direction,
|
||||||
PinosStreamFlags flags,
|
const gchar *port_path,
|
||||||
GBytes *possible_formats);
|
|
||||||
gboolean pinos_stream_connect_sink (PinosStream *stream,
|
|
||||||
const gchar *sink_path,
|
|
||||||
PinosStreamFlags flags,
|
PinosStreamFlags flags,
|
||||||
GBytes *possible_formats);
|
GBytes *possible_formats);
|
||||||
gboolean pinos_stream_connect_provide (PinosStream *stream,
|
gboolean pinos_stream_connect_provide (PinosStream *stream,
|
||||||
|
|
|
||||||
|
|
@ -105,11 +105,11 @@ notify_event (PinosSubscribe *subscribe,
|
||||||
else if (g_strcmp0 (interface_name, "org.pinos.Client1") == 0) {
|
else if (g_strcmp0 (interface_name, "org.pinos.Client1") == 0) {
|
||||||
flags = PINOS_SUBSCRIPTION_FLAG_CLIENT;
|
flags = PINOS_SUBSCRIPTION_FLAG_CLIENT;
|
||||||
}
|
}
|
||||||
else if (g_strcmp0 (interface_name, "org.pinos.Source1") == 0) {
|
else if (g_strcmp0 (interface_name, "org.pinos.Node1") == 0) {
|
||||||
flags = PINOS_SUBSCRIPTION_FLAG_SOURCE;
|
flags = PINOS_SUBSCRIPTION_FLAG_NODE;
|
||||||
}
|
}
|
||||||
else if (g_strcmp0 (interface_name, "org.pinos.Sink1") == 0) {
|
else if (g_strcmp0 (interface_name, "org.pinos.Port1") == 0) {
|
||||||
flags = PINOS_SUBSCRIPTION_FLAG_SINK;
|
flags = PINOS_SUBSCRIPTION_FLAG_PORT;
|
||||||
}
|
}
|
||||||
else if (g_strcmp0 (interface_name, "org.pinos.Channel1") == 0) {
|
else if (g_strcmp0 (interface_name, "org.pinos.Channel1") == 0) {
|
||||||
flags = PINOS_SUBSCRIPTION_FLAG_CHANNEL;
|
flags = PINOS_SUBSCRIPTION_FLAG_CHANNEL;
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PINOS_SUBSCRIPTION_FLAG_DAEMON = (1 << 0),
|
PINOS_SUBSCRIPTION_FLAG_DAEMON = (1 << 0),
|
||||||
PINOS_SUBSCRIPTION_FLAG_CLIENT = (1 << 1),
|
PINOS_SUBSCRIPTION_FLAG_CLIENT = (1 << 1),
|
||||||
PINOS_SUBSCRIPTION_FLAG_SOURCE = (1 << 2),
|
PINOS_SUBSCRIPTION_FLAG_NODE = (1 << 2),
|
||||||
PINOS_SUBSCRIPTION_FLAG_SINK = (1 << 3),
|
PINOS_SUBSCRIPTION_FLAG_PORT = (1 << 3),
|
||||||
PINOS_SUBSCRIPTION_FLAG_CHANNEL = (1 << 4),
|
PINOS_SUBSCRIPTION_FLAG_CHANNEL = (1 << 4),
|
||||||
} PinosSubscriptionFlags;
|
} PinosSubscriptionFlags;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,34 +54,22 @@
|
||||||
-->
|
-->
|
||||||
<method name='Disconnect'/>
|
<method name='Disconnect'/>
|
||||||
<!-- CreateSourceChannel:
|
<!-- CreateSourceChannel:
|
||||||
@source: the Source1 object path or / for default
|
@direction: the channel direction, 0 = input, 1 = output
|
||||||
|
@port: the Port1 object path or / for default
|
||||||
@possible_formats: the possible formats that can be accepted
|
@possible_formats: the possible formats that can be accepted
|
||||||
@properties: extra properties
|
@properties: extra properties
|
||||||
@channel: the Channel object path
|
@channel: the Channel object path
|
||||||
|
|
||||||
Create a new channel to capture from @source with given @possible_formats
|
Create a new channel to stream to/from @port with given @possible_formats
|
||||||
-->
|
-->
|
||||||
<method name='CreateSourceChannel'>
|
<method name='CreateChannel'>
|
||||||
<arg type='s' name='source' direction='in'/>
|
<arg type='u' name='direction' direction='in'/>
|
||||||
|
<arg type='s' name='port' direction='in'/>
|
||||||
<arg type='s' name='possible_formats' direction='in'/>
|
<arg type='s' name='possible_formats' direction='in'/>
|
||||||
<arg type='a{sv}' name='properties' direction='in'/>
|
<arg type='a{sv}' name='properties' direction='in'/>
|
||||||
<arg type='o' name='channel' direction='out'/>
|
<arg type='o' name='channel' direction='out'/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<!-- CreateSinkChannel:
|
|
||||||
@sink: the Sink1 object path or / for default
|
|
||||||
@possible_formats: the possible formats that can be provided
|
|
||||||
@properties: extra properties
|
|
||||||
@channel: the Channel object path
|
|
||||||
|
|
||||||
Create a new channel to playback to @sink with given @possible_formats
|
|
||||||
-->
|
|
||||||
<method name='CreateSinkChannel'>
|
|
||||||
<arg type='s' name='sink' direction='in'/>
|
|
||||||
<arg type='s' name='possible_formats' direction='in'/>
|
|
||||||
<arg type='a{sv}' name='properties' direction='in'/>
|
|
||||||
<arg type='o' name='channel' direction='out'/>
|
|
||||||
</method>
|
|
||||||
<!-- CreateUploadChannel:
|
<!-- CreateUploadChannel:
|
||||||
@possible_formats: the formats that can be provided
|
@possible_formats: the formats that can be provided
|
||||||
@properties: extra properties
|
@properties: extra properties
|
||||||
|
|
@ -98,92 +86,87 @@
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
org.pinos.Source1:
|
org.pinos.Node1:
|
||||||
@short_description: Main source interface
|
@short_description: A processing node
|
||||||
|
|
||||||
A source is an object that can provide media content.
|
A node is an object that can consume and/or produce media.
|
||||||
-->
|
-->
|
||||||
<interface name='org.pinos.Source1'>
|
<interface name='org.pinos.Node1'>
|
||||||
<!-- Name: the name of the source -->
|
<!-- Name: the name of the node -->
|
||||||
<property name='Name' type='s' access='read' />
|
<property name='Name' type='s' access='read' />
|
||||||
<!-- Properties: extra source properties -->
|
<!-- Properties: extra node properties -->
|
||||||
<property name='Properties' type='a{sv}' access='read' />
|
<property name='Properties' type='a{sv}' access='read' />
|
||||||
<!-- state: state of the source
|
<!-- state: state of the node
|
||||||
-1 = the source is in error
|
-1 = the node is in error
|
||||||
0 = the source is suspended, this means the device is closed
|
0 = the node is suspended, this means that the node is not
|
||||||
1 = the source is initializing
|
processing any data and has closed all devices if any
|
||||||
2 = the source is idle, this means the device is opened but
|
1 = the node is initializing
|
||||||
no channel is consuming the data
|
2 = the node is idle, this means no channel is consuming
|
||||||
3 = the source is running
|
the data. An idle node can become suspended.
|
||||||
|
3 = the node is running
|
||||||
-->
|
-->
|
||||||
<property name='State' type='u' access='read' />
|
<property name='State' type='u' access='read' />
|
||||||
|
</interface>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
org.pinos.Port1:
|
||||||
|
@short_description: a Node1 input/output port
|
||||||
|
|
||||||
|
A port on a Node1 can provide or consume data.
|
||||||
|
-->
|
||||||
|
<interface name='org.pinos.Port1'>
|
||||||
|
<!-- Name: the name of the port -->
|
||||||
|
<property name='Name' type='s' access='read' />
|
||||||
|
<!-- Node: the owner node of this port -->
|
||||||
|
<property name='Node' type='o' access='read' />
|
||||||
|
<!-- Direction: the direction of the port
|
||||||
|
0 = an input port
|
||||||
|
1 = an output port
|
||||||
|
-->
|
||||||
|
<property name='Direction' type='u' access='read' />
|
||||||
|
<!-- Properties: extra port properties -->
|
||||||
|
<property name='Properties' type='a{sv}' access='read' />
|
||||||
<!-- PossibleFormats:
|
<!-- PossibleFormats:
|
||||||
|
|
||||||
The all possible formats of this source.
|
The all possible formats of this port.
|
||||||
-->
|
-->
|
||||||
<property name='PossibleFormats' type='s' access='read' />
|
<property name='PossibleFormats' type='s' access='read' />
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
org.pinos.Sink1:
|
org.pinos.Channel1:
|
||||||
@short_description: Main sink interface
|
|
||||||
|
|
||||||
A sink is an object that can consume media content.
|
|
||||||
-->
|
|
||||||
<interface name='org.pinos.Sink1'>
|
|
||||||
<!-- Name: the name of the sink -->
|
|
||||||
<property name='Name' type='s' access='read' />
|
|
||||||
<!-- Properties: extra sink properties -->
|
|
||||||
<property name='Properties' type='a{sv}' access='read' />
|
|
||||||
<!-- state: state of the sink
|
|
||||||
-1 = the sink is in error
|
|
||||||
0 = the sink is suspended, this means the device is closed
|
|
||||||
1 = the sink is initializing
|
|
||||||
2 = the sink is idle, this means the device is opened but
|
|
||||||
no channel is providing any data
|
|
||||||
3 = the sink is running
|
|
||||||
-->
|
|
||||||
<property name='State' type='u' access='read' />
|
|
||||||
<!-- PossibleFormats:
|
|
||||||
|
|
||||||
The all possible formats of this sink.
|
|
||||||
-->
|
|
||||||
<property name='PossibleFormats' type='s' access='read' />
|
|
||||||
</interface>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
org.pinos.Channel:
|
|
||||||
@short_description: Interface for input/output channel
|
@short_description: Interface for input/output channel
|
||||||
|
|
||||||
This interface is used to control the input/output of a
|
This interface is used to control the input/output of a
|
||||||
source/sink and start/stop the media transport.
|
Port1 and start/stop the media transport.
|
||||||
-->
|
-->
|
||||||
<interface name='org.pinos.Channel1'>
|
<interface name='org.pinos.Channel1'>
|
||||||
<!-- Client: the owner client of this channel -->
|
<!-- Client: the owner client of this channel -->
|
||||||
<property name='Client' type='o' access='read' />
|
<property name='Client' type='o' access='read' />
|
||||||
<!-- Owner: the owner source/sink of this channel -->
|
<!-- Owner: the owner port of this channel -->
|
||||||
<property name='Owner' type='o' access='read' />
|
<property name='Port' type='o' access='read' />
|
||||||
<!-- type: type of the channel
|
<!-- Direction: the direction of the port
|
||||||
0 = input channel
|
0 = an input port
|
||||||
1 = output channel
|
1 = an output port
|
||||||
-->
|
-->
|
||||||
<property name='Type' type='u' access='read' />
|
<property name='Direction' type='u' access='read' />
|
||||||
|
<!-- Properties: extra channel properties -->
|
||||||
|
<property name='Properties' type='a{sv}' access='read' />
|
||||||
|
|
||||||
|
<!-- state: state of the channel
|
||||||
|
-1 = the channel is in error
|
||||||
|
0 = the channel is stopped
|
||||||
|
1 = the channel is starting
|
||||||
|
2 = the channel is streaming
|
||||||
|
-->
|
||||||
|
<property name='State' type='u' access='read' />
|
||||||
|
|
||||||
<!-- PossibleFormats:
|
<!-- PossibleFormats:
|
||||||
all possible formats of the channel. This is filtered
|
all possible formats of the channel. This is filtered
|
||||||
against the accepted_formats when creating the channel.
|
against the accepted_formats when creating the channel.
|
||||||
-->
|
-->
|
||||||
<property name='PossibleFormats' type='s' access='read' />
|
<property name='PossibleFormats' type='s' access='read' />
|
||||||
|
|
||||||
<!-- Properties: extra channel properties -->
|
|
||||||
<property name='Properties' type='a{sv}' access='read' />
|
|
||||||
|
|
||||||
<!-- state: state of the channel
|
|
||||||
-1 = the channel is in error
|
|
||||||
0 = the channel is idle
|
|
||||||
1 = the channel is starting
|
|
||||||
2 = the channel is streaming
|
|
||||||
-->
|
|
||||||
<property name='State' type='u' access='read' />
|
|
||||||
<!-- Format: the current streaming format -->
|
<!-- Format: the current streaming format -->
|
||||||
<property name='Format' type='s' access='read' />
|
<property name='Format' type='s' access='read' />
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,19 +191,21 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstDevice *
|
static GstDevice *
|
||||||
new_source (const PinosSourceInfo *info)
|
new_node (const PinosNodeInfo *info)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstStructure *props;
|
GstStructure *props;
|
||||||
gpointer state = NULL;
|
gpointer state = NULL;
|
||||||
const gchar *klass;
|
const gchar *klass;
|
||||||
|
|
||||||
|
/* FIXME, iterate ports */
|
||||||
|
#if 0
|
||||||
if (info->possible_formats)
|
if (info->possible_formats)
|
||||||
caps = gst_caps_from_string (g_bytes_get_data (info->possible_formats, NULL));
|
caps = gst_caps_from_string (g_bytes_get_data (info->possible_formats, NULL));
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
caps = gst_caps_new_any();
|
caps = gst_caps_new_any();
|
||||||
|
|
||||||
|
|
||||||
props = gst_structure_new_empty ("pinos-proplist");
|
props = gst_structure_new_empty ("pinos-proplist");
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
|
|
@ -223,21 +225,21 @@ new_source (const PinosSourceInfo *info)
|
||||||
return gst_pinos_device_new (info->id,
|
return gst_pinos_device_new (info->id,
|
||||||
info->name,
|
info->name,
|
||||||
caps,
|
caps,
|
||||||
info->source_path,
|
info->node_path,
|
||||||
klass,
|
klass,
|
||||||
GST_PINOS_DEVICE_TYPE_SOURCE,
|
GST_PINOS_DEVICE_TYPE_SOURCE,
|
||||||
props);
|
props);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_source_info_cb (PinosContext *context,
|
get_node_info_cb (PinosContext *context,
|
||||||
const PinosSourceInfo *info,
|
const PinosNodeInfo *info,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GstPinosDeviceProvider *self = user_data;
|
GstPinosDeviceProvider *self = user_data;
|
||||||
GstDevice *dev;
|
GstDevice *dev;
|
||||||
|
|
||||||
dev = new_source (info);
|
dev = new_node (info);
|
||||||
if (dev)
|
if (dev)
|
||||||
gst_device_provider_device_add (GST_DEVICE_PROVIDER (self), dev);
|
gst_device_provider_device_add (GST_DEVICE_PROVIDER (self), dev);
|
||||||
}
|
}
|
||||||
|
|
@ -273,22 +275,22 @@ context_subscribe_cb (PinosContext *context,
|
||||||
GstDeviceProvider *provider = user_data;
|
GstDeviceProvider *provider = user_data;
|
||||||
GstPinosDevice *dev;
|
GstPinosDevice *dev;
|
||||||
|
|
||||||
if (flags != PINOS_SUBSCRIPTION_FLAG_SOURCE)
|
if (flags != PINOS_SUBSCRIPTION_FLAG_NODE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dev = find_device (provider, id);
|
dev = find_device (provider, id);
|
||||||
|
|
||||||
if (type == PINOS_SUBSCRIPTION_EVENT_NEW) {
|
if (type == PINOS_SUBSCRIPTION_EVENT_NEW) {
|
||||||
if (flags == PINOS_SUBSCRIPTION_FLAG_SOURCE && dev == NULL)
|
if (flags == PINOS_SUBSCRIPTION_FLAG_NODE && dev == NULL)
|
||||||
pinos_context_get_source_info_by_id (context,
|
pinos_context_get_node_info_by_id (context,
|
||||||
id,
|
id,
|
||||||
PINOS_SOURCE_INFO_FLAGS_FORMATS,
|
PINOS_NODE_INFO_FLAGS_NONE,
|
||||||
get_source_info_cb,
|
get_node_info_cb,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
self);
|
self);
|
||||||
} else if (type == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
|
} else if (type == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
|
||||||
if (flags == PINOS_SUBSCRIPTION_FLAG_SOURCE && dev != NULL) {
|
if (flags == PINOS_SUBSCRIPTION_FLAG_NODE && dev != NULL) {
|
||||||
gst_device_provider_device_remove (GST_DEVICE_PROVIDER (self),
|
gst_device_provider_device_remove (GST_DEVICE_PROVIDER (self),
|
||||||
GST_DEVICE (dev));
|
GST_DEVICE (dev));
|
||||||
}
|
}
|
||||||
|
|
@ -303,25 +305,25 @@ typedef struct {
|
||||||
} InfoData;
|
} InfoData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
list_source_info_cb (PinosContext *c,
|
list_node_info_cb (PinosContext *c,
|
||||||
const PinosSourceInfo *info,
|
const PinosNodeInfo *info,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
InfoData *data = user_data;
|
InfoData *data = user_data;
|
||||||
|
|
||||||
*data->devices = g_list_prepend (*data->devices, gst_object_ref_sink (new_source (info)));
|
*data->devices = g_list_prepend (*data->devices, gst_object_ref_sink (new_node (info)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
list_source_info_end_cb (GObject *source_object,
|
list_node_info_end_cb (GObject *source_object,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
InfoData *data = user_data;
|
InfoData *data = user_data;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!pinos_context_info_finish (source_object, res, &error)) {
|
if (!pinos_context_info_finish (source_object, res, &error)) {
|
||||||
GST_WARNING_OBJECT (source_object, "failed to list sources: %s", error->message);
|
GST_WARNING_OBJECT (source_object, "failed to list nodes: %s", error->message);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
data->end = TRUE;
|
data->end = TRUE;
|
||||||
|
|
@ -396,12 +398,12 @@ gst_pinos_device_provider_probe (GstDeviceProvider * provider)
|
||||||
|
|
||||||
data.end = FALSE;
|
data.end = FALSE;
|
||||||
data.devices = NULL;
|
data.devices = NULL;
|
||||||
pinos_context_list_source_info (c,
|
pinos_context_list_node_info (c,
|
||||||
PINOS_SOURCE_INFO_FLAGS_FORMATS,
|
PINOS_NODE_INFO_FLAGS_NONE,
|
||||||
list_source_info_cb,
|
list_node_info_cb,
|
||||||
NULL,
|
NULL,
|
||||||
list_source_info_end_cb,
|
list_node_info_end_cb,
|
||||||
&data);
|
&data);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (pinos_context_get_state (c) <= 0)
|
if (pinos_context_get_state (c) <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -366,12 +366,14 @@ gst_pinos_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstPinosSink *pinossink;
|
GstPinosSink *pinossink;
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
GBytes *format;
|
||||||
PinosStreamState state;
|
PinosStreamState state;
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
|
|
||||||
pinossink = GST_PINOS_SINK (bsink);
|
pinossink = GST_PINOS_SINK (bsink);
|
||||||
|
|
||||||
str = gst_caps_to_string (caps);
|
str = gst_caps_to_string (caps);
|
||||||
|
format = g_bytes_new_take (str, strlen (str) + 1);
|
||||||
|
|
||||||
pinos_main_loop_lock (pinossink->loop);
|
pinos_main_loop_lock (pinossink->loop);
|
||||||
state = pinos_stream_get_state (pinossink->stream);
|
state = pinos_stream_get_state (pinossink->stream);
|
||||||
|
|
@ -379,6 +381,26 @@ gst_pinos_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
if (state == PINOS_STREAM_STATE_ERROR)
|
if (state == PINOS_STREAM_STATE_ERROR)
|
||||||
goto start_error;
|
goto start_error;
|
||||||
|
|
||||||
|
if (state == PINOS_STREAM_STATE_UNCONNECTED) {
|
||||||
|
pinos_stream_connect (pinossink->stream,
|
||||||
|
PINOS_DIRECTION_INPUT,
|
||||||
|
pinossink->path,
|
||||||
|
0,
|
||||||
|
g_bytes_ref (format));
|
||||||
|
|
||||||
|
while (TRUE) {
|
||||||
|
state = pinos_stream_get_state (pinossink->stream);
|
||||||
|
|
||||||
|
if (state == PINOS_STREAM_STATE_READY)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (state == PINOS_STREAM_STATE_ERROR)
|
||||||
|
goto start_error;
|
||||||
|
|
||||||
|
pinos_main_loop_wait (pinossink->loop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (state == PINOS_STREAM_STATE_STREAMING) {
|
if (state == PINOS_STREAM_STATE_STREAMING) {
|
||||||
PinosBufferBuilder builder;
|
PinosBufferBuilder builder;
|
||||||
PinosPacketFormatChange change;
|
PinosPacketFormatChange change;
|
||||||
|
|
@ -387,16 +409,16 @@ gst_pinos_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
pinos_buffer_builder_init (&builder);
|
pinos_buffer_builder_init (&builder);
|
||||||
|
|
||||||
change.id = 1;
|
change.id = 1;
|
||||||
change.format = str;
|
change.format = g_bytes_get_data (format, NULL);
|
||||||
pinos_buffer_builder_add_format_change (&builder, &change);
|
pinos_buffer_builder_add_format_change (&builder, &change);
|
||||||
pinos_buffer_builder_end (&builder, &pbuf);
|
pinos_buffer_builder_end (&builder, &pbuf);
|
||||||
|
|
||||||
res = pinos_stream_send_buffer (pinossink->stream, &pbuf);
|
res = pinos_stream_send_buffer (pinossink->stream, &pbuf);
|
||||||
pinos_buffer_clear (&pbuf);
|
pinos_buffer_clear (&pbuf);
|
||||||
} else {
|
} else {
|
||||||
GBytes *format = g_bytes_new_take (str, strlen (str) + 1);
|
res = pinos_stream_start (pinossink->stream,
|
||||||
|
g_bytes_ref (format),
|
||||||
res = pinos_stream_start (pinossink->stream, format, PINOS_STREAM_MODE_BUFFER);
|
PINOS_STREAM_MODE_BUFFER);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
state = pinos_stream_get_state (pinossink->stream);
|
state = pinos_stream_get_state (pinossink->stream);
|
||||||
|
|
@ -411,6 +433,7 @@ gst_pinos_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pinos_main_loop_unlock (pinossink->loop);
|
pinos_main_loop_unlock (pinossink->loop);
|
||||||
|
g_bytes_unref (format);
|
||||||
|
|
||||||
pinossink->negotiated = res;
|
pinossink->negotiated = res;
|
||||||
|
|
||||||
|
|
@ -420,6 +443,7 @@ start_error:
|
||||||
{
|
{
|
||||||
GST_ERROR ("could not start stream");
|
GST_ERROR ("could not start stream");
|
||||||
pinos_main_loop_unlock (pinossink->loop);
|
pinos_main_loop_unlock (pinossink->loop);
|
||||||
|
g_bytes_unref (format);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -563,32 +587,9 @@ gst_pinos_sink_start (GstBaseSink * basesink)
|
||||||
pinossink->stream = pinos_stream_new (pinossink->ctx, pinossink->client_name, props);
|
pinossink->stream = pinos_stream_new (pinossink->ctx, pinossink->client_name, props);
|
||||||
g_signal_connect (pinossink->stream, "notify::state", (GCallback) on_stream_notify, pinossink);
|
g_signal_connect (pinossink->stream, "notify::state", (GCallback) on_stream_notify, pinossink);
|
||||||
g_signal_connect (pinossink->stream, "new-buffer", (GCallback) on_new_buffer, pinossink);
|
g_signal_connect (pinossink->stream, "new-buffer", (GCallback) on_new_buffer, pinossink);
|
||||||
|
|
||||||
pinos_stream_connect_sink (pinossink->stream, pinossink->path, 0, g_bytes_new_static ("ANY", strlen ("ANY")+1));
|
|
||||||
|
|
||||||
while (TRUE) {
|
|
||||||
PinosStreamState state = pinos_stream_get_state (pinossink->stream);
|
|
||||||
|
|
||||||
if (state == PINOS_STREAM_STATE_READY)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (state == PINOS_STREAM_STATE_ERROR)
|
|
||||||
goto connect_error;
|
|
||||||
|
|
||||||
pinos_main_loop_wait (pinossink->loop);
|
|
||||||
}
|
|
||||||
pinos_main_loop_unlock (pinossink->loop);
|
pinos_main_loop_unlock (pinossink->loop);
|
||||||
|
|
||||||
pinossink->negotiated = TRUE;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
connect_error:
|
|
||||||
{
|
|
||||||
GST_ERROR ("could not connect stream");
|
|
||||||
pinos_main_loop_unlock (pinossink->loop);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
||||||
|
|
@ -648,7 +648,7 @@ gst_pinos_src_negotiate (GstBaseSrc * basesrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (basesrc, "connect capture with path %s", pinossrc->path);
|
GST_DEBUG_OBJECT (basesrc, "connect capture with path %s", pinossrc->path);
|
||||||
pinos_stream_connect_source (pinossrc->stream, pinossrc->path, 0, accepted);
|
pinos_stream_connect (pinossrc->stream, PINOS_DIRECTION_OUTPUT, pinossrc->path, 0, accepted);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
PinosStreamState state = pinos_stream_get_state (pinossrc->stream);
|
PinosStreamState state = pinos_stream_get_state (pinossrc->stream);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ device_added (PinosGstManager *manager,
|
||||||
PinosGstManagerPrivate *priv = manager->priv;
|
PinosGstManagerPrivate *priv = manager->priv;
|
||||||
gchar *name, *klass;
|
gchar *name, *klass;
|
||||||
GstElement *element;
|
GstElement *element;
|
||||||
PinosNode *node;
|
PinosNode *node = NULL;
|
||||||
GstStructure *p;
|
GstStructure *p;
|
||||||
PinosProperties *properties;
|
PinosProperties *properties;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
@ -91,24 +91,24 @@ device_added (PinosGstManager *manager,
|
||||||
"gstreamer.device.class",
|
"gstreamer.device.class",
|
||||||
klass);
|
klass);
|
||||||
|
|
||||||
node = pinos_node_new (priv->daemon);
|
|
||||||
g_object_set_data (G_OBJECT (device), "PinosNode", node);
|
|
||||||
|
|
||||||
element = gst_device_create_element (device, NULL);
|
element = gst_device_create_element (device, NULL);
|
||||||
|
|
||||||
if (strstr (klass, "Source")) {
|
if (strstr (klass, "Source")) {
|
||||||
pinos_gst_source_new (node,
|
node = pinos_gst_source_new (priv->daemon,
|
||||||
name,
|
name,
|
||||||
properties,
|
properties,
|
||||||
element,
|
element,
|
||||||
caps);
|
caps);
|
||||||
} else if (strstr (klass, "Sink")) {
|
} else if (strstr (klass, "Sink")) {
|
||||||
pinos_gst_sink_new (node,
|
node = pinos_gst_sink_new (priv->daemon,
|
||||||
name,
|
name,
|
||||||
properties,
|
properties,
|
||||||
element,
|
element,
|
||||||
caps);
|
caps);
|
||||||
}
|
}
|
||||||
|
if (node)
|
||||||
|
g_object_set_data (G_OBJECT (device), "PinosNode", node);
|
||||||
|
|
||||||
pinos_properties_free (properties);
|
pinos_properties_free (properties);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ struct _PinosGstSinkPrivate
|
||||||
GstElement *depay;
|
GstElement *depay;
|
||||||
GstElement *element;
|
GstElement *element;
|
||||||
|
|
||||||
|
PinosPort *input;
|
||||||
GstCaps *possible_formats;
|
GstCaps *possible_formats;
|
||||||
|
|
||||||
GstNetTimeProvider *provider;
|
GstNetTimeProvider *provider;
|
||||||
|
|
@ -50,15 +51,15 @@ enum {
|
||||||
PROP_POSSIBLE_FORMATS
|
PROP_POSSIBLE_FORMATS
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (PinosGstSink, pinos_gst_sink, PINOS_TYPE_SINK);
|
G_DEFINE_TYPE (PinosGstSink, pinos_gst_sink, PINOS_TYPE_NODE);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
bus_handler (GstBus *bus,
|
bus_handler (GstBus *bus,
|
||||||
GstMessage *message,
|
GstMessage *message,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosSink *sink = user_data;
|
PinosNode *node = user_data;
|
||||||
PinosGstSinkPrivate *priv = PINOS_GST_SINK (sink)->priv;
|
PinosGstSinkPrivate *priv = PINOS_GST_SINK (node)->priv;
|
||||||
|
|
||||||
switch (GST_MESSAGE_TYPE (message)) {
|
switch (GST_MESSAGE_TYPE (message)) {
|
||||||
case GST_MESSAGE_ERROR:
|
case GST_MESSAGE_ERROR:
|
||||||
|
|
@ -70,7 +71,7 @@ bus_handler (GstBus *bus,
|
||||||
g_warning ("got error %s (%s)\n", error->message, debug);
|
g_warning ("got error %s (%s)\n", error->message, debug);
|
||||||
g_free (debug);
|
g_free (debug);
|
||||||
|
|
||||||
pinos_sink_report_error (sink, error);
|
pinos_node_report_error (node, error);
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -82,9 +83,9 @@ bus_handler (GstBus *bus,
|
||||||
gst_message_parse_new_clock (message, &clock);
|
gst_message_parse_new_clock (message, &clock);
|
||||||
GST_INFO ("got new clock %s", GST_OBJECT_NAME (clock));
|
GST_INFO ("got new clock %s", GST_OBJECT_NAME (clock));
|
||||||
|
|
||||||
g_object_get (sink, "properties", &props, NULL);
|
g_object_get (node, "properties", &props, NULL);
|
||||||
pinos_properties_set (props, "gst.pipeline.clock", GST_OBJECT_NAME (clock));
|
pinos_properties_set (props, "gst.pipeline.clock", GST_OBJECT_NAME (clock));
|
||||||
g_object_set (sink, "properties", props, NULL);
|
g_object_set (node, "properties", props, NULL);
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -96,9 +97,9 @@ bus_handler (GstBus *bus,
|
||||||
gst_message_parse_new_clock (message, &clock);
|
gst_message_parse_new_clock (message, &clock);
|
||||||
GST_INFO ("clock lost %s", GST_OBJECT_NAME (clock));
|
GST_INFO ("clock lost %s", GST_OBJECT_NAME (clock));
|
||||||
|
|
||||||
g_object_get (sink, "properties", &props, NULL);
|
g_object_get (node, "properties", &props, NULL);
|
||||||
pinos_properties_remove (props, "gst.pipeline.clock");
|
pinos_properties_remove (props, "gst.pipeline.clock");
|
||||||
g_object_set (sink, "properties", props, NULL);
|
g_object_set (node, "properties", props, NULL);
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
|
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
||||||
|
|
@ -146,10 +147,12 @@ static gboolean
|
||||||
start_pipeline (PinosGstSink *sink, GError **error)
|
start_pipeline (PinosGstSink *sink, GError **error)
|
||||||
{
|
{
|
||||||
PinosGstSinkPrivate *priv = sink->priv;
|
PinosGstSinkPrivate *priv = sink->priv;
|
||||||
|
#if 0
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstQuery *query;
|
GstQuery *query;
|
||||||
GstStateChangeReturn ret;
|
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
#endif
|
||||||
|
GstStateChangeReturn ret;
|
||||||
|
|
||||||
g_debug ("gst-sink %p: starting pipeline", sink);
|
g_debug ("gst-sink %p: starting pipeline", sink);
|
||||||
|
|
||||||
|
|
@ -157,6 +160,7 @@ start_pipeline (PinosGstSink *sink, GError **error)
|
||||||
if (ret == GST_STATE_CHANGE_FAILURE)
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||||
goto ready_failed;
|
goto ready_failed;
|
||||||
|
|
||||||
|
#if 0
|
||||||
query = gst_query_new_caps (NULL);
|
query = gst_query_new_caps (NULL);
|
||||||
if (gst_element_query (priv->element, query)) {
|
if (gst_element_query (priv->element, query)) {
|
||||||
gst_query_parse_caps_result (query, &caps);
|
gst_query_parse_caps_result (query, &caps);
|
||||||
|
|
@ -166,6 +170,7 @@ start_pipeline (PinosGstSink *sink, GError **error)
|
||||||
g_free (str);
|
g_free (str);
|
||||||
}
|
}
|
||||||
gst_query_unref (query);
|
gst_query_unref (query);
|
||||||
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
|
@ -204,96 +209,37 @@ destroy_pipeline (PinosGstSink *sink)
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
set_state (PinosSink *sink,
|
set_state (PinosNode *node,
|
||||||
PinosSinkState state)
|
PinosNodeState state)
|
||||||
{
|
{
|
||||||
PinosGstSinkPrivate *priv = PINOS_GST_SINK (sink)->priv;
|
PinosGstSinkPrivate *priv = PINOS_GST_SINK (node)->priv;
|
||||||
|
|
||||||
g_debug ("gst-sink %p: set state %d", sink, state);
|
g_debug ("gst-sink %p: set state %s", node, pinos_node_state_as_string (state));
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PINOS_SINK_STATE_SUSPENDED:
|
case PINOS_NODE_STATE_SUSPENDED:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SINK_STATE_INITIALIZING:
|
case PINOS_NODE_STATE_INITIALIZING:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SINK_STATE_IDLE:
|
case PINOS_NODE_STATE_IDLE:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SINK_STATE_RUNNING:
|
case PINOS_NODE_STATE_RUNNING:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SINK_STATE_ERROR:
|
case PINOS_NODE_STATE_ERROR:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pinos_sink_update_state (sink, state);
|
pinos_node_update_state (node, state);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GBytes *
|
|
||||||
get_formats (PinosSink *sink,
|
|
||||||
GBytes *filter,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
PinosGstSinkPrivate *priv = PINOS_GST_SINK (sink)->priv;
|
|
||||||
GstCaps *caps, *cfilter;
|
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
if (filter) {
|
|
||||||
cfilter = gst_caps_from_string (g_bytes_get_data (filter, NULL));
|
|
||||||
if (cfilter == NULL)
|
|
||||||
goto invalid_filter;
|
|
||||||
|
|
||||||
caps = gst_caps_intersect (priv->possible_formats, cfilter);
|
|
||||||
gst_caps_unref (cfilter);
|
|
||||||
|
|
||||||
if (caps == NULL)
|
|
||||||
goto no_formats;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
caps = gst_caps_ref (priv->possible_formats);
|
|
||||||
}
|
|
||||||
g_object_get (priv->depay, "caps", &cfilter, NULL);
|
|
||||||
if (cfilter != NULL) {
|
|
||||||
GstCaps *t = caps;
|
|
||||||
|
|
||||||
caps = gst_caps_intersect (t, cfilter);
|
|
||||||
gst_caps_unref (cfilter);
|
|
||||||
gst_caps_unref (t);
|
|
||||||
}
|
|
||||||
if (gst_caps_is_empty (caps)) {
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
goto no_formats;
|
|
||||||
}
|
|
||||||
|
|
||||||
str = gst_caps_to_string (caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
|
|
||||||
return g_bytes_new_take (str, strlen (str) + 1);
|
|
||||||
|
|
||||||
invalid_filter:
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_INVALID_ARGUMENT,
|
|
||||||
"Invalid filter received");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
no_formats:
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_NOT_FOUND,
|
|
||||||
"No compatible format found");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_socket_notify (GObject *gobject,
|
on_socket_notify (GObject *gobject,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
|
|
@ -322,7 +268,7 @@ on_socket_notify (GObject *gobject,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_handles == 0) {
|
if (num_handles == 0) {
|
||||||
pinos_sink_report_idle (PINOS_SINK (sink));
|
pinos_node_report_idle (PINOS_NODE (sink));
|
||||||
g_object_set (priv->depay, "caps", NULL, NULL);
|
g_object_set (priv->depay, "caps", NULL, NULL);
|
||||||
|
|
||||||
str = gst_caps_to_string (priv->possible_formats);
|
str = gst_caps_to_string (priv->possible_formats);
|
||||||
|
|
@ -352,13 +298,9 @@ on_socket_notify (GObject *gobject,
|
||||||
}
|
}
|
||||||
/* this is what we use as the final format for the output */
|
/* this is what we use as the final format for the output */
|
||||||
g_object_set (gobject, "format", format, NULL);
|
g_object_set (gobject, "format", format, NULL);
|
||||||
pinos_sink_report_busy (PINOS_SINK (sink));
|
pinos_node_report_busy (PINOS_NODE (sink));
|
||||||
g_object_unref (socket);
|
g_object_unref (socket);
|
||||||
}
|
}
|
||||||
if (format) {
|
|
||||||
pinos_sink_update_possible_formats (PINOS_SINK (sink), format);
|
|
||||||
g_bytes_unref (format);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_get (gobject, "properties", &props, NULL);
|
g_object_get (gobject, "properties", &props, NULL);
|
||||||
while ((key = pinos_properties_iterate (priv->props, &state))) {
|
while ((key = pinos_properties_iterate (priv->props, &state))) {
|
||||||
|
|
@ -369,64 +311,29 @@ on_socket_notify (GObject *gobject,
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PinosChannel *
|
static void
|
||||||
create_channel (PinosSink *sink,
|
on_channel_added (PinosPort *port, PinosChannel *channel, PinosGstSink *sink)
|
||||||
const gchar *client_path,
|
|
||||||
GBytes *format_filter,
|
|
||||||
PinosProperties *props,
|
|
||||||
const gchar *prefix,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
PinosGstSink *s = PINOS_GST_SINK (sink);
|
PinosGstSinkPrivate *priv = sink->priv;
|
||||||
PinosGstSinkPrivate *priv = s->priv;
|
GError *error = NULL;
|
||||||
PinosChannel *channel;
|
|
||||||
gpointer state = NULL;
|
|
||||||
const gchar *key, *val;
|
|
||||||
|
|
||||||
if (priv->n_channels == 0) {
|
if (priv->n_channels == 0) {
|
||||||
if (!start_pipeline (s, error))
|
if (!start_pipeline (sink, &error))
|
||||||
return NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((key = pinos_properties_iterate (priv->props, &state))) {
|
g_signal_connect (channel, "notify::socket", (GCallback) on_socket_notify, sink);
|
||||||
val = pinos_properties_get (priv->props, key);
|
|
||||||
pinos_properties_set (props, key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
channel = PINOS_SINK_CLASS (pinos_gst_sink_parent_class)
|
|
||||||
->create_channel (sink,
|
|
||||||
client_path,
|
|
||||||
format_filter,
|
|
||||||
props,
|
|
||||||
prefix,
|
|
||||||
error);
|
|
||||||
if (channel == NULL)
|
|
||||||
goto no_channel;
|
|
||||||
|
|
||||||
g_signal_connect (channel,
|
|
||||||
"notify::socket",
|
|
||||||
(GCallback) on_socket_notify,
|
|
||||||
sink);
|
|
||||||
|
|
||||||
priv->n_channels++;
|
priv->n_channels++;
|
||||||
|
|
||||||
return channel;
|
|
||||||
|
|
||||||
/* ERRORS */
|
|
||||||
no_channel:
|
|
||||||
{
|
|
||||||
if (priv->n_channels == 0)
|
|
||||||
stop_pipeline (s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
release_channel (PinosSink *sink,
|
on_channel_removed (PinosPort *port, PinosChannel *channel, PinosGstSink *sink)
|
||||||
PinosChannel *channel)
|
|
||||||
{
|
{
|
||||||
return PINOS_SINK_CLASS (pinos_gst_sink_parent_class)
|
PinosGstSinkPrivate *priv = sink->priv;
|
||||||
->release_channel (sink, channel);
|
|
||||||
|
priv->n_channels--;
|
||||||
|
if (priv->n_channels == 0)
|
||||||
|
stop_pipeline (sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -481,10 +388,26 @@ static void
|
||||||
sink_constructed (GObject * object)
|
sink_constructed (GObject * object)
|
||||||
{
|
{
|
||||||
PinosGstSink *sink = PINOS_GST_SINK (object);
|
PinosGstSink *sink = PINOS_GST_SINK (object);
|
||||||
|
PinosGstSinkPrivate *priv = sink->priv;
|
||||||
setup_pipeline (sink, NULL);
|
gchar *str;
|
||||||
|
GBytes *format;
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_gst_sink_parent_class)->constructed (object);
|
G_OBJECT_CLASS (pinos_gst_sink_parent_class)->constructed (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),
|
||||||
|
PINOS_DIRECTION_INPUT,
|
||||||
|
"input",
|
||||||
|
format,
|
||||||
|
NULL);
|
||||||
|
g_bytes_unref (format);
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -504,7 +427,7 @@ static void
|
||||||
pinos_gst_sink_class_init (PinosGstSinkClass * klass)
|
pinos_gst_sink_class_init (PinosGstSinkClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
PinosSinkClass *sink_class = PINOS_SINK_CLASS (klass);
|
PinosNodeClass *node_class = PINOS_NODE_CLASS (klass);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (PinosGstSinkPrivate));
|
g_type_class_add_private (klass, sizeof (PinosGstSinkPrivate));
|
||||||
|
|
||||||
|
|
@ -532,10 +455,7 @@ pinos_gst_sink_class_init (PinosGstSinkClass * klass)
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
sink_class->get_formats = get_formats;
|
node_class->set_state = set_state;
|
||||||
sink_class->set_state = set_state;
|
|
||||||
sink_class->create_channel = create_channel;
|
|
||||||
sink_class->release_channel = release_channel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -547,22 +467,22 @@ pinos_gst_sink_init (PinosGstSink * sink)
|
||||||
priv->props = pinos_properties_new (NULL, NULL);
|
priv->props = pinos_properties_new (NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
PinosSink *
|
PinosNode *
|
||||||
pinos_gst_sink_new (PinosNode *node,
|
pinos_gst_sink_new (PinosDaemon *daemon,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
PinosProperties *properties,
|
PinosProperties *properties,
|
||||||
GstElement *element,
|
GstElement *element,
|
||||||
GstCaps *caps)
|
GstCaps *caps)
|
||||||
{
|
{
|
||||||
PinosSink *sink;
|
PinosNode *node;
|
||||||
|
|
||||||
sink = g_object_new (PINOS_TYPE_GST_SINK,
|
node = g_object_new (PINOS_TYPE_GST_SINK,
|
||||||
"node", node,
|
"daemon", daemon,
|
||||||
"name", name,
|
"name", name,
|
||||||
"properties", properties,
|
"properties", properties,
|
||||||
"element", element,
|
"element", element,
|
||||||
"possible-formats", caps,
|
"possible-formats", caps,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return sink;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include <client/pinos.h>
|
#include <client/pinos.h>
|
||||||
#include <server/node.h>
|
#include <server/node.h>
|
||||||
#include <server/sink.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
@ -42,18 +41,18 @@ typedef struct _PinosGstSinkClass PinosGstSinkClass;
|
||||||
typedef struct _PinosGstSinkPrivate PinosGstSinkPrivate;
|
typedef struct _PinosGstSinkPrivate PinosGstSinkPrivate;
|
||||||
|
|
||||||
struct _PinosGstSink {
|
struct _PinosGstSink {
|
||||||
PinosSink object;
|
PinosNode object;
|
||||||
|
|
||||||
PinosGstSinkPrivate *priv;
|
PinosGstSinkPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _PinosGstSinkClass {
|
struct _PinosGstSinkClass {
|
||||||
PinosSinkClass parent_class;
|
PinosNodeClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType pinos_gst_sink_get_type (void);
|
GType pinos_gst_sink_get_type (void);
|
||||||
|
|
||||||
PinosSink * pinos_gst_sink_new (PinosNode *node,
|
PinosNode * pinos_gst_sink_new (PinosDaemon *daemon,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
PinosProperties *properties,
|
PinosProperties *properties,
|
||||||
GstElement *element,
|
GstElement *element,
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ struct _PinosGstSourcePrivate
|
||||||
GstElement *filter;
|
GstElement *filter;
|
||||||
GstElement *sink;
|
GstElement *sink;
|
||||||
|
|
||||||
|
PinosPort *output;
|
||||||
GstCaps *possible_formats;
|
GstCaps *possible_formats;
|
||||||
|
|
||||||
GstNetTimeProvider *provider;
|
GstNetTimeProvider *provider;
|
||||||
|
|
@ -50,15 +51,15 @@ enum {
|
||||||
PROP_POSSIBLE_FORMATS
|
PROP_POSSIBLE_FORMATS
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (PinosGstSource, pinos_gst_source, PINOS_TYPE_SOURCE);
|
G_DEFINE_TYPE (PinosGstSource, pinos_gst_source, PINOS_TYPE_NODE);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
bus_handler (GstBus *bus,
|
bus_handler (GstBus *bus,
|
||||||
GstMessage *message,
|
GstMessage *message,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosSource *source = user_data;
|
PinosNode *node = user_data;
|
||||||
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv;
|
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (node)->priv;
|
||||||
|
|
||||||
switch (GST_MESSAGE_TYPE (message)) {
|
switch (GST_MESSAGE_TYPE (message)) {
|
||||||
case GST_MESSAGE_ERROR:
|
case GST_MESSAGE_ERROR:
|
||||||
|
|
@ -70,7 +71,7 @@ bus_handler (GstBus *bus,
|
||||||
g_warning ("got error %s (%s)\n", error->message, debug);
|
g_warning ("got error %s (%s)\n", error->message, debug);
|
||||||
g_free (debug);
|
g_free (debug);
|
||||||
|
|
||||||
pinos_source_report_error (source, error);
|
pinos_node_report_error (node, error);
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -82,9 +83,9 @@ bus_handler (GstBus *bus,
|
||||||
gst_message_parse_new_clock (message, &clock);
|
gst_message_parse_new_clock (message, &clock);
|
||||||
GST_INFO ("got new clock %s", GST_OBJECT_NAME (clock));
|
GST_INFO ("got new clock %s", GST_OBJECT_NAME (clock));
|
||||||
|
|
||||||
g_object_get (source, "properties", &props, NULL);
|
g_object_get (node, "properties", &props, NULL);
|
||||||
pinos_properties_set (props, "gst.pipeline.clock", GST_OBJECT_NAME (clock));
|
pinos_properties_set (props, "gst.pipeline.clock", GST_OBJECT_NAME (clock));
|
||||||
g_object_set (source, "properties", props, NULL);
|
g_object_set (node, "properties", props, NULL);
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -96,9 +97,9 @@ bus_handler (GstBus *bus,
|
||||||
gst_message_parse_new_clock (message, &clock);
|
gst_message_parse_new_clock (message, &clock);
|
||||||
GST_INFO ("clock lost %s", GST_OBJECT_NAME (clock));
|
GST_INFO ("clock lost %s", GST_OBJECT_NAME (clock));
|
||||||
|
|
||||||
g_object_get (source, "properties", &props, NULL);
|
g_object_get (node, "properties", &props, NULL);
|
||||||
pinos_properties_remove (props, "gst.pipeline.clock");
|
pinos_properties_remove (props, "gst.pipeline.clock");
|
||||||
g_object_set (source, "properties", props, NULL);
|
g_object_set (node, "properties", props, NULL);
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
|
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
||||||
|
|
@ -111,19 +112,16 @@ bus_handler (GstBus *bus,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
setup_pipeline (PinosGstSource *source, GError **error)
|
setup_pipeline (PinosGstSource *source, GError **error)
|
||||||
{
|
{
|
||||||
PinosGstSourcePrivate *priv = source->priv;
|
PinosGstSourcePrivate *priv = source->priv;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
|
||||||
|
g_debug ("gst-source %p: setup pipeline", source);
|
||||||
priv->pipeline = gst_pipeline_new (NULL);
|
priv->pipeline = gst_pipeline_new (NULL);
|
||||||
gst_pipeline_set_latency (GST_PIPELINE_CAST (priv->pipeline), 0);
|
gst_pipeline_set_latency (GST_PIPELINE_CAST (priv->pipeline), 0);
|
||||||
|
|
||||||
g_debug ("gst-source %p: setup pipeline", source);
|
|
||||||
|
|
||||||
gst_bin_add (GST_BIN (priv->pipeline), priv->element);
|
gst_bin_add (GST_BIN (priv->pipeline), priv->element);
|
||||||
|
|
||||||
priv->filter = gst_element_factory_make ("capsfilter", NULL);
|
priv->filter = gst_element_factory_make ("capsfilter", NULL);
|
||||||
|
|
@ -150,9 +148,10 @@ static gboolean
|
||||||
start_pipeline (PinosGstSource *source, GError **error)
|
start_pipeline (PinosGstSource *source, GError **error)
|
||||||
{
|
{
|
||||||
PinosGstSourcePrivate *priv = source->priv;
|
PinosGstSourcePrivate *priv = source->priv;
|
||||||
GstCaps *res;
|
GstCaps *caps;
|
||||||
GstQuery *query;
|
GstQuery *query;
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
|
gchar *str;
|
||||||
|
|
||||||
g_debug ("gst-source %p: starting pipeline", source);
|
g_debug ("gst-source %p: starting pipeline", source);
|
||||||
|
|
||||||
|
|
@ -161,9 +160,13 @@ start_pipeline (PinosGstSource *source, GError **error)
|
||||||
goto ready_failed;
|
goto ready_failed;
|
||||||
|
|
||||||
query = gst_query_new_caps (NULL);
|
query = gst_query_new_caps (NULL);
|
||||||
gst_element_query (priv->element, query);
|
if (gst_element_query (priv->element, query)) {
|
||||||
gst_query_parse_caps_result (query, &res);
|
gst_query_parse_caps_result (query, &caps);
|
||||||
gst_caps_replace (&priv->possible_formats, res);
|
gst_caps_replace (&priv->possible_formats, caps);
|
||||||
|
str = gst_caps_to_string (caps);
|
||||||
|
g_debug ("gst-source %p: updated possible formats %s", source, str);
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
gst_query_unref (query);
|
gst_query_unref (query);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
@ -203,27 +206,27 @@ destroy_pipeline (PinosGstSource *source)
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
set_state (PinosSource *source,
|
set_state (PinosNode *node,
|
||||||
PinosSourceState state)
|
PinosNodeState state)
|
||||||
{
|
{
|
||||||
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv;
|
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (node)->priv;
|
||||||
|
|
||||||
g_debug ("gst-source %p: set state %d", source, state);
|
g_debug ("gst-source %p: set state %s", node, pinos_node_state_as_string (state));
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PINOS_SOURCE_STATE_SUSPENDED:
|
case PINOS_NODE_STATE_SUSPENDED:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SOURCE_STATE_INITIALIZING:
|
case PINOS_NODE_STATE_INITIALIZING:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SOURCE_STATE_IDLE:
|
case PINOS_NODE_STATE_IDLE:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SOURCE_STATE_RUNNING:
|
case PINOS_NODE_STATE_RUNNING:
|
||||||
{
|
{
|
||||||
GstQuery *query;
|
GstQuery *query;
|
||||||
GstClock *clock;
|
GstClock *clock;
|
||||||
|
|
@ -276,72 +279,13 @@ set_state (PinosSource *source,
|
||||||
pinos_properties_setf (priv->props, "pinos.latency.max", "%"G_GUINT64_FORMAT, max_latency);
|
pinos_properties_setf (priv->props, "pinos.latency.max", "%"G_GUINT64_FORMAT, max_latency);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PINOS_SOURCE_STATE_ERROR:
|
case PINOS_NODE_STATE_ERROR:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pinos_source_update_state (source, state);
|
pinos_node_update_state (node, state);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GBytes *
|
|
||||||
get_formats (PinosSource *source,
|
|
||||||
GBytes *filter,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv;
|
|
||||||
GstCaps *caps, *cfilter;
|
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
if (filter) {
|
|
||||||
cfilter = gst_caps_from_string (g_bytes_get_data (filter, NULL));
|
|
||||||
if (cfilter == NULL)
|
|
||||||
goto invalid_filter;
|
|
||||||
|
|
||||||
caps = gst_caps_intersect (priv->possible_formats, cfilter);
|
|
||||||
gst_caps_unref (cfilter);
|
|
||||||
|
|
||||||
if (caps == NULL)
|
|
||||||
goto no_formats;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
caps = gst_caps_ref (priv->possible_formats);
|
|
||||||
}
|
|
||||||
g_object_get (priv->filter, "caps", &cfilter, NULL);
|
|
||||||
if (cfilter != NULL) {
|
|
||||||
GstCaps *t = caps;
|
|
||||||
|
|
||||||
caps = gst_caps_intersect (t, cfilter);
|
|
||||||
gst_caps_unref (cfilter);
|
|
||||||
gst_caps_unref (t);
|
|
||||||
}
|
|
||||||
if (gst_caps_is_empty (caps)) {
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
goto no_formats;
|
|
||||||
}
|
|
||||||
|
|
||||||
str = gst_caps_to_string (caps);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
|
|
||||||
return g_bytes_new_take (str, strlen (str) + 1);
|
|
||||||
|
|
||||||
invalid_filter:
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_INVALID_ARGUMENT,
|
|
||||||
"Invalid filter received");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
no_formats:
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_NOT_FOUND,
|
|
||||||
"No compatible format found");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_socket_notify (GObject *gobject,
|
on_socket_notify (GObject *gobject,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
|
|
@ -374,7 +318,7 @@ on_socket_notify (GObject *gobject,
|
||||||
|
|
||||||
g_object_get (priv->sink, "num-handles", &num_handles, NULL);
|
g_object_get (priv->sink, "num-handles", &num_handles, NULL);
|
||||||
if (num_handles == 0) {
|
if (num_handles == 0) {
|
||||||
pinos_source_report_idle (PINOS_SOURCE (source));
|
pinos_node_report_idle (PINOS_NODE (source));
|
||||||
g_object_set (priv->filter, "caps", NULL, NULL);
|
g_object_set (priv->filter, "caps", NULL, NULL);
|
||||||
|
|
||||||
str = gst_caps_to_string (priv->possible_formats);
|
str = gst_caps_to_string (priv->possible_formats);
|
||||||
|
|
@ -404,10 +348,10 @@ on_socket_notify (GObject *gobject,
|
||||||
}
|
}
|
||||||
/* this is what we use as the final format for the output */
|
/* this is what we use as the final format for the output */
|
||||||
g_object_set (gobject, "format", format, NULL);
|
g_object_set (gobject, "format", format, NULL);
|
||||||
pinos_source_report_busy (PINOS_SOURCE (source));
|
pinos_node_report_busy (PINOS_NODE (source));
|
||||||
}
|
}
|
||||||
if (format) {
|
if (format) {
|
||||||
pinos_source_update_possible_formats (PINOS_SOURCE (source), format);
|
g_object_set (priv->output, "possible-formats", format, NULL);
|
||||||
g_bytes_unref (format);
|
g_bytes_unref (format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -420,64 +364,29 @@ on_socket_notify (GObject *gobject,
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PinosChannel *
|
static void
|
||||||
create_channel (PinosSource *source,
|
on_channel_added (PinosPort *port, PinosChannel *channel, PinosGstSource *source)
|
||||||
const gchar *client_path,
|
|
||||||
GBytes *format_filter,
|
|
||||||
PinosProperties *props,
|
|
||||||
const gchar *prefix,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
PinosGstSource *s = PINOS_GST_SOURCE (source);
|
PinosGstSourcePrivate *priv = source->priv;
|
||||||
PinosGstSourcePrivate *priv = s->priv;
|
GError *error = NULL;
|
||||||
PinosChannel *channel;
|
|
||||||
gpointer state = NULL;
|
|
||||||
const gchar *key, *val;
|
|
||||||
|
|
||||||
if (priv->n_channels == 0) {
|
if (priv->n_channels == 0) {
|
||||||
if (!start_pipeline (s, error))
|
if (!start_pipeline (source, &error))
|
||||||
return NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((key = pinos_properties_iterate (priv->props, &state))) {
|
g_signal_connect (channel, "notify::socket", (GCallback) on_socket_notify, source);
|
||||||
val = pinos_properties_get (priv->props, key);
|
|
||||||
pinos_properties_set (props, key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
channel = PINOS_SOURCE_CLASS (pinos_gst_source_parent_class)
|
|
||||||
->create_channel (source,
|
|
||||||
client_path,
|
|
||||||
format_filter,
|
|
||||||
props,
|
|
||||||
prefix,
|
|
||||||
error);
|
|
||||||
if (channel == NULL)
|
|
||||||
goto no_channel;
|
|
||||||
|
|
||||||
g_signal_connect (channel,
|
|
||||||
"notify::socket",
|
|
||||||
(GCallback) on_socket_notify,
|
|
||||||
source);
|
|
||||||
|
|
||||||
priv->n_channels++;
|
priv->n_channels++;
|
||||||
|
|
||||||
return channel;
|
|
||||||
|
|
||||||
/* ERRORS */
|
|
||||||
no_channel:
|
|
||||||
{
|
|
||||||
if (priv->n_channels == 0)
|
|
||||||
stop_pipeline (s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
release_channel (PinosSource *source,
|
on_channel_removed (PinosPort *port, PinosChannel *channel, PinosGstSource *source)
|
||||||
PinosChannel *channel)
|
|
||||||
{
|
{
|
||||||
return PINOS_SOURCE_CLASS (pinos_gst_source_parent_class)
|
PinosGstSourcePrivate *priv = source->priv;
|
||||||
->release_channel (source, channel);
|
|
||||||
|
priv->n_channels--;
|
||||||
|
if (priv->n_channels == 0)
|
||||||
|
stop_pipeline (source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -532,10 +441,26 @@ static void
|
||||||
source_constructed (GObject * object)
|
source_constructed (GObject * object)
|
||||||
{
|
{
|
||||||
PinosGstSource *source = PINOS_GST_SOURCE (object);
|
PinosGstSource *source = PINOS_GST_SOURCE (object);
|
||||||
|
PinosGstSourcePrivate *priv = source->priv;
|
||||||
setup_pipeline (source, NULL);
|
gchar *str;
|
||||||
|
GBytes *format;
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_gst_source_parent_class)->constructed (object);
|
G_OBJECT_CLASS (pinos_gst_source_parent_class)->constructed (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),
|
||||||
|
PINOS_DIRECTION_OUTPUT,
|
||||||
|
"output",
|
||||||
|
format,
|
||||||
|
NULL);
|
||||||
|
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);
|
||||||
|
|
||||||
|
setup_pipeline (source, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -555,7 +480,7 @@ static void
|
||||||
pinos_gst_source_class_init (PinosGstSourceClass * klass)
|
pinos_gst_source_class_init (PinosGstSourceClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
PinosSourceClass *source_class = PINOS_SOURCE_CLASS (klass);
|
PinosNodeClass *node_class = PINOS_NODE_CLASS (klass);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (PinosGstSourcePrivate));
|
g_type_class_add_private (klass, sizeof (PinosGstSourcePrivate));
|
||||||
|
|
||||||
|
|
@ -583,10 +508,7 @@ pinos_gst_source_class_init (PinosGstSourceClass * klass)
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
source_class->get_formats = get_formats;
|
node_class->set_state = set_state;
|
||||||
source_class->set_state = set_state;
|
|
||||||
source_class->create_channel = create_channel;
|
|
||||||
source_class->release_channel = release_channel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -598,22 +520,22 @@ pinos_gst_source_init (PinosGstSource * source)
|
||||||
priv->props = pinos_properties_new (NULL, NULL);
|
priv->props = pinos_properties_new (NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
PinosSource *
|
PinosNode *
|
||||||
pinos_gst_source_new (PinosNode *node,
|
pinos_gst_source_new (PinosDaemon *daemon,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
PinosProperties *properties,
|
PinosProperties *properties,
|
||||||
GstElement *element,
|
GstElement *element,
|
||||||
GstCaps *caps)
|
GstCaps *caps)
|
||||||
{
|
{
|
||||||
PinosSource *source;
|
PinosNode *node;
|
||||||
|
|
||||||
source = g_object_new (PINOS_TYPE_GST_SOURCE,
|
node = g_object_new (PINOS_TYPE_GST_SOURCE,
|
||||||
"node", node,
|
"daemon", daemon,
|
||||||
"name", name,
|
"name", name,
|
||||||
"properties", properties,
|
"properties", properties,
|
||||||
"element", element,
|
"element", element,
|
||||||
"possible-formats", caps,
|
"possible-formats", caps,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return source;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include <client/pinos.h>
|
#include <client/pinos.h>
|
||||||
#include <server/node.h>
|
#include <server/node.h>
|
||||||
#include <server/source.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
@ -42,18 +41,18 @@ typedef struct _PinosGstSourceClass PinosGstSourceClass;
|
||||||
typedef struct _PinosGstSourcePrivate PinosGstSourcePrivate;
|
typedef struct _PinosGstSourcePrivate PinosGstSourcePrivate;
|
||||||
|
|
||||||
struct _PinosGstSource {
|
struct _PinosGstSource {
|
||||||
PinosSource object;
|
PinosNode object;
|
||||||
|
|
||||||
PinosGstSourcePrivate *priv;
|
PinosGstSourcePrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _PinosGstSourceClass {
|
struct _PinosGstSourceClass {
|
||||||
PinosSourceClass parent_class;
|
PinosNodeClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType pinos_gst_source_get_type (void);
|
GType pinos_gst_source_get_type (void);
|
||||||
|
|
||||||
PinosSource * pinos_gst_source_new (PinosNode *node,
|
PinosNode * pinos_gst_source_new (PinosDaemon *daemon,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
PinosProperties *properties,
|
PinosProperties *properties,
|
||||||
GstElement *element,
|
GstElement *element,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ struct _PinosChannelPrivate
|
||||||
|
|
||||||
gchar *object_path;
|
gchar *object_path;
|
||||||
gchar *client_path;
|
gchar *client_path;
|
||||||
gchar *owner_path;
|
gchar *port_path;
|
||||||
|
PinosDirection direction;
|
||||||
|
|
||||||
GBytes *possible_formats;
|
GBytes *possible_formats;
|
||||||
PinosProperties *properties;
|
PinosProperties *properties;
|
||||||
|
|
@ -58,7 +59,8 @@ enum
|
||||||
PROP_DAEMON,
|
PROP_DAEMON,
|
||||||
PROP_OBJECT_PATH,
|
PROP_OBJECT_PATH,
|
||||||
PROP_CLIENT_PATH,
|
PROP_CLIENT_PATH,
|
||||||
PROP_OWNER_PATH,
|
PROP_PORT_PATH,
|
||||||
|
PROP_DIRECTION,
|
||||||
PROP_POSSIBLE_FORMATS,
|
PROP_POSSIBLE_FORMATS,
|
||||||
PROP_PROPERTIES,
|
PROP_PROPERTIES,
|
||||||
PROP_REQUESTED_FORMAT,
|
PROP_REQUESTED_FORMAT,
|
||||||
|
|
@ -97,8 +99,12 @@ pinos_channel_get_property (GObject *_object,
|
||||||
g_value_set_string (value, priv->client_path);
|
g_value_set_string (value, priv->client_path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_OWNER_PATH:
|
case PROP_PORT_PATH:
|
||||||
g_value_set_string (value, priv->owner_path);
|
g_value_set_string (value, priv->port_path);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_DIRECTION:
|
||||||
|
g_value_set_enum (value, priv->direction);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_POSSIBLE_FORMATS:
|
case PROP_POSSIBLE_FORMATS:
|
||||||
|
|
@ -154,9 +160,14 @@ pinos_channel_set_property (GObject *_object,
|
||||||
g_object_set (priv->iface, "client", priv->client_path, NULL);
|
g_object_set (priv->iface, "client", priv->client_path, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_OWNER_PATH:
|
case PROP_PORT_PATH:
|
||||||
priv->owner_path = g_value_dup_string (value);
|
priv->port_path = g_value_dup_string (value);
|
||||||
g_object_set (priv->iface, "owner", priv->owner_path, NULL);
|
g_object_set (priv->iface, "port", priv->port_path, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_DIRECTION:
|
||||||
|
priv->direction = g_value_get_enum (value);
|
||||||
|
g_object_set (priv->iface, "direction", priv->direction, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_POSSIBLE_FORMATS:
|
case PROP_POSSIBLE_FORMATS:
|
||||||
|
|
@ -212,7 +223,7 @@ stop_transfer (PinosChannel *channel)
|
||||||
g_object_notify (G_OBJECT (channel), "socket");
|
g_object_notify (G_OBJECT (channel), "socket");
|
||||||
}
|
}
|
||||||
clear_formats (channel);
|
clear_formats (channel);
|
||||||
priv->state = PINOS_CHANNEL_STATE_IDLE;
|
priv->state = PINOS_CHANNEL_STATE_STOPPED;
|
||||||
g_object_set (priv->iface,
|
g_object_set (priv->iface,
|
||||||
"state", priv->state,
|
"state", priv->state,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
@ -321,14 +332,13 @@ handle_remove (PinosChannel1 *interface,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
channel_register_object (PinosChannel *channel,
|
channel_register_object (PinosChannel *channel)
|
||||||
const gchar *prefix)
|
|
||||||
{
|
{
|
||||||
PinosChannelPrivate *priv = channel->priv;
|
PinosChannelPrivate *priv = channel->priv;
|
||||||
PinosObjectSkeleton *skel;
|
PinosObjectSkeleton *skel;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
|
||||||
name = g_strdup_printf ("%s/channel", prefix);
|
name = g_strdup_printf ("%s/channel", priv->client_path);
|
||||||
skel = pinos_object_skeleton_new (name);
|
skel = pinos_object_skeleton_new (name);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
|
|
@ -377,7 +387,7 @@ pinos_channel_finalize (GObject * object)
|
||||||
g_clear_object (&priv->iface);
|
g_clear_object (&priv->iface);
|
||||||
g_free (priv->client_path);
|
g_free (priv->client_path);
|
||||||
g_free (priv->object_path);
|
g_free (priv->object_path);
|
||||||
g_free (priv->owner_path);
|
g_free (priv->port_path);
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_channel_parent_class)->finalize (object);
|
G_OBJECT_CLASS (pinos_channel_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
@ -386,10 +396,9 @@ static void
|
||||||
pinos_channel_constructed (GObject * object)
|
pinos_channel_constructed (GObject * object)
|
||||||
{
|
{
|
||||||
PinosChannel *channel = PINOS_CHANNEL (object);
|
PinosChannel *channel = PINOS_CHANNEL (object);
|
||||||
PinosChannelPrivate *priv = channel->priv;
|
|
||||||
|
|
||||||
g_debug ("channel %p: constructed", channel);
|
g_debug ("channel %p: constructed", channel);
|
||||||
channel_register_object (channel, priv->object_path);
|
channel_register_object (channel);
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_channel_parent_class)->constructed (object);
|
G_OBJECT_CLASS (pinos_channel_parent_class)->constructed (object);
|
||||||
}
|
}
|
||||||
|
|
@ -438,15 +447,26 @@ pinos_channel_class_init (PinosChannelClass * klass)
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_OWNER_PATH,
|
PROP_PORT_PATH,
|
||||||
g_param_spec_string ("owner-path",
|
g_param_spec_string ("port-path",
|
||||||
"Owner Path",
|
"Port Path",
|
||||||
"The owner object path",
|
"The port object path",
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_CONSTRUCT |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_DIRECTION,
|
||||||
|
g_param_spec_enum ("direction",
|
||||||
|
"Direction",
|
||||||
|
"The direction of the port",
|
||||||
|
PINOS_TYPE_DIRECTION,
|
||||||
|
PINOS_DIRECTION_INVALID,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_POSSIBLE_FORMATS,
|
PROP_POSSIBLE_FORMATS,
|
||||||
g_param_spec_boxed ("possible-formats",
|
g_param_spec_boxed ("possible-formats",
|
||||||
|
|
@ -516,9 +536,11 @@ pinos_channel_init (PinosChannel * channel)
|
||||||
g_signal_connect (priv->iface, "handle-stop", (GCallback) handle_stop, channel);
|
g_signal_connect (priv->iface, "handle-stop", (GCallback) handle_stop, channel);
|
||||||
g_signal_connect (priv->iface, "handle-remove", (GCallback) handle_remove, channel);
|
g_signal_connect (priv->iface, "handle-remove", (GCallback) handle_remove, channel);
|
||||||
|
|
||||||
priv->state = PINOS_CHANNEL_STATE_IDLE;
|
priv->state = PINOS_CHANNEL_STATE_STOPPED;
|
||||||
g_object_set (priv->iface, "state", priv->state, NULL);
|
g_object_set (priv->iface, "state", priv->state, NULL);
|
||||||
|
|
||||||
|
priv->direction = PINOS_DIRECTION_INVALID;
|
||||||
|
|
||||||
g_debug ("channel %p: new", channel);
|
g_debug ("channel %p: new", channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
/* Pinos
|
|
||||||
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __PINOS_CLIENT_SOURCE_H__
|
|
||||||
#define __PINOS_CLIENT_SOURCE_H__
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef struct _PinosClientSource PinosClientSource;
|
|
||||||
typedef struct _PinosClientSourceClass PinosClientSourceClass;
|
|
||||||
typedef struct _PinosClientSourcePrivate PinosClientSourcePrivate;
|
|
||||||
|
|
||||||
#include <pinos/server/source.h>
|
|
||||||
|
|
||||||
#define PINOS_TYPE_CLIENT_SOURCE (pinos_client_source_get_type ())
|
|
||||||
#define PINOS_IS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE))
|
|
||||||
#define PINOS_IS_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SOURCE))
|
|
||||||
#define PINOS_CLIENT_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SOURCE, PinosClientSourceClass))
|
|
||||||
#define PINOS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SOURCE, PinosClientSource))
|
|
||||||
#define PINOS_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SOURCE, PinosClientSourceClass))
|
|
||||||
#define PINOS_CLIENT_SOURCE_CAST(obj) ((PinosClientSource*)(obj))
|
|
||||||
#define PINOS_CLIENT_SOURCE_CLASS_CAST(klass) ((PinosClientSourceClass*)(klass))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PinosClientSource:
|
|
||||||
*
|
|
||||||
* Pinos client source object class.
|
|
||||||
*/
|
|
||||||
struct _PinosClientSource {
|
|
||||||
PinosSource object;
|
|
||||||
|
|
||||||
PinosClientSourcePrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PinosClientSourceClass:
|
|
||||||
*
|
|
||||||
* Pinos client source object class.
|
|
||||||
*/
|
|
||||||
struct _PinosClientSourceClass {
|
|
||||||
PinosSourceClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* normal GObject stuff */
|
|
||||||
GType pinos_client_source_get_type (void);
|
|
||||||
|
|
||||||
PinosSource * pinos_client_source_new (PinosDaemon *daemon,
|
|
||||||
GBytes *possible_formats);
|
|
||||||
|
|
||||||
PinosChannel * pinos_client_source_get_channel (PinosClientSource *source,
|
|
||||||
const gchar *client_path,
|
|
||||||
GBytes *format_filter,
|
|
||||||
PinosProperties *props,
|
|
||||||
const gchar *prefix,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __PINOS_CLIENT_SOURCE_H__ */
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
|
|
||||||
#include "pinos/server/client.h"
|
#include "pinos/server/client.h"
|
||||||
#include "pinos/server/client-source.h"
|
#include "pinos/server/upload-node.h"
|
||||||
|
|
||||||
#include "pinos/dbus/org-pinos.h"
|
#include "pinos/dbus/org-pinos.h"
|
||||||
|
|
||||||
|
|
@ -139,17 +139,17 @@ handle_remove_channel (PinosChannel *channel,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_create_source_channel (PinosClient1 *interface,
|
handle_create_channel (PinosClient1 *interface,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
const gchar *arg_source,
|
PinosDirection direction,
|
||||||
const gchar *arg_accepted_formats,
|
const gchar *arg_port,
|
||||||
GVariant *arg_properties,
|
const gchar *arg_possible_formats,
|
||||||
gpointer user_data)
|
GVariant *arg_properties,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosClient *client = user_data;
|
PinosClient *client = user_data;
|
||||||
PinosClientPrivate *priv = client->priv;
|
PinosClientPrivate *priv = client->priv;
|
||||||
PinosNode *node;
|
PinosPort *port;
|
||||||
PinosSource *source;
|
|
||||||
PinosChannel *channel;
|
PinosChannel *channel;
|
||||||
const gchar *object_path, *sender;
|
const gchar *object_path, *sender;
|
||||||
GBytes *formats;
|
GBytes *formats;
|
||||||
|
|
@ -160,27 +160,25 @@ handle_create_source_channel (PinosClient1 *interface,
|
||||||
if (g_strcmp0 (pinos_client_get_sender (client), sender) != 0)
|
if (g_strcmp0 (pinos_client_get_sender (client), sender) != 0)
|
||||||
goto not_allowed;
|
goto not_allowed;
|
||||||
|
|
||||||
formats = g_bytes_new (arg_accepted_formats, strlen (arg_accepted_formats) + 1);
|
formats = g_bytes_new (arg_possible_formats, strlen (arg_possible_formats) + 1);
|
||||||
props = pinos_properties_from_variant (arg_properties);
|
props = pinos_properties_from_variant (arg_properties);
|
||||||
|
|
||||||
node = pinos_daemon_find_node (priv->daemon,
|
port = pinos_daemon_find_port (priv->daemon,
|
||||||
arg_source,
|
direction,
|
||||||
|
arg_port,
|
||||||
props,
|
props,
|
||||||
formats,
|
formats,
|
||||||
&error);
|
&error);
|
||||||
if (node == NULL)
|
if (port == NULL)
|
||||||
goto no_node;
|
goto no_port;
|
||||||
|
|
||||||
source = pinos_node_get_source (node);
|
g_debug ("client %p: matched port %s", client, pinos_port_get_object_path (port));
|
||||||
if (source == NULL)
|
|
||||||
goto no_source;
|
|
||||||
|
|
||||||
channel = pinos_source_create_channel (source,
|
channel = pinos_port_create_channel (port,
|
||||||
priv->object_path,
|
priv->object_path,
|
||||||
formats,
|
formats,
|
||||||
props,
|
props,
|
||||||
priv->object_path,
|
&error);
|
||||||
&error);
|
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
g_bytes_unref (formats);
|
g_bytes_unref (formats);
|
||||||
|
|
||||||
|
|
@ -208,124 +206,18 @@ not_allowed:
|
||||||
"org.pinos.Error", "not client owner");
|
"org.pinos.Error", "not client owner");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
no_node:
|
no_port:
|
||||||
{
|
{
|
||||||
g_debug ("client %p: could not find node %s, %s", client, arg_source, error->message);
|
g_debug ("client %p: could not find port %s, %s", client, arg_port, error->message);
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
g_bytes_unref (formats);
|
g_bytes_unref (formats);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
return TRUE;
|
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:
|
no_channel:
|
||||||
{
|
{
|
||||||
g_debug ("client %p: could not create source channel %s", client, error->message);
|
g_debug ("client %p: could not create 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_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
@ -341,7 +233,7 @@ handle_create_upload_channel (PinosClient1 *interface,
|
||||||
{
|
{
|
||||||
PinosClient *client = user_data;
|
PinosClient *client = user_data;
|
||||||
PinosClientPrivate *priv = client->priv;
|
PinosClientPrivate *priv = client->priv;
|
||||||
PinosSource *source;
|
PinosNode *node;
|
||||||
PinosChannel *channel;
|
PinosChannel *channel;
|
||||||
const gchar *channel_path, *sender;
|
const gchar *channel_path, *sender;
|
||||||
GBytes *formats;
|
GBytes *formats;
|
||||||
|
|
@ -354,19 +246,18 @@ handle_create_upload_channel (PinosClient1 *interface,
|
||||||
|
|
||||||
formats = g_bytes_new (arg_possible_formats, strlen (arg_possible_formats) + 1);
|
formats = g_bytes_new (arg_possible_formats, strlen (arg_possible_formats) + 1);
|
||||||
|
|
||||||
source = pinos_client_source_new (priv->daemon, formats);
|
node = pinos_upload_node_new (priv->daemon, formats);
|
||||||
if (source == NULL)
|
if (node == NULL)
|
||||||
goto no_source;
|
goto no_node;
|
||||||
|
|
||||||
sender = g_dbus_method_invocation_get_sender (invocation);
|
sender = g_dbus_method_invocation_get_sender (invocation);
|
||||||
props = pinos_properties_from_variant (arg_properties);
|
props = pinos_properties_from_variant (arg_properties);
|
||||||
|
|
||||||
channel = pinos_client_source_get_channel (PINOS_CLIENT_SOURCE (source),
|
channel = pinos_upload_node_get_channel (PINOS_UPLOAD_NODE (node),
|
||||||
priv->object_path,
|
priv->object_path,
|
||||||
formats,
|
formats,
|
||||||
props,
|
props,
|
||||||
priv->object_path,
|
&error);
|
||||||
&error);
|
|
||||||
pinos_properties_free (props);
|
pinos_properties_free (props);
|
||||||
|
|
||||||
if (channel == NULL)
|
if (channel == NULL)
|
||||||
|
|
@ -374,7 +265,7 @@ handle_create_upload_channel (PinosClient1 *interface,
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (channel),
|
g_object_set_data_full (G_OBJECT (channel),
|
||||||
"channel-owner",
|
"channel-owner",
|
||||||
source,
|
node,
|
||||||
g_object_unref);
|
g_object_unref);
|
||||||
|
|
||||||
channel_path = pinos_channel_get_object_path (channel);
|
channel_path = pinos_channel_get_object_path (channel);
|
||||||
|
|
@ -399,11 +290,11 @@ not_allowed:
|
||||||
"org.pinos.Error", "not client owner");
|
"org.pinos.Error", "not client owner");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
no_source:
|
no_node:
|
||||||
{
|
{
|
||||||
g_debug ("client %p: could not create source", client);
|
g_debug ("client %p: could not create upload node", client);
|
||||||
g_dbus_method_invocation_return_dbus_error (invocation,
|
g_dbus_method_invocation_return_dbus_error (invocation,
|
||||||
"org.pinos.Error", "Can't create source");
|
"org.pinos.Error", "Can't create upload node");
|
||||||
g_bytes_unref (formats);
|
g_bytes_unref (formats);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +302,7 @@ no_channel:
|
||||||
{
|
{
|
||||||
g_debug ("client %p: could not create upload 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_dbus_method_invocation_return_gerror (invocation, error);
|
||||||
g_object_unref (source);
|
g_object_unref (node);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
g_bytes_unref (formats);
|
g_bytes_unref (formats);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
@ -448,11 +339,8 @@ client_register_object (PinosClient *client,
|
||||||
priv->client1 = pinos_client1_skeleton_new ();
|
priv->client1 = pinos_client1_skeleton_new ();
|
||||||
pinos_client1_set_name (priv->client1, priv->sender);
|
pinos_client1_set_name (priv->client1, priv->sender);
|
||||||
pinos_client1_set_properties (priv->client1, pinos_properties_to_variant (priv->properties));
|
pinos_client1_set_properties (priv->client1, pinos_properties_to_variant (priv->properties));
|
||||||
g_signal_connect (priv->client1, "handle-create-source-channel",
|
g_signal_connect (priv->client1, "handle-create-channel",
|
||||||
(GCallback) handle_create_source_channel,
|
(GCallback) handle_create_channel,
|
||||||
client);
|
|
||||||
g_signal_connect (priv->client1, "handle-create-sink-channel",
|
|
||||||
(GCallback) handle_create_sink_channel,
|
|
||||||
client);
|
client);
|
||||||
g_signal_connect (priv->client1, "handle-create-upload-channel",
|
g_signal_connect (priv->client1, "handle-create-upload-channel",
|
||||||
(GCallback) handle_create_upload_channel,
|
(GCallback) handle_create_upload_channel,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
@ -380,47 +382,83 @@ pinos_daemon_remove_node (PinosDaemon *daemon,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_daemon_find_node:
|
* pinos_daemon_find_port:
|
||||||
* @daemon: a #PinosDaemon
|
* @daemon: a #PinosDaemon
|
||||||
* @name: a node name
|
* @name: a port name
|
||||||
* @props: node properties
|
* @props: port properties
|
||||||
* @format_filter: a format filter
|
* @format_filter: a format filter
|
||||||
* @error: location for an error
|
* @error: location for an error
|
||||||
*
|
*
|
||||||
* Find the best node in @daemon that matches the given parameters.
|
* Find the best port in @daemon that matches the given parameters.
|
||||||
*
|
*
|
||||||
* Returns: a #PinosNode or %NULL when no node could be found.
|
* Returns: a #PinosPort or %NULL when no port could be found.
|
||||||
*/
|
*/
|
||||||
PinosNode *
|
PinosPort *
|
||||||
pinos_daemon_find_node (PinosDaemon *daemon,
|
pinos_daemon_find_port (PinosDaemon *daemon,
|
||||||
|
PinosDirection direction,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
PinosProperties *props,
|
PinosProperties *props,
|
||||||
GBytes *format_filter,
|
GBytes *format_filter,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
PinosDaemonPrivate *priv;
|
PinosDaemonPrivate *priv;
|
||||||
PinosNode *best = NULL;
|
PinosPort *best = NULL;
|
||||||
GList *walk;
|
GList *node, *port;
|
||||||
|
gboolean have_name;
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
|
||||||
priv = daemon->priv;
|
priv = daemon->priv;
|
||||||
|
|
||||||
for (walk = priv->nodes; walk; walk = g_list_next (walk)) {
|
have_name = name ? strlen (name) > 0 : FALSE;
|
||||||
PinosNode *n = walk->data;
|
|
||||||
|
|
||||||
if (name == NULL) {
|
for (node = priv->nodes; node; node = g_list_next (node)) {
|
||||||
best = n;
|
PinosNode *n = node->data;
|
||||||
break;
|
gboolean node_found = FALSE;
|
||||||
|
|
||||||
|
/* we found the node */
|
||||||
|
if (have_name && g_str_has_suffix (pinos_node_get_object_path (n), name)) {
|
||||||
|
g_debug ("name \"%s\" matches node %s", name, pinos_node_get_object_path (n));
|
||||||
|
node_found = TRUE;
|
||||||
}
|
}
|
||||||
else if (g_str_has_suffix (pinos_node_get_object_path (n), name))
|
|
||||||
best = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (port = pinos_node_get_ports (n); port; port = g_list_next (port)) {
|
||||||
|
PinosPort *p = port->data;
|
||||||
|
PinosDirection dir;
|
||||||
|
GBytes *format;
|
||||||
|
|
||||||
|
g_object_get (p, "direction", &dir, NULL);
|
||||||
|
if (dir != direction)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (have_name && !node_found) {
|
||||||
|
if (!g_str_has_suffix (pinos_port_get_object_path (p), name))
|
||||||
|
continue;
|
||||||
|
g_debug ("name \"%s\" matches port %s", name, pinos_port_get_object_path (p));
|
||||||
|
best = p;
|
||||||
|
node_found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
format = pinos_port_get_formats (p, format_filter, NULL);
|
||||||
|
if (format != NULL) {
|
||||||
|
g_debug ("port %s with format %s matches filter %s",
|
||||||
|
pinos_port_get_object_path (p),
|
||||||
|
(gchar*)g_bytes_get_data (format, NULL),
|
||||||
|
format_filter ? (gchar*)g_bytes_get_data (format_filter, NULL) : "ANY");
|
||||||
|
g_bytes_unref (format);
|
||||||
|
best = p;
|
||||||
|
node_found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (node_found)
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (best == NULL) {
|
if (best == NULL) {
|
||||||
if (error)
|
if (error)
|
||||||
*error = g_error_new (G_IO_ERROR,
|
*error = g_error_new (G_IO_ERROR,
|
||||||
G_IO_ERROR_NOT_FOUND,
|
G_IO_ERROR_NOT_FOUND,
|
||||||
"Node not found");
|
"No matching Port found");
|
||||||
}
|
}
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ typedef struct _PinosDaemonClass PinosDaemonClass;
|
||||||
typedef struct _PinosDaemonPrivate PinosDaemonPrivate;
|
typedef struct _PinosDaemonPrivate PinosDaemonPrivate;
|
||||||
|
|
||||||
#include <pinos/server/node.h>
|
#include <pinos/server/node.h>
|
||||||
|
#include <pinos/server/port.h>
|
||||||
#include <pinos/client/properties.h>
|
#include <pinos/client/properties.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -73,7 +74,9 @@ void pinos_daemon_unexport (PinosDaemon *daemon, const gch
|
||||||
|
|
||||||
void pinos_daemon_add_node (PinosDaemon *daemon, PinosNode *node);
|
void pinos_daemon_add_node (PinosDaemon *daemon, PinosNode *node);
|
||||||
void pinos_daemon_remove_node (PinosDaemon *daemon, PinosNode *node);
|
void pinos_daemon_remove_node (PinosDaemon *daemon, PinosNode *node);
|
||||||
PinosNode * pinos_daemon_find_node (PinosDaemon *daemon,
|
|
||||||
|
PinosPort * pinos_daemon_find_port (PinosDaemon *daemon,
|
||||||
|
PinosDirection direction,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
PinosProperties *props,
|
PinosProperties *props,
|
||||||
GBytes *format_filter,
|
GBytes *format_filter,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
#include "pinos/client/enumtypes.h"
|
#include "pinos/client/enumtypes.h"
|
||||||
|
|
||||||
#include "pinos/server/node.h"
|
#include "pinos/server/node.h"
|
||||||
#include "pinos/server/source.h"
|
|
||||||
#include "pinos/server/daemon.h"
|
#include "pinos/server/daemon.h"
|
||||||
|
|
||||||
#include "pinos/dbus/org-pinos.h"
|
#include "pinos/dbus/org-pinos.h"
|
||||||
|
|
@ -35,10 +34,18 @@
|
||||||
struct _PinosNodePrivate
|
struct _PinosNodePrivate
|
||||||
{
|
{
|
||||||
PinosDaemon *daemon;
|
PinosDaemon *daemon;
|
||||||
PinosObjectSkeleton *skeleton;
|
PinosNode1 *iface;
|
||||||
|
|
||||||
gchar *object_path;
|
gchar *object_path;
|
||||||
PinosSource *source;
|
gchar *name;
|
||||||
PinosSink *sink;
|
|
||||||
|
PinosNodeState state;
|
||||||
|
GError *error;
|
||||||
|
guint idle_timeout;
|
||||||
|
|
||||||
|
PinosProperties *properties;
|
||||||
|
|
||||||
|
GList *ports;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (PinosNode, pinos_node, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (PinosNode, pinos_node, G_TYPE_OBJECT);
|
||||||
|
|
@ -47,8 +54,10 @@ enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_DAEMON,
|
PROP_DAEMON,
|
||||||
PROP_SKELETON,
|
|
||||||
PROP_OBJECT_PATH,
|
PROP_OBJECT_PATH,
|
||||||
|
PROP_NAME,
|
||||||
|
PROP_STATE,
|
||||||
|
PROP_PROPERTIES,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -65,14 +74,22 @@ pinos_node_get_property (GObject *_object,
|
||||||
g_value_set_object (value, priv->daemon);
|
g_value_set_object (value, priv->daemon);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SKELETON:
|
|
||||||
g_value_set_object (value, priv->skeleton);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_OBJECT_PATH:
|
case PROP_OBJECT_PATH:
|
||||||
g_value_set_string (value, priv->object_path);
|
g_value_set_string (value, priv->object_path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_NAME:
|
||||||
|
g_value_set_string (value, priv->name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_STATE:
|
||||||
|
g_value_set_enum (value, priv->state);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_PROPERTIES:
|
||||||
|
g_value_set_boxed (value, priv->properties);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (node, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (node, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
@ -93,6 +110,19 @@ pinos_node_set_property (GObject *_object,
|
||||||
priv->daemon = g_value_dup_object (value);
|
priv->daemon = g_value_dup_object (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_NAME:
|
||||||
|
priv->name = g_value_dup_string (value);
|
||||||
|
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,
|
||||||
|
priv->properties ? pinos_properties_to_variant (priv->properties) : NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (node, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (node, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
@ -104,11 +134,20 @@ node_register_object (PinosNode *node)
|
||||||
{
|
{
|
||||||
PinosNodePrivate *priv = node->priv;
|
PinosNodePrivate *priv = node->priv;
|
||||||
PinosDaemon *daemon = priv->daemon;
|
PinosDaemon *daemon = priv->daemon;
|
||||||
|
PinosObjectSkeleton *skel;
|
||||||
|
|
||||||
priv->skeleton = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_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);
|
g_free (priv->object_path);
|
||||||
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (priv->skeleton));
|
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
|
||||||
|
g_object_unref (skel);
|
||||||
|
|
||||||
pinos_daemon_add_node (daemon, node);
|
pinos_daemon_add_node (daemon, node);
|
||||||
|
|
||||||
|
|
@ -122,7 +161,7 @@ node_unregister_object (PinosNode *node)
|
||||||
|
|
||||||
pinos_daemon_unexport (priv->daemon, priv->object_path);
|
pinos_daemon_unexport (priv->daemon, priv->object_path);
|
||||||
pinos_daemon_remove_node (priv->daemon, node);
|
pinos_daemon_remove_node (priv->daemon, node);
|
||||||
g_clear_object (&priv->skeleton);
|
g_clear_object (&priv->iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -187,6 +226,37 @@ pinos_node_class_init (PinosNodeClass * klass)
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READABLE |
|
G_PARAM_READABLE |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_NAME,
|
||||||
|
g_param_spec_string ("name",
|
||||||
|
"Name",
|
||||||
|
"The node name",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_STATE,
|
||||||
|
g_param_spec_enum ("state",
|
||||||
|
"State",
|
||||||
|
"The state of the node",
|
||||||
|
PINOS_TYPE_NODE_STATE,
|
||||||
|
PINOS_NODE_STATE_SUSPENDED,
|
||||||
|
G_PARAM_READABLE |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PROPERTIES,
|
||||||
|
g_param_spec_boxed ("properties",
|
||||||
|
"Properties",
|
||||||
|
"The properties of the node",
|
||||||
|
PINOS_TYPE_PROPERTIES,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -234,96 +304,210 @@ pinos_node_get_object_path (PinosNode *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_node_set_source:
|
* pinos_node_add_port:
|
||||||
* @node: a #PinosNode
|
* @node: a #PinosNode
|
||||||
* @source: a #PinosSource
|
* @port: a #PinosPort
|
||||||
*
|
*
|
||||||
* Set the #PinosSource of @node
|
* Add the #PinosPort to @node
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pinos_node_set_source (PinosNode *node, PinosSource *source, GObject *iface)
|
pinos_node_add_port (PinosNode *node, PinosPort *port)
|
||||||
{
|
{
|
||||||
PinosNodePrivate *priv;
|
PinosNodePrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (PINOS_IS_NODE (node));
|
g_return_if_fail (PINOS_IS_NODE (node));
|
||||||
g_return_if_fail (source == NULL || PINOS_IS_SOURCE (source));
|
g_return_if_fail (PINOS_IS_PORT (port));
|
||||||
g_return_if_fail (iface == NULL || PINOS_IS_SOURCE1 (iface));
|
|
||||||
priv = node->priv;
|
priv = node->priv;
|
||||||
|
|
||||||
if (source) {
|
priv->ports = g_list_append (priv->ports, port);
|
||||||
pinos_object_skeleton_set_source1 (priv->skeleton, PINOS_SOURCE1 (iface));
|
|
||||||
priv->source = source;
|
|
||||||
} else {
|
|
||||||
pinos_object_skeleton_set_source1 (priv->skeleton, NULL);
|
|
||||||
priv->source = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_node_get_source:
|
* pinos_node_remove_port:
|
||||||
|
* @node: a #PinosNode
|
||||||
|
* @port: a #PinosPort
|
||||||
|
*
|
||||||
|
* Remove the #PinosPort from @node
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pinos_node_remove_port (PinosNode *node, PinosPort *port)
|
||||||
|
{
|
||||||
|
PinosNodePrivate *priv;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_node_get_ports:
|
||||||
* @node: a #PinosNode
|
* @node: a #PinosNode
|
||||||
*
|
*
|
||||||
* Get the #PinosSource of @node
|
* Get the list of ports in @node.
|
||||||
*
|
*
|
||||||
* Returns: the #PinosSource of @node or %NULL
|
* Returns: a #GList of nodes owned by @node.
|
||||||
*/
|
*/
|
||||||
PinosSource *
|
GList *
|
||||||
pinos_node_get_source (PinosNode *node)
|
pinos_node_get_ports (PinosNode *node)
|
||||||
{
|
{
|
||||||
PinosNodePrivate *priv;
|
PinosNodePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_NODE (node), NULL);
|
g_return_val_if_fail (PINOS_IS_NODE (node), NULL);
|
||||||
priv = node->priv;
|
priv = node->priv;
|
||||||
|
|
||||||
return priv->source;
|
return priv->ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
/**
|
remove_idle_timeout (PinosNode *node)
|
||||||
* pinos_node_set_sink:
|
|
||||||
* @node: a #PinosNode
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
*
|
|
||||||
* Set the #PinosSink of @node
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
pinos_node_set_sink (PinosNode *node, PinosSink *sink, GObject *iface)
|
|
||||||
{
|
{
|
||||||
PinosNodePrivate *priv;
|
PinosNodePrivate *priv = node->priv;
|
||||||
|
|
||||||
g_return_if_fail (PINOS_IS_NODE (node));
|
if (priv->idle_timeout) {
|
||||||
g_return_if_fail (sink == NULL || PINOS_IS_SINK (sink));
|
g_source_remove (priv->idle_timeout);
|
||||||
g_return_if_fail (iface == NULL || PINOS_IS_SINK1 (iface));
|
priv->idle_timeout = 0;
|
||||||
priv = node->priv;
|
|
||||||
|
|
||||||
if (sink) {
|
|
||||||
pinos_object_skeleton_set_sink1 (priv->skeleton, PINOS_SINK1 (iface));
|
|
||||||
priv->sink = sink;
|
|
||||||
} else {
|
|
||||||
pinos_object_skeleton_set_sink1 (priv->skeleton, NULL);
|
|
||||||
priv->sink = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_node_get_sink:
|
* pinos_node_set_state:
|
||||||
* @node: a #PinosNode
|
* @node: a #PinosNode
|
||||||
|
* @state: a #PinosNodeState
|
||||||
*
|
*
|
||||||
* Get the #PinosSink of @node
|
* Set the state of @node to @state.
|
||||||
*
|
*
|
||||||
* Returns: the #PinosSink of @node or %NULL
|
* Returns: %TRUE on success.
|
||||||
*/
|
*/
|
||||||
PinosSink *
|
gboolean
|
||||||
pinos_node_get_sink (PinosNode *node)
|
pinos_node_set_state (PinosNode *node,
|
||||||
|
PinosNodeState state)
|
||||||
|
{
|
||||||
|
PinosNodeClass *klass;
|
||||||
|
gboolean res;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PINOS_IS_NODE (node), FALSE);
|
||||||
|
|
||||||
|
klass = PINOS_NODE_GET_CLASS (node);
|
||||||
|
|
||||||
|
remove_idle_timeout (node);
|
||||||
|
|
||||||
|
if (klass->set_state)
|
||||||
|
res = klass->set_state (node, state);
|
||||||
|
else
|
||||||
|
res = FALSE;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_node_update_state:
|
||||||
|
* @node: a #PinosNode
|
||||||
|
* @state: a #PinosNodeState
|
||||||
|
*
|
||||||
|
* Update the state of a node. This method is used from
|
||||||
|
* inside @node itself.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pinos_node_update_state (PinosNode *node,
|
||||||
|
PinosNodeState state)
|
||||||
{
|
{
|
||||||
PinosNodePrivate *priv;
|
PinosNodePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_NODE (node), NULL);
|
g_return_if_fail (PINOS_IS_NODE (node));
|
||||||
priv = node->priv;
|
priv = node->priv;
|
||||||
|
|
||||||
return priv->sink;
|
if (priv->state != state) {
|
||||||
|
priv->state = state;
|
||||||
|
pinos_node1_set_state (priv->iface, state);
|
||||||
|
g_object_notify (G_OBJECT (node), "state");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_node_report_error:
|
||||||
|
* @node: a #PinosNode
|
||||||
|
* @error: a #GError
|
||||||
|
*
|
||||||
|
* Report an error from within @node.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pinos_node_report_error (PinosNode *node,
|
||||||
|
GError *error)
|
||||||
|
{
|
||||||
|
PinosNodePrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (PINOS_IS_NODE (node));
|
||||||
|
priv = node->priv;
|
||||||
|
|
||||||
|
g_clear_error (&priv->error);
|
||||||
|
remove_idle_timeout (node);
|
||||||
|
priv->error = error;
|
||||||
|
priv->state = PINOS_NODE_STATE_ERROR;
|
||||||
|
g_debug ("got error state %s", error->message);
|
||||||
|
pinos_node1_set_state (priv->iface, priv->state);
|
||||||
|
g_object_notify (G_OBJECT (node), "state");
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
idle_timeout (PinosNode *node)
|
||||||
|
{
|
||||||
|
PinosNodePrivate *priv = node->priv;
|
||||||
|
|
||||||
|
priv->idle_timeout = 0;
|
||||||
|
pinos_node_set_state (node, PINOS_NODE_STATE_SUSPENDED);
|
||||||
|
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_node_report_idle:
|
||||||
|
* @node: a #PinosNode
|
||||||
|
*
|
||||||
|
* Mark @node as being idle. This will start a timeout that will
|
||||||
|
* set the node to SUSPENDED.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pinos_node_report_idle (PinosNode *node)
|
||||||
|
{
|
||||||
|
PinosNodePrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (PINOS_IS_NODE (node));
|
||||||
|
priv = node->priv;
|
||||||
|
|
||||||
|
pinos_node_set_state (node, PINOS_NODE_STATE_IDLE);
|
||||||
|
|
||||||
|
priv->idle_timeout = g_timeout_add_seconds (3,
|
||||||
|
(GSourceFunc) idle_timeout,
|
||||||
|
node);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_node_report_busy:
|
||||||
|
* @node: a #PinosNode
|
||||||
|
*
|
||||||
|
* Mark @node as being busy. This will set the state of the node
|
||||||
|
* to the RUNNING state.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pinos_node_report_busy (PinosNode *node)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PINOS_IS_NODE (node));
|
||||||
|
|
||||||
|
pinos_node_set_state (node, PINOS_NODE_STATE_RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_node_new:
|
||||||
|
* @daemon: a #PinosDaemon
|
||||||
|
*
|
||||||
|
* Make a new node
|
||||||
|
*
|
||||||
|
* Returns: a new #PinosNode
|
||||||
|
*/
|
||||||
PinosNode *
|
PinosNode *
|
||||||
pinos_node_new (PinosDaemon *daemon)
|
pinos_node_new (PinosDaemon *daemon)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ typedef struct _PinosNodePrivate PinosNodePrivate;
|
||||||
|
|
||||||
#include <pinos/client/introspect.h>
|
#include <pinos/client/introspect.h>
|
||||||
#include <pinos/server/daemon.h>
|
#include <pinos/server/daemon.h>
|
||||||
#include <pinos/server/source.h>
|
#include <pinos/server/node.h>
|
||||||
#include <pinos/server/sink.h>
|
#include <pinos/server/port.h>
|
||||||
|
|
||||||
#define PINOS_TYPE_NODE (pinos_node_get_type ())
|
#define PINOS_TYPE_NODE (pinos_node_get_type ())
|
||||||
#define PINOS_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_NODE))
|
#define PINOS_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_NODE))
|
||||||
|
|
@ -55,11 +55,15 @@ struct _PinosNode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PinosNodeClass:
|
* PinosNodeClass:
|
||||||
|
* @set_state: called to change the current state of the node
|
||||||
*
|
*
|
||||||
* Pinos node class.
|
* Pinos node class.
|
||||||
*/
|
*/
|
||||||
struct _PinosNodeClass {
|
struct _PinosNodeClass {
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
gboolean (*set_state) (PinosNode *node, PinosNodeState state);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* normal GObject stuff */
|
/* normal GObject stuff */
|
||||||
|
|
@ -70,15 +74,18 @@ PinosNode * pinos_node_new (PinosDaemon *daemon);
|
||||||
PinosDaemon * pinos_node_get_daemon (PinosNode *node);
|
PinosDaemon * pinos_node_get_daemon (PinosNode *node);
|
||||||
const gchar * pinos_node_get_object_path (PinosNode *node);
|
const gchar * pinos_node_get_object_path (PinosNode *node);
|
||||||
|
|
||||||
void pinos_node_set_source (PinosNode *node,
|
void pinos_node_add_port (PinosNode *node,
|
||||||
PinosSource *source,
|
PinosPort *port);
|
||||||
GObject *iface);
|
void pinos_node_remove_port (PinosNode *node,
|
||||||
PinosSource * pinos_node_get_source (PinosNode *node);
|
PinosPort *port);
|
||||||
|
GList * pinos_node_get_ports (PinosNode *node);
|
||||||
|
|
||||||
void pinos_node_set_sink (PinosNode *node,
|
gboolean pinos_node_set_state (PinosNode *node, PinosNodeState state);
|
||||||
PinosSink *sink,
|
void pinos_node_update_state (PinosNode *node, PinosNodeState state);
|
||||||
GObject *iface);
|
|
||||||
PinosSink * pinos_node_get_sink (PinosNode *node);
|
void pinos_node_report_error (PinosNode *node, GError *error);
|
||||||
|
void pinos_node_report_idle (PinosNode *node);
|
||||||
|
void pinos_node_report_busy (PinosNode *node);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
||||||
666
pinos/server/port.c
Normal file
666
pinos/server/port.c
Normal file
|
|
@ -0,0 +1,666 @@
|
||||||
|
/* Pinos
|
||||||
|
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "pinos/client/pinos.h"
|
||||||
|
#include "pinos/client/enumtypes.h"
|
||||||
|
|
||||||
|
#include "pinos/server/port.h"
|
||||||
|
#include "pinos/server/node.h"
|
||||||
|
|
||||||
|
#include "pinos/dbus/org-pinos.h"
|
||||||
|
|
||||||
|
#define PINOS_PORT_GET_PRIVATE(obj) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_PORT, PinosPortPrivate))
|
||||||
|
|
||||||
|
struct _PinosPortPrivate
|
||||||
|
{
|
||||||
|
PinosNode *node;
|
||||||
|
PinosPort1 *iface;
|
||||||
|
gchar *object_path;
|
||||||
|
|
||||||
|
gchar *name;
|
||||||
|
PinosDirection direction;
|
||||||
|
GBytes *possible_formats;
|
||||||
|
PinosProperties *properties;
|
||||||
|
|
||||||
|
GList *channels;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (PinosPort, pinos_port, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_NODE,
|
||||||
|
PROP_OBJECT_PATH,
|
||||||
|
PROP_NAME,
|
||||||
|
PROP_DIRECTION,
|
||||||
|
PROP_POSSIBLE_FORMATS,
|
||||||
|
PROP_PROPERTIES
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SIGNAL_FORMAT_REQUEST,
|
||||||
|
SIGNAL_CHANNEL_ADDED,
|
||||||
|
SIGNAL_CHANNEL_REMOVED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
|
static void
|
||||||
|
pinos_port_get_property (GObject *_object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
PinosPort *port = PINOS_PORT (_object);
|
||||||
|
PinosPortPrivate *priv = port->priv;
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_NODE:
|
||||||
|
g_value_set_object (value, priv->node);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_NAME:
|
||||||
|
g_value_set_string (value, priv->name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_OBJECT_PATH:
|
||||||
|
g_value_set_string (value, priv->object_path);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_DIRECTION:
|
||||||
|
g_value_set_enum (value, priv->direction);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_POSSIBLE_FORMATS:
|
||||||
|
g_value_set_boxed (value, priv->possible_formats);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_PROPERTIES:
|
||||||
|
g_value_set_boxed (value, priv->properties);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (port, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
PinosPort *port = PINOS_PORT (_object);
|
||||||
|
PinosPortPrivate *priv = port->priv;
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_NODE:
|
||||||
|
priv->node = g_value_dup_object (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_NAME:
|
||||||
|
priv->name = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_DIRECTION:
|
||||||
|
priv->direction = g_value_get_enum (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_POSSIBLE_FORMATS:
|
||||||
|
set_possible_formats (port, g_value_get_boxed (value));
|
||||||
|
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);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (port, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
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),
|
||||||
|
G_DBUS_OBJECT_SKELETON (skel));
|
||||||
|
|
||||||
|
g_object_unref (skel);
|
||||||
|
|
||||||
|
pinos_node_add_port (priv->node, port);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
port_unregister_object (PinosPort *port)
|
||||||
|
{
|
||||||
|
PinosPortPrivate *priv = port->priv;
|
||||||
|
|
||||||
|
pinos_node_remove_port (priv->node, port);
|
||||||
|
g_clear_object (&priv->iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pinos_port_constructed (GObject * object)
|
||||||
|
{
|
||||||
|
PinosPort *port = PINOS_PORT (object);
|
||||||
|
|
||||||
|
port_register_object (port);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
g_list_foreach (priv->channels, (GFunc) do_remove_channel, port);
|
||||||
|
port_unregister_object (port);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (pinos_port_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pinos_port_finalize (GObject * object)
|
||||||
|
{
|
||||||
|
PinosPort *port = PINOS_PORT (object);
|
||||||
|
PinosPortPrivate *priv = port->priv;
|
||||||
|
|
||||||
|
g_free (priv->name);
|
||||||
|
if (priv->possible_formats)
|
||||||
|
g_bytes_unref (priv->possible_formats);
|
||||||
|
if (priv->properties)
|
||||||
|
pinos_properties_free (priv->properties);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (pinos_port_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_remove_channel (PinosChannel *channel,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
PinosPort *port = user_data;
|
||||||
|
|
||||||
|
pinos_port_release_channel (port, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PinosChannel *
|
||||||
|
default_create_channel (PinosPort *port,
|
||||||
|
const gchar *client_path,
|
||||||
|
GBytes *format_filter,
|
||||||
|
PinosProperties *props,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
PinosPortPrivate *priv = port->priv;
|
||||||
|
PinosChannel *channel;
|
||||||
|
GBytes *possible_formats;
|
||||||
|
|
||||||
|
possible_formats = pinos_port_get_formats (port, format_filter, error);
|
||||||
|
if (possible_formats == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
channel = g_object_new (PINOS_TYPE_CHANNEL, "daemon", pinos_node_get_daemon (priv->node),
|
||||||
|
"client-path", client_path,
|
||||||
|
"direction", priv->direction,
|
||||||
|
"port-path", pinos_port_get_object_path (port),
|
||||||
|
"possible-formats", possible_formats,
|
||||||
|
"properties", props,
|
||||||
|
NULL);
|
||||||
|
g_bytes_unref (possible_formats);
|
||||||
|
|
||||||
|
if (channel == NULL)
|
||||||
|
goto no_channel;
|
||||||
|
|
||||||
|
g_signal_connect (channel,
|
||||||
|
"remove",
|
||||||
|
(GCallback) handle_remove_channel,
|
||||||
|
port);
|
||||||
|
|
||||||
|
priv->channels = g_list_prepend (priv->channels, channel);
|
||||||
|
|
||||||
|
return g_object_ref (channel);
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
no_channel:
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
*error = g_error_new (G_IO_ERROR,
|
||||||
|
G_IO_ERROR_FAILED,
|
||||||
|
"Could not create channel");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
default_release_channel (PinosPort *port,
|
||||||
|
PinosChannel *channel)
|
||||||
|
{
|
||||||
|
PinosPortPrivate *priv = port->priv;
|
||||||
|
GList *find;
|
||||||
|
|
||||||
|
find = g_list_find (priv->channels, channel);
|
||||||
|
if (find == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
priv->channels = g_list_delete_link (priv->channels, find);
|
||||||
|
g_object_unref (channel);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pinos_port_class_init (PinosPortClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (PinosPortPrivate));
|
||||||
|
|
||||||
|
gobject_class->constructed = pinos_port_constructed;
|
||||||
|
gobject_class->dispose = pinos_port_dispose;
|
||||||
|
gobject_class->finalize = pinos_port_finalize;
|
||||||
|
gobject_class->set_property = pinos_port_set_property;
|
||||||
|
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,
|
||||||
|
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,
|
||||||
|
G_PARAM_READABLE |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_NAME,
|
||||||
|
g_param_spec_string ("name",
|
||||||
|
"Name",
|
||||||
|
"The port name",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_DIRECTION,
|
||||||
|
g_param_spec_enum ("direction",
|
||||||
|
"Direction",
|
||||||
|
"The direction of the port",
|
||||||
|
PINOS_TYPE_DIRECTION,
|
||||||
|
PINOS_DIRECTION_INVALID,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_POSSIBLE_FORMATS,
|
||||||
|
g_param_spec_boxed ("possible-formats",
|
||||||
|
"Possible Formats",
|
||||||
|
"The possbile formats of the port",
|
||||||
|
G_TYPE_BYTES,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PROPERTIES,
|
||||||
|
g_param_spec_boxed ("properties",
|
||||||
|
"Properties",
|
||||||
|
"The properties of the port",
|
||||||
|
PINOS_TYPE_PROPERTIES,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
|
||||||
|
signals[SIGNAL_FORMAT_REQUEST] = g_signal_new ("format-request",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
g_cclosure_marshal_generic,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
0,
|
||||||
|
G_TYPE_NONE);
|
||||||
|
signals[SIGNAL_CHANNEL_ADDED] = g_signal_new ("channel-added",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
g_cclosure_marshal_generic,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
1,
|
||||||
|
PINOS_TYPE_CHANNEL);
|
||||||
|
signals[SIGNAL_CHANNEL_REMOVED] = g_signal_new ("channel-removed",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
g_cclosure_marshal_generic,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
1,
|
||||||
|
PINOS_TYPE_CHANNEL);
|
||||||
|
|
||||||
|
|
||||||
|
klass->create_channel = default_create_channel;
|
||||||
|
klass->release_channel = default_release_channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pinos_port_init (PinosPort * port)
|
||||||
|
{
|
||||||
|
PinosPortPrivate *priv = port->priv = PINOS_PORT_GET_PRIVATE (port);
|
||||||
|
|
||||||
|
priv->direction = PINOS_DIRECTION_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_port_new:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Returns: a new #PinosPort
|
||||||
|
*/
|
||||||
|
PinosPort *
|
||||||
|
pinos_port_new (PinosNode *node,
|
||||||
|
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 (name != NULL, NULL);
|
||||||
|
|
||||||
|
return g_object_new (PINOS_TYPE_PORT,
|
||||||
|
"node", node,
|
||||||
|
"direction", direction,
|
||||||
|
"name", name,
|
||||||
|
"possible-formats", possible_formats,
|
||||||
|
"properties", props,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
pinos_port_get_object_path (PinosPort *port)
|
||||||
|
{
|
||||||
|
PinosPortPrivate *priv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PINOS_IS_PORT (port), NULL);
|
||||||
|
priv = port->priv;
|
||||||
|
|
||||||
|
return priv->object_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_port_get_formats:
|
||||||
|
* @port: a #PinosPort
|
||||||
|
* @filter: a #GBytes
|
||||||
|
* @error: a #GError or %NULL
|
||||||
|
*
|
||||||
|
* Get all the currently supported formats for @port and filter the
|
||||||
|
* results with @filter.
|
||||||
|
*
|
||||||
|
* Returns: the list of supported format. If %NULL is returned, @error will
|
||||||
|
* be set.
|
||||||
|
*/
|
||||||
|
GBytes *
|
||||||
|
pinos_port_get_formats (PinosPort *port,
|
||||||
|
GBytes *filter,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GstCaps *tmp, *caps, *cfilter;
|
||||||
|
gchar *str;
|
||||||
|
PinosPortPrivate *priv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PINOS_IS_PORT (port), NULL);
|
||||||
|
priv = port->priv;
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
cfilter = gst_caps_from_string (g_bytes_get_data (filter, NULL));
|
||||||
|
if (cfilter == NULL)
|
||||||
|
goto invalid_filter;
|
||||||
|
} else {
|
||||||
|
cfilter = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_signal_emit (port, signals[SIGNAL_FORMAT_REQUEST], 0, NULL);
|
||||||
|
|
||||||
|
if (priv->possible_formats)
|
||||||
|
caps = gst_caps_from_string (g_bytes_get_data (priv->possible_formats, NULL));
|
||||||
|
else
|
||||||
|
caps = gst_caps_new_any ();
|
||||||
|
|
||||||
|
if (caps && cfilter) {
|
||||||
|
tmp = gst_caps_intersect_full (caps, cfilter, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
g_clear_pointer (&cfilter, gst_caps_unref);
|
||||||
|
gst_caps_take (&caps, tmp);
|
||||||
|
}
|
||||||
|
if (caps == NULL || gst_caps_is_empty (caps))
|
||||||
|
goto no_format;
|
||||||
|
|
||||||
|
str = gst_caps_to_string (caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
|
return g_bytes_new_take (str, strlen (str) + 1);
|
||||||
|
|
||||||
|
invalid_filter:
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
*error = g_error_new (G_IO_ERROR,
|
||||||
|
G_IO_ERROR_INVALID_ARGUMENT,
|
||||||
|
"Invalid filter received");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
no_format:
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
*error = g_error_new (G_IO_ERROR,
|
||||||
|
G_IO_ERROR_NOT_FOUND,
|
||||||
|
"No compatible format found");
|
||||||
|
if (cfilter)
|
||||||
|
gst_caps_unref (cfilter);
|
||||||
|
if (caps)
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_port_get_channels:
|
||||||
|
* @port: a #PinosPort
|
||||||
|
*
|
||||||
|
* Get all the channels in @port.
|
||||||
|
*
|
||||||
|
* Returns: a #GList of #PinosChannel objects.
|
||||||
|
*/
|
||||||
|
GList *
|
||||||
|
pinos_port_get_channels (PinosPort *port)
|
||||||
|
{
|
||||||
|
PinosPortPrivate *priv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PINOS_IS_PORT (port), NULL);
|
||||||
|
priv = port->priv;
|
||||||
|
|
||||||
|
return priv->channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_port_create_channel:
|
||||||
|
* @port: a #PinosPort
|
||||||
|
* @client_path: the client path
|
||||||
|
* @format_filter: a #GBytes
|
||||||
|
* @props: #PinosProperties
|
||||||
|
* @prefix: a prefix
|
||||||
|
* @error: a #GError or %NULL
|
||||||
|
*
|
||||||
|
* Create a new #PinosChannel for @port.
|
||||||
|
*
|
||||||
|
* Returns: a new #PinosChannel or %NULL, in wich case @error will contain
|
||||||
|
* more information about the error.
|
||||||
|
*/
|
||||||
|
PinosChannel *
|
||||||
|
pinos_port_create_channel (PinosPort *port,
|
||||||
|
const gchar *client_path,
|
||||||
|
GBytes *format_filter,
|
||||||
|
PinosProperties *props,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
PinosPortClass *klass;
|
||||||
|
PinosChannel *channel;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PINOS_IS_PORT (port), NULL);
|
||||||
|
|
||||||
|
klass = PINOS_PORT_GET_CLASS (port);
|
||||||
|
|
||||||
|
if (klass->create_channel) {
|
||||||
|
channel = klass->create_channel (port, client_path, format_filter, props, error);
|
||||||
|
if (channel)
|
||||||
|
g_signal_emit (port, signals[SIGNAL_CHANNEL_ADDED], 0, channel);
|
||||||
|
} else {
|
||||||
|
if (error) {
|
||||||
|
*error = g_error_new (G_IO_ERROR,
|
||||||
|
G_IO_ERROR_NOT_SUPPORTED,
|
||||||
|
"CreateChannel not implemented");
|
||||||
|
}
|
||||||
|
channel = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pinos_port_release_channel:
|
||||||
|
* @port: a #PinosPort
|
||||||
|
* @channel: a #PinosChannel
|
||||||
|
*
|
||||||
|
* Release the @channel in @port.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE on success.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
pinos_port_release_channel (PinosPort *port,
|
||||||
|
PinosChannel *channel)
|
||||||
|
{
|
||||||
|
PinosPortClass *klass;
|
||||||
|
gboolean res;
|
||||||
|
|
||||||
|
g_return_val_if_fail (PINOS_IS_PORT (port), FALSE);
|
||||||
|
g_return_val_if_fail (PINOS_IS_CHANNEL (channel), FALSE);
|
||||||
|
|
||||||
|
klass = PINOS_PORT_GET_CLASS (port);
|
||||||
|
|
||||||
|
if (klass->release_channel) {
|
||||||
|
g_signal_emit (port, signals[SIGNAL_CHANNEL_REMOVED], 0, channel);
|
||||||
|
res = klass->release_channel (port, channel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
res = FALSE;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
101
pinos/server/port.h
Normal file
101
pinos/server/port.h
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
/* Pinos
|
||||||
|
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PINOS_PORT_H__
|
||||||
|
#define __PINOS_PORT_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct _PinosPort PinosPort;
|
||||||
|
typedef struct _PinosPortClass PinosPortClass;
|
||||||
|
typedef struct _PinosPortPrivate PinosPortPrivate;
|
||||||
|
|
||||||
|
#include <pinos/client/introspect.h>
|
||||||
|
#include <pinos/server/node.h>
|
||||||
|
#include <pinos/server/channel.h>
|
||||||
|
|
||||||
|
#define PINOS_TYPE_PORT (pinos_port_get_type ())
|
||||||
|
#define PINOS_IS_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_PORT))
|
||||||
|
#define PINOS_IS_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_PORT))
|
||||||
|
#define PINOS_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_PORT, PinosPortClass))
|
||||||
|
#define PINOS_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_PORT, PinosPort))
|
||||||
|
#define PINOS_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_PORT, PinosPortClass))
|
||||||
|
#define PINOS_PORT_CAST(obj) ((PinosPort*)(obj))
|
||||||
|
#define PINOS_PORT_CLASS_CAST(klass) ((PinosPortClass*)(klass))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PinosPort:
|
||||||
|
*
|
||||||
|
* Pinos port object class.
|
||||||
|
*/
|
||||||
|
struct _PinosPort {
|
||||||
|
GObject object;
|
||||||
|
|
||||||
|
PinosPortPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PinosPortClass:
|
||||||
|
* @get_formats: called to get a list of supported formats from the port
|
||||||
|
* @create_channel: called to create a new channel object
|
||||||
|
* @release_channel: called to release a channel object
|
||||||
|
*
|
||||||
|
* Pinos port object class.
|
||||||
|
*/
|
||||||
|
struct _PinosPortClass {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
PinosChannel * (*create_channel) (PinosPort *port,
|
||||||
|
const gchar *client_path,
|
||||||
|
GBytes *format_filter,
|
||||||
|
PinosProperties *props,
|
||||||
|
GError **error);
|
||||||
|
gboolean (*release_channel) (PinosPort *port,
|
||||||
|
PinosChannel *channel);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* normal GObject stuff */
|
||||||
|
GType pinos_port_get_type (void);
|
||||||
|
|
||||||
|
PinosPort * pinos_port_new (PinosNode *node,
|
||||||
|
PinosDirection direction,
|
||||||
|
const gchar *name,
|
||||||
|
GBytes *possible_formats,
|
||||||
|
PinosProperties *props);
|
||||||
|
|
||||||
|
const gchar * pinos_port_get_object_path (PinosPort *port);
|
||||||
|
|
||||||
|
GBytes * pinos_port_get_formats (PinosPort *port,
|
||||||
|
GBytes *filter,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
PinosChannel * pinos_port_create_channel (PinosPort *port,
|
||||||
|
const gchar *client_path,
|
||||||
|
GBytes *format_filter,
|
||||||
|
PinosProperties *props,
|
||||||
|
GError **error);
|
||||||
|
gboolean pinos_port_release_channel (PinosPort *port,
|
||||||
|
PinosChannel *channel);
|
||||||
|
GList * pinos_port_get_channels (PinosPort *port);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __PINOS_PORT_H__ */
|
||||||
|
|
@ -1,646 +0,0 @@
|
||||||
/* Pinos
|
|
||||||
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gio/gio.h>
|
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
|
||||||
#include "pinos/client/enumtypes.h"
|
|
||||||
|
|
||||||
#include "pinos/server/sink.h"
|
|
||||||
#include "pinos/server/node.h"
|
|
||||||
|
|
||||||
#include "pinos/dbus/org-pinos.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define PINOS_SINK_GET_PRIVATE(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SINK, PinosSinkPrivate))
|
|
||||||
|
|
||||||
struct _PinosSinkPrivate
|
|
||||||
{
|
|
||||||
PinosNode *node;
|
|
||||||
PinosSink1 *iface;
|
|
||||||
|
|
||||||
gchar *name;
|
|
||||||
PinosProperties *properties;
|
|
||||||
|
|
||||||
PinosSinkState state;
|
|
||||||
GError *error;
|
|
||||||
guint idle_timeout;
|
|
||||||
|
|
||||||
GList *channels;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE (PinosSink, pinos_sink, G_TYPE_OBJECT);
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PROP_0,
|
|
||||||
PROP_NODE,
|
|
||||||
PROP_NAME,
|
|
||||||
PROP_STATE,
|
|
||||||
PROP_PROPERTIES
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
pinos_sink_get_property (GObject *_object,
|
|
||||||
guint prop_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
PinosSink *sink = PINOS_SINK (_object);
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_NODE:
|
|
||||||
g_value_set_object (value, priv->node);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_NAME:
|
|
||||||
g_value_set_string (value, priv->name);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_STATE:
|
|
||||||
g_value_set_enum (value, priv->state);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_PROPERTIES:
|
|
||||||
g_value_set_boxed (value, priv->properties);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (sink, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pinos_sink_set_property (GObject *_object,
|
|
||||||
guint prop_id,
|
|
||||||
const GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
PinosSink *sink = PINOS_SINK (_object);
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_NODE:
|
|
||||||
priv->node = g_value_dup_object (value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_NAME:
|
|
||||||
g_free (priv->name);
|
|
||||||
priv->name = g_value_dup_string (value);
|
|
||||||
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);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (sink, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
sink_register_object (PinosSink *sink)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
GBytes *formats;
|
|
||||||
GVariant *variant;
|
|
||||||
|
|
||||||
formats = pinos_sink_get_formats (sink, NULL, NULL);
|
|
||||||
|
|
||||||
if (priv->properties)
|
|
||||||
variant = pinos_properties_to_variant (priv->properties);
|
|
||||||
else
|
|
||||||
variant = NULL;
|
|
||||||
|
|
||||||
priv->iface = pinos_sink1_skeleton_new ();
|
|
||||||
g_object_set (priv->iface, "name", priv->name,
|
|
||||||
"state", priv->state,
|
|
||||||
"properties", variant,
|
|
||||||
"possible-formats", g_bytes_get_data (formats, NULL),
|
|
||||||
NULL);
|
|
||||||
g_bytes_unref (formats);
|
|
||||||
|
|
||||||
pinos_node_set_sink (priv->node, sink, G_OBJECT (priv->iface));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
sink_unregister_object (PinosSink *sink)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
|
|
||||||
pinos_node_set_sink (priv->node, NULL, NULL);
|
|
||||||
g_clear_object (&priv->iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pinos_sink_constructed (GObject * object)
|
|
||||||
{
|
|
||||||
PinosSink *sink = PINOS_SINK (object);
|
|
||||||
|
|
||||||
sink_register_object (sink);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_sink_parent_class)->constructed (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
do_remove_channel (PinosChannel *channel,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
pinos_channel_remove (channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pinos_sink_dispose (GObject * object)
|
|
||||||
{
|
|
||||||
PinosSink *sink = PINOS_SINK (object);
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
|
|
||||||
g_list_foreach (priv->channels, (GFunc) do_remove_channel, sink);
|
|
||||||
sink_unregister_object (sink);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_sink_parent_class)->dispose (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pinos_sink_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
PinosSink *sink = PINOS_SINK (object);
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
|
|
||||||
g_free (priv->name);
|
|
||||||
if (priv->properties)
|
|
||||||
pinos_properties_free (priv->properties);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_sink_parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
default_set_state (PinosSink *sink,
|
|
||||||
PinosSinkState state)
|
|
||||||
{
|
|
||||||
pinos_sink_update_state (sink, state);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
handle_remove_channel (PinosChannel *channel,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
PinosSink *sink = user_data;
|
|
||||||
|
|
||||||
pinos_sink_release_channel (sink, channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PinosChannel *
|
|
||||||
default_create_channel (PinosSink *sink,
|
|
||||||
const gchar *client_path,
|
|
||||||
GBytes *format_filter,
|
|
||||||
PinosProperties *props,
|
|
||||||
const gchar *prefix,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
PinosChannel *channel;
|
|
||||||
GBytes *possible_formats;
|
|
||||||
|
|
||||||
possible_formats = pinos_sink_get_formats (sink, format_filter, error);
|
|
||||||
if (possible_formats == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
channel = g_object_new (PINOS_TYPE_CHANNEL, "daemon", pinos_node_get_daemon (priv->node),
|
|
||||||
"object-path", prefix,
|
|
||||||
"client-path", client_path,
|
|
||||||
"owner-path", pinos_node_get_object_path (priv->node),
|
|
||||||
"possible-formats", possible_formats,
|
|
||||||
"properties", props,
|
|
||||||
NULL);
|
|
||||||
g_bytes_unref (possible_formats);
|
|
||||||
|
|
||||||
if (channel == NULL)
|
|
||||||
goto no_channel;
|
|
||||||
|
|
||||||
g_signal_connect (channel,
|
|
||||||
"remove",
|
|
||||||
(GCallback) handle_remove_channel,
|
|
||||||
sink);
|
|
||||||
|
|
||||||
priv->channels = g_list_prepend (priv->channels, channel);
|
|
||||||
|
|
||||||
return g_object_ref (channel);
|
|
||||||
|
|
||||||
/* ERRORS */
|
|
||||||
no_channel:
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_FAILED,
|
|
||||||
"Could not create channel");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
default_release_channel (PinosSink *sink,
|
|
||||||
PinosChannel *channel)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
GList *find;
|
|
||||||
|
|
||||||
find = g_list_find (priv->channels, channel);
|
|
||||||
if (find == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
priv->channels = g_list_delete_link (priv->channels, find);
|
|
||||||
g_object_unref (channel);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pinos_sink_class_init (PinosSinkClass * klass)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (PinosSinkPrivate));
|
|
||||||
|
|
||||||
gobject_class->constructed = pinos_sink_constructed;
|
|
||||||
gobject_class->dispose = pinos_sink_dispose;
|
|
||||||
gobject_class->finalize = pinos_sink_finalize;
|
|
||||||
gobject_class->set_property = pinos_sink_set_property;
|
|
||||||
gobject_class->get_property = pinos_sink_get_property;
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
|
||||||
PROP_NODE,
|
|
||||||
g_param_spec_object ("node",
|
|
||||||
"Node",
|
|
||||||
"The Node",
|
|
||||||
PINOS_TYPE_NODE,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
|
||||||
PROP_NAME,
|
|
||||||
g_param_spec_string ("name",
|
|
||||||
"Name",
|
|
||||||
"The sink name",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT_ONLY |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
|
||||||
PROP_STATE,
|
|
||||||
g_param_spec_enum ("state",
|
|
||||||
"State",
|
|
||||||
"The state of the sink",
|
|
||||||
PINOS_TYPE_SINK_STATE,
|
|
||||||
PINOS_SINK_STATE_SUSPENDED,
|
|
||||||
G_PARAM_READABLE |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
|
||||||
PROP_PROPERTIES,
|
|
||||||
g_param_spec_boxed ("properties",
|
|
||||||
"Properties",
|
|
||||||
"The properties of the sink",
|
|
||||||
PINOS_TYPE_PROPERTIES,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
|
|
||||||
klass->set_state = default_set_state;
|
|
||||||
klass->create_channel = default_create_channel;
|
|
||||||
klass->release_channel = default_release_channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
pinos_sink_init (PinosSink * sink)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv = sink->priv = PINOS_SINK_GET_PRIVATE (sink);
|
|
||||||
|
|
||||||
priv->state = PINOS_SINK_STATE_SUSPENDED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_get_formats:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
* @filter: a #GBytes
|
|
||||||
* @error: a #GError or %NULL
|
|
||||||
*
|
|
||||||
* Get all the currently supported formats for @sink and filter the
|
|
||||||
* results with @filter.
|
|
||||||
*
|
|
||||||
* Returns: the list of supported format. If %NULL is returned, @error will
|
|
||||||
* be set.
|
|
||||||
*/
|
|
||||||
GBytes *
|
|
||||||
pinos_sink_get_formats (PinosSink *sink,
|
|
||||||
GBytes *filter,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
PinosSinkClass *klass;
|
|
||||||
GBytes *res;
|
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_SINK (sink), NULL);
|
|
||||||
|
|
||||||
klass = PINOS_SINK_GET_CLASS (sink);
|
|
||||||
|
|
||||||
if (klass->get_formats)
|
|
||||||
res = klass->get_formats (sink, filter, error);
|
|
||||||
else {
|
|
||||||
res = NULL;
|
|
||||||
if (error)
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_NOT_SUPPORTED,
|
|
||||||
"Format query is not supported");
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
remove_idle_timeout (PinosSink *sink)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
|
|
||||||
if (priv->idle_timeout) {
|
|
||||||
g_source_remove (priv->idle_timeout);
|
|
||||||
priv->idle_timeout = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_set_state:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
* @state: a #PinosSinkState
|
|
||||||
*
|
|
||||||
* Set the state of @sink to @state.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE on success.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
pinos_sink_set_state (PinosSink *sink,
|
|
||||||
PinosSinkState state)
|
|
||||||
{
|
|
||||||
PinosSinkClass *klass;
|
|
||||||
gboolean res;
|
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_SINK (sink), FALSE);
|
|
||||||
|
|
||||||
klass = PINOS_SINK_GET_CLASS (sink);
|
|
||||||
|
|
||||||
remove_idle_timeout (sink);
|
|
||||||
|
|
||||||
if (klass->set_state)
|
|
||||||
res = klass->set_state (sink, state);
|
|
||||||
else
|
|
||||||
res = FALSE;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_update_state:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
* @state: a #PinosSinkState
|
|
||||||
*
|
|
||||||
* Update the state of a sink. This method is used from
|
|
||||||
* inside @sink itself.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
pinos_sink_update_state (PinosSink *sink,
|
|
||||||
PinosSinkState state)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (PINOS_IS_SINK (sink));
|
|
||||||
priv = sink->priv;
|
|
||||||
|
|
||||||
if (priv->state != state) {
|
|
||||||
priv->state = state;
|
|
||||||
pinos_sink1_set_state (priv->iface, state);
|
|
||||||
g_object_notify (G_OBJECT (sink), "state");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_report_error:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
* @error: a #GError
|
|
||||||
*
|
|
||||||
* Report an error from within @sink.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
pinos_sink_report_error (PinosSink *sink,
|
|
||||||
GError *error)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (PINOS_IS_SINK (sink));
|
|
||||||
priv = sink->priv;
|
|
||||||
|
|
||||||
g_clear_error (&priv->error);
|
|
||||||
remove_idle_timeout (sink);
|
|
||||||
priv->error = error;
|
|
||||||
priv->state = PINOS_SINK_STATE_ERROR;
|
|
||||||
g_debug ("got error state %s", error->message);
|
|
||||||
pinos_sink1_set_state (priv->iface, priv->state);
|
|
||||||
g_object_notify (G_OBJECT (sink), "state");
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
idle_timeout (PinosSink *sink)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv = sink->priv;
|
|
||||||
|
|
||||||
priv->idle_timeout = 0;
|
|
||||||
pinos_sink_set_state (sink, PINOS_SINK_STATE_SUSPENDED);
|
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_report_idle:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
*
|
|
||||||
* Mark @sink as being idle. This will start a timeout that will
|
|
||||||
* set the sink to SUSPENDED.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
pinos_sink_report_idle (PinosSink *sink)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (PINOS_IS_SINK (sink));
|
|
||||||
priv = sink->priv;
|
|
||||||
|
|
||||||
pinos_sink_set_state (sink, PINOS_SINK_STATE_IDLE);
|
|
||||||
|
|
||||||
priv->idle_timeout = g_timeout_add_seconds (3,
|
|
||||||
(GSourceFunc) idle_timeout,
|
|
||||||
sink);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_report_busy:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
*
|
|
||||||
* Mark @sink as being busy. This will set the state of the sink
|
|
||||||
* to the RUNNING state.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
pinos_sink_report_busy (PinosSink *sink)
|
|
||||||
{
|
|
||||||
g_return_if_fail (PINOS_IS_SINK (sink));
|
|
||||||
|
|
||||||
pinos_sink_set_state (sink, PINOS_SINK_STATE_RUNNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_update_possible_formats:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
* @formats: a #GBytes
|
|
||||||
*
|
|
||||||
* Update the possible formats in @sink to @formats. This function also
|
|
||||||
* updates the possible formats of the channels.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
pinos_sink_update_possible_formats (PinosSink *sink, GBytes *formats)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv;
|
|
||||||
GList *walk;
|
|
||||||
|
|
||||||
g_return_if_fail (PINOS_IS_SINK (sink));
|
|
||||||
priv = sink->priv;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_update_format:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
* @format: a #GBytes
|
|
||||||
*
|
|
||||||
* Update the current format in @sink to @format. This function also
|
|
||||||
* updates the current format of the channels.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
pinos_sink_update_format (PinosSink *sink, GBytes *format)
|
|
||||||
{
|
|
||||||
PinosSinkPrivate *priv;
|
|
||||||
GList *walk;
|
|
||||||
|
|
||||||
g_return_if_fail (PINOS_IS_SINK (sink));
|
|
||||||
priv = sink->priv;
|
|
||||||
|
|
||||||
for (walk = priv->channels; walk; walk = g_list_next (walk))
|
|
||||||
g_object_set (walk->data, "format", format, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_create_channel:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
* @client_path: the client path
|
|
||||||
* @format_filter: a #GBytes
|
|
||||||
* @props: #PinosProperties
|
|
||||||
* @prefix: a prefix
|
|
||||||
* @error: a #GError or %NULL
|
|
||||||
*
|
|
||||||
* Create a new #PinosChannel for @sink.
|
|
||||||
*
|
|
||||||
* Returns: a new #PinosChannel or %NULL, in wich case @error will contain
|
|
||||||
* more information about the error.
|
|
||||||
*/
|
|
||||||
PinosChannel *
|
|
||||||
pinos_sink_create_channel (PinosSink *sink,
|
|
||||||
const gchar *client_path,
|
|
||||||
GBytes *format_filter,
|
|
||||||
PinosProperties *props,
|
|
||||||
const gchar *prefix,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
PinosSinkClass *klass;
|
|
||||||
PinosChannel *res;
|
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_SINK (sink), NULL);
|
|
||||||
|
|
||||||
klass = PINOS_SINK_GET_CLASS (sink);
|
|
||||||
|
|
||||||
if (klass->create_channel) {
|
|
||||||
res = klass->create_channel (sink, client_path, format_filter, props, prefix, error);
|
|
||||||
} else {
|
|
||||||
if (error) {
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_NOT_SUPPORTED,
|
|
||||||
"CreateChannel not implemented");
|
|
||||||
}
|
|
||||||
res = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pinos_sink_release_channel:
|
|
||||||
* @sink: a #PinosSink
|
|
||||||
* @channel: a #PinosChannel
|
|
||||||
*
|
|
||||||
* Release the @channel in @sink.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE on success.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
pinos_sink_release_channel (PinosSink *sink,
|
|
||||||
PinosChannel *channel)
|
|
||||||
{
|
|
||||||
PinosSinkClass *klass;
|
|
||||||
gboolean res;
|
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_SINK (sink), FALSE);
|
|
||||||
g_return_val_if_fail (PINOS_IS_CHANNEL (channel), FALSE);
|
|
||||||
|
|
||||||
klass = PINOS_SINK_GET_CLASS (sink);
|
|
||||||
|
|
||||||
if (klass->release_channel)
|
|
||||||
res = klass->release_channel (sink, channel);
|
|
||||||
else
|
|
||||||
res = FALSE;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/* Pinos
|
|
||||||
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __PINOS_SINK_H__
|
|
||||||
#define __PINOS_SINK_H__
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef struct _PinosSink PinosSink;
|
|
||||||
typedef struct _PinosSinkClass PinosSinkClass;
|
|
||||||
typedef struct _PinosSinkPrivate PinosSinkPrivate;
|
|
||||||
|
|
||||||
#include <pinos/client/introspect.h>
|
|
||||||
#include <pinos/server/channel.h>
|
|
||||||
|
|
||||||
#define PINOS_TYPE_SINK (pinos_sink_get_type ())
|
|
||||||
#define PINOS_IS_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SINK))
|
|
||||||
#define PINOS_IS_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SINK))
|
|
||||||
#define PINOS_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SINK, PinosSinkClass))
|
|
||||||
#define PINOS_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SINK, PinosSink))
|
|
||||||
#define PINOS_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SINK, PinosSinkClass))
|
|
||||||
#define PINOS_SINK_CAST(obj) ((PinosSink*)(obj))
|
|
||||||
#define PINOS_SINK_CLASS_CAST(klass) ((PinosSinkClass*)(klass))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PinosSink:
|
|
||||||
*
|
|
||||||
* Pinos sink object class.
|
|
||||||
*/
|
|
||||||
struct _PinosSink {
|
|
||||||
GObject object;
|
|
||||||
|
|
||||||
PinosSinkPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PinosSinkClass:
|
|
||||||
* @get_formats: called to get a list of supported formats from the sink
|
|
||||||
* @set_state: called to change the current state of the sink
|
|
||||||
* @create_channel: called to create a new channel object
|
|
||||||
* @release_channel: called to release a channel object
|
|
||||||
*
|
|
||||||
* Pinos sink object class.
|
|
||||||
*/
|
|
||||||
struct _PinosSinkClass {
|
|
||||||
GObjectClass parent_class;
|
|
||||||
|
|
||||||
GBytes * (*get_formats) (PinosSink *sink,
|
|
||||||
GBytes *filter,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
gboolean (*set_state) (PinosSink *sink, PinosSinkState);
|
|
||||||
|
|
||||||
PinosChannel * (*create_channel) (PinosSink *sink,
|
|
||||||
const gchar *client_path,
|
|
||||||
GBytes *format_filter,
|
|
||||||
PinosProperties *props,
|
|
||||||
const gchar *prefix,
|
|
||||||
GError **error);
|
|
||||||
gboolean (*release_channel) (PinosSink *sink,
|
|
||||||
PinosChannel *channel);
|
|
||||||
};
|
|
||||||
|
|
||||||
/* normal GObject stuff */
|
|
||||||
GType pinos_sink_get_type (void);
|
|
||||||
|
|
||||||
GBytes * pinos_sink_get_formats (PinosSink *sink,
|
|
||||||
GBytes *filter,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
gboolean pinos_sink_set_state (PinosSink *sink, PinosSinkState state);
|
|
||||||
void pinos_sink_update_state (PinosSink *sink, PinosSinkState state);
|
|
||||||
void pinos_sink_report_error (PinosSink *sink, GError *error);
|
|
||||||
void pinos_sink_report_idle (PinosSink *sink);
|
|
||||||
void pinos_sink_report_busy (PinosSink *sink);
|
|
||||||
|
|
||||||
void pinos_sink_update_possible_formats (PinosSink *sink, GBytes *formats);
|
|
||||||
void pinos_sink_update_format (PinosSink *sink, GBytes *format);
|
|
||||||
|
|
||||||
PinosChannel * pinos_sink_create_channel (PinosSink *sink,
|
|
||||||
const gchar *client_path,
|
|
||||||
GBytes *format_filter,
|
|
||||||
PinosProperties *props,
|
|
||||||
const gchar *prefix,
|
|
||||||
GError **error);
|
|
||||||
gboolean pinos_sink_release_channel (PinosSink *sink,
|
|
||||||
PinosChannel *channel);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __PINOS_SINK_H__ */
|
|
||||||
|
|
@ -22,12 +22,12 @@
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#include <pinos/server/daemon.h>
|
#include <pinos/server/daemon.h>
|
||||||
#include <pinos/server/client-source.h>
|
#include <pinos/server/upload-node.h>
|
||||||
|
|
||||||
#define PINOS_CLIENT_SOURCE_GET_PRIVATE(obj) \
|
#define PINOS_UPLOAD_NODE_GET_PRIVATE(obj) \
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_CLIENT_SOURCE, PinosClientSourcePrivate))
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_UPLOAD_NODE, PinosUploadNodePrivate))
|
||||||
|
|
||||||
struct _PinosClientSourcePrivate
|
struct _PinosUploadNodePrivate
|
||||||
{
|
{
|
||||||
GstElement *pipeline;
|
GstElement *pipeline;
|
||||||
GstElement *src;
|
GstElement *src;
|
||||||
|
|
@ -37,10 +37,12 @@ struct _PinosClientSourcePrivate
|
||||||
GstCaps *format;
|
GstCaps *format;
|
||||||
GBytes *possible_formats;
|
GBytes *possible_formats;
|
||||||
|
|
||||||
|
PinosPort *input, *output;
|
||||||
|
|
||||||
PinosChannel *channel;
|
PinosChannel *channel;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (PinosClientSource, pinos_client_source, PINOS_TYPE_SOURCE);
|
G_DEFINE_TYPE (PinosUploadNode, pinos_upload_node, PINOS_TYPE_NODE);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
@ -49,13 +51,13 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
client_source_get_property (GObject *_object,
|
upload_node_get_property (GObject *_object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
PinosClientSource *source = PINOS_CLIENT_SOURCE (_object);
|
PinosUploadNode *node = PINOS_UPLOAD_NODE (_object);
|
||||||
PinosClientSourcePrivate *priv = source->priv;
|
PinosUploadNodePrivate *priv = node->priv;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_POSSIBLE_FORMATS:
|
case PROP_POSSIBLE_FORMATS:
|
||||||
|
|
@ -63,43 +65,47 @@ client_source_get_property (GObject *_object,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (source, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (node, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
client_source_set_property (GObject *_object,
|
upload_node_set_property (GObject *_object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
PinosClientSource *source = PINOS_CLIENT_SOURCE (_object);
|
PinosUploadNode *node = PINOS_UPLOAD_NODE (_object);
|
||||||
PinosClientSourcePrivate *priv = source->priv;
|
PinosUploadNodePrivate *priv = node->priv;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_POSSIBLE_FORMATS:
|
case PROP_POSSIBLE_FORMATS:
|
||||||
if (priv->possible_formats)
|
if (priv->possible_formats)
|
||||||
g_bytes_unref (priv->possible_formats);
|
g_bytes_unref (priv->possible_formats);
|
||||||
priv->possible_formats = g_value_dup_boxed (value);
|
priv->possible_formats = g_value_dup_boxed (value);
|
||||||
pinos_source_update_possible_formats (PINOS_SOURCE (source),
|
g_object_set (priv->output, "possible-formats", priv->possible_formats, NULL);
|
||||||
priv->possible_formats);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (source, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (node, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_channel_format (PinosChannel *channel, GBytes *format)
|
||||||
|
{
|
||||||
|
g_object_set (channel, "format", format, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
bus_handler (GstBus *bus,
|
bus_handler (GstBus *bus,
|
||||||
GstMessage *message,
|
GstMessage *message,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosSource *source = user_data;
|
PinosNode *node = user_data;
|
||||||
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
|
PinosUploadNodePrivate *priv = PINOS_UPLOAD_NODE (node)->priv;
|
||||||
|
|
||||||
switch (GST_MESSAGE_TYPE (message)) {
|
switch (GST_MESSAGE_TYPE (message)) {
|
||||||
case GST_MESSAGE_ERROR:
|
case GST_MESSAGE_ERROR:
|
||||||
|
|
@ -111,7 +117,7 @@ bus_handler (GstBus *bus,
|
||||||
g_warning ("got error %s (%s)\n", error->message, debug);
|
g_warning ("got error %s (%s)\n", error->message, debug);
|
||||||
g_free (debug);
|
g_free (debug);
|
||||||
|
|
||||||
pinos_source_report_error (source, error);
|
pinos_node_report_error (node, error);
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -128,9 +134,8 @@ bus_handler (GstBus *bus,
|
||||||
caps_str = gst_caps_to_string (caps);
|
caps_str = gst_caps_to_string (caps);
|
||||||
|
|
||||||
format = g_bytes_new_take (caps_str, strlen (caps_str) + 1);
|
format = g_bytes_new_take (caps_str, strlen (caps_str) + 1);
|
||||||
g_object_set (priv->channel, "possible-formats", format, "format", format, NULL);
|
g_list_foreach (pinos_port_get_channels (priv->output), (GFunc) update_channel_format, format);
|
||||||
pinos_source_update_possible_formats (source, format);
|
g_list_foreach (pinos_port_get_channels (priv->input), (GFunc) update_channel_format, format);
|
||||||
pinos_source_update_format (source, format);
|
|
||||||
g_bytes_unref (format);
|
g_bytes_unref (format);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -142,9 +147,9 @@ bus_handler (GstBus *bus,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_pipeline (PinosClientSource *source)
|
setup_pipeline (PinosUploadNode *node)
|
||||||
{
|
{
|
||||||
PinosClientSourcePrivate *priv = source->priv;
|
PinosUploadNodePrivate *priv = node->priv;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
|
||||||
priv->pipeline = gst_parse_launch ("socketsrc "
|
priv->pipeline = gst_parse_launch ("socketsrc "
|
||||||
|
|
@ -159,116 +164,56 @@ setup_pipeline (PinosClientSource *source)
|
||||||
priv->src = gst_bin_get_by_name (GST_BIN (priv->pipeline), "src");
|
priv->src = gst_bin_get_by_name (GST_BIN (priv->pipeline), "src");
|
||||||
|
|
||||||
bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
|
bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
|
||||||
priv->id = gst_bus_add_watch (bus, bus_handler, source);
|
priv->id = gst_bus_add_watch (bus, bus_handler, node);
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
|
|
||||||
g_debug ("client-source %p: setup pipeline", source);
|
g_debug ("upload-node %p: setup pipeline", node);
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps *
|
|
||||||
collect_caps (PinosSource *source,
|
|
||||||
GstCaps *filter)
|
|
||||||
{
|
|
||||||
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
|
|
||||||
|
|
||||||
if (priv->format)
|
|
||||||
return gst_caps_ref (priv->format);
|
|
||||||
else
|
|
||||||
return gst_caps_new_any ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
client_set_state (PinosSource *source,
|
node_set_state (PinosNode *node,
|
||||||
PinosSourceState state)
|
PinosNodeState state)
|
||||||
{
|
{
|
||||||
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
|
PinosUploadNodePrivate *priv = PINOS_UPLOAD_NODE (node)->priv;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PINOS_SOURCE_STATE_SUSPENDED:
|
case PINOS_NODE_STATE_SUSPENDED:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SOURCE_STATE_INITIALIZING:
|
case PINOS_NODE_STATE_INITIALIZING:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SOURCE_STATE_IDLE:
|
case PINOS_NODE_STATE_IDLE:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SOURCE_STATE_RUNNING:
|
case PINOS_NODE_STATE_RUNNING:
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PINOS_SOURCE_STATE_ERROR:
|
case PINOS_NODE_STATE_ERROR:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pinos_source_update_state (source, state);
|
pinos_node_update_state (node, state);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GBytes *
|
|
||||||
client_get_formats (PinosSource *source,
|
|
||||||
GBytes *filter,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
GstCaps *caps, *cfilter;
|
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
if (filter) {
|
|
||||||
cfilter = gst_caps_from_string (g_bytes_get_data (filter, NULL));
|
|
||||||
if (cfilter == NULL)
|
|
||||||
goto invalid_filter;
|
|
||||||
} else {
|
|
||||||
cfilter = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
caps = collect_caps (source, cfilter);
|
|
||||||
if (caps == NULL)
|
|
||||||
goto no_format;
|
|
||||||
|
|
||||||
str = gst_caps_to_string (caps);
|
|
||||||
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
if (cfilter)
|
|
||||||
gst_caps_unref (cfilter);
|
|
||||||
|
|
||||||
return g_bytes_new_take (str, strlen (str) + 1);
|
|
||||||
|
|
||||||
invalid_filter:
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_INVALID_ARGUMENT,
|
|
||||||
"Invalid filter received");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
no_format:
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
*error = g_error_new (G_IO_ERROR,
|
|
||||||
G_IO_ERROR_NOT_FOUND,
|
|
||||||
"No compatible format found");
|
|
||||||
if (cfilter)
|
|
||||||
gst_caps_unref (cfilter);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_socket_notify (GObject *gobject,
|
on_socket_notify (GObject *gobject,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosClientSource *source = user_data;
|
PinosUploadNode *node = user_data;
|
||||||
PinosClientSourcePrivate *priv = source->priv;
|
PinosUploadNodePrivate *priv = node->priv;
|
||||||
GSocket *socket;
|
GSocket *socket;
|
||||||
guint num_handles;
|
guint num_handles;
|
||||||
|
|
||||||
g_object_get (gobject, "socket", &socket, NULL);
|
g_object_get (gobject, "socket", &socket, NULL);
|
||||||
|
|
||||||
g_debug ("client-source %p: output socket notify %p", source, socket);
|
g_debug ("upload-node %p: output socket notify %p", node, socket);
|
||||||
|
|
||||||
if (socket == NULL) {
|
if (socket == NULL) {
|
||||||
GSocket *prev_socket = g_object_steal_data (gobject, "last-socket");
|
GSocket *prev_socket = g_object_steal_data (gobject, "last-socket");
|
||||||
|
|
@ -292,66 +237,39 @@ on_socket_notify (GObject *gobject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PinosChannel *
|
static void
|
||||||
client_create_channel (PinosSource *source,
|
on_channel_added (PinosPort *port, PinosChannel *channel, PinosNode *node)
|
||||||
const gchar *client_path,
|
|
||||||
GBytes *format_filter,
|
|
||||||
PinosProperties *props,
|
|
||||||
const gchar *prefix,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
|
g_signal_connect (channel, "notify::socket", (GCallback) on_socket_notify, node);
|
||||||
PinosChannel *channel;
|
|
||||||
|
|
||||||
/* propose format of input */
|
g_debug ("upload-node %p: create channel %p", node, channel);
|
||||||
g_object_get (priv->channel, "format", &format_filter, NULL);
|
|
||||||
|
|
||||||
channel = PINOS_SOURCE_CLASS (pinos_client_source_parent_class)
|
|
||||||
->create_channel (source,
|
|
||||||
client_path,
|
|
||||||
format_filter,
|
|
||||||
props,
|
|
||||||
prefix,
|
|
||||||
error);
|
|
||||||
g_bytes_unref (format_filter);
|
|
||||||
|
|
||||||
if (channel == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
g_debug ("client-source %p: create channel %p", source, channel);
|
|
||||||
|
|
||||||
g_signal_connect (channel, "notify::socket", (GCallback) on_socket_notify, source);
|
|
||||||
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
client_release_channel (PinosSource *source,
|
|
||||||
PinosChannel *channel)
|
|
||||||
{
|
|
||||||
g_debug ("client-source %p: release channel %p", source, channel);
|
|
||||||
return PINOS_SOURCE_CLASS (pinos_client_source_parent_class)->release_channel (source, channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
client_source_dispose (GObject * object)
|
on_channel_removed (PinosPort *port, PinosChannel *channel, PinosNode *node)
|
||||||
{
|
{
|
||||||
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv;
|
g_debug ("upload-node %p: release channel %p", node, channel);
|
||||||
|
}
|
||||||
|
|
||||||
g_debug ("client-source %p: dispose", object);
|
static void
|
||||||
|
upload_node_dispose (GObject * object)
|
||||||
|
{
|
||||||
|
PinosUploadNodePrivate *priv = PINOS_UPLOAD_NODE (object)->priv;
|
||||||
|
|
||||||
|
g_debug ("upload-node %p: dispose", object);
|
||||||
|
|
||||||
g_source_remove (priv->id);
|
g_source_remove (priv->id);
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_client_source_parent_class)->dispose (object);
|
G_OBJECT_CLASS (pinos_upload_node_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
client_source_finalize (GObject * object)
|
upload_node_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv;
|
PinosUploadNodePrivate *priv = PINOS_UPLOAD_NODE (object)->priv;
|
||||||
|
|
||||||
g_debug ("client-source %p: finalize", object);
|
g_debug ("upload-node %p: finalize", object);
|
||||||
|
|
||||||
g_clear_object (&priv->channel);
|
g_clear_object (&priv->channel);
|
||||||
g_clear_object (&priv->sink);
|
g_clear_object (&priv->sink);
|
||||||
|
|
@ -362,7 +280,7 @@ client_source_finalize (GObject * object)
|
||||||
g_bytes_unref (priv->possible_formats);
|
g_bytes_unref (priv->possible_formats);
|
||||||
gst_caps_replace (&priv->format, NULL);
|
gst_caps_replace (&priv->format, NULL);
|
||||||
|
|
||||||
G_OBJECT_CLASS (pinos_client_source_parent_class)->finalize (object);
|
G_OBJECT_CLASS (pinos_upload_node_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -371,14 +289,14 @@ on_input_socket_notify (GObject *gobject,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosClientSource *source = user_data;
|
PinosUploadNode *node = user_data;
|
||||||
PinosClientSourcePrivate *priv = source->priv;
|
PinosUploadNodePrivate *priv = node->priv;
|
||||||
GSocket *socket;
|
GSocket *socket;
|
||||||
GBytes *requested_format;
|
GBytes *requested_format;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
g_object_get (gobject, "socket", &socket, NULL);
|
g_object_get (gobject, "socket", &socket, NULL);
|
||||||
g_debug ("client-source %p: input socket notify %p", source, socket);
|
g_debug ("upload-node %p: input socket notify %p", node, socket);
|
||||||
|
|
||||||
if (socket) {
|
if (socket) {
|
||||||
/* requested format is final format */
|
/* requested format is final format */
|
||||||
|
|
@ -397,11 +315,11 @@ on_input_socket_notify (GObject *gobject,
|
||||||
g_object_set (priv->src, "socket", socket, NULL);
|
g_object_set (priv->src, "socket", socket, NULL);
|
||||||
|
|
||||||
if (socket) {
|
if (socket) {
|
||||||
g_debug ("client-source %p: set pipeline to PLAYING", source);
|
g_debug ("upload-node %p: set pipeline to PLAYING", node);
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
|
||||||
g_object_unref (socket);
|
g_object_unref (socket);
|
||||||
} else {
|
} else {
|
||||||
g_debug ("client-source %p: set pipeline to READY", source);
|
g_debug ("upload-node %p: set pipeline to READY", node);
|
||||||
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
gst_element_set_state (priv->pipeline, GST_STATE_READY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -410,16 +328,16 @@ static void
|
||||||
handle_remove_channel (PinosChannel *channel,
|
handle_remove_channel (PinosChannel *channel,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PinosClientSource *source = user_data;
|
PinosUploadNode *node = user_data;
|
||||||
PinosClientSourcePrivate *priv = source->priv;
|
PinosUploadNodePrivate *priv = node->priv;
|
||||||
|
|
||||||
g_debug ("client-source %p: remove channel %p", source, priv->channel);
|
g_debug ("upload-node %p: remove channel %p", node, priv->channel);
|
||||||
g_clear_pointer (&priv->channel, g_object_unref);
|
g_clear_pointer (&priv->channel, g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_client_source_get_channel:
|
* pinos_upload_node_get_channel:
|
||||||
* @source: a #PinosClientSource
|
* @node: a #PinosUploadNode
|
||||||
* @client_path: the client path
|
* @client_path: the client path
|
||||||
* @format_filter: a #GBytes
|
* @format_filter: a #GBytes
|
||||||
* @props: extra properties
|
* @props: extra properties
|
||||||
|
|
@ -432,57 +350,54 @@ handle_remove_channel (PinosChannel *channel,
|
||||||
* Returns: a new #PinosChannel.
|
* Returns: a new #PinosChannel.
|
||||||
*/
|
*/
|
||||||
PinosChannel *
|
PinosChannel *
|
||||||
pinos_client_source_get_channel (PinosClientSource *source,
|
pinos_upload_node_get_channel (PinosUploadNode *node,
|
||||||
const gchar *client_path,
|
const gchar *client_path,
|
||||||
GBytes *format_filter,
|
GBytes *format_filter,
|
||||||
PinosProperties *props,
|
PinosProperties *props,
|
||||||
const gchar *prefix,
|
GError **error)
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
PinosClientSourcePrivate *priv;
|
PinosUploadNodePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (PINOS_IS_CLIENT_SOURCE (source), NULL);
|
g_return_val_if_fail (PINOS_IS_UPLOAD_NODE (node), NULL);
|
||||||
priv = source->priv;
|
priv = node->priv;
|
||||||
|
|
||||||
if (priv->channel == NULL) {
|
if (priv->channel == NULL) {
|
||||||
GstCaps *caps = gst_caps_from_string (g_bytes_get_data (format_filter, NULL));
|
GstCaps *caps = gst_caps_from_string (g_bytes_get_data (format_filter, NULL));
|
||||||
|
|
||||||
gst_caps_take (&priv->format, caps);
|
gst_caps_take (&priv->format, caps);
|
||||||
|
|
||||||
priv->channel = PINOS_SOURCE_CLASS (pinos_client_source_parent_class)
|
priv->channel = pinos_port_create_channel (priv->input,
|
||||||
->create_channel (PINOS_SOURCE (source),
|
client_path,
|
||||||
client_path,
|
format_filter,
|
||||||
format_filter,
|
props,
|
||||||
props,
|
error);
|
||||||
prefix,
|
|
||||||
error);
|
|
||||||
if (priv->channel == NULL)
|
if (priv->channel == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
g_signal_connect (priv->channel,
|
g_signal_connect (priv->channel,
|
||||||
"remove",
|
"remove",
|
||||||
(GCallback) handle_remove_channel,
|
(GCallback) handle_remove_channel,
|
||||||
source);
|
node);
|
||||||
|
|
||||||
g_debug ("client-source %p: get source input %p", source, priv->channel);
|
g_debug ("upload-node %p: get input %p", node, priv->channel);
|
||||||
g_signal_connect (priv->channel, "notify::socket", (GCallback) on_input_socket_notify, source);
|
g_signal_connect (priv->channel, "notify::socket", (GCallback) on_input_socket_notify, node);
|
||||||
}
|
}
|
||||||
return g_object_ref (priv->channel);
|
return g_object_ref (priv->channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pinos_client_source_class_init (PinosClientSourceClass * klass)
|
pinos_upload_node_class_init (PinosUploadNodeClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
PinosSourceClass *source_class = PINOS_SOURCE_CLASS (klass);
|
PinosNodeClass *node_class = PINOS_NODE_CLASS (klass);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (PinosClientSourcePrivate));
|
g_type_class_add_private (klass, sizeof (PinosUploadNodePrivate));
|
||||||
|
|
||||||
gobject_class->dispose = client_source_dispose;
|
gobject_class->dispose = upload_node_dispose;
|
||||||
gobject_class->finalize = client_source_finalize;
|
gobject_class->finalize = upload_node_finalize;
|
||||||
|
|
||||||
gobject_class->get_property = client_source_get_property;
|
gobject_class->get_property = upload_node_get_property;
|
||||||
gobject_class->set_property = client_source_set_property;
|
gobject_class->set_property = upload_node_set_property;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_POSSIBLE_FORMATS,
|
PROP_POSSIBLE_FORMATS,
|
||||||
|
|
@ -494,37 +409,47 @@ pinos_client_source_class_init (PinosClientSourceClass * klass)
|
||||||
G_PARAM_CONSTRUCT |
|
G_PARAM_CONSTRUCT |
|
||||||
G_PARAM_STATIC_STRINGS));
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
source_class->get_formats = client_get_formats;
|
node_class->set_state = node_set_state;
|
||||||
source_class->set_state = client_set_state;
|
|
||||||
source_class->create_channel = client_create_channel;
|
|
||||||
source_class->release_channel = client_release_channel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pinos_client_source_init (PinosClientSource * source)
|
pinos_upload_node_init (PinosUploadNode * node)
|
||||||
{
|
{
|
||||||
source->priv = PINOS_CLIENT_SOURCE_GET_PRIVATE (source);
|
PinosUploadNodePrivate *priv = node->priv = PINOS_UPLOAD_NODE_GET_PRIVATE (node);
|
||||||
|
|
||||||
g_debug ("client-source %p: new", source);
|
g_debug ("upload-node %p: new", node);
|
||||||
setup_pipeline (source);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pinos_client_source_new:
|
* pinos_upload_node_new:
|
||||||
* @daemon: the parent #PinosDaemon
|
* @daemon: the parent #PinosDaemon
|
||||||
* @possible_formats: a #GBytes
|
* @possible_formats: a #GBytes
|
||||||
*
|
*
|
||||||
* Make a new #PinosSource that can be used to receive data from a client.
|
* Make a new #PinosNode that can be used to receive data from a client.
|
||||||
*
|
*
|
||||||
* Returns: a new #PinosSource.
|
* Returns: a new #PinosNode.
|
||||||
*/
|
*/
|
||||||
PinosSource *
|
PinosNode *
|
||||||
pinos_client_source_new (PinosDaemon *daemon,
|
pinos_upload_node_new (PinosDaemon *daemon,
|
||||||
GBytes *possible_formats)
|
GBytes *possible_formats)
|
||||||
{
|
{
|
||||||
return g_object_new (PINOS_TYPE_CLIENT_SOURCE,
|
return g_object_new (PINOS_TYPE_UPLOAD_NODE,
|
||||||
"daemon", daemon,
|
"daemon", daemon,
|
||||||
"name", "client-source",
|
"name", "upload-node",
|
||||||
"possible-formats", possible_formats,
|
"possible-formats", possible_formats,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
75
pinos/server/upload-node.h
Normal file
75
pinos/server/upload-node.h
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
/* Pinos
|
||||||
|
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PINOS_UPLOAD_NODE_H__
|
||||||
|
#define __PINOS_UPLOAD_NODE_H__
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct _PinosUploadNode PinosUploadNode;
|
||||||
|
typedef struct _PinosUploadNodeClass PinosUploadNodeClass;
|
||||||
|
typedef struct _PinosUploadNodePrivate PinosUploadNodePrivate;
|
||||||
|
|
||||||
|
#include <pinos/server/node.h>
|
||||||
|
|
||||||
|
#define PINOS_TYPE_UPLOAD_NODE (pinos_upload_node_get_type ())
|
||||||
|
#define PINOS_IS_UPLOAD_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_UPLOAD_NODE))
|
||||||
|
#define PINOS_IS_UPLOAD_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_UPLOAD_NODE))
|
||||||
|
#define PINOS_UPLOAD_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_UPLOAD_NODE, PinosUploadNodeClass))
|
||||||
|
#define PINOS_UPLOAD_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_UPLOAD_NODE, PinosUploadNode))
|
||||||
|
#define PINOS_UPLOAD_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_UPLOAD_NODE, PinosUploadNodeClass))
|
||||||
|
#define PINOS_UPLOAD_NODE_CAST(obj) ((PinosUploadNode*)(obj))
|
||||||
|
#define PINOS_UPLOAD_NODE_CLASS_CAST(klass) ((PinosUploadNodeClass*)(klass))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PinosUploadNode:
|
||||||
|
*
|
||||||
|
* Pinos client source object class.
|
||||||
|
*/
|
||||||
|
struct _PinosUploadNode {
|
||||||
|
PinosNode object;
|
||||||
|
|
||||||
|
PinosUploadNodePrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PinosUploadNodeClass:
|
||||||
|
*
|
||||||
|
* Pinos client source object class.
|
||||||
|
*/
|
||||||
|
struct _PinosUploadNodeClass {
|
||||||
|
PinosNodeClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* normal GObject stuff */
|
||||||
|
GType pinos_upload_node_get_type (void);
|
||||||
|
|
||||||
|
PinosNode * pinos_upload_node_new (PinosDaemon *daemon,
|
||||||
|
GBytes *possible_formats);
|
||||||
|
|
||||||
|
PinosChannel * pinos_upload_node_get_channel (PinosUploadNode *source,
|
||||||
|
const gchar *client_path,
|
||||||
|
GBytes *format_filter,
|
||||||
|
PinosProperties *props,
|
||||||
|
GError **error);
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __PINOS_UPLOAD_NODE_H__ */
|
||||||
|
|
@ -143,7 +143,7 @@ on_state_notify (GObject *gobject,
|
||||||
g_signal_connect (stream, "notify::socket", (GCallback) on_socket_notify, stream);
|
g_signal_connect (stream, "notify::socket", (GCallback) on_socket_notify, stream);
|
||||||
|
|
||||||
format = g_bytes_new_static (ANY_CAPS, strlen (ANY_CAPS) + 1);
|
format = g_bytes_new_static (ANY_CAPS, strlen (ANY_CAPS) + 1);
|
||||||
pinos_stream_connect_source (stream, NULL, 0, format);
|
pinos_stream_connect (stream, PINOS_DIRECTION_OUTPUT, NULL, 0, format);
|
||||||
g_bytes_unref (format);
|
g_bytes_unref (format);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,32 +137,32 @@ dump_client_info (PinosContext *c, const PinosClientInfo *info, gpointer user_da
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_source_info (PinosContext *c, const PinosSourceInfo *info, gpointer user_data)
|
dump_node_info (PinosContext *c, const PinosNodeInfo *info, gpointer user_data)
|
||||||
{
|
{
|
||||||
DumpData *data = user_data;
|
DumpData *data = user_data;
|
||||||
|
|
||||||
g_print ("\tid: %p\n", info->id);
|
g_print ("\tid: %p\n", info->id);
|
||||||
g_print ("\tsource-path: \"%s\"\n", info->source_path);
|
g_print ("\tnode-path: \"%s\"\n", info->node_path);
|
||||||
if (data->print_all) {
|
if (data->print_all) {
|
||||||
g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name);
|
g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name);
|
||||||
print_properties (info->properties, MARK_CHANGE (1));
|
print_properties (info->properties, MARK_CHANGE (1));
|
||||||
g_print ("%c\tstate: \"%s\"\n", MARK_CHANGE (2), pinos_source_state_as_string (info->state));
|
g_print ("%c\tstate: \"%s\"\n", MARK_CHANGE (2), pinos_node_state_as_string (info->state));
|
||||||
print_formats ("possible formats", info->possible_formats, MARK_CHANGE (3));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_sink_info (PinosContext *c, const PinosSinkInfo *info, gpointer user_data)
|
dump_port_info (PinosContext *c, const PinosPortInfo *info, gpointer user_data)
|
||||||
{
|
{
|
||||||
DumpData *data = user_data;
|
DumpData *data = user_data;
|
||||||
|
|
||||||
g_print ("\tid: %p\n", info->id);
|
g_print ("\tid: %p\n", info->id);
|
||||||
g_print ("\tsink-path: \"%s\"\n", info->sink_path);
|
g_print ("\tport-path: \"%s\"\n", info->port_path);
|
||||||
if (data->print_all) {
|
if (data->print_all) {
|
||||||
|
g_print ("\tnode-path: \"%s\"\n", info->node_path);
|
||||||
|
g_print ("\tdirection: \"%s\"\n", pinos_direction_as_string (info->direction));
|
||||||
g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name);
|
g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name);
|
||||||
print_properties (info->properties, MARK_CHANGE (1));
|
print_properties (info->properties, MARK_CHANGE (1));
|
||||||
g_print ("%c\tstate: \"%s\"\n", MARK_CHANGE (2), pinos_sink_state_as_string (info->state));
|
print_formats ("possible formats", info->possible_formats, MARK_CHANGE (2));
|
||||||
print_formats ("possible formats", info->possible_formats, MARK_CHANGE (3));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,12 +175,13 @@ dump_channel_info (PinosContext *c, const PinosChannelInfo *info, gpointer user_
|
||||||
g_print ("\tid: %p\n", info->id);
|
g_print ("\tid: %p\n", info->id);
|
||||||
g_print ("\tchannel-path: \"%s\"\n", info->channel_path);
|
g_print ("\tchannel-path: \"%s\"\n", info->channel_path);
|
||||||
if (data->print_all) {
|
if (data->print_all) {
|
||||||
g_print ("%c\tclient-path: \"%s\"\n", MARK_CHANGE (0), info->client_path);
|
g_print ("\tdirection: \"%s\"\n", pinos_direction_as_string (info->direction));
|
||||||
g_print ("%c\towner-path: \"%s\"\n", MARK_CHANGE (1), info->owner_path);
|
g_print ("\tclient-path: \"%s\"\n", info->client_path);
|
||||||
print_formats ("possible-formats", info->possible_formats, MARK_CHANGE (2));
|
g_print ("%c\tport-path: \"%s\"\n", MARK_CHANGE (0), info->port_path);
|
||||||
g_print ("%c\tstate: \"%s\"\n", MARK_CHANGE (3), pinos_channel_state_as_string (info->state));
|
print_properties (info->properties, MARK_CHANGE (1));
|
||||||
|
g_print ("%c\tstate: \"%s\"\n", MARK_CHANGE (2), pinos_channel_state_as_string (info->state));
|
||||||
|
print_formats ("possible-formats", info->possible_formats, MARK_CHANGE (3));
|
||||||
print_formats ("format", info->format, MARK_CHANGE (4));
|
print_formats ("format", info->format, MARK_CHANGE (4));
|
||||||
print_properties (info->properties, MARK_CHANGE (5));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,20 +206,20 @@ dump_object (PinosContext *context, gpointer id, PinosSubscriptionFlags flags,
|
||||||
info_ready,
|
info_ready,
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
else if (flags & PINOS_SUBSCRIPTION_FLAG_SOURCE) {
|
else if (flags & PINOS_SUBSCRIPTION_FLAG_NODE) {
|
||||||
pinos_context_get_source_info_by_id (context,
|
pinos_context_get_node_info_by_id (context,
|
||||||
id,
|
|
||||||
PINOS_SOURCE_INFO_FLAGS_FORMATS,
|
|
||||||
dump_source_info,
|
|
||||||
NULL,
|
|
||||||
info_ready,
|
|
||||||
data);
|
|
||||||
}
|
|
||||||
else if (flags & PINOS_SUBSCRIPTION_FLAG_SINK) {
|
|
||||||
pinos_context_get_sink_info_by_id (context,
|
|
||||||
id,
|
id,
|
||||||
PINOS_SINK_INFO_FLAGS_FORMATS,
|
PINOS_NODE_INFO_FLAGS_NONE,
|
||||||
dump_sink_info,
|
dump_node_info,
|
||||||
|
NULL,
|
||||||
|
info_ready,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
else if (flags & PINOS_SUBSCRIPTION_FLAG_PORT) {
|
||||||
|
pinos_context_get_port_info_by_id (context,
|
||||||
|
id,
|
||||||
|
PINOS_PORT_INFO_FLAGS_FORMATS,
|
||||||
|
dump_port_info,
|
||||||
NULL,
|
NULL,
|
||||||
info_ready,
|
info_ready,
|
||||||
data);
|
data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue