PipeWire  0.3.61
client-node.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2018 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PIPEWIRE_EXT_CLIENT_NODE_H
26 #define PIPEWIRE_EXT_CLIENT_NODE_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <spa/utils/defs.h>
33 #include <spa/param/param.h>
34 
43 #define PW_TYPE_INTERFACE_ClientNode PW_TYPE_INFO_INTERFACE_BASE "ClientNode"
44 
45 #define PW_VERSION_CLIENT_NODE 4
46 struct pw_client_node;
47 
48 #define PW_EXTENSION_MODULE_CLIENT_NODE PIPEWIRE_MODULE_PREFIX "module-client-node"
49 
52  uint32_t mem_id;
53  uint32_t offset;
54  uint32_t size;
55  struct spa_buffer *buffer;
56 };
57 
58 #define PW_CLIENT_NODE_EVENT_TRANSPORT 0
59 #define PW_CLIENT_NODE_EVENT_SET_PARAM 1
60 #define PW_CLIENT_NODE_EVENT_SET_IO 2
61 #define PW_CLIENT_NODE_EVENT_EVENT 3
62 #define PW_CLIENT_NODE_EVENT_COMMAND 4
63 #define PW_CLIENT_NODE_EVENT_ADD_PORT 5
64 #define PW_CLIENT_NODE_EVENT_REMOVE_PORT 6
65 #define PW_CLIENT_NODE_EVENT_PORT_SET_PARAM 7
66 #define PW_CLIENT_NODE_EVENT_PORT_USE_BUFFERS 8
67 #define PW_CLIENT_NODE_EVENT_PORT_SET_IO 9
68 #define PW_CLIENT_NODE_EVENT_SET_ACTIVATION 10
69 #define PW_CLIENT_NODE_EVENT_PORT_SET_MIX_INFO 11
70 #define PW_CLIENT_NODE_EVENT_NUM 12
71 
74 #define PW_VERSION_CLIENT_NODE_EVENTS 1
75  uint32_t version;
87  int (*transport) (void *data,
88  int readfd,
89  int writefd,
90  uint32_t mem_id,
91  uint32_t offset,
92  uint32_t size);
103  int (*set_param) (void *data,
104  uint32_t id, uint32_t flags,
105  const struct spa_pod *param);
117  int (*set_io) (void *data,
118  uint32_t id,
119  uint32_t mem_id,
120  uint32_t offset,
121  uint32_t size);
125  int (*event) (void *data, const struct spa_event *event);
131  int (*command) (void *data, const struct spa_command *command);
142  int (*add_port) (void *data,
143  enum spa_direction direction,
144  uint32_t port_id,
145  const struct spa_dict *props);
152  int (*remove_port) (void *data,
153  enum spa_direction direction,
154  uint32_t port_id);
164  int (*port_set_param) (void *data,
165  enum spa_direction direction,
166  uint32_t port_id,
167  uint32_t id, uint32_t flags,
168  const struct spa_pod *param);
178  int (*port_use_buffers) (void *data,
179  enum spa_direction direction,
180  uint32_t port_id,
181  uint32_t mix_id,
182  uint32_t flags,
183  uint32_t n_buffers,
184  struct pw_client_node_buffer *buffers);
196  int (*port_set_io) (void *data,
197  enum spa_direction direction,
198  uint32_t port_id,
199  uint32_t mix_id,
200  uint32_t id,
201  uint32_t mem_id,
202  uint32_t offset,
203  uint32_t size);
204 
215  int (*set_activation) (void *data,
216  uint32_t node_id,
217  int signalfd,
218  uint32_t mem_id,
219  uint32_t offset,
220  uint32_t size);
221 
233  int (*port_set_mix_info) (void *data,
234  enum spa_direction direction,
235  uint32_t port_id,
236  uint32_t mix_id,
237  uint32_t peer_id,
238  const struct spa_dict *props);
239 };
240 
241 #define PW_CLIENT_NODE_METHOD_ADD_LISTENER 0
242 #define PW_CLIENT_NODE_METHOD_GET_NODE 1
243 #define PW_CLIENT_NODE_METHOD_UPDATE 2
244 #define PW_CLIENT_NODE_METHOD_PORT_UPDATE 3
245 #define PW_CLIENT_NODE_METHOD_SET_ACTIVE 4
246 #define PW_CLIENT_NODE_METHOD_EVENT 5
247 #define PW_CLIENT_NODE_METHOD_PORT_BUFFERS 6
248 #define PW_CLIENT_NODE_METHOD_NUM 7
249 
251 struct pw_client_node_methods {
252 #define PW_VERSION_CLIENT_NODE_METHODS 0
253  uint32_t version;
254 
255  int (*add_listener) (void *object,
256  struct spa_hook *listener,
257  const struct pw_client_node_events *events,
258  void *data);
261  struct pw_node * (*get_node) (void *object, uint32_t version, size_t user_data_size);
272  int (*update) (void *object,
273 #define PW_CLIENT_NODE_UPDATE_PARAMS (1 << 0)
274 #define PW_CLIENT_NODE_UPDATE_INFO (1 << 1)
275  uint32_t change_mask,
276  uint32_t n_params,
277  const struct spa_pod **params,
278  const struct spa_node_info *info);
279 
291  int (*port_update) (void *object,
292  enum spa_direction direction,
293  uint32_t port_id,
294 #define PW_CLIENT_NODE_PORT_UPDATE_PARAMS (1 << 0)
295 #define PW_CLIENT_NODE_PORT_UPDATE_INFO (1 << 1)
296  uint32_t change_mask,
297  uint32_t n_params,
298  const struct spa_pod **params,
299  const struct spa_port_info *info);
303  int (*set_active) (void *object, bool active);
308  int (*event) (void *object, const struct spa_event *event);
309 
313  int (*port_buffers) (void *object,
314  enum spa_direction direction,
315  uint32_t port_id,
316  uint32_t mix_id,
317  uint32_t n_buffers,
318  struct spa_buffer **buffers);
319 };
320 
321 
322 #define pw_client_node_method(o,method,version,...) \
323 ({ \
324  int _res = -ENOTSUP; \
325  spa_interface_call_res((struct spa_interface*)o, \
326  struct pw_client_node_methods, _res, \
327  method, version, ##__VA_ARGS__); \
328  _res; \
329 })
330 
331 #define pw_client_node_add_listener(c,...) pw_client_node_method(c,add_listener,0,__VA_ARGS__)
332 
333 static inline struct pw_node *
334 pw_client_node_get_node(struct pw_client_node *p, uint32_t version, size_t user_data_size)
335 {
336  struct pw_node *res = NULL;
339  get_node, 0, version, user_data_size);
340  return res;
341 }
342 
343 #define pw_client_node_update(c,...) pw_client_node_method(c,update,0,__VA_ARGS__)
344 #define pw_client_node_port_update(c,...) pw_client_node_method(c,port_update,0,__VA_ARGS__)
345 #define pw_client_node_set_active(c,...) pw_client_node_method(c,set_active,0,__VA_ARGS__)
346 #define pw_client_node_event(c,...) pw_client_node_method(c,event,0,__VA_ARGS__)
347 #define pw_client_node_port_buffers(c,...) pw_client_node_method(c,port_buffers,0,__VA_ARGS__)
348 
353 #ifdef __cplusplus
354 } /* extern "C" */
355 #endif
356 
357 #endif /* PIPEWIRE_EXT_CLIENT_NODE_H */
spa/utils/defs.h
static struct pw_node * pw_client_node_get_node(struct pw_client_node *p, uint32_t version, size_t user_data_size)
Definition: client-node.h:371
int(* update)(void *object, #define PW_CLIENT_NODE_UPDATE_PARAMS #define PW_CLIENT_NODE_UPDATE_INFO uint32_t change_mask, uint32_t n_params, const struct spa_pod **params, const struct spa_node_info *info)
Update the node ports and properties.
Definition: client-node.h:303
int(* port_update)(void *object, enum spa_direction direction, uint32_t port_id, #define PW_CLIENT_NODE_PORT_UPDATE_PARAMS #define PW_CLIENT_NODE_PORT_UPDATE_INFO uint32_t change_mask, uint32_t n_params, const struct spa_pod **params, const struct spa_port_info *info)
Update a node port.
Definition: client-node.h:324
#define spa_interface_call_res(iface, method_type, res, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition: hook.h:255
spa_direction
Definition: defs.h:108
spa/param/param.h
information about a buffer
Definition: client-node.h:59
uint32_t size
size in memory
Definition: client-node.h:62
uint32_t mem_id
the memory id for the metadata
Definition: client-node.h:60
uint32_t offset
offset in memory
Definition: client-node.h:61
struct spa_buffer * buffer
buffer describing metadata and buffer memory
Definition: client-node.h:63
Client Node events
Definition: client-node.h:94
int(* port_set_io)(void *data, enum spa_direction direction, uint32_t port_id, uint32_t mix_id, uint32_t id, uint32_t mem_id, uint32_t offset, uint32_t size)
Configure the io area with id of port_id.
Definition: client-node.h:218
int(* port_use_buffers)(void *data, enum spa_direction direction, uint32_t port_id, uint32_t mix_id, uint32_t flags, uint32_t n_buffers, struct pw_client_node_buffer *buffers)
Notify the port of buffers.
Definition: client-node.h:200
int(* remove_port)(void *data, enum spa_direction direction, uint32_t port_id)
A port was removed from the node.
Definition: client-node.h:174
uint32_t version
Definition: client-node.h:97
int(* port_set_param)(void *data, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t flags, const struct spa_pod *param)
A parameter was configured on the port.
Definition: client-node.h:186
int(* event)(void *data, const struct spa_event *event)
Receive an event from the client node.
Definition: client-node.h:147
int(* set_activation)(void *data, uint32_t node_id, int signalfd, uint32_t mem_id, uint32_t offset, uint32_t size)
Notify the activation record of the next node to trigger.
Definition: client-node.h:237
int(* port_set_mix_info)(void *data, enum spa_direction direction, uint32_t port_id, uint32_t mix_id, uint32_t peer_id, const struct spa_dict *props)
Notify about the peer of mix_id.
Definition: client-node.h:255
int(* command)(void *data, const struct spa_command *command)
Notify of a new node command.
Definition: client-node.h:153
int(* set_io)(void *data, uint32_t id, uint32_t mem_id, uint32_t offset, uint32_t size)
Configure an IO area for the client.
Definition: client-node.h:139
int(* add_port)(void *data, enum spa_direction direction, uint32_t port_id, const struct spa_dict *props)
A new port was added to the node.
Definition: client-node.h:164
int(* set_param)(void *data, uint32_t id, uint32_t flags, const struct spa_pod *param)
Notify of a property change.
Definition: client-node.h:125
int(* transport)(void *data, int readfd, int writefd, uint32_t mem_id, uint32_t offset, uint32_t size)
Notify of a new transport area.
Definition: client-node.h:109
Client Node methods
Definition: client-node.h:281
int(* event)(void *object, const struct spa_event *event)
Send an event to the node.
Definition: client-node.h:343
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_client_node_events *events, void *data)
Definition: client-node.h:286
int(* port_buffers)(void *object, enum spa_direction direction, uint32_t port_id, uint32_t mix_id, uint32_t n_buffers, struct spa_buffer **buffers)
Send allocated buffers.
Definition: client-node.h:348
uint32_t version
Definition: client-node.h:284
int(* set_active)(void *object, bool active)
Activate or deactivate the node.
Definition: client-node.h:338
Definition: impl.h:45
A Buffer.
Definition: buffer.h:109
Definition: command.h:49
Definition: dict.h:59
uint32_t flags
Definition: dict.h:62
Definition: event.h:48
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351
Definition: hook.h:158
Node information structure.
Definition: node.h:68
uint32_t n_params
number of items in params
Definition: node.h:102
uint64_t change_mask
Definition: node.h:77
Definition: pod.h:63
uint32_t size
Definition: pod.h:64
Port information structure.
Definition: node.h:113