PipeWire  0.1.4
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_client_proxy;
41 struct pw_link_proxy;
42 
61 #define PW_TYPE_INTERFACE__Core PW_TYPE_INTERFACE_BASE "Core"
62 #define PW_TYPE_INTERFACE__Registry PW_TYPE_INTERFACE_BASE "Registry"
63 #define PW_TYPE_INTERFACE__Module PW_TYPE_INTERFACE_BASE "Module"
64 #define PW_TYPE_INTERFACE__Node PW_TYPE_INTERFACE_BASE "Node"
65 #define PW_TYPE_INTERFACE__Client PW_TYPE_INTERFACE_BASE "Client"
66 #define PW_TYPE_INTERFACE__Link PW_TYPE_INTERFACE_BASE "Link"
67 
68 #define PW_VERSION_CORE 0
69 
70 #define PW_CORE_PROXY_METHOD_UPDATE_TYPES 0
71 #define PW_CORE_PROXY_METHOD_SYNC 1
72 #define PW_CORE_PROXY_METHOD_GET_REGISTRY 2
73 #define PW_CORE_PROXY_METHOD_CLIENT_UPDATE 3
74 #define PW_CORE_PROXY_METHOD_CREATE_NODE 4
75 #define PW_CORE_PROXY_METHOD_CREATE_LINK 5
76 #define PW_CORE_PROXY_METHOD_NUM 6
77 
87 #define PW_VERSION_CORE_PROXY_METHODS 0
88  uint32_t version;
98  void (*update_types) (void *object,
99  uint32_t first_id,
100  uint32_t n_types,
101  const char **types);
111  void (*sync) (void *object, uint32_t seq);
120  void (*get_registry) (void *object, uint32_t version, uint32_t new_id);
125  void (*client_update) (void *object, const struct spa_dict *props);
138  void (*create_node) (void *object,
139  const char *factory_name,
140  const char *name,
141  uint32_t type,
142  uint32_t version,
143  const struct spa_dict *props,
144  uint32_t new_id);
156  void (*create_link) (void *object,
157  uint32_t output_node_id,
158  uint32_t output_port_id,
159  uint32_t input_node_id,
160  uint32_t input_port_id,
161  const struct spa_format *filter,
162  const struct spa_dict *props,
163  uint32_t new_id);
164 };
165 
166 static inline void
167 pw_core_proxy_update_types(struct pw_core_proxy *core, uint32_t first_id, uint32_t n_types, const char **types)
168 {
169  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, update_types, first_id, n_types, types);
170 }
171 
172 static inline void
173 pw_core_proxy_sync(struct pw_core_proxy *core, uint32_t seq)
174 {
175  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, sync, seq);
176 }
177 
178 static inline struct pw_registry_proxy *
179 pw_core_proxy_get_registry(struct pw_core_proxy *core, uint32_t type, uint32_t version, size_t user_data_size)
180 {
181  struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
182  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, get_registry, version, pw_proxy_get_id(p));
183  return (struct pw_registry_proxy *) p;
184 }
185 
186 static inline void
187 pw_core_proxy_client_update(struct pw_core_proxy *core, const struct spa_dict *props)
188 {
189  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, client_update, props);
190 }
191 
192 static inline void *
193 pw_core_proxy_create_node(struct pw_core_proxy *core,
194  const char *factory_name,
195  const char *name,
196  uint32_t type,
197  uint32_t version,
198  const struct spa_dict *props,
199  size_t user_data_size)
200 {
201  struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
202  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, create_node, factory_name,
203  name, type, version, props, pw_proxy_get_id(p));
204  return p;
205 }
206 
207 static inline struct pw_link_proxy *
208 pw_core_proxy_create_link(struct pw_core_proxy *core,
209  uint32_t type,
210  uint32_t output_node_id,
211  uint32_t output_port_id,
212  uint32_t input_node_id,
213  uint32_t input_port_id,
214  const struct spa_format *filter,
215  const struct spa_dict *prop,
216  size_t user_data_size)
217 {
218  struct pw_proxy *p = pw_proxy_new((struct pw_proxy*)core, type, user_data_size);
219  pw_proxy_do((struct pw_proxy*)core, struct pw_core_proxy_methods, create_link, output_node_id, output_port_id,
220  input_node_id, input_port_id, filter, prop, pw_proxy_get_id(p));
221  return (struct pw_link_proxy*) p;
222 }
223 
224 
225 #define PW_CORE_PROXY_EVENT_UPDATE_TYPES 0
226 #define PW_CORE_PROXY_EVENT_DONE 1
227 #define PW_CORE_PROXY_EVENT_ERROR 2
228 #define PW_CORE_PROXY_EVENT_REMOVE_ID 3
229 #define PW_CORE_PROXY_EVENT_INFO 4
230 #define PW_CORE_PROXY_EVENT_NUM 5
231 
237 #define PW_VERSION_CORE_PROXY_EVENTS 0
238  uint32_t version;
248  void (*update_types) (void *object,
249  uint32_t first_id,
250  uint32_t n_types,
251  const char **types);
259  void (*done) (void *object, uint32_t seq);
272  void (*error) (void *object, uint32_t id, int res, const char *error, ...);
283  void (*remove_id) (void *object, uint32_t id);
289  void (*info) (void *object, struct pw_core_info *info);
290 };
291 
292 static inline void
293 pw_core_proxy_add_listener(struct pw_core_proxy *core,
294  struct spa_hook *listener,
295  const struct pw_core_proxy_events *events,
296  void *data)
297 {
298  pw_proxy_add_proxy_listener((struct pw_proxy*)core, listener, events, data);
299 }
300 
301 
302 #define pw_core_resource_update_types(r,...) pw_resource_notify(r,struct pw_core_proxy_events,update_types,__VA_ARGS__)
303 #define pw_core_resource_done(r,...) pw_resource_notify(r,struct pw_core_proxy_events,done,__VA_ARGS__)
304 #define pw_core_resource_error(r,...) pw_resource_notify(r,struct pw_core_proxy_events,error,__VA_ARGS__)
305 #define pw_core_resource_remove_id(r,...) pw_resource_notify(r,struct pw_core_proxy_events,remove_id,__VA_ARGS__)
306 #define pw_core_resource_info(r,...) pw_resource_notify(r,struct pw_core_proxy_events,info,__VA_ARGS__)
307 
308 
309 #define PW_VERSION_REGISTRY 0
310 
311 #define PW_REGISTRY_PROXY_METHOD_BIND 0
312 #define PW_REGISTRY_PROXY_METHOD_NUM 1
313 
316 #define PW_VERSION_REGISTRY_PROXY_METHODS 0
317  uint32_t version;
330  void (*bind) (void *object, uint32_t id, uint32_t type, uint32_t version, uint32_t new_id);
331 };
332 
334 static inline void *
335 pw_registry_proxy_bind(struct pw_registry_proxy *registry,
336  uint32_t id, uint32_t type, uint32_t version,
337  size_t user_data_size)
338 {
339  struct pw_proxy *reg = (struct pw_proxy*)registry;
340  struct pw_proxy *p = pw_proxy_new(reg, type, user_data_size);
341  pw_proxy_do(reg, struct pw_registry_proxy_methods, bind, id, type, version, pw_proxy_get_id(p));
342  return p;
343 }
344 
345 #define PW_REGISTRY_PROXY_EVENT_GLOBAL 0
346 #define PW_REGISTRY_PROXY_EVENT_GLOBAL_REMOVE 1
347 #define PW_REGISTRY_PROXY_EVENT_NUM 2
348 
351 #define PW_VERSION_REGISTRY_PROXY_EVENTS 0
352  uint32_t version;
365  void (*global) (void *object, uint32_t id, uint32_t parent_id,
366  uint32_t permissions, uint32_t type, uint32_t version);
376  void (*global_remove) (void *object, uint32_t id);
377 };
378 
379 static inline void
380 pw_registry_proxy_add_listener(struct pw_registry_proxy *registry,
381  struct spa_hook *listener,
382  const struct pw_registry_proxy_events *events,
383  void *data)
384 {
385  pw_proxy_add_proxy_listener((struct pw_proxy*)registry, listener, events, data);
386 }
387 
388 #define pw_registry_resource_global(r,...) pw_resource_notify(r,struct pw_registry_proxy_events,global,__VA_ARGS__)
389 #define pw_registry_resource_global_remove(r,...) pw_resource_notify(r,struct pw_registry_proxy_events,global_remove,__VA_ARGS__)
390 
391 
392 #define PW_VERSION_MODULE 0
393 
394 #define PW_MODULE_PROXY_EVENT_INFO 0
395 #define PW_MODULE_PROXY_EVENT_NUM 1
396 
399 #define PW_VERSION_MODULE_PROXY_EVENTS 0
400  uint32_t version;
406  void (*info) (void *object, struct pw_module_info *info);
407 };
408 
409 static inline void
410 pw_module_proxy_add_listener(struct pw_module_proxy *module,
411  struct spa_hook *listener,
412  const struct pw_module_proxy_events *events,
413  void *data)
414 {
415  pw_proxy_add_proxy_listener((struct pw_proxy*)module, listener, events, data);
416 }
417 
418 #define pw_module_resource_info(r,...) pw_resource_notify(r,struct pw_module_proxy_events,info,__VA_ARGS__)
419 
420 #define PW_VERSION_NODE 0
421 
422 #define PW_NODE_PROXY_EVENT_INFO 0
423 #define PW_NODE_PROXY_EVENT_NUM 1
424 
427 #define PW_VERSION_NODE_PROXY_EVENTS 0
428  uint32_t version;
434  void (*info) (void *object, struct pw_node_info *info);
435 };
436 
437 static inline void
438 pw_node_proxy_add_listener(struct pw_node_proxy *node,
439  struct spa_hook *listener,
440  const struct pw_node_proxy_events *events,
441  void *data)
442 {
443  pw_proxy_add_proxy_listener((struct pw_proxy*)node, listener, events, data);
444 }
445 
446 #define pw_node_resource_info(r,...) pw_resource_notify(r,struct pw_node_proxy_events,info,__VA_ARGS__)
447 
448 #define PW_VERSION_CLIENT 0
449 
450 #define PW_CLIENT_PROXY_EVENT_INFO 0
451 #define PW_CLIENT_PROXY_EVENT_NUM 1
452 
455 #define PW_VERSION_CLIENT_PROXY_EVENTS 0
456  uint32_t version;
462  void (*info) (void *object, struct pw_client_info *info);
463 };
464 
466 static inline void
467 pw_client_proxy_add_listener(struct pw_client_proxy *client,
468  struct spa_hook *listener,
469  const struct pw_client_proxy_events *events,
470  void *data)
471 {
472  pw_proxy_add_proxy_listener((struct pw_proxy*)client, listener, events, data);
473 }
474 
475 #define pw_client_resource_info(r,...) pw_resource_notify(r,struct pw_client_proxy_events,info,__VA_ARGS__)
476 
477 
478 #define PW_VERSION_LINK 0
479 
480 #define PW_LINK_PROXY_EVENT_INFO 0
481 #define PW_LINK_PROXY_EVENT_NUM 1
482 
485 #define PW_VERSION_LINK_PROXY_EVENTS 0
486  uint32_t version;
492  void (*info) (void *object, struct pw_link_info *info);
493 };
494 
496 static inline void
497 pw_link_proxy_add_listener(struct pw_link_proxy *link,
498  struct spa_hook *listener,
499  const struct pw_link_proxy_events *events,
500  void *data)
501 {
502  pw_proxy_add_proxy_listener((struct pw_proxy*)link, listener, events, data);
503 }
504 
505 #define pw_link_resource_info(r,...) pw_resource_notify(r,struct pw_link_proxy_events,info,__VA_ARGS__)
506 
507 #ifdef __cplusplus
508 } /* extern "C" */
509 #endif
510 
511 #endif /* __PIPEWIRE_INTERFACES_H__ */
uint32_t version
Definition: interfaces.h:400
uint32_t version
Definition: interfaces.h:456
uint32_t pw_proxy_get_id(struct pw_proxy *proxy)
Definition: proxy.c:83
void(* create_node)(void *object, const char *factory_name, const char *name, uint32_t type, uint32_t version, const struct spa_dict *props, uint32_t new_id)
Create a new node on the PipeWire server from a factory.
Definition: interfaces.h:138
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:125
Module events.
Definition: interfaces.h:398
void(* get_registry)(void *object, uint32_t version, uint32_t new_id)
Get the registry object.
Definition: interfaces.h:120
void(* info)(void *object, struct pw_module_info *info)
Notify module info.
Definition: interfaces.h:406
Represents an object on the client side.
Definition: private.h:306
The core information.
Definition: introspect.h:76
uint32_t version
Definition: interfaces.h:352
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:156
Node events.
Definition: interfaces.h:426
void pw_proxy_add_proxy_listener(struct pw_proxy *proxy, struct spa_hook *listener, const void *events, void *data)
Definition: proxy.c:101
#define pw_proxy_do(p, type, method,...)
Definition: proxy.h:129
uint32_t version
Definition: interfaces.h:317
void(* error)(void *object, uint32_t id, int res, const char *error,...)
Fatal error event.
Definition: interfaces.h:272
The client information.
Definition: introspect.h:119
void(* info)(void *object, struct pw_client_info *info)
Notify client info.
Definition: interfaces.h:462
uint32_t version
Definition: interfaces.h:428
Core events.
Definition: interfaces.h:236
The module information.
Definition: introspect.h:102
Client events.
Definition: interfaces.h:454
uint32_t version
Definition: interfaces.h:88
uint32_t version
Definition: interfaces.h:238
Registry methods.
Definition: interfaces.h:315
void(* info)(void *object, struct pw_core_info *info)
Notify new core info.
Definition: interfaces.h:289
void(* update_types)(void *object, uint32_t first_id, uint32_t n_types, const char **types)
Update the type map.
Definition: interfaces.h:98
The node information.
Definition: introspect.h:135
void(* info)(void *object, struct pw_node_info *info)
Notify node info.
Definition: interfaces.h:434
Core methods.
Definition: interfaces.h:86
Registry events.
Definition: interfaces.h:350
void(* sync)(void *object, uint32_t seq)
Do server roundtrip.
Definition: interfaces.h:111