PipeWire 0.3.77
Loading...
Searching...
No Matches
spa/include/spa/node/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 0
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_NUM 4
137struct spa_node_events {
138#define SPA_VERSION_NODE_EVENTS 0
139 uint32_t version;
142 void (*info) (void *data, const struct spa_node_info *info);
143
145 void (*port_info) (void *data,
146 enum spa_direction direction, uint32_t port,
147 const struct spa_port_info *info);
165 void (*result) (void *data, int seq, int res,
166 uint32_t type, const void *result);
167
175 void (*event) (void *data, const struct spa_event *event);
177
178#define SPA_NODE_CALLBACK_READY 0
179#define SPA_NODE_CALLBACK_REUSE_BUFFER 1
180#define SPA_NODE_CALLBACK_XRUN 2
181#define SPA_NODE_CALLBACK_NUM 3
188struct spa_node_callbacks {
189#define SPA_VERSION_NODE_CALLBACKS 0
190 uint32_t version;
199 int (*ready) (void *data, int state);
200
211 int (*reuse_buffer) (void *data,
212 uint32_t port_id,
213 uint32_t buffer_id);
214
225 int (*xrun) (void *data, uint64_t trigger, uint64_t delay,
226 struct spa_pod *info);
227};
228
229
231#define SPA_NODE_PARAM_FLAG_TEST_ONLY (1 << 0)
232#define SPA_NODE_PARAM_FLAG_FIXATE (1 << 1)
233#define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2)
237#define SPA_NODE_BUFFERS_FLAG_ALLOC (1 << 0)
242#define SPA_NODE_METHOD_ADD_LISTENER 0
243#define SPA_NODE_METHOD_SET_CALLBACKS 1
244#define SPA_NODE_METHOD_SYNC 2
245#define SPA_NODE_METHOD_ENUM_PARAMS 3
246#define SPA_NODE_METHOD_SET_PARAM 4
247#define SPA_NODE_METHOD_SET_IO 5
248#define SPA_NODE_METHOD_SEND_COMMAND 6
249#define SPA_NODE_METHOD_ADD_PORT 7
250#define SPA_NODE_METHOD_REMOVE_PORT 8
251#define SPA_NODE_METHOD_PORT_ENUM_PARAMS 9
252#define SPA_NODE_METHOD_PORT_SET_PARAM 10
253#define SPA_NODE_METHOD_PORT_USE_BUFFERS 11
254#define SPA_NODE_METHOD_PORT_SET_IO 12
255#define SPA_NODE_METHOD_PORT_REUSE_BUFFER 13
256#define SPA_NODE_METHOD_PROCESS 14
257#define SPA_NODE_METHOD_NUM 15
258
262struct spa_node_methods {
263 /* the version of the node methods. This can be used to expand this
264 * structure in the future */
265#define SPA_VERSION_NODE_METHODS 0
266 uint32_t version;
267
282 int (*add_listener) (void *object,
283 struct spa_hook *listener,
284 const struct spa_node_events *events,
285 void *data);
299 int (*set_callbacks) (void *object,
300 const struct spa_node_callbacks *callbacks,
301 void *data);
317 int (*sync) (void *object, int seq);
350 int (*enum_params) (void *object, int seq,
351 uint32_t id, uint32_t start, uint32_t max,
352 const struct spa_pod *filter);
353
375 int (*set_param) (void *object,
376 uint32_t id, uint32_t flags,
377 const struct spa_pod *param);
378
397 int (*set_io) (void *object,
398 uint32_t id, void *data, size_t size);
399
414 int (*send_command) (void *object, const struct spa_command *command);
415
432 int (*add_port) (void *object,
433 enum spa_direction direction, uint32_t port_id,
434 const struct spa_dict *props);
435
446 int (*remove_port) (void *object,
447 enum spa_direction direction, uint32_t port_id);
448
479 int (*port_enum_params) (void *object, int seq,
480 enum spa_direction direction, uint32_t port_id,
481 uint32_t id, uint32_t start, uint32_t max,
482 const struct spa_pod *filter);
507 int (*port_set_param) (void *object,
508 enum spa_direction direction,
509 uint32_t port_id,
510 uint32_t id, uint32_t flags,
511 const struct spa_pod *param);
553 int (*port_use_buffers) (void *object,
554 enum spa_direction direction,
555 uint32_t port_id,
556 uint32_t flags,
557 struct spa_buffer **buffers,
558 uint32_t n_buffers);
559
580 int (*port_set_io) (void *object,
581 enum spa_direction direction,
582 uint32_t port_id,
583 uint32_t id,
584 void *data, size_t size);
585
597 int (*port_reuse_buffer) (void *object, uint32_t port_id, uint32_t buffer_id);
598
622 int (*process) (void *object);
623};
624
625#define spa_node_method(o,method,version,...) \
626({ \
627 int _res = -ENOTSUP; \
628 struct spa_node *_n = o; \
629 spa_interface_call_res(&_n->iface, \
630 struct spa_node_methods, _res, \
631 method, version, ##__VA_ARGS__); \
632 _res; \
633})
634
635#define spa_node_method_fast(o,method,version,...) \
636({ \
637 int _res; \
638 struct spa_node *_n = o; \
639 spa_interface_call_fast_res(&_n->iface, \
640 struct spa_node_methods, _res, \
641 method, version, ##__VA_ARGS__); \
642 _res; \
643})
644
645#define spa_node_add_listener(n,...) spa_node_method(n, add_listener, 0, __VA_ARGS__)
646#define spa_node_set_callbacks(n,...) spa_node_method(n, set_callbacks, 0, __VA_ARGS__)
647#define spa_node_sync(n,...) spa_node_method(n, sync, 0, __VA_ARGS__)
648#define spa_node_enum_params(n,...) spa_node_method(n, enum_params, 0, __VA_ARGS__)
649#define spa_node_set_param(n,...) spa_node_method(n, set_param, 0, __VA_ARGS__)
650#define spa_node_set_io(n,...) spa_node_method(n, set_io, 0, __VA_ARGS__)
651#define spa_node_send_command(n,...) spa_node_method(n, send_command, 0, __VA_ARGS__)
652#define spa_node_add_port(n,...) spa_node_method(n, add_port, 0, __VA_ARGS__)
653#define spa_node_remove_port(n,...) spa_node_method(n, remove_port, 0, __VA_ARGS__)
654#define spa_node_port_enum_params(n,...) spa_node_method(n, port_enum_params, 0, __VA_ARGS__)
655#define spa_node_port_set_param(n,...) spa_node_method(n, port_set_param, 0, __VA_ARGS__)
656#define spa_node_port_use_buffers(n,...) spa_node_method(n, port_use_buffers, 0, __VA_ARGS__)
657#define spa_node_port_set_io(n,...) spa_node_method(n, port_set_io, 0, __VA_ARGS__)
658
659#define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__)
660#define spa_node_port_reuse_buffer_fast(n,...) spa_node_method_fast(n, port_reuse_buffer, 0, __VA_ARGS__)
661#define spa_node_process(n) spa_node_method(n, process, 0)
662#define spa_node_process_fast(n) spa_node_method_fast(n, process, 0)
668#ifdef __cplusplus
669} /* extern "C" */
670#endif
671
672#endif /* SPA_NODE_H */
spa/buffer/buffer.h
spa/utils/defs.h
spa_direction
Definition: defs.h:92
spa/utils/hook.h
spa/node/command.h
spa/node/event.h
spa/utils/type.h
A Buffer.
Definition: buffer/buffer.h:90
Definition: pod/command.h:29
Definition: utils/dict.h:39
Definition: pod/event.h:28
Definition: defs.h:123
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: spa/include/spa/node/node.h:232
uint32_t version
Definition: spa/include/spa/node/node.h:235
int(* ready)(void *data, int state)
Definition: spa/include/spa/node/node.h:244
int(* reuse_buffer)(void *data, uint32_t port_id, uint32_t buffer_id)
Definition: spa/include/spa/node/node.h:256
int(* xrun)(void *data, uint64_t trigger, uint64_t delay, struct spa_pod *info)
Definition: spa/include/spa/node/node.h:270
events from the spa_node.
Definition: spa/include/spa/node/node.h:176
uint32_t version
version of this structure
Definition: spa/include/spa/node/node.h:179
void(* event)(void *data, const struct spa_event *event)
Definition: spa/include/spa/node/node.h:215
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result.
Definition: spa/include/spa/node/node.h:205
void(* info)(void *data, const struct spa_node_info *info)
Emitted when info changes.
Definition: spa/include/spa/node/node.h:182
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: spa/include/spa/node/node.h:185
Node information structure.
Definition: spa/include/spa/node/node.h:48
struct spa_param_info * params
parameter information
Definition: spa/include/spa/node/node.h:81
uint64_t flags
Definition: spa/include/spa/node/node.h:79
uint32_t n_params
number of items in params
Definition: spa/include/spa/node/node.h:82
uint32_t max_output_ports
Definition: spa/include/spa/node/node.h:50
uint64_t change_mask
Definition: spa/include/spa/node/node.h:57
uint32_t max_input_ports
Definition: spa/include/spa/node/node.h:49
Node methods.
Definition: spa/include/spa/node/node.h:327
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set the configurable parameter in node.
Definition: spa/include/spa/node/node.h:441
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: spa/include/spa/node/node.h:545
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: spa/include/spa/node/node.h:646
int(* process)(void *object)
Process the node.
Definition: spa/include/spa/node/node.h:688
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: spa/include/spa/node/node.h:619
int(* add_listener)(void *object, struct spa_hook *listener, const struct spa_node_events *events, void *data)
Adds an event listener on node.
Definition: spa/include/spa/node/node.h:348
int(* sync)(void *object, int seq)
Perform a sync operation.
Definition: spa/include/spa/node/node.h:383
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: spa/include/spa/node/node.h:498
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: spa/include/spa/node/node.h:416
int(* set_callbacks)(void *object, const struct spa_node_callbacks *callbacks, void *data)
Set callbacks to on node.
Definition: spa/include/spa/node/node.h:365
uint32_t version
Definition: spa/include/spa/node/node.h:332
int(* set_io)(void *object, uint32_t id, void *data, size_t size)
Configure the given memory area with id on node.
Definition: spa/include/spa/node/node.h:463
int(* port_reuse_buffer)(void *object, uint32_t port_id, uint32_t buffer_id)
Tell an output port to reuse a buffer.
Definition: spa/include/spa/node/node.h:663
int(* remove_port)(void *object, enum spa_direction direction, uint32_t port_id)
Remove a port with port_id.
Definition: spa/include/spa/node/node.h:512
int(* send_command)(void *object, const struct spa_command *command)
Send a command to a node.
Definition: spa/include/spa/node/node.h:480
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: spa/include/spa/node/node.h:573
Definition: spa/include/spa/node/node.h:41
struct spa_interface iface
Definition: spa/include/spa/node/node.h:41
information about a parameter
Definition: param.h:50
Definition: pod/pod.h:43
Port information structure.
Definition: spa/include/spa/node/node.h:93
uint64_t flags
port flags
Definition: spa/include/spa/node/node.h:131
struct spa_fraction rate
rate of sequence numbers on port
Definition: spa/include/spa/node/node.h:132
struct spa_param_info * params
parameter information
Definition: spa/include/spa/node/node.h:134
uint64_t change_mask
Definition: spa/include/spa/node/node.h:102
uint32_t n_params
number of items in params
Definition: spa/include/spa/node/node.h:135
an error result
Definition: spa/include/spa/node/node.h:147
const char * message
Definition: spa/include/spa/node/node.h:148
the result of enum_params or port_enum_params.
Definition: spa/include/spa/node/node.h:152
struct spa_pod * param
the result param
Definition: spa/include/spa/node/node.h:156
uint32_t next
next index of iteration
Definition: spa/include/spa/node/node.h:155
uint32_t index
index of parameter
Definition: spa/include/spa/node/node.h:154
uint32_t id
id of parameter
Definition: spa/include/spa/node/node.h:153