Improve introspection

Add instrospection of client and source-output.
Add properties to source-output and to CreateSourceOutput/Input
Add helper to fill properties of context.
Add client-name to pinossrc and pinossink
Improve test-subscribe to show all new introspection details.
This commit is contained in:
Wim Taymans 2015-07-28 17:05:03 +02:00
parent 85e09e7a5b
commit 13d846ec38
21 changed files with 684 additions and 72 deletions

View file

@ -255,11 +255,12 @@ on_socket_notify (GObject *gobject,
}
static PinosSourceOutput *
client_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
client_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
PinosProperties *props,
const gchar *prefix,
GError **error)
{
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
PinosSourceOutput *output;
@ -271,6 +272,7 @@ client_create_source_output (PinosSource *source,
->create_source_output (source,
client_path,
format_filter,
props,
prefix,
error);
@ -355,6 +357,7 @@ PinosSourceOutput *
pinos_client_source_get_source_input (PinosClientSource *source,
const gchar *client_path,
GBytes *format_filter,
PinosProperties *props,
const gchar *prefix,
GError **error)
{
@ -373,6 +376,7 @@ pinos_client_source_get_source_input (PinosClientSource *source,
->create_source_output (PINOS_SOURCE (source),
client_path,
format_filter,
props,
prefix,
error);
if (priv->input == NULL)

View file

@ -69,6 +69,7 @@ PinosSource * pinos_client_source_new (PinosDaemon *daemon,
PinosSourceOutput * pinos_client_source_get_source_input (PinosClientSource *source,
const gchar *client_path,
GBytes *format_filter,
PinosProperties *props,
const gchar *prefix,
GError **error);

View file

@ -143,6 +143,7 @@ handle_create_source_output (PinosClient1 *interface,
GDBusMethodInvocation *invocation,
const gchar *arg_source,
const gchar *arg_accepted_formats,
GVariant *arg_properties,
gpointer user_data)
{
PinosClient *client = user_data;
@ -151,6 +152,7 @@ handle_create_source_output (PinosClient1 *interface,
PinosSourceOutput *output;
const gchar *object_path, *sender;
GBytes *formats;
PinosProperties *props;
GError *error = NULL;
sender = g_dbus_method_invocation_get_sender (invocation);
@ -158,10 +160,11 @@ handle_create_source_output (PinosClient1 *interface,
goto not_allowed;
formats = g_bytes_new (arg_accepted_formats, strlen (arg_accepted_formats) + 1);
props = pinos_properties_from_variant (arg_properties);
source = pinos_daemon_find_source (priv->daemon,
arg_source,
priv->properties,
props,
formats,
&error);
if (source == NULL)
@ -170,6 +173,7 @@ handle_create_source_output (PinosClient1 *interface,
output = pinos_source_create_source_output (source,
priv->object_path,
formats,
props,
priv->object_path,
&error);
if (output == NULL)
@ -216,6 +220,7 @@ static gboolean
handle_create_source_input (PinosClient1 *interface,
GDBusMethodInvocation *invocation,
const gchar *arg_possible_formats,
GVariant *arg_properties,
gpointer user_data)
{
PinosClient *client = user_data;
@ -225,12 +230,14 @@ handle_create_source_input (PinosClient1 *interface,
const gchar *source_input_path, *sender;
GBytes *formats;
GError *error = NULL;
PinosProperties *props;
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_possible_formats, strlen (arg_possible_formats) + 1);
props = pinos_properties_from_variant (arg_properties);
source = pinos_client_source_new (priv->daemon, formats);
if (source == NULL)
@ -243,10 +250,10 @@ handle_create_source_input (PinosClient1 *interface,
sender = g_dbus_method_invocation_get_sender (invocation);
input = pinos_client_source_get_source_input (PINOS_CLIENT_SOURCE (source),
priv->object_path,
formats,
props,
priv->object_path,
&error);
if (input == NULL)
@ -279,6 +286,7 @@ no_source:
g_dbus_method_invocation_return_dbus_error (invocation,
"org.pinos.Error", "Can't create source");
g_bytes_unref (formats);
pinos_properties_free (props);
return TRUE;
}
no_input:
@ -286,6 +294,7 @@ no_input:
g_dbus_method_invocation_return_gerror (invocation, error);
g_clear_error (&error);
g_bytes_unref (formats);
pinos_properties_free (props);
return TRUE;
}
}
@ -318,6 +327,7 @@ client_register_object (PinosClient *client,
priv->client1 = pinos_client1_skeleton_new ();
pinos_client1_set_name (priv->client1, priv->sender);
pinos_client1_set_properties (priv->client1, pinos_properties_to_variant (priv->properties));
g_signal_connect (priv->client1, "handle-create-source-output",
(GCallback) handle_create_source_output,
client);

View file

@ -39,6 +39,7 @@ struct _PinosSourceOutputPrivate
gchar *source_path;
GBytes *possible_formats;
PinosProperties *properties;
GBytes *requested_format;
GBytes *format;
@ -58,6 +59,7 @@ enum
PROP_CLIENT_PATH,
PROP_SOURCE_PATH,
PROP_POSSIBLE_FORMATS,
PROP_PROPERTIES,
PROP_REQUESTED_FORMAT,
PROP_FORMAT,
PROP_SOCKET,
@ -101,6 +103,10 @@ pinos_source_output_get_property (GObject *_object,
g_value_set_boxed (value, priv->possible_formats);
break;
case PROP_PROPERTIES:
g_value_set_boxed (value, priv->properties);
break;
case PROP_REQUESTED_FORMAT:
g_value_set_boxed (value, priv->requested_format);
break;
@ -155,6 +161,14 @@ pinos_source_output_set_property (GObject *_object,
g_bytes_get_data (priv->possible_formats, NULL), NULL);
break;
case PROP_PROPERTIES:
if (priv->properties)
pinos_properties_free (priv->properties);
priv->properties = g_value_dup_boxed (value);
g_object_set (priv->iface, "properties",
pinos_properties_to_variant (priv->properties), NULL);
break;
case PROP_FORMAT:
if (priv->format)
g_bytes_unref (priv->format);
@ -389,6 +403,16 @@ pinos_source_output_class_init (PinosSourceOutputClass * klass)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_PROPERTIES,
g_param_spec_boxed ("properties",
"Properties",
"Extra properties of the stream",
PINOS_TYPE_PROPERTIES,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
PROP_REQUESTED_FORMAT,
g_param_spec_boxed ("requested-format",

View file

@ -236,11 +236,12 @@ handle_remove_output (PinosSourceOutput *output,
}
static PinosSourceOutput *
default_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
default_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
PinosProperties *props,
const gchar *prefix,
GError **error)
{
PinosSourcePrivate *priv = source->priv;
PinosSourceOutput *output;
@ -250,6 +251,7 @@ default_create_source_output (PinosSource *source,
"client-path", client_path,
"source-path", priv->object_path,
"possible-formats", format_filter,
"properties", props,
NULL);
g_signal_connect (output,
@ -482,17 +484,19 @@ pinos_source_update_possible_formats (PinosSource *source, GBytes *formats)
g_return_if_fail (PINOS_IS_SOURCE (source));
priv = source->priv;
g_object_set (priv->iface, "possible-formats",
g_bytes_get_data (formats, NULL),
NULL);
if (priv->iface)
g_object_set (priv->iface, "possible-formats",
g_bytes_get_data (formats, NULL),
NULL);
}
PinosSourceOutput *
pinos_source_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
pinos_source_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
PinosProperties *props,
const gchar *prefix,
GError **error)
{
PinosSourceClass *klass;
PinosSourceOutput *res;
@ -502,7 +506,7 @@ pinos_source_create_source_output (PinosSource *source,
klass = PINOS_SOURCE_GET_CLASS (source);
if (klass->create_source_output) {
res = klass->create_source_output (source, client_path, format_filter, prefix, error);
res = klass->create_source_output (source, client_path, format_filter, props, prefix, error);
} else {
if (error) {
*error = g_error_new (G_IO_ERROR,

View file

@ -68,11 +68,12 @@ struct _PinosSourceClass {
gboolean (*set_state) (PinosSource *source, PinosSourceState);
PinosSourceOutput * (*create_source_output) (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error);
PinosSourceOutput * (*create_source_output) (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
PinosProperties *props,
const gchar *prefix,
GError **error);
gboolean (*release_source_output) (PinosSource *source,
PinosSourceOutput *output);
};
@ -92,11 +93,12 @@ void pinos_source_report_busy (PinosSource *source);
void pinos_source_update_possible_formats (PinosSource *source, GBytes *formats);
PinosSourceOutput * pinos_source_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error);
PinosSourceOutput * pinos_source_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
PinosProperties *props,
const gchar *prefix,
GError **error);
gboolean pinos_source_release_source_output (PinosSource *source,
PinosSourceOutput *output);