2016-07-28 21:19:20 +02:00
|
|
|
/* Simple Plugin API
|
|
|
|
|
* Copyright (C) 2016 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 __SPA_CONTROL_H__
|
|
|
|
|
#define __SPA_CONTROL_H__
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
typedef struct _SpaControl SpaControl;
|
|
|
|
|
typedef struct _SpaControlIter SpaControlIter;
|
|
|
|
|
typedef struct _SpaControlBuilder SpaControlBuilder;
|
|
|
|
|
|
|
|
|
|
#define SPA_CONTROL_VERSION 0
|
|
|
|
|
|
|
|
|
|
#include <spa/defs.h>
|
|
|
|
|
#include <spa/props.h>
|
|
|
|
|
#include <spa/format.h>
|
|
|
|
|
#include <spa/port.h>
|
2016-08-02 16:34:44 +02:00
|
|
|
#include <spa/node.h>
|
2016-07-28 21:19:20 +02:00
|
|
|
|
|
|
|
|
struct _SpaControl {
|
|
|
|
|
size_t x[16];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SpaResult spa_control_init_data (SpaControl *control,
|
|
|
|
|
void *data,
|
|
|
|
|
size_t size,
|
|
|
|
|
int *fds,
|
|
|
|
|
unsigned int n_fds);
|
|
|
|
|
|
|
|
|
|
SpaResult spa_control_clear (SpaControl *control);
|
|
|
|
|
|
|
|
|
|
uint32_t spa_control_get_version (SpaControl *control);
|
|
|
|
|
int spa_control_get_fd (SpaControl *control,
|
|
|
|
|
unsigned int index,
|
|
|
|
|
bool close);
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
SPA_CONTROL_CMD_INVALID = 0,
|
|
|
|
|
/* client to server */
|
|
|
|
|
SPA_CONTROL_CMD_NODE_UPDATE = 1,
|
|
|
|
|
SPA_CONTROL_CMD_PORT_UPDATE = 2,
|
|
|
|
|
SPA_CONTROL_CMD_PORT_REMOVED = 3,
|
|
|
|
|
|
2016-09-09 16:05:58 +02:00
|
|
|
SPA_CONTROL_CMD_PORT_STATUS_CHANGE = 4,
|
2016-07-28 21:19:20 +02:00
|
|
|
|
|
|
|
|
/* server to client */
|
|
|
|
|
SPA_CONTROL_CMD_ADD_PORT = 32,
|
|
|
|
|
SPA_CONTROL_CMD_REMOVE_PORT = 33,
|
|
|
|
|
|
|
|
|
|
SPA_CONTROL_CMD_SET_FORMAT = 34,
|
|
|
|
|
SPA_CONTROL_CMD_SET_PROPERTY = 35,
|
|
|
|
|
|
2016-09-09 16:05:58 +02:00
|
|
|
SPA_CONTROL_CMD_NODE_COMMAND = 36,
|
2016-07-28 21:19:20 +02:00
|
|
|
|
|
|
|
|
/* both */
|
|
|
|
|
SPA_CONTROL_CMD_ADD_MEM = 64,
|
|
|
|
|
SPA_CONTROL_CMD_REMOVE_MEM = 65,
|
|
|
|
|
|
2016-08-26 17:43:48 +02:00
|
|
|
SPA_CONTROL_CMD_USE_BUFFERS = 66,
|
|
|
|
|
SPA_CONTROL_CMD_PROCESS_BUFFER = 67,
|
2016-07-28 21:19:20 +02:00
|
|
|
|
2016-09-09 16:05:58 +02:00
|
|
|
SPA_CONTROL_CMD_NODE_EVENT = 68,
|
2016-07-28 21:19:20 +02:00
|
|
|
} SpaControlCmd;
|
|
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_NODE_UPDATE */
|
|
|
|
|
typedef struct {
|
2016-09-09 16:05:58 +02:00
|
|
|
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
|
|
|
|
#define SPA_CONTROL_CMD_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
|
|
|
|
|
#define SPA_CONTROL_CMD_NODE_UPDATE_PROPS (1 << 2)
|
2016-07-28 21:19:20 +02:00
|
|
|
uint32_t change_mask;
|
2016-08-05 16:39:26 +02:00
|
|
|
unsigned int max_input_ports;
|
|
|
|
|
unsigned int max_output_ports;
|
2016-07-28 21:19:20 +02:00
|
|
|
const SpaProps *props;
|
|
|
|
|
} SpaControlCmdNodeUpdate;
|
|
|
|
|
|
2016-08-05 19:46:37 +02:00
|
|
|
|
2016-07-28 21:19:20 +02:00
|
|
|
/* SPA_CONTROL_CMD_PORT_UPDATE */
|
|
|
|
|
typedef struct {
|
2016-08-02 16:34:44 +02:00
|
|
|
uint32_t port_id;
|
2016-09-09 16:05:58 +02:00
|
|
|
#define SPA_CONTROL_CMD_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
|
|
|
|
|
#define SPA_CONTROL_CMD_PORT_UPDATE_PROPS (1 << 1)
|
|
|
|
|
#define SPA_CONTROL_CMD_PORT_UPDATE_INFO (1 << 2)
|
2016-07-28 21:19:20 +02:00
|
|
|
uint32_t change_mask;
|
2016-08-05 16:39:26 +02:00
|
|
|
unsigned int n_possible_formats;
|
2016-08-09 15:53:12 +02:00
|
|
|
SpaFormat **possible_formats;
|
2016-07-28 21:19:20 +02:00
|
|
|
const SpaProps *props;
|
|
|
|
|
const SpaPortInfo *info;
|
|
|
|
|
} SpaControlCmdPortUpdate;
|
|
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_PORT_REMOVED */
|
|
|
|
|
typedef struct {
|
2016-08-02 16:34:44 +02:00
|
|
|
uint32_t port_id;
|
2016-07-28 21:19:20 +02:00
|
|
|
} SpaControlCmdPortRemoved;
|
|
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_PORT_STATUS_CHANGE */
|
|
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_ADD_PORT */
|
|
|
|
|
typedef struct {
|
2016-08-05 16:39:26 +02:00
|
|
|
uint32_t port_id;
|
2016-07-28 21:19:20 +02:00
|
|
|
} SpaControlCmdAddPort;
|
|
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_REMOVE_PORT */
|
|
|
|
|
typedef struct {
|
2016-08-02 16:34:44 +02:00
|
|
|
uint32_t port_id;
|
2016-07-28 21:19:20 +02:00
|
|
|
} SpaControlCmdRemovePort;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_SET_FORMAT */
|
|
|
|
|
typedef struct {
|
2016-08-04 17:33:49 +02:00
|
|
|
uint32_t port_id;
|
|
|
|
|
SpaFormat *format;
|
2016-07-28 21:19:20 +02:00
|
|
|
} SpaControlCmdSetFormat;
|
|
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_SET_PROPERTY */
|
|
|
|
|
typedef struct {
|
2016-08-02 16:34:44 +02:00
|
|
|
uint32_t port_id;
|
2016-07-28 21:19:20 +02:00
|
|
|
uint32_t id;
|
2016-08-05 16:39:26 +02:00
|
|
|
size_t size;
|
2016-07-28 21:19:20 +02:00
|
|
|
void *value;
|
|
|
|
|
} SpaControlCmdSetProperty;
|
|
|
|
|
|
2016-09-09 16:05:58 +02:00
|
|
|
/* SPA_CONTROL_CMD_NODE_COMMAND */
|
|
|
|
|
typedef struct {
|
|
|
|
|
SpaNodeCommand *command;
|
|
|
|
|
} SpaControlCmdNodeCommand;
|
2016-07-28 21:19:20 +02:00
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_ADD_MEM */
|
|
|
|
|
typedef struct {
|
2016-08-04 17:33:49 +02:00
|
|
|
uint32_t port_id;
|
|
|
|
|
SpaMemoryRef mem;
|
|
|
|
|
uint32_t mem_type;
|
2016-08-05 16:39:26 +02:00
|
|
|
unsigned int fd_index;
|
2016-08-04 17:33:49 +02:00
|
|
|
uint32_t flags;
|
2016-08-05 16:39:26 +02:00
|
|
|
size_t size;
|
2016-07-28 21:19:20 +02:00
|
|
|
} SpaControlCmdAddMem;
|
|
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_REMOVE_MEM */
|
|
|
|
|
typedef struct {
|
2016-08-05 16:39:26 +02:00
|
|
|
uint32_t port_id;
|
2016-08-04 17:33:49 +02:00
|
|
|
SpaMemoryRef mem;
|
2016-07-28 21:19:20 +02:00
|
|
|
} SpaControlCmdRemoveMem;
|
|
|
|
|
|
2016-08-26 17:43:48 +02:00
|
|
|
/* SPA_CONTROL_CMD_USE_BUFFERS */
|
2016-07-28 21:19:20 +02:00
|
|
|
typedef struct {
|
2016-08-26 17:43:48 +02:00
|
|
|
uint32_t port_id;
|
|
|
|
|
unsigned int n_buffers;
|
|
|
|
|
SpaBuffer **buffers;
|
|
|
|
|
} SpaControlCmdUseBuffers;
|
2016-07-28 21:19:20 +02:00
|
|
|
|
|
|
|
|
/* SPA_CONTROL_CMD_PROCESS_BUFFER */
|
|
|
|
|
typedef struct {
|
2016-08-02 16:34:44 +02:00
|
|
|
uint32_t port_id;
|
|
|
|
|
uint32_t buffer_id;
|
2016-07-28 21:19:20 +02:00
|
|
|
} SpaControlCmdProcessBuffer;
|
|
|
|
|
|
2016-09-09 16:05:58 +02:00
|
|
|
/* SPA_CONTROL_CMD_NODE_EVENT */
|
2016-07-28 21:19:20 +02:00
|
|
|
typedef struct {
|
2016-09-09 16:05:58 +02:00
|
|
|
SpaNodeEvent *event;
|
|
|
|
|
} SpaControlCmdNodeEvent;
|
2016-07-28 21:19:20 +02:00
|
|
|
|
|
|
|
|
struct _SpaControlIter {
|
|
|
|
|
/*< private >*/
|
|
|
|
|
size_t x[16];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SpaResult spa_control_iter_init_full (SpaControlIter *iter,
|
|
|
|
|
SpaControl *control,
|
|
|
|
|
uint32_t version);
|
|
|
|
|
#define spa_control_iter_init(i,b) spa_control_iter_init_full(i,b, SPA_CONTROL_VERSION);
|
|
|
|
|
|
|
|
|
|
SpaResult spa_control_iter_next (SpaControlIter *iter);
|
|
|
|
|
SpaResult spa_control_iter_end (SpaControlIter *iter);
|
|
|
|
|
|
|
|
|
|
SpaControlCmd spa_control_iter_get_cmd (SpaControlIter *iter);
|
2016-08-05 16:39:26 +02:00
|
|
|
void * spa_control_iter_get_data (SpaControlIter *iter,
|
|
|
|
|
size_t *size);
|
2016-07-28 21:19:20 +02:00
|
|
|
|
|
|
|
|
SpaResult spa_control_iter_parse_cmd (SpaControlIter *iter,
|
|
|
|
|
void *command);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SpaControlBuilder:
|
|
|
|
|
*/
|
|
|
|
|
struct _SpaControlBuilder {
|
|
|
|
|
/*< private >*/
|
|
|
|
|
size_t x[16];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SpaResult spa_control_builder_init_full (SpaControlBuilder *builder,
|
|
|
|
|
uint32_t version,
|
|
|
|
|
void *data,
|
|
|
|
|
size_t max_data,
|
|
|
|
|
int *fds,
|
|
|
|
|
unsigned int max_fds);
|
|
|
|
|
#define spa_control_builder_init_into(b,d,md,f,mf) spa_control_builder_init_full(b, SPA_CONTROL_VERSION,d,md,f,mf);
|
|
|
|
|
#define spa_control_builder_init(b) spa_control_builder_init_into(b, NULL, 0, NULL, 0);
|
|
|
|
|
|
|
|
|
|
SpaResult spa_control_builder_clear (SpaControlBuilder *builder);
|
|
|
|
|
SpaResult spa_control_builder_end (SpaControlBuilder *builder,
|
|
|
|
|
SpaControl *control);
|
|
|
|
|
|
|
|
|
|
int spa_control_builder_add_fd (SpaControlBuilder *builder,
|
|
|
|
|
int fd,
|
|
|
|
|
bool close);
|
|
|
|
|
|
|
|
|
|
SpaResult spa_control_builder_add_cmd (SpaControlBuilder *builder,
|
|
|
|
|
SpaControlCmd cmd,
|
|
|
|
|
void *command);
|
|
|
|
|
|
|
|
|
|
/* IO */
|
|
|
|
|
SpaResult spa_control_read (SpaControl *control,
|
|
|
|
|
int fd,
|
|
|
|
|
void *data,
|
|
|
|
|
size_t max_data,
|
|
|
|
|
int *fds,
|
|
|
|
|
unsigned int max_fds);
|
|
|
|
|
SpaResult spa_control_write (SpaControl *control,
|
|
|
|
|
int fd);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
} /* extern "C" */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* __SPA_CONTROL_H__ */
|