25 #ifndef PIPEWIRE_CORE_H 26 #define PIPEWIRE_CORE_H 35 #include <spa/utils/hook.h> 37 #define PW_TYPE_INTERFACE_Core PW_TYPE_INFO_INTERFACE_BASE "Core" 38 #define PW_TYPE_INTERFACE_Registry PW_TYPE_INFO_INTERFACE_BASE "Registry" 40 #define PW_VERSION_CORE 3 42 #define PW_VERSION_REGISTRY 3 46 #define PW_DEFAULT_REMOTE "pipewire-0" 52 #define PW_ID_ANY (uint32_t)(0xffffffff) 62 #define PW_CORE_CHANGE_MASK_PROPS (1 << 0) 63 #define PW_CORE_CHANGE_MASK_ALL ((1 << 1)-1) 91 #define PW_CORE_EVENT_INFO 0 92 #define PW_CORE_EVENT_DONE 1 93 #define PW_CORE_EVENT_PING 2 94 #define PW_CORE_EVENT_ERROR 3 95 #define PW_CORE_EVENT_REMOVE_ID 4 96 #define PW_CORE_EVENT_BOUND_ID 5 97 #define PW_CORE_EVENT_ADD_MEM 6 98 #define PW_CORE_EVENT_REMOVE_MEM 7 99 #define PW_CORE_EVENT_NUM 8 106 #define PW_VERSION_CORE_EVENTS 0 126 void (*done) (
void *object, uint32_t
id,
int seq);
133 void (*ping) (
void *object, uint32_t
id,
int seq);
164 void (*remove_id) (
void *object, uint32_t
id);
176 void (*bound_id) (
void *object, uint32_t
id, uint32_t global_id);
192 void (*add_mem) (
void *object, uint32_t
id, uint32_t type,
int fd, uint32_t flags);
199 void (*remove_mem) (
void *object, uint32_t
id);
202 #define PW_CORE_METHOD_ADD_LISTENER 0 203 #define PW_CORE_METHOD_HELLO 1 204 #define PW_CORE_METHOD_SYNC 2 205 #define PW_CORE_METHOD_PONG 3 206 #define PW_CORE_METHOD_ERROR 4 207 #define PW_CORE_METHOD_GET_REGISTRY 5 208 #define PW_CORE_METHOD_CREATE_OBJECT 6 209 #define PW_CORE_METHOD_DESTROY 7 210 #define PW_CORE_METHOD_NUM 8 221 #define PW_VERSION_CORE_METHODS 0 224 int (*add_listener) (
void *object,
225 struct spa_hook *listener,
233 int (*hello) (
void *object, uint32_t
version);
245 int (*sync) (
void *object, uint32_t
id,
int seq);
253 int (*pong) (
void *object, uint32_t
id,
int seq);
279 struct pw_registry * (*get_registry) (
void *object, uint32_t
version,
280 size_t user_data_size);
291 void * (*create_object) (
void *object,
292 const char *factory_name,
295 const struct spa_dict *
props,
296 size_t user_data_size);
304 int (*destroy) (
void *object,
void *proxy);
307 #define pw_core_method(o,method,version,...) \ 309 int _res = -ENOTSUP; \ 310 spa_interface_call_res((struct spa_interface*)o, \ 311 struct pw_core_methods, _res, \ 312 method, version, ##__VA_ARGS__); \ 316 #define pw_core_add_listener(c,...) pw_core_method(c,add_listener,0,__VA_ARGS__) 317 #define pw_core_hello(c,...) pw_core_method(c,hello,0,__VA_ARGS__) 318 #define pw_core_sync(c,...) pw_core_method(c,sync,0,__VA_ARGS__) 319 #define pw_core_pong(c,...) pw_core_method(c,pong,0,__VA_ARGS__) 320 #define pw_core_error(c,...) pw_core_method(c,error,0,__VA_ARGS__) 324 SPA_PRINTF_FUNC(5, 0) int
325 pw_core_errorv(struct pw_core *core, uint32_t
id,
int seq,
329 vsnprintf(buffer,
sizeof(buffer), message, args);
335 SPA_PRINTF_FUNC(5, 6) int
336 pw_core_errorf(struct pw_core *core, uint32_t
id,
int seq,
342 r = pw_core_errorv(core,
id, seq, res, message, args);
347 static inline struct pw_registry *
348 pw_core_get_registry(
struct pw_core *core, uint32_t
version,
size_t user_data_size)
350 struct pw_registry *
res = NULL;
351 spa_interface_call_res((
struct spa_interface*)core,
353 get_registry, 0, version, user_data_size);
358 pw_core_create_object(
struct pw_core *core,
359 const char *factory_name,
362 const struct spa_dict *
props,
363 size_t user_data_size)
366 spa_interface_call_res((
struct spa_interface*)core,
368 create_object, 0, factory_name,
369 type, version, props, user_data_size);
373 #define pw_core_destroy(c,...) pw_core_method(c,destroy,0,__VA_ARGS__) 407 #define PW_REGISTRY_EVENT_GLOBAL 0 408 #define PW_REGISTRY_EVENT_GLOBAL_REMOVE 1 409 #define PW_REGISTRY_EVENT_NUM 2 413 #define PW_VERSION_REGISTRY_EVENTS 0 427 void (*global) (
void *object, uint32_t
id,
428 uint32_t permissions,
const char *type, uint32_t
version,
429 const struct spa_dict *
props);
439 void (*global_remove) (
void *object, uint32_t
id);
442 #define PW_REGISTRY_METHOD_ADD_LISTENER 0 443 #define PW_REGISTRY_METHOD_BIND 1 444 #define PW_REGISTRY_METHOD_DESTROY 2 445 #define PW_REGISTRY_METHOD_NUM 3 449 #define PW_VERSION_REGISTRY_METHODS 0 452 int (*add_listener) (
void *object,
453 struct spa_hook *listener,
468 void * (*bind) (
void *object, uint32_t
id,
const char *type, uint32_t
version,
469 size_t use_data_size);
478 int (*destroy) (
void *object, uint32_t
id);
481 #define pw_registry_method(o,method,version,...) \ 483 int _res = -ENOTSUP; \ 484 spa_interface_call_res((struct spa_interface*)o, \ 485 struct pw_registry_methods, _res, \ 486 method, version, ##__VA_ARGS__); \ 491 #define pw_registry_add_listener(p,...) pw_registry_method(p,add_listener,0,__VA_ARGS__) 494 pw_registry_bind(
struct pw_registry *
registry,
495 uint32_t
id,
const char *type, uint32_t version,
496 size_t user_data_size)
499 spa_interface_call_res((
struct spa_interface*)registry,
501 bind, 0,
id, type, version, user_data_size);
505 #define pw_registry_destroy(p,...) pw_registry_method(p,destroy,0,__VA_ARGS__) 515 size_t user_data_size );
526 size_t user_data_size );
534 size_t user_data_size );
575 const struct spa_dict *props,
577 size_t user_data_size );
const struct pw_properties * pw_core_get_properties(struct pw_core *core)
Get properties from the core.
Definition: core.c:140
uint32_t version
Definition: core.h:414
int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
Update the core properties.
Definition: core.c:146
A collection of key/value pairs.
Definition: properties.h:45
struct spa_dict * props
extra properties
Definition: core.h:65
void * pw_core_get_user_data(struct pw_core *core)
Get the user_data.
Definition: core.c:164
static uint32_t int int res
Definition: core.h:325
uint64_t change_mask
bitfield of changed fields since last call
Definition: core.h:64
Core events.
Definition: core.h:105
void(* error)(void *object, uint32_t id, int seq, int res, const char *message)
Fatal error event.
Definition: core.h:152
static uint32_t int int const char int r
Definition: core.h:338
const char * host_name
name of the machine the core is running on
Definition: core.h:59
SPA_EXPORT struct pw_core * pw_context_connect_self(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: core.c:454
struct pw_client * pw_core_get_client(struct pw_core *core)
Get the client proxy of the connected core.
Definition: core.c:262
Core methods.
Definition: core.h:220
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
static uint32_t int int const char * message
Definition: core.h:325
uint32_t version
Definition: core.h:107
uint32_t cookie
a random cookie for identifying this instance of PipeWire
Definition: core.h:57
uint32_t id
id of the global
Definition: core.h:56
The core information.
Definition: core.h:55
SPA_EXPORT struct pw_core * pw_context_connect(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: core.c:402
SPA_EXPORT struct pw_core * pw_context_connect_fd(struct pw_context *context, int fd, struct pw_properties *properties, size_t user_data_size)
Definition: core.c:429
Registry events.
Definition: core.h:412
Represents an object on the client side.
const char * version
version of the core
Definition: core.h:60
SPA_EXPORT struct pw_core_info * pw_core_info_update(struct pw_core_info *info, const struct pw_core_info *update)
Definition: introspect.c:129
struct pw_mempool * pw_core_get_mempool(struct pw_core *core)
Get the core mempool object.
Definition: core.c:483
static uint32_t int seq
Definition: core.h:325
void(* info)(void *object, const struct pw_core_info *info)
Notify new core info.
Definition: core.h:117
const char * user_name
name of the user that started the core
Definition: core.h:58
int pw_core_set_paused(struct pw_core *core, bool paused)
Pause or resume the core.
Definition: core.c:476
uint32_t version
Definition: core.h:450
static uint32_t int int const char va_list args
Definition: core.h:327
struct pw_proxy * pw_core_find_proxy(struct pw_core *core, uint32_t id)
Get the proxy with the given id.
Definition: core.c:268
int pw_core_steal_fd(struct pw_core *core)
Steal the fd of the core connection or < 0 on error.
Definition: core.c:468
Registry methods.
Definition: core.h:448
uint32_t version
Definition: core.h:222
Definition: pipewire.c:66
#define pw_core_error(c,...)
Definition: core.h:320
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:274
int pw_core_disconnect(struct pw_core *core)
disconnect and destroy a core
Definition: core.c:489
struct pw_context * pw_core_get_context(struct pw_core *core)
Get the context object used to created this core.
Definition: core.c:134
const char * name
name of the core
Definition: core.h:61
SPA_EXPORT void pw_core_info_free(struct pw_core_info *info)
Definition: introspect.c:158
vsnprintf(buffer, sizeof(buffer), message, args)