source-output -> channel

Rename the source-output object to channel because it is used for both
input and output.
Start the beginnings of sink support. This will make it possible to make
pinos consume data as well as provide data.
This commit is contained in:
Wim Taymans 2016-05-03 18:00:56 +02:00
parent 76afc1e330
commit 7597e48e02
23 changed files with 954 additions and 633 deletions

View file

@ -148,8 +148,9 @@ pinos_context_finalize (GObject * object)
pinos_properties_free (priv->properties);
g_list_free (priv->sources);
g_list_free (priv->sinks);
g_list_free (priv->clients);
g_list_free (priv->source_outputs);
g_list_free (priv->channels);
g_clear_object (&priv->subscribe);
g_clear_error (&priv->error);
@ -494,11 +495,18 @@ subscription_cb (PinosSubscribe *subscribe,
priv->sources = g_list_remove (priv->sources, object);
break;
case PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT:
case PINOS_SUBSCRIPTION_FLAG_SINK:
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
priv->source_outputs = g_list_prepend (priv->source_outputs, object);
priv->sinks = g_list_prepend (priv->sinks, object);
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
priv->source_outputs = g_list_remove (priv->source_outputs, object);
priv->sinks = g_list_remove (priv->sinks, object);
break;
case PINOS_SUBSCRIPTION_FLAG_CHANNEL:
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
priv->channels = g_list_prepend (priv->channels, object);
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
priv->channels = g_list_remove (priv->channels, object);
break;
}

View file

@ -404,71 +404,69 @@ pinos_context_get_source_info_by_id (PinosContext *context,
}
/**
* pinos_source_output_state_as_string:
* @state: a #PinosSourceOutputState
* pinos_sink_state_as_string:
* @state: a #PinosSinkState
*
* Return the string representation of @state.
*
* Returns: the string representation of @state.
*/
const gchar *
pinos_source_output_state_as_string (PinosSourceOutputState state)
pinos_sink_state_as_string (PinosSinkState state)
{
GEnumValue *val;
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_SOURCE_OUTPUT_STATE)),
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_SINK_STATE)),
state);
return val == NULL ? "invalid-state" : val->value_nick;
}
static void
source_output_fill_info (PinosSourceOutputInfo *info, GDBusProxy *proxy)
sink_fill_info (PinosSinkInfo *info, GDBusProxy *proxy)
{
GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties");
info->id = proxy;
info->output_path = g_dbus_proxy_get_object_path (proxy);
info->sink_path = g_dbus_proxy_get_object_path (proxy);
info->change_mask = 0;
SET_STRING ("Client", client_path, 0);
SET_STRING ("Source", source_path, 1);
SET_BYTES ("PossibleFormats", possible_formats, 2);
SET_UINT32 ("State", state, 3, PINOS_SOURCE_OUTPUT_STATE_ERROR);
SET_BYTES ("Format", format, 4);
SET_PROPERTIES ("Properties", properties, 5);
SET_STRING ("Name", name, 0);
SET_PROPERTIES ("Properties", properties, 1);
SET_UINT32 ("State", state, 2, PINOS_SINK_STATE_ERROR);
SET_BYTES ("PossibleFormats", possible_formats, 3);
if (changed)
g_hash_table_remove_all (changed);
}
static void
source_output_clear_info (PinosSourceOutputInfo *info)
sink_clear_info (PinosSinkInfo *info)
{
if (info->possible_formats)
g_bytes_unref (info->possible_formats);
if (info->properties)
pinos_properties_free (info->properties);
if (info->possible_formats)
g_bytes_unref (info->possible_formats);
}
/**
* pinos_context_list_source_output_info:
* pinos_context_list_sink_info:
* @context: a connected #PinosContext
* @flags: extra #PinosSourceOutputInfoFlags
* @cb: a #PinosSourceOutputInfoCallback
* @flags: extra #PinosSinkInfoFlags
* @cb: a #PinosSinkInfoCallback
* @cancelable: a #GCancellable
* @callback: a #GAsyncReadyCallback to call when the operation is finished
* @user_data: user data passed to @cb
*
* Call @cb for each source-output.
* Call @cb for each sink.
*/
void
pinos_context_list_source_output_info (PinosContext *context,
PinosSourceOutputInfoFlags flags,
PinosSourceOutputInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
pinos_context_list_sink_info (PinosContext *context,
PinosSinkInfoFlags flags,
PinosSinkInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
PinosContextPrivate *priv;
GList *walk;
@ -481,13 +479,13 @@ pinos_context_list_source_output_info (PinosContext *context,
priv = context->priv;
for (walk = priv->source_outputs; walk; walk = g_list_next (walk)) {
for (walk = priv->sinks; walk; walk = g_list_next (walk)) {
GDBusProxy *proxy = walk->data;
PinosSourceOutputInfo info;
PinosSinkInfo info;
source_output_fill_info (&info, proxy);
sink_fill_info (&info, proxy);
cb (context, &info, user_data);
source_output_clear_info (&info);
sink_clear_info (&info);
}
g_task_return_boolean (task, TRUE);
@ -495,27 +493,27 @@ pinos_context_list_source_output_info (PinosContext *context,
}
/**
* pinos_context_get_source_output_info_by_id:
* pinos_context_get_sink_info_by_id:
* @context: a connected #PinosContext
* @id: a source output id
* @flags: extra #PinosSourceOutputInfoFlags
* @cb: a #PinosSourceOutputInfoCallback
* @id: a sink id
* @flags: extra #PinosSinkInfoFlags
* @cb: a #PinosSinkInfoCallback
* @cancelable: a #GCancellable
* @callback: a #GAsyncReadyCallback to call when the operation is finished
* @user_data: user data passed to @cb
*
* Call @cb for the source output with @id.
* Call @cb for the sink with @id.
*/
void
pinos_context_get_source_output_info_by_id (PinosContext *context,
gpointer id,
PinosSourceOutputInfoFlags flags,
PinosSourceOutputInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
pinos_context_get_sink_info_by_id (PinosContext *context,
gpointer id,
PinosSinkInfoFlags flags,
PinosSinkInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
PinosSourceOutputInfo info;
PinosSinkInfo info;
GDBusProxy *proxy;
GTask *task;
@ -527,9 +525,141 @@ pinos_context_get_source_output_info_by_id (PinosContext *context,
proxy = G_DBUS_PROXY (id);
source_output_fill_info (&info, proxy);
sink_fill_info (&info, proxy);
cb (context, &info, user_data);
source_output_clear_info (&info);
sink_clear_info (&info);
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
/**
* pinos_channel_state_as_string:
* @state: a #PinosChannelState
*
* Return the string representation of @state.
*
* Returns: the string representation of @state.
*/
const gchar *
pinos_channel_state_as_string (PinosChannelState state)
{
GEnumValue *val;
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_CHANNEL_STATE)),
state);
return val == NULL ? "invalid-state" : val->value_nick;
}
static void
channel_fill_info (PinosChannelInfo *info, GDBusProxy *proxy)
{
GHashTable *changed = g_object_get_data (G_OBJECT (proxy), "pinos-changed-properties");
info->id = proxy;
info->channel_path = g_dbus_proxy_get_object_path (proxy);
info->change_mask = 0;
SET_STRING ("Client", client_path, 0);
SET_STRING ("Owner", owner_path, 1);
SET_BYTES ("PossibleFormats", possible_formats, 2);
SET_UINT32 ("State", state, 3, PINOS_CHANNEL_STATE_ERROR);
SET_BYTES ("Format", format, 4);
SET_PROPERTIES ("Properties", properties, 5);
if (changed)
g_hash_table_remove_all (changed);
}
static void
channel_clear_info (PinosChannelInfo *info)
{
if (info->possible_formats)
g_bytes_unref (info->possible_formats);
if (info->properties)
pinos_properties_free (info->properties);
}
/**
* pinos_context_list_channel_info:
* @context: a connected #PinosContext
* @flags: extra #PinosChannelInfoFlags
* @cb: a #PinosChannelInfoCallback
* @cancelable: a #GCancellable
* @callback: a #GAsyncReadyCallback to call when the operation is finished
* @user_data: user data passed to @cb
*
* Call @cb for each channel.
*/
void
pinos_context_list_channel_info (PinosContext *context,
PinosChannelInfoFlags flags,
PinosChannelInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
PinosContextPrivate *priv;
GList *walk;
GTask *task;
g_return_if_fail (PINOS_IS_CONTEXT (context));
g_return_if_fail (cb != NULL);
task = g_task_new (context, cancellable, callback, user_data);
priv = context->priv;
for (walk = priv->channels; walk; walk = g_list_next (walk)) {
GDBusProxy *proxy = walk->data;
PinosChannelInfo info;
channel_fill_info (&info, proxy);
cb (context, &info, user_data);
channel_clear_info (&info);
}
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
/**
* pinos_context_get_channel_info_by_id:
* @context: a connected #PinosContext
* @id: a source output id
* @flags: extra #PinosChannelInfoFlags
* @cb: a #PinosChannelInfoCallback
* @cancelable: a #GCancellable
* @callback: a #GAsyncReadyCallback to call when the operation is finished
* @user_data: user data passed to @cb
*
* Call @cb for the channel with @id.
*/
void
pinos_context_get_channel_info_by_id (PinosContext *context,
gpointer id,
PinosChannelInfoFlags flags,
PinosChannelInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
PinosChannelInfo info;
GDBusProxy *proxy;
GTask *task;
g_return_if_fail (PINOS_IS_CONTEXT (context));
g_return_if_fail (id != NULL);
g_return_if_fail (cb != NULL);
task = g_task_new (context, cancellable, callback, user_data);
proxy = G_DBUS_PROXY (id);
channel_fill_info (&info, proxy);
cb (context, &info, user_data);
channel_clear_info (&info);
g_task_return_boolean (task, TRUE);
g_object_unref (task);

View file

@ -151,7 +151,7 @@ void pinos_context_get_client_info_by_id (PinosContext *context,
* @PINOS_SOURCE_STATE_INITIALIZING: the source is initializing, the device is
* being opened and the capabilities are queried
* @PINOS_SOURCE_STATE_IDLE: the source is running but there is no active
* source-output
* channel
* @PINOS_SOURCE_STATE_RUNNING: the source is running
*
* The different source states
@ -228,86 +228,189 @@ void pinos_context_get_source_info_by_id (PinosContext *context,
gpointer user_data);
/**
* PinosSourceState:
* @PINOS_SOURCE_OUTPUT_STATE_ERROR: the source output is in error
* @PINOS_SOURCE_OUTPUT_STATE_IDLE: the source output is idle
* @PINOS_SOURCE_OUTPUT_STATE_STARTING: the source output is starting
* @PINOS_SOURCE_OUTPUT_STATE_STREAMING: the source output is streaming
* 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
* @PINOS_SINK_STATE_RUNNING: the sink is running
*
* The different source output states
* The different sink states
*/
typedef enum {
PINOS_SOURCE_OUTPUT_STATE_ERROR = -1,
PINOS_SOURCE_OUTPUT_STATE_IDLE = 0,
PINOS_SOURCE_OUTPUT_STATE_STARTING = 1,
PINOS_SOURCE_OUTPUT_STATE_STREAMING = 2,
} PinosSourceOutputState;
PINOS_SINK_STATE_ERROR = -1,
PINOS_SINK_STATE_SUSPENDED = 0,
PINOS_SINK_STATE_INITIALIZING = 1,
PINOS_SINK_STATE_IDLE = 2,
PINOS_SINK_STATE_RUNNING = 3,
} PinosSinkState;
const gchar * pinos_source_output_state_as_string (PinosSourceOutputState state);
const gchar * pinos_sink_state_as_string (PinosSinkState state);
/**
* PinosSourceOutputInfo:
* @id: generic id of the output
* @path: the unique path of the output
* PinosSinkInfo:
* @id: generic id of the sink
* @sink_path: the unique path of the sink, suitable for connecting
* @change_mask: bitfield of changed fields since last call
* @client_path: the owner client
* @source_path: the source path
* @possible_formats: the possible formats
* @state: the state
* @format: when streaming, the current format
* @properties: the properties of the source
* @name: name the sink, suitable for display
* @properties: the properties of the sink
* @state: the current state of the sink
* @possible formats: the possible formats this sink can consume
*
* The source information. Extra information can be added in later
* The sink information. Extra information can be added in later
* versions.
*/
typedef struct {
gpointer id;
const char *output_path;
const char *sink_path;
guint64 change_mask;
const char *client_path;
const char *source_path;
GBytes *possible_formats;
PinosSourceOutputState state;
GBytes *format;
const char *name;
PinosProperties *properties;
} PinosSourceOutputInfo;
PinosSinkState state;
GBytes *possible_formats;
} PinosSinkInfo;
/**
* PinosSourceOutputInfoFlags:
* @PINOS_SOURCE_OUTPUT_INFO_FLAGS_NONE: no flags
* PinosSinkInfoFlags:
* @PINOS_SINK_INFO_FLAGS_NONE: no flags
* @PINOS_SINK_INFO_FLAGS_FORMATS: include formats
*
* Extra flags to pass to pinos_context_list_source_output_info() and
* pinos_context_get_source_output_info_by_id().
* Extra flags to pass to pinos_context_get_sink_info_list.
*/
typedef enum {
PINOS_SOURCE_OUTPUT_INFO_FLAGS_NONE = 0,
} PinosSourceOutputInfoFlags;
PINOS_SINK_INFO_FLAGS_NONE = 0,
PINOS_SINK_INFO_FLAGS_FORMATS = (1 << 0)
} PinosSinkInfoFlags;
/**
* PinosSourceOutputInfoCallback:
* PinosSinkInfoCallback:
* @c: a #PinosContext
* @info: a #PinosSourceOutputInfo
* @info: a #PinosSinkInfo
* @user_data: user data
*
* Callback with information about the Pinos source output in @info.
* Callback with information about the Pinos sink in @info.
*/
typedef void (*PinosSourceOutputInfoCallback) (PinosContext *c,
const PinosSourceOutputInfo *info,
gpointer user_data);
typedef void (*PinosSinkInfoCallback) (PinosContext *c,
const PinosSinkInfo *info,
gpointer user_data);
void pinos_context_list_source_output_info (PinosContext *context,
PinosSourceOutputInfoFlags flags,
PinosSourceOutputInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
void pinos_context_get_source_output_info_by_id (PinosContext *context,
gpointer id,
PinosSourceOutputInfoFlags flags,
PinosSourceOutputInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
void pinos_context_list_sink_info (PinosContext *context,
PinosSinkInfoFlags flags,
PinosSinkInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
void pinos_context_get_sink_info_by_id (PinosContext *context,
gpointer id,
PinosSinkInfoFlags flags,
PinosSinkInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
/**
* PinosChannelType:
* @PINOS_CHANNEL_TYPE_UNKNOWN: an unknown channel type
* @PINOS_CHANNEL_TYPE_INPUT: an input channel type
* @PINOS_CHANNEL_TYPE_OUTPUT: an output channel type
*
* The different channel states
*/
typedef enum {
PINOS_CHANNEL_TYPE_UNKNOWN = 0,
PINOS_CHANNEL_TYPE_INPUT = 1,
PINOS_CHANNEL_TYPE_OUTPUT = 2,
} PinosChannelType;
/**
* PinosChannelState:
* @PINOS_CHANNEL_STATE_ERROR: the channel is in error
* @PINOS_CHANNEL_STATE_IDLE: the channel is idle
* @PINOS_CHANNEL_STATE_STARTING: the channel is starting
* @PINOS_CHANNEL_STATE_STREAMING: the channel is streaming
*
* The different channel states
*/
typedef enum {
PINOS_CHANNEL_STATE_ERROR = -1,
PINOS_CHANNEL_STATE_IDLE = 0,
PINOS_CHANNEL_STATE_STARTING = 1,
PINOS_CHANNEL_STATE_STREAMING = 2,
} PinosChannelState;
const gchar * pinos_channel_state_as_string (PinosChannelState state);
/**
* PinosChannelInfo:
* @id: generic id of the channel_
* @channel_path: the unique path of the channel
* @change_mask: bitfield of changed fields since last call
* @client_path: the owner client
* @owner_path: the owner source or sink path
* @type: the channel type
* @possible_formats: the possible formats
* @state: the state
* @format: when streaming, the current format
* @properties: the properties of the channel
*
* The channel information. Extra information can be added in later
* versions.
*/
typedef struct {
gpointer id;
const char *channel_path;
guint64 change_mask;
const char *client_path;
const char *owner_path;
PinosChannelType type;
GBytes *possible_formats;
PinosChannelState state;
GBytes *format;
PinosProperties *properties;
} PinosChannelInfo;
/**
* PinosChannelInfoFlags:
* @PINOS_CHANNEL_INFO_FLAGS_NONE: no flags
* @PINOS_CHANNEL_INFO_FLAGS_NO_SOURCE: don't list source channels
* @PINOS_CHANNEL_INFO_FLAGS_NO_SINK: don't list sink channels
*
* Extra flags to pass to pinos_context_list_channel_info() and
* pinos_context_get_channel_info_by_id().
*/
typedef enum {
PINOS_CHANNEL_INFO_FLAGS_NONE = 0,
PINOS_CHANNEL_INFO_FLAGS_NO_SOURCE = (1 << 0),
PINOS_CHANNEL_INFO_FLAGS_NO_SINK = (1 << 1),
} PinosChannelInfoFlags;
/**
* PinosChannelInfoCallback:
* @c: a #PinosContext
* @info: a #PinosChannelInfo
* @user_data: user data
*
* Callback with information about the Pinos channel in @info.
*/
typedef void (*PinosChannelInfoCallback) (PinosContext *c,
const PinosChannelInfo *info,
gpointer user_data);
void pinos_context_list_channel_info (PinosContext *context,
PinosChannelInfoFlags flags,
PinosChannelInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
void pinos_context_get_channel_info_by_id (PinosContext *context,
gpointer id,
PinosChannelInfoFlags flags,
PinosChannelInfoCallback cb,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
G_END_DECLS
#endif /* __PINOS_INTROSPECT_H__ */

View file

@ -41,7 +41,8 @@ struct _PinosContextPrivate
GList *clients;
GList *sources;
GList *source_outputs;
GList *sinks;
GList *channels;
};
void pinos_subscribe_get_proxy (PinosSubscribe *subscribe,

View file

@ -40,13 +40,12 @@ struct _PinosStreamPrivate
GError *error;
gchar *source_path;
GBytes *accepted_formats;
GBytes *possible_formats;
gboolean provide;
GBytes *possible_formats;
GBytes *format;
GDBusProxy *source_output;
GDBusProxy *channel;
gboolean disconnecting;
PinosStreamMode mode;
@ -194,9 +193,9 @@ subscription_cb (PinosSubscribe *subscribe,
PinosStreamPrivate *priv = stream->priv;
switch (flags) {
case PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT:
case PINOS_SUBSCRIPTION_FLAG_CHANNEL:
if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
if (object == priv->source_output && !priv->disconnecting) {
if (object == priv->channel && !priv->disconnecting) {
stream_set_state (stream,
PINOS_STREAM_STATE_ERROR,
g_error_new_literal (G_IO_ERROR,
@ -234,7 +233,7 @@ pinos_stream_finalize (GObject * object)
g_debug ("free stream %p", stream);
g_clear_object (&priv->socket);
g_clear_object (&priv->source_output);
g_clear_object (&priv->channel);
if (priv->possible_formats)
g_bytes_unref (priv->possible_formats);
@ -242,8 +241,8 @@ pinos_stream_finalize (GObject * object)
g_bytes_unref (priv->format);
g_free (priv->source_path);
if (priv->accepted_formats)
g_bytes_unref (priv->accepted_formats);
if (priv->possible_formats)
g_bytes_unref (priv->possible_formats);
g_clear_error (&priv->error);
@ -491,9 +490,9 @@ pinos_stream_get_error (PinosStream *stream)
}
static void
on_source_output_proxy (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
on_channel_proxy (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
PinosStream *stream = user_data;
PinosStreamPrivate *priv = stream->priv;
@ -502,14 +501,14 @@ on_source_output_proxy (GObject *source_object,
gchar *str;
GError *error = NULL;
priv->source_output = pinos_subscribe_get_proxy_finish (context->priv->subscribe,
priv->channel = pinos_subscribe_get_proxy_finish (context->priv->subscribe,
res,
&error);
if (priv->source_output == NULL)
goto source_output_failed;
if (priv->channel == NULL)
goto channel_failed;
/* get the source we are connected to */
v = g_dbus_proxy_get_cached_property (priv->source_output, "Source");
v = g_dbus_proxy_get_cached_property (priv->channel, "Source");
if (v) {
gsize len;
str = g_variant_dup_string (v, &len);
@ -519,7 +518,7 @@ on_source_output_proxy (GObject *source_object,
priv->source_path = str;
}
v = g_dbus_proxy_get_cached_property (priv->source_output, "PossibleFormats");
v = g_dbus_proxy_get_cached_property (priv->channel, "PossibleFormats");
if (v) {
gsize len;
str = g_variant_dup_string (v, &len);
@ -531,7 +530,7 @@ on_source_output_proxy (GObject *source_object,
g_object_notify (G_OBJECT (stream), "possible-formats");
}
v = g_dbus_proxy_get_cached_property (priv->source_output, "Properties");
v = g_dbus_proxy_get_cached_property (priv->channel, "Properties");
if (v) {
if (priv->properties)
pinos_properties_free (priv->properties);
@ -546,9 +545,9 @@ on_source_output_proxy (GObject *source_object,
return;
source_output_failed:
channel_failed:
{
g_warning ("failed to get source output proxy: %s", error->message);
g_warning ("failed to get channel proxy: %s", error->message);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR, error);
g_object_unref (stream);
return;
@ -556,16 +555,16 @@ source_output_failed:
}
static void
on_source_output_created (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
on_channel_created (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
PinosStream *stream = user_data;
PinosStreamPrivate *priv = stream->priv;
PinosContext *context = priv->context;
GVariant *ret;
GError *error = NULL;
const gchar *source_output_path;
const gchar *channel_path;
g_assert (context->priv->client == G_DBUS_PROXY (source_object));
@ -573,14 +572,14 @@ on_source_output_created (GObject *source_object,
if (ret == NULL)
goto create_failed;
g_variant_get (ret, "(&o)", &source_output_path);
g_variant_get (ret, "(&o)", &channel_path);
pinos_subscribe_get_proxy (context->priv->subscribe,
PINOS_DBUS_SERVICE,
source_output_path,
"org.pinos.SourceOutput1",
channel_path,
"org.pinos.Channel1",
NULL,
on_source_output_proxy,
on_channel_proxy,
stream);
g_variant_unref (ret);
@ -597,48 +596,48 @@ create_failed:
}
static gboolean
do_connect_capture (PinosStream *stream)
do_connect_source (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
PinosContext *context = priv->context;
g_dbus_proxy_call (context->priv->client,
"CreateSourceOutput",
"CreateSourceChannel",
g_variant_new ("(ss@a{sv})",
(priv->source_path ? priv->source_path : ""),
g_bytes_get_data (priv->accepted_formats, NULL),
g_bytes_get_data (priv->possible_formats, NULL),
pinos_properties_to_variant (priv->properties)),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, /* GCancellable *cancellable */
on_source_output_created,
on_channel_created,
stream);
return FALSE;
}
/**
* pinos_stream_connect_capture:
* pinos_stream_connect_source:
* @stream: a #PinosStream
* @source_path: the source path to connect to
* @flags: a #PinosStreamFlags
* @accepted_formats: (transfer full): a #GBytes with accepted formats
* @possible_formats: (transfer full): a #GBytes with possible accepted formats
*
* Connect @stream for capturing from @source_path.
*
* Returns: %TRUE on success.
*/
gboolean
pinos_stream_connect_capture (PinosStream *stream,
const gchar *source_path,
PinosStreamFlags flags,
GBytes *accepted_formats)
pinos_stream_connect_source (PinosStream *stream,
const gchar *source_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 (accepted_formats != NULL, FALSE);
g_return_val_if_fail (possible_formats != NULL, FALSE);
priv = stream->priv;
context = priv->context;
@ -647,15 +646,15 @@ pinos_stream_connect_capture (PinosStream *stream,
g_free (priv->source_path);
priv->source_path = g_strdup (source_path);
if (priv->accepted_formats)
g_bytes_unref (priv->accepted_formats);
priv->accepted_formats = accepted_formats;
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_capture,
(GSourceFunc) do_connect_source,
g_object_ref (stream));
return TRUE;
@ -668,14 +667,14 @@ do_connect_provide (PinosStream *stream)
PinosContext *context = priv->context;
g_dbus_proxy_call (context->priv->client,
"CreateSourceInput",
"CreateUploadChannel",
g_variant_new ("(s@a{sv})",
g_bytes_get_data (priv->possible_formats, NULL),
pinos_properties_to_variant (priv->properties)),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, /* GCancellable *cancellable */
on_source_output_created,
on_channel_created,
stream);
return FALSE;
@ -721,7 +720,7 @@ pinos_stream_connect_provide (PinosStream *stream,
}
static void
on_source_output_removed (GObject *source_object,
on_channel_removed (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
@ -730,10 +729,10 @@ on_source_output_removed (GObject *source_object,
GVariant *ret;
GError *error = NULL;
g_assert (priv->source_output == G_DBUS_PROXY (source_object));
g_assert (priv->channel == G_DBUS_PROXY (source_object));
priv->disconnecting = FALSE;
g_clear_object (&priv->source_output);
g_clear_object (&priv->channel);
ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
if (ret == NULL)
@ -760,13 +759,13 @@ do_disconnect (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
g_dbus_proxy_call (priv->source_output,
g_dbus_proxy_call (priv->channel,
"Remove",
g_variant_new ("()"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, /* GCancellable *cancellable */
on_source_output_removed,
on_channel_removed,
stream);
return FALSE;
@ -789,7 +788,7 @@ pinos_stream_disconnect (PinosStream *stream)
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state >= PINOS_STREAM_STATE_READY, FALSE);
g_return_val_if_fail (priv->source_output != NULL, FALSE);
g_return_val_if_fail (priv->channel != NULL, FALSE);
context = priv->context;
g_return_val_if_fail (pinos_context_get_state (context) >= PINOS_CONTEXT_STATE_READY, FALSE);
g_return_val_if_fail (!priv->disconnecting, FALSE);
@ -975,7 +974,7 @@ on_stream_started (GObject *source_object,
GError *error = NULL;
GVariant *result, *properties;
result = g_dbus_proxy_call_with_unix_fd_list_finish (priv->source_output,
result = g_dbus_proxy_call_with_unix_fd_list_finish (priv->channel,
&out_fd_list,
res,
&error);
@ -1039,7 +1038,7 @@ do_start (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
g_dbus_proxy_call (priv->source_output,
g_dbus_proxy_call (priv->channel,
"Start",
g_variant_new ("(s)", g_bytes_get_data (priv->format, NULL)),
G_DBUS_CALL_FLAGS_NONE,
@ -1102,7 +1101,7 @@ on_stream_stopped (GObject *source_object,
GVariant *ret;
GError *error = NULL;
ret = g_dbus_proxy_call_finish (priv->source_output, res, &error);
ret = g_dbus_proxy_call_finish (priv->channel, res, &error);
if (ret == NULL)
goto call_failed;
@ -1132,7 +1131,7 @@ do_stop (PinosStream *stream)
{
PinosStreamPrivate *priv = stream->priv;
g_dbus_proxy_call (priv->source_output,
g_dbus_proxy_call (priv->channel,
"Stop",
g_variant_new ("()"),
G_DBUS_CALL_FLAGS_NONE,

View file

@ -91,10 +91,14 @@ PinosStream * pinos_stream_new (PinosContext *context,
PinosStreamState pinos_stream_get_state (PinosStream *stream);
const GError * pinos_stream_get_error (PinosStream *stream);
gboolean pinos_stream_connect_capture (PinosStream *stream,
gboolean pinos_stream_connect_source (PinosStream *stream,
const gchar *source_path,
PinosStreamFlags flags,
GBytes *accepted_formats);
GBytes *possible_formats);
gboolean pinos_stream_connect_sink (PinosStream *stream,
const gchar *sink_path,
PinosStreamFlags flags,
GBytes *possible_formats);
gboolean pinos_stream_connect_provide (PinosStream *stream,
PinosStreamFlags flags,
GBytes *possible_formats);

View file

@ -108,8 +108,11 @@ notify_event (PinosSubscribe *subscribe,
else if (g_strcmp0 (interface_name, "org.pinos.Source1") == 0) {
flags = PINOS_SUBSCRIPTION_FLAG_SOURCE;
}
else if (g_strcmp0 (interface_name, "org.pinos.SourceOutput1") == 0) {
flags = PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT;
else if (g_strcmp0 (interface_name, "org.pinos.Sink1") == 0) {
flags = PINOS_SUBSCRIPTION_FLAG_SINK;
}
else if (g_strcmp0 (interface_name, "org.pinos.Channel1") == 0) {
flags = PINOS_SUBSCRIPTION_FLAG_CHANNEL;
}
g_signal_emit (subscribe, signals[SIGNAL_SUBSCRIPTION_EVENT], 0,
event, flags, data->proxy);

View file

@ -48,10 +48,11 @@ typedef enum {
PINOS_SUBSCRIPTION_FLAG_DAEMON = (1 << 0),
PINOS_SUBSCRIPTION_FLAG_CLIENT = (1 << 1),
PINOS_SUBSCRIPTION_FLAG_SOURCE = (1 << 2),
PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT = (1 << 3),
PINOS_SUBSCRIPTION_FLAG_SINK = (1 << 3),
PINOS_SUBSCRIPTION_FLAG_CHANNEL = (1 << 4),
} PinosSubscriptionFlags;
#define PINOS_SUBSCRIPTION_FLAGS_ALL 0xf
#define PINOS_SUBSCRIPTION_FLAGS_ALL 0x1f
typedef enum {
PINOS_SUBSCRIPTION_EVENT_NEW = 0,