PipeWire  0.1.7
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_UPDATE_TYPES 0
70 #define PW_CORE_PROXY_METHOD_SYNC 1
71 #define PW_CORE_PROXY_METHOD_GET_REGISTRY 2
72 #define PW_CORE_PROXY_METHOD_CLIENT_UPDATE 3
73 #define PW_CORE_PROXY_METHOD_CREATE_OBJECT 4
74 #define PW_CORE_PROXY_METHOD_CREATE_LINK 5
75 #define PW_CORE_PROXY_METHOD_NUM 6
76 
86 #define PW_VERSION_CORE_PROXY_METHODS 0
87  uint32_t version;
97  void (*update_types) (void *object,
98  uint32_t first_id,
99  const char **types,
100  uint32_t n_types);
110  void (*sync) (void *object, uint32_t seq);
119  void (*get_registry) (void *object, uint32_t version, uint32_t new_id);
124  void (*client_update) (void *object, const struct spa_dict *props);
136  void (*create_object) (void *object,
137  const char *factory_name,
138  uint32_t type,
139  uint32_t version,
140  const struct spa_dict *props,
141  uint32_t new_id);
153  void (*create_link) (void *object,
154  uint32_t output_node_id,
155  uint32_t output_port_id,
156  uint32_t input_node_id,
157  uint32_t input_port_id,
158  const struct spa_pod *filter,
159  const struct spa_dict *props,
160  uint32_t new_id);
161 };
162 
163 static inline void
164 pw_core_proxy_update_types(struct pw_core_proxy *core, uint32_t first_id, const char **types, uint32_t n_types)
165 {
166  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, update_types, first_id, types, n_types);
167 }
168 
169 static inline void
170 pw_core_proxy_sync(struct pw_core_proxy *core, uint32_t seq)
171 {
172  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, sync, seq);
173 }
174 
175 static inline struct pw_registry_proxy *
176 pw_core_proxy_get_registry(struct pw_core_proxy *core, uint32_t type, uint32_t version, size_t user_data_size)
177 {
178  struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
179  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, get_registry, version, pw_proxy_get_id(p));
180  return (struct pw_registry_proxy *) p;
181 }
182 
183 static inline void
184 pw_core_proxy_client_update(struct pw_core_proxy *core, const struct spa_dict *props)
185 {
186  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, client_update, props);
187 }
188 
189 static inline void *
190 pw_core_proxy_create_object(struct pw_core_proxy *core,
191  const char *factory_name,
192  uint32_t type,
193  uint32_t version,
194  const struct spa_dict *props,
195  size_t user_data_size)
196 {
197  struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
198  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, create_object, factory_name,
199  type, version, props, pw_proxy_get_id(p));
200  return p;
201 }
202 
203 static inline struct pw_link_proxy *
204 pw_core_proxy_create_link(struct pw_core_proxy *core,
205  uint32_t type,
206  uint32_t output_node_id,
207  uint32_t output_port_id,
208  uint32_t input_node_id,
209  uint32_t input_port_id,
210  const struct spa_pod *filter,
211  const struct spa_dict *prop,
212  size_t user_data_size)
213 {
214  struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
215  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, create_link, output_node_id, output_port_id,
216  input_node_id, input_port_id, filter, prop, pw_proxy_get_id(p));
217  return (struct pw_link_proxy*) p;
218 }
219 
220 
221 #define PW_CORE_PROXY_EVENT_UPDATE_TYPES 0
222 #define PW_CORE_PROXY_EVENT_DONE 1
223 #define PW_CORE_PROXY_EVENT_ERROR 2
224 #define PW_CORE_PROXY_EVENT_REMOVE_ID 3
225 #define PW_CORE_PROXY_EVENT_INFO 4
226 #define PW_CORE_PROXY_EVENT_NUM 5
227 
233 #define PW_VERSION_CORE_PROXY_EVENTS 0
234  uint32_t version;
244  void (*update_types) (void *object,
245  uint32_t first_id,
246  const char **types,
247  uint32_t n_types);
255  void (*done) (void *object, uint32_t seq);
268  void (*error) (void *object, uint32_t id, int res, const char *error, ...);
279  void (*remove_id) (void *object, uint32_t id);
285  void (*info) (void *object, struct pw_core_info *info);
286 };
287 
288 static inline void
289 pw_core_proxy_add_listener(struct pw_core_proxy *core,
290  struct spa_hook *listener,
291  const struct pw_core_proxy_events *events,
292  void *data)
293 {
294  pw_proxy_add_proxy_listener((struct pw_proxy*)core, listener, events, data);
295 }
296 
297 
298 #define pw_core_resource_update_types(r,...) pw_resource_notify(r,struct pw_core_proxy_events,update_types,__VA_ARGS__)
299 #define pw_core_resource_done(r,...) pw_resource_notify(r,struct pw_core_proxy_events,done,__VA_ARGS__)
300 #define pw_core_resource_error(r,...) pw_resource_notify(r,struct pw_core_proxy_events,error,__VA_ARGS__)
301 #define pw_core_resource_remove_id(r,...) pw_resource_notify(r,struct pw_core_proxy_events,remove_id,__VA_ARGS__)
302 #define pw_core_resource_info(r,...) pw_resource_notify(r,struct pw_core_proxy_events,info,__VA_ARGS__)
303 
304 
305 #define PW_VERSION_REGISTRY 0
306 
333 #define PW_REGISTRY_PROXY_METHOD_BIND 0
334 #define PW_REGISTRY_PROXY_METHOD_NUM 1
335 
338 #define PW_VERSION_REGISTRY_PROXY_METHODS 0
339  uint32_t version;
352  void (*bind) (void *object, uint32_t id, uint32_t type, uint32_t version, uint32_t new_id);
353 };
354 
356 static inline void *
357 pw_registry_proxy_bind(struct pw_registry_proxy *registry,
358  uint32_t id, uint32_t type, uint32_t version,
359  size_t user_data_size)
360 {
361  struct pw_proxy *reg = (struct pw_proxy*)registry;
362  struct pw_proxy *p = pw_proxy_new(reg, type, user_data_size);
363  pw_proxy_do(reg, struct pw_registry_proxy_methods, bind, id, type, version, pw_proxy_get_id(p));
364  return p;
365 }
366 
367 #define PW_REGISTRY_PROXY_EVENT_GLOBAL 0
368 #define PW_REGISTRY_PROXY_EVENT_GLOBAL_REMOVE 1
369 #define PW_REGISTRY_PROXY_EVENT_NUM 2
370 
373 #define PW_VERSION_REGISTRY_PROXY_EVENTS 0
374  uint32_t version;
387  void (*global) (void *object, uint32_t id, uint32_t parent_id,
388  uint32_t permissions, uint32_t type, uint32_t version);
398  void (*global_remove) (void *object, uint32_t id);
399 };
400 
401 static inline void
402 pw_registry_proxy_add_listener(struct pw_registry_proxy *registry,
403  struct spa_hook *listener,
404  const struct pw_registry_proxy_events *events,
405  void *data)
406 {
407  pw_proxy_add_proxy_listener((struct pw_proxy*)registry, listener, events, data);
408 }
409 
410 #define pw_registry_resource_global(r,...) pw_resource_notify(r,struct pw_registry_proxy_events,global,__VA_ARGS__)
411 #define pw_registry_resource_global_remove(r,...) pw_resource_notify(r,struct pw_registry_proxy_events,global_remove,__VA_ARGS__)
412 
413 
414 #define PW_VERSION_MODULE 0
415 
416 #define PW_MODULE_PROXY_EVENT_INFO 0
417 #define PW_MODULE_PROXY_EVENT_NUM 1
418 
421 #define PW_VERSION_MODULE_PROXY_EVENTS 0
422  uint32_t version;
428  void (*info) (void *object, struct pw_module_info *info);
429 };
430 
431 static inline void
432 pw_module_proxy_add_listener(struct pw_module_proxy *module,
433  struct spa_hook *listener,
434  const struct pw_module_proxy_events *events,
435  void *data)
436 {
437  pw_proxy_add_proxy_listener((struct pw_proxy*)module, listener, events, data);
438 }
439 
440 #define pw_module_resource_info(r,...) pw_resource_notify(r,struct pw_module_proxy_events,info,__VA_ARGS__)
441 
442 #define PW_VERSION_NODE 0
443 
444 #define PW_NODE_PROXY_EVENT_INFO 0
445 #define PW_NODE_PROXY_EVENT_NUM 1
446 
449 #define PW_VERSION_NODE_PROXY_EVENTS 0
450  uint32_t version;
456  void (*info) (void *object, struct pw_node_info *info);
457 };
458 
459 static inline void
460 pw_node_proxy_add_listener(struct pw_node_proxy *node,
461  struct spa_hook *listener,
462  const struct pw_node_proxy_events *events,
463  void *data)
464 {
465  pw_proxy_add_proxy_listener((struct pw_proxy*)node, listener, events, data);
466 }
467 
468 #define pw_node_resource_info(r,...) pw_resource_notify(r,struct pw_node_proxy_events,info,__VA_ARGS__)
469 
470 #define PW_VERSION_FACTORY 0
471 
472 #define PW_FACTORY_PROXY_EVENT_INFO 0
473 #define PW_FACTORY_PROXY_EVENT_NUM 1
474 
477 #define PW_VERSION_FACTORY_PROXY_EVENTS 0
478  uint32_t version;
484  void (*info) (void *object, struct pw_factory_info *info);
485 };
486 
488 static inline void
489 pw_factory_proxy_add_listener(struct pw_factory_proxy *factory,
490  struct spa_hook *listener,
491  const struct pw_factory_proxy_events *events,
492  void *data)
493 {
494  pw_proxy_add_proxy_listener((struct pw_proxy*)factory, listener, events, data);
495 }
496 
497 #define pw_factory_resource_info(r,...) pw_resource_notify(r,struct pw_factory_proxy_events,info,__VA_ARGS__)
498 
499 #define PW_VERSION_CLIENT 0
500 
501 #define PW_CLIENT_PROXY_EVENT_INFO 0
502 #define PW_CLIENT_PROXY_EVENT_NUM 1
503 
506 #define PW_VERSION_CLIENT_PROXY_EVENTS 0
507  uint32_t version;
513  void (*info) (void *object, struct pw_client_info *info);
514 };
515 
517 static inline void
518 pw_client_proxy_add_listener(struct pw_client_proxy *client,
519  struct spa_hook *listener,
520  const struct pw_client_proxy_events *events,
521  void *data)
522 {
523  pw_proxy_add_proxy_listener((struct pw_proxy*)client, listener, events, data);
524 }
525 
526 #define pw_client_resource_info(r,...) pw_resource_notify(r,struct pw_client_proxy_events,info,__VA_ARGS__)
527 
528 
529 #define PW_VERSION_LINK 0
530 
531 #define PW_LINK_PROXY_EVENT_INFO 0
532 #define PW_LINK_PROXY_EVENT_NUM 1
533 
536 #define PW_VERSION_LINK_PROXY_EVENTS 0
537  uint32_t version;
543  void (*info) (void *object, struct pw_link_info *info);
544 };
545 
547 static inline void
548 pw_link_proxy_add_listener(struct pw_link_proxy *link,
549  struct spa_hook *listener,
550  const struct pw_link_proxy_events *events,
551  void *data)
552 {
553  pw_proxy_add_proxy_listener((struct pw_proxy*)link, listener, events, data);
554 }
555 
556 #define pw_link_resource_info(r,...) pw_resource_notify(r,struct pw_link_proxy_events,info,__VA_ARGS__)
557 
558 #ifdef __cplusplus
559 } /* extern "C" */
560 #endif
561 
562 #endif /* __PIPEWIRE_INTERFACES_H__ */
uint32_t version
Definition: interfaces.h:422
uint32_t version
Definition: interfaces.h:507
struct pw_proxy * pw_proxy_new(struct pw_proxy *factory, uint32_t type, size_t user_data_size)
Make a new proxy object.
void(* client_update)(void *object, const struct spa_dict *props)
Update the client properties.
Definition: interfaces.h:124
Module events.
Definition: interfaces.h:420
void(* get_registry)(void *object, uint32_t version, uint32_t new_id)
Get the registry object.
Definition: interfaces.h:119
void(* info)(void *object, struct pw_module_info *info)
Notify module info.
Definition: interfaces.h:428
The core information.
Definition: introspect.h:76
uint32_t version
Definition: interfaces.h:374
Factory events.
Definition: interfaces.h:476
Represents an object on the client side.
uint32_t pw_proxy_get_id(struct pw_proxy *proxy)
Get the local id of the proxy.
Definition: proxy.c:83
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_pod *filter, const struct spa_dict *props, uint32_t new_id)
Create a new link between two node ports.
Definition: interfaces.h:153
Node events.
Definition: interfaces.h:448
#define pw_proxy_do(p, type, method,...)
Definition: proxy.h:149
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
uint32_t version
Definition: interfaces.h:339
void(* error)(void *object, uint32_t id, int res, const char *error,...)
Fatal error event.
Definition: interfaces.h:268
The client information.
Definition: introspect.h:125
void(* info)(void *object, struct pw_factory_info *info)
Notify factory info.
Definition: interfaces.h:484
void(* info)(void *object, struct pw_client_info *info)
Notify client info.
Definition: interfaces.h:513
uint32_t version
Definition: interfaces.h:450
Core events.
Definition: interfaces.h:232
uint32_t version
Definition: interfaces.h:478
The factory information.
Definition: introspect.h:174
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:136
The module information.
Definition: introspect.h:103
Client events.
Definition: interfaces.h:505
uint32_t version
Definition: interfaces.h:87
uint32_t version
Definition: interfaces.h:234
Registry methods.
Definition: interfaces.h:337
void(* info)(void *object, struct pw_core_info *info)
Notify new core info.
Definition: interfaces.h:285
The node information.
Definition: introspect.h:142
void(* update_types)(void *object, uint32_t first_id, const char **types, uint32_t n_types)
Update the type map.
Definition: interfaces.h:97
void(* info)(void *object, struct pw_node_info *info)
Notify node info.
Definition: interfaces.h:456
Core methods.
Definition: interfaces.h:85
Registry events.
Definition: interfaces.h:372
void(* sync)(void *object, uint32_t seq)
Do server roundtrip.
Definition: interfaces.h:110