PipeWire  0.3.80
src/pipewire/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 
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 
39  PW_NODE_STATE_ERROR = -1,
43  PW_NODE_STATE_IDLE = 2,
46 };
47 
49 const char * pw_node_state_as_string(enum pw_node_state state);
50 
52 struct pw_node_info {
53  uint32_t id;
54  uint32_t max_input_ports;
55  uint32_t max_output_ports;
56 #define PW_NODE_CHANGE_MASK_INPUT_PORTS (1 << 0)
57 #define PW_NODE_CHANGE_MASK_OUTPUT_PORTS (1 << 1)
58 #define PW_NODE_CHANGE_MASK_STATE (1 << 2)
59 #define PW_NODE_CHANGE_MASK_PROPS (1 << 3)
60 #define PW_NODE_CHANGE_MASK_PARAMS (1 << 4)
61 #define PW_NODE_CHANGE_MASK_ALL ((1 << 5)-1)
62  uint64_t change_mask;
63  uint32_t n_input_ports;
64  uint32_t n_output_ports;
66  const char *error;
67  struct spa_dict *props;
68  struct spa_param_info *params;
69  uint32_t n_params;
70 };
71 
72 struct pw_node_info *
74  const struct pw_node_info *update);
75 
76 struct pw_node_info *
78  const struct pw_node_info *update, bool reset);
79 
80 void
81 pw_node_info_free(struct pw_node_info *info);
82 
83 #define PW_NODE_EVENT_INFO 0
84 #define PW_NODE_EVENT_PARAM 1
85 #define PW_NODE_EVENT_NUM 2
86 
88 struct pw_node_events {
89 #define PW_VERSION_NODE_EVENTS 0
90  uint32_t version;
96  void (*info) (void *data, const struct pw_node_info *info);
108  void (*param) (void *data, int seq,
109  uint32_t id, uint32_t index, uint32_t next,
110  const struct spa_pod *param);
111 };
112 
113 #define PW_NODE_METHOD_ADD_LISTENER 0
114 #define PW_NODE_METHOD_SUBSCRIBE_PARAMS 1
115 #define PW_NODE_METHOD_ENUM_PARAMS 2
116 #define PW_NODE_METHOD_SET_PARAM 3
117 #define PW_NODE_METHOD_SEND_COMMAND 4
118 #define PW_NODE_METHOD_NUM 5
119 
121 struct pw_node_methods {
122 #define PW_VERSION_NODE_METHODS 0
123  uint32_t version;
124 
125  int (*add_listener) (void *object,
126  struct spa_hook *listener,
127  const struct pw_node_events *events,
128  void *data);
140  int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
141 
156  int (*enum_params) (void *object, int seq, uint32_t id,
157  uint32_t start, uint32_t num,
158  const struct spa_pod *filter);
159 
169  int (*set_param) (void *object, uint32_t id, uint32_t flags,
170  const struct spa_pod *param);
171 
179  int (*send_command) (void *object, const struct spa_command *command);
180 };
181 
182 #define pw_node_method(o,method,version,...) \
183 ({ \
184  int _res = -ENOTSUP; \
185  spa_interface_call_res((struct spa_interface*)o, \
186  struct pw_node_methods, _res, \
187  method, version, ##__VA_ARGS__); \
188  _res; \
189 })
190 
192 #define pw_node_add_listener(c,...) pw_node_method(c,add_listener,0,__VA_ARGS__)
193 #define pw_node_subscribe_params(c,...) pw_node_method(c,subscribe_params,0,__VA_ARGS__)
194 #define pw_node_enum_params(c,...) pw_node_method(c,enum_params,0,__VA_ARGS__)
195 #define pw_node_set_param(c,...) pw_node_method(c,set_param,0,__VA_ARGS__)
196 #define pw_node_send_command(c,...) pw_node_method(c,send_command,0,__VA_ARGS__)
197 
202 #ifdef __cplusplus
203 } /* extern "C" */
204 #endif
205 
206 #endif /* PIPEWIRE_NODE_H */
spa/utils/defs.h
void pw_node_info_free(struct pw_node_info *info)
Definition: introspect.c:232
struct pw_node_info * pw_node_info_merge(struct pw_node_info *info, const struct pw_node_info *update, bool reset)
Definition: introspect.c:157
struct pw_node_info * pw_node_info_update(struct pw_node_info *info, const struct pw_node_info *update)
Definition: introspect.c:225
pw_node_state
The different node states.
Definition: src/pipewire/node.h:46
const char * pw_node_state_as_string(enum pw_node_state state)
Convert a pw_node_state to a readable string.
Definition: introspect.c:14
@ PW_NODE_STATE_ERROR
error state
Definition: src/pipewire/node.h:47
@ PW_NODE_STATE_SUSPENDED
the node is suspended, the device might be closed
Definition: src/pipewire/node.h:49
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: src/pipewire/node.h:51
@ PW_NODE_STATE_CREATING
the node is being created
Definition: src/pipewire/node.h:48
@ PW_NODE_STATE_RUNNING
the node is running
Definition: src/pipewire/node.h:53
spa/utils/hook.h
spa/node/command.h
spa/param/param.h
pipewire/proxy.h
Node events.
Definition: src/pipewire/node.h:105
void(* info)(void *data, const struct pw_node_info *info)
Notify node info.
Definition: src/pipewire/node.h:114
uint32_t version
Definition: src/pipewire/node.h:108
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: src/pipewire/node.h:126
The node information.
Definition: src/pipewire/node.h:60
enum pw_node_state state
the current state of the node
Definition: src/pipewire/node.h:79
uint32_t max_input_ports
maximum number of inputs
Definition: src/pipewire/node.h:62
const char * error
an error reason if state is error
Definition: src/pipewire/node.h:80
uint32_t id
id of the global
Definition: src/pipewire/node.h:61
uint64_t change_mask
bitfield of changed fields since last call
Definition: src/pipewire/node.h:76
struct spa_param_info * params
parameters
Definition: src/pipewire/node.h:82
uint32_t n_output_ports
number of outputs
Definition: src/pipewire/node.h:78
uint32_t max_output_ports
maximum number of outputs
Definition: src/pipewire/node.h:63
uint32_t n_params
number of items in params
Definition: src/pipewire/node.h:83
uint32_t n_input_ports
number of inputs
Definition: src/pipewire/node.h:77
Node methods.
Definition: src/pipewire/node.h:145
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_node_events *events, void *data)
Definition: src/pipewire/node.h:150
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on the node.
Definition: src/pipewire/node.h:194
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: src/pipewire/node.h:181
uint32_t version
Definition: src/pipewire/node.h:148
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: src/pipewire/node.h:165
int(* send_command)(void *object, const struct spa_command *command)
Send a command to the node.
Definition: src/pipewire/node.h:204
Definition: impl.h:25
Definition: pod/command.h:29
Definition: utils/dict.h:39
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:350
information about a parameter
Definition: param.h:51
Definition: pod/pod.h:43