PipeWire 1.2.6
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 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};
67
68#define SPA_NODE_INFO_INIT() ((struct spa_node_info) { 0, })
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
114 const char *message;
115};
116
119 uint32_t id;
120 uint32_t index;
121 uint32_t next;
122 struct spa_pod *param;
123};
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
130
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
482 int (*port_enum_params) (void *object, int seq,
483 enum spa_direction direction, uint32_t port_id,
484 uint32_t id, uint32_t start, uint32_t max,
485 const struct spa_pod *filter);
512 int (*port_set_param) (void *object,
513 enum spa_direction direction,
514 uint32_t port_id,
515 uint32_t id, uint32_t flags,
516 const struct spa_pod *param);
517
559 int (*port_use_buffers) (void *object,
560 enum spa_direction direction,
561 uint32_t port_id,
562 uint32_t flags,
563 struct spa_buffer **buffers,
564 uint32_t n_buffers);
565
591 int (*port_set_io) (void *object,
592 enum spa_direction direction,
593 uint32_t port_id,
594 uint32_t id,
595 void *data, size_t size);
596
608 int (*port_reuse_buffer) (void *object, uint32_t port_id, uint32_t buffer_id);
609
633 int (*process) (void *object);
634};
635
636#define spa_node_method(o,method,version,...) \
637({ \
638 int _res = -ENOTSUP; \
639 struct spa_node *_n = o; \
640 spa_interface_call_res(&_n->iface, \
641 struct spa_node_methods, _res, \
642 method, version, ##__VA_ARGS__); \
643 _res; \
644})
645
646#define spa_node_method_fast(o,method,version,...) \
647({ \
648 int _res; \
649 struct spa_node *_n = o; \
650 spa_interface_call_fast_res(&_n->iface, \
651 struct spa_node_methods, _res, \
652 method, version, ##__VA_ARGS__); \
653 _res; \
654})
655
656#define spa_node_add_listener(n,...) spa_node_method(n, add_listener, 0, __VA_ARGS__)
657#define spa_node_set_callbacks(n,...) spa_node_method(n, set_callbacks, 0, __VA_ARGS__)
658#define spa_node_sync(n,...) spa_node_method(n, sync, 0, __VA_ARGS__)
659#define spa_node_enum_params(n,...) spa_node_method(n, enum_params, 0, __VA_ARGS__)
660#define spa_node_set_param(n,...) spa_node_method(n, set_param, 0, __VA_ARGS__)
661#define spa_node_set_io(n,...) spa_node_method(n, set_io, 0, __VA_ARGS__)
662#define spa_node_send_command(n,...) spa_node_method(n, send_command, 0, __VA_ARGS__)
663#define spa_node_add_port(n,...) spa_node_method(n, add_port, 0, __VA_ARGS__)
664#define spa_node_remove_port(n,...) spa_node_method(n, remove_port, 0, __VA_ARGS__)
665#define spa_node_port_enum_params(n,...) spa_node_method(n, port_enum_params, 0, __VA_ARGS__)
666#define spa_node_port_set_param(n,...) spa_node_method(n, port_set_param, 0, __VA_ARGS__)
667#define spa_node_port_use_buffers(n,...) spa_node_method(n, port_use_buffers, 0, __VA_ARGS__)
668#define spa_node_port_set_io(n,...) spa_node_method(n, port_set_io, 0, __VA_ARGS__)
669
670#define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__)
671#define spa_node_port_reuse_buffer_fast(n,...) spa_node_method_fast(n, port_reuse_buffer, 0, __VA_ARGS__)
672#define spa_node_process(n) spa_node_method(n, process, 0)
673#define spa_node_process_fast(n) spa_node_method_fast(n, process, 0)
679#ifdef __cplusplus
680} /* extern "C" */
681#endif
682
683#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:232
uint32_t version
Definition node.h:235
int(* ready)(void *data, int state)
Definition node.h:244
int(* reuse_buffer)(void *data, uint32_t port_id, uint32_t buffer_id)
Definition node.h:256
int(* xrun)(void *data, uint64_t trigger, uint64_t delay, struct spa_pod *info)
Definition node.h:270
events from the spa_node.
Definition node.h:176
uint32_t version
version of this structure
Definition node.h:179
void(* event)(void *data, const struct spa_event *event)
Definition node.h:215
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result.
Definition node.h:205
void(* info)(void *data, const struct spa_node_info *info)
Emitted when info changes.
Definition 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 node.h:185
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:327
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
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:548
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:657
int(* process)(void *object)
Process the node.
Definition node.h:699
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:625
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
int(* sync)(void *object, int seq)
Perform a sync operation.
Definition 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 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 node.h:416
int(* set_callbacks)(void *object, const struct spa_node_callbacks *callbacks, void *data)
Set callbacks to on node.
Definition node.h:365
uint32_t version
Definition 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 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 node.h:674
int(* remove_port)(void *object, enum spa_direction direction, uint32_t port_id)
Remove a port with port_id.
Definition node.h:512
int(* send_command)(void *object, const struct spa_command *command)
Send a command to a node.
Definition 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 node.h:578
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