more rename PV -> PINOS, Pv -> Pinos, pv -> pinos

This commit is contained in:
Wim Taymans 2015-07-07 16:46:23 +02:00
parent 0dd41f5e40
commit a3505fb880
46 changed files with 2333 additions and 2267 deletions

View file

@ -19,24 +19,23 @@
#include "client/pinos.h"
#include "client/pv-context.h"
#include "client/pv-enumtypes.h"
#include "client/pv-subscribe.h"
#include "client/context.h"
#include "client/enumtypes.h"
#include "client/subscribe.h"
#include "client/pv-private.h"
#include "client/private.h"
#define PV_CONTEXT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_CONTEXT, PvContextPrivate))
#define PINOS_CONTEXT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_CONTEXT, PinosContextPrivate))
G_DEFINE_TYPE (PvContext, pv_context, G_TYPE_OBJECT);
G_DEFINE_TYPE (PinosContext, pinos_context, G_TYPE_OBJECT);
static void subscription_state (GObject *object, GParamSpec *pspec, gpointer user_data);
static void
subscription_cb (PvSubscribe *subscribe,
PvSubscriptionEvent event,
PvSubscriptionFlags flags,
GDBusProxy *object,
gpointer user_data);
static void subscription_cb (PinosSubscribe *subscribe,
PinosSubscriptionEvent event,
PinosSubscriptionFlags flags,
GDBusProxy *object,
gpointer user_data);
enum
{
@ -58,13 +57,13 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
static void
pv_context_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
pinos_context_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PvContext *context = PV_CONTEXT (_object);
PvContextPrivate *priv = context->priv;
PinosContext *context = PINOS_CONTEXT (_object);
PinosContextPrivate *priv = context->priv;
switch (prop_id) {
case PROP_MAIN_CONTEXT:
@ -98,13 +97,13 @@ pv_context_get_property (GObject *_object,
}
static void
pv_context_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
pinos_context_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PvContext *context = PV_CONTEXT (_object);
PvContextPrivate *priv = context->priv;
PinosContext *context = PINOS_CONTEXT (_object);
PinosContextPrivate *priv = context->priv;
switch (prop_id) {
case PROP_MAIN_CONTEXT:
@ -133,10 +132,10 @@ pv_context_set_property (GObject *_object,
}
static void
pv_context_finalize (GObject * object)
pinos_context_finalize (GObject * object)
{
PvContext *context = PV_CONTEXT (object);
PvContextPrivate *priv = context->priv;
PinosContext *context = PINOS_CONTEXT (object);
PinosContextPrivate *priv = context->priv;
g_clear_pointer (&priv->context, g_main_context_unref);
g_free (priv->name);
@ -146,22 +145,22 @@ pv_context_finalize (GObject * object)
g_clear_object (&priv->subscribe);
g_clear_error (&priv->error);
G_OBJECT_CLASS (pv_context_parent_class)->finalize (object);
G_OBJECT_CLASS (pinos_context_parent_class)->finalize (object);
}
static void
pv_context_class_init (PvContextClass * klass)
pinos_context_class_init (PinosContextClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (PvContextPrivate));
g_type_class_add_private (klass, sizeof (PinosContextPrivate));
gobject_class->finalize = pv_context_finalize;
gobject_class->set_property = pv_context_set_property;
gobject_class->get_property = pv_context_get_property;
gobject_class->finalize = pinos_context_finalize;
gobject_class->set_property = pinos_context_set_property;
gobject_class->get_property = pinos_context_get_property;
/**
* PvContext:main-context
* PinosContext:main-context
*
* The main context to use
*/
@ -175,7 +174,7 @@ pv_context_class_init (PvContextClass * klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* PvContext:name
* PinosContext:name
*
* The application name of the context.
*/
@ -188,7 +187,7 @@ pv_context_class_init (PvContextClass * klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* PvContext:properties
* PinosContext:properties
*
* Properties of the context.
*/
@ -202,7 +201,7 @@ pv_context_class_init (PvContextClass * klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* PvContext:state
* PinosContext:state
*
* The state of the context.
*/
@ -211,12 +210,12 @@ pv_context_class_init (PvContextClass * klass)
g_param_spec_enum ("state",
"State",
"The context state",
PV_TYPE_CONTEXT_STATE,
PV_CONTEXT_STATE_UNCONNECTED,
PINOS_TYPE_CONTEXT_STATE,
PINOS_CONTEXT_STATE_UNCONNECTED,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* PvContext:connection
* PinosContext:connection
*
* The connection of the context.
*/
@ -229,7 +228,7 @@ pv_context_class_init (PvContextClass * klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* PvContext:subscription-mask
* PinosContext:subscription-mask
*
* The subscription mask
*/
@ -238,15 +237,15 @@ pv_context_class_init (PvContextClass * klass)
g_param_spec_flags ("subscription-mask",
"Subscription Mask",
"The object to receive subscription events of",
PV_TYPE_SUBSCRIPTION_FLAGS,
PINOS_TYPE_SUBSCRIPTION_FLAGS,
0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* PvContext:subscription-event
* @subscribe: The #PvContext emitting the signal.
* @event: A #PvSubscriptionEvent
* @flags: #PvSubscriptionFlags indicating the object
* PinosContext:subscription-event
* @subscribe: The #PinosContext emitting the signal.
* @event: A #PinosSubscriptionEvent
* @flags: #PinosSubscriptionFlags indicating the object
* @object: the GDBusProxy object
*
* Notify about a new object that was added/removed/modified.
@ -260,35 +259,37 @@ pv_context_class_init (PvContextClass * klass)
g_cclosure_marshal_generic,
G_TYPE_NONE,
3,
PV_TYPE_SUBSCRIPTION_EVENT,
PV_TYPE_SUBSCRIPTION_FLAGS,
PINOS_TYPE_SUBSCRIPTION_EVENT,
PINOS_TYPE_SUBSCRIPTION_FLAGS,
G_TYPE_DBUS_PROXY);
}
static void
pv_context_init (PvContext * context)
pinos_context_init (PinosContext * context)
{
PvContextPrivate *priv = context->priv = PV_CONTEXT_GET_PRIVATE (context);
PinosContextPrivate *priv = context->priv = PINOS_CONTEXT_GET_PRIVATE (context);
priv->state = PV_CONTEXT_STATE_UNCONNECTED;
priv->subscribe = pv_subscribe_new ();
g_object_set (priv->subscribe, "subscription-mask", PV_SUBSCRIPTION_FLAGS_ALL, NULL);
priv->state = PINOS_CONTEXT_STATE_UNCONNECTED;
priv->subscribe = pinos_subscribe_new ();
g_object_set (priv->subscribe, "subscription-mask", PINOS_SUBSCRIPTION_FLAGS_ALL, NULL);
g_signal_connect (priv->subscribe, "subscription-event", (GCallback) subscription_cb, context);
g_signal_connect (priv->subscribe, "notify::state", (GCallback) subscription_state, context);
}
/**
* pv_context_new:
* pinos_context_new:
* @name: an application name
* @properties: optional properties
*
* Make a new unconnected #PvContext
* Make a new unconnected #PinosContext
*
* Returns: a new unconnected #PvContext
* Returns: a new unconnected #PinosContext
*/
PvContext *
pv_context_new (GMainContext *context, const gchar *name, GVariant *properties)
PinosContext *
pinos_context_new (GMainContext *context,
const gchar *name,
GVariant *properties)
{
g_return_val_if_fail (name != NULL, NULL);
@ -299,11 +300,11 @@ pv_context_new (GMainContext *context, const gchar *name, GVariant *properties)
g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (name));
properties = g_variant_builder_end (&builder);
}
return g_object_new (PV_TYPE_CONTEXT, "main-context", context, "name", name, "properties", properties, NULL);
return g_object_new (PINOS_TYPE_CONTEXT, "main-context", context, "name", name, "properties", properties, NULL);
}
static gboolean
do_notify_state (PvContext *context)
do_notify_state (PinosContext *context)
{
g_object_notify (G_OBJECT (context), "state");
g_object_unref (context);
@ -311,7 +312,8 @@ do_notify_state (PvContext *context)
}
static void
context_set_state (PvContext *context, PvContextState state)
context_set_state (PinosContext *context,
PinosContextState state)
{
if (context->priv->state != state) {
context->priv->state = state;
@ -321,40 +323,40 @@ context_set_state (PvContext *context, PvContextState state)
}
}
static void
on_client_proxy (GObject *source_object,
on_client_proxy (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvContext *context = user_data;
PvContextPrivate *priv = context->priv;
PinosContext *context = user_data;
PinosContextPrivate *priv = context->priv;
GError *error = NULL;
priv->client = pv_subscribe_get_proxy_finish (priv->subscribe,
priv->client = pinos_subscribe_get_proxy_finish (priv->subscribe,
res,
&error);
if (priv->client == NULL)
goto client_failed;
context_set_state (context, PV_CONTEXT_STATE_READY);
context_set_state (context, PINOS_CONTEXT_STATE_READY);
return;
client_failed:
{
priv->error = error;
context_set_state (context, PV_STREAM_STATE_ERROR);
context_set_state (context, PINOS_STREAM_STATE_ERROR);
g_warning ("failed to get client proxy: %s", error->message);
return;
}
}
static void
on_client_connected (GObject *source_object,
on_client_connected (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvContext *context = user_data;
PvContextPrivate *priv = context->priv;
PinosContext *context = user_data;
PinosContextPrivate *priv = context->priv;
GVariant *ret;
GError *error = NULL;
const gchar *client_path;
@ -363,14 +365,14 @@ on_client_connected (GObject *source_object,
if (ret == NULL) {
g_warning ("failed to connect client: %s", error->message);
priv->error = error;
context_set_state (context, PV_CONTEXT_STATE_ERROR);
context_set_state (context, PINOS_CONTEXT_STATE_ERROR);
return;
}
g_variant_get (ret, "(&o)", &client_path);
pv_subscribe_get_proxy (priv->subscribe,
PV_DBUS_SERVICE,
pinos_subscribe_get_proxy (priv->subscribe,
PINOS_DBUS_SERVICE,
client_path,
"org.pinos.Client1",
NULL,
@ -380,14 +382,14 @@ on_client_connected (GObject *source_object,
}
static void
on_daemon_connected (GObject *source_object,
on_daemon_connected (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvContext *context = user_data;
PvContextPrivate *priv = context->priv;
PinosContext *context = user_data;
PinosContextPrivate *priv = context->priv;
context_set_state (context, PV_CONTEXT_STATE_REGISTERING);
context_set_state (context, PINOS_CONTEXT_STATE_REGISTERING);
g_dbus_proxy_call (priv->daemon,
"ConnectClient",
@ -400,37 +402,37 @@ on_daemon_connected (GObject *source_object,
}
static void
subscription_cb (PvSubscribe *subscribe,
PvSubscriptionEvent event,
PvSubscriptionFlags flags,
GDBusProxy *object,
gpointer user_data)
subscription_cb (PinosSubscribe *subscribe,
PinosSubscriptionEvent event,
PinosSubscriptionFlags flags,
GDBusProxy *object,
gpointer user_data)
{
PvContext *context = user_data;
PvContextPrivate *priv = context->priv;
PinosContext *context = user_data;
PinosContextPrivate *priv = context->priv;
switch (flags) {
case PV_SUBSCRIPTION_FLAGS_DAEMON:
case PINOS_SUBSCRIPTION_FLAGS_DAEMON:
priv->daemon = g_object_ref (object);
break;
case PV_SUBSCRIPTION_FLAGS_CLIENT:
if (event == PV_SUBSCRIPTION_EVENT_REMOVE) {
case PINOS_SUBSCRIPTION_FLAGS_CLIENT:
if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
if (object == priv->client) {
priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "Client disappeared");
context_set_state (context, PV_CONTEXT_STATE_ERROR);
context_set_state (context, PINOS_CONTEXT_STATE_ERROR);
}
}
break;
case PV_SUBSCRIPTION_FLAGS_SOURCE:
if (event == PV_SUBSCRIPTION_EVENT_NEW)
case PINOS_SUBSCRIPTION_FLAGS_SOURCE:
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
priv->sources = g_list_prepend (priv->sources, object);
else if (event == PV_SUBSCRIPTION_EVENT_REMOVE)
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
priv->sources = g_list_remove (priv->sources, object);
break;
case PV_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT:
case PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT:
break;
}
@ -449,16 +451,16 @@ subscription_state (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
PvContext *context = user_data;
PvContextPrivate *priv = context->priv;
PvSubscriptionState state;
PinosContext *context = user_data;
PinosContextPrivate *priv = context->priv;
PinosSubscriptionState state;
g_assert (object == G_OBJECT (priv->subscribe));
state = pv_subscribe_get_state (priv->subscribe);
state = pinos_subscribe_get_state (priv->subscribe);
switch (state) {
case PV_SUBSCRIPTION_STATE_READY:
case PINOS_SUBSCRIPTION_STATE_READY:
on_daemon_connected (NULL, NULL, context);
break;
@ -470,12 +472,12 @@ subscription_state (GObject *object,
static void
on_name_appeared (GDBusConnection *connection,
const gchar *name,
const gchar *name_owner,
gpointer user_data)
const gchar *name,
const gchar *name_owner,
gpointer user_data)
{
PvContext *context = user_data;
PvContextPrivate *priv = context->priv;
PinosContext *context = user_data;
PinosContextPrivate *priv = context->priv;
priv->connection = connection;
@ -485,36 +487,36 @@ on_name_appeared (GDBusConnection *connection,
static void
on_name_vanished (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
const gchar *name,
gpointer user_data)
{
PvContext *context = user_data;
PvContextPrivate *priv = context->priv;
PinosContext *context = user_data;
PinosContextPrivate *priv = context->priv;
priv->connection = connection;
g_object_set (priv->subscribe, "connection", connection, NULL);
if (priv->flags & PV_CONTEXT_FLAGS_NOFAIL) {
context_set_state (context, PV_CONTEXT_STATE_CONNECTING);
if (priv->flags & PINOS_CONTEXT_FLAGS_NOFAIL) {
context_set_state (context, PINOS_CONTEXT_STATE_CONNECTING);
} else {
priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "Connection closed");
context_set_state (context, PV_CONTEXT_STATE_ERROR);
context_set_state (context, PINOS_CONTEXT_STATE_ERROR);
}
}
static gboolean
do_connect (PvContext *context)
do_connect (PinosContext *context)
{
PvContextPrivate *priv = context->priv;
PinosContextPrivate *priv = context->priv;
GBusNameWatcherFlags nw_flags;
nw_flags = G_BUS_NAME_WATCHER_FLAGS_NONE;
if (!(priv->flags & PV_CONTEXT_FLAGS_NOAUTOSPAWN))
if (!(priv->flags & PINOS_CONTEXT_FLAGS_NOAUTOSPAWN))
nw_flags = G_BUS_NAME_WATCHER_FLAGS_AUTO_START;
priv->id = g_bus_watch_name (G_BUS_TYPE_SESSION,
PV_DBUS_SERVICE,
PINOS_DBUS_SERVICE,
nw_flags,
on_name_appeared,
on_name_vanished,
@ -524,27 +526,28 @@ do_connect (PvContext *context)
}
/**
* pv_context_connect:
* @context: a #PvContext
* @flags: #PvContextFlags
* pinos_context_connect:
* @context: a #PinosContext
* @flags: #PinosContextFlags
*
* Connect to the daemon with @flags
*
* Returns: %TRUE on success.
*/
gboolean
pv_context_connect (PvContext *context, PvContextFlags flags)
pinos_context_connect (PinosContext *context,
PinosContextFlags flags)
{
PvContextPrivate *priv;
PinosContextPrivate *priv;
g_return_val_if_fail (PV_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (PINOS_IS_CONTEXT (context), FALSE);
priv = context->priv;
g_return_val_if_fail (priv->connection == NULL, FALSE);
priv->flags = flags;
context_set_state (context, PV_CONTEXT_STATE_CONNECTING);
context_set_state (context, PINOS_CONTEXT_STATE_CONNECTING);
g_main_context_invoke (priv->context,
(GSourceFunc) do_connect,
g_object_ref (context));
@ -553,12 +556,12 @@ pv_context_connect (PvContext *context, PvContextFlags flags)
}
static void
on_client_disconnected (GObject *source_object,
on_client_disconnected (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvContext *context = user_data;
PvContextPrivate *priv = context->priv;
PinosContext *context = user_data;
PinosContextPrivate *priv = context->priv;
GError *error = NULL;
GVariant *ret;
@ -566,7 +569,7 @@ on_client_disconnected (GObject *source_object,
if (ret == NULL) {
g_warning ("failed to disconnect client: %s", error->message);
priv->error = error;
context_set_state (context, PV_CONTEXT_STATE_ERROR);
context_set_state (context, PINOS_CONTEXT_STATE_ERROR);
g_object_unref (context);
return;
}
@ -577,14 +580,14 @@ on_client_disconnected (GObject *source_object,
g_bus_unwatch_name(priv->id);
priv->id = 0;
context_set_state (context, PV_CONTEXT_STATE_UNCONNECTED);
context_set_state (context, PINOS_CONTEXT_STATE_UNCONNECTED);
g_object_unref (context);
}
static gboolean
do_disconnect (PvContext *context)
do_disconnect (PinosContext *context)
{
PvContextPrivate *priv = context->priv;
PinosContextPrivate *priv = context->priv;
g_dbus_proxy_call (priv->client,
"Disconnect",
@ -599,19 +602,19 @@ do_disconnect (PvContext *context)
}
/**
* pv_context_disconnect:
* @context: a #PvContext
* pinos_context_disconnect:
* @context: a #PinosContext
*
* Disonnect from the daemon.
*
* Returns: %TRUE on success.
*/
gboolean
pv_context_disconnect (PvContext *context)
pinos_context_disconnect (PinosContext *context)
{
PvContextPrivate *priv;
PinosContextPrivate *priv;
g_return_val_if_fail (PV_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (PINOS_IS_CONTEXT (context), FALSE);
priv = context->priv;
g_return_val_if_fail (priv->client != NULL, FALSE);
@ -624,39 +627,39 @@ pv_context_disconnect (PvContext *context)
}
/**
* pv_context_get_state:
* @context: a #PvContext
* pinos_context_get_state:
* @context: a #PinosContext
*
* Get the state of @context.
*
* Returns: the state of @context
*/
PvContextState
pv_context_get_state (PvContext *context)
PinosContextState
pinos_context_get_state (PinosContext *context)
{
PvContextPrivate *priv;
PinosContextPrivate *priv;
g_return_val_if_fail (PV_IS_CONTEXT (context), PV_CONTEXT_STATE_ERROR);
g_return_val_if_fail (PINOS_IS_CONTEXT (context), PINOS_CONTEXT_STATE_ERROR);
priv = context->priv;
return priv->state;
}
/**
* pv_context_get_error:
* @context: a #PvContext
* pinos_context_get_error:
* @context: a #PinosContext
*
* Get the current error of @context or %NULL when the context state
* is not #PV_CONTEXT_STATE_ERROR
* is not #PINOS_CONTEXT_STATE_ERROR
*
* Returns: the last error or %NULL
*/
const GError *
pv_context_get_error (PvContext *context)
pinos_context_get_error (PinosContext *context)
{
PvContextPrivate *priv;
PinosContextPrivate *priv;
g_return_val_if_fail (PV_IS_CONTEXT (context), NULL);
g_return_val_if_fail (PINOS_IS_CONTEXT (context), NULL);
priv = context->priv;
return priv->error;

113
src/client/context.h Normal file
View file

@ -0,0 +1,113 @@
/* 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_CONTEXT_H__
#define __PINOS_CONTEXT_H__
#include <glib-object.h>
#include <gio/gio.h>
#include <client/subscribe.h>
G_BEGIN_DECLS
#define PINOS_TYPE_CONTEXT (pinos_context_get_type ())
#define PINOS_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_CONTEXT))
#define PINOS_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_CONTEXT))
#define PINOS_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_CONTEXT, PinosContextClass))
#define PINOS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_CONTEXT, PinosContext))
#define PINOS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_CONTEXT, PinosContextClass))
#define PINOS_CONTEXT_CAST(obj) ((PinosContext*)(obj))
#define PINOS_CONTEXT_CLASS_CAST(klass) ((PinosContextClass*)(klass))
typedef struct _PinosContext PinosContext;
typedef struct _PinosContextClass PinosContextClass;
typedef struct _PinosContextPrivate PinosContextPrivate;
/**
* PinosContextFlags:
* @PINOS_CONTEXT_FLAGS_NONE: no flags
* @PINOS_CONTEXT_FLAGS_NOAUTOSPAWN: disable autostart of the daemon
* @PINOS_CONTEXT_FLAGS_NOFAIL: Don't fail if the daemon is not available,
* instead enter PINOS_CONTEXT_CONNECTING state and wait for the daemon
* to appear.
*
* Context flags passed to pinos_context_connect()
*/
typedef enum {
PINOS_CONTEXT_FLAGS_NONE = 0,
PINOS_CONTEXT_FLAGS_NOAUTOSPAWN = (1 << 0),
PINOS_CONTEXT_FLAGS_NOFAIL = (1 << 1)
} PinosContextFlags;
/**
* PinosContextState:
* @PINOS_CONTEXT_STATE_UNCONNECTED: not connected
* @PINOS_CONTEXT_STATE_CONNECTING: connecting to daemon
* @PINOS_CONTEXT_STATE_REGISTERING: registering with daemon
* @PINOS_CONTEXT_STATE_READY: context is ready
* @PINOS_CONTEXT_STATE_ERROR: context is in error
*
* The state of a #PinosContext
*/
typedef enum {
PINOS_CONTEXT_STATE_UNCONNECTED = 0,
PINOS_CONTEXT_STATE_CONNECTING = 1,
PINOS_CONTEXT_STATE_REGISTERING = 2,
PINOS_CONTEXT_STATE_READY = 3,
PINOS_CONTEXT_STATE_ERROR = 4
} PinosContextState;
/**
* PinosContext:
*
* Pinos context object class.
*/
struct _PinosContext {
GObject object;
PinosContextPrivate *priv;
};
/**
* PinosContextClass:
*
* Pinos context object class.
*/
struct _PinosContextClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pinos_context_get_type (void);
PinosContext * pinos_context_new (GMainContext *ctx,
const gchar *name,
GVariant *properties);
gboolean pinos_context_connect (PinosContext *context, PinosContextFlags flags);
gboolean pinos_context_disconnect (PinosContext *context);
PinosContextState pinos_context_get_state (PinosContext *context);
const GError * pinos_context_get_error (PinosContext *context);
G_END_DECLS
#endif /* __PINOS_CONTEXT_H__ */

View file

@ -19,35 +19,35 @@
#include "client/pinos.h"
#include "client/pv-context.h"
#include "client/pv-enumtypes.h"
#include "client/pv-subscribe.h"
#include "client/context.h"
#include "client/enumtypes.h"
#include "client/subscribe.h"
#include "client/pv-private.h"
#include "client/private.h"
/**
* pv_context_list_source_info:
* @context: a connected #PvContext
* @flags: extra #PvSourceInfoFlags
* @cb: a #PvSourceInfoCallback
* pinos_context_list_source_info:
* @context: a connected #PinosContext
* @flags: extra #PinosSourceInfoFlags
* @cb: a #PinosSourceInfoCallback
* @cancelable: a #GCancellable
* @user_data: user data passed to @cb
*
* Call @cb for each source.
*/
void
pv_context_list_source_info (PvContext *context,
PvSourceInfoFlags flags,
PvSourceInfoCallback cb,
GCancellable *cancellable,
gpointer user_data)
pinos_context_list_source_info (PinosContext *context,
PinosSourceInfoFlags flags,
PinosSourceInfoCallback cb,
GCancellable *cancellable,
gpointer user_data)
{
GList *walk;
PvContextPrivate *priv = context->priv;
PinosContextPrivate *priv = context->priv;
for (walk = priv->sources; walk; walk = g_list_next (walk)) {
GDBusProxy *proxy = walk->data;
PvSourceInfo info;
PinosSourceInfo info;
info.name = "gst";

View file

@ -17,39 +17,39 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __PV_INTROSPECT_H__
#define __PV_INTROSPECT_H__
#ifndef __PINOS_INTROSPECT_H__
#define __PINOS_INTROSPECT_H__
#include <gio/gio.h>
#include <glib-object.h>
#include <client/pv-context.h>
#include <client/context.h>
G_BEGIN_DECLS
/**
* PvSourceState:
* @PV_SOURCE_STATE_ERROR: the source is in error
* @PV_SOURCE_STATE_SUSPENDED: the source is suspended, the device might
* PinosSourceState:
* @PINOS_SOURCE_STATE_ERROR: the source is in error
* @PINOS_SOURCE_STATE_SUSPENDED: the source is suspended, the device might
* be closed
* @PV_SOURCE_STATE_INIT: the source is initializing, it opens the device
* @PINOS_SOURCE_STATE_INIT: the source is initializing, it opens the device
* and gets the device capabilities
* @PV_SOURCE_STATE_IDLE: the source is running but there is no active
* @PINOS_SOURCE_STATE_IDLE: the source is running but there is no active
* source-output
* @PV_SOURCE_STATE_RUNNING: the source is running.
* @PINOS_SOURCE_STATE_RUNNING: the source is running.
*
* The different source states
*/
typedef enum {
PV_SOURCE_STATE_ERROR = 0,
PV_SOURCE_STATE_SUSPENDED = 1,
PV_SOURCE_STATE_INIT = 2,
PV_SOURCE_STATE_IDLE = 3,
PV_SOURCE_STATE_RUNNING = 4,
} PvSourceState;
PINOS_SOURCE_STATE_ERROR = 0,
PINOS_SOURCE_STATE_SUSPENDED = 1,
PINOS_SOURCE_STATE_INIT = 2,
PINOS_SOURCE_STATE_IDLE = 3,
PINOS_SOURCE_STATE_RUNNING = 4,
} PinosSourceState;
/**
* PvSourceInfo:
* PinosSourceInfo:
* @name: the name of the source
* @properties: the properties of the source
* @state: the current state of the source
@ -60,31 +60,31 @@ typedef enum {
typedef struct {
const char *name;
GVariant *properties;
PvSourceState state;
PinosSourceState state;
GBytes *formats;
} PvSourceInfo;
} PinosSourceInfo;
/**
* PvSourceInfoFlags:
* @PV_SOURCE_INFO_FLAGS_NONE: no flags
* @PV_SOURCE_INFO_FLAGS_FORMATS: include formats
* PinosSourceInfoFlags:
* @PINOS_SOURCE_INFO_FLAGS_NONE: no flags
* @PINOS_SOURCE_INFO_FLAGS_FORMATS: include formats
*
* Extra flags to pass to pv_context_get_source_info_list.
* Extra flags to pass to pinos_context_get_source_info_list.
*/
typedef enum {
PV_SOURCE_INFO_FLAGS_NONE = 0,
PV_SOURCE_INFO_FLAGS_FORMATS = (1 << 0)
} PvSourceInfoFlags;
PINOS_SOURCE_INFO_FLAGS_NONE = 0,
PINOS_SOURCE_INFO_FLAGS_FORMATS = (1 << 0)
} PinosSourceInfoFlags;
typedef gboolean (*PvSourceInfoCallback) (PvContext *c, const PvSourceInfo *info, gpointer userdata);
typedef gboolean (*PinosSourceInfoCallback) (PinosContext *c, const PinosSourceInfo *info, gpointer userdata);
void pv_context_list_source_info (PvContext *context,
PvSourceInfoFlags flags,
PvSourceInfoCallback cb,
void pinos_context_list_source_info (PinosContext *context,
PinosSourceInfoFlags flags,
PinosSourceInfoCallback cb,
GCancellable *cancellable,
gpointer user_data);
G_END_DECLS
#endif /* __PV_INTROSPECT_H__ */
#endif /* __PINOS_INTROSPECT_H__ */

View file

@ -17,13 +17,12 @@
* Boston, MA 02110-1301, USA.
*/
#include <gst/gst.h>
#include "client/pinos.h"
#include "gst/gstfdpay.h"
#include "gst/gstfddepay.h"
/**
* pv_init:
* pinos_init:
* @argc: pointer to argc
* @argv: pointer to argv
*
@ -31,7 +30,7 @@
* by @argc and @argv.
*/
void
pv_init (int *argc, char **argv[])
pinos_init (int *argc, char **argv[])
{
gst_init (argc, argv);
}

View file

@ -20,17 +20,17 @@
#ifndef __PINOS_H__
#define __PINOS_H__
#include <client/pv-stream.h>
#include <client/pv-context.h>
#include <client/pv-subscribe.h>
#include <client/pv-introspect.h>
#include <client/stream.h>
#include <client/context.h>
#include <client/subscribe.h>
#include <client/introspect.h>
#define PV_DBUS_SERVICE "org.pinos"
#define PV_DBUS_OBJECT_PREFIX "/org/pinos"
#define PV_DBUS_OBJECT_SERVER PV_DBUS_OBJECT_PREFIX "/server"
#define PV_DBUS_OBJECT_SOURCE PV_DBUS_OBJECT_PREFIX "/source"
#define PV_DBUS_OBJECT_CLIENT PV_DBUS_OBJECT_PREFIX "/client"
#define PINOS_DBUS_SERVICE "org.pinos"
#define PINOS_DBUS_OBJECT_PREFIX "/org/pinos"
#define PINOS_DBUS_OBJECT_SERVER PINOS_DBUS_OBJECT_PREFIX "/server"
#define PINOS_DBUS_OBJECT_SOURCE PINOS_DBUS_OBJECT_PREFIX "/source"
#define PINOS_DBUS_OBJECT_CLIENT PINOS_DBUS_OBJECT_PREFIX "/client"
void pv_init (int *argc, char **argv[]);
void pinos_init (int *argc, char **argv[]);
#endif /* __PINOS_H__ */

View file

@ -17,7 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
struct _PvContextPrivate
struct _PinosContextPrivate
{
GMainContext *context;
@ -27,16 +27,16 @@ struct _PvContextPrivate
guint id;
GDBusConnection *connection;
PvContextFlags flags;
PinosContextFlags flags;
PvContextState state;
PinosContextState state;
GError *error;
GDBusProxy *daemon;
GDBusProxy *client;
PvSubscriptionFlags subscription_mask;
PvSubscribe *subscribe;
PinosSubscriptionFlags subscription_mask;
PinosSubscribe *subscribe;
GList *sources;
};

View file

@ -1,113 +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 __PV_CONTEXT_H__
#define __PV_CONTEXT_H__
#include <glib-object.h>
#include <gio/gio.h>
#include <client/pv-subscribe.h>
G_BEGIN_DECLS
#define PV_TYPE_CONTEXT (pv_context_get_type ())
#define PV_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_CONTEXT))
#define PV_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_CONTEXT))
#define PV_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_CONTEXT, PvContextClass))
#define PV_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_CONTEXT, PvContext))
#define PV_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_CONTEXT, PvContextClass))
#define PV_CONTEXT_CAST(obj) ((PvContext*)(obj))
#define PV_CONTEXT_CLASS_CAST(klass) ((PvContextClass*)(klass))
typedef struct _PvContext PvContext;
typedef struct _PvContextClass PvContextClass;
typedef struct _PvContextPrivate PvContextPrivate;
/**
* PvContextFlags:
* @PV_CONTEXT_FLAGS_NONE: no flags
* @PV_CONTEXT_FLAGS_NOAUTOSPAWN: disable autostart of the daemon
* @PV_CONTEXT_FLAGS_NOFAIL: Don't fail if the daemon is not available,
* instead enter PV_CONTEXT_CONNECTING state and wait for the daemon
* to appear.
*
* Context flags passed to pv_context_connect()
*/
typedef enum {
PV_CONTEXT_FLAGS_NONE = 0,
PV_CONTEXT_FLAGS_NOAUTOSPAWN = (1 << 0),
PV_CONTEXT_FLAGS_NOFAIL = (1 << 1)
} PvContextFlags;
/**
* PvContextState:
* @PV_CONTEXT_STATE_UNCONNECTED: not connected
* @PV_CONTEXT_STATE_CONNECTING: connecting to daemon
* @PV_CONTEXT_STATE_REGISTERING: registering with daemon
* @PV_CONTEXT_STATE_READY: context is ready
* @PV_CONTEXT_STATE_ERROR: context is in error
*
* The state of a #PvContext
*/
typedef enum {
PV_CONTEXT_STATE_UNCONNECTED = 0,
PV_CONTEXT_STATE_CONNECTING = 1,
PV_CONTEXT_STATE_REGISTERING = 2,
PV_CONTEXT_STATE_READY = 3,
PV_CONTEXT_STATE_ERROR = 4
} PvContextState;
/**
* PvContext:
*
* Pinos context object class.
*/
struct _PvContext {
GObject object;
PvContextPrivate *priv;
};
/**
* PvContextClass:
*
* Pinos context object class.
*/
struct _PvContextClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pv_context_get_type (void);
PvContext * pv_context_new (GMainContext *ctx,
const gchar *name,
GVariant *properties);
gboolean pv_context_connect (PvContext *context, PvContextFlags flags);
gboolean pv_context_disconnect (PvContext *context);
PvContextState pv_context_get_state (PvContext *context);
const GError * pv_context_get_error (PvContext *context);
G_END_DECLS
#endif /* __PV_CONTEXT_H__ */

View file

@ -1,125 +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 __PV_STREAM_H__
#define __PV_STREAM_H__
#include <gio/gio.h>
#include <glib-object.h>
#include "pv-context.h"
G_BEGIN_DECLS
#define PV_TYPE_STREAM (pv_stream_get_type ())
#define PV_IS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_STREAM))
#define PV_IS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_STREAM))
#define PV_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_STREAM, PvStreamClass))
#define PV_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_STREAM, PvStream))
#define PV_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_STREAM, PvStreamClass))
#define PV_STREAM_CAST(obj) ((PvStream*)(obj))
#define PV_STREAM_CLASS_CAST(klass) ((PvStreamClass*)(klass))
typedef struct _PvStream PvStream;
typedef struct _PvStreamClass PvStreamClass;
typedef struct _PvStreamPrivate PvStreamPrivate;
typedef enum {
PV_STREAM_STATE_UNCONNECTED = 0,
PV_STREAM_STATE_CONNECTING = 1,
PV_STREAM_STATE_READY = 2,
PV_STREAM_STATE_STARTING = 3,
PV_STREAM_STATE_STREAMING = 4,
PV_STREAM_STATE_ERROR = 5
} PvStreamState;
typedef enum {
PV_STREAM_FLAGS_NONE = 0,
} PvStreamFlags;
typedef struct {
guint32 flags;
guint32 seq;
gint64 pts;
gint64 dts_offset;
guint64 offset;
guint64 size;
GSocketControlMessage *message;
} PvBufferInfo;
typedef enum {
PV_STREAM_MODE_SOCKET = 0,
PV_STREAM_MODE_BUFFER = 1,
} PvStreamMode;
/**
* PvStream:
*
* Pinos stream object class.
*/
struct _PvStream {
GObject object;
PvStreamPrivate *priv;
};
/**
* PvStreamClass:
*
* Pinos stream object class.
*/
struct _PvStreamClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pv_stream_get_type (void);
PvStream * pv_stream_new (PvContext * context,
const gchar *name,
GVariant * props);
PvStreamState pv_stream_get_state (PvStream *stream);
const GError * pv_stream_get_error (PvStream *stream);
gboolean pv_stream_connect_capture (PvStream *stream,
const gchar *source,
PvStreamFlags flags,
GBytes *accepted_formats);
gboolean pv_stream_connect_provide (PvStream *stream,
PvStreamFlags flags,
GBytes *possible_formats);
gboolean pv_stream_disconnect (PvStream *stream);
gboolean pv_stream_start (PvStream *stream,
GBytes *format,
PvStreamMode mode);
gboolean pv_stream_stop (PvStream *stream);
gboolean pv_stream_capture_buffer (PvStream *stream,
PvBufferInfo *info);
gboolean pv_stream_provide_buffer (PvStream *stream,
PvBufferInfo *info);
G_END_DECLS
#endif /* __PV_STREAM_H__ */

View file

@ -1,106 +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 __PV_SUBSCRIBE_H__
#define __PV_SUBSCRIBE_H__
#include <glib.h>
G_BEGIN_DECLS
#define PV_TYPE_SUBSCRIBE (pv_subscribe_get_type ())
#define PV_IS_SUBSCRIBE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_SUBSCRIBE))
#define PV_IS_SUBSCRIBE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_SUBSCRIBE))
#define PV_SUBSCRIBE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_SUBSCRIBE, PvSubscribeClass))
#define PV_SUBSCRIBE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_SUBSCRIBE, PvSubscribe))
#define PV_SUBSCRIBE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_SUBSCRIBE, PvSubscribeClass))
#define PV_SUBSCRIBE_CAST(obj) ((PvSubscribe*)(obj))
#define PV_SUBSCRIBE_CLASS_CAST(klass) ((PvSubscribeClass*)(klass))
typedef struct _PvSubscribe PvSubscribe;
typedef struct _PvSubscribeClass PvSubscribeClass;
typedef struct _PvSubscribePrivate PvSubscribePrivate;
typedef enum {
PV_SUBSCRIPTION_STATE_UNCONNECTED = 0,
PV_SUBSCRIPTION_STATE_CONNECTING = 1,
PV_SUBSCRIPTION_STATE_READY = 2,
PV_SUBSCRIPTION_STATE_ERROR = 3,
} PvSubscriptionState;
typedef enum {
PV_SUBSCRIPTION_FLAGS_DAEMON = (1 << 0),
PV_SUBSCRIPTION_FLAGS_CLIENT = (1 << 1),
PV_SUBSCRIPTION_FLAGS_SOURCE = (1 << 2),
PV_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT = (1 << 3),
} PvSubscriptionFlags;
#define PV_SUBSCRIPTION_FLAGS_ALL 0xf
typedef enum {
PV_SUBSCRIPTION_EVENT_NEW = 0,
PV_SUBSCRIPTION_EVENT_CHANGE = 1,
PV_SUBSCRIPTION_EVENT_REMOVE = 2,
} PvSubscriptionEvent;
/**
* PvSubscribe:
*
* Pinos subscribe object class.
*/
struct _PvSubscribe {
GObject object;
PvSubscribePrivate *priv;
};
/**
* PvSubscribeClass:
*
* Pinos subscribe object class.
*/
struct _PvSubscribeClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pv_subscribe_get_type (void);
PvSubscribe * pv_subscribe_new (void);
PvSubscriptionState pv_subscribe_get_state (PvSubscribe *subscribe);
GError * pv_subscribe_get_error (PvSubscribe *subscribe);
void pv_subscribe_get_proxy (PvSubscribe *subscribe,
const gchar *name,
const gchar *object_path,
const gchar *interface_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDBusProxy * pv_subscribe_get_proxy_finish (PvSubscribe *subscribe,
GAsyncResult *res,
GError **error);
G_END_DECLS
#endif /* __PV_SUBSCRIBE_H__ */

View file

@ -20,23 +20,23 @@
#include <string.h>
#include <gio/gunixfdlist.h>
#include "server/pv-daemon.h"
#include "server/daemon.h"
#include "client/pinos.h"
#include "client/pv-context.h"
#include "client/pv-stream.h"
#include "client/pv-enumtypes.h"
#include "client/context.h"
#include "client/stream.h"
#include "client/enumtypes.h"
#include "client/pv-private.h"
#include "client/private.h"
struct _PvStreamPrivate
struct _PinosStreamPrivate
{
PvContext *context;
PinosContext *context;
gchar *name;
GVariant *properties;
guint id;
PvStreamState state;
PinosStreamState state;
GError *error;
gchar *target;
@ -48,17 +48,17 @@ struct _PvStreamPrivate
GDBusProxy *source_output;
PvStreamMode mode;
PinosStreamMode mode;
GSocket *socket;
GSource *socket_source;
PvBufferInfo info;
PinosBufferInfo info;
};
#define PV_STREAM_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_STREAM, PvStreamPrivate))
#define PINOS_STREAM_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_STREAM, PinosStreamPrivate))
G_DEFINE_TYPE (PvStream, pv_stream, G_TYPE_OBJECT);
G_DEFINE_TYPE (PinosStream, pinos_stream, G_TYPE_OBJECT);
enum
{
@ -81,13 +81,13 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
static void
pv_stream_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
pinos_stream_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PvStream *stream = PV_STREAM (_object);
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = PINOS_STREAM (_object);
PinosStreamPrivate *priv = stream->priv;
switch (prop_id) {
case PROP_CONTEXT:
@ -125,13 +125,13 @@ pv_stream_get_property (GObject *_object,
}
static void
pv_stream_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
pinos_stream_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PvStream *stream = PV_STREAM (_object);
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = PINOS_STREAM (_object);
PinosStreamPrivate *priv = stream->priv;
switch (prop_id) {
case PROP_CONTEXT:
@ -155,7 +155,7 @@ pv_stream_set_property (GObject *_object,
}
static gboolean
do_notify_state (PvStream *stream)
do_notify_state (PinosStream *stream)
{
g_object_notify (G_OBJECT (stream), "state");
g_object_unref (stream);
@ -163,7 +163,8 @@ do_notify_state (PvStream *stream)
}
static void
stream_set_state (PvStream *stream, PvStreamState state)
stream_set_state (PinosStream *stream,
PinosStreamState state)
{
if (stream->priv->state != state) {
stream->priv->state = state;
@ -174,21 +175,21 @@ stream_set_state (PvStream *stream, PvStreamState state)
}
static void
subscription_cb (PvSubscribe *subscribe,
PvSubscriptionEvent event,
PvSubscriptionFlags flags,
GDBusProxy *object,
gpointer user_data)
subscription_cb (PinosSubscribe *subscribe,
PinosSubscriptionEvent event,
PinosSubscriptionFlags flags,
GDBusProxy *object,
gpointer user_data)
{
PvStream *stream = PV_STREAM (user_data);
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = PINOS_STREAM (user_data);
PinosStreamPrivate *priv = stream->priv;
switch (flags) {
case PV_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT:
if (event == PV_SUBSCRIPTION_EVENT_REMOVE) {
case PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT:
if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
if (object == priv->source_output) {
priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "output disappeared");
stream_set_state (stream, PV_STREAM_STATE_ERROR);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR);
}
}
break;
@ -199,24 +200,24 @@ subscription_cb (PvSubscribe *subscribe,
}
static void
pv_stream_constructed (GObject * object)
pinos_stream_constructed (GObject * object)
{
PvStream *stream = PV_STREAM (object);
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = PINOS_STREAM (object);
PinosStreamPrivate *priv = stream->priv;
priv->id = g_signal_connect (priv->context->priv->subscribe,
"subscription-event",
(GCallback) subscription_cb,
stream);
G_OBJECT_CLASS (pv_stream_parent_class)->constructed (object);
G_OBJECT_CLASS (pinos_stream_parent_class)->constructed (object);
}
static void
pv_stream_finalize (GObject * object)
pinos_stream_finalize (GObject * object)
{
PvStream *stream = PV_STREAM (object);
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = PINOS_STREAM (object);
PinosStreamPrivate *priv = stream->priv;
g_clear_object (&priv->source_output);
@ -237,23 +238,23 @@ pv_stream_finalize (GObject * object)
g_clear_object (&priv->context);
g_free (priv->name);
G_OBJECT_CLASS (pv_stream_parent_class)->finalize (object);
G_OBJECT_CLASS (pinos_stream_parent_class)->finalize (object);
}
static void
pv_stream_class_init (PvStreamClass * klass)
pinos_stream_class_init (PinosStreamClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (PvStreamPrivate));
g_type_class_add_private (klass, sizeof (PinosStreamPrivate));
gobject_class->constructed = pv_stream_constructed;
gobject_class->finalize = pv_stream_finalize;
gobject_class->set_property = pv_stream_set_property;
gobject_class->get_property = pv_stream_get_property;
gobject_class->constructed = pinos_stream_constructed;
gobject_class->finalize = pinos_stream_finalize;
gobject_class->set_property = pinos_stream_set_property;
gobject_class->get_property = pinos_stream_get_property;
/**
* PvStream:context
* PinosStream:context
*
* The context of the stream.
*/
@ -262,12 +263,12 @@ pv_stream_class_init (PvStreamClass * klass)
g_param_spec_object ("context",
"Context",
"The context",
PV_TYPE_CONTEXT,
PINOS_TYPE_CONTEXT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* PvStream:name
* PinosStream:name
*
* The name of the stream as specified at construction time.
*/
@ -281,7 +282,7 @@ pv_stream_class_init (PvStreamClass * klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* PvStream:properties
* PinosStream:properties
*
* The properties of the stream as specified at construction time.
*/
@ -296,7 +297,7 @@ pv_stream_class_init (PvStreamClass * klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* PvStream:state
* PinosStream:state
*
* The state of the stream. Use the notify::state signal to be notified
* of state changes.
@ -306,12 +307,12 @@ pv_stream_class_init (PvStreamClass * klass)
g_param_spec_enum ("state",
"State",
"The stream state",
PV_TYPE_STREAM_STATE,
PV_STREAM_STATE_UNCONNECTED,
PINOS_TYPE_STREAM_STATE,
PINOS_STREAM_STATE_UNCONNECTED,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* PvStream:possible-formats
* PinosStream:possible-formats
*
* The possible formats for the stream. this can only be used after connecting
* the stream for capture or provide.
@ -325,7 +326,7 @@ pv_stream_class_init (PvStreamClass * klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* PvStream:formats
* PinosStream:formats
*
* The format of the stream. This will be set after starting the stream.
*/
@ -338,10 +339,10 @@ pv_stream_class_init (PvStreamClass * klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* PvStream:socket
* PinosStream:socket
*
* The socket of the stream. When doing pv_stream_start() with
* #PV_STREAM_MODE_SOCKET, the socket will contain a data stream with
* The socket of the stream. When doing pinos_stream_start() with
* #PINOS_STREAM_MODE_SOCKET, the socket will contain a data stream with
* meta data and anciliary data containing fds with the data.
*/
g_object_class_install_property (gobject_class,
@ -355,11 +356,11 @@ pv_stream_class_init (PvStreamClass * klass)
/**
* PvStream:new-buffer
* PinosStream:new-buffer
*
* When doing pv_stream_start() with #PV_STREAM_MODE_BUFFER, this signal
* When doing pinos_stream_start() with #PINOS_STREAM_MODE_BUFFER, this signal
* will be fired whenever a new buffer can be obtained with
* pv_stream_capture_buffer().
* pinos_stream_capture_buffer().
*/
signals[SIGNAL_NEW_BUFFER] = g_signal_new ("new-buffer",
G_TYPE_FROM_CLASS (klass),
@ -374,77 +375,79 @@ pv_stream_class_init (PvStreamClass * klass)
}
static void
pv_stream_init (PvStream * stream)
pinos_stream_init (PinosStream * stream)
{
PvStreamPrivate *priv = stream->priv = PV_STREAM_GET_PRIVATE (stream);
PinosStreamPrivate *priv = stream->priv = PINOS_STREAM_GET_PRIVATE (stream);
priv->state = PV_STREAM_STATE_UNCONNECTED;
priv->state = PINOS_STREAM_STATE_UNCONNECTED;
}
/**
* pv_stream_new:
* @context: a #PvContext
* pinos_stream_new:
* @context: a #PinosContext
* @name: a stream name
* @properties: stream properties
*
* Make a new unconnected #PvStream
* Make a new unconnected #PinosStream
*
* Returns: a new unconnected #PvStream
* Returns: a new unconnected #PinosStream
*/
PvStream *
pv_stream_new (PvContext * context, const gchar *name, GVariant *props)
PinosStream *
pinos_stream_new (PinosContext *context,
const gchar *name,
GVariant *props)
{
g_return_val_if_fail (PV_IS_CONTEXT (context), NULL);
g_return_val_if_fail (PINOS_IS_CONTEXT (context), NULL);
g_return_val_if_fail (name != NULL, NULL);
return g_object_new (PV_TYPE_STREAM, "context", context, "name", name, "properties", props, NULL);
return g_object_new (PINOS_TYPE_STREAM, "context", context, "name", name, "properties", props, NULL);
}
/**
* pv_stream_get_state:
* @stream: a #PvStream
* pinos_stream_get_state:
* @stream: a #PinosStream
*
* Get the state of @stream.
*
* Returns: the state of @stream
*/
PvStreamState
pv_stream_get_state (PvStream *stream)
PinosStreamState
pinos_stream_get_state (PinosStream *stream)
{
g_return_val_if_fail (PV_IS_STREAM (stream), PV_STREAM_STATE_ERROR);
g_return_val_if_fail (PINOS_IS_STREAM (stream), PINOS_STREAM_STATE_ERROR);
return stream->priv->state;
}
/**
* pv_stream_get_error:
* @stream: a #PvStream
* pinos_stream_get_error:
* @stream: a #PinosStream
*
* Get the error of @stream.
*
* Returns: the error of @stream or %NULL when there is no error
*/
const GError *
pv_stream_get_error (PvStream *stream)
pinos_stream_get_error (PinosStream *stream)
{
g_return_val_if_fail (PV_IS_STREAM (stream), NULL);
g_return_val_if_fail (PINOS_IS_STREAM (stream), NULL);
return stream->priv->error;
}
static void
on_source_output_proxy (GObject *source_object,
on_source_output_proxy (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvStream *stream = user_data;
PvStreamPrivate *priv = stream->priv;
PvContext *context = priv->context;
PinosStream *stream = user_data;
PinosStreamPrivate *priv = stream->priv;
PinosContext *context = priv->context;
GVariant *v;
gchar *str;
GError *error = NULL;
priv->source_output = pv_subscribe_get_proxy_finish (context->priv->subscribe,
priv->source_output = pinos_subscribe_get_proxy_finish (context->priv->subscribe,
res,
&error);
if (priv->source_output == NULL)
@ -462,7 +465,7 @@ on_source_output_proxy (GObject *source_object,
g_object_notify (G_OBJECT (stream), "possible-formats");
}
stream_set_state (stream, PV_STREAM_STATE_READY);
stream_set_state (stream, PINOS_STREAM_STATE_READY);
g_object_unref (stream);
return;
@ -470,7 +473,7 @@ on_source_output_proxy (GObject *source_object,
source_output_failed:
{
priv->error = error;
stream_set_state (stream, PV_STREAM_STATE_ERROR);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR);
g_warning ("failed to get source output proxy: %s", error->message);
g_object_unref (stream);
return;
@ -478,13 +481,13 @@ source_output_failed:
}
static void
on_source_output_created (GObject *source_object,
on_source_output_created (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvStream *stream = user_data;
PvStreamPrivate *priv = stream->priv;
PvContext *context = priv->context;
PinosStream *stream = user_data;
PinosStreamPrivate *priv = stream->priv;
PinosContext *context = priv->context;
GVariant *ret;
GError *error = NULL;
const gchar *source_output_path;
@ -495,8 +498,8 @@ on_source_output_created (GObject *source_object,
g_variant_get (ret, "(o)", &source_output_path);
pv_subscribe_get_proxy (context->priv->subscribe,
PV_DBUS_SERVICE,
pinos_subscribe_get_proxy (context->priv->subscribe,
PINOS_DBUS_SERVICE,
source_output_path,
"org.pinos.SourceOutput1",
NULL,
@ -510,7 +513,7 @@ on_source_output_created (GObject *source_object,
create_failed:
{
priv->error = error;
stream_set_state (stream, PV_STREAM_STATE_ERROR);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR);
g_warning ("failed to get connect capture: %s", error->message);
g_object_unref (stream);
return;
@ -518,10 +521,10 @@ create_failed:
}
static gboolean
do_connect_capture (PvStream *stream)
do_connect_capture (PinosStream *stream)
{
PvStreamPrivate *priv = stream->priv;
PvContext *context = priv->context;
PinosStreamPrivate *priv = stream->priv;
PinosContext *context = priv->context;
g_dbus_proxy_call (context->priv->client,
"CreateSourceOutput",
@ -538,10 +541,10 @@ do_connect_capture (PvStream *stream)
}
/**
* pv_stream_connect_capture:
* @stream: a #PvStream
* pinos_stream_connect_capture:
* @stream: a #PinosStream
* @source: the source name to connect to
* @flags: a #PvStreamFlags
* @flags: a #PinosStreamFlags
* @spec: a #GVariant
*
* Connect @stream for capturing from @source.
@ -549,20 +552,20 @@ do_connect_capture (PvStream *stream)
* Returns: %TRUE on success.
*/
gboolean
pv_stream_connect_capture (PvStream *stream,
const gchar *source,
PvStreamFlags flags,
GBytes *accepted_formats)
pinos_stream_connect_capture (PinosStream *stream,
const gchar *source,
PinosStreamFlags flags,
GBytes *accepted_formats)
{
PvStreamPrivate *priv;
PvContext *context;
PinosStreamPrivate *priv;
PinosContext *context;
g_return_val_if_fail (PV_IS_STREAM (stream), FALSE);
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
g_return_val_if_fail (accepted_formats != NULL, FALSE);
priv = stream->priv;
context = priv->context;
g_return_val_if_fail (pv_context_get_state (context) == PV_CONTEXT_STATE_READY, FALSE);
g_return_val_if_fail (pinos_context_get_state (context) == PINOS_CONTEXT_STATE_READY, FALSE);
g_free (priv->target);
priv->target = g_strdup (source);
@ -571,7 +574,7 @@ pv_stream_connect_capture (PvStream *stream,
priv->accepted_formats = g_bytes_ref (accepted_formats);
priv->provide = FALSE;
stream_set_state (stream, PV_STREAM_STATE_CONNECTING);
stream_set_state (stream, PINOS_STREAM_STATE_CONNECTING);
g_main_context_invoke (context->priv->context,
(GSourceFunc) do_connect_capture,
@ -581,10 +584,10 @@ pv_stream_connect_capture (PvStream *stream,
}
static gboolean
do_connect_provide (PvStream *stream)
do_connect_provide (PinosStream *stream)
{
PvStreamPrivate *priv = stream->priv;
PvContext *context = priv->context;
PinosStreamPrivate *priv = stream->priv;
PinosContext *context = priv->context;
g_dbus_proxy_call (context->priv->client,
"CreateSourceInput",
@ -599,9 +602,9 @@ do_connect_provide (PvStream *stream)
}
/**
* pv_stream_connect_provide:
* @stream: a #PvStream
* @flags: a #PvStreamFlags
* pinos_stream_connect_provide:
* @stream: a #PinosStream
* @flags: a #PinosStreamFlags
* @spec: a #GVariant
*
* Connect @stream for providing data for a new source.
@ -609,28 +612,28 @@ do_connect_provide (PvStream *stream)
* Returns: %TRUE on success.
*/
gboolean
pv_stream_connect_provide (PvStream *stream,
PvStreamFlags flags,
GBytes *possible_formats)
pinos_stream_connect_provide (PinosStream *stream,
PinosStreamFlags flags,
GBytes *possible_formats)
{
PvStreamPrivate *priv;
PvContext *context;
PinosStreamPrivate *priv;
PinosContext *context;
g_return_val_if_fail (PV_IS_STREAM (stream), FALSE);
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 (pv_context_get_state (context) == PV_CONTEXT_STATE_READY, FALSE);
g_return_val_if_fail (pinos_context_get_state (context) == PINOS_CONTEXT_STATE_READY, FALSE);
if (priv->possible_formats)
g_bytes_unref (priv->possible_formats);
priv->possible_formats = g_bytes_ref (possible_formats);
priv->provide = TRUE;
stream_set_state (stream, PV_STREAM_STATE_CONNECTING);
stream_set_state (stream, PINOS_STREAM_STATE_CONNECTING);
g_main_context_invoke (context->priv->context,
g_main_context_invoke (context->priv->context,
(GSourceFunc) do_connect_provide,
g_object_ref (stream));
@ -638,33 +641,33 @@ pv_stream_connect_provide (PvStream *stream,
}
static void
on_source_output_removed (GObject *source_object,
on_source_output_removed (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvStream *stream = user_data;
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = user_data;
PinosStreamPrivate *priv = stream->priv;
GVariant *ret;
GError *error = NULL;
ret = g_dbus_proxy_call_finish (priv->source_output, res, &error);
if (ret == NULL) {
priv->error = error;
stream_set_state (stream, PV_STREAM_STATE_ERROR);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR);
g_warning ("failed to disconnect: %s", error->message);
g_object_unref (stream);
return;
}
g_clear_object (&priv->source_output);
stream_set_state (stream, PV_STREAM_STATE_UNCONNECTED);
stream_set_state (stream, PINOS_STREAM_STATE_UNCONNECTED);
g_object_unref (stream);
}
static gboolean
do_disconnect (PvStream *stream)
do_disconnect (PinosStream *stream)
{
PvStreamPrivate *priv = stream->priv;
PinosStreamPrivate *priv = stream->priv;
g_dbus_proxy_call (priv->source_output,
"Remove",
@ -679,25 +682,25 @@ do_disconnect (PvStream *stream)
}
/**
* pv_stream_disconnect:
* @stream: a #PvStream
* pinos_stream_disconnect:
* @stream: a #PinosStream
*
* Disconnect @stream.
*
* Returns: %TRUE on success
*/
gboolean
pv_stream_disconnect (PvStream *stream)
pinos_stream_disconnect (PinosStream *stream)
{
PvStreamPrivate *priv;
PvContext *context;
PinosStreamPrivate *priv;
PinosContext *context;
g_return_val_if_fail (PV_IS_STREAM (stream), FALSE);
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state >= PV_STREAM_STATE_READY, FALSE);
g_return_val_if_fail (priv->state >= PINOS_STREAM_STATE_READY, FALSE);
g_return_val_if_fail (priv->source_output != NULL, FALSE);
context = priv->context;
g_return_val_if_fail (pv_context_get_state (context) >= PV_CONTEXT_STATE_READY, FALSE);
g_return_val_if_fail (pinos_context_get_state (context) >= PINOS_CONTEXT_STATE_READY, FALSE);
g_main_context_invoke (context->priv->context,
(GSourceFunc) do_disconnect,
@ -709,12 +712,12 @@ pv_stream_disconnect (PvStream *stream)
#include <gst/wire-protocol.h>
static gboolean
on_socket_condition (GSocket *socket,
GIOCondition condition,
gpointer user_data)
on_socket_condition (GSocket *socket,
GIOCondition condition,
gpointer user_data)
{
PvStream *stream = user_data;
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = user_data;
PinosStreamPrivate *priv = stream->priv;
switch (condition) {
case G_IO_IN:
@ -771,9 +774,9 @@ on_socket_condition (GSocket *socket,
static void
handle_socket (PvStream *stream, gint fd)
handle_socket (PinosStream *stream, gint fd)
{
PvStreamPrivate *priv = stream->priv;
PinosStreamPrivate *priv = stream->priv;
GError *error = NULL;
priv->socket = g_socket_new_from_fd (fd, &error);
@ -781,11 +784,11 @@ handle_socket (PvStream *stream, gint fd)
goto socket_failed;
switch (priv->mode) {
case PV_STREAM_MODE_SOCKET:
case PINOS_STREAM_MODE_SOCKET:
g_object_notify (G_OBJECT (stream), "socket");
break;
case PV_STREAM_MODE_BUFFER:
case PINOS_STREAM_MODE_BUFFER:
{
if (!priv->provide) {
priv->socket_source = g_socket_create_source (priv->socket, G_IO_IN, NULL);
@ -804,24 +807,24 @@ handle_socket (PvStream *stream, gint fd)
socket_failed:
{
priv->error = error;
stream_set_state (stream, PV_STREAM_STATE_ERROR);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR);
g_warning ("failed to create socket: %s", error->message);
return;
}
}
static void
unhandle_socket (PvStream *stream)
unhandle_socket (PinosStream *stream)
{
PvStreamPrivate *priv = stream->priv;
PinosStreamPrivate *priv = stream->priv;
switch (priv->mode) {
case PV_STREAM_MODE_SOCKET:
case PINOS_STREAM_MODE_SOCKET:
g_clear_object (&priv->socket);
g_object_notify (G_OBJECT (stream), "socket");
break;
case PV_STREAM_MODE_BUFFER:
case PINOS_STREAM_MODE_BUFFER:
if (priv->socket_source) {
g_source_destroy (priv->socket_source);
g_clear_pointer (&priv->socket_source, g_source_unref);
@ -834,12 +837,12 @@ unhandle_socket (PvStream *stream)
}
static void
on_stream_started (GObject *source_object,
on_stream_started (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvStream *stream = user_data;
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = user_data;
PinosStreamPrivate *priv = stream->priv;
GUnixFDList *out_fd_list;
gint fd_idx, fd;
gchar *format;
@ -871,7 +874,7 @@ on_stream_started (GObject *source_object,
handle_socket (stream, fd);
stream_set_state (stream, PV_STREAM_STATE_STREAMING);
stream_set_state (stream, PINOS_STREAM_STATE_STREAMING);
return;
@ -889,15 +892,15 @@ fd_failed:
exit_error:
{
priv->error = error;
stream_set_state (stream, PV_STREAM_STATE_ERROR);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR);
return;
}
}
static gboolean
do_start (PvStream *stream)
do_start (PinosStream *stream)
{
PvStreamPrivate *priv = stream->priv;
PinosStreamPrivate *priv = stream->priv;
g_dbus_proxy_call (priv->source_output,
"Start",
@ -912,35 +915,37 @@ do_start (PvStream *stream)
}
/**
* pv_stream_start:
* @stream: a #PvStream
* @mode: a #PvStreamMode
* pinos_stream_start:
* @stream: a #PinosStream
* @mode: a #PinosStreamMode
*
* Start capturing from @stream.
*
* When @mode is #PV_STREAM_MODE_SOCKET, you should connect to the notify::socket
* When @mode is #PINOS_STREAM_MODE_SOCKET, you should connect to the notify::socket
* signal to obtain a readable socket with metadata and data.
*
* When @mode is #PV_STREAM_MODE_BUFFER, you should connect to the new-buffer
* signal and use pv_stream_capture_buffer() to get the latest metadata and
* When @mode is #PINOS_STREAM_MODE_BUFFER, you should connect to the new-buffer
* signal and use pinos_stream_capture_buffer() to get the latest metadata and
* data.
*
* Returns: %TRUE on success.
*/
gboolean
pv_stream_start (PvStream *stream, GBytes *format, PvStreamMode mode)
pinos_stream_start (PinosStream *stream,
GBytes *format,
PinosStreamMode mode)
{
PvStreamPrivate *priv;
PinosStreamPrivate *priv;
g_return_val_if_fail (PV_IS_STREAM (stream), FALSE);
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state == PV_STREAM_STATE_READY, FALSE);
g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_READY, FALSE);
priv->mode = mode;
priv->format = g_bytes_ref (format);
stream_set_state (stream, PV_STREAM_STATE_STARTING);
stream_set_state (stream, PINOS_STREAM_STATE_STARTING);
g_main_context_invoke (priv->context->priv->context, (GSourceFunc) do_start, stream);
@ -948,12 +953,12 @@ pv_stream_start (PvStream *stream, GBytes *format, PvStreamMode mode)
}
static void
on_stream_stopped (GObject *source_object,
on_stream_stopped (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvStream *stream = user_data;
PvStreamPrivate *priv = stream->priv;
PinosStream *stream = user_data;
PinosStreamPrivate *priv = stream->priv;
GVariant *ret;
GError *error = NULL;
@ -967,7 +972,7 @@ on_stream_stopped (GObject *source_object,
g_clear_pointer (&priv->format, g_free);
g_object_notify (G_OBJECT (stream), "format");
stream_set_state (stream, PV_STREAM_STATE_READY);
stream_set_state (stream, PINOS_STREAM_STATE_READY);
return;
@ -975,16 +980,16 @@ on_stream_stopped (GObject *source_object,
call_failed:
{
priv->error = error;
stream_set_state (stream, PV_STREAM_STATE_ERROR);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR);
g_warning ("failed to release: %s", error->message);
return;
}
}
static gboolean
do_stop (PvStream *stream)
do_stop (PinosStream *stream)
{
PvStreamPrivate *priv = stream->priv;
PinosStreamPrivate *priv = stream->priv;
g_dbus_proxy_call (priv->source_output,
"Stop",
@ -999,22 +1004,22 @@ do_stop (PvStream *stream)
return FALSE;
}
/**
* pv_stream_stop:
* @stream: a #PvStream
* pinos_stream_stop:
* @stream: a #PinosStream
*
* Stop capturing from @stream.
*
* Returns: %TRUE on success.
*/
gboolean
pv_stream_stop (PvStream *stream)
pinos_stream_stop (PinosStream *stream)
{
PvStreamPrivate *priv;
PinosStreamPrivate *priv;
g_return_val_if_fail (PV_IS_STREAM (stream), FALSE);
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state == PV_STREAM_STATE_STREAMING, FALSE);
g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE);
g_main_context_invoke (priv->context->priv->context, (GSourceFunc) do_stop, stream);
@ -1022,9 +1027,9 @@ pv_stream_stop (PvStream *stream)
}
/**
* pv_stream_capture_buffer:
* @stream: a #PvStream
* @info: a #PvBufferInfo
* pinos_stream_capture_buffer:
* @stream: a #PinosStream
* @info: a #PinosBufferInfo
*
* Capture the next buffer from @stream. This function should be called every
* time after the new-buffer callback has been emitted.
@ -1032,15 +1037,16 @@ pv_stream_stop (PvStream *stream)
* Returns: %TRUE when @info contains valid information
*/
gboolean
pv_stream_capture_buffer (PvStream *stream, PvBufferInfo *info)
pinos_stream_capture_buffer (PinosStream *stream,
PinosBufferInfo *info)
{
PvStreamPrivate *priv;
PinosStreamPrivate *priv;
g_return_val_if_fail (PV_IS_STREAM (stream), FALSE);
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
g_return_val_if_fail (info != NULL, FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state == PV_STREAM_STATE_STREAMING, FALSE);
g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE);
*info = priv->info;
@ -1048,9 +1054,9 @@ pv_stream_capture_buffer (PvStream *stream, PvBufferInfo *info)
}
/**
* pv_stream_provide_buffer:
* @stream: a #PvStream
* @info: a #PvBufferInfo
* pinos_stream_provide_buffer:
* @stream: a #PinosStream
* @info: a #PinosBufferInfo
*
* Provide the next buffer from @stream. This function should be called every
* time a new frame becomes available.
@ -1058,20 +1064,21 @@ pv_stream_capture_buffer (PvStream *stream, PvBufferInfo *info)
* Returns: %TRUE when @info was handled
*/
gboolean
pv_stream_provide_buffer (PvStream *stream, PvBufferInfo *info)
pinos_stream_provide_buffer (PinosStream *stream,
PinosBufferInfo *info)
{
PvStreamPrivate *priv;
PinosStreamPrivate *priv;
gssize len;
GOutputVector ovec;
FDMessage msg;
gint flags = 0;
GError *error = NULL;
g_return_val_if_fail (PV_IS_STREAM (stream), FALSE);
g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE);
g_return_val_if_fail (info != NULL, FALSE);
priv = stream->priv;
g_return_val_if_fail (priv->state == PV_STREAM_STATE_STREAMING, FALSE);
g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE);
msg.flags = info->flags;
msg.seq = info->seq;
@ -1107,7 +1114,7 @@ pv_stream_provide_buffer (PvStream *stream, PvBufferInfo *info)
send_error:
{
priv->error = error;
stream_set_state (stream, PV_STREAM_STATE_ERROR);
stream_set_state (stream, PINOS_STREAM_STATE_ERROR);
g_warning ("failed to send_message: %s", error->message);
return FALSE;
}

125
src/client/stream.h Normal file
View file

@ -0,0 +1,125 @@
/* 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_STREAM_H__
#define __PINOS_STREAM_H__
#include <gio/gio.h>
#include <glib-object.h>
#include "context.h"
G_BEGIN_DECLS
#define PINOS_TYPE_STREAM (pinos_stream_get_type ())
#define PINOS_IS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_STREAM))
#define PINOS_IS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_STREAM))
#define PINOS_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_STREAM, PinosStreamClass))
#define PINOS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_STREAM, PinosStream))
#define PINOS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_STREAM, PinosStreamClass))
#define PINOS_STREAM_CAST(obj) ((PinosStream*)(obj))
#define PINOS_STREAM_CLASS_CAST(klass) ((PinosStreamClass*)(klass))
typedef struct _PinosStream PinosStream;
typedef struct _PinosStreamClass PinosStreamClass;
typedef struct _PinosStreamPrivate PinosStreamPrivate;
typedef enum {
PINOS_STREAM_STATE_UNCONNECTED = 0,
PINOS_STREAM_STATE_CONNECTING = 1,
PINOS_STREAM_STATE_READY = 2,
PINOS_STREAM_STATE_STARTING = 3,
PINOS_STREAM_STATE_STREAMING = 4,
PINOS_STREAM_STATE_ERROR = 5
} PinosStreamState;
typedef enum {
PINOS_STREAM_FLAGS_NONE = 0,
} PinosStreamFlags;
typedef struct {
guint32 flags;
guint32 seq;
gint64 pts;
gint64 dts_offset;
guint64 offset;
guint64 size;
GSocketControlMessage *message;
} PinosBufferInfo;
typedef enum {
PINOS_STREAM_MODE_SOCKET = 0,
PINOS_STREAM_MODE_BUFFER = 1,
} PinosStreamMode;
/**
* PinosStream:
*
* Pinos stream object class.
*/
struct _PinosStream {
GObject object;
PinosStreamPrivate *priv;
};
/**
* PinosStreamClass:
*
* Pinos stream object class.
*/
struct _PinosStreamClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pinos_stream_get_type (void);
PinosStream * pinos_stream_new (PinosContext * context,
const gchar *name,
GVariant * props);
PinosStreamState pinos_stream_get_state (PinosStream *stream);
const GError * pinos_stream_get_error (PinosStream *stream);
gboolean pinos_stream_connect_capture (PinosStream *stream,
const gchar *source,
PinosStreamFlags flags,
GBytes *accepted_formats);
gboolean pinos_stream_connect_provide (PinosStream *stream,
PinosStreamFlags flags,
GBytes *possible_formats);
gboolean pinos_stream_disconnect (PinosStream *stream);
gboolean pinos_stream_start (PinosStream *stream,
GBytes *format,
PinosStreamMode mode);
gboolean pinos_stream_stop (PinosStream *stream);
gboolean pinos_stream_capture_buffer (PinosStream *stream,
PinosBufferInfo *info);
gboolean pinos_stream_provide_buffer (PinosStream *stream,
PinosBufferInfo *info);
G_END_DECLS
#endif /* __PINOS_STREAM_H__ */

View file

@ -20,12 +20,12 @@
#include <gio/gio.h>
#include "client/pinos.h"
#include "client/pv-enumtypes.h"
#include "client/enumtypes.h"
struct _PvSubscribePrivate
struct _PinosSubscribePrivate
{
gchar *service;
PvSubscriptionFlags subscription_mask;
PinosSubscriptionFlags subscription_mask;
GDBusConnection *connection;
GCancellable *cancellable;
@ -35,13 +35,13 @@ struct _PvSubscribePrivate
guint pending_proxies;
GList *objects;
PvSubscriptionState state;
PinosSubscriptionState state;
GError *error;
};
typedef struct
{
PvSubscribe *subscribe;
PinosSubscribe *subscribe;
gchar *sender_name;
gchar *object_path;
gchar *interface_name;
@ -49,13 +49,13 @@ typedef struct
GDBusProxy *proxy;
GList *tasks;
gboolean removed;
} PvObjectData;
} PinosObjectData;
#define PV_SUBSCRIBE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_SUBSCRIBE, PvSubscribePrivate))
#define PINOS_SUBSCRIBE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SUBSCRIBE, PinosSubscribePrivate))
G_DEFINE_TYPE (PvSubscribe, pv_subscribe, G_TYPE_OBJECT);
G_DEFINE_TYPE (PinosSubscribe, pinos_subscribe, G_TYPE_OBJECT);
enum
{
@ -75,9 +75,10 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
static void
subscription_set_state (PvSubscribe *subscribe, PvSubscriptionState state)
subscription_set_state (PinosSubscribe *subscribe,
PinosSubscriptionState state)
{
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribePrivate *priv = subscribe->priv;
if (state != priv->state) {
priv->state = state;
@ -86,25 +87,25 @@ subscription_set_state (PvSubscribe *subscribe, PvSubscriptionState state)
}
static void
notify_event (PvSubscribe *subscribe,
PvObjectData *data,
PvSubscriptionEvent event)
notify_event (PinosSubscribe *subscribe,
PinosObjectData *data,
PinosSubscriptionEvent event)
{
const gchar *interface_name;
PvSubscriptionFlags flags = 0;
PinosSubscriptionFlags flags = 0;
interface_name = g_dbus_proxy_get_interface_name (data->proxy);
if (g_strcmp0 (interface_name, "org.pinos.Daemon1") == 0) {
flags = PV_SUBSCRIPTION_FLAGS_DAEMON;
flags = PINOS_SUBSCRIPTION_FLAGS_DAEMON;
}
else if (g_strcmp0 (interface_name, "org.pinos.Client1") == 0) {
flags = PV_SUBSCRIPTION_FLAGS_CLIENT;
flags = PINOS_SUBSCRIPTION_FLAGS_CLIENT;
}
else if (g_strcmp0 (interface_name, "org.pinos.Source1") == 0) {
flags = PV_SUBSCRIPTION_FLAGS_SOURCE;
flags = PINOS_SUBSCRIPTION_FLAGS_SOURCE;
}
else if (g_strcmp0 (interface_name, "org.pinos.SourceOutput1") == 0) {
flags = PV_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT;
flags = PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT;
}
g_signal_emit (subscribe, signals[SIGNAL_SUBSCRIPTION_EVENT], 0,
event, flags, data->proxy);
@ -116,13 +117,13 @@ on_proxy_properties_changed (GDBusProxy *proxy,
GStrv invalidated_properties,
gpointer user_data)
{
PvObjectData *data = user_data;
PinosObjectData *data = user_data;
notify_event (data->subscribe, data, PV_SUBSCRIPTION_EVENT_CHANGE);
notify_event (data->subscribe, data, PINOS_SUBSCRIPTION_EVENT_CHANGE);
}
static void
object_data_free (PvObjectData *data)
object_data_free (PinosObjectData *data)
{
g_object_unref (data->proxy);
g_free (data->sender_name);
@ -132,24 +133,25 @@ object_data_free (PvObjectData *data)
}
static void
remove_data (PvSubscribe *subscribe, PvObjectData *data)
remove_data (PinosSubscribe *subscribe,
PinosObjectData *data)
{
if (data->pending) {
data->removed = TRUE;
} else {
notify_event (subscribe, data, PV_SUBSCRIPTION_EVENT_REMOVE);
notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_REMOVE);
object_data_free (data);
}
}
static void
remove_all_data (PvSubscribe *subscribe)
remove_all_data (PinosSubscribe *subscribe)
{
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribePrivate *priv = subscribe->priv;
GList *walk;
for (walk = priv->objects; walk; walk = g_list_next (walk)) {
PvObjectData *data = walk->data;
PinosObjectData *data = walk->data;
remove_data (subscribe, data);
}
g_list_free (priv->objects);
@ -157,13 +159,13 @@ remove_all_data (PvSubscribe *subscribe)
}
static void
on_proxy_created (GObject *source_object,
on_proxy_created (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvObjectData *data = user_data;
PvSubscribe *subscribe = data->subscribe;
PvSubscribePrivate *priv = subscribe->priv;
PinosObjectData *data = user_data;
PinosSubscribe *subscribe = data->subscribe;
PinosSubscribePrivate *priv = subscribe->priv;
GError *error = NULL;
GList *walk;
@ -173,7 +175,7 @@ on_proxy_created (GObject *source_object,
if (data->proxy == NULL) {
priv->objects = g_list_remove (priv->objects, data);
g_warning ("could not create proxy: %s", error->message);
subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_ERROR);
subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_ERROR);
priv->error = error;
return;
}
@ -183,7 +185,7 @@ on_proxy_created (GObject *source_object,
(GCallback) on_proxy_properties_changed,
data);
notify_event (subscribe, data, PV_SUBSCRIPTION_EVENT_NEW);
notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_NEW);
for (walk = data->tasks; walk; walk = g_list_next (walk)) {
GTask *task = walk->data;
@ -194,7 +196,7 @@ on_proxy_created (GObject *source_object,
data->tasks = NULL;
if (--priv->pending_proxies == 0)
subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_READY);
subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_READY);
if (data->removed) {
priv->objects = g_list_remove (priv->objects, data);
@ -204,15 +206,15 @@ on_proxy_created (GObject *source_object,
static void
add_interface (PvSubscribe *subscribe,
const gchar *object_path,
const gchar *interface_name,
GVariant *properties)
add_interface (PinosSubscribe *subscribe,
const gchar *object_path,
const gchar *interface_name,
GVariant *properties)
{
PvSubscribePrivate *priv = subscribe->priv;
PvObjectData *data;
PinosSubscribePrivate *priv = subscribe->priv;
PinosObjectData *data;
data = g_new0 (PvObjectData, 1);
data = g_new0 (PinosObjectData, 1);
data->subscribe = subscribe;
data->sender_name = g_strdup (priv->service);
data->object_path = g_strdup (object_path);
@ -234,15 +236,15 @@ add_interface (PvSubscribe *subscribe,
}
static void
remove_interface (PvSubscribe *subscribe,
const gchar *object_path,
const gchar *interface_name)
remove_interface (PinosSubscribe *subscribe,
const gchar *object_path,
const gchar *interface_name)
{
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribePrivate *priv = subscribe->priv;
GList *walk;
for (walk = priv->objects; walk; walk = g_list_next (walk)) {
PvObjectData *data = walk->data;
PinosObjectData *data = walk->data;
if (g_strcmp0 (data->object_path, object_path) == 0 &&
g_strcmp0 (data->interface_name, interface_name) == 0) {
@ -254,9 +256,9 @@ remove_interface (PvSubscribe *subscribe,
}
static void
add_ifaces_and_properties (PvSubscribe *subscribe,
const gchar *object_path,
GVariant *ifaces_and_properties)
add_ifaces_and_properties (PinosSubscribe *subscribe,
const gchar *object_path,
GVariant *ifaces_and_properties)
{
GVariantIter iter;
const gchar *interface_name;
@ -275,9 +277,9 @@ add_ifaces_and_properties (PvSubscribe *subscribe,
}
static void
remove_ifaces (PvSubscribe *subscribe,
const gchar *object_path,
const gchar **ifaces)
remove_ifaces (PinosSubscribe *subscribe,
const gchar *object_path,
const gchar **ifaces)
{
while (*ifaces) {
remove_interface (subscribe, object_path, *ifaces);
@ -293,7 +295,7 @@ on_manager_proxy_signal (GDBusProxy *proxy,
GVariant *parameters,
gpointer user_data)
{
PvSubscribe *subscribe = user_data;
PinosSubscribe *subscribe = user_data;
const gchar *object_path;
if (g_strcmp0 (signal_name, "InterfacesAdded") == 0) {
@ -321,12 +323,12 @@ on_manager_proxy_signal (GDBusProxy *proxy,
}
static void
on_managed_objects_ready (GObject *source_object,
on_managed_objects_ready (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvSubscribe *subscribe = user_data;
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribe *subscribe = user_data;
PinosSubscribePrivate *priv = subscribe->priv;
GError *error = NULL;
GVariant *objects;
GVariant *arg0;
@ -337,7 +339,7 @@ on_managed_objects_ready (GObject *source_object,
objects = g_dbus_proxy_call_finish (priv->manager_proxy, res, &error);
if (objects == NULL) {
g_warning ("could not get objects: %s", error->message);
subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_ERROR);
subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_ERROR);
priv->error = error;
return;
}
@ -357,13 +359,13 @@ on_managed_objects_ready (GObject *source_object,
g_variant_unref (objects);
if (priv->pending_proxies == 0)
subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_READY);
subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_READY);
}
static void
manager_proxy_appeared (PvSubscribe *subscribe)
manager_proxy_appeared (PinosSubscribe *subscribe)
{
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribePrivate *priv = subscribe->priv;
g_dbus_proxy_call (priv->manager_proxy,
"GetManagedObjects",
@ -376,7 +378,7 @@ manager_proxy_appeared (PvSubscribe *subscribe)
}
static void
manager_proxy_disappeared (PvSubscribe *subscribe)
manager_proxy_disappeared (PinosSubscribe *subscribe)
{
remove_all_data (subscribe);
}
@ -386,8 +388,8 @@ on_manager_proxy_name_owner (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
PvSubscribe *subscribe = user_data;
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribe *subscribe = user_data;
PinosSubscribePrivate *priv = subscribe->priv;
gchar *name_owner;
g_object_get (priv->manager_proxy, "g-name-owner", &name_owner, NULL);
@ -402,9 +404,9 @@ on_manager_proxy_name_owner (GObject *object,
static void
connect_client_signals (PvSubscribe *subscribe)
connect_client_signals (PinosSubscribe *subscribe)
{
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribePrivate *priv = subscribe->priv;
g_signal_connect (priv->manager_proxy, "notify::g-name-owner",
(GCallback) on_manager_proxy_name_owner, subscribe);
@ -414,12 +416,12 @@ connect_client_signals (PvSubscribe *subscribe)
}
static void
on_manager_proxy_ready (GObject *source_object,
on_manager_proxy_ready (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
gpointer user_data)
{
PvSubscribe *subscribe = user_data;
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribe *subscribe = user_data;
PinosSubscribePrivate *priv = subscribe->priv;
GError *error = NULL;
priv->manager_proxy = g_dbus_proxy_new_finish (res, &error);
@ -437,7 +439,7 @@ on_manager_proxy_ready (GObject *source_object,
manager_error:
{
g_warning ("could not create client manager: %s", error->message);
subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_ERROR);
subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_ERROR);
priv->error = error;
g_object_unref (subscribe);
return;
@ -445,17 +447,17 @@ manager_error:
}
static void
install_subscription (PvSubscribe *subscribe)
install_subscription (PinosSubscribe *subscribe)
{
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribePrivate *priv = subscribe->priv;
subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_CONNECTING);
subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_CONNECTING);
g_dbus_proxy_new (priv->connection,
G_DBUS_PROXY_FLAGS_NONE,
NULL, /* GDBusInterfaceInfo* */
priv->service,
PV_DBUS_OBJECT_PREFIX,
PINOS_DBUS_OBJECT_PREFIX,
"org.freedesktop.DBus.ObjectManager",
priv->cancellable,
on_manager_proxy_ready,
@ -463,23 +465,23 @@ install_subscription (PvSubscribe *subscribe)
}
static void
uninstall_subscription (PvSubscribe *subscribe)
uninstall_subscription (PinosSubscribe *subscribe)
{
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribePrivate *priv = subscribe->priv;
g_clear_object (&priv->manager_proxy);
g_clear_error (&priv->error);
subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_UNCONNECTED);
subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_UNCONNECTED);
}
static void
pv_subscribe_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
pinos_subscribe_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PvSubscribe *subscribe = PV_SUBSCRIBE (_object);
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribe *subscribe = PINOS_SUBSCRIBE (_object);
PinosSubscribePrivate *priv = subscribe->priv;
switch (prop_id) {
case PROP_CONNECTION:
@ -505,13 +507,13 @@ pv_subscribe_get_property (GObject *_object,
}
static void
pv_subscribe_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
pinos_subscribe_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PvSubscribe *subscribe = PV_SUBSCRIBE (_object);
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribe *subscribe = PINOS_SUBSCRIBE (_object);
PinosSubscribePrivate *priv = subscribe->priv;
switch (prop_id) {
case PROP_CONNECTION:
@ -541,10 +543,10 @@ pv_subscribe_set_property (GObject *_object,
}
static void
pv_subscribe_finalize (GObject * object)
pinos_subscribe_finalize (GObject * object)
{
PvSubscribe *subscribe = PV_SUBSCRIBE (object);
PvSubscribePrivate *priv = subscribe->priv;
PinosSubscribe *subscribe = PINOS_SUBSCRIBE (object);
PinosSubscribePrivate *priv = subscribe->priv;
g_cancellable_cancel (priv->cancellable);
if (priv->manager_proxy)
@ -552,22 +554,22 @@ pv_subscribe_finalize (GObject * object)
g_object_unref (priv->cancellable);
g_free (priv->service);
G_OBJECT_CLASS (pv_subscribe_parent_class)->finalize (object);
G_OBJECT_CLASS (pinos_subscribe_parent_class)->finalize (object);
}
static void
pv_subscribe_class_init (PvSubscribeClass * klass)
pinos_subscribe_class_init (PinosSubscribeClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (PvSubscribePrivate));
g_type_class_add_private (klass, sizeof (PinosSubscribePrivate));
gobject_class->finalize = pv_subscribe_finalize;
gobject_class->set_property = pv_subscribe_set_property;
gobject_class->get_property = pv_subscribe_get_property;
gobject_class->finalize = pinos_subscribe_finalize;
gobject_class->set_property = pinos_subscribe_set_property;
gobject_class->get_property = pinos_subscribe_get_property;
/**
* PvSubscribe:connection
* PinosSubscribe:connection
*
* The connection of the subscribe.
*/
@ -580,7 +582,7 @@ pv_subscribe_class_init (PvSubscribeClass * klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* PvSubscribe:service
* PinosSubscribe:service
*
* The service of the subscribe.
*/
@ -589,26 +591,26 @@ pv_subscribe_class_init (PvSubscribeClass * klass)
g_param_spec_string ("service",
"Service",
"The service",
PV_DBUS_SERVICE,
PINOS_DBUS_SERVICE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* PvSubscribe:subscription-mask
* PinosSubscribe:subscription-mask
*
* A mask for what object notifications will be signaled with
* PvSubscribe:subscription-event
* PinosSubscribe:subscription-event
*/
g_object_class_install_property (gobject_class,
PROP_SUBSCRIPTION_MASK,
g_param_spec_flags ("subscription-mask",
"Subscription Mask",
"The object to receive subscription events of",
PV_TYPE_SUBSCRIPTION_FLAGS,
PINOS_TYPE_SUBSCRIPTION_FLAGS,
0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* PvSubscribe:state
* PinosSubscribe:state
*
* The state of the subscription
*/
@ -617,15 +619,15 @@ pv_subscribe_class_init (PvSubscribeClass * klass)
g_param_spec_enum ("state",
"State",
"The state",
PV_TYPE_SUBSCRIPTION_STATE,
PV_SUBSCRIPTION_STATE_UNCONNECTED,
PINOS_TYPE_SUBSCRIPTION_STATE,
PINOS_SUBSCRIPTION_STATE_UNCONNECTED,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
/**
* PvSubscribe:subscription-event
* @subscribe: The #PvSubscribe emitting the signal.
* @event: A #PvSubscriptionEvent
* @flags: #PvSubscriptionFlags indicating the object
* PinosSubscribe:subscription-event
* @subscribe: The #PinosSubscribe emitting the signal.
* @event: A #PinosSubscriptionEvent
* @flags: #PinosSubscriptionFlags indicating the object
* @path: the object path
*
* Notify about a new object that was added/removed/modified.
@ -639,62 +641,63 @@ pv_subscribe_class_init (PvSubscribeClass * klass)
g_cclosure_marshal_generic,
G_TYPE_NONE,
3,
PV_TYPE_SUBSCRIPTION_EVENT,
PV_TYPE_SUBSCRIPTION_FLAGS,
PINOS_TYPE_SUBSCRIPTION_EVENT,
PINOS_TYPE_SUBSCRIPTION_FLAGS,
G_TYPE_DBUS_PROXY);
}
static void
pv_subscribe_init (PvSubscribe * subscribe)
pinos_subscribe_init (PinosSubscribe * subscribe)
{
PvSubscribePrivate *priv = subscribe->priv = PV_SUBSCRIBE_GET_PRIVATE (subscribe);
PinosSubscribePrivate *priv = subscribe->priv = PINOS_SUBSCRIBE_GET_PRIVATE (subscribe);
priv->service = g_strdup (PV_DBUS_SERVICE);
priv->state = PV_SUBSCRIPTION_STATE_UNCONNECTED;
priv->service = g_strdup (PINOS_DBUS_SERVICE);
priv->state = PINOS_SUBSCRIPTION_STATE_UNCONNECTED;
priv->cancellable = g_cancellable_new ();
}
/**
* pv_subscribe_new:
* pinos_subscribe_new:
* @name: an application name
* @properties: optional properties
*
* Make a new unconnected #PvSubscribe
* Make a new unconnected #PinosSubscribe
*
* Returns: a new unconnected #PvSubscribe
* Returns: a new unconnected #PinosSubscribe
*/
PvSubscribe *
pv_subscribe_new (void)
PinosSubscribe *
pinos_subscribe_new (void)
{
return g_object_new (PV_TYPE_SUBSCRIBE, NULL);
return g_object_new (PINOS_TYPE_SUBSCRIBE, NULL);
}
PvSubscriptionState
pv_subscribe_get_state (PvSubscribe *subscribe)
PinosSubscriptionState
pinos_subscribe_get_state (PinosSubscribe *subscribe)
{
PvSubscribePrivate *priv;
PinosSubscribePrivate *priv;
g_return_val_if_fail (PV_IS_SUBSCRIBE (subscribe), PV_SUBSCRIPTION_STATE_ERROR);
g_return_val_if_fail (PINOS_IS_SUBSCRIBE (subscribe), PINOS_SUBSCRIPTION_STATE_ERROR);
priv = subscribe->priv;
return priv->state;
}
GError *
pv_subscribe_get_error (PvSubscribe *subscribe)
pinos_subscribe_get_error (PinosSubscribe *subscribe)
{
PvSubscribePrivate *priv;
PinosSubscribePrivate *priv;
g_return_val_if_fail (PV_IS_SUBSCRIBE (subscribe), NULL);
g_return_val_if_fail (PINOS_IS_SUBSCRIBE (subscribe), NULL);
priv = subscribe->priv;
return priv->error;
}
static gint
compare_data (PvObjectData *data, const gchar *name,
const gchar *object_path,
const gchar *interface_name)
compare_data (PinosObjectData *data,
const gchar *name,
const gchar *object_path,
const gchar *interface_name)
{
gint res;
@ -708,22 +711,22 @@ compare_data (PvObjectData *data, const gchar *name,
}
void
pv_subscribe_get_proxy (PvSubscribe *subscribe,
const gchar *name,
const gchar *object_path,
const gchar *interface_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
pinos_subscribe_get_proxy (PinosSubscribe *subscribe,
const gchar *name,
const gchar *object_path,
const gchar *interface_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
PvSubscribePrivate *priv;
PinosSubscribePrivate *priv;
GList *walk;
g_return_if_fail (PV_IS_SUBSCRIBE (subscribe));
g_return_if_fail (PINOS_IS_SUBSCRIBE (subscribe));
priv = subscribe->priv;
for (walk = priv->objects; walk; walk = g_list_next (walk)) {
PvObjectData *data = walk->data;
PinosObjectData *data = walk->data;
if (compare_data (data, name, object_path, interface_name) == 0) {
GTask *task;
@ -746,9 +749,9 @@ pv_subscribe_get_proxy (PvSubscribe *subscribe,
}
GDBusProxy *
pv_subscribe_get_proxy_finish (PvSubscribe *subscribe,
GAsyncResult *res,
GError **error)
pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe,
GAsyncResult *res,
GError **error)
{
return g_task_propagate_pointer (G_TASK (res), error);
}

106
src/client/subscribe.h Normal file
View file

@ -0,0 +1,106 @@
/* 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_SUBSCRIBE_H__
#define __PINOS_SUBSCRIBE_H__
#include <glib.h>
G_BEGIN_DECLS
#define PINOS_TYPE_SUBSCRIBE (pinos_subscribe_get_type ())
#define PINOS_IS_SUBSCRIBE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SUBSCRIBE))
#define PINOS_IS_SUBSCRIBE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SUBSCRIBE))
#define PINOS_SUBSCRIBE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SUBSCRIBE, PinosSubscribeClass))
#define PINOS_SUBSCRIBE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SUBSCRIBE, PinosSubscribe))
#define PINOS_SUBSCRIBE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SUBSCRIBE, PinosSubscribeClass))
#define PINOS_SUBSCRIBE_CAST(obj) ((PinosSubscribe*)(obj))
#define PINOS_SUBSCRIBE_CLASS_CAST(klass) ((PinosSubscribeClass*)(klass))
typedef struct _PinosSubscribe PinosSubscribe;
typedef struct _PinosSubscribeClass PinosSubscribeClass;
typedef struct _PinosSubscribePrivate PinosSubscribePrivate;
typedef enum {
PINOS_SUBSCRIPTION_STATE_UNCONNECTED = 0,
PINOS_SUBSCRIPTION_STATE_CONNECTING = 1,
PINOS_SUBSCRIPTION_STATE_READY = 2,
PINOS_SUBSCRIPTION_STATE_ERROR = 3,
} PinosSubscriptionState;
typedef enum {
PINOS_SUBSCRIPTION_FLAGS_DAEMON = (1 << 0),
PINOS_SUBSCRIPTION_FLAGS_CLIENT = (1 << 1),
PINOS_SUBSCRIPTION_FLAGS_SOURCE = (1 << 2),
PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT = (1 << 3),
} PinosSubscriptionFlags;
#define PINOS_SUBSCRIPTION_FLAGS_ALL 0xf
typedef enum {
PINOS_SUBSCRIPTION_EVENT_NEW = 0,
PINOS_SUBSCRIPTION_EVENT_CHANGE = 1,
PINOS_SUBSCRIPTION_EVENT_REMOVE = 2,
} PinosSubscriptionEvent;
/**
* PinosSubscribe:
*
* Pinos subscribe object class.
*/
struct _PinosSubscribe {
GObject object;
PinosSubscribePrivate *priv;
};
/**
* PinosSubscribeClass:
*
* Pinos subscribe object class.
*/
struct _PinosSubscribeClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pinos_subscribe_get_type (void);
PinosSubscribe * pinos_subscribe_new (void);
PinosSubscriptionState pinos_subscribe_get_state (PinosSubscribe *subscribe);
GError * pinos_subscribe_get_error (PinosSubscribe *subscribe);
void pinos_subscribe_get_proxy (PinosSubscribe *subscribe,
const gchar *name,
const gchar *object_path,
const gchar *interface_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDBusProxy * pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe,
GAsyncResult *res,
GError **error);
G_END_DECLS
#endif /* __PINOS_SUBSCRIBE_H__ */