25 #ifndef PIPEWIRE_CORE_H
26 #define PIPEWIRE_CORE_H
54 #define PW_TYPE_INTERFACE_Core PW_TYPE_INFO_INTERFACE_BASE "Core"
55 #define PW_TYPE_INTERFACE_Registry PW_TYPE_INFO_INTERFACE_BASE "Registry"
57 #define PW_VERSION_CORE 3
59 #define PW_VERSION_REGISTRY 3
63 #define PW_DEFAULT_REMOTE "pipewire-0"
69 #define PW_ID_ANY (uint32_t)(0xffffffff)
80 #define PW_CORE_CHANGE_MASK_PROPS (1 << 0)
81 #define PW_CORE_CHANGE_MASK_ALL ((1 << 1)-1)
103 #define PW_CORE_EVENT_INFO 0
104 #define PW_CORE_EVENT_DONE 1
105 #define PW_CORE_EVENT_PING 2
106 #define PW_CORE_EVENT_ERROR 3
107 #define PW_CORE_EVENT_REMOVE_ID 4
108 #define PW_CORE_EVENT_BOUND_ID 5
109 #define PW_CORE_EVENT_ADD_MEM 6
110 #define PW_CORE_EVENT_REMOVE_MEM 7
111 #define PW_CORE_EVENT_NUM 8
118 #define PW_VERSION_CORE_EVENTS 0
138 void (*
done) (
void *object, uint32_t
id,
int seq);
145 void (*
ping) (
void *object, uint32_t
id,
int seq);
164 void (*
error) (
void *object, uint32_t
id,
int seq,
int res,
const char *message);
188 void (*
bound_id) (
void *object, uint32_t
id, uint32_t global_id);
204 void (*
add_mem) (
void *object, uint32_t
id, uint32_t type,
int fd, uint32_t flags);
214 #define PW_CORE_METHOD_ADD_LISTENER 0
215 #define PW_CORE_METHOD_HELLO 1
216 #define PW_CORE_METHOD_SYNC 2
217 #define PW_CORE_METHOD_PONG 3
218 #define PW_CORE_METHOD_ERROR 4
219 #define PW_CORE_METHOD_GET_REGISTRY 5
220 #define PW_CORE_METHOD_CREATE_OBJECT 6
221 #define PW_CORE_METHOD_DESTROY 7
222 #define PW_CORE_METHOD_NUM 8
233 #define PW_VERSION_CORE_METHODS 0
257 int (*
sync) (
void *object, uint32_t id,
int seq);
265 int (*
pong) (
void *object, uint32_t id,
int seq);
282 int (*
error) (
void *object, uint32_t id,
int seq,
int res,
const char *message);
291 struct pw_registry * (*get_registry) (
void *object, uint32_t
version,
292 size_t user_data_size);
303 void * (*create_object) (
void *object,
304 const char *factory_name,
308 size_t user_data_size);
319 #define pw_core_method(o,method,version,...) \
321 int _res = -ENOTSUP; \
322 spa_interface_call_res((struct spa_interface*)o, \
323 struct pw_core_methods, _res, \
324 method, version, ##__VA_ARGS__); \
328 #define pw_core_add_listener(c,...) pw_core_method(c,add_listener,0,__VA_ARGS__)
329 #define pw_core_hello(c,...) pw_core_method(c,hello,0,__VA_ARGS__)
330 #define pw_core_sync(c,...) pw_core_method(c,sync,0,__VA_ARGS__)
331 #define pw_core_pong(c,...) pw_core_method(c,pong,0,__VA_ARGS__)
332 #define pw_core_error(c,...) pw_core_method(c,error,0,__VA_ARGS__)
337 pw_core_errorv(struct pw_core *core, uint32_t
id,
int seq,
338 int res, const
char *message, va_list args)
348 pw_core_errorf(struct pw_core *core, uint32_t
id,
int seq,
349 int res, const
char *message, ...)
353 va_start(args, message);
354 r = pw_core_errorv(core,
id, seq, res, message, args);
359 static inline struct pw_registry *
360 pw_core_get_registry(
struct pw_core *core, uint32_t version,
size_t user_data_size)
362 struct pw_registry *res = NULL;
365 get_registry, 0, version, user_data_size);
370 pw_core_create_object(
struct pw_core *core,
371 const char *factory_name,
375 size_t user_data_size)
380 create_object, 0, factory_name,
381 type, version,
props, user_data_size);
385 #define pw_core_destroy(c,...) pw_core_method(c,destroy,0,__VA_ARGS__)
426 #define PW_REGISTRY_EVENT_GLOBAL 0
427 #define PW_REGISTRY_EVENT_GLOBAL_REMOVE 1
428 #define PW_REGISTRY_EVENT_NUM 2
432 #define PW_VERSION_REGISTRY_EVENTS 0
446 void (*
global) (
void *object, uint32_t id,
447 uint32_t permissions,
const char *type, uint32_t
version,
461 #define PW_REGISTRY_METHOD_ADD_LISTENER 0
462 #define PW_REGISTRY_METHOD_BIND 1
463 #define PW_REGISTRY_METHOD_DESTROY 2
464 #define PW_REGISTRY_METHOD_NUM 3
468 #define PW_VERSION_REGISTRY_METHODS 0
487 void * (*bind) (
void *object, uint32_t id,
const char *type, uint32_t
version,
488 size_t use_data_size);
500 #define pw_registry_method(o,method,version,...) \
502 int _res = -ENOTSUP; \
503 spa_interface_call_res((struct spa_interface*)o, \
504 struct pw_registry_methods, _res, \
505 method, version, ##__VA_ARGS__); \
510 #define pw_registry_add_listener(p,...) pw_registry_method(p,add_listener,0,__VA_ARGS__)
513 pw_registry_bind(
struct pw_registry *
registry,
514 uint32_t
id,
const char *type, uint32_t
version,
515 size_t user_data_size)
520 bind, 0,
id, type,
version, user_data_size);
524 #define pw_registry_destroy(p,...) pw_registry_method(p,destroy,0,__VA_ARGS__)
548 size_t user_data_size);
564 size_t user_data_size);
577 size_t user_data_size);
620 size_t user_data_size );
#define pw_core_error(c,...)
Definition: core.h:332
struct pw_core * pw_context_connect(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Connect to a PipeWire instance.
Definition: core.c:402
struct pw_core * pw_context_connect_self(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Connect to a given PipeWire instance.
Definition: core.c:454
struct pw_core_info * pw_core_info_merge(struct pw_core_info *info, const struct pw_core_info *update, bool reset)
Update an existing pw_core_info with update.
Definition: introspect.c:127
struct pw_client * pw_core_get_client(struct pw_core *core)
Get the client proxy of the connected core.
Definition: core.c:263
void * pw_core_get_user_data(struct pw_core *core)
Get the user_data.
Definition: core.c:162
struct pw_mempool * pw_core_get_mempool(struct pw_core *core)
Get the core mempool object.
Definition: core.c:483
struct pw_core_info * pw_core_info_update(struct pw_core_info *info, const struct pw_core_info *update)
Update an existing pw_core_info with update with reset.
Definition: introspect.c:158
int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
Update the core properties.
Definition: core.c:144
struct pw_proxy * pw_core_find_proxy(struct pw_core *core, uint32_t id)
Get the proxy with the given id.
Definition: core.c:269
int pw_core_disconnect(struct pw_core *core)
disconnect and destroy a core
Definition: core.c:489
int pw_core_steal_fd(struct pw_core *core)
Steal the fd of the core connection or < 0 on error.
Definition: core.c:468
struct pw_core * pw_context_connect_fd(struct pw_context *context, int fd, struct pw_properties *properties, size_t user_data_size)
Connect to a PipeWire instance on the given socket.
Definition: core.c:429
struct pw_context * pw_core_get_context(struct pw_core *core)
Get the context object used to created this core.
Definition: core.c:132
const struct pw_properties * pw_core_get_properties(struct pw_core *core)
Get properties from the core.
Definition: core.c:138
int pw_core_set_paused(struct pw_core *core, bool paused)
Pause or resume the core.
Definition: core.c:476
void pw_core_info_free(struct pw_core_info *info)
Free a pw_core_info
Definition: introspect.c:165
struct pw_proxy * pw_core_export(struct pw_core *core, const char *type, const struct spa_dict *props, void *object, size_t user_data_size)
Export an object into the PipeWire instance associated with core.
Definition: core.c:275
#define spa_interface_call_res(iface, method_type, res, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition: hook.h:226
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:211
user data to add to an object
Definition: filter.c:75
Core events.
Definition: core.h:117
void(* error)(void *object, uint32_t id, int seq, int res, const char *message)
Fatal error event.
Definition: core.h:164
void(* remove_mem)(void *object, uint32_t id)
Remove memory for a client.
Definition: core.h:211
void(* done)(void *object, uint32_t id, int seq)
Emit a done event.
Definition: core.h:138
uint32_t version
Definition: core.h:119
void(* remove_id)(void *object, uint32_t id)
Remove an object ID.
Definition: core.h:176
void(* info)(void *object, const struct pw_core_info *info)
Notify new core info.
Definition: core.h:129
void(* ping)(void *object, uint32_t id, int seq)
Emit a ping event.
Definition: core.h:145
void(* bound_id)(void *object, uint32_t id, uint32_t global_id)
Notify an object binding.
Definition: core.h:188
void(* add_mem)(void *object, uint32_t id, uint32_t type, int fd, uint32_t flags)
Add memory for a client.
Definition: core.h:204
The core information.
Definition: core.h:73
struct spa_dict * props
extra properties
Definition: core.h:83
uint64_t change_mask
bitfield of changed fields since last call
Definition: core.h:82
const char * version
version of the core
Definition: core.h:78
uint32_t cookie
a random cookie for identifying this instance of PipeWire
Definition: core.h:75
uint32_t id
id of the global
Definition: core.h:74
const char * user_name
name of the user that started the core
Definition: core.h:76
const char * host_name
name of the machine the core is running on
Definition: core.h:77
const char * name
name of the core
Definition: core.h:79
Core methods.
Definition: core.h:232
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_core_events *events, void *data)
Definition: core.h:236
int(* pong)(void *object, uint32_t id, int seq)
Reply to a server ping event.
Definition: core.h:265
int(* destroy)(void *object, void *proxy)
Destroy an resource.
Definition: core.h:316
int(* hello)(void *object, uint32_t version)
Start a conversation with the server.
Definition: core.h:245
int(* error)(void *object, uint32_t id, int seq, int res, const char *message)
Fatal error event.
Definition: core.h:282
uint32_t version
Definition: core.h:234
A memory pool is a collection of pw_memblocks.
Definition: src/pipewire/mem.h:72
Definition: properties.h:49
struct spa_dict dict
dictionary of key/values
Definition: properties.h:50
Registry events.
Definition: core.h:431
void(* global_remove)(void *object, uint32_t id)
Notify of a global object removal.
Definition: core.h:458
uint32_t version
Definition: core.h:433
void(* global)(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version, const struct spa_dict *props)
Notify of a new global object.
Definition: core.h:446
Registry methods.
Definition: core.h:467
uint32_t version
Definition: core.h:469
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_registry_events *events, void *data)
Definition: core.h:471
int(* destroy)(void *object, uint32_t id)
Attempt to destroy a global object.
Definition: core.h:497
Definition: pipewire.c:79
Definition: utils/dict.h:48
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:313
Definition: media-session.c:123