PipeWire 1.1.81
Loading...
Searching...
No Matches
node.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_NODE_H
6#define SPA_NODE_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
22#include <errno.h>
23#include <spa/utils/defs.h>
24#include <spa/utils/type.h>
25#include <spa/utils/hook.h>
26#include <spa/buffer/buffer.h>
27#include <spa/node/event.h>
28#include <spa/node/command.h>
29
30
31#define SPA_TYPE_INTERFACE_Node SPA_TYPE_INFO_INTERFACE_BASE "Node"
32
33#define SPA_VERSION_NODE 1
34struct spa_node { struct spa_interface iface; };
35
42 uint32_t max_input_ports;
43 uint32_t max_output_ports;
44#define SPA_NODE_CHANGE_MASK_FLAGS (1u<<0)
45#define SPA_NODE_CHANGE_MASK_PROPS (1u<<1)
46#define SPA_NODE_CHANGE_MASK_PARAMS (1u<<2)
47 uint64_t change_mask;
49#define SPA_NODE_FLAG_RT (1u<<0)
50#define SPA_NODE_FLAG_IN_DYNAMIC_PORTS (1u<<1)
51#define SPA_NODE_FLAG_OUT_DYNAMIC_PORTS (1u<<2)
52#define SPA_NODE_FLAG_IN_PORT_CONFIG (1u<<3)
54#define SPA_NODE_FLAG_OUT_PORT_CONFIG (1u<<4)
56#define SPA_NODE_FLAG_NEED_CONFIGURE (1u<<5)
58#define SPA_NODE_FLAG_ASYNC (1u<<6)
62 uint64_t flags;
63 struct spa_dict *props;
65 uint32_t n_params;
66};
68#define SPA_NODE_INFO_INIT() ((struct spa_node_info) { 0, })
69
75struct spa_port_info {
76#define SPA_PORT_CHANGE_MASK_FLAGS (1u<<0)
77#define SPA_PORT_CHANGE_MASK_RATE (1u<<1)
78#define SPA_PORT_CHANGE_MASK_PROPS (1u<<2)
79#define SPA_PORT_CHANGE_MASK_PARAMS (1u<<3)
80 uint64_t change_mask;
82#define SPA_PORT_FLAG_REMOVABLE (1u<<0)
83#define SPA_PORT_FLAG_OPTIONAL (1u<<1)
84#define SPA_PORT_FLAG_CAN_ALLOC_BUFFERS (1u<<2)
85#define SPA_PORT_FLAG_IN_PLACE (1u<<3)
87#define SPA_PORT_FLAG_NO_REF (1u<<4)
91#define SPA_PORT_FLAG_LIVE (1u<<5)
93#define SPA_PORT_FLAG_PHYSICAL (1u<<6)
94#define SPA_PORT_FLAG_TERMINAL (1u<<7)
97#define SPA_PORT_FLAG_DYNAMIC_DATA (1u<<8)
100 uint64_t flags;
102 const struct spa_dict *props;
103 struct spa_param_info *params;
104 uint32_t n_params;
106
107#define SPA_PORT_INFO_INIT() ((struct spa_port_info) { 0, })
108
109#define SPA_RESULT_TYPE_NODE_ERROR 1
110#define SPA_RESULT_TYPE_NODE_PARAMS 2
111
114 const char *message;
115};
116
119 uint32_t id;
120 uint32_t index;
121 uint32_t next;
122 struct spa_pod *param;
123};
124
125#define SPA_NODE_EVENT_INFO 0
126#define SPA_NODE_EVENT_PORT_INFO 1
127#define SPA_NODE_EVENT_RESULT 2
128#define SPA_NODE_EVENT_EVENT 3
129#define SPA_NODE_EVENT_PEER_ENUM_PARAM 4
130#define SPA_NODE_EVENT_NUM 5
138struct spa_node_events {
139#define SPA_VERSION_NODE_EVENTS 1
140 uint32_t version;
143 void (*info) (void *data, const struct spa_node_info *info);
146 void (*port_info) (void *data,
147 enum spa_direction direction, uint32_t port,
148 const struct spa_port_info *info);
149
166 void (*result) (void *data, int seq, int res,
167 uint32_t type, const void *result);
176 void (*event) (void *data, const struct spa_event *event);
177
186 void (*peer_enum_params) (void *data, int seq,
187 enum spa_direction direction, uint32_t port_id,
188 uint32_t id, uint32_t start, uint32_t max,
189 const struct spa_pod *filter,
190 const struct spa_node_events *events, void *events_data,
191 int *res);
192};
193
194#define SPA_NODE_CALLBACK_READY 0
195#define SPA_NODE_CALLBACK_REUSE_BUFFER 1
196#define SPA_NODE_CALLBACK_XRUN 2
197#define SPA_NODE_CALLBACK_NUM 3
198
204struct spa_node_callbacks {
205#define SPA_VERSION_NODE_CALLBACKS 0
206 uint32_t version;
215 int (*ready) (void *data, int state);
216
227 int (*reuse_buffer) (void *data,
228 uint32_t port_id,
229 uint32_t buffer_id);
230
241 int (*xrun) (void *data, uint64_t trigger, uint64_t delay,
242 struct spa_pod *info);
243};
244
245
247#define SPA_NODE_PARAM_FLAG_TEST_ONLY (1 << 0)
248#define SPA_NODE_PARAM_FLAG_FIXATE (1 << 1)
249#define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2)
253#define SPA_NODE_BUFFERS_FLAG_ALLOC (1 << 0)
258#define SPA_NODE_METHOD_ADD_LISTENER 0
259#define SPA_NODE_METHOD_SET_CALLBACKS 1
260#define SPA_NODE_METHOD_SYNC 2
261#define SPA_NODE_METHOD_ENUM_PARAMS 3
262#define SPA_NODE_METHOD_SET_PARAM 4
263#define SPA_NODE_METHOD_SET_IO 5
264#define SPA_NODE_METHOD_SEND_COMMAND 6
265#define SPA_NODE_METHOD_ADD_PORT 7
266#define SPA_NODE_METHOD_REMOVE_PORT 8
267#define SPA_NODE_METHOD_PORT_ENUM_PARAMS 9
268#define SPA_NODE_METHOD_PORT_SET_PARAM 10
269#define SPA_NODE_METHOD_PORT_USE_BUFFERS 11
270#define SPA_NODE_METHOD_PORT_SET_IO 12
271#define SPA_NODE_METHOD_PORT_REUSE_BUFFER 13
272#define SPA_NODE_METHOD_PROCESS 14
273#define SPA_NODE_METHOD_NUM 15
274
278struct spa_node_methods {
279 /* the version of the node methods. This can be used to expand this
280 * structure in the future */
281#define SPA_VERSION_NODE_METHODS 0
282 uint32_t version;
283
298 int (*add_listener) (void *object,
299 struct spa_hook *listener,
300 const struct spa_node_events *events,
301 void *data);
315 int (*set_callbacks) (void *object,
316 const struct spa_node_callbacks *callbacks,
317 void *data);
333 int (*sync) (void *object, int seq);
334
366 int (*enum_params) (void *object, int seq,
367 uint32_t id, uint32_t start, uint32_t max,
368 const struct spa_pod *filter);
369
391 int (*set_param) (void *object,
392 uint32_t id, uint32_t flags,
393 const struct spa_pod *param);
394
413 int (*set_io) (void *object,
414 uint32_t id, void *data, size_t size);
415
430 int (*send_command) (void *object, const struct spa_command *command);
431
448 int (*add_port) (void *object,
449 enum spa_direction direction, uint32_t port_id,
450 const struct spa_dict *props);
451
462 int (*remove_port) (void *object,
463 enum spa_direction direction, uint32_t port_id);
464
498 int (*port_enum_params) (void *object, int seq,
499 enum spa_direction direction, uint32_t port_id,
500 uint32_t id, uint32_t start, uint32_t max,
501 const struct spa_pod *filter);
528 int (*port_set_param) (void *object,
529 enum spa_direction direction,
530 uint32_t port_id,
531 uint32_t id, uint32_t flags,
532 const struct spa_pod *param);
533
575 int (*port_use_buffers) (void *object,
576 enum spa_direction direction,
577 uint32_t port_id,
578 uint32_t flags,
579 struct spa_buffer **buffers,
580 uint32_t n_buffers);
581
607 int (*port_set_io) (void *object,
608 enum spa_direction direction,
609 uint32_t port_id,
610 uint32_t id,
611 void *data, size_t size);
612
624 int (*port_reuse_buffer) (void *object, uint32_t port_id, uint32_t buffer_id);
625
649 int (*process) (void *object);
650};
651
652#define spa_node_method(o,method,version,...) \
653({ \
654 int _res = -ENOTSUP; \
655 struct spa_node *_n = o; \
656 spa_interface_call_res(&_n->iface, \
657 struct spa_node_methods, _res, \
658 method, version, ##__VA_ARGS__); \
659 _res; \
660})
661
662#define spa_node_method_fast(o,method,version,...) \
663({ \
664 int _res; \
665 struct spa_node *_n = o; \
666 spa_interface_call_fast_res(&_n->iface, \
667 struct spa_node_methods, _res, \
668 method, version, ##__VA_ARGS__); \
669 _res; \
670})
671
672#define spa_node_add_listener(n,...) spa_node_method(n, add_listener, 0, __VA_ARGS__)
673#define spa_node_set_callbacks(n,...) spa_node_method(n, set_callbacks, 0, __VA_ARGS__)
674#define spa_node_sync(n,...) spa_node_method(n, sync, 0, __VA_ARGS__)
675#define spa_node_enum_params(n,...) spa_node_method(n, enum_params, 0, __VA_ARGS__)
676#define spa_node_set_param(n,...) spa_node_method(n, set_param, 0, __VA_ARGS__)
677#define spa_node_set_io(n,...) spa_node_method(n, set_io, 0, __VA_ARGS__)
678#define spa_node_send_command(n,...) spa_node_method(n, send_command, 0, __VA_ARGS__)
679#define spa_node_add_port(n,...) spa_node_method(n, add_port, 0, __VA_ARGS__)
680#define spa_node_remove_port(n,...) spa_node_method(n, remove_port, 0, __VA_ARGS__)
681#define spa_node_port_enum_params(n,...) spa_node_method(n, port_enum_params, 0, __VA_ARGS__)
682#define spa_node_port_set_param(n,...) spa_node_method(n, port_set_param, 0, __VA_ARGS__)
683#define spa_node_port_use_buffers(n,...) spa_node_method(n, port_use_buffers, 0, __VA_ARGS__)
684#define spa_node_port_set_io(n,...) spa_node_method(n, port_set_io, 0, __VA_ARGS__)
685
686#define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__)
687#define spa_node_port_reuse_buffer_fast(n,...) spa_node_method_fast(n, port_reuse_buffer, 0, __VA_ARGS__)
688#define spa_node_process(n) spa_node_method(n, process, 0)
689#define spa_node_process_fast(n) spa_node_method_fast(n, process, 0)
690
695#ifdef __cplusplus
696} /* extern "C" */
697#endif
698
699#endif /* SPA_NODE_H */
spa/buffer/buffer.h
spa/utils/defs.h
spa_direction
Definition defs.h:106
spa/utils/hook.h
spa/node/command.h
spa/node/event.h
spa/utils/type.h
A Buffer.
Definition buffer.h:100
Definition command.h:29
Definition dict.h:39
Definition event.h:28
Definition defs.h:137
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:350
Definition hook.h:138
Node callbacks.
Definition node.h:249
uint32_t version
Definition node.h:252
int(* ready)(void *data, int state)
Definition node.h:261
int(* reuse_buffer)(void *data, uint32_t port_id, uint32_t buffer_id)
Definition node.h:273
int(* xrun)(void *data, uint64_t trigger, uint64_t delay, struct spa_pod *info)
Definition node.h:287
events from the spa_node.
Definition node.h:178
uint32_t version
version of this structure
Definition node.h:181
void(* event)(void *data, const struct spa_event *event)
Definition node.h:217
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result.
Definition node.h:207
void(* info)(void *data, const struct spa_node_info *info)
Emitted when info changes.
Definition node.h:184
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:187
void(* peer_enum_params)(void *data, int seq, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t start, uint32_t max, const struct spa_pod *filter, const struct spa_node_events *events, void *events_data, int *res)
Definition node.h:227
Node information structure.
Definition node.h:48
struct spa_param_info * params
parameter information
Definition node.h:81
uint64_t flags
Definition node.h:79
uint32_t n_params
number of items in params
Definition node.h:82
uint32_t max_output_ports
Definition node.h:50
uint64_t change_mask
Definition node.h:57
uint32_t max_input_ports
Definition node.h:49
Node methods.
Definition node.h:344
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:458
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:565
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:674
int(* process)(void *object)
Process the node.
Definition node.h:716
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:642
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:365
int(* sync)(void *object, int seq)
Perform a sync operation.
Definition node.h:400
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:515
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:433
int(* set_callbacks)(void *object, const struct spa_node_callbacks *callbacks, void *data)
Set callbacks to on node.
Definition node.h:382
uint32_t version
Definition node.h:349
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:480
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:691
int(* remove_port)(void *object, enum spa_direction direction, uint32_t port_id)
Remove a port with port_id.
Definition node.h:529
int(* send_command)(void *object, const struct spa_command *command)
Send a command to a node.
Definition node.h:497
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:595
Definition node.h:41
struct spa_interface iface
Definition node.h:41
information about a parameter
Definition param.h:51
Definition pod.h:43
Port information structure.
Definition node.h:93
uint64_t flags
port flags
Definition node.h:131
struct spa_fraction rate
rate of sequence numbers on port
Definition node.h:132
struct spa_param_info * params
parameter information
Definition node.h:134
uint64_t change_mask
Definition node.h:102
uint32_t n_params
number of items in params
Definition node.h:135
an error result
Definition node.h:147
const char * message
Definition node.h:148
the result of enum_params or port_enum_params.
Definition node.h:152
struct spa_pod * param
the result param
Definition node.h:156
uint32_t next
next index of iteration
Definition node.h:155
uint32_t index
index of parameter
Definition node.h:154
uint32_t id
id of parameter
Definition node.h:153