PipeWire: interfaces.h Source File

PipeWire 0.1.5.1

interfaces.h
Go to the documentation of this file.
1 /* PipeWire
2 * Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef __PIPEWIRE_INTERFACES_H__
21 #define __PIPEWIRE_INTERFACES_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <spa/defs.h>
28 #include <spa/props.h>
29 #include <spa/format.h>
30 #include <spa/param-alloc.h>
31 #include <spa/node.h>
32
33 #include <pipewire/introspect.h>
34 #include <pipewire/proxy.h>
35
36 struct pw_core_proxy;
37 struct pw_registry_proxy;
38 struct pw_module_proxy;
39 struct pw_node_proxy;
40 struct pw_factory_proxy;
41 struct pw_client_proxy;
42 struct pw_link_proxy;
43
62 #define PW_TYPE_INTERFACE__Core PW_TYPE_INTERFACE_BASE "Core"
63 #define PW_TYPE_INTERFACE__Registry PW_TYPE_INTERFACE_BASE "Registry"
64 #define PW_TYPE_INTERFACE__Module PW_TYPE_INTERFACE_BASE "Module"
65 #define PW_TYPE_INTERFACE__Node PW_TYPE_INTERFACE_BASE "Node"
66 #define PW_TYPE_INTERFACE__Client PW_TYPE_INTERFACE_BASE "Client"
67 #define PW_TYPE_INTERFACE__Link PW_TYPE_INTERFACE_BASE "Link"
68
69 #define PW_VERSION_CORE 0
70
71 #define PW_CORE_PROXY_METHOD_UPDATE_TYPES 0
72 #define PW_CORE_PROXY_METHOD_SYNC 1
73 #define PW_CORE_PROXY_METHOD_GET_REGISTRY 2
74 #define PW_CORE_PROXY_METHOD_CLIENT_UPDATE 3
75 #define PW_CORE_PROXY_METHOD_CREATE_OBJECT 4
76 #define PW_CORE_PROXY_METHOD_CREATE_LINK 5
77 #define PW_CORE_PROXY_METHOD_NUM 6
78
87 struct pw_core_proxy_methods {
88 #define PW_VERSION_CORE_PROXY_METHODS 0
89 uint32_t version;
99 void (*update_types) (void *object,
100 uint32_t first_id,
101 uint32_t n_types,
102 const char **types);
112 void (*sync) (void *object, uint32_t seq);
121 void (*get_registry) (void *object, uint32_t version, uint32_t new_id);
126 void (*client_update) (void *object, const struct spa_dict *props);
138 void (*create_object) (void *object,
139 const char *factory_name,
140 uint32_t type,
141 uint32_t version,
142 const struct spa_dict *props,
143 uint32_t new_id);
155 void (*create_link) (void *object,
156 uint32_t output_node_id,
157 uint32_t output_port_id,
158 uint32_t input_node_id,
159 uint32_t input_port_id,
160 const struct spa_format *filter,
161 const struct spa_dict *props,
162 uint32_t new_id);
163 };
164
165 static inline void
166 pw_core_proxy_update_types(struct pw_core_proxy *core, uint32_t first_id, uint32_t n_types, const char **types)
167 {
168 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, update_types, first_id, n_types, types);
169 }
170
171 static inline void
172 pw_core_proxy_sync(struct pw_core_proxy *core, uint32_t seq)
173 {
174 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, sync, seq);
175 }
176
177 static inline struct pw_registry_proxy *
178 pw_core_proxy_get_registry(struct pw_core_proxy *core, uint32_t type, uint32_t version, size_t user_data_size)
179 {
180 struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
181 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, get_registry, version, pw_proxy_get_id(p));
182 return (struct pw_registry_proxy *) p;
183 }
184
185 static inline void
186 pw_core_proxy_client_update(struct pw_core_proxy *core, const struct spa_dict *props)
187 {
188 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, client_update, props);
189 }
190
191 static inline void *
192 pw_core_proxy_create_object(struct pw_core_proxy *core,
193 const char *factory_name,
194 uint32_t type,
195 uint32_t version,
196 const struct spa_dict *props,
197 size_t user_data_size)
198 {
199 struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
200 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, create_object, factory_name,
201 type, version, props, pw_proxy_get_id(p));
202 return p;
203 }
204
205 static inline struct pw_link_proxy *
206 pw_core_proxy_create_link(struct pw_core_proxy *core,
207 uint32_t type,
208 uint32_t output_node_id,
209 uint32_t output_port_id,
210 uint32_t input_node_id,
211 uint32_t input_port_id,
212 const struct spa_format *filter,
213 const struct spa_dict *prop,
214 size_t user_data_size)
215 {
216 struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
217 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, create_link, output_node_id, output_port_id,
218 input_node_id, input_port_id, filter, prop, pw_proxy_get_id(p));
219 return (struct pw_link_proxy*) p;
220 }
221
222
223 #define PW_CORE_PROXY_EVENT_UPDATE_TYPES 0
224 #define PW_CORE_PROXY_EVENT_DONE 1
225 #define PW_CORE_PROXY_EVENT_ERROR 2
226 #define PW_CORE_PROXY_EVENT_REMOVE_ID 3
227 #define PW_CORE_PROXY_EVENT_INFO 4
228 #define PW_CORE_PROXY_EVENT_NUM 5
229
234 struct pw_core_proxy_events {
235 #define PW_VERSION_CORE_PROXY_EVENTS 0
236 uint32_t version;
246 void (*update_types) (void *object,
247 uint32_t first_id,
248 uint32_t n_types,
249 const char **types);
257 void (*done) (void *object, uint32_t seq);
270 void (*error) (void *object, uint32_t id, int res, const char *error, ...);
281 void (*remove_id) (void *object, uint32_t id);
287 void (*info) (void *object, struct pw_core_info *info);
288 };
289
290 static inline void
291 pw_core_proxy_add_listener(struct pw_core_proxy *core,
292 struct spa_hook *listener,
293 const struct pw_core_proxy_events *events,
294 void *data)
295 {
296 pw_proxy_add_proxy_listener((struct pw_proxy*)core, listener, events, data);
297 }
298
299
300 #define pw_core_resource_update_types(r,...) pw_resource_notify(r,struct pw_core_proxy_events,update_types,__VA_ARGS__)
301 #define pw_core_resource_done(r,...) pw_resource_notify(r,struct pw_core_proxy_events,done,__VA_ARGS__)
302 #define pw_core_resource_error(r,...) pw_resource_notify(r,struct pw_core_proxy_events,error,__VA_ARGS__)
303 #define pw_core_resource_remove_id(r,...) pw_resource_notify(r,struct pw_core_proxy_events,remove_id,__VA_ARGS__)
304 #define pw_core_resource_info(r,...) pw_resource_notify(r,struct pw_core_proxy_events,info,__VA_ARGS__)
305
306
307 #define PW_VERSION_REGISTRY 0
308
335 #define PW_REGISTRY_PROXY_METHOD_BIND 0
336 #define PW_REGISTRY_PROXY_METHOD_NUM 1
337
339 struct pw_registry_proxy_methods {
340 #define PW_VERSION_REGISTRY_PROXY_METHODS 0
341 uint32_t version;
354 void (*bind) (void *object, uint32_t id, uint32_t type, uint32_t version, uint32_t new_id);
355 };
356
358 static inline void *
359 pw_registry_proxy_bind(struct pw_registry_proxy *registry,
360 uint32_t id, uint32_t type, uint32_t version,
361 size_t user_data_size)
362 {
363 struct pw_proxy *reg = (struct pw_proxy*)registry;
364 struct pw_proxy *p = pw_proxy_new(reg, type, user_data_size);
365 pw_proxy_do(reg, struct pw_registry_proxy_methods, bind, id, type, version, pw_proxy_get_id(p));
366 return p;
367 }
368
369 #define PW_REGISTRY_PROXY_EVENT_GLOBAL 0
370 #define PW_REGISTRY_PROXY_EVENT_GLOBAL_REMOVE 1
371 #define PW_REGISTRY_PROXY_EVENT_NUM 2
372
374 struct pw_registry_proxy_events {
375 #define PW_VERSION_REGISTRY_PROXY_EVENTS 0
376 uint32_t version;
389 void (*global) (void *object, uint32_t id, uint32_t parent_id,
390 uint32_t permissions, uint32_t type, uint32_t version);
400 void (*global_remove) (void *object, uint32_t id);
401 };
402
403 static inline void
404 pw_registry_proxy_add_listener(struct pw_registry_proxy *registry,
405 struct spa_hook *listener,
406 const struct pw_registry_proxy_events *events,
407 void *data)
408 {
409 pw_proxy_add_proxy_listener((struct pw_proxy*)registry, listener, events, data);
410 }
411
412 #define pw_registry_resource_global(r,...) pw_resource_notify(r,struct pw_registry_proxy_events,global,__VA_ARGS__)
413 #define pw_registry_resource_global_remove(r,...) pw_resource_notify(r,struct pw_registry_proxy_events,global_remove,__VA_ARGS__)
414
415
416 #define PW_VERSION_MODULE 0
417
418 #define PW_MODULE_PROXY_EVENT_INFO 0
419 #define PW_MODULE_PROXY_EVENT_NUM 1
420
422 struct pw_module_proxy_events {
423 #define PW_VERSION_MODULE_PROXY_EVENTS 0
424 uint32_t version;
430 void (*info) (void *object, struct pw_module_info *info);
431 };
432
433 static inline void
434 pw_module_proxy_add_listener(struct pw_module_proxy *module,
435 struct spa_hook *listener,
436 const struct pw_module_proxy_events *events,
437 void *data)
438 {
439 pw_proxy_add_proxy_listener((struct pw_proxy*)module, listener, events, data);
440 }
441
442 #define pw_module_resource_info(r,...) pw_resource_notify(r,struct pw_module_proxy_events,info,__VA_ARGS__)
443
444 #define PW_VERSION_NODE 0
445
446 #define PW_NODE_PROXY_EVENT_INFO 0
447 #define PW_NODE_PROXY_EVENT_NUM 1
448
450 struct pw_node_proxy_events {
451 #define PW_VERSION_NODE_PROXY_EVENTS 0
452 uint32_t version;
458 void (*info) (void *object, struct pw_node_info *info);
459 };
460
461 static inline void
462 pw_node_proxy_add_listener(struct pw_node_proxy *node,
463 struct spa_hook *listener,
464 const struct pw_node_proxy_events *events,
465 void *data)
466 {
467 pw_proxy_add_proxy_listener((struct pw_proxy*)node, listener, events, data);
468 }
469
470 #define pw_node_resource_info(r,...) pw_resource_notify(r,struct pw_node_proxy_events,info,__VA_ARGS__)
471
472 #define PW_VERSION_FACTORY 0
473
474 #define PW_FACTORY_PROXY_EVENT_INFO 0
475 #define PW_FACTORY_PROXY_EVENT_NUM 1
476
478 struct pw_factory_proxy_events {
479 #define PW_VERSION_FACTORY_PROXY_EVENTS 0
480 uint32_t version;
486 void (*info) (void *object, struct pw_factory_info *info);
487 };
488
490 static inline void
491 pw_factory_proxy_add_listener(struct pw_factory_proxy *factory,
492 struct spa_hook *listener,
493 const struct pw_factory_proxy_events *events,
494 void *data)
495 {
496 pw_proxy_add_proxy_listener((struct pw_proxy*)factory, listener, events, data);
497 }
498
499 #define pw_factory_resource_info(r,...) pw_resource_notify(r,struct pw_factory_proxy_events,info,__VA_ARGS__)
500
501 #define PW_VERSION_CLIENT 0
502
503 #define PW_CLIENT_PROXY_EVENT_INFO 0
504 #define PW_CLIENT_PROXY_EVENT_NUM 1
505
507 struct pw_client_proxy_events {
508 #define PW_VERSION_CLIENT_PROXY_EVENTS 0
509 uint32_t version;
515 void (*info) (void *object, struct pw_client_info *info);
516 };
517
519 static inline void
520 pw_client_proxy_add_listener(struct pw_client_proxy *client,
521 struct spa_hook *listener,
522 const struct pw_client_proxy_events *events,
523 void *data)
524 {
525 pw_proxy_add_proxy_listener((struct pw_proxy*)client, listener, events, data);
526 }
527
528 #define pw_client_resource_info(r,...) pw_resource_notify(r,struct pw_client_proxy_events,info,__VA_ARGS__)
529
530
531 #define PW_VERSION_LINK 0
532
533 #define PW_LINK_PROXY_EVENT_INFO 0
534 #define PW_LINK_PROXY_EVENT_NUM 1
535
537 struct pw_link_proxy_events {
538 #define PW_VERSION_LINK_PROXY_EVENTS 0
539 uint32_t version;
545 void (*info) (void *object, struct pw_link_info *info);
546 };
547
549 static inline void
550 pw_link_proxy_add_listener(struct pw_link_proxy *link,
551 struct spa_hook *listener,
552 const struct pw_link_proxy_events *events,
553 void *data)
554 {
555 pw_proxy_add_proxy_listener((struct pw_proxy*)link, listener, events, data);
556 }
557
558 #define pw_link_resource_info(r,...) pw_resource_notify(r,struct pw_link_proxy_events,info,__VA_ARGS__)
559
560 #ifdef __cplusplus
561 } /* extern "C" */
562 #endif
563
564 #endif /* __PIPEWIRE_INTERFACES_H__ */
pw_module_proxy_events::version
uint32_t version
Definition: interfaces.h:424
pw_client_proxy_events::version
uint32_t version
Definition: interfaces.h:509
introspect.h
pw_proxy_new
struct pw_proxy * pw_proxy_new(struct pw_proxy *factory, uint32_t type, size_t user_data_size)
Make a new proxy object.
pw_core_proxy_methods::client_update
void(* client_update)(void *object, const struct spa_dict *props)
Update the client properties.
Definition: interfaces.h:126
pw_module_proxy_events
Module events.
Definition: interfaces.h:422
pw_core_proxy_methods::get_registry
void(* get_registry)(void *object, uint32_t version, uint32_t new_id)
Get the registry object.
Definition: interfaces.h:121
pw_module_proxy_events::info
void(* info)(void *object, struct pw_module_info *info)
Notify module info.
Definition: interfaces.h:430
pw_link_proxy_events::version
uint32_t version
Definition: interfaces.h:539
pw_core_info
The core information.
Definition: introspect.h:76
pw_registry_proxy_events::version
uint32_t version
Definition: interfaces.h:376
pw_factory_proxy_events
Factory events.
Definition: interfaces.h:478
pw_proxy
Represents an object on the client side.
pw_core_proxy_methods::create_link
void(* create_link)(void *object, uint32_t output_node_id, uint32_t output_port_id, uint32_t input_node_id, uint32_t input_port_id, const struct spa_format *filter, const struct spa_dict *props, uint32_t new_id)
Create a new link between two node ports.
Definition: interfaces.h:155
pw_proxy_get_id
uint32_t pw_proxy_get_id(struct pw_proxy *proxy)
Get the local id of the proxy.
Definition: proxy.c:83
pw_node_proxy_events
Node events.
Definition: interfaces.h:450
pw_proxy_do
#define pw_proxy_do(p, type, method,...)
Definition: proxy.h:149
pw_proxy_add_proxy_listener
void pw_proxy_add_proxy_listener(struct pw_proxy *proxy, struct spa_hook *listener, const void *events, void *data)
Add a listener for the events received from the remote resource.
Definition: proxy.c:101
pw_registry_proxy_methods::version
uint32_t version
Definition: interfaces.h:341
pw_core_proxy_events::error
void(* error)(void *object, uint32_t id, int res, const char *error,...)
Fatal error event.
Definition: interfaces.h:270
pw_client_info
The client information.
Definition: introspect.h:125
pw_link_proxy_events
Link events.
Definition: interfaces.h:537
pw_factory_proxy_events::info
void(* info)(void *object, struct pw_factory_info *info)
Notify factory info.
Definition: interfaces.h:486
pw_client_proxy_events::info
void(* info)(void *object, struct pw_client_info *info)
Notify client info.
Definition: interfaces.h:515
pw_node_proxy_events::version
uint32_t version
Definition: interfaces.h:452
pw_core_proxy_events
Core events.
Definition: interfaces.h:234
pw_factory_proxy_events::version
uint32_t version
Definition: interfaces.h:480
pw_link_info
The link information.
Definition: introspect.h:192
pw_factory_info
The factory information.
Definition: introspect.h:174
pw_core_proxy_methods::create_object
void(* create_object)(void *object, const char *factory_name, uint32_t type, uint32_t version, const struct spa_dict *props, uint32_t new_id)
Create a new object on the PipeWire server from a factory.
Definition: interfaces.h:138
pw_module_info
The module information.
Definition: introspect.h:103
proxy.h
pw_client_proxy_events
Client events.
Definition: interfaces.h:507
pw_core_proxy_methods::version
uint32_t version
Definition: interfaces.h:89
pw_link_proxy_events::info
void(* info)(void *object, struct pw_link_info *info)
Notify link info.
Definition: interfaces.h:545
pw_core_proxy_events::version
uint32_t version
Definition: interfaces.h:236
pw_registry_proxy_methods
Registry methods.
Definition: interfaces.h:339
pw_core_proxy_events::info
void(* info)(void *object, struct pw_core_info *info)
Notify new core info.
Definition: interfaces.h:287
pw_core_proxy_methods::update_types
void(* update_types)(void *object, uint32_t first_id, uint32_t n_types, const char **types)
Update the type map.
Definition: interfaces.h:99
pw_node_info
The node information.
Definition: introspect.h:142
pw_node_proxy_events::info
void(* info)(void *object, struct pw_node_info *info)
Notify node info.
Definition: interfaces.h:458
pw_core_proxy_methods
Core methods.
Definition: interfaces.h:87
pw_registry_proxy_events
Registry events.
Definition: interfaces.h:374
pw_core_proxy_methods::sync
void(* sync)(void *object, uint32_t seq)
Do server roundtrip.
Definition: interfaces.h:112