PipeWire 1.4.5 |

Loading...
Searching...
No Matches
node.h
Go to the documentation of this file.
1/* PipeWire */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef PIPEWIRE_NODE_H
6#define PIPEWIRE_NODE_H
7
8#ifdef __cplusplus
9 extern "C" {
10#endif
11
12#include <stdarg.h>
13#include <errno.h>
14
15#include <spa/utils/defs.h>
16#include <spa/utils/hook.h>
17#include <spa/node/command.h>
18#include <spa/param/param.h>
19
20#include <pipewire/proxy.h>
21
25
30#define PW_TYPE_INTERFACE_Node PW_TYPE_INFO_INTERFACE_BASE "Node"
31
32#define PW_NODE_PERM_MASK PW_PERM_RWXML
33
34#define PW_VERSION_NODE 3
35 struct pw_node;
36
37#ifndef PW_API_NODE_IMPL
38#define PW_API_NODE_IMPL static inline
39#endif
40
42 enum pw_node_state {
43 PW_NODE_STATE_ERROR = -1,
44 PW_NODE_STATE_CREATING = 0,
45 PW_NODE_STATE_SUSPENDED = 1,
47 PW_NODE_STATE_IDLE = 2,
49 PW_NODE_STATE_RUNNING = 3,
50};
51
53 const char * pw_node_state_as_string(enum pw_node_state state);
54
56 struct pw_node_info {
57 uint32_t id;
58 uint32_t max_input_ports;
59 uint32_t max_output_ports;
60#define PW_NODE_CHANGE_MASK_INPUT_PORTS (1 << 0)
61#define PW_NODE_CHANGE_MASK_OUTPUT_PORTS (1 << 1)
62#define PW_NODE_CHANGE_MASK_STATE (1 << 2)
63#define PW_NODE_CHANGE_MASK_PROPS (1 << 3)
64#define PW_NODE_CHANGE_MASK_PARAMS (1 << 4)
65#define PW_NODE_CHANGE_MASK_ALL ((1 << 5)-1)
66 uint64_t change_mask;
67 uint32_t n_input_ports;
68 uint32_t n_output_ports;
69 enum pw_node_state state;
70 const char *error;
71 struct spa_dict *props;
72 struct spa_param_info *params;
73 uint32_t n_params;
74};
75
76 struct pw_node_info *
77 pw_node_info_update(struct pw_node_info *info,
78 const struct pw_node_info *update);
79
80 struct pw_node_info *
81 pw_node_info_merge(struct pw_node_info *info,
82 const struct pw_node_info *update, bool reset);
83
84 void
85 pw_node_info_free(struct pw_node_info *info);
86
87#define PW_NODE_EVENT_INFO 0
88#define PW_NODE_EVENT_PARAM 1
89#define PW_NODE_EVENT_NUM 2
90
92 struct pw_node_events {
93#define PW_VERSION_NODE_EVENTS 0
94 uint32_t version;
100 void (*info) (void *data, const struct pw_node_info *info);
110 * \param param the parameter
111 */
112 void (*param) (void *data, int seq,
113 uint32_t id, uint32_t index, uint32_t next,
114 const struct spa_pod *param);
115};
116
117#define PW_NODE_METHOD_ADD_LISTENER 0
118#define PW_NODE_METHOD_SUBSCRIBE_PARAMS 1
119#define PW_NODE_METHOD_ENUM_PARAMS 2
120#define PW_NODE_METHOD_SET_PARAM 3
121#define PW_NODE_METHOD_SEND_COMMAND 4
122#define PW_NODE_METHOD_NUM 5
123
125 struct pw_node_methods {
126#define PW_VERSION_NODE_METHODS 0
127 uint32_t version;
128
129 int (*add_listener) (void *object,
130 struct spa_hook *listener,
131 const struct pw_node_events *events,
132 void *data);
135
144 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
145
150 * param event will be emitted.
151 *
152 * \param seq a sequence number to place in the reply
153 * \param id the parameter id to enum or PW_ID_ANY for all
154 * \param start the start index or 0 for the first param
155 * \param num the maximum number of params to retrieve
156 * \param filter a param filter or NULL
157 *
158 * This requires X permissions on the node.
159 */
160 int (*enum_params) (void *object, int seq, uint32_t id,
161 uint32_t start, uint32_t num,
162 const struct spa_pod *filter);
163
173 int (*set_param) (void *object, uint32_t id, uint32_t flags,
174 const struct spa_pod *param);
175
183 int (*send_command) (void *object, const struct spa_command *command);
184};
185
186
189 PW_API_NODE_IMPL int pw_node_add_listener(struct pw_node *object,
190 struct spa_hook *listener,
191 const struct pw_node_events *events,
192 void *data)
193{
194 return spa_api_method_r(int, -ENOTSUP,
195 pw_node, (struct spa_interface*)object, add_listener, 0,
196 listener, events, data);
197}
200 PW_API_NODE_IMPL int pw_node_subscribe_params(struct pw_node *object, uint32_t *ids, uint32_t n_ids)
201{
202 return spa_api_method_r(int, -ENOTSUP,
203 pw_node, (struct spa_interface*)object, subscribe_params, 0,
204 ids, n_ids);
205}
208 PW_API_NODE_IMPL int pw_node_enum_params(struct pw_node *object,
209 int seq, uint32_t id, uint32_t start, uint32_t num,
210 const struct spa_pod *filter)
211{
212 return spa_api_method_r(int, -ENOTSUP,
213 pw_node, (struct spa_interface*)object, enum_params, 0,
214 seq, id, start, num, filter);
215}
218 PW_API_NODE_IMPL int pw_node_set_param(struct pw_node *object, uint32_t id, uint32_t flags,
219 const struct spa_pod *param)
220{
221 return spa_api_method_r(int, -ENOTSUP,
222 pw_node, (struct spa_interface*)object, set_param, 0,
223 id, flags, param);
224}
226 * \sa pw_node_methods.send_command */
227 PW_API_NODE_IMPL int pw_node_send_command(struct pw_node *object, const struct spa_command *command)
228{
229 return spa_api_method_r(int, -ENOTSUP,
230 pw_node, (struct spa_interface*)object, send_command, 0, command);
231}
232
234 * \}
235 */
236
237#ifdef __cplusplus
238} /* extern "C" */
239#endif
240
241#endif /* PIPEWIRE_NODE_H */
defs.h
spa/utils/defs.h
seq
uint32_t int seq
Definition core.h:432
id
uint32_t id
Definition core.h:432
pw_node_subscribe_params
PW_API_NODE_IMPL int pw_node_subscribe_params(struct pw_node *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition node.h:226
pw_node_info_free
void pw_node_info_free(struct pw_node_info *info)
Definition introspect.c:233
pw_node_info_merge
struct pw_node_info * pw_node_info_merge(struct pw_node_info *info, const struct pw_node_info *update, bool reset)
Definition introspect.c:158
PW_API_NODE_IMPL
#define PW_API_NODE_IMPL
Definition node.h:47
pw_node_info_update
struct pw_node_info * pw_node_info_update(struct pw_node_info *info, const struct pw_node_info *update)
Definition introspect.c:226
pw_node_state_as_string
const char * pw_node_state_as_string(enum pw_node_state state)
Convert a pw_node_state to a readable string.
Definition introspect.c:15
pw_node_state
pw_node_state
The different node states.
Definition node.h:51
pw_node_send_command
PW_API_NODE_IMPL int pw_node_send_command(struct pw_node *object, const struct spa_command *command)
Send a command to the node.
Definition node.h:253
pw_node_add_listener
PW_API_NODE_IMPL int pw_node_add_listener(struct pw_node *object, struct spa_hook *listener, const struct pw_node_events *events, void *data)
Definition node.h:215
pw_node_set_param
PW_API_NODE_IMPL int pw_node_set_param(struct pw_node *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on the node.
Definition node.h:244
pw_node_enum_params
PW_API_NODE_IMPL int pw_node_enum_params(struct pw_node *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter)
Enumerate node parameters.
Definition node.h:234
PW_NODE_STATE_ERROR
@ PW_NODE_STATE_ERROR
error state
Definition node.h:52
PW_NODE_STATE_SUSPENDED
@ PW_NODE_STATE_SUSPENDED
the node is suspended, the device might be closed
Definition node.h:54
PW_NODE_STATE_IDLE
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition node.h:56
PW_NODE_STATE_CREATING
@ PW_NODE_STATE_CREATING
the node is being created
Definition node.h:53
PW_NODE_STATE_RUNNING
@ PW_NODE_STATE_RUNNING
the node is running
Definition node.h:58
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
hook.h
spa/utils/hook.h
command.h
spa/node/command.h
param.h
spa/param/param.h
proxy.h
pipewire/proxy.h
pw_node_events
Node events.
Definition node.h:110
pw_node_events::version
uint32_t version
Definition node.h:113
pw_node_events::param
void(* param)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a node param.
Definition node.h:131
pw_node_info
The node information.
Definition node.h:65
pw_node_info::state
enum pw_node_state state
the current state of the node
Definition node.h:84
pw_node_info::max_input_ports
uint32_t max_input_ports
maximum number of inputs
Definition node.h:67
pw_node_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition node.h:81
pw_node_info::params
struct spa_param_info * params
parameters
Definition node.h:87
pw_node_info::n_output_ports
uint32_t n_output_ports
number of outputs
Definition node.h:83
pw_node_info::max_output_ports
uint32_t max_output_ports
maximum number of outputs
Definition node.h:68
pw_node_info::n_params
uint32_t n_params
number of items in params
Definition node.h:88
pw_node_info::n_input_ports
uint32_t n_input_ports
number of inputs
Definition node.h:82
pw_node_methods
Node methods.
Definition node.h:150
pw_node_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_node_events *events, void *data)
Definition node.h:155
pw_node_methods::set_param
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on the node.
Definition node.h:199
pw_node_methods::enum_params
int(* enum_params)(void *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter)
Enumerate node parameters.
Definition node.h:186
pw_node_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition node.h:170
pw_node_methods::send_command
int(* send_command)(void *object, const struct spa_command *command)
Send a command to the node.
Definition node.h:209
pw_node
spa_command
Definition command.h:29
spa_dict
Definition dict.h:51
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_interface
Definition hook.h:148
spa_param_info
information about a parameter
Definition param.h:51
spa_pod
Definition pod.h:43