mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-17 07:00:03 -05:00
Work on introspection
This commit is contained in:
parent
7c29209023
commit
b969623ec8
39 changed files with 1726 additions and 574 deletions
|
|
@ -126,6 +126,99 @@ connection_parse_create_client_node (PinosConnection *conn, PinosMessageCreateCl
|
|||
m->props = pinos_serialize_dict_deserialize (p, SPA_PTR_TO_INT (m->props));
|
||||
}
|
||||
|
||||
static void
|
||||
connection_parse_core_info (PinosConnection *conn, PinosMessageCoreInfo *m)
|
||||
{
|
||||
void *p;
|
||||
PinosCoreInfo *di;
|
||||
|
||||
p = conn->in.data;
|
||||
memcpy (m, p, sizeof (PinosMessageCoreInfo));
|
||||
if (m->info) {
|
||||
m->info = SPA_MEMBER (p, SPA_PTR_TO_INT (m->info), PinosCoreInfo);
|
||||
di = m->info;
|
||||
|
||||
if (m->info->user_name)
|
||||
m->info->user_name = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->user_name), const char);
|
||||
if (m->info->host_name)
|
||||
m->info->host_name = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->host_name), const char);
|
||||
if (m->info->version)
|
||||
m->info->version = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->version), const char);
|
||||
if (m->info->name)
|
||||
m->info->name = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->name), const char);
|
||||
if (m->info->props)
|
||||
m->info->props = pinos_serialize_dict_deserialize (di, SPA_PTR_TO_INT (m->info->props));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_parse_module_info (PinosConnection *conn, PinosMessageModuleInfo *m)
|
||||
{
|
||||
void *p;
|
||||
PinosModuleInfo *di;
|
||||
|
||||
p = conn->in.data;
|
||||
memcpy (m, p, sizeof (PinosMessageModuleInfo));
|
||||
if (m->info) {
|
||||
m->info = SPA_MEMBER (p, SPA_PTR_TO_INT (m->info), PinosModuleInfo);
|
||||
di = m->info;
|
||||
if (m->info->name)
|
||||
m->info->name = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->name), const char);
|
||||
if (m->info->filename)
|
||||
m->info->filename = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->filename), const char);
|
||||
if (m->info->args)
|
||||
m->info->args = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->args), const char);
|
||||
if (m->info->props)
|
||||
m->info->props = pinos_serialize_dict_deserialize (di, SPA_PTR_TO_INT (m->info->props));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_parse_node_info (PinosConnection *conn, PinosMessageNodeInfo *m)
|
||||
{
|
||||
void *p;
|
||||
PinosNodeInfo *di;
|
||||
|
||||
p = conn->in.data;
|
||||
memcpy (m, p, sizeof (PinosMessageNodeInfo));
|
||||
if (m->info) {
|
||||
m->info = SPA_MEMBER (p, SPA_PTR_TO_INT (m->info), PinosNodeInfo);
|
||||
di = m->info;
|
||||
|
||||
if (m->info->name)
|
||||
m->info->name = SPA_MEMBER (di, SPA_PTR_TO_INT (m->info->name), const char);
|
||||
if (m->info->props)
|
||||
m->info->props = pinos_serialize_dict_deserialize (di, SPA_PTR_TO_INT (m->info->props));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_parse_client_info (PinosConnection *conn, PinosMessageClientInfo *m)
|
||||
{
|
||||
void *p;
|
||||
PinosClientInfo *di;
|
||||
|
||||
p = conn->in.data;
|
||||
memcpy (m, p, sizeof (PinosMessageClientInfo));
|
||||
if (m->info) {
|
||||
m->info = SPA_MEMBER (p, SPA_PTR_TO_INT (m->info), PinosClientInfo);
|
||||
di = m->info;
|
||||
if (m->info->props)
|
||||
m->info->props = pinos_serialize_dict_deserialize (di, SPA_PTR_TO_INT (m->info->props));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_parse_link_info (PinosConnection *conn, PinosMessageLinkInfo *m)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = conn->in.data;
|
||||
memcpy (m, p, sizeof (PinosMessageLinkInfo));
|
||||
if (m->info)
|
||||
m->info = SPA_MEMBER (p, SPA_PTR_TO_INT (m->info), PinosLinkInfo);
|
||||
}
|
||||
|
||||
static void
|
||||
connection_parse_node_update (PinosConnection *conn, PinosMessageNodeUpdate *nu)
|
||||
{
|
||||
|
|
@ -297,8 +390,6 @@ connection_add_create_node (PinosConnection *conn, uint32_t dest_id, PinosMessag
|
|||
if (m->props) {
|
||||
len = pinos_serialize_dict_serialize (p, m->props);
|
||||
d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
} else {
|
||||
d->props = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -328,8 +419,223 @@ connection_add_create_client_node (PinosConnection *conn, uint32_t dest_id, Pino
|
|||
if (m->props) {
|
||||
len = pinos_serialize_dict_serialize (p, m->props);
|
||||
d->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
} else {
|
||||
d->props = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_add_core_info (PinosConnection *conn, uint32_t dest_id, PinosMessageCoreInfo *m)
|
||||
{
|
||||
size_t len, slen;
|
||||
void *p;
|
||||
PinosMessageCoreInfo *d;
|
||||
|
||||
/* calc len */
|
||||
len = sizeof (PinosMessageCoreInfo);
|
||||
if (m->info) {
|
||||
len += sizeof (PinosCoreInfo);
|
||||
len += m->info->user_name ? strlen (m->info->user_name) + 1 : 0;
|
||||
len += m->info->host_name ? strlen (m->info->host_name) + 1 : 0;
|
||||
len += m->info->version ? strlen (m->info->version) + 1 : 0;
|
||||
len += m->info->name ? strlen (m->info->name) + 1 : 0;
|
||||
len += pinos_serialize_dict_get_size (m->info->props);
|
||||
}
|
||||
|
||||
p = connection_add_message (conn, dest_id, PINOS_MESSAGE_CORE_INFO, len);
|
||||
memcpy (p, m, sizeof (PinosMessageCoreInfo));
|
||||
d = p;
|
||||
|
||||
p = SPA_MEMBER (d, sizeof (PinosMessageCoreInfo), void);
|
||||
if (m->info) {
|
||||
PinosCoreInfo *di;
|
||||
|
||||
memcpy (p, m->info, sizeof (PinosCoreInfo));
|
||||
di = p;
|
||||
|
||||
d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
|
||||
p = SPA_MEMBER (p, sizeof (PinosCoreInfo), void);
|
||||
if (m->info->user_name) {
|
||||
slen = strlen (m->info->user_name) + 1;
|
||||
memcpy (p, m->info->user_name, slen);
|
||||
di->user_name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
if (m->info->host_name) {
|
||||
slen = strlen (m->info->host_name) + 1;
|
||||
memcpy (p, m->info->host_name, slen);
|
||||
di->host_name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
if (m->info->version) {
|
||||
slen = strlen (m->info->version) + 1;
|
||||
memcpy (p, m->info->version, slen);
|
||||
di->version = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
if (m->info->name) {
|
||||
slen = strlen (m->info->name) + 1;
|
||||
memcpy (p, m->info->name, slen);
|
||||
di->name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
if (m->info->props) {
|
||||
len = pinos_serialize_dict_serialize (p, m->info->props);
|
||||
di->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_add_module_info (PinosConnection *conn, uint32_t dest_id, PinosMessageModuleInfo *m)
|
||||
{
|
||||
size_t len, slen;
|
||||
void *p;
|
||||
PinosMessageModuleInfo *d;
|
||||
|
||||
/* calc len */
|
||||
len = sizeof (PinosMessageModuleInfo);
|
||||
if (m->info) {
|
||||
len += sizeof (PinosModuleInfo);
|
||||
len += m->info->name ? strlen (m->info->name) + 1 : 0;
|
||||
len += m->info->filename ? strlen (m->info->filename) + 1 : 0;
|
||||
len += m->info->args ? strlen (m->info->args) + 1 : 0;
|
||||
len += pinos_serialize_dict_get_size (m->info->props);
|
||||
}
|
||||
|
||||
p = connection_add_message (conn, dest_id, PINOS_MESSAGE_MODULE_INFO, len);
|
||||
memcpy (p, m, sizeof (PinosMessageModuleInfo));
|
||||
d = p;
|
||||
|
||||
p = SPA_MEMBER (d, sizeof (PinosMessageModuleInfo), void);
|
||||
if (m->info) {
|
||||
PinosModuleInfo *di;
|
||||
|
||||
memcpy (p, m->info, sizeof (PinosModuleInfo));
|
||||
d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
di = p;
|
||||
|
||||
p = SPA_MEMBER (p, sizeof (PinosModuleInfo), void);
|
||||
if (m->info->name) {
|
||||
slen = strlen (m->info->name) + 1;
|
||||
memcpy (p, m->info->name, slen);
|
||||
di->name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
if (m->info->filename) {
|
||||
slen = strlen (m->info->filename) + 1;
|
||||
memcpy (p, m->info->filename, slen);
|
||||
di->filename = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
if (m->info->args) {
|
||||
slen = strlen (m->info->args) + 1;
|
||||
memcpy (p, m->info->args, slen);
|
||||
di->args = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
if (m->info->props) {
|
||||
len = pinos_serialize_dict_serialize (p, m->info->props);
|
||||
di->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_add_node_info (PinosConnection *conn, uint32_t dest_id, PinosMessageNodeInfo *m)
|
||||
{
|
||||
size_t len, slen;
|
||||
void *p;
|
||||
PinosMessageNodeInfo *d;
|
||||
|
||||
/* calc len */
|
||||
len = sizeof (PinosMessageNodeInfo);
|
||||
if (m->info) {
|
||||
len += sizeof (PinosNodeInfo);
|
||||
len += m->info->name ? strlen (m->info->name) + 1 : 0;
|
||||
len += pinos_serialize_dict_get_size (m->info->props);
|
||||
}
|
||||
|
||||
p = connection_add_message (conn, dest_id, PINOS_MESSAGE_NODE_INFO, len);
|
||||
memcpy (p, m, sizeof (PinosMessageNodeInfo));
|
||||
d = p;
|
||||
|
||||
p = SPA_MEMBER (d, sizeof (PinosMessageNodeInfo), void);
|
||||
if (m->info) {
|
||||
PinosNodeInfo *di;
|
||||
|
||||
memcpy (p, m->info, sizeof (PinosNodeInfo));
|
||||
d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
di = p;
|
||||
|
||||
p = SPA_MEMBER (p, sizeof (PinosNodeInfo), void);
|
||||
if (m->info->name) {
|
||||
slen = strlen (m->info->name) + 1;
|
||||
memcpy (p, m->info->name, slen);
|
||||
di->name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
p += slen;
|
||||
}
|
||||
if (m->info->props) {
|
||||
len = pinos_serialize_dict_serialize (p, m->info->props);
|
||||
di->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_add_client_info (PinosConnection *conn, uint32_t dest_id, PinosMessageClientInfo *m)
|
||||
{
|
||||
size_t len;
|
||||
void *p;
|
||||
PinosMessageClientInfo *d;
|
||||
|
||||
/* calc len */
|
||||
len = sizeof (PinosMessageClientInfo);
|
||||
if (m->info) {
|
||||
len += sizeof (PinosClientInfo);
|
||||
len += pinos_serialize_dict_get_size (m->info->props);
|
||||
}
|
||||
|
||||
p = connection_add_message (conn, dest_id, PINOS_MESSAGE_CLIENT_INFO, len);
|
||||
memcpy (p, m, sizeof (PinosMessageClientInfo));
|
||||
d = p;
|
||||
|
||||
p = SPA_MEMBER (d, sizeof (PinosMessageClientInfo), void);
|
||||
if (m->info) {
|
||||
PinosClientInfo *di;
|
||||
|
||||
memcpy (p, m->info, sizeof (PinosClientInfo));
|
||||
d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
di = p;
|
||||
|
||||
p = SPA_MEMBER (p, sizeof (PinosClientInfo), void);
|
||||
if (m->info->props) {
|
||||
len = pinos_serialize_dict_serialize (p, m->info->props);
|
||||
di->props = SPA_INT_TO_PTR (SPA_PTRDIFF (p, di));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connection_add_link_info (PinosConnection *conn, uint32_t dest_id, PinosMessageLinkInfo *m)
|
||||
{
|
||||
size_t len;
|
||||
void *p;
|
||||
PinosMessageLinkInfo *d;
|
||||
|
||||
/* calc len */
|
||||
len = sizeof (PinosMessageLinkInfo);
|
||||
if (m->info) {
|
||||
len += sizeof (PinosLinkInfo);
|
||||
}
|
||||
|
||||
p = connection_add_message (conn, dest_id, PINOS_MESSAGE_LINK_INFO, len);
|
||||
memcpy (p, m, sizeof (PinosMessageLinkInfo));
|
||||
d = p;
|
||||
|
||||
p = SPA_MEMBER (d, sizeof (PinosMessageLinkInfo), void);
|
||||
if (m->info) {
|
||||
memcpy (p, m->info, sizeof (PinosLinkInfo));
|
||||
d->info = SPA_INT_TO_PTR (SPA_PTRDIFF (p, d));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -761,10 +1067,30 @@ pinos_connection_parse_message (PinosConnection *conn,
|
|||
memcpy (message, conn->in.data, sizeof (PinosMessageDestroy));
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_DESTROY_DONE:
|
||||
if (conn->in.size < sizeof (PinosMessageDestroyDone))
|
||||
case PINOS_MESSAGE_REMOVE_ID:
|
||||
if (conn->in.size < sizeof (PinosMessageRemoveId))
|
||||
return false;
|
||||
memcpy (message, conn->in.data, sizeof (PinosMessageDestroyDone));
|
||||
memcpy (message, conn->in.data, sizeof (PinosMessageRemoveId));
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_CORE_INFO:
|
||||
connection_parse_core_info (conn, message);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_MODULE_INFO:
|
||||
connection_parse_module_info (conn, message);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_NODE_INFO:
|
||||
connection_parse_node_info (conn, message);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_CLIENT_INFO:
|
||||
connection_parse_client_info (conn, message);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_LINK_INFO:
|
||||
connection_parse_link_info (conn, message);
|
||||
break;
|
||||
|
||||
/* C -> S */
|
||||
|
|
@ -927,11 +1253,30 @@ pinos_connection_add_message (PinosConnection *conn,
|
|||
memcpy (p, message, sizeof (PinosMessageDestroy));
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_DESTROY_DONE:
|
||||
p = connection_add_message (conn, dest_id, type, sizeof (PinosMessageDestroyDone));
|
||||
memcpy (p, message, sizeof (PinosMessageDestroyDone));
|
||||
case PINOS_MESSAGE_REMOVE_ID:
|
||||
p = connection_add_message (conn, dest_id, type, sizeof (PinosMessageRemoveId));
|
||||
memcpy (p, message, sizeof (PinosMessageRemoveId));
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_CORE_INFO:
|
||||
connection_add_core_info (conn, dest_id, message);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_MODULE_INFO:
|
||||
connection_add_module_info (conn, dest_id, message);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_NODE_INFO:
|
||||
connection_add_node_info (conn, dest_id, message);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_CLIENT_INFO:
|
||||
connection_add_client_info (conn, dest_id, message);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_LINK_INFO:
|
||||
connection_add_link_info (conn, dest_id, message);
|
||||
break;
|
||||
|
||||
/* C -> S */
|
||||
case PINOS_MESSAGE_NODE_UPDATE:
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ typedef enum {
|
|||
PINOS_MESSAGE_SYNC,
|
||||
PINOS_MESSAGE_NOTIFY_DONE,
|
||||
PINOS_MESSAGE_GET_REGISTRY,
|
||||
PINOS_MESSAGE_REMOVE_ID,
|
||||
PINOS_MESSAGE_CORE_INFO,
|
||||
|
||||
PINOS_MESSAGE_BIND,
|
||||
PINOS_MESSAGE_NOTIFY_GLOBAL,
|
||||
|
|
@ -50,7 +52,11 @@ typedef enum {
|
|||
PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE,
|
||||
|
||||
PINOS_MESSAGE_DESTROY,
|
||||
PINOS_MESSAGE_DESTROY_DONE,
|
||||
|
||||
PINOS_MESSAGE_MODULE_INFO,
|
||||
PINOS_MESSAGE_NODE_INFO,
|
||||
PINOS_MESSAGE_CLIENT_INFO,
|
||||
PINOS_MESSAGE_LINK_INFO,
|
||||
|
||||
/* client to server */
|
||||
PINOS_MESSAGE_NODE_UPDATE,
|
||||
|
|
@ -78,6 +84,8 @@ typedef enum {
|
|||
|
||||
} PinosMessageType;
|
||||
|
||||
#include <pinos/client/introspect.h>
|
||||
|
||||
/* PINOS_MESSAGE_SYNC */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
|
|
@ -94,6 +102,36 @@ typedef struct {
|
|||
uint32_t new_id;
|
||||
} PinosMessageGetRegistry;
|
||||
|
||||
/* PINOS_MESSAGE_REMOVE_ID */
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
} PinosMessageRemoveId;
|
||||
|
||||
/* PINOS_MESSAGE_CORE_INFO */
|
||||
typedef struct {
|
||||
PinosCoreInfo *info;
|
||||
} PinosMessageCoreInfo;
|
||||
|
||||
/* PINOS_MESSAGE_MODULE_INFO */
|
||||
typedef struct {
|
||||
PinosModuleInfo *info;
|
||||
} PinosMessageModuleInfo;
|
||||
|
||||
/* PINOS_MESSAGE_NODE_INFO */
|
||||
typedef struct {
|
||||
PinosNodeInfo *info;
|
||||
} PinosMessageNodeInfo;
|
||||
|
||||
/* PINOS_MESSAGE_CLIENT_INFO */
|
||||
typedef struct {
|
||||
PinosClientInfo *info;
|
||||
} PinosMessageClientInfo;
|
||||
|
||||
/* PINOS_MESSAGE_LINK_INFO */
|
||||
typedef struct {
|
||||
PinosLinkInfo *info;
|
||||
} PinosMessageLinkInfo;
|
||||
|
||||
/* PINOS_MESSAGE_BIND */
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
|
|
@ -145,12 +183,6 @@ typedef struct {
|
|||
uint32_t id;
|
||||
} PinosMessageDestroy;
|
||||
|
||||
/* PINOS_MESSAGE_DESTROY_DONE */
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
uint32_t id;
|
||||
} PinosMessageDestroyDone;
|
||||
|
||||
/* PINOS_MESSAGE_NODE_UPDATE */
|
||||
typedef struct {
|
||||
#define PINOS_MESSAGE_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ typedef struct {
|
|||
|
||||
bool disconnecting;
|
||||
|
||||
PinosSubscriptionFlags subscribe_mask;
|
||||
PinosSubscriptionFunc subscribe_func;
|
||||
void *subscribe_data;
|
||||
} PinosContextImpl;
|
||||
|
|
@ -102,7 +101,8 @@ core_dispatch_func (void *object,
|
|||
void *message,
|
||||
void *data)
|
||||
{
|
||||
PinosContext *context = data;
|
||||
PinosContextImpl *impl = data;
|
||||
PinosContext *this = &impl->this;
|
||||
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_NOTIFY_DONE:
|
||||
|
|
@ -110,7 +110,142 @@ core_dispatch_func (void *object,
|
|||
PinosMessageNotifyDone *nd = message;
|
||||
|
||||
if (nd->seq == 0)
|
||||
context_set_state (context, PINOS_CONTEXT_STATE_CONNECTED, NULL);
|
||||
context_set_state (this, PINOS_CONTEXT_STATE_CONNECTED, NULL);
|
||||
break;
|
||||
}
|
||||
case PINOS_MESSAGE_REMOVE_ID:
|
||||
{
|
||||
PinosMessageRemoveId *m = message;
|
||||
PinosProxy *proxy;
|
||||
|
||||
proxy = pinos_map_lookup (&this->objects, m->id);
|
||||
if (proxy) {
|
||||
pinos_log_debug ("context %p: object remove %u", this, m->id);
|
||||
pinos_map_remove (&this->objects, m->id);
|
||||
pinos_proxy_destroy (proxy);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
pinos_log_warn ("unhandled message %d", type);
|
||||
break;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
module_dispatch_func (void *object,
|
||||
PinosMessageType type,
|
||||
void *message,
|
||||
void *data)
|
||||
{
|
||||
PinosContextImpl *impl = data;
|
||||
PinosContext *this = &impl->this;
|
||||
PinosProxy *proxy = object;
|
||||
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_MODULE_INFO:
|
||||
{
|
||||
PinosMessageModuleInfo *m = message;
|
||||
PinosSubscriptionEvent event;
|
||||
|
||||
pinos_log_debug ("got module info %d", type);
|
||||
if (proxy->user_data == NULL)
|
||||
event = PINOS_SUBSCRIPTION_EVENT_NEW;
|
||||
else
|
||||
event = PINOS_SUBSCRIPTION_EVENT_CHANGE;
|
||||
|
||||
proxy->user_data = pinos_module_info_update (proxy->user_data, m->info);
|
||||
|
||||
if (impl->subscribe_func) {
|
||||
impl->subscribe_func (this,
|
||||
event,
|
||||
proxy->type,
|
||||
proxy->id,
|
||||
impl->subscribe_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
pinos_log_warn ("unhandled message %d", type);
|
||||
break;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
node_dispatch_func (void *object,
|
||||
PinosMessageType type,
|
||||
void *message,
|
||||
void *data)
|
||||
{
|
||||
PinosContextImpl *impl = data;
|
||||
PinosContext *this = &impl->this;
|
||||
PinosProxy *proxy = object;
|
||||
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_NODE_INFO:
|
||||
{
|
||||
PinosMessageNodeInfo *m = message;
|
||||
PinosSubscriptionEvent event;
|
||||
|
||||
pinos_log_debug ("got node info %d", type);
|
||||
if (proxy->user_data == NULL)
|
||||
event = PINOS_SUBSCRIPTION_EVENT_NEW;
|
||||
else
|
||||
event = PINOS_SUBSCRIPTION_EVENT_CHANGE;
|
||||
|
||||
proxy->user_data = pinos_node_info_update (proxy->user_data, m->info);
|
||||
|
||||
if (impl->subscribe_func) {
|
||||
impl->subscribe_func (this,
|
||||
event,
|
||||
proxy->type,
|
||||
proxy->id,
|
||||
impl->subscribe_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
pinos_log_warn ("unhandled message %d", type);
|
||||
break;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
client_dispatch_func (void *object,
|
||||
PinosMessageType type,
|
||||
void *message,
|
||||
void *data)
|
||||
{
|
||||
PinosContextImpl *impl = data;
|
||||
PinosContext *this = &impl->this;
|
||||
PinosProxy *proxy = object;
|
||||
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_CLIENT_INFO:
|
||||
{
|
||||
PinosMessageClientInfo *m = message;
|
||||
PinosSubscriptionEvent event;
|
||||
|
||||
pinos_log_debug ("got client info %d", type);
|
||||
if (proxy->user_data == NULL)
|
||||
event = PINOS_SUBSCRIPTION_EVENT_NEW;
|
||||
else
|
||||
event = PINOS_SUBSCRIPTION_EVENT_CHANGE;
|
||||
|
||||
proxy->user_data = pinos_client_info_update (proxy->user_data, m->info);
|
||||
|
||||
if (impl->subscribe_func) {
|
||||
impl->subscribe_func (this,
|
||||
event,
|
||||
proxy->type,
|
||||
proxy->id,
|
||||
impl->subscribe_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -126,17 +261,61 @@ registry_dispatch_func (void *object,
|
|||
void *message,
|
||||
void *data)
|
||||
{
|
||||
PinosContextImpl *impl = data;
|
||||
PinosContext *this = &impl->this;
|
||||
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_NOTIFY_GLOBAL:
|
||||
{
|
||||
PinosMessageNotifyGlobal *ng = message;
|
||||
PinosProxy *proxy = NULL;
|
||||
|
||||
pinos_log_debug ("got global %u %s", ng->id, ng->type);
|
||||
|
||||
if (!strcmp (ng->type, PINOS_NODE_URI)) {
|
||||
proxy = pinos_proxy_new (this,
|
||||
SPA_ID_INVALID,
|
||||
this->uri.node);
|
||||
proxy->dispatch_func = node_dispatch_func;
|
||||
proxy->dispatch_data = impl;
|
||||
} else if (!strcmp (ng->type, PINOS_MODULE_URI)) {
|
||||
proxy = pinos_proxy_new (this,
|
||||
SPA_ID_INVALID,
|
||||
this->uri.module);
|
||||
proxy->dispatch_func = module_dispatch_func;
|
||||
proxy->dispatch_data = impl;
|
||||
} else if (!strcmp (ng->type, PINOS_CLIENT_URI)) {
|
||||
proxy = pinos_proxy_new (this,
|
||||
SPA_ID_INVALID,
|
||||
this->uri.client);
|
||||
proxy->dispatch_func = client_dispatch_func;
|
||||
proxy->dispatch_data = impl;
|
||||
} else if (!strcmp (ng->type, PINOS_LINK_URI)) {
|
||||
}
|
||||
if (proxy) {
|
||||
PinosMessageBind m;
|
||||
|
||||
m.id = ng->id;
|
||||
m.new_id = proxy->id;
|
||||
pinos_proxy_send_message (this->registry_proxy,
|
||||
PINOS_MESSAGE_BIND,
|
||||
&m,
|
||||
true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE:
|
||||
{
|
||||
PinosMessageNotifyGlobalRemove *ng = message;
|
||||
pinos_log_debug ("got global remove %u", ng->id);
|
||||
|
||||
if (impl->subscribe_func) {
|
||||
impl->subscribe_func (this,
|
||||
PINOS_SUBSCRIPTION_EVENT_REMOVE,
|
||||
SPA_ID_INVALID,
|
||||
ng->id,
|
||||
impl->subscribe_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -146,19 +325,6 @@ registry_dispatch_func (void *object,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static PinosProxy *
|
||||
find_proxy (PinosContext *context,
|
||||
uint32_t id)
|
||||
{
|
||||
PinosProxy *p;
|
||||
|
||||
spa_list_for_each (p, &context->proxy_list, link) {
|
||||
if (p->id == id)
|
||||
return p;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
on_context_data (SpaSource *source,
|
||||
int fd,
|
||||
|
|
@ -190,11 +356,15 @@ on_context_data (SpaSource *source,
|
|||
continue;
|
||||
}
|
||||
|
||||
proxy = find_proxy (this, id);
|
||||
proxy = pinos_map_lookup (&this->objects, id);
|
||||
if (proxy == NULL) {
|
||||
pinos_log_error ("context %p: could not find proxy %u", this, id);
|
||||
continue;
|
||||
}
|
||||
if (proxy->dispatch_func == NULL) {
|
||||
pinos_log_error ("context %p: no dispatch function for proxy %u", this, id);
|
||||
continue;
|
||||
}
|
||||
|
||||
proxy->dispatch_func (proxy, type, p, proxy->dispatch_data);
|
||||
}
|
||||
|
|
@ -250,6 +420,8 @@ pinos_context_new (PinosLoop *loop,
|
|||
pinos_fill_context_properties (properties);
|
||||
this->properties = properties;
|
||||
|
||||
pinos_uri_init (&this->uri);
|
||||
|
||||
this->loop = loop;
|
||||
|
||||
this->state = PINOS_CONTEXT_STATE_UNCONNECTED;
|
||||
|
|
@ -365,15 +537,15 @@ pinos_context_connect (PinosContext *context)
|
|||
|
||||
context->core_proxy = pinos_proxy_new (context,
|
||||
SPA_ID_INVALID,
|
||||
0);
|
||||
context->uri.core);
|
||||
context->core_proxy->dispatch_func = core_dispatch_func;
|
||||
context->core_proxy->dispatch_data = context;
|
||||
context->core_proxy->dispatch_data = impl;
|
||||
|
||||
context->registry_proxy = pinos_proxy_new (context,
|
||||
SPA_ID_INVALID,
|
||||
0);
|
||||
context->uri.registry);
|
||||
context->registry_proxy->dispatch_func = registry_dispatch_func;
|
||||
context->registry_proxy->dispatch_data = context;
|
||||
context->registry_proxy->dispatch_data = impl;
|
||||
|
||||
grm.seq = 0;
|
||||
grm.new_id = context->registry_proxy->id;
|
||||
|
|
@ -409,23 +581,84 @@ pinos_context_disconnect (PinosContext *context)
|
|||
|
||||
void
|
||||
pinos_context_subscribe (PinosContext *context,
|
||||
PinosSubscriptionFlags mask,
|
||||
PinosSubscriptionFunc func,
|
||||
void *data)
|
||||
{
|
||||
PinosContextImpl *impl = SPA_CONTAINER_OF (context, PinosContextImpl, this);
|
||||
|
||||
impl->subscribe_mask = mask;
|
||||
impl->subscribe_func = func;
|
||||
impl->subscribe_data = data;
|
||||
}
|
||||
|
||||
void
|
||||
pinos_context_get_daemon_info (PinosContext *context,
|
||||
PinosDaemonInfoCallback cb,
|
||||
void *user_data)
|
||||
pinos_context_get_core_info (PinosContext *context,
|
||||
PinosCoreInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
cb (context, SPA_RESULT_OK, NULL, user_data);
|
||||
PinosProxy *proxy;
|
||||
|
||||
proxy = pinos_map_lookup (&context->objects, 0);
|
||||
if (proxy == NULL) {
|
||||
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
|
||||
} else if (proxy->type == context->uri.core && proxy->user_data) {
|
||||
PinosCoreInfo *info = proxy->user_data;
|
||||
cb (context, SPA_RESULT_OK, info, user_data);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
cb (context, SPA_RESULT_ENUM_END, NULL, user_data);
|
||||
}
|
||||
|
||||
typedef void (*ListFunc) (PinosContext *, SpaResult, void *, void *);
|
||||
|
||||
static void
|
||||
do_list (PinosContext *context,
|
||||
uint32_t type,
|
||||
ListFunc cb,
|
||||
void *user_data)
|
||||
{
|
||||
PinosMapItem *item;
|
||||
|
||||
pinos_array_for_each (item, &context->objects.items) {
|
||||
PinosProxy *proxy;
|
||||
|
||||
if (pinos_map_item_is_free (item))
|
||||
continue;
|
||||
|
||||
proxy = item->data;
|
||||
if (proxy->type != type)
|
||||
continue;
|
||||
|
||||
cb (context, SPA_RESULT_OK, proxy->user_data, user_data);
|
||||
}
|
||||
cb (context, SPA_RESULT_ENUM_END, NULL, user_data);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pinos_context_list_module_info (PinosContext *context,
|
||||
PinosModuleInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
do_list (context, context->uri.module, (ListFunc) cb, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
pinos_context_get_module_info_by_id (PinosContext *context,
|
||||
uint32_t id,
|
||||
PinosModuleInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
PinosProxy *proxy;
|
||||
|
||||
proxy = pinos_map_lookup (&context->objects, id);
|
||||
if (proxy == NULL) {
|
||||
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
|
||||
} else if (proxy->type == context->uri.module && proxy->user_data) {
|
||||
PinosModuleInfo *info = proxy->user_data;
|
||||
cb (context, SPA_RESULT_OK, info, user_data);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
cb (context, SPA_RESULT_ENUM_END, NULL, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -433,7 +666,7 @@ pinos_context_list_client_info (PinosContext *context,
|
|||
PinosClientInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
cb (context, SPA_RESULT_OK, NULL, user_data);
|
||||
do_list (context, context->uri.client, (ListFunc) cb, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -442,7 +675,17 @@ pinos_context_get_client_info_by_id (PinosContext *context,
|
|||
PinosClientInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
cb (context, SPA_RESULT_OK, NULL, user_data);
|
||||
PinosProxy *proxy;
|
||||
|
||||
proxy = pinos_map_lookup (&context->objects, id);
|
||||
if (proxy == NULL) {
|
||||
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
|
||||
} else if (proxy->type == context->uri.client && proxy->user_data) {
|
||||
PinosClientInfo *info = proxy->user_data;
|
||||
cb (context, SPA_RESULT_OK, info, user_data);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
cb (context, SPA_RESULT_ENUM_END, NULL, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -450,7 +693,7 @@ pinos_context_list_node_info (PinosContext *context,
|
|||
PinosNodeInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
cb (context, SPA_RESULT_OK, NULL, user_data);
|
||||
do_list (context, context->uri.node, (ListFunc) cb, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -459,7 +702,17 @@ pinos_context_get_node_info_by_id (PinosContext *context,
|
|||
PinosNodeInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
cb (context, SPA_RESULT_OK, NULL, user_data);
|
||||
PinosProxy *proxy;
|
||||
|
||||
proxy = pinos_map_lookup (&context->objects, id);
|
||||
if (proxy == NULL) {
|
||||
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
|
||||
} else if (proxy->type == context->uri.node && proxy->user_data) {
|
||||
PinosNodeInfo *info = proxy->user_data;
|
||||
cb (context, SPA_RESULT_OK, info, user_data);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
cb (context, SPA_RESULT_ENUM_END, NULL, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -467,7 +720,7 @@ pinos_context_list_link_info (PinosContext *context,
|
|||
PinosLinkInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
cb (context, SPA_RESULT_OK, NULL, user_data);
|
||||
do_list (context, context->uri.link, (ListFunc) cb, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -476,5 +729,15 @@ pinos_context_get_link_info_by_id (PinosContext *context,
|
|||
PinosLinkInfoCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
cb (context, SPA_RESULT_OK, NULL, user_data);
|
||||
PinosProxy *proxy;
|
||||
|
||||
proxy = pinos_map_lookup (&context->objects, id);
|
||||
if (proxy == NULL) {
|
||||
cb (context, SPA_RESULT_INVALID_OBJECT_ID, NULL, user_data);
|
||||
} else if (proxy->type == context->uri.link && proxy->user_data) {
|
||||
PinosLinkInfo *info = proxy->user_data;
|
||||
cb (context, SPA_RESULT_OK, info, user_data);
|
||||
info->change_mask = 0;
|
||||
}
|
||||
cb (context, SPA_RESULT_ENUM_END, NULL, user_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,9 @@ typedef struct _PinosContext PinosContext;
|
|||
|
||||
#include <pinos/client/map.h>
|
||||
#include <pinos/client/loop.h>
|
||||
#include <pinos/client/subscribe.h>
|
||||
#include <pinos/client/properties.h>
|
||||
#include <pinos/client/connection.h>
|
||||
#include <pinos/client/proxy.h>
|
||||
#include <pinos/client/uri.h>
|
||||
|
||||
/**
|
||||
* PinosContextState:
|
||||
|
|
@ -60,6 +59,8 @@ struct _PinosContext {
|
|||
char *name;
|
||||
PinosProperties *properties;
|
||||
|
||||
PinosURI uri;
|
||||
|
||||
PinosLoop *loop;
|
||||
|
||||
PinosProxy *core_proxy;
|
||||
|
|
|
|||
|
|
@ -103,3 +103,177 @@ pinos_link_state_as_string (PinosLinkState state)
|
|||
}
|
||||
return "invalid-state";
|
||||
}
|
||||
|
||||
static void
|
||||
pinos_spa_dict_destroy (SpaDict *dict)
|
||||
{
|
||||
SpaDictItem *item;
|
||||
|
||||
spa_dict_for_each (item, dict) {
|
||||
free ((void *)item->key);
|
||||
free ((void *)item->value);
|
||||
}
|
||||
free (dict->items);
|
||||
free (dict);
|
||||
}
|
||||
|
||||
static SpaDict *
|
||||
pinos_spa_dict_copy (SpaDict *dict)
|
||||
{
|
||||
SpaDict *copy;
|
||||
unsigned int i;
|
||||
|
||||
if (dict == NULL)
|
||||
return NULL;
|
||||
|
||||
copy = calloc (1, sizeof (SpaDict));
|
||||
copy->items = calloc (dict->n_items, sizeof (SpaDictItem));
|
||||
copy->n_items = dict->n_items;
|
||||
|
||||
for (i = 0; i < dict->n_items; i++) {
|
||||
copy->items[i].key = strdup (dict->items[i].key);
|
||||
copy->items[i].value = strdup (dict->items[i].value);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
PinosNodeInfo *
|
||||
pinos_node_info_update (PinosNodeInfo *info,
|
||||
const PinosNodeInfo *update)
|
||||
{
|
||||
uint64_t change_mask;
|
||||
|
||||
if (update == NULL)
|
||||
return info;
|
||||
|
||||
if (info == NULL) {
|
||||
info = calloc (1, sizeof (PinosNodeInfo));
|
||||
change_mask = ~0;
|
||||
} else {
|
||||
change_mask = info->change_mask | update->change_mask;
|
||||
}
|
||||
info->id = update->id;
|
||||
info->change_mask = change_mask;
|
||||
|
||||
if (update->change_mask & (1 << 0)) {
|
||||
if (info->name)
|
||||
free ((void*)info->name);
|
||||
info->name = update->name ? strdup (update->name) : NULL;
|
||||
}
|
||||
if (update->change_mask & (1 << 1)) {
|
||||
info->state = update->state;
|
||||
}
|
||||
if (update->change_mask & (1 << 2)) {
|
||||
if (info->props)
|
||||
pinos_spa_dict_destroy (info->props);
|
||||
info->props = pinos_spa_dict_copy (update->props);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
void
|
||||
pinos_node_info_free (PinosNodeInfo *info)
|
||||
{
|
||||
if (info == NULL)
|
||||
return;
|
||||
if (info->name)
|
||||
free ((void*)info->name);
|
||||
if (info->props)
|
||||
pinos_spa_dict_destroy (info->props);
|
||||
free (info);
|
||||
}
|
||||
|
||||
PinosModuleInfo *
|
||||
pinos_module_info_update (PinosModuleInfo *info,
|
||||
const PinosModuleInfo *update)
|
||||
{
|
||||
uint64_t change_mask;
|
||||
|
||||
if (update == NULL)
|
||||
return info;
|
||||
|
||||
if (info == NULL) {
|
||||
info = calloc (1, sizeof (PinosModuleInfo));
|
||||
change_mask = ~0;
|
||||
} else {
|
||||
change_mask = info->change_mask | update->change_mask;
|
||||
}
|
||||
info->id = update->id;
|
||||
info->change_mask = change_mask;
|
||||
|
||||
if (update->change_mask & (1 << 0)) {
|
||||
if (info->name)
|
||||
free ((void*)info->name);
|
||||
info->name = update->name ? strdup (update->name) : NULL;
|
||||
}
|
||||
if (update->change_mask & (1 << 1)) {
|
||||
if (info->filename)
|
||||
free ((void*)info->filename);
|
||||
info->filename = update->filename ? strdup (update->filename) : NULL;
|
||||
}
|
||||
if (update->change_mask & (1 << 2)) {
|
||||
if (info->args)
|
||||
free ((void*)info->args);
|
||||
info->args = update->args ? strdup (update->args) : NULL;
|
||||
}
|
||||
if (update->change_mask & (1 << 3)) {
|
||||
if (info->props)
|
||||
pinos_spa_dict_destroy (info->props);
|
||||
info->props = pinos_spa_dict_copy (update->props);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
void
|
||||
pinos_module_info_free (PinosModuleInfo *info)
|
||||
{
|
||||
if (info == NULL)
|
||||
return;
|
||||
|
||||
if (info->name)
|
||||
free ((void*)info->name);
|
||||
if (info->filename)
|
||||
free ((void*)info->filename);
|
||||
if (info->args)
|
||||
free ((void*)info->args);
|
||||
if (info->props)
|
||||
pinos_spa_dict_destroy (info->props);
|
||||
free (info);
|
||||
}
|
||||
|
||||
|
||||
PinosClientInfo *
|
||||
pinos_client_info_update (PinosClientInfo *info,
|
||||
const PinosClientInfo *update)
|
||||
{
|
||||
uint64_t change_mask;
|
||||
|
||||
if (update == NULL)
|
||||
return info;
|
||||
|
||||
if (info == NULL) {
|
||||
info = calloc (1, sizeof (PinosClientInfo));
|
||||
change_mask = ~0;
|
||||
} else {
|
||||
change_mask = info->change_mask | update->change_mask;
|
||||
}
|
||||
info->id = update->id;
|
||||
info->change_mask = change_mask;
|
||||
|
||||
if (update->change_mask & (1 << 0)) {
|
||||
if (info->props)
|
||||
pinos_spa_dict_destroy (info->props);
|
||||
info->props = pinos_spa_dict_copy (update->props);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
void
|
||||
pinos_client_info_free (PinosClientInfo *info)
|
||||
{
|
||||
if (info == NULL)
|
||||
return;
|
||||
if (info->props)
|
||||
pinos_spa_dict_destroy (info->props);
|
||||
free (info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,19 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum _PinosNodeState PinosNodeState;
|
||||
typedef enum _PinosDirection PinosDirection;
|
||||
typedef enum _PinosLinkState PinosLinkState;
|
||||
|
||||
typedef struct _PinosCoreInfo PinosCoreInfo;
|
||||
typedef struct _PinosModuleInfo PinosModuleInfo;
|
||||
typedef struct _PinosClientInfo PinosClientInfo;
|
||||
typedef struct _PinosNodeInfo PinosNodeInfo;
|
||||
typedef struct _PinosLinkInfo PinosLinkInfo;
|
||||
|
||||
#include <pinos/client/context.h>
|
||||
#include <pinos/client/properties.h>
|
||||
|
||||
/**
|
||||
* PinosNodeState:
|
||||
* @PINOS_NODE_STATE_ERROR: the node is in error
|
||||
|
|
@ -40,14 +53,14 @@ extern "C" {
|
|||
*
|
||||
* The different node states
|
||||
*/
|
||||
typedef enum {
|
||||
enum _PinosNodeState {
|
||||
PINOS_NODE_STATE_ERROR = -1,
|
||||
PINOS_NODE_STATE_CREATING = 0,
|
||||
PINOS_NODE_STATE_SUSPENDED = 1,
|
||||
PINOS_NODE_STATE_INITIALIZING = 2,
|
||||
PINOS_NODE_STATE_IDLE = 3,
|
||||
PINOS_NODE_STATE_RUNNING = 4,
|
||||
} PinosNodeState;
|
||||
};
|
||||
|
||||
const char * pinos_node_state_as_string (PinosNodeState state);
|
||||
|
||||
|
|
@ -59,11 +72,11 @@ const char * pinos_node_state_as_string (PinosNodeState state);
|
|||
*
|
||||
* The direction of a port
|
||||
*/
|
||||
typedef enum {
|
||||
enum _PinosDirection {
|
||||
PINOS_DIRECTION_INVALID = SPA_DIRECTION_INVALID,
|
||||
PINOS_DIRECTION_INPUT = SPA_DIRECTION_INPUT,
|
||||
PINOS_DIRECTION_OUTPUT = SPA_DIRECTION_OUTPUT
|
||||
} PinosDirection;
|
||||
};
|
||||
|
||||
const char * pinos_direction_as_string (PinosDirection direction);
|
||||
|
||||
|
|
@ -79,7 +92,7 @@ const char * pinos_direction_as_string (PinosDirection direction);
|
|||
*
|
||||
* The different link states
|
||||
*/
|
||||
typedef enum {
|
||||
enum _PinosLinkState {
|
||||
PINOS_LINK_STATE_ERROR = -2,
|
||||
PINOS_LINK_STATE_UNLINKED = -1,
|
||||
PINOS_LINK_STATE_INIT = 0,
|
||||
|
|
@ -87,28 +100,25 @@ typedef enum {
|
|||
PINOS_LINK_STATE_ALLOCATING = 2,
|
||||
PINOS_LINK_STATE_PAUSED = 3,
|
||||
PINOS_LINK_STATE_RUNNING = 4,
|
||||
} PinosLinkState;
|
||||
};
|
||||
|
||||
const char * pinos_link_state_as_string (PinosLinkState state);
|
||||
|
||||
#include <pinos/client/context.h>
|
||||
#include <pinos/client/properties.h>
|
||||
|
||||
/**
|
||||
* PinosDaemonInfo:
|
||||
* @id: generic id of the daemon
|
||||
* PinosCoreInfo:
|
||||
* @id: generic id of the core
|
||||
* @change_mask: bitfield of changed fields since last call
|
||||
* @user_name: name of the user that started the daemon
|
||||
* @host_name: name of the machine the daemon is running on
|
||||
* @version: version of the daemon
|
||||
* @name: name of the daemon
|
||||
* @user_name: name of the user that started the core
|
||||
* @host_name: name of the machine the core is running on
|
||||
* @version: version of the core
|
||||
* @name: name of the core
|
||||
* @cookie: a random cookie for identifying this instance of Pinos
|
||||
* @properties: extra properties
|
||||
* @props: extra properties
|
||||
*
|
||||
* The daemon information. Extra information can be added in later
|
||||
* The core information. Extra information can be added in later
|
||||
* versions.
|
||||
*/
|
||||
typedef struct {
|
||||
struct _PinosCoreInfo {
|
||||
uint32_t id;
|
||||
uint64_t change_mask;
|
||||
const char *user_name;
|
||||
|
|
@ -116,41 +126,93 @@ typedef struct {
|
|||
const char *version;
|
||||
const char *name;
|
||||
uint32_t cookie;
|
||||
PinosProperties *properties;
|
||||
} PinosDaemonInfo;
|
||||
SpaDict *props;
|
||||
};
|
||||
|
||||
PinosCoreInfo * pinos_core_info_update (PinosCoreInfo *info,
|
||||
const PinosCoreInfo *update);
|
||||
void pinos_core_info_free (PinosCoreInfo *info);
|
||||
|
||||
/**
|
||||
* PinosCoreInfoCallback:
|
||||
* @c: a #PinosContext
|
||||
* @info: a #PinosCoreInfo
|
||||
* @user_data: user data
|
||||
*
|
||||
* Callback with information about the Pinos core in @info.
|
||||
*/
|
||||
typedef void (*PinosCoreInfoCallback) (PinosContext *c,
|
||||
SpaResult res,
|
||||
const PinosCoreInfo *info,
|
||||
void *user_data);
|
||||
|
||||
void pinos_context_get_core_info (PinosContext *context,
|
||||
PinosCoreInfoCallback cb,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* PinosModuleInfo:
|
||||
* @id: generic id of the module
|
||||
* @change_mask: bitfield of changed fields since last call
|
||||
* @props: extra properties
|
||||
*
|
||||
* The module information. Extra information can be added in later
|
||||
* versions.
|
||||
*/
|
||||
struct _PinosModuleInfo {
|
||||
uint32_t id;
|
||||
uint64_t change_mask;
|
||||
const char *name;
|
||||
const char *filename;
|
||||
const char *args;
|
||||
SpaDict *props;
|
||||
};
|
||||
|
||||
PinosModuleInfo * pinos_module_info_update (PinosModuleInfo *info,
|
||||
const PinosModuleInfo *update);
|
||||
void pinos_module_info_free (PinosModuleInfo *info);
|
||||
|
||||
|
||||
/**
|
||||
* PinosDaemonInfoCallback:
|
||||
* PinosModuleInfoCallback:
|
||||
* @c: a #PinosContext
|
||||
* @info: a #PinosDaemonInfo
|
||||
* @info: a #PinosModuleInfo
|
||||
* @user_data: user data
|
||||
*
|
||||
* Callback with information about the Pinos daemon in @info.
|
||||
* Callback with information about the Pinos module in @info.
|
||||
*/
|
||||
typedef void (*PinosDaemonInfoCallback) (PinosContext *c,
|
||||
SpaResult res,
|
||||
const PinosDaemonInfo *info,
|
||||
typedef void (*PinosModuleInfoCallback) (PinosContext *c,
|
||||
SpaResult res,
|
||||
const PinosModuleInfo *info,
|
||||
void *user_data);
|
||||
|
||||
void pinos_context_get_daemon_info (PinosContext *context,
|
||||
PinosDaemonInfoCallback cb,
|
||||
void *user_data);
|
||||
void pinos_context_list_module_info (PinosContext *context,
|
||||
PinosModuleInfoCallback cb,
|
||||
void *user_data);
|
||||
void pinos_context_get_module_info_by_id (PinosContext *context,
|
||||
uint32_t id,
|
||||
PinosModuleInfoCallback cb,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* PinosClientInfo:
|
||||
* @id: generic id of the client
|
||||
* @change_mask: bitfield of changed fields since last call
|
||||
* @properties: extra properties
|
||||
* @props: extra properties
|
||||
*
|
||||
* The client information. Extra information can be added in later
|
||||
* versions.
|
||||
*/
|
||||
typedef struct {
|
||||
struct _PinosClientInfo {
|
||||
uint32_t id;
|
||||
uint64_t change_mask;
|
||||
PinosProperties *properties;
|
||||
} PinosClientInfo;
|
||||
SpaDict *props;
|
||||
};
|
||||
|
||||
PinosClientInfo * pinos_client_info_update (PinosClientInfo *info,
|
||||
const PinosClientInfo *update);
|
||||
void pinos_client_info_free (PinosClientInfo *info);
|
||||
|
||||
|
||||
/**
|
||||
* PinosClientInfoCallback:
|
||||
|
|
@ -178,19 +240,23 @@ void pinos_context_get_client_info_by_id (PinosContext *co
|
|||
* @id: generic id of the node
|
||||
* @change_mask: bitfield of changed fields since last call
|
||||
* @name: name the node, suitable for display
|
||||
* @properties: the properties of the node
|
||||
* @props: the properties of the node
|
||||
* @state: the current state of the node
|
||||
*
|
||||
* The node information. Extra information can be added in later
|
||||
* versions.
|
||||
*/
|
||||
typedef struct {
|
||||
struct _PinosNodeInfo {
|
||||
uint32_t id;
|
||||
uint64_t change_mask;
|
||||
const char *name;
|
||||
PinosProperties *properties;
|
||||
PinosNodeState state;
|
||||
} PinosNodeInfo;
|
||||
SpaDict *props;
|
||||
};
|
||||
|
||||
PinosNodeInfo * pinos_node_info_update (PinosNodeInfo *info,
|
||||
const PinosNodeInfo *update);
|
||||
void pinos_node_info_free (PinosNodeInfo *info);
|
||||
|
||||
/**
|
||||
* PinosNodeInfoCallback:
|
||||
|
|
@ -226,14 +292,14 @@ void pinos_context_get_node_info_by_id (PinosContext *cont
|
|||
* The link information. Extra information can be added in later
|
||||
* versions.
|
||||
*/
|
||||
typedef struct {
|
||||
struct _PinosLinkInfo {
|
||||
uint32_t id;
|
||||
uint64_t change_mask;
|
||||
uint32_t output_node_id;
|
||||
uint32_t output_port_id;
|
||||
uint32_t input_node_id;
|
||||
uint32_t input_port_id;
|
||||
} PinosLinkInfo;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ pinos_headers = [
|
|||
'subscribe.h',
|
||||
'thread-mainloop.h',
|
||||
'transport.h',
|
||||
'uri.h',
|
||||
'utils.h',
|
||||
]
|
||||
|
||||
|
|
@ -33,6 +34,7 @@ pinos_sources = [
|
|||
'rtkit.c',
|
||||
'thread-mainloop.c',
|
||||
'transport.c',
|
||||
'uri.c',
|
||||
'utils.c',
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -21,37 +21,40 @@
|
|||
#include "pinos/client/properties.h"
|
||||
|
||||
typedef struct {
|
||||
char *key;
|
||||
char *value;
|
||||
} PropItem;
|
||||
PinosProperties this;
|
||||
|
||||
struct _PinosProperties {
|
||||
PinosArray items;
|
||||
};
|
||||
} PinosPropertiesImpl;
|
||||
|
||||
static void
|
||||
add_func (PinosProperties *props, char *key, char *value)
|
||||
add_func (PinosProperties *this, char *key, char *value)
|
||||
{
|
||||
PropItem *item;
|
||||
item = pinos_array_add (&props->items, sizeof (PropItem));
|
||||
SpaDictItem *item;
|
||||
PinosPropertiesImpl *impl = SPA_CONTAINER_OF (this, PinosPropertiesImpl, this);
|
||||
|
||||
item = pinos_array_add (&impl->items, sizeof (SpaDictItem));
|
||||
item->key = key;
|
||||
item->value = value;
|
||||
|
||||
this->dict.items = impl->items.data;
|
||||
this->dict.n_items = pinos_array_get_len (&impl->items, SpaDictItem);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_item (PropItem *item)
|
||||
clear_item (SpaDictItem *item)
|
||||
{
|
||||
free (item->key);
|
||||
free (item->value);
|
||||
free ((char*)item->key);
|
||||
free ((char*)item->value);
|
||||
}
|
||||
|
||||
static int
|
||||
find_index (PinosProperties *props, const char *key)
|
||||
find_index (PinosProperties *this, const char *key)
|
||||
{
|
||||
int i, len = pinos_array_get_len (&props->items, PropItem);
|
||||
PinosPropertiesImpl *impl = SPA_CONTAINER_OF (this, PinosPropertiesImpl, this);
|
||||
int i, len = pinos_array_get_len (&impl->items, SpaDictItem);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
PropItem *item = pinos_array_get_unchecked (&props->items, i, PropItem);
|
||||
SpaDictItem *item = pinos_array_get_unchecked (&impl->items, i, SpaDictItem);
|
||||
if (strcmp (item->key, key) == 0)
|
||||
return i;
|
||||
}
|
||||
|
|
@ -70,22 +73,22 @@ find_index (PinosProperties *props, const char *key)
|
|||
PinosProperties *
|
||||
pinos_properties_new (const char *key, ...)
|
||||
{
|
||||
PinosProperties *props;
|
||||
PinosPropertiesImpl *impl;
|
||||
va_list varargs;
|
||||
const char *value;
|
||||
|
||||
props = calloc (1, sizeof (PinosProperties));
|
||||
pinos_array_init (&props->items);
|
||||
impl = calloc (1, sizeof (PinosPropertiesImpl));
|
||||
pinos_array_init (&impl->items);
|
||||
|
||||
va_start (varargs, key);
|
||||
while (key != NULL) {
|
||||
value = va_arg (varargs, char *);
|
||||
add_func (props, strdup (key), strdup (value));
|
||||
add_func (&impl->this, strdup (key), strdup (value));
|
||||
key = va_arg (varargs, char *);
|
||||
}
|
||||
va_end (varargs);
|
||||
|
||||
return props;
|
||||
return &impl->this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -99,11 +102,12 @@ pinos_properties_new (const char *key, ...)
|
|||
PinosProperties *
|
||||
pinos_properties_copy (PinosProperties *properties)
|
||||
{
|
||||
PinosPropertiesImpl *impl = SPA_CONTAINER_OF (properties, PinosPropertiesImpl, this);
|
||||
PinosProperties *copy;
|
||||
PropItem *item;
|
||||
SpaDictItem *item;
|
||||
|
||||
copy = pinos_properties_new (NULL, NULL);
|
||||
pinos_array_for_each (item, &properties->items)
|
||||
pinos_array_for_each (item, &impl->items)
|
||||
add_func (copy, strdup (item->key), strdup (item->value));
|
||||
|
||||
return copy;
|
||||
|
|
@ -145,13 +149,14 @@ pinos_properties_merge (PinosProperties *oldprops,
|
|||
void
|
||||
pinos_properties_free (PinosProperties *properties)
|
||||
{
|
||||
PropItem *item;
|
||||
PinosPropertiesImpl *impl = SPA_CONTAINER_OF (properties, PinosPropertiesImpl, this);
|
||||
SpaDictItem *item;
|
||||
|
||||
pinos_array_for_each (item, &properties->items)
|
||||
pinos_array_for_each (item, &impl->items)
|
||||
clear_item (item);
|
||||
|
||||
pinos_array_clear (&properties->items);
|
||||
free (properties);
|
||||
pinos_array_clear (&impl->items);
|
||||
free (impl);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -159,21 +164,22 @@ do_replace (PinosProperties *properties,
|
|||
char *key,
|
||||
char *value)
|
||||
{
|
||||
PinosPropertiesImpl *impl = SPA_CONTAINER_OF (properties, PinosPropertiesImpl, this);
|
||||
int index = find_index (properties, key);
|
||||
|
||||
if (index == -1) {
|
||||
add_func (properties, key, value);
|
||||
} else {
|
||||
PropItem *item = pinos_array_get_unchecked (&properties->items, index, PropItem);
|
||||
SpaDictItem *item = pinos_array_get_unchecked (&impl->items, index, SpaDictItem);
|
||||
|
||||
clear_item (item);
|
||||
if (value == NULL) {
|
||||
PropItem *other = pinos_array_get_unchecked (&properties->items,
|
||||
pinos_array_get_len (&properties->items, PropItem) - 1,
|
||||
PropItem);
|
||||
SpaDictItem *other = pinos_array_get_unchecked (&impl->items,
|
||||
pinos_array_get_len (&impl->items, SpaDictItem) - 1,
|
||||
SpaDictItem);
|
||||
item->key = other->key;
|
||||
item->value = other->value;
|
||||
properties->items.size -= sizeof (PropItem);
|
||||
impl->items.size -= sizeof (SpaDictItem);
|
||||
} else {
|
||||
item->key = key;
|
||||
item->value = value;
|
||||
|
|
@ -238,12 +244,13 @@ const char *
|
|||
pinos_properties_get (PinosProperties *properties,
|
||||
const char *key)
|
||||
{
|
||||
PinosPropertiesImpl *impl = SPA_CONTAINER_OF (properties, PinosPropertiesImpl, this);
|
||||
int index = find_index (properties, key);
|
||||
|
||||
if (index == -1)
|
||||
return NULL;
|
||||
|
||||
return pinos_array_get_unchecked (&properties->items, index, PropItem)->value;
|
||||
return pinos_array_get_unchecked (&impl->items, index, SpaDictItem)->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -264,6 +271,7 @@ const char *
|
|||
pinos_properties_iterate (PinosProperties *properties,
|
||||
void **state)
|
||||
{
|
||||
PinosPropertiesImpl *impl = SPA_CONTAINER_OF (properties, PinosPropertiesImpl, this);
|
||||
unsigned int index;
|
||||
|
||||
if (*state == NULL)
|
||||
|
|
@ -271,10 +279,10 @@ pinos_properties_iterate (PinosProperties *properties,
|
|||
else
|
||||
index = SPA_PTR_TO_INT (*state);
|
||||
|
||||
if (!pinos_array_check_index (&properties->items, index, PropItem))
|
||||
if (!pinos_array_check_index (&impl->items, index, SpaDictItem))
|
||||
return NULL;
|
||||
|
||||
*state = SPA_INT_TO_PTR (index + 1);
|
||||
|
||||
return pinos_array_get_unchecked (&properties->items, index, PropItem)->key;
|
||||
return pinos_array_get_unchecked (&impl->items, index, SpaDictItem)->key;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ extern "C" {
|
|||
|
||||
typedef struct _PinosProperties PinosProperties;
|
||||
|
||||
struct _PinosProperties {
|
||||
SpaDict dict;
|
||||
};
|
||||
|
||||
PinosProperties * pinos_properties_new (const char *key, ...);
|
||||
PinosProperties * pinos_properties_copy (PinosProperties *properties);
|
||||
PinosProperties * pinos_properties_merge (PinosProperties *oldprops,
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ pinos_proxy_destroy (PinosProxy *proxy)
|
|||
|
||||
SpaResult
|
||||
pinos_proxy_send_message (PinosProxy *proxy,
|
||||
PinosMessageType type,
|
||||
uint32_t opcode,
|
||||
void *message,
|
||||
bool flush)
|
||||
{
|
||||
if (proxy->send_func)
|
||||
return proxy->send_func (proxy, proxy->id, type, message, flush, proxy->send_data);
|
||||
return proxy->send_func (proxy, proxy->id, opcode, message, flush, proxy->send_data);
|
||||
|
||||
pinos_log_error ("proxy %p: send func not implemented", proxy);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,21 +24,20 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <pinos/client/connection.h>
|
||||
|
||||
typedef struct _PinosProxy PinosProxy;
|
||||
|
||||
typedef SpaResult (*PinosSendFunc) (void *object,
|
||||
uint32_t id,
|
||||
PinosMessageType type,
|
||||
uint32_t opcode,
|
||||
void *message,
|
||||
bool flush,
|
||||
void *data);
|
||||
|
||||
typedef SpaResult (*PinosDispatchFunc) (void *object,
|
||||
PinosMessageType type,
|
||||
uint32_t opcode,
|
||||
void *message,
|
||||
void *data);
|
||||
#include <pinos/client/connection.h>
|
||||
#include <pinos/client/context.h>
|
||||
|
||||
struct _PinosProxy {
|
||||
|
|
@ -53,6 +52,8 @@ struct _PinosProxy {
|
|||
PinosDispatchFunc dispatch_func;
|
||||
void *dispatch_data;
|
||||
|
||||
void *user_data;
|
||||
|
||||
PINOS_SIGNAL (destroy_signal, (PinosListener *listener,
|
||||
PinosProxy *proxy));
|
||||
};
|
||||
|
|
@ -63,7 +64,7 @@ PinosProxy * pinos_proxy_new (PinosContext *contex
|
|||
void pinos_proxy_destroy (PinosProxy *proxy);
|
||||
|
||||
SpaResult pinos_proxy_send_message (PinosProxy *proxy,
|
||||
PinosMessageType type,
|
||||
uint32_t opcode,
|
||||
void *message,
|
||||
bool flush);
|
||||
|
||||
|
|
|
|||
|
|
@ -610,13 +610,18 @@ stream_dispatch_func (void *object,
|
|||
case PINOS_MESSAGE_GET_REGISTRY:
|
||||
case PINOS_MESSAGE_BIND:
|
||||
case PINOS_MESSAGE_DESTROY:
|
||||
case PINOS_MESSAGE_DESTROY_DONE:
|
||||
case PINOS_MESSAGE_REMOVE_ID:
|
||||
case PINOS_MESSAGE_CREATE_NODE:
|
||||
case PINOS_MESSAGE_CREATE_CLIENT_NODE:
|
||||
case PINOS_MESSAGE_NODE_UPDATE:
|
||||
case PINOS_MESSAGE_PORT_UPDATE:
|
||||
case PINOS_MESSAGE_PORT_STATUS_CHANGE:
|
||||
case PINOS_MESSAGE_NODE_STATE_CHANGE:
|
||||
case PINOS_MESSAGE_CORE_INFO:
|
||||
case PINOS_MESSAGE_MODULE_INFO:
|
||||
case PINOS_MESSAGE_NODE_INFO:
|
||||
case PINOS_MESSAGE_CLIENT_INFO:
|
||||
case PINOS_MESSAGE_LINK_INFO:
|
||||
pinos_log_warn ("got unexpected message %d", type);
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,21 +26,21 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PINOS_SUBSCRIPTION_STATE_UNCONNECTED = 0,
|
||||
PINOS_SUBSCRIPTION_STATE_CONNECTING = 1,
|
||||
PINOS_SUBSCRIPTION_STATE_READY = 2,
|
||||
PINOS_SUBSCRIPTION_STATE_ERROR = 3,
|
||||
} PinosSubscriptionState;
|
||||
#define PINOS_CORE_URI "http://pinos.org/ns/core"
|
||||
#define PINOS_CORE_PREFIX PINOS_CORE_URI "#"
|
||||
#define PINOS_CORE_REGISTRY PINOS_CORE_PREFIX "Registry"
|
||||
|
||||
typedef enum {
|
||||
PINOS_SUBSCRIPTION_FLAG_DAEMON = (1 << 0),
|
||||
PINOS_SUBSCRIPTION_FLAG_CLIENT = (1 << 1),
|
||||
PINOS_SUBSCRIPTION_FLAG_NODE = (1 << 2),
|
||||
PINOS_SUBSCRIPTION_FLAG_LINK = (1 << 3)
|
||||
} PinosSubscriptionFlags;
|
||||
#define PINOS_NODE_URI "http://pinos.org/ns/node"
|
||||
#define PINOS_NODE_PREFIX PINOS_NODE_URI "#"
|
||||
|
||||
#define PINOS_SUBSCRIPTION_FLAGS_ALL 0x0f
|
||||
#define PINOS_CLIENT_URI "http://pinos.org/ns/client"
|
||||
#define PINOS_CLIENT_PREFIX PINOS_CLIENT_URI "#"
|
||||
|
||||
#define PINOS_LINK_URI "http://pinos.org/ns/link"
|
||||
#define PINOS_LINK_PREFIX PINOS_LINK_URI "#"
|
||||
|
||||
#define PINOS_MODULE_URI "http://pinos.org/ns/module"
|
||||
#define PINOS_MODULE_PREFIX PINOS_MODULE_URI "#"
|
||||
|
||||
typedef enum {
|
||||
PINOS_SUBSCRIPTION_EVENT_NEW = 0,
|
||||
|
|
@ -49,13 +49,12 @@ typedef enum {
|
|||
} PinosSubscriptionEvent;
|
||||
|
||||
typedef void (*PinosSubscriptionFunc) (PinosContext *context,
|
||||
PinosSubscriptionFlags flags,
|
||||
PinosSubscriptionEvent event,
|
||||
uint32_t type,
|
||||
uint32_t id,
|
||||
void *data);
|
||||
|
||||
void pinos_context_subscribe (PinosContext *context,
|
||||
PinosSubscriptionFlags mask,
|
||||
PinosSubscriptionFunc func,
|
||||
void *data);
|
||||
|
||||
|
|
|
|||
51
pinos/client/uri.c
Normal file
51
pinos/client/uri.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/* Pinos
|
||||
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/client/uri.h"
|
||||
|
||||
#include "pinos/server/core.h"
|
||||
#include "pinos/server/node.h"
|
||||
#include "pinos/server/node-factory.h"
|
||||
#include "pinos/server/client.h"
|
||||
#include "pinos/server/client-node.h"
|
||||
#include "pinos/server/module.h"
|
||||
|
||||
#include "spa/include/spa/monitor.h"
|
||||
|
||||
void
|
||||
pinos_uri_init (PinosURI *uri)
|
||||
{
|
||||
uri->map = pinos_id_map_get_default();
|
||||
|
||||
uri->core = spa_id_map_get_id (uri->map, PINOS_CORE_URI);
|
||||
uri->registry = spa_id_map_get_id (uri->map, PINOS_CORE_REGISTRY);
|
||||
uri->node = spa_id_map_get_id (uri->map, PINOS_NODE_URI);
|
||||
uri->node_factory = spa_id_map_get_id (uri->map, PINOS_NODE_FACTORY_URI);
|
||||
uri->link = spa_id_map_get_id (uri->map, PINOS_LINK_URI);
|
||||
uri->client = spa_id_map_get_id (uri->map, PINOS_CLIENT_URI);
|
||||
uri->client_node = spa_id_map_get_id (uri->map, PINOS_CLIENT_NODE_URI);
|
||||
uri->module = spa_id_map_get_id (uri->map, PINOS_MODULE_URI);
|
||||
|
||||
uri->spa_node = spa_id_map_get_id (uri->map, SPA_NODE_URI);
|
||||
uri->spa_clock = spa_id_map_get_id (uri->map, SPA_CLOCK_URI);
|
||||
uri->spa_monitor = spa_id_map_get_id (uri->map, SPA_MONITOR_URI);
|
||||
}
|
||||
63
pinos/client/uri.h
Normal file
63
pinos/client/uri.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/* 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_URI_H__
|
||||
#define __PINOS_URI_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PINOS_URI_URI "http://pinos.org/ns/uri"
|
||||
#define PINOS_URI_PREFIX PINOS_URI_URI "#"
|
||||
|
||||
#include <pinos/client/map.h>
|
||||
#include <spa/include/spa/id-map.h>
|
||||
|
||||
typedef struct _PinosURI PinosURI;
|
||||
|
||||
/**
|
||||
* PinosURI:
|
||||
*
|
||||
* Pinos URI support struct.
|
||||
*/
|
||||
struct _PinosURI {
|
||||
SpaIDMap *map;
|
||||
|
||||
uint32_t core;
|
||||
uint32_t registry;
|
||||
uint32_t node;
|
||||
uint32_t node_factory;
|
||||
uint32_t link;
|
||||
uint32_t client;
|
||||
uint32_t client_node;
|
||||
uint32_t module;
|
||||
|
||||
uint32_t spa_node;
|
||||
uint32_t spa_clock;
|
||||
uint32_t spa_monitor;
|
||||
};
|
||||
|
||||
void pinos_uri_init (PinosURI *uri);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PINOS_URI_H__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue