mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-18 08:56:45 -05:00
Rework serialization
Move serialization to the protocol, we now just send blocks of bytes over the connection and let the protocol deserialize them.
This commit is contained in:
parent
842d73ca4b
commit
41399b0b25
26 changed files with 1617 additions and 2501 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -25,300 +25,29 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <spa/defs.h>
|
#include <spa/defs.h>
|
||||||
#include <spa/props.h>
|
|
||||||
#include <spa/format.h>
|
|
||||||
#include <spa/port.h>
|
|
||||||
#include <spa/node.h>
|
|
||||||
|
|
||||||
#include <pinos/client/interfaces.h>
|
|
||||||
|
|
||||||
typedef struct _PinosConnection PinosConnection;
|
typedef struct _PinosConnection PinosConnection;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PINOS_MESSAGE_INVALID = 0,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_CLIENT_UPDATE,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_SYNC,
|
|
||||||
PINOS_MESSAGE_NOTIFY_DONE,
|
|
||||||
PINOS_MESSAGE_ERROR,
|
|
||||||
PINOS_MESSAGE_GET_REGISTRY,
|
|
||||||
PINOS_MESSAGE_REMOVE_ID,
|
|
||||||
PINOS_MESSAGE_CORE_INFO,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_BIND,
|
|
||||||
PINOS_MESSAGE_NOTIFY_GLOBAL,
|
|
||||||
PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_CREATE_NODE,
|
|
||||||
PINOS_MESSAGE_CREATE_NODE_DONE,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_CREATE_CLIENT_NODE,
|
|
||||||
PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_DESTROY,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_MODULE_INFO,
|
|
||||||
PINOS_MESSAGE_NODE_INFO,
|
|
||||||
PINOS_MESSAGE_CLIENT_INFO,
|
|
||||||
PINOS_MESSAGE_LINK_INFO,
|
|
||||||
|
|
||||||
/* client to server */
|
|
||||||
PINOS_MESSAGE_NODE_UPDATE,
|
|
||||||
PINOS_MESSAGE_PORT_UPDATE,
|
|
||||||
PINOS_MESSAGE_NODE_STATE_CHANGE,
|
|
||||||
PINOS_MESSAGE_NODE_EVENT,
|
|
||||||
|
|
||||||
/* server to client */
|
|
||||||
PINOS_MESSAGE_TRANSPORT_UPDATE,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_ADD_PORT,
|
|
||||||
PINOS_MESSAGE_REMOVE_PORT,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_SET_FORMAT,
|
|
||||||
PINOS_MESSAGE_SET_PROPERTY,
|
|
||||||
|
|
||||||
PINOS_MESSAGE_NODE_COMMAND,
|
|
||||||
PINOS_MESSAGE_PORT_COMMAND,
|
|
||||||
|
|
||||||
/* both */
|
|
||||||
PINOS_MESSAGE_ADD_MEM,
|
|
||||||
PINOS_MESSAGE_USE_BUFFERS,
|
|
||||||
|
|
||||||
} PinosMessageType;
|
|
||||||
|
|
||||||
#include <pinos/client/introspect.h>
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_CLIENT_UPDATE */
|
|
||||||
typedef struct {
|
|
||||||
const SpaDict *props;
|
|
||||||
} PinosMessageClientUpdate;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_SYNC */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
} PinosMessageSync;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_NOTIFY_DONE */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
} PinosMessageNotifyDone;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_ERROR */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t id;
|
|
||||||
SpaResult res;
|
|
||||||
const char *error;
|
|
||||||
} PinosMessageError;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_GET_REGISTRY */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
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;
|
|
||||||
uint32_t new_id;
|
|
||||||
} PinosMessageBind;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_NOTIFY_GLOBAL */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t id;
|
|
||||||
const char *type;
|
|
||||||
} PinosMessageNotifyGlobal;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t id;
|
|
||||||
} PinosMessageNotifyGlobalRemove;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_CREATE_NODE */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
const char *factory_name;
|
|
||||||
const char *name;
|
|
||||||
const SpaDict *props;
|
|
||||||
uint32_t new_id;
|
|
||||||
} PinosMessageCreateNode;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_CREATE_NODE_DONE */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
} PinosMessageCreateNodeDone;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_CREATE_CLIENT_NODE */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
const char *name;
|
|
||||||
const SpaDict *props;
|
|
||||||
uint32_t new_id;
|
|
||||||
} PinosMessageCreateClientNode;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
int datafd;
|
|
||||||
} PinosMessageCreateClientNodeDone;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_DESTROY */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
} PinosMessageDestroy;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_NODE_UPDATE */
|
|
||||||
typedef struct {
|
|
||||||
#define PINOS_MESSAGE_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
|
||||||
#define PINOS_MESSAGE_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
|
|
||||||
#define PINOS_MESSAGE_NODE_UPDATE_PROPS (1 << 2)
|
|
||||||
uint32_t change_mask;
|
|
||||||
unsigned int max_input_ports;
|
|
||||||
unsigned int max_output_ports;
|
|
||||||
const SpaProps *props;
|
|
||||||
} PinosMessageNodeUpdate;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_PORT_UPDATE */
|
|
||||||
typedef struct {
|
|
||||||
SpaDirection direction;
|
|
||||||
uint32_t port_id;
|
|
||||||
#define PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
|
|
||||||
#define PINOS_MESSAGE_PORT_UPDATE_FORMAT (1 << 1)
|
|
||||||
#define PINOS_MESSAGE_PORT_UPDATE_PROPS (1 << 2)
|
|
||||||
#define PINOS_MESSAGE_PORT_UPDATE_INFO (1 << 3)
|
|
||||||
uint32_t change_mask;
|
|
||||||
unsigned int n_possible_formats;
|
|
||||||
SpaFormat **possible_formats;
|
|
||||||
SpaFormat *format;
|
|
||||||
const SpaProps *props;
|
|
||||||
const SpaPortInfo *info;
|
|
||||||
} PinosMessagePortUpdate;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_NODE_STATE_CHANGE */
|
|
||||||
typedef struct {
|
|
||||||
SpaNodeState state;
|
|
||||||
} PinosMessageNodeStateChange;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_NODE_EVENT */
|
|
||||||
typedef struct {
|
|
||||||
SpaNodeEvent *event;
|
|
||||||
} PinosMessageNodeEvent;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_ADD_PORT */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
SpaDirection direction;
|
|
||||||
uint32_t port_id;
|
|
||||||
} PinosMessageAddPort;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_REMOVE_PORT */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
SpaDirection direction;
|
|
||||||
uint32_t port_id;
|
|
||||||
} PinosMessageRemovePort;
|
|
||||||
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_SET_FORMAT */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
SpaDirection direction;
|
|
||||||
uint32_t port_id;
|
|
||||||
SpaPortFormatFlags flags;
|
|
||||||
const SpaFormat *format;
|
|
||||||
} PinosMessageSetFormat;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_SET_PROPERTY */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
uint32_t id;
|
|
||||||
size_t size;
|
|
||||||
void *value;
|
|
||||||
} PinosMessageSetProperty;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_NODE_COMMAND */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
SpaNodeCommand *command;
|
|
||||||
} PinosMessageNodeCommand;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_PORT_COMMAND */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t port_id;
|
|
||||||
SpaNodeCommand *command;
|
|
||||||
} PinosMessagePortCommand;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_TRANSPORT_UPDATE */
|
|
||||||
typedef struct {
|
|
||||||
int memfd;
|
|
||||||
off_t offset;
|
|
||||||
size_t size;
|
|
||||||
} PinosMessageTransportUpdate;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_ADD_MEM */
|
|
||||||
typedef struct {
|
|
||||||
SpaDirection direction;
|
|
||||||
uint32_t port_id;
|
|
||||||
uint32_t mem_id;
|
|
||||||
SpaDataType type;
|
|
||||||
int memfd;
|
|
||||||
uint32_t flags;
|
|
||||||
off_t offset;
|
|
||||||
size_t size;
|
|
||||||
} PinosMessageAddMem;
|
|
||||||
|
|
||||||
/* PINOS_MESSAGE_USE_BUFFERS */
|
|
||||||
typedef struct {
|
|
||||||
uint32_t seq;
|
|
||||||
SpaDirection direction;
|
|
||||||
uint32_t port_id;
|
|
||||||
unsigned int n_buffers;
|
|
||||||
PinosClientNodeBuffer *buffers;
|
|
||||||
} PinosMessageUseBuffers;
|
|
||||||
|
|
||||||
PinosConnection * pinos_connection_new (int fd);
|
PinosConnection * pinos_connection_new (int fd);
|
||||||
void pinos_connection_destroy (PinosConnection *conn);
|
void pinos_connection_destroy (PinosConnection *conn);
|
||||||
|
|
||||||
|
int pinos_connection_add_fd (PinosConnection *conn,
|
||||||
|
int fd);
|
||||||
|
int pinos_connection_get_fd (PinosConnection *conn,
|
||||||
|
int index);
|
||||||
|
|
||||||
bool pinos_connection_get_next (PinosConnection *conn,
|
bool pinos_connection_get_next (PinosConnection *conn,
|
||||||
PinosMessageType *type,
|
uint8_t *opcode,
|
||||||
uint32_t *dest_id,
|
uint32_t *dest_id,
|
||||||
|
void **data,
|
||||||
size_t *size);
|
size_t *size);
|
||||||
bool pinos_connection_parse_message (PinosConnection *conn,
|
|
||||||
void *msg);
|
void * pinos_connection_begin_write (PinosConnection *conn,
|
||||||
bool pinos_connection_add_message (PinosConnection *conn,
|
size_t size);
|
||||||
|
void pinos_connection_end_write (PinosConnection *conn,
|
||||||
uint32_t dest_id,
|
uint32_t dest_id,
|
||||||
PinosMessageType type,
|
uint8_t opcode,
|
||||||
void *msg);
|
size_t size);
|
||||||
|
|
||||||
bool pinos_connection_flush (PinosConnection *conn);
|
bool pinos_connection_flush (PinosConnection *conn);
|
||||||
bool pinos_connection_clear (PinosConnection *conn);
|
bool pinos_connection_clear (PinosConnection *conn);
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ registry_event_global (void *object,
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
proxy->event = &node_events;
|
proxy->event = &node_events;
|
||||||
proxy->marshall = &pinos_protocol_native_client_node_marshall;
|
proxy->demarshal = &pinos_protocol_native_client_node_demarshal;
|
||||||
proxy->interface = NULL;
|
proxy->interface = NULL;
|
||||||
} else if (!strcmp (type, PINOS_MODULE_URI)) {
|
} else if (!strcmp (type, PINOS_MODULE_URI)) {
|
||||||
proxy = pinos_proxy_new (this,
|
proxy = pinos_proxy_new (this,
|
||||||
|
|
@ -313,7 +313,7 @@ registry_event_global (void *object,
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
proxy->event = &module_events;
|
proxy->event = &module_events;
|
||||||
proxy->marshall = &pinos_protocol_native_client_module_marshall;
|
proxy->demarshal = &pinos_protocol_native_client_module_demarshal;
|
||||||
proxy->interface = NULL;
|
proxy->interface = NULL;
|
||||||
} else if (!strcmp (type, PINOS_CLIENT_URI)) {
|
} else if (!strcmp (type, PINOS_CLIENT_URI)) {
|
||||||
proxy = pinos_proxy_new (this,
|
proxy = pinos_proxy_new (this,
|
||||||
|
|
@ -323,7 +323,7 @@ registry_event_global (void *object,
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
proxy->event = &client_events;
|
proxy->event = &client_events;
|
||||||
proxy->marshall = &pinos_protocol_native_client_client_marshall;
|
proxy->demarshal = &pinos_protocol_native_client_client_demarshal;
|
||||||
proxy->interface = NULL;
|
proxy->interface = NULL;
|
||||||
} else if (!strcmp (type, PINOS_LINK_URI)) {
|
} else if (!strcmp (type, PINOS_LINK_URI)) {
|
||||||
proxy = pinos_proxy_new (this,
|
proxy = pinos_proxy_new (this,
|
||||||
|
|
@ -333,7 +333,7 @@ registry_event_global (void *object,
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
proxy->event = &link_events;
|
proxy->event = &link_events;
|
||||||
proxy->marshall = &pinos_protocol_native_client_link_marshall;
|
proxy->demarshal = &pinos_protocol_native_client_link_demarshal;
|
||||||
proxy->interface = NULL;
|
proxy->interface = NULL;
|
||||||
}
|
}
|
||||||
if (proxy)
|
if (proxy)
|
||||||
|
|
@ -385,32 +385,27 @@ on_context_data (SpaSource *source,
|
||||||
|
|
||||||
if (mask & SPA_IO_IN) {
|
if (mask & SPA_IO_IN) {
|
||||||
PinosConnection *conn = impl->connection;
|
PinosConnection *conn = impl->connection;
|
||||||
PinosMessageType type;
|
uint8_t opcode;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
void *message;
|
||||||
|
|
||||||
while (pinos_connection_get_next (conn, &type, &id, &size)) {
|
while (pinos_connection_get_next (conn, &opcode, &id, &message, &size)) {
|
||||||
void *p = alloca (size);
|
|
||||||
PinosProxy *proxy;
|
PinosProxy *proxy;
|
||||||
const PinosMarshallFunc *marshall;
|
const PinosDemarshalFunc *demarshal;
|
||||||
|
|
||||||
if (!pinos_connection_parse_message (conn, p)) {
|
|
||||||
pinos_log_error ("context %p: failed to parse message", this);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy = pinos_map_lookup (&this->objects, id);
|
proxy = pinos_map_lookup (&this->objects, id);
|
||||||
if (proxy == NULL) {
|
if (proxy == NULL) {
|
||||||
pinos_log_error ("context %p: could not find proxy %u", this, id);
|
pinos_log_error ("context %p: could not find proxy %u", this, id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pinos_log_debug ("context %p: object marshall %u, %u", this, id, type);
|
pinos_log_debug ("context %p: object demarshal %u, %u", this, id, opcode);
|
||||||
|
|
||||||
marshall = proxy->marshall;
|
demarshal = proxy->demarshal;
|
||||||
if (marshall[type])
|
if (demarshal[opcode])
|
||||||
marshall[type] (proxy, p, size);
|
demarshal[opcode] (proxy, message, size);
|
||||||
else
|
else
|
||||||
pinos_log_error ("context %p: function %d not implemented", this, type);
|
pinos_log_error ("context %p: function %d not implemented", this, opcode);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -602,7 +597,7 @@ pinos_context_connect_fd (PinosContext *context,
|
||||||
|
|
||||||
context->core_proxy->event = &core_events;
|
context->core_proxy->event = &core_events;
|
||||||
context->core_proxy->interface = &pinos_protocol_native_client_core_interface;
|
context->core_proxy->interface = &pinos_protocol_native_client_core_interface;
|
||||||
context->core_proxy->marshall = &pinos_protocol_native_client_core_marshall;
|
context->core_proxy->demarshal = &pinos_protocol_native_client_core_demarshal;
|
||||||
|
|
||||||
pinos_core_do_client_update (context->core_proxy,
|
pinos_core_do_client_update (context->core_proxy,
|
||||||
&context->properties->dict);
|
&context->properties->dict);
|
||||||
|
|
@ -615,7 +610,7 @@ pinos_context_connect_fd (PinosContext *context,
|
||||||
|
|
||||||
context->registry_proxy->event = ®istry_events;
|
context->registry_proxy->event = ®istry_events;
|
||||||
context->registry_proxy->interface = &pinos_protocol_native_client_registry_interface;
|
context->registry_proxy->interface = &pinos_protocol_native_client_registry_interface;
|
||||||
context->registry_proxy->marshall = &pinos_protocol_native_client_registry_marshall;
|
context->registry_proxy->demarshal = &pinos_protocol_native_client_registry_demarshal;
|
||||||
|
|
||||||
pinos_core_do_get_registry (context->core_proxy,
|
pinos_core_do_get_registry (context->core_proxy,
|
||||||
0,
|
0,
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,6 @@ typedef struct _PinosClientNodeBuffer PinosClientNodeBuffer;
|
||||||
|
|
||||||
#include <pinos/client/introspect.h>
|
#include <pinos/client/introspect.h>
|
||||||
|
|
||||||
#define PINOS_CORE_CLIENT_UPDATE 0
|
|
||||||
#define PINOS_CORE_SYNC 1
|
|
||||||
#define PINOS_CORE_GET_REGISTRY 2
|
|
||||||
#define PINOS_CORE_CREATE_NODE 3
|
|
||||||
#define PINOS_CORE_CREATE_CLIENT_NODE 4
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void (*client_update) (void *object,
|
void (*client_update) (void *object,
|
||||||
const SpaDict *props);
|
const SpaDict *props);
|
||||||
|
|
@ -85,8 +79,6 @@ typedef struct {
|
||||||
#define pinos_core_notify_error(r,...) ((PinosCoreEvent*)r->event)->error(r,__VA_ARGS__)
|
#define pinos_core_notify_error(r,...) ((PinosCoreEvent*)r->event)->error(r,__VA_ARGS__)
|
||||||
#define pinos_core_notify_remove_id(r,...) ((PinosCoreEvent*)r->event)->remove_id(r,__VA_ARGS__)
|
#define pinos_core_notify_remove_id(r,...) ((PinosCoreEvent*)r->event)->remove_id(r,__VA_ARGS__)
|
||||||
|
|
||||||
#define PINOS_REGISTRY_BIND 0
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void (*bind) (void *object,
|
void (*bind) (void *object,
|
||||||
uint32_t id,
|
uint32_t id,
|
||||||
|
|
@ -123,17 +115,11 @@ typedef struct {
|
||||||
#define pinos_node_notify_done(r,...) ((PinosNodeEvent*)r->event)->done(r,__VA_ARGS__)
|
#define pinos_node_notify_done(r,...) ((PinosNodeEvent*)r->event)->done(r,__VA_ARGS__)
|
||||||
#define pinos_node_notify_info(r,...) ((PinosNodeEvent*)r->event)->info(r,__VA_ARGS__)
|
#define pinos_node_notify_info(r,...) ((PinosNodeEvent*)r->event)->info(r,__VA_ARGS__)
|
||||||
|
|
||||||
#define PINOS_CLIENT_NODE_UPDATE 0
|
|
||||||
#define PINOS_CLIENT_NODE_PORT_UPDATE 1
|
|
||||||
#define PINOS_CLIENT_NODE_STATE_CHANGE 2
|
|
||||||
#define PINOS_CLIENT_NODE_EVENT 3
|
|
||||||
#define PINOS_CLIENT_NODE_DESTROY 4
|
|
||||||
|
|
||||||
struct _PinosClientNodeBuffer {
|
struct _PinosClientNodeBuffer {
|
||||||
SpaBuffer *buffer;
|
|
||||||
uint32_t mem_id;
|
uint32_t mem_id;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
SpaBuffer *buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -155,8 +141,8 @@ typedef struct {
|
||||||
#define PINOS_MESSAGE_PORT_UPDATE_INFO (1 << 3)
|
#define PINOS_MESSAGE_PORT_UPDATE_INFO (1 << 3)
|
||||||
uint32_t change_mask,
|
uint32_t change_mask,
|
||||||
unsigned int n_possible_formats,
|
unsigned int n_possible_formats,
|
||||||
SpaFormat **possible_formats,
|
const SpaFormat **possible_formats,
|
||||||
SpaFormat *format,
|
const SpaFormat *format,
|
||||||
const SpaProps *props,
|
const SpaProps *props,
|
||||||
const SpaPortInfo *info);
|
const SpaPortInfo *info);
|
||||||
void (*state_change) (void *object,
|
void (*state_change) (void *object,
|
||||||
|
|
@ -178,7 +164,7 @@ typedef struct {
|
||||||
uint32_t seq,
|
uint32_t seq,
|
||||||
int datafd);
|
int datafd);
|
||||||
void (*event) (void *object,
|
void (*event) (void *object,
|
||||||
SpaNodeEvent *event);
|
const SpaNodeEvent *event);
|
||||||
void (*add_port) (void *object,
|
void (*add_port) (void *object,
|
||||||
uint32_t seq,
|
uint32_t seq,
|
||||||
SpaDirection direction,
|
SpaDirection direction,
|
||||||
|
|
@ -197,7 +183,7 @@ typedef struct {
|
||||||
uint32_t seq,
|
uint32_t seq,
|
||||||
uint32_t id,
|
uint32_t id,
|
||||||
size_t size,
|
size_t size,
|
||||||
void *value);
|
const void *value);
|
||||||
void (*add_mem) (void *object,
|
void (*add_mem) (void *object,
|
||||||
SpaDirection direction,
|
SpaDirection direction,
|
||||||
uint32_t port_id,
|
uint32_t port_id,
|
||||||
|
|
@ -215,10 +201,10 @@ typedef struct {
|
||||||
PinosClientNodeBuffer *buffers);
|
PinosClientNodeBuffer *buffers);
|
||||||
void (*node_command) (void *object,
|
void (*node_command) (void *object,
|
||||||
uint32_t seq,
|
uint32_t seq,
|
||||||
SpaNodeCommand *command);
|
const SpaNodeCommand *command);
|
||||||
void (*port_command) (void *object,
|
void (*port_command) (void *object,
|
||||||
uint32_t port_id,
|
uint32_t port_id,
|
||||||
SpaNodeCommand *command);
|
const SpaNodeCommand *command);
|
||||||
void (*transport) (void *object,
|
void (*transport) (void *object,
|
||||||
int memfd,
|
int memfd,
|
||||||
off_t offset,
|
off_t offset,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
#include "pinos/client/serialize.h"
|
|
||||||
|
|
||||||
#include "pinos/client/context.h"
|
#include "pinos/client/context.h"
|
||||||
#include "pinos/client/subscribe.h"
|
#include "pinos/client/subscribe.h"
|
||||||
|
|
@ -254,8 +253,8 @@ pinos_node_info_update (PinosNodeInfo *info,
|
||||||
info->input_formats = NULL;
|
info->input_formats = NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < info->n_input_formats; i++) {
|
for (i = 0; i < info->n_input_formats; i++) {
|
||||||
size = pinos_serialize_format_get_size (update->input_formats[i]);
|
size = SPA_POD_SIZE (update->input_formats[i]);
|
||||||
info->input_formats[i] = size ? pinos_serialize_format_copy_into (malloc (size), update->input_formats[i]) : NULL;
|
info->input_formats[i] = memcpy (malloc (size), update->input_formats[i], size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (update->change_mask & (1 << 3))
|
if (update->change_mask & (1 << 3))
|
||||||
|
|
@ -271,8 +270,8 @@ pinos_node_info_update (PinosNodeInfo *info,
|
||||||
info->output_formats = NULL;
|
info->output_formats = NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < info->n_output_formats; i++) {
|
for (i = 0; i < info->n_output_formats; i++) {
|
||||||
size = pinos_serialize_format_get_size (update->output_formats[i]);
|
size = SPA_POD_SIZE (update->output_formats[i]);
|
||||||
info->output_formats[i] = size ? pinos_serialize_format_copy_into (malloc (size), update->output_formats[i]) : NULL;
|
info->output_formats[i] = memcpy (malloc (size), update->output_formats[i], size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#define __PINOS_INTROSPECT_H__
|
#define __PINOS_INTROSPECT_H__
|
||||||
|
|
||||||
#include <spa/include/spa/defs.h>
|
#include <spa/include/spa/defs.h>
|
||||||
|
#include <spa/include/spa/format.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -18,17 +18,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
|
#include "pinos/client/interfaces.h"
|
||||||
|
|
||||||
typedef void (*PinosMarshallFunc) (void *object, void *data, size_t size);
|
typedef void (*PinosDemarshalFunc) (void *object, void *data, size_t size);
|
||||||
|
|
||||||
extern const PinosCoreInterface pinos_protocol_native_client_core_interface;
|
extern const PinosCoreInterface pinos_protocol_native_client_core_interface;
|
||||||
extern const PinosRegistryInterface pinos_protocol_native_client_registry_interface;
|
extern const PinosRegistryInterface pinos_protocol_native_client_registry_interface;
|
||||||
extern const PinosClientNodeInterface pinos_protocol_native_client_client_node_interface;
|
extern const PinosClientNodeInterface pinos_protocol_native_client_client_node_interface;
|
||||||
|
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_client_core_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_client_core_demarshal[];
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_client_module_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_client_module_demarshal[];
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_client_node_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_client_node_demarshal[];
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_client_client_node_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_client_client_node_demarshal[];
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_client_client_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_client_client_demarshal[];
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_client_link_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_client_link_demarshal[];
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_client_registry_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_client_registry_demarshal[];
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ struct _PinosProxy {
|
||||||
|
|
||||||
const void *interface;
|
const void *interface;
|
||||||
const void *event;
|
const void *event;
|
||||||
const void *marshall;
|
const void *demarshal;
|
||||||
|
|
||||||
PINOS_SIGNAL (destroy_signal, (PinosListener *listener,
|
PINOS_SIGNAL (destroy_signal, (PinosListener *listener,
|
||||||
PinosProxy *proxy));
|
PinosProxy *proxy));
|
||||||
|
|
|
||||||
|
|
@ -89,45 +89,6 @@ pinos_serialize_buffer_copy_into (void *dest, const SpaBuffer *buffer)
|
||||||
return pinos_serialize_buffer_deserialize (dest, 0);
|
return pinos_serialize_buffer_deserialize (dest, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
|
||||||
pinos_serialize_format_get_size (const SpaFormat *format)
|
|
||||||
{
|
|
||||||
if (format == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return SPA_POD_SIZE (format);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
pinos_serialize_format_serialize (void *dest, const SpaFormat *format)
|
|
||||||
{
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
if (format == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
size = SPA_POD_SIZE (format);
|
|
||||||
memcpy (dest, format, size);
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaFormat *
|
|
||||||
pinos_serialize_format_deserialize (void *src, off_t offset)
|
|
||||||
{
|
|
||||||
return SPA_MEMBER (src, offset, SpaFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaFormat *
|
|
||||||
pinos_serialize_format_copy_into (void *dest, const SpaFormat *format)
|
|
||||||
{
|
|
||||||
if (format == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
pinos_serialize_format_serialize (dest, format);
|
|
||||||
return pinos_serialize_format_deserialize (dest, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
pinos_serialize_port_info_get_size (const SpaPortInfo *info)
|
pinos_serialize_port_info_get_size (const SpaPortInfo *info)
|
||||||
{
|
{
|
||||||
|
|
@ -201,130 +162,3 @@ pinos_serialize_port_info_copy_into (void *dest, const SpaPortInfo *info)
|
||||||
pinos_serialize_port_info_serialize (dest, info);
|
pinos_serialize_port_info_serialize (dest, info);
|
||||||
return pinos_serialize_port_info_deserialize (dest, 0);
|
return pinos_serialize_port_info_deserialize (dest, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
|
||||||
pinos_serialize_props_get_size (const SpaProps *props)
|
|
||||||
{
|
|
||||||
if (props == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return SPA_POD_SIZE (props);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
pinos_serialize_props_serialize (void *p, const SpaProps *props)
|
|
||||||
{
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
if (props == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
size = SPA_POD_SIZE (props);
|
|
||||||
memcpy (p, props, size);
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaProps *
|
|
||||||
pinos_serialize_props_deserialize (void *p, off_t offset)
|
|
||||||
{
|
|
||||||
return SPA_MEMBER (p, offset, SpaProps);
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaProps *
|
|
||||||
pinos_serialize_props_copy_into (void *dest, const SpaProps *props)
|
|
||||||
{
|
|
||||||
if (props == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
pinos_serialize_props_serialize (dest, props);
|
|
||||||
return pinos_serialize_props_deserialize (dest, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
pinos_serialize_dict_get_size (const SpaDict *dict)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
if (dict == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
len = sizeof (SpaDict);
|
|
||||||
len += dict->n_items * sizeof (SpaDictItem);
|
|
||||||
for (i = 0; i < dict->n_items; i++) {
|
|
||||||
SpaDictItem *di = &dict->items[i];
|
|
||||||
len += di->key ? strlen (di->key) + 1 : 0;
|
|
||||||
len += di->value ? strlen (di->value) + 1 : 0;
|
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
pinos_serialize_dict_serialize (void *p, const SpaDict *dict)
|
|
||||||
{
|
|
||||||
SpaDict *pi;
|
|
||||||
SpaDictItem *di;
|
|
||||||
int i;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (dict == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
pi = p;
|
|
||||||
memcpy (pi, dict, sizeof (SpaDict));
|
|
||||||
|
|
||||||
di = SPA_MEMBER (pi, sizeof (SpaDict), SpaDictItem);
|
|
||||||
if (dict->n_items)
|
|
||||||
pi->items = SPA_INT_TO_PTR (SPA_PTRDIFF (di, pi));
|
|
||||||
else
|
|
||||||
pi->items = 0;
|
|
||||||
|
|
||||||
p = SPA_MEMBER (di, sizeof (SpaDictItem) * dict->n_items, void);
|
|
||||||
|
|
||||||
for (i = 0; i < dict->n_items; i++) {
|
|
||||||
if (dict->items[i].key) {
|
|
||||||
len = strlen (dict->items[i].key) + 1;
|
|
||||||
memcpy (p, dict->items[i].key, len);
|
|
||||||
di[i].key = SPA_INT_TO_PTR (SPA_PTRDIFF (p, pi));
|
|
||||||
p += len;
|
|
||||||
} else {
|
|
||||||
di[i].key = NULL;
|
|
||||||
}
|
|
||||||
if (dict->items[i].value) {
|
|
||||||
len = strlen (dict->items[i].value) + 1;
|
|
||||||
memcpy (p, dict->items[i].value, len);
|
|
||||||
di[i].value = SPA_INT_TO_PTR (SPA_PTRDIFF (p, pi));
|
|
||||||
p += len;
|
|
||||||
} else {
|
|
||||||
di[i].value = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SPA_PTRDIFF (p, pi);
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaDict *
|
|
||||||
pinos_serialize_dict_deserialize (void *p, off_t offset)
|
|
||||||
{
|
|
||||||
SpaDict *pi;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
pi = SPA_MEMBER (p, offset, SpaDict);
|
|
||||||
if (pi->items)
|
|
||||||
pi->items = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->items), SpaDictItem);
|
|
||||||
for (i = 0; i < pi->n_items; i++) {
|
|
||||||
pi->items[i].key = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->items[i].key), char);
|
|
||||||
pi->items[i].value = SPA_MEMBER (pi, SPA_PTR_TO_INT (pi->items[i].value), char);
|
|
||||||
}
|
|
||||||
return pi;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaDict *
|
|
||||||
pinos_serialize_dict_copy_into (void *dest, const SpaDict *dict)
|
|
||||||
{
|
|
||||||
if (dict == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
pinos_serialize_dict_serialize (dest, dict);
|
|
||||||
return pinos_serialize_dict_deserialize (dest, 0);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -34,26 +34,11 @@ size_t pinos_serialize_buffer_serialize (void *dest, const SpaBuff
|
||||||
SpaBuffer * pinos_serialize_buffer_deserialize (void *src, off_t offset);
|
SpaBuffer * pinos_serialize_buffer_deserialize (void *src, off_t offset);
|
||||||
SpaBuffer * pinos_serialize_buffer_copy_into (void *dest, const SpaBuffer *buffer);
|
SpaBuffer * pinos_serialize_buffer_copy_into (void *dest, const SpaBuffer *buffer);
|
||||||
|
|
||||||
size_t pinos_serialize_format_get_size (const SpaFormat *format);
|
|
||||||
size_t pinos_serialize_format_serialize (void *dest, const SpaFormat *format);
|
|
||||||
SpaFormat * pinos_serialize_format_deserialize (void *src, off_t offset);
|
|
||||||
SpaFormat * pinos_serialize_format_copy_into (void *dest, const SpaFormat *format);
|
|
||||||
|
|
||||||
size_t pinos_serialize_port_info_get_size (const SpaPortInfo *info);
|
size_t pinos_serialize_port_info_get_size (const SpaPortInfo *info);
|
||||||
size_t pinos_serialize_port_info_serialize (void *dest, const SpaPortInfo *info);
|
size_t pinos_serialize_port_info_serialize (void *dest, const SpaPortInfo *info);
|
||||||
SpaPortInfo * pinos_serialize_port_info_deserialize (void *src, off_t offset);
|
SpaPortInfo * pinos_serialize_port_info_deserialize (void *src, off_t offset);
|
||||||
SpaPortInfo * pinos_serialize_port_info_copy_into (void *dest, const SpaPortInfo *info);
|
SpaPortInfo * pinos_serialize_port_info_copy_into (void *dest, const SpaPortInfo *info);
|
||||||
|
|
||||||
size_t pinos_serialize_props_get_size (const SpaProps *props);
|
|
||||||
size_t pinos_serialize_props_serialize (void *dest, const SpaProps *props);
|
|
||||||
SpaProps * pinos_serialize_props_deserialize (void *src, off_t offset);
|
|
||||||
SpaProps * pinos_serialize_props_copy_into (void *dest, const SpaProps *props);
|
|
||||||
|
|
||||||
size_t pinos_serialize_dict_get_size (const SpaDict *dict);
|
|
||||||
size_t pinos_serialize_dict_serialize (void *dest, const SpaDict *dict);
|
|
||||||
SpaDict * pinos_serialize_dict_deserialize (void *src, off_t offset);
|
|
||||||
SpaDict * pinos_serialize_dict_copy_into (void *dest, const SpaDict *dict);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "spa/lib/debug.h"
|
#include "spa/lib/debug.h"
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
|
#include "pinos/client/interfaces.h"
|
||||||
#include "pinos/client/protocol-native.h"
|
#include "pinos/client/protocol-native.h"
|
||||||
#include "pinos/client/array.h"
|
#include "pinos/client/array.h"
|
||||||
#include "pinos/client/connection.h"
|
#include "pinos/client/connection.h"
|
||||||
|
|
@ -34,6 +35,7 @@
|
||||||
#include "pinos/client/stream.h"
|
#include "pinos/client/stream.h"
|
||||||
#include "pinos/client/serialize.h"
|
#include "pinos/client/serialize.h"
|
||||||
#include "pinos/client/transport.h"
|
#include "pinos/client/transport.h"
|
||||||
|
#include "pinos/client/utils.h"
|
||||||
|
|
||||||
#define MAX_BUFFER_SIZE 4096
|
#define MAX_BUFFER_SIZE 4096
|
||||||
#define MAX_FDS 32
|
#define MAX_FDS 32
|
||||||
|
|
@ -344,8 +346,8 @@ add_port_update (PinosStream *stream, uint32_t change_mask, bool flush)
|
||||||
impl->port_id,
|
impl->port_id,
|
||||||
change_mask,
|
change_mask,
|
||||||
impl->n_possible_formats,
|
impl->n_possible_formats,
|
||||||
impl->possible_formats,
|
(const SpaFormat **) impl->possible_formats,
|
||||||
impl->format,
|
(const SpaFormat *) impl->format,
|
||||||
NULL,
|
NULL,
|
||||||
&impl->port_info);
|
&impl->port_info);
|
||||||
}
|
}
|
||||||
|
|
@ -583,7 +585,7 @@ handle_socket (PinosStream *stream, int rtfd)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_node_event (PinosStream *stream,
|
handle_node_event (PinosStream *stream,
|
||||||
SpaNodeEvent *event)
|
const SpaNodeEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SPA_NODE_EVENT_TYPE_INVALID:
|
case SPA_NODE_EVENT_TYPE_INVALID:
|
||||||
|
|
@ -603,7 +605,7 @@ handle_node_event (PinosStream *stream,
|
||||||
static bool
|
static bool
|
||||||
handle_node_command (PinosStream *stream,
|
handle_node_command (PinosStream *stream,
|
||||||
uint32_t seq,
|
uint32_t seq,
|
||||||
SpaNodeCommand *command)
|
const SpaNodeCommand *command)
|
||||||
{
|
{
|
||||||
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
||||||
|
|
||||||
|
|
@ -672,7 +674,7 @@ client_node_done (void *object,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
client_node_event (void *object,
|
client_node_event (void *object,
|
||||||
SpaNodeEvent *event)
|
const SpaNodeEvent *event)
|
||||||
{
|
{
|
||||||
PinosProxy *proxy = object;
|
PinosProxy *proxy = object;
|
||||||
PinosStream *stream = proxy->user_data;
|
PinosStream *stream = proxy->user_data;
|
||||||
|
|
@ -708,13 +710,10 @@ client_node_set_format (void *object,
|
||||||
PinosProxy *proxy = object;
|
PinosProxy *proxy = object;
|
||||||
PinosStream *stream = proxy->user_data;
|
PinosStream *stream = proxy->user_data;
|
||||||
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
||||||
void *mem;
|
|
||||||
|
|
||||||
if (impl->format)
|
if (impl->format)
|
||||||
free (impl->format);
|
free (impl->format);
|
||||||
mem = malloc (pinos_serialize_format_get_size (format));
|
impl->format = spa_format_copy (format);
|
||||||
impl->format = pinos_serialize_format_copy_into (mem, format);
|
|
||||||
|
|
||||||
impl->pending_seq = seq;
|
impl->pending_seq = seq;
|
||||||
|
|
||||||
pinos_signal_emit (&stream->format_changed, stream, impl->format);
|
pinos_signal_emit (&stream->format_changed, stream, impl->format);
|
||||||
|
|
@ -726,7 +725,7 @@ client_node_set_property (void *object,
|
||||||
uint32_t seq,
|
uint32_t seq,
|
||||||
uint32_t id,
|
uint32_t id,
|
||||||
size_t size,
|
size_t size,
|
||||||
void *value)
|
const void *value)
|
||||||
{
|
{
|
||||||
pinos_log_warn ("set property not implemented");
|
pinos_log_warn ("set property not implemented");
|
||||||
}
|
}
|
||||||
|
|
@ -876,7 +875,7 @@ client_node_use_buffers (void *object,
|
||||||
static void
|
static void
|
||||||
client_node_node_command (void *object,
|
client_node_node_command (void *object,
|
||||||
uint32_t seq,
|
uint32_t seq,
|
||||||
SpaNodeCommand *command)
|
const SpaNodeCommand *command)
|
||||||
{
|
{
|
||||||
PinosProxy *proxy = object;
|
PinosProxy *proxy = object;
|
||||||
PinosStream *stream = proxy->user_data;
|
PinosStream *stream = proxy->user_data;
|
||||||
|
|
@ -886,7 +885,7 @@ client_node_node_command (void *object,
|
||||||
static void
|
static void
|
||||||
client_node_port_command (void *object,
|
client_node_port_command (void *object,
|
||||||
uint32_t port_id,
|
uint32_t port_id,
|
||||||
SpaNodeCommand *command)
|
const SpaNodeCommand *command)
|
||||||
{
|
{
|
||||||
pinos_log_warn ("port command not supported");
|
pinos_log_warn ("port command not supported");
|
||||||
}
|
}
|
||||||
|
|
@ -1000,7 +999,7 @@ pinos_stream_connect (PinosStream *stream,
|
||||||
impl->node_proxy->user_data = stream;
|
impl->node_proxy->user_data = stream;
|
||||||
impl->node_proxy->event = &client_node_events;
|
impl->node_proxy->event = &client_node_events;
|
||||||
impl->node_proxy->interface = &pinos_protocol_native_client_client_node_interface;
|
impl->node_proxy->interface = &pinos_protocol_native_client_client_node_interface;
|
||||||
impl->node_proxy->marshall = &pinos_protocol_native_client_client_node_marshall;
|
impl->node_proxy->demarshal = &pinos_protocol_native_client_client_node_demarshal;
|
||||||
|
|
||||||
pinos_core_do_create_client_node (stream->context->core_proxy,
|
pinos_core_do_create_client_node (stream->context->core_proxy,
|
||||||
++impl->seq,
|
++impl->seq,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <spa/defs.h>
|
#include <spa/defs.h>
|
||||||
|
#include <spa/pod.h>
|
||||||
|
|
||||||
const char * pinos_split_walk (const char *str,
|
const char * pinos_split_walk (const char *str,
|
||||||
const char *delimiter,
|
const char *delimiter,
|
||||||
|
|
@ -39,6 +40,15 @@ void pinos_free_strv (char **str);
|
||||||
char * pinos_strip (char *str,
|
char * pinos_strip (char *str,
|
||||||
const char *whitespace);
|
const char *whitespace);
|
||||||
|
|
||||||
|
static inline SpaPOD *
|
||||||
|
pinos_spa_pod_copy (const SpaPOD *pod)
|
||||||
|
{
|
||||||
|
return pod ? memcpy (malloc (SPA_POD_SIZE (pod)), pod, SPA_POD_SIZE (pod)) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define spa_format_copy(f) ((SpaFormat*)pinos_spa_pod_copy(&(f)->pod))
|
||||||
|
#define spa_props_copy(p) ((SpaProps*)pinos_spa_pod_copy(&(p)->pod))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,9 @@ do_check_send (PinosListener *listener,
|
||||||
PinosCore *core = client->core;
|
PinosCore *core = client->core;
|
||||||
|
|
||||||
if (data->resource->type == core->uri.registry) {
|
if (data->resource->type == core->uri.registry) {
|
||||||
|
#if 0
|
||||||
switch (data->opcode) {
|
switch (data->opcode) {
|
||||||
case PINOS_MESSAGE_NOTIFY_GLOBAL:
|
case 0:
|
||||||
{
|
{
|
||||||
PinosMessageNotifyGlobal *m = data->message;
|
PinosMessageNotifyGlobal *m = data->message;
|
||||||
|
|
||||||
|
|
@ -74,7 +75,7 @@ do_check_send (PinosListener *listener,
|
||||||
data->res = SPA_RESULT_SKIPPED;
|
data->res = SPA_RESULT_SKIPPED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE:
|
case 1:
|
||||||
{
|
{
|
||||||
PinosMessageNotifyGlobalRemove *m = data->message;
|
PinosMessageNotifyGlobalRemove *m = data->message;
|
||||||
|
|
||||||
|
|
@ -89,6 +90,7 @@ do_check_send (PinosListener *listener,
|
||||||
data->res = SPA_RESULT_NO_PERMISSION;
|
data->res = SPA_RESULT_NO_PERMISSION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data->res = SPA_RESULT_OK;
|
data->res = SPA_RESULT_OK;
|
||||||
|
|
@ -104,7 +106,8 @@ do_check_dispatch (PinosListener *listener,
|
||||||
PinosCore *core = client->core;
|
PinosCore *core = client->core;
|
||||||
|
|
||||||
if (data->resource->type == core->uri.registry) {
|
if (data->resource->type == core->uri.registry) {
|
||||||
if (data->opcode == PINOS_MESSAGE_BIND) {
|
#if 0
|
||||||
|
if (data->opcode == 0) {
|
||||||
PinosMessageBind *m = data->message;
|
PinosMessageBind *m = data->message;
|
||||||
|
|
||||||
if (check_global_owner (core, client, m->id))
|
if (check_global_owner (core, client, m->id))
|
||||||
|
|
@ -114,6 +117,7 @@ do_check_dispatch (PinosListener *listener,
|
||||||
} else {
|
} else {
|
||||||
data->res = SPA_RESULT_NO_PERMISSION;
|
data->res = SPA_RESULT_NO_PERMISSION;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data->res = SPA_RESULT_OK;
|
data->res = SPA_RESULT_OK;
|
||||||
|
|
|
||||||
|
|
@ -103,31 +103,31 @@ on_resource_added (PinosListener *listener,
|
||||||
{
|
{
|
||||||
if (resource->type == resource->core->uri.core) {
|
if (resource->type == resource->core->uri.core) {
|
||||||
resource->event = &pinos_protocol_native_server_core_event;
|
resource->event = &pinos_protocol_native_server_core_event;
|
||||||
resource->marshall = &pinos_protocol_native_server_core_marshall;
|
resource->demarshal = &pinos_protocol_native_server_core_demarshal;
|
||||||
}
|
}
|
||||||
else if (resource->type == resource->core->uri.registry) {
|
else if (resource->type == resource->core->uri.registry) {
|
||||||
resource->event = &pinos_protocol_native_server_registry_event;
|
resource->event = &pinos_protocol_native_server_registry_event;
|
||||||
resource->marshall = &pinos_protocol_native_server_registry_marshall;
|
resource->demarshal = &pinos_protocol_native_server_registry_demarshal;
|
||||||
}
|
}
|
||||||
else if (resource->type == resource->core->uri.module) {
|
else if (resource->type == resource->core->uri.module) {
|
||||||
resource->event = &pinos_protocol_native_server_module_event;
|
resource->event = &pinos_protocol_native_server_module_event;
|
||||||
resource->marshall = NULL;
|
resource->demarshal = NULL;
|
||||||
}
|
}
|
||||||
else if (resource->type == resource->core->uri.node) {
|
else if (resource->type == resource->core->uri.node) {
|
||||||
resource->event = &pinos_protocol_native_server_node_event;
|
resource->event = &pinos_protocol_native_server_node_event;
|
||||||
resource->marshall = NULL;
|
resource->demarshal = NULL;
|
||||||
}
|
}
|
||||||
else if (resource->type == resource->core->uri.client) {
|
else if (resource->type == resource->core->uri.client) {
|
||||||
resource->event = &pinos_protocol_native_server_client_event;
|
resource->event = &pinos_protocol_native_server_client_event;
|
||||||
resource->marshall = NULL;
|
resource->demarshal = NULL;
|
||||||
}
|
}
|
||||||
else if (resource->type == resource->core->uri.client_node) {
|
else if (resource->type == resource->core->uri.client_node) {
|
||||||
resource->event = &pinos_protocol_native_server_client_node_events;
|
resource->event = &pinos_protocol_native_server_client_node_events;
|
||||||
resource->marshall = &pinos_protocol_native_server_client_node_marshall;
|
resource->demarshal = &pinos_protocol_native_server_client_node_demarshal;
|
||||||
}
|
}
|
||||||
else if (resource->type == resource->core->uri.link) {
|
else if (resource->type == resource->core->uri.link) {
|
||||||
resource->event = &pinos_protocol_native_server_link_event;
|
resource->event = &pinos_protocol_native_server_link_event;
|
||||||
resource->marshall = NULL;
|
resource->demarshal = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,10 +139,11 @@ connection_data (SpaSource *source,
|
||||||
{
|
{
|
||||||
PinosProtocolNativeClient *client = data;
|
PinosProtocolNativeClient *client = data;
|
||||||
PinosConnection *conn = client->connection;
|
PinosConnection *conn = client->connection;
|
||||||
PinosMessageType type;
|
uint8_t opcode;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
size_t size;
|
size_t size;
|
||||||
PinosClient *c = client->client;
|
PinosClient *c = client->client;
|
||||||
|
void *message;
|
||||||
|
|
||||||
if (mask & (SPA_IO_ERR | SPA_IO_HUP)) {
|
if (mask & (SPA_IO_ERR | SPA_IO_HUP)) {
|
||||||
pinos_log_debug ("protocol-native %p: got connection error", client->impl);
|
pinos_log_debug ("protocol-native %p: got connection error", client->impl);
|
||||||
|
|
@ -150,28 +151,22 @@ connection_data (SpaSource *source,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pinos_connection_get_next (conn, &type, &id, &size)) {
|
while (pinos_connection_get_next (conn, &opcode, &id, &message, &size)) {
|
||||||
PinosResource *resource;
|
PinosResource *resource;
|
||||||
void *message = alloca (size);
|
const PinosDemarshalFunc *demarshal;
|
||||||
const PinosMarshallFunc *marshall;
|
|
||||||
|
|
||||||
pinos_log_debug ("protocol-native %p: got message %d from %u", client->impl, type, id);
|
pinos_log_debug ("protocol-native %p: got message %d from %u", client->impl, opcode, id);
|
||||||
|
|
||||||
if (!pinos_connection_parse_message (conn, message)) {
|
|
||||||
pinos_log_error ("protocol-native %p: failed to parse message", client->impl);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
resource = pinos_map_lookup (&c->objects, id);
|
resource = pinos_map_lookup (&c->objects, id);
|
||||||
if (resource == NULL) {
|
if (resource == NULL) {
|
||||||
pinos_log_error ("protocol-native %p: unknown resource %u", client->impl, id);
|
pinos_log_error ("protocol-native %p: unknown resource %u", client->impl, id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
marshall = resource->marshall;
|
demarshal = resource->demarshal;
|
||||||
if (marshall[type])
|
if (demarshal[opcode])
|
||||||
marshall[type] (resource, message, size);
|
demarshal[opcode] (resource, message, size);
|
||||||
else
|
else
|
||||||
pinos_log_error ("protocol-native %p: function %d not implemented", client->impl, type);
|
pinos_log_error ("protocol-native %p: function %d not implemented", client->impl, opcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,8 +314,8 @@ do_update_port (SpaProxy *this,
|
||||||
uint32_t port_id,
|
uint32_t port_id,
|
||||||
uint32_t change_mask,
|
uint32_t change_mask,
|
||||||
unsigned int n_possible_formats,
|
unsigned int n_possible_formats,
|
||||||
SpaFormat **possible_formats,
|
const SpaFormat **possible_formats,
|
||||||
SpaFormat *format,
|
const SpaFormat *format,
|
||||||
const SpaProps *props,
|
const SpaProps *props,
|
||||||
const SpaPortInfo *info)
|
const SpaPortInfo *info)
|
||||||
{
|
{
|
||||||
|
|
@ -340,15 +340,13 @@ do_update_port (SpaProxy *this,
|
||||||
port->formats = NULL;
|
port->formats = NULL;
|
||||||
}
|
}
|
||||||
for (i = 0; i < port->n_formats; i++) {
|
for (i = 0; i < port->n_formats; i++) {
|
||||||
size = pinos_serialize_format_get_size (possible_formats[i]);
|
port->formats[i] = spa_format_copy (possible_formats[i]);
|
||||||
port->formats[i] = size ? pinos_serialize_format_copy_into (malloc (size), possible_formats[i]) : NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (change_mask & PINOS_MESSAGE_PORT_UPDATE_FORMAT) {
|
if (change_mask & PINOS_MESSAGE_PORT_UPDATE_FORMAT) {
|
||||||
if (port->format)
|
if (port->format)
|
||||||
free (port->format);
|
free (port->format);
|
||||||
size = pinos_serialize_format_get_size (format);
|
port->format = spa_format_copy (format);
|
||||||
port->format = size ? pinos_serialize_format_copy_into (malloc (size), format) : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change_mask & PINOS_MESSAGE_PORT_UPDATE_PROPS) {
|
if (change_mask & PINOS_MESSAGE_PORT_UPDATE_PROPS) {
|
||||||
|
|
@ -912,8 +910,8 @@ client_node_port_update (void *object,
|
||||||
uint32_t port_id,
|
uint32_t port_id,
|
||||||
uint32_t change_mask,
|
uint32_t change_mask,
|
||||||
unsigned int n_possible_formats,
|
unsigned int n_possible_formats,
|
||||||
SpaFormat **possible_formats,
|
const SpaFormat **possible_formats,
|
||||||
SpaFormat *format,
|
const SpaFormat *format,
|
||||||
const SpaProps *props,
|
const SpaProps *props,
|
||||||
const SpaPortInfo *info)
|
const SpaPortInfo *info)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,6 @@ void pinos_client_node_destroy (PinosClientNode *node);
|
||||||
|
|
||||||
SpaResult pinos_client_node_get_data_socket (PinosClientNode *node, int *fd);
|
SpaResult pinos_client_node_get_data_socket (PinosClientNode *node, int *fd);
|
||||||
|
|
||||||
SpaResult pinos_client_node_dispatch_message (PinosClientNode *node,
|
|
||||||
PinosMessageType type,
|
|
||||||
void *message);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
#include "pinos/client/interfaces.h"
|
#include "pinos/client/interfaces.h"
|
||||||
#include "pinos/client/serialize.h"
|
|
||||||
|
|
||||||
#include "pinos/server/node.h"
|
#include "pinos/server/node.h"
|
||||||
#include "pinos/server/data-loop.h"
|
#include "pinos/server/data-loop.h"
|
||||||
|
|
@ -404,7 +403,6 @@ node_bind_func (PinosGlobal *global,
|
||||||
info.input_formats = NULL;
|
info.input_formats = NULL;
|
||||||
for (info.n_input_formats = 0; ; info.n_input_formats++) {
|
for (info.n_input_formats = 0; ; info.n_input_formats++) {
|
||||||
SpaFormat *fmt;
|
SpaFormat *fmt;
|
||||||
void *p;
|
|
||||||
|
|
||||||
if (spa_node_port_enum_formats (this->node,
|
if (spa_node_port_enum_formats (this->node,
|
||||||
SPA_DIRECTION_INPUT,
|
SPA_DIRECTION_INPUT,
|
||||||
|
|
@ -415,16 +413,13 @@ node_bind_func (PinosGlobal *global,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
info.input_formats = realloc (info.input_formats, sizeof (SpaFormat*) * (info.n_input_formats + 1));
|
info.input_formats = realloc (info.input_formats, sizeof (SpaFormat*) * (info.n_input_formats + 1));
|
||||||
|
info.input_formats[info.n_input_formats] = spa_format_copy (fmt);
|
||||||
p = malloc (pinos_serialize_format_get_size (fmt));
|
|
||||||
info.input_formats[info.n_input_formats] = pinos_serialize_format_copy_into (p, fmt);
|
|
||||||
}
|
}
|
||||||
info.max_outputs = this->transport->area->max_outputs;
|
info.max_outputs = this->transport->area->max_outputs;
|
||||||
info.n_outputs = this->transport->area->n_outputs;
|
info.n_outputs = this->transport->area->n_outputs;
|
||||||
info.output_formats = NULL;
|
info.output_formats = NULL;
|
||||||
for (info.n_output_formats = 0; ; info.n_output_formats++) {
|
for (info.n_output_formats = 0; ; info.n_output_formats++) {
|
||||||
SpaFormat *fmt;
|
SpaFormat *fmt;
|
||||||
void *p;
|
|
||||||
|
|
||||||
if (spa_node_port_enum_formats (this->node,
|
if (spa_node_port_enum_formats (this->node,
|
||||||
SPA_DIRECTION_OUTPUT,
|
SPA_DIRECTION_OUTPUT,
|
||||||
|
|
@ -435,9 +430,7 @@ node_bind_func (PinosGlobal *global,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
info.output_formats = realloc (info.output_formats, sizeof (SpaFormat*) * (info.n_output_formats + 1));
|
info.output_formats = realloc (info.output_formats, sizeof (SpaFormat*) * (info.n_output_formats + 1));
|
||||||
|
info.output_formats[info.n_output_formats] = spa_format_copy (fmt);
|
||||||
p = malloc (pinos_serialize_format_get_size (fmt));
|
|
||||||
info.output_formats[info.n_output_formats] = pinos_serialize_format_copy_into (p, fmt);
|
|
||||||
}
|
}
|
||||||
info.state = this->state;
|
info.state = this->state;
|
||||||
info.error = this->error;
|
info.error = this->error;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
|
|
||||||
typedef void (*PinosMarshallFunc) (void *object, void *data, size_t size);
|
typedef void (*PinosDemarshalFunc) (void *object, void *data, size_t size);
|
||||||
|
|
||||||
extern const PinosCoreEvent pinos_protocol_native_server_core_event;
|
extern const PinosCoreEvent pinos_protocol_native_server_core_event;
|
||||||
extern const PinosRegistryEvent pinos_protocol_native_server_registry_event;
|
extern const PinosRegistryEvent pinos_protocol_native_server_registry_event;
|
||||||
|
|
@ -29,6 +29,6 @@ extern const PinosClientEvent pinos_protocol_native_server_client_event;
|
||||||
extern const PinosClientNodeEvent pinos_protocol_native_server_client_node_events;
|
extern const PinosClientNodeEvent pinos_protocol_native_server_client_node_events;
|
||||||
extern const PinosLinkEvent pinos_protocol_native_server_link_event;
|
extern const PinosLinkEvent pinos_protocol_native_server_link_event;
|
||||||
|
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_server_core_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_server_core_demarshal[];
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_server_registry_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_server_registry_demarshal[];
|
||||||
extern const PinosMarshallFunc pinos_protocol_native_server_client_node_marshall[];
|
extern const PinosDemarshalFunc pinos_protocol_native_server_client_node_demarshal[];
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ struct _PinosResource {
|
||||||
|
|
||||||
const void *interface;
|
const void *interface;
|
||||||
const void *event;
|
const void *event;
|
||||||
const void *marshall;
|
const void *demarshal;
|
||||||
|
|
||||||
PINOS_SIGNAL (destroy_signal, (PinosListener *listener,
|
PINOS_SIGNAL (destroy_signal, (PinosListener *listener,
|
||||||
PinosResource *resource));
|
PinosResource *resource));
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ spa_pod_builder_double (SpaPODBuilder *builder, double val)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline off_t
|
static inline off_t
|
||||||
spa_pod_builder_string (SpaPODBuilder *builder, const char *str, uint32_t len)
|
spa_pod_builder_string_len (SpaPODBuilder *builder, const char *str, uint32_t len)
|
||||||
{
|
{
|
||||||
const SpaPODString p = { { len + 1, SPA_POD_TYPE_STRING } };
|
const SpaPODString p = { { len + 1, SPA_POD_TYPE_STRING } };
|
||||||
off_t out = spa_pod_builder_raw (builder, &p, sizeof (p) , false);
|
off_t out = spa_pod_builder_raw (builder, &p, sizeof (p) , false);
|
||||||
|
|
@ -220,6 +220,23 @@ spa_pod_builder_string (SpaPODBuilder *builder, const char *str, uint32_t len)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline off_t
|
||||||
|
spa_pod_builder_string (SpaPODBuilder *builder, const char *str)
|
||||||
|
{
|
||||||
|
uint32_t len = str ? strlen (str) : 0;
|
||||||
|
return spa_pod_builder_string_len (builder, str ? str : "", len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline off_t
|
||||||
|
spa_pod_builder_bytes (SpaPODBuilder *builder, const void *bytes, uint32_t len)
|
||||||
|
{
|
||||||
|
const SpaPODBytes p = { { len, SPA_POD_TYPE_BYTES } };
|
||||||
|
off_t out = spa_pod_builder_raw (builder, &p, sizeof (p) , false);
|
||||||
|
if (spa_pod_builder_raw (builder, bytes, len, true) == -1)
|
||||||
|
out = -1;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
static inline off_t
|
static inline off_t
|
||||||
spa_pod_builder_rectangle (SpaPODBuilder *builder, uint32_t width, uint32_t height)
|
spa_pod_builder_rectangle (SpaPODBuilder *builder, uint32_t width, uint32_t height)
|
||||||
{
|
{
|
||||||
|
|
@ -334,7 +351,7 @@ spa_pod_builder_propv (SpaPODBuilder *builder,
|
||||||
{
|
{
|
||||||
const char *str = va_arg (args, char *);
|
const char *str = va_arg (args, char *);
|
||||||
uint32_t len = va_arg (args, uint32_t);
|
uint32_t len = va_arg (args, uint32_t);
|
||||||
spa_pod_builder_string (builder, str, len);
|
spa_pod_builder_string_len (builder, str, len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPA_POD_TYPE_RECTANGLE:
|
case SPA_POD_TYPE_RECTANGLE:
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,16 @@ typedef struct {
|
||||||
int32_t value;
|
int32_t value;
|
||||||
} SpaPODInt;
|
} SpaPODInt;
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
spa_pod_get_int (SpaPOD **pod, int32_t *val)
|
||||||
|
{
|
||||||
|
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_INT)
|
||||||
|
return false;
|
||||||
|
*val = ((SpaPODInt *)(*pod))->value;
|
||||||
|
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
typedef SpaPODInt SpaPODBool;
|
typedef SpaPODInt SpaPODBool;
|
||||||
typedef SpaPODInt SpaPODURI;
|
typedef SpaPODInt SpaPODURI;
|
||||||
|
|
||||||
|
|
@ -78,6 +88,16 @@ typedef struct {
|
||||||
int64_t value;
|
int64_t value;
|
||||||
} SpaPODLong;
|
} SpaPODLong;
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
spa_pod_get_long (SpaPOD **pod, int64_t *val)
|
||||||
|
{
|
||||||
|
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_LONG)
|
||||||
|
return false;
|
||||||
|
*val = ((SpaPODLong *)*pod)->value;
|
||||||
|
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SpaPOD pod;
|
SpaPOD pod;
|
||||||
float value;
|
float value;
|
||||||
|
|
@ -93,6 +113,21 @@ typedef struct {
|
||||||
/* value here */
|
/* value here */
|
||||||
} SpaPODString;
|
} SpaPODString;
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
spa_pod_get_string (SpaPOD **pod, const char **val)
|
||||||
|
{
|
||||||
|
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_STRING)
|
||||||
|
return false;
|
||||||
|
*val = SPA_POD_CONTENTS (SpaPODString, *pod);
|
||||||
|
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SpaPOD pod;
|
||||||
|
/* value here */
|
||||||
|
} SpaPODBytes;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SpaPOD pod;
|
SpaPOD pod;
|
||||||
SpaRectangle value;
|
SpaRectangle value;
|
||||||
|
|
@ -123,6 +158,16 @@ typedef struct {
|
||||||
/* one or more SpaPOD follow */
|
/* one or more SpaPOD follow */
|
||||||
} SpaPODStruct;
|
} SpaPODStruct;
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
spa_pod_get_struct (SpaPOD **pod, SpaPOD **val)
|
||||||
|
{
|
||||||
|
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_STRUCT)
|
||||||
|
return false;
|
||||||
|
*val = *pod;
|
||||||
|
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t key;
|
uint32_t key;
|
||||||
#define SPA_POD_PROP_RANGE_NONE 0
|
#define SPA_POD_PROP_RANGE_NONE 0
|
||||||
|
|
@ -161,6 +206,28 @@ typedef struct {
|
||||||
SpaPODObjectBody body;
|
SpaPODObjectBody body;
|
||||||
} SpaPODObject;
|
} SpaPODObject;
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
spa_pod_get_object (SpaPOD **pod, const SpaPOD **val)
|
||||||
|
{
|
||||||
|
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_OBJECT)
|
||||||
|
return false;
|
||||||
|
*val = *pod;
|
||||||
|
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
spa_pod_get_bytes (SpaPOD **pod, const void **val, uint32_t *size)
|
||||||
|
{
|
||||||
|
if (*pod == NULL || (*pod)->type != SPA_POD_TYPE_BYTES)
|
||||||
|
return false;
|
||||||
|
*val = SPA_POD_CONTENTS (SpaPODBytes, *pod);
|
||||||
|
*size = SPA_POD_SIZE (*pod);
|
||||||
|
*pod = SPA_MEMBER (*pod, SPA_ROUND_UP_N (SPA_POD_SIZE (*pod), 8), SpaPOD);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define SPA_POD_ARRAY_BODY_FOREACH(body, size, iter) \
|
#define SPA_POD_ARRAY_BODY_FOREACH(body, size, iter) \
|
||||||
for ((iter) = SPA_MEMBER (body, sizeof(SpaPODArrayBody), __typeof__(*iter)); \
|
for ((iter) = SPA_MEMBER (body, sizeof(SpaPODArrayBody), __typeof__(*iter)); \
|
||||||
(iter) < SPA_MEMBER (body, (size), __typeof__(*iter)); \
|
(iter) < SPA_MEMBER (body, (size), __typeof__(*iter)); \
|
||||||
|
|
@ -204,6 +271,7 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key)
|
||||||
return spa_pod_contents_find_prop (&obj->pod, sizeof (SpaPODObject), key);
|
return spa_pod_contents_find_prop (&obj->pod, sizeof (SpaPODObject), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -424,6 +424,10 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SPA_POD_TYPE_BYTES:
|
||||||
|
printf ("%-*sBytes\n", prefix, "");
|
||||||
|
spa_debug_dump_mem (body, size);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
printf ("unhandled prop type %d\n", type);
|
printf ("unhandled prop type %d\n", type);
|
||||||
break;
|
break;
|
||||||
|
|
@ -477,6 +481,9 @@ print_format_value (uint32_t size, uint32_t type, void *body)
|
||||||
case SPA_POD_TYPE_BITMASK:
|
case SPA_POD_TYPE_BITMASK:
|
||||||
fprintf (stderr, "Bitmask");
|
fprintf (stderr, "Bitmask");
|
||||||
break;
|
break;
|
||||||
|
case SPA_POD_TYPE_BYTES:
|
||||||
|
fprintf (stderr, "Bytes");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ main (int argc, char *argv[])
|
||||||
spa_pod_builder_long (&b, 6000);
|
spa_pod_builder_long (&b, 6000);
|
||||||
spa_pod_builder_float (&b, 4.0);
|
spa_pod_builder_float (&b, 4.0);
|
||||||
spa_pod_builder_double (&b, 3.14);
|
spa_pod_builder_double (&b, 3.14);
|
||||||
spa_pod_builder_string (&b, "test123", strlen ("test123"));
|
spa_pod_builder_string (&b, "test123");
|
||||||
spa_pod_builder_rectangle (&b, 320, 240);
|
spa_pod_builder_rectangle (&b, 320, 240);
|
||||||
spa_pod_builder_fraction (&b, 25, 1);
|
spa_pod_builder_fraction (&b, 25, 1);
|
||||||
spa_pod_builder_push_array (&b, &frame[3]);
|
spa_pod_builder_push_array (&b, &frame[3]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue