| 1 |
/* PipeWire */ |
| 2 |
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */ |
| 3 |
/* SPDX-License-Identifier: MIT */ |
| 4 |
|
| 5 |
#ifndef PIPEWIRE_EXT_CLIENT_NODE_H |
| 6 |
#define PIPEWIRE_EXT_CLIENT_NODE_H |
| 7 |
|
| 8 |
#include <pw-headers/spa/utils/defs.h> |
| 9 |
#include <pw-headers/spa/param/param.h> |
| 10 |
|
| 11 |
#ifdef __cplusplus |
| 12 |
extern "C" { |
| 13 |
#endif |
| 14 |
|
| 15 |
/** \defgroup pw_client_node Client Node |
| 16 |
* Client node interface |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* \addtogroup pw_client_node |
| 21 |
* \{ |
| 22 |
*/ |
| 23 |
#define PW_TYPE_INTERFACE_ClientNode PW_TYPE_INFO_INTERFACE_BASE "ClientNode" |
| 24 |
|
| 25 |
/* |
| 26 |
* version 4: new port_set_mix_info event added |
| 27 |
* version 5: driver nodes are scheduled on the client |
| 28 |
* version 6: client needs to set activation INACTIVE -> FINISHED |
| 29 |
*/ |
| 30 |
#define PW_VERSION_CLIENT_NODE 6 |
| 31 |
struct pw_client_node; |
| 32 |
|
| 33 |
#ifndef PW_API_CLIENT_NODE_IMPL |
| 34 |
#define PW_API_CLIENT_NODE_IMPL static inline |
| 35 |
#endif |
| 36 |
|
| 37 |
#define PW_EXTENSION_MODULE_CLIENT_NODE PIPEWIRE_MODULE_PREFIX "module-client-node" |
| 38 |
|
| 39 |
/** information about a buffer */ |
| 40 |
struct pw_client_node_buffer { |
| 41 |
uint32_t mem_id; /**< the memory id for the metadata */ |
| 42 |
uint32_t offset; /**< offset in memory */ |
| 43 |
uint32_t size; /**< size in memory */ |
| 44 |
struct spa_buffer *buffer; /**< buffer describing metadata and buffer memory */ |
| 45 |
}; |
| 46 |
|
| 47 |
#define PW_CLIENT_NODE_EVENT_TRANSPORT 0 |
| 48 |
#define PW_CLIENT_NODE_EVENT_SET_PARAM 1 |
| 49 |
#define PW_CLIENT_NODE_EVENT_SET_IO 2 |
| 50 |
#define PW_CLIENT_NODE_EVENT_EVENT 3 |
| 51 |
#define PW_CLIENT_NODE_EVENT_COMMAND 4 |
| 52 |
#define PW_CLIENT_NODE_EVENT_ADD_PORT 5 |
| 53 |
#define PW_CLIENT_NODE_EVENT_REMOVE_PORT 6 |
| 54 |
#define PW_CLIENT_NODE_EVENT_PORT_SET_PARAM 7 |
| 55 |
#define PW_CLIENT_NODE_EVENT_PORT_USE_BUFFERS 8 |
| 56 |
#define PW_CLIENT_NODE_EVENT_PORT_SET_IO 9 |
| 57 |
#define PW_CLIENT_NODE_EVENT_SET_ACTIVATION 10 |
| 58 |
#define PW_CLIENT_NODE_EVENT_PORT_SET_MIX_INFO 11 |
| 59 |
#define PW_CLIENT_NODE_EVENT_NUM 12 |
| 60 |
|
| 61 |
/** \ref pw_client_node events */ |
| 62 |
struct pw_client_node_events { |
| 63 |
#define PW_VERSION_CLIENT_NODE_EVENTS 1 |
| 64 |
uint32_t version; |
| 65 |
/** |
| 66 |
* Notify of a new transport area |
| 67 |
* |
| 68 |
* The transport area is used to signal the client and the server. |
| 69 |
* |
| 70 |
* \param readfd fd for signal data can be read |
| 71 |
* \param writefd fd for signal data can be written |
| 72 |
* \param mem_id id for activation memory |
| 73 |
* \param offset offset of activation memory |
| 74 |
* \param size size of activation memory |
| 75 |
*/ |
| 76 |
int (*transport) (void *data, |
| 77 |
int readfd, |
| 78 |
int writefd, |
| 79 |
uint32_t mem_id, |
| 80 |
uint32_t offset, |
| 81 |
uint32_t size); |
| 82 |
/** |
| 83 |
* Notify of a property change |
| 84 |
* |
| 85 |
* When the server configures the properties on the node |
| 86 |
* this event is sent |
| 87 |
* |
| 88 |
* \param id the id of the parameter |
| 89 |
* \param flags parameter flags |
| 90 |
* \param param the param to set |
| 91 |
*/ |
| 92 |
int (*set_param) (void *data, |
| 93 |
uint32_t id, uint32_t flags, |
| 94 |
const struct spa_pod *param); |
| 95 |
/** |
| 96 |
* Configure an IO area for the client |
| 97 |
* |
| 98 |
* IO areas are identified with an id and are used to |
| 99 |
* exchange state between client and server |
| 100 |
* |
| 101 |
* \param id the id of the io area |
| 102 |
* \param mem_id the id of the memory to use |
| 103 |
* \param offset offset of io area in memory |
| 104 |
* \param size size of the io area |
| 105 |
*/ |
| 106 |
int (*set_io) (void *data, |
| 107 |
uint32_t id, |
| 108 |
uint32_t mem_id, |
| 109 |
uint32_t offset, |
| 110 |
uint32_t size); |
| 111 |
/** |
| 112 |
* Receive an event from the client node |
| 113 |
* \param event the received event */ |
| 114 |
int (*event) (void *data, const struct spa_event *event); |
| 115 |
/** |
| 116 |
* Notify of a new node command |
| 117 |
* |
| 118 |
* \param command the command |
| 119 |
*/ |
| 120 |
int (*command) (void *data, const struct spa_command *command); |
| 121 |
/** |
| 122 |
* A new port was added to the node |
| 123 |
* |
| 124 |
* The server can at any time add a port to the node when there |
| 125 |
* are free ports available. |
| 126 |
* |
| 127 |
* \param direction the direction of the port |
| 128 |
* \param port_id the new port id |
| 129 |
* \param props extra properties |
| 130 |
*/ |
| 131 |
int (*add_port) (void *data, |
| 132 |
enum spa_direction direction, |
| 133 |
uint32_t port_id, |
| 134 |
const struct spa_dict *props); |
| 135 |
/** |
| 136 |
* A port was removed from the node |
| 137 |
* |
| 138 |
* \param direction a port direction |
| 139 |
* \param port_id the remove port id |
| 140 |
*/ |
| 141 |
int (*remove_port) (void *data, |
| 142 |
enum spa_direction direction, |
| 143 |
uint32_t port_id); |
| 144 |
/** |
| 145 |
* A parameter was configured on the port |
| 146 |
* |
| 147 |
* \param direction a port direction |
| 148 |
* \param port_id the port id |
| 149 |
* \param id the id of the parameter |
| 150 |
* \param flags flags used when setting the param |
| 151 |
* \param param the new param |
| 152 |
*/ |
| 153 |
int (*port_set_param) (void *data, |
| 154 |
enum spa_direction direction, |
| 155 |
uint32_t port_id, |
| 156 |
uint32_t id, uint32_t flags, |
| 157 |
const struct spa_pod *param); |
| 158 |
/** |
| 159 |
* Notify the port of buffers |
| 160 |
* |
| 161 |
* \param direction a port direction |
| 162 |
* \param port_id the port id |
| 163 |
* \param mix_id the mixer port id |
| 164 |
* \param n_buffer the number of buffers |
| 165 |
* \param buffers and array of buffer descriptions |
| 166 |
*/ |
| 167 |
int (*port_use_buffers) (void *data, |
| 168 |
enum spa_direction direction, |
| 169 |
uint32_t port_id, |
| 170 |
uint32_t mix_id, |
| 171 |
uint32_t flags, |
| 172 |
uint32_t n_buffers, |
| 173 |
struct pw_client_node_buffer *buffers); |
| 174 |
/** |
| 175 |
* Configure the io area with \a id of \a port_id. |
| 176 |
* |
| 177 |
* \param direction the direction of the port |
| 178 |
* \param port_id the port id |
| 179 |
* \param mix_id the mixer port id |
| 180 |
* \param id the id of the io area to set |
| 181 |
* \param mem_id the id of the memory to use |
| 182 |
* \param offset offset of io area in memory |
| 183 |
* \param size size of the io area |
| 184 |
*/ |
| 185 |
int (*port_set_io) (void *data, |
| 186 |
enum spa_direction direction, |
| 187 |
uint32_t port_id, |
| 188 |
uint32_t mix_id, |
| 189 |
uint32_t id, |
| 190 |
uint32_t mem_id, |
| 191 |
uint32_t offset, |
| 192 |
uint32_t size); |
| 193 |
|
| 194 |
/** |
| 195 |
* Notify the activation record of the next |
| 196 |
* node to trigger |
| 197 |
* |
| 198 |
* \param node_id the peer node id |
| 199 |
* \param signalfd the fd to wake up the peer |
| 200 |
* \param mem_id the mem id of the memory |
| 201 |
* \param the offset in \a mem_id to map |
| 202 |
* \param the size of \a mem_id to map |
| 203 |
*/ |
| 204 |
int (*set_activation) (void *data, |
| 205 |
uint32_t node_id, |
| 206 |
int signalfd, |
| 207 |
uint32_t mem_id, |
| 208 |
uint32_t offset, |
| 209 |
uint32_t size); |
| 210 |
|
| 211 |
/** |
| 212 |
* Notify about the peer of mix_id |
| 213 |
* |
| 214 |
* \param direction the direction of the port |
| 215 |
* \param port_id the port id |
| 216 |
* \param mix_id the mix id |
| 217 |
* \param peer_id the id of the peer port |
| 218 |
* \param props extra properties |
| 219 |
* |
| 220 |
* Since version 4:1 |
| 221 |
*/ |
| 222 |
int (*port_set_mix_info) (void *data, |
| 223 |
enum spa_direction direction, |
| 224 |
uint32_t port_id, |
| 225 |
uint32_t mix_id, |
| 226 |
uint32_t peer_id, |
| 227 |
const struct spa_dict *props); |
| 228 |
}; |
| 229 |
|
| 230 |
#define PW_CLIENT_NODE_METHOD_ADD_LISTENER 0 |
| 231 |
#define PW_CLIENT_NODE_METHOD_GET_NODE 1 |
| 232 |
#define PW_CLIENT_NODE_METHOD_UPDATE 2 |
| 233 |
#define PW_CLIENT_NODE_METHOD_PORT_UPDATE 3 |
| 234 |
#define PW_CLIENT_NODE_METHOD_SET_ACTIVE 4 |
| 235 |
#define PW_CLIENT_NODE_METHOD_EVENT 5 |
| 236 |
#define PW_CLIENT_NODE_METHOD_PORT_BUFFERS 6 |
| 237 |
#define PW_CLIENT_NODE_METHOD_NUM 7 |
| 238 |
|
| 239 |
/** \ref pw_client_node methods */ |
| 240 |
struct pw_client_node_methods { |
| 241 |
#define PW_VERSION_CLIENT_NODE_METHODS 0 |
| 242 |
uint32_t version; |
| 243 |
|
| 244 |
int (*add_listener) (void *object, |
| 245 |
struct spa_hook *listener, |
| 246 |
const struct pw_client_node_events *events, |
| 247 |
void *data); |
| 248 |
/** get the node object |
| 249 |
*/ |
| 250 |
struct pw_node * (*get_node) (void *object, uint32_t version, size_t user_data_size); |
| 251 |
/** |
| 252 |
* Update the node ports and properties |
| 253 |
* |
| 254 |
* Update the maximum number of ports and the params of the |
| 255 |
* client node. |
| 256 |
* \param change_mask bitfield with changed parameters |
| 257 |
* \param max_input_ports new max input ports |
| 258 |
* \param max_output_ports new max output ports |
| 259 |
* \param params new params |
| 260 |
*/ |
| 261 |
int (*update) (void *object, |
| 262 |
#define PW_CLIENT_NODE_UPDATE_PARAMS (1 << 0) |
| 263 |
#define PW_CLIENT_NODE_UPDATE_INFO (1 << 1) |
| 264 |
uint32_t change_mask, |
| 265 |
uint32_t n_params, |
| 266 |
const struct spa_pod **params, |
| 267 |
const struct spa_node_info *info); |
| 268 |
|
| 269 |
/** |
| 270 |
* Update a node port |
| 271 |
* |
| 272 |
* Update the information of one port of a node. |
| 273 |
* \param direction the direction of the port |
| 274 |
* \param port_id the port id to update |
| 275 |
* \param change_mask a bitfield of changed items |
| 276 |
* \param n_params number of port parameters |
| 277 |
* \param params array of port parameters |
| 278 |
* \param info port information |
| 279 |
*/ |
| 280 |
int (*port_update) (void *object, |
| 281 |
enum spa_direction direction, |
| 282 |
uint32_t port_id, |
| 283 |
#define PW_CLIENT_NODE_PORT_UPDATE_PARAMS (1 << 0) |
| 284 |
#define PW_CLIENT_NODE_PORT_UPDATE_INFO (1 << 1) |
| 285 |
uint32_t change_mask, |
| 286 |
uint32_t n_params, |
| 287 |
const struct spa_pod **params, |
| 288 |
const struct spa_port_info *info); |
| 289 |
/** |
| 290 |
* Activate or deactivate the node |
| 291 |
*/ |
| 292 |
int (*set_active) (void *object, bool active); |
| 293 |
/** |
| 294 |
* Send an event to the node |
| 295 |
* \param event the event to send |
| 296 |
*/ |
| 297 |
int (*event) (void *object, const struct spa_event *event); |
| 298 |
|
| 299 |
/** |
| 300 |
* Send allocated buffers |
| 301 |
*/ |
| 302 |
int (*port_buffers) (void *object, |
| 303 |
enum spa_direction direction, |
| 304 |
uint32_t port_id, |
| 305 |
uint32_t mix_id, |
| 306 |
uint32_t n_buffers, |
| 307 |
struct spa_buffer **buffers); |
| 308 |
}; |
| 309 |
|
| 310 |
PW_API_CLIENT_NODE_IMPL int pw_client_node_add_listener(struct pw_client_node *object, |
| 311 |
struct spa_hook *listener, |
| 312 |
const struct pw_client_node_events *events, |
| 313 |
void *data) |
| 314 |
{ |
| 315 |
return spa_api_method_r(int, -ENOTSUP, pw_client_node, (struct spa_interface*)object, |
| 316 |
add_listener, 0, listener, events, data); |
| 317 |
} |
| 318 |
PW_API_CLIENT_NODE_IMPL struct pw_node * |
| 319 |
pw_client_node_get_node(struct pw_client_node *p, uint32_t version, size_t user_data_size) |
| 320 |
{ |
| 321 |
return spa_api_method_r(struct pw_node*, NULL, pw_client_node, (struct spa_interface*)p, |
| 322 |
get_node, 0, version, user_data_size); |
| 323 |
} |
| 324 |
PW_API_CLIENT_NODE_IMPL int pw_client_node_update(struct pw_client_node *object, |
| 325 |
uint32_t change_mask, |
| 326 |
uint32_t n_params, const struct spa_pod **params, |
| 327 |
const struct spa_node_info *info) |
| 328 |
{ |
| 329 |
return spa_api_method_r(int, -ENOTSUP, pw_client_node, (struct spa_interface*)object, |
| 330 |
update, 0, change_mask, n_params, params, info); |
| 331 |
} |
| 332 |
PW_API_CLIENT_NODE_IMPL int pw_client_node_port_update(struct pw_client_node *object, |
| 333 |
enum spa_direction direction, uint32_t port_id, |
| 334 |
uint32_t change_mask, |
| 335 |
uint32_t n_params, const struct spa_pod **params, |
| 336 |
const struct spa_port_info *info) |
| 337 |
{ |
| 338 |
return spa_api_method_r(int, -ENOTSUP, pw_client_node, (struct spa_interface*)object, |
| 339 |
port_update, 0, direction, port_id, change_mask, n_params, params, info); |
| 340 |
} |
| 341 |
PW_API_CLIENT_NODE_IMPL int pw_client_node_set_active(struct pw_client_node *object, bool active) |
| 342 |
{ |
| 343 |
return spa_api_method_r(int, -ENOTSUP, pw_client_node, (struct spa_interface*)object, |
| 344 |
set_active, 0, active); |
| 345 |
} |
| 346 |
PW_API_CLIENT_NODE_IMPL int pw_client_node_event(struct pw_client_node *object, const struct spa_event *event) |
| 347 |
{ |
| 348 |
return spa_api_method_r(int, -ENOTSUP, pw_client_node, (struct spa_interface*)object, |
| 349 |
event, 0, event); |
| 350 |
} |
| 351 |
PW_API_CLIENT_NODE_IMPL int pw_client_node_port_buffers(struct pw_client_node *object, |
| 352 |
enum spa_direction direction, uint32_t port_id, |
| 353 |
uint32_t mix_id, uint32_t n_buffers, struct spa_buffer **buffers) |
| 354 |
{ |
| 355 |
return spa_api_method_r(int, -ENOTSUP, pw_client_node, (struct spa_interface*)object, |
| 356 |
port_buffers, 0, direction, port_id, mix_id, n_buffers, buffers); |
| 357 |
} |
| 358 |
|
| 359 |
/** |
| 360 |
* \} |
| 361 |
*/ |
| 362 |
|
| 363 |
#ifdef __cplusplus |
| 364 |
} /* extern "C" */ |
| 365 |
#endif |
| 366 |
|
| 367 |
#endif /* PIPEWIRE_EXT_CLIENT_NODE_H */ |