Loading...
Searching...
No Matches
node.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_NODE_H
#define SPA_NODE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/type.h>
#include <spa/utils/hook.h>
#include <spa/buffer/buffer.h>
#include <spa/node/event.h>
#include <spa/node/command.h>
#define SPA_TYPE_INTERFACE_Node SPA_TYPE_INFO_INTERFACE_BASE "Node"
#define SPA_VERSION_NODE 0
struct spa_node { struct spa_interface iface; };
struct spa_node_info {
uint32_t max_input_ports;
uint32_t max_output_ports;
#define SPA_NODE_CHANGE_MASK_FLAGS (1u<<0)
#define SPA_NODE_CHANGE_MASK_PROPS (1u<<1)
#define SPA_NODE_CHANGE_MASK_PARAMS (1u<<2)
uint64_t change_mask;
#define SPA_NODE_FLAG_RT (1u<<0)
#define SPA_NODE_FLAG_IN_DYNAMIC_PORTS (1u<<1)
#define SPA_NODE_FLAG_OUT_DYNAMIC_PORTS (1u<<2)
#define SPA_NODE_FLAG_IN_PORT_CONFIG (1u<<3)
#define SPA_NODE_FLAG_OUT_PORT_CONFIG (1u<<4)
#define SPA_NODE_FLAG_NEED_CONFIGURE (1u<<5)
#define SPA_NODE_FLAG_ASYNC (1u<<6)
uint64_t flags;
struct spa_dict *props;
struct spa_param_info *params;
uint32_t n_params;
};
#define SPA_NODE_INFO_INIT() ((struct spa_node_info) { 0, })
struct spa_port_info {
#define SPA_PORT_CHANGE_MASK_FLAGS (1u<<0)
#define SPA_PORT_CHANGE_MASK_RATE (1u<<1)
#define SPA_PORT_CHANGE_MASK_PROPS (1u<<2)
#define SPA_PORT_CHANGE_MASK_PARAMS (1u<<3)
uint64_t change_mask;
#define SPA_PORT_FLAG_REMOVABLE (1u<<0)
#define SPA_PORT_FLAG_OPTIONAL (1u<<1)
#define SPA_PORT_FLAG_CAN_ALLOC_BUFFERS (1u<<2)
#define SPA_PORT_FLAG_IN_PLACE (1u<<3)
#define SPA_PORT_FLAG_NO_REF (1u<<4)
#define SPA_PORT_FLAG_LIVE (1u<<5)
#define SPA_PORT_FLAG_PHYSICAL (1u<<6)
#define SPA_PORT_FLAG_TERMINAL (1u<<7)
#define SPA_PORT_FLAG_DYNAMIC_DATA (1u<<8)
uint64_t flags;
struct spa_fraction rate;
const struct spa_dict *props;
struct spa_param_info *params;
uint32_t n_params;
};
#define SPA_PORT_INFO_INIT() ((struct spa_port_info) { 0, })
#define SPA_RESULT_TYPE_NODE_ERROR 1
#define SPA_RESULT_TYPE_NODE_PARAMS 2
struct spa_result_node_error {
const char *message;
};
struct spa_result_node_params {
uint32_t id;
uint32_t index;
uint32_t next;
struct spa_pod *param;
};
#define SPA_NODE_EVENT_INFO 0
#define SPA_NODE_EVENT_PORT_INFO 1
#define SPA_NODE_EVENT_RESULT 2
#define SPA_NODE_EVENT_EVENT 3
#define SPA_NODE_EVENT_NUM 4
struct spa_node_events {
#define SPA_VERSION_NODE_EVENTS 0
uint32_t version;
void (*info) (void *data, const struct spa_node_info *info);
void (*port_info) (void *data,
enum spa_direction direction, uint32_t port,
const struct spa_port_info *info);
void (*result) (void *data, int seq, int res,
uint32_t type, const void *result);
void (*event) (void *data, const struct spa_event *event);
};
#define SPA_NODE_CALLBACK_READY 0
#define SPA_NODE_CALLBACK_REUSE_BUFFER 1
#define SPA_NODE_CALLBACK_XRUN 2
#define SPA_NODE_CALLBACK_NUM 3
struct spa_node_callbacks {
#define SPA_VERSION_NODE_CALLBACKS 0
uint32_t version;
int (*ready) (void *data, int state);
int (*reuse_buffer) (void *data,
uint32_t port_id,
uint32_t buffer_id);
int (*xrun) (void *data, uint64_t trigger, uint64_t delay,
struct spa_pod *info);
};
#define SPA_NODE_PARAM_FLAG_TEST_ONLY (1 << 0)
#define SPA_NODE_PARAM_FLAG_FIXATE (1 << 1)
#define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2)
#define SPA_NODE_BUFFERS_FLAG_ALLOC (1 << 0)
#define SPA_NODE_METHOD_ADD_LISTENER 0
#define SPA_NODE_METHOD_SET_CALLBACKS 1
#define SPA_NODE_METHOD_SYNC 2
#define SPA_NODE_METHOD_ENUM_PARAMS 3
#define SPA_NODE_METHOD_SET_PARAM 4
#define SPA_NODE_METHOD_SET_IO 5
#define SPA_NODE_METHOD_SEND_COMMAND 6
#define SPA_NODE_METHOD_ADD_PORT 7
#define SPA_NODE_METHOD_REMOVE_PORT 8
#define SPA_NODE_METHOD_PORT_ENUM_PARAMS 9
#define SPA_NODE_METHOD_PORT_SET_PARAM 10
#define SPA_NODE_METHOD_PORT_USE_BUFFERS 11
#define SPA_NODE_METHOD_PORT_SET_IO 12
#define SPA_NODE_METHOD_PORT_REUSE_BUFFER 13
#define SPA_NODE_METHOD_PROCESS 14
#define SPA_NODE_METHOD_NUM 15
struct spa_node_methods {
/* the version of the node methods. This can be used to expand this
* structure in the future */
#define SPA_VERSION_NODE_METHODS 0
uint32_t version;
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct spa_node_events *events,
void *data);
int (*set_callbacks) (void *object,
const struct spa_node_callbacks *callbacks,
void *data);
int (*sync) (void *object, int seq);
int (*enum_params) (void *object, int seq,
uint32_t id, uint32_t start, uint32_t max,
const struct spa_pod *filter);
int (*set_param) (void *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
int (*set_io) (void *object,
uint32_t id, void *data, size_t size);
int (*send_command) (void *object, const struct spa_command *command);
int (*add_port) (void *object,
enum spa_direction direction, uint32_t port_id,
const struct spa_dict *props);
int (*remove_port) (void *object,
enum spa_direction direction, uint32_t port_id);
int (*port_enum_params) (void *object, int seq,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t start, uint32_t max,
const struct spa_pod *filter);
int (*port_set_param) (void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
int (*port_use_buffers) (void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers,
uint32_t n_buffers);
int (*port_set_io) (void *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t id,
void *data, size_t size);
int (*port_reuse_buffer) (void *object, uint32_t port_id, uint32_t buffer_id);
int (*process) (void *object);
};
#define spa_node_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_node *_n = o; \
spa_interface_call_res(&_n->iface, \
struct spa_node_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_node_method_fast(o,method,version,...) \
({ \
int _res; \
struct spa_node *_n = o; \
spa_interface_call_fast_res(&_n->iface, \
struct spa_node_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_node_add_listener(n,...) spa_node_method(n, add_listener, 0, __VA_ARGS__)
#define spa_node_set_callbacks(n,...) spa_node_method(n, set_callbacks, 0, __VA_ARGS__)
#define spa_node_sync(n,...) spa_node_method(n, sync, 0, __VA_ARGS__)
#define spa_node_enum_params(n,...) spa_node_method(n, enum_params, 0, __VA_ARGS__)
#define spa_node_set_param(n,...) spa_node_method(n, set_param, 0, __VA_ARGS__)
#define spa_node_set_io(n,...) spa_node_method(n, set_io, 0, __VA_ARGS__)
#define spa_node_send_command(n,...) spa_node_method(n, send_command, 0, __VA_ARGS__)
#define spa_node_add_port(n,...) spa_node_method(n, add_port, 0, __VA_ARGS__)
#define spa_node_remove_port(n,...) spa_node_method(n, remove_port, 0, __VA_ARGS__)
#define spa_node_port_enum_params(n,...) spa_node_method(n, port_enum_params, 0, __VA_ARGS__)
#define spa_node_port_set_param(n,...) spa_node_method(n, port_set_param, 0, __VA_ARGS__)
#define spa_node_port_use_buffers(n,...) spa_node_method(n, port_use_buffers, 0, __VA_ARGS__)
#define spa_node_port_set_io(n,...) spa_node_method(n, port_set_io, 0, __VA_ARGS__)
#define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__)
#define spa_node_port_reuse_buffer_fast(n,...) spa_node_method_fast(n, port_reuse_buffer, 0, __VA_ARGS__)
#define spa_node_process(n) spa_node_method(n, process, 0)
#define spa_node_process_fast(n) spa_node_method_fast(n, process, 0)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_NODE_H */
buffer.h
spa/buffer/buffer.h
defs.h
spa/utils/defs.h
spa_direction
spa_direction
Definition defs.h:92
hook.h
spa/utils/hook.h
command.h
spa/node/command.h
event.h
spa/node/event.h
type.h
spa/utils/type.h
spa_buffer
A Buffer.
Definition buffer.h:94
spa_command
Definition command.h:29
spa_dict
Definition dict.h:39
spa_event
Definition event.h:28
spa_fraction
Definition defs.h:123
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:350
spa_interface
Definition hook.h:138
spa_node_callbacks
Node callbacks.
Definition node.h:232
spa_node_callbacks::version
uint32_t version
Definition node.h:235
spa_node_callbacks::ready
int(* ready)(void *data, int state)
Definition node.h:244
spa_node_callbacks::reuse_buffer
int(* reuse_buffer)(void *data, uint32_t port_id, uint32_t buffer_id)
Definition node.h:256
spa_node_callbacks::xrun
int(* xrun)(void *data, uint64_t trigger, uint64_t delay, struct spa_pod *info)
Definition node.h:270
spa_node_events
events from the spa_node.
Definition node.h:176
spa_node_events::version
uint32_t version
version of this structure
Definition node.h:179
spa_node_events::event
void(* event)(void *data, const struct spa_event *event)
Definition node.h:215
spa_node_events::result
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result.
Definition node.h:205
spa_node_events::info
void(* info)(void *data, const struct spa_node_info *info)
Emitted when info changes.
Definition node.h:182
spa_node_events::port_info
void(* port_info)(void *data, enum spa_direction direction, uint32_t port, const struct spa_port_info *info)
Emitted when port info changes, NULL when port is removed.
Definition node.h:185
spa_node_info
Node information structure.
Definition node.h:48
spa_node_info::params
struct spa_param_info * params
parameter information
Definition node.h:81
spa_node_info::flags
uint64_t flags
Definition node.h:79
spa_node_info::n_params
uint32_t n_params
number of items in params
Definition node.h:82
spa_node_info::max_output_ports
uint32_t max_output_ports
Definition node.h:50
spa_node_info::change_mask
uint64_t change_mask
Definition node.h:57
spa_node_info::max_input_ports
uint32_t max_input_ports
Definition node.h:49
spa_node_methods
Node methods.
Definition node.h:327
spa_node_methods::set_param
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set the configurable parameter in node.
Definition node.h:441
spa_node_methods::port_enum_params
int(* port_enum_params)(void *object, int seq, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t start, uint32_t max, const struct spa_pod *filter)
Enumerate all possible parameters of id on port_id of node that are compatible with filter.
Definition node.h:545
spa_node_methods::port_set_io
int(* port_set_io)(void *object, enum spa_direction direction, uint32_t port_id, uint32_t id, void *data, size_t size)
Configure the given memory area with id on port_id.
Definition node.h:654
spa_node_methods::process
int(* process)(void *object)
Process the node.
Definition node.h:696
spa_node_methods::port_use_buffers
int(* port_use_buffers)(void *object, enum spa_direction direction, uint32_t port_id, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers)
Tell the port to use the given buffers.
Definition node.h:622
spa_node_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct spa_node_events *events, void *data)
Adds an event listener on node.
Definition node.h:348
spa_node_methods::sync
int(* sync)(void *object, int seq)
Perform a sync operation.
Definition node.h:383
spa_node_methods::add_port
int(* add_port)(void *object, enum spa_direction direction, uint32_t port_id, const struct spa_dict *props)
Make a new port with port_id.
Definition node.h:498
spa_node_methods::enum_params
int(* enum_params)(void *object, int seq, uint32_t id, uint32_t start, uint32_t max, const struct spa_pod *filter)
Enumerate the parameters of a node.
Definition node.h:416
spa_node_methods::set_callbacks
int(* set_callbacks)(void *object, const struct spa_node_callbacks *callbacks, void *data)
Set callbacks to on node.
Definition node.h:365
spa_node_methods::version
uint32_t version
Definition node.h:332
spa_node_methods::set_io
int(* set_io)(void *object, uint32_t id, void *data, size_t size)
Configure the given memory area with id on node.
Definition node.h:463
spa_node_methods::port_reuse_buffer
int(* port_reuse_buffer)(void *object, uint32_t port_id, uint32_t buffer_id)
Tell an output port to reuse a buffer.
Definition node.h:671
spa_node_methods::remove_port
int(* remove_port)(void *object, enum spa_direction direction, uint32_t port_id)
Remove a port with port_id.
Definition node.h:512
spa_node_methods::send_command
int(* send_command)(void *object, const struct spa_command *command)
Send a command to a node.
Definition node.h:480
spa_node_methods::port_set_param
int(* port_set_param)(void *object, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on port_id of node.
Definition node.h:575
spa_node
Definition node.h:41
spa_node::iface
struct spa_interface iface
Definition node.h:41
spa_param_info
information about a parameter
Definition param.h:51
spa_pod
Definition pod.h:43
spa_port_info
Port information structure.
Definition node.h:93
spa_port_info::flags
uint64_t flags
port flags
Definition node.h:131
spa_port_info::rate
struct spa_fraction rate
rate of sequence numbers on port
Definition node.h:132
spa_port_info::params
struct spa_param_info * params
parameter information
Definition node.h:134
spa_port_info::change_mask
uint64_t change_mask
Definition node.h:102
spa_port_info::n_params
uint32_t n_params
number of items in params
Definition node.h:135
spa_result_node_error
an error result
Definition node.h:147
spa_result_node_error::message
const char * message
Definition node.h:148
spa_result_node_params
the result of enum_params or port_enum_params.
Definition node.h:152
spa_result_node_params::param
struct spa_pod * param
the result param
Definition node.h:156
spa_result_node_params::next
uint32_t next
next index of iteration
Definition node.h:155
spa_result_node_params::index
uint32_t index
index of parameter
Definition node.h:154
spa_result_node_params::id
uint32_t id
id of parameter
Definition node.h:153