PipeWire: interfaces.h Source File

PipeWire 0.1.8

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/utils/defs.h>
28 #include <spa/param/param.h>
29 #include <spa/node/node.h>
30
31 #include <pipewire/introspect.h>
32 #include <pipewire/proxy.h>
33
34 struct pw_core_proxy;
35 struct pw_registry_proxy;
36 struct pw_module_proxy;
37 struct pw_node_proxy;
38 struct pw_factory_proxy;
39 struct pw_client_proxy;
40 struct pw_link_proxy;
41
60 #define PW_TYPE_INTERFACE__Core PW_TYPE_INTERFACE_BASE "Core"
61 #define PW_TYPE_INTERFACE__Registry PW_TYPE_INTERFACE_BASE "Registry"
62 #define PW_TYPE_INTERFACE__Module PW_TYPE_INTERFACE_BASE "Module"
63 #define PW_TYPE_INTERFACE__Node PW_TYPE_INTERFACE_BASE "Node"
64 #define PW_TYPE_INTERFACE__Client PW_TYPE_INTERFACE_BASE "Client"
65 #define PW_TYPE_INTERFACE__Link PW_TYPE_INTERFACE_BASE "Link"
66
67 #define PW_VERSION_CORE 0
68
69 #define PW_CORE_PROXY_METHOD_HELLO 0
70 #define PW_CORE_PROXY_METHOD_UPDATE_TYPES 1
71 #define PW_CORE_PROXY_METHOD_SYNC 2
72 #define PW_CORE_PROXY_METHOD_GET_REGISTRY 3
73 #define PW_CORE_PROXY_METHOD_CLIENT_UPDATE 4
74 #define PW_CORE_PROXY_METHOD_PERMISSIONS 5
75 #define PW_CORE_PROXY_METHOD_CREATE_OBJECT 6
76 #define PW_CORE_PROXY_METHOD_NUM 7
77
81 #define PW_CORE_PROXY_PERMISSIONS_DEFAULT "permissions.default"
82
88 #define PW_CORE_PROXY_PERMISSIONS_GLOBAL "permissions.global"
89
96 #define PW_CORE_PROXY_PERMISSIONS_EXISTING "permissions.existing"
97
98 #define PW_LINK_OUTPUT_NODE_ID "link.output_node.id"
99 #define PW_LINK_OUTPUT_PORT_ID "link.output_port.id"
100 #define PW_LINK_INPUT_NODE_ID "link.input_node.id"
101 #define PW_LINK_INPUT_PORT_ID "link.input_port.id"
102
111 struct pw_core_proxy_methods {
112 #define PW_VERSION_CORE_PROXY_METHODS 0
113 uint32_t version;
118 void (*hello) (void *object);
128 void (*update_types) (void *object,
129 uint32_t first_id,
130 const char **types,
131 uint32_t n_types);
141 void (*sync) (void *object, uint32_t seq);
150 void (*get_registry) (void *object, uint32_t version, uint32_t new_id);
155 void (*client_update) (void *object, const struct spa_dict *props);
168 void (*permissions) (void *object, const struct spa_dict *props);
180 void (*create_object) (void *object,
181 const char *factory_name,
182 uint32_t type,
183 uint32_t version,
184 const struct spa_dict *props,
185 uint32_t new_id);
186 };
187
188 static inline void
189 pw_core_proxy_hello(struct pw_core_proxy *core)
190 {
191 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, hello);
192 }
193
194 static inline void
195 pw_core_proxy_update_types(struct pw_core_proxy *core, uint32_t first_id, const char **types, uint32_t n_types)
196 {
197 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, update_types, first_id, types, n_types);
198 }
199
200 static inline void
201 pw_core_proxy_sync(struct pw_core_proxy *core, uint32_t seq)
202 {
203 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, sync, seq);
204 }
205
206 static inline struct pw_registry_proxy *
207 pw_core_proxy_get_registry(struct pw_core_proxy *core, uint32_t type, uint32_t version, size_t user_data_size)
208 {
209 struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
210 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, get_registry, version, pw_proxy_get_id(p));
211 return (struct pw_registry_proxy *) p;
212 }
213
214 static inline void
215 pw_core_proxy_client_update(struct pw_core_proxy *core, const struct spa_dict *props)
216 {
217 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, client_update, props);
218 }
219
220 static inline void
221 pw_core_proxy_permissions(struct pw_core_proxy *core, const struct spa_dict *props)
222 {
223 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, permissions, props);
224 }
225
226 static inline void *
227 pw_core_proxy_create_object(struct pw_core_proxy *core,
228 const char *factory_name,
229 uint32_t type,
230 uint32_t version,
231 const struct spa_dict *props,
232 size_t user_data_size)
233 {
234 struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
235 pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, create_object, factory_name,
236 type, version, props, pw_proxy_get_id(p));
237 return p;
238 }
239
240 #define PW_CORE_PROXY_EVENT_UPDATE_TYPES 0
241 #define PW_CORE_PROXY_EVENT_DONE 1
242 #define PW_CORE_PROXY_EVENT_ERROR 2
243 #define PW_CORE_PROXY_EVENT_REMOVE_ID 3
244 #define PW_CORE_PROXY_EVENT_INFO 4
245 #define PW_CORE_PROXY_EVENT_NUM 5
246
251 struct pw_core_proxy_events {
252 #define PW_VERSION_CORE_PROXY_EVENTS 0
253 uint32_t version;
263 void (*update_types) (void *object,
264 uint32_t first_id,
265 const char **types,
266 uint32_t n_types);
274 void (*done) (void *object, uint32_t seq);
287 void (*error) (void *object, uint32_t id, int res, const char *error, ...);
298 void (*remove_id) (void *object, uint32_t id);
304 void (*info) (void *object, struct pw_core_info *info);
305 };
306
307 static inline void
308 pw_core_proxy_add_listener(struct pw_core_proxy *core,
309 struct spa_hook *listener,
310 const struct pw_core_proxy_events *events,
311 void *data)
312 {
313 pw_proxy_add_proxy_listener((struct pw_proxy*)core, listener, events, data);
314 }
315
316
317 #define pw_core_resource_update_types(r,...) pw_resource_notify(r,struct pw_core_proxy_events,update_types,__VA_ARGS__)
318 #define pw_core_resource_done(r,...) pw_resource_notify(r,struct pw_core_proxy_events,done,__VA_ARGS__)
319 #define pw_core_resource_error(r,...) pw_resource_notify(r,struct pw_core_proxy_events,error,__VA_ARGS__)
320 #define pw_core_resource_remove_id(r,...) pw_resource_notify(r,struct pw_core_proxy_events,remove_id,__VA_ARGS__)
321 #define pw_core_resource_info(r,...) pw_resource_notify(r,struct pw_core_proxy_events,info,__VA_ARGS__)
322
323
324 #define PW_VERSION_REGISTRY 0
325
357 #define PW_REGISTRY_PROXY_METHOD_BIND 0
358 #define PW_REGISTRY_PROXY_METHOD_NUM 1
359
361 struct pw_registry_proxy_methods {
362 #define PW_VERSION_REGISTRY_PROXY_METHODS 0
363 uint32_t version;
376 void (*bind) (void *object, uint32_t id, uint32_t type, uint32_t version, uint32_t new_id);
377 };
378
380 static inline void *
381 pw_registry_proxy_bind(struct pw_registry_proxy *registry,
382 uint32_t id, uint32_t type, uint32_t version,
383 size_t user_data_size)
384 {
385 struct pw_proxy *reg = (struct pw_proxy*)registry;
386 struct pw_proxy *p = pw_proxy_new(reg, type, user_data_size);
387 pw_proxy_do(reg, struct pw_registry_proxy_methods, bind, id, type, version, pw_proxy_get_id(p));
388 return p;
389 }
390
391 #define PW_REGISTRY_PROXY_EVENT_GLOBAL 0
392 #define PW_REGISTRY_PROXY_EVENT_GLOBAL_REMOVE 1
393 #define PW_REGISTRY_PROXY_EVENT_NUM 2
394
396 struct pw_registry_proxy_events {
397 #define PW_VERSION_REGISTRY_PROXY_EVENTS 0
398 uint32_t version;
412 void (*global) (void *object, uint32_t id, uint32_t parent_id,
413 uint32_t permissions, uint32_t type, uint32_t version,
414 const struct spa_dict *props);
424 void (*global_remove) (void *object, uint32_t id);
425 };
426
427 static inline void
428 pw_registry_proxy_add_listener(struct pw_registry_proxy *registry,
429 struct spa_hook *listener,
430 const struct pw_registry_proxy_events *events,
431 void *data)
432 {
433 pw_proxy_add_proxy_listener((struct pw_proxy*)registry, listener, events, data);
434 }
435
436 #define pw_registry_resource_global(r,...) pw_resource_notify(r,struct pw_registry_proxy_events,global,__VA_ARGS__)
437 #define pw_registry_resource_global_remove(r,...) pw_resource_notify(r,struct pw_registry_proxy_events,global_remove,__VA_ARGS__)
438
439
440 #define PW_VERSION_MODULE 0
441
442 #define PW_MODULE_PROXY_EVENT_INFO 0
443 #define PW_MODULE_PROXY_EVENT_NUM 1
444
446 struct pw_module_proxy_events {
447 #define PW_VERSION_MODULE_PROXY_EVENTS 0
448 uint32_t version;
454 void (*info) (void *object, struct pw_module_info *info);
455 };
456
457 static inline void
458 pw_module_proxy_add_listener(struct pw_module_proxy *module,
459 struct spa_hook *listener,
460 const struct pw_module_proxy_events *events,
461 void *data)
462 {
463 pw_proxy_add_proxy_listener((struct pw_proxy*)module, listener, events, data);
464 }
465
466 #define pw_module_resource_info(r,...) pw_resource_notify(r,struct pw_module_proxy_events,info,__VA_ARGS__)
467
468 #define PW_VERSION_NODE 0
469
470 #define PW_NODE_PROXY_EVENT_INFO 0
471 #define PW_NODE_PROXY_EVENT_NUM 1
472
474 struct pw_node_proxy_events {
475 #define PW_VERSION_NODE_PROXY_EVENTS 0
476 uint32_t version;
482 void (*info) (void *object, struct pw_node_info *info);
483 };
484
485 static inline void
486 pw_node_proxy_add_listener(struct pw_node_proxy *node,
487 struct spa_hook *listener,
488 const struct pw_node_proxy_events *events,
489 void *data)
490 {
491 pw_proxy_add_proxy_listener((struct pw_proxy*)node, listener, events, data);
492 }
493
494 #define pw_node_resource_info(r,...) pw_resource_notify(r,struct pw_node_proxy_events,info,__VA_ARGS__)
495
496 #define PW_VERSION_FACTORY 0
497
498 #define PW_FACTORY_PROXY_EVENT_INFO 0
499 #define PW_FACTORY_PROXY_EVENT_NUM 1
500
502 struct pw_factory_proxy_events {
503 #define PW_VERSION_FACTORY_PROXY_EVENTS 0
504 uint32_t version;
510 void (*info) (void *object, struct pw_factory_info *info);
511 };
512
514 static inline void
515 pw_factory_proxy_add_listener(struct pw_factory_proxy *factory,
516 struct spa_hook *listener,
517 const struct pw_factory_proxy_events *events,
518 void *data)
519 {
520 pw_proxy_add_proxy_listener((struct pw_proxy*)factory, listener, events, data);
521 }
522
523 #define pw_factory_resource_info(r,...) pw_resource_notify(r,struct pw_factory_proxy_events,info,__VA_ARGS__)
524
525 #define PW_VERSION_CLIENT 0
526
527 #define PW_CLIENT_PROXY_EVENT_INFO 0
528 #define PW_CLIENT_PROXY_EVENT_NUM 1
529
531 struct pw_client_proxy_events {
532 #define PW_VERSION_CLIENT_PROXY_EVENTS 0
533 uint32_t version;
539 void (*info) (void *object, struct pw_client_info *info);
540 };
541
543 static inline void
544 pw_client_proxy_add_listener(struct pw_client_proxy *client,
545 struct spa_hook *listener,
546 const struct pw_client_proxy_events *events,
547 void *data)
548 {
549 pw_proxy_add_proxy_listener((struct pw_proxy*)client, listener, events, data);
550 }
551
552 #define pw_client_resource_info(r,...) pw_resource_notify(r,struct pw_client_proxy_events,info,__VA_ARGS__)
553
554
555 #define PW_VERSION_LINK 0
556
557 #define PW_LINK_PROXY_EVENT_INFO 0
558 #define PW_LINK_PROXY_EVENT_NUM 1
559
561 struct pw_link_proxy_events {
562 #define PW_VERSION_LINK_PROXY_EVENTS 0
563 uint32_t version;
569 void (*info) (void *object, struct pw_link_info *info);
570 };
571
573 static inline void
574 pw_link_proxy_add_listener(struct pw_link_proxy *link,
575 struct spa_hook *listener,
576 const struct pw_link_proxy_events *events,
577 void *data)
578 {
579 pw_proxy_add_proxy_listener((struct pw_proxy*)link, listener, events, data);
580 }
581
582 #define pw_link_resource_info(r,...) pw_resource_notify(r,struct pw_link_proxy_events,info,__VA_ARGS__)
583
584 #ifdef __cplusplus
585 } /* extern "C" */
586 #endif
587
588 #endif /* __PIPEWIRE_INTERFACES_H__ */
pw_core_proxy_events::update_types
void(* update_types)(void *object, uint32_t first_id, const char **types, uint32_t n_types)
Update the type map.
Definition: interfaces.h:263
pw_module_proxy_events::version
uint32_t version
Definition: interfaces.h:448
pw_client_proxy_events::version
uint32_t version
Definition: interfaces.h:533
introspect.h
pw_registry_proxy_methods::bind
void(* bind)(void *object, uint32_t id, uint32_t type, uint32_t version, uint32_t new_id)
Bind to a global object.
Definition: interfaces.h:376
pw_registry_proxy_events::global
void(* global)(void *object, uint32_t id, uint32_t parent_id, uint32_t permissions, uint32_t type, uint32_t version, const struct spa_dict *props)
Notify of a new global object.
Definition: interfaces.h:412
pw_core_proxy_methods::client_update
void(* client_update)(void *object, const struct spa_dict *props)
Update the client properties.
Definition: interfaces.h:155
pw_module_proxy_events
Module events.
Definition: interfaces.h:446
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:150
pw_module_proxy_events::info
void(* info)(void *object, struct pw_module_info *info)
Notify module info.
Definition: interfaces.h:454
pw_link_proxy_events::version
uint32_t version
Definition: interfaces.h:563
pw_core_info
The core information.
Definition: introspect.h:76
pw_core_proxy_methods::hello
void(* hello)(void *object)
Start a conversation with the server.
Definition: interfaces.h:118
pw_core_proxy_methods::permissions
void(* permissions)(void *object, const struct spa_dict *props)
Manage the permissions of the global objects.
Definition: interfaces.h:168
pw_registry_proxy_events::version
uint32_t version
Definition: interfaces.h:398
pw_factory_proxy_events
Factory events.
Definition: interfaces.h:502
pw_proxy
Represents an object on the client side.
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:474
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_core_proxy_events::remove_id
void(* remove_id)(void *object, uint32_t id)
Remove an object ID.
Definition: interfaces.h:298
pw_registry_proxy_methods::version
uint32_t version
Definition: interfaces.h:363
pw_core_proxy_events::error
void(* error)(void *object, uint32_t id, int res, const char *error,...)
Fatal error event.
Definition: interfaces.h:287
pw_client_info
The client information.
Definition: introspect.h:125
pw_link_proxy_events
Link events.
Definition: interfaces.h:561
pw_factory_proxy_events::info
void(* info)(void *object, struct pw_factory_info *info)
Notify factory info.
Definition: interfaces.h:510
pw_client_proxy_events::info
void(* info)(void *object, struct pw_client_info *info)
Notify client info.
Definition: interfaces.h:539
pw_node_proxy_events::version
uint32_t version
Definition: interfaces.h:476
pw_core_proxy_events::done
void(* done)(void *object, uint32_t seq)
Emit a done event.
Definition: interfaces.h:274
pw_registry_proxy_events::global_remove
void(* global_remove)(void *object, uint32_t id)
Notify of a global object removal.
Definition: interfaces.h:424
pw_core_proxy_events
Core events
Definition: interfaces.h:251
pw_factory_proxy_events::version
uint32_t version
Definition: interfaces.h:504
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:180
pw_module_info
The module information.
Definition: introspect.h:103
proxy.h
pw_client_proxy_events
Client events.
Definition: interfaces.h:531
pw_core_proxy_methods::version
uint32_t version
Definition: interfaces.h:113
pw_proxy::pw_proxy_new
struct pw_proxy * pw_proxy_new(struct pw_proxy *factory, uint32_t type, size_t user_data_size)
Create a proxy object with a given id and type.
Definition: proxy.c:46
pw_link_proxy_events::info
void(* info)(void *object, struct pw_link_info *info)
Notify link info.
Definition: interfaces.h:569
pw_core_proxy_events::version
uint32_t version
Definition: interfaces.h:253
pw_registry_proxy_methods
Registry methods.
Definition: interfaces.h:361
pw_core_proxy_events::info
void(* info)(void *object, struct pw_core_info *info)
Notify new core info.
Definition: interfaces.h:304
pw_node_info
The node information.
Definition: introspect.h:142
pw_core_proxy_methods::update_types
void(* update_types)(void *object, uint32_t first_id, const char **types, uint32_t n_types)
Update the type map.
Definition: interfaces.h:128
pw_node_proxy_events::info
void(* info)(void *object, struct pw_node_info *info)
Notify node info.
Definition: interfaces.h:482
pw_core_proxy_methods
Core methods.
Definition: interfaces.h:111
pw_registry_proxy_events
Registry events.
Definition: interfaces.h:396
pw_core_proxy_methods::sync
void(* sync)(void *object, uint32_t seq)
Do server roundtrip.
Definition: interfaces.h:141