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 49 #define PW_ID_ANY (uint32_t)(0xffffffff) 59 #define PW_CORE_CHANGE_MASK_PROPS (1 << 0) 60 #define PW_CORE_CHANGE_MASK_ALL ((1 << 1)-1) 88 #define PW_CORE_EVENT_INFO 0 89 #define PW_CORE_EVENT_DONE 1 90 #define PW_CORE_EVENT_PING 2 91 #define PW_CORE_EVENT_ERROR 3 92 #define PW_CORE_EVENT_REMOVE_ID 4 93 #define PW_CORE_EVENT_BOUND_ID 5 94 #define PW_CORE_EVENT_ADD_MEM 6 95 #define PW_CORE_EVENT_REMOVE_MEM 7 96 #define PW_CORE_EVENT_NUM 8 103 #define PW_VERSION_CORE_EVENTS 0 173 void (*
bound_id) (
void *object, uint32_t
id, uint32_t global_id);
189 void (*
add_mem) (
void *object, uint32_t
id, uint32_t type,
int fd, uint32_t flags);
199 #define PW_CORE_METHOD_ADD_LISTENER 0 200 #define PW_CORE_METHOD_HELLO 1 201 #define PW_CORE_METHOD_SYNC 2 202 #define PW_CORE_METHOD_PONG 3 203 #define PW_CORE_METHOD_ERROR 4 204 #define PW_CORE_METHOD_GET_REGISTRY 5 205 #define PW_CORE_METHOD_CREATE_OBJECT 6 206 #define PW_CORE_METHOD_DESTROY 7 207 #define PW_CORE_METHOD_NUM 8 218 #define PW_VERSION_CORE_METHODS 0 222 struct spa_hook *listener,
276 struct pw_registry * (*get_registry) (
void *object, uint32_t
version,
277 size_t user_data_size);
288 void * (*create_object) (
void *object,
289 const char *factory_name,
292 const struct spa_dict *props,
293 size_t user_data_size);
304 #define pw_core_method(o,method,version,...) \ 306 int _res = -ENOTSUP; \ 307 spa_interface_call_res((struct spa_interface*)o, \ 308 struct pw_core_methods, _res, \ 309 method, version, ##__VA_ARGS__); \ 313 #define pw_core_add_listener(c,...) pw_core_method(c,add_listener,0,__VA_ARGS__) 314 #define pw_core_hello(c,...) pw_core_method(c,hello,0,__VA_ARGS__) 315 #define pw_core_sync(c,...) pw_core_method(c,sync,0,__VA_ARGS__) 316 #define pw_core_pong(c,...) pw_core_method(c,pong,0,__VA_ARGS__) 317 #define pw_core_error(c,...) pw_core_method(c,error,0,__VA_ARGS__) 321 SPA_PRINTF_FUNC(5, 0) int
322 pw_core_errorv(struct pw_core *core, uint32_t
id,
int seq,
332 SPA_PRINTF_FUNC(5, 6) int
333 pw_core_errorf(struct pw_core *core, uint32_t
id,
int seq,
344 static inline struct pw_registry *
345 pw_core_get_registry(
struct pw_core *core, uint32_t version,
size_t user_data_size)
347 struct pw_registry *
res = NULL;
348 spa_interface_call_res((
struct spa_interface*)core,
350 get_registry, 0, version, user_data_size);
355 pw_core_create_object(
struct pw_core *core,
356 const char *factory_name,
359 const struct spa_dict *props,
360 size_t user_data_size)
363 spa_interface_call_res((
struct spa_interface*)core,
365 create_object, 0, factory_name,
366 type, version, props, user_data_size);
370 #define pw_core_destroy(c,...) pw_core_method(c,destroy,0,__VA_ARGS__) 404 #define PW_REGISTRY_EVENT_GLOBAL 0 405 #define PW_REGISTRY_EVENT_GLOBAL_REMOVE 1 406 #define PW_REGISTRY_EVENT_NUM 2 410 #define PW_VERSION_REGISTRY_EVENTS 0 425 uint32_t permissions,
const char *type, uint32_t
version,
426 const struct spa_dict *props);
439 #define PW_REGISTRY_METHOD_ADD_LISTENER 0 440 #define PW_REGISTRY_METHOD_BIND 1 441 #define PW_REGISTRY_METHOD_DESTROY 2 442 #define PW_REGISTRY_METHOD_NUM 3 446 #define PW_VERSION_REGISTRY_METHODS 0 450 struct spa_hook *listener,
465 void * (*bind) (
void *object, uint32_t
id,
const char *type, uint32_t
version,
466 size_t use_data_size);
478 #define pw_registry_method(o,method,version,...) \ 480 int _res = -ENOTSUP; \ 481 spa_interface_call_res((struct spa_interface*)o, \ 482 struct pw_registry_methods, _res, \ 483 method, version, ##__VA_ARGS__); \ 488 #define pw_registry_add_listener(p,...) pw_registry_method(p,add_listener,0,__VA_ARGS__) 491 pw_registry_bind(
struct pw_registry *
registry,
492 uint32_t
id,
const char *type, uint32_t
version,
493 size_t user_data_size)
496 spa_interface_call_res((
struct spa_interface*)
registry,
498 bind, 0,
id, type,
version, user_data_size);
502 #define pw_registry_destroy(p,...) pw_registry_method(p,destroy,0,__VA_ARGS__) 512 size_t user_data_size );
523 size_t user_data_size );
531 size_t user_data_size );
572 const struct spa_dict *props,
574 size_t user_data_size );
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_registry_events *events, void *data)
Definition: core.h:449
const struct pw_properties * pw_core_get_properties(struct pw_core *core)
Get properties from the core.
Definition: core.c:139
uint32_t version
Definition: core.h:411
int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
Update the core properties.
Definition: core.c:145
A collection of key/value pairs.
Definition: properties.h:45
struct spa_dict * props
extra properties
Definition: core.h:62
void * pw_core_get_user_data(struct pw_core *core)
Get the user_data.
Definition: core.c:163
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:424
static uint32_t int int res
Definition: core.h:322
void(* add_mem)(void *object, uint32_t id, uint32_t type, int fd, uint32_t flags)
Add memory for a client.
Definition: core.h:189
uint64_t change_mask
bitfield of changed fields since last call
Definition: core.h:61
Core events
Definition: core.h:102
void(* error)(void *object, uint32_t id, int seq, int res, const char *message)
Fatal error event.
Definition: core.h:149
static uint32_t int int const char int r
Definition: core.h:335
const char * host_name
name of the machine the core is running on
Definition: core.h:56
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:453
struct pw_client * pw_core_get_client(struct pw_core *core)
Get the client proxy of the connected core.
Definition: core.c:261
Core methods.
Definition: core.h:217
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
static uint32_t int int const char * message
Definition: core.h:322
int(* destroy)(void *object, void *proxy)
Destroy an resource.
Definition: core.h:301
uint32_t version
Definition: core.h:104
uint32_t cookie
a random cookie for identifying this instance of PipeWire
Definition: core.h:54
uint32_t id
id of the global
Definition: core.h:53
The core information.
Definition: core.h:52
void(* bound_id)(void *object, uint32_t id, uint32_t global_id)
Notify an object binding.
Definition: core.h:173
SPA_EXPORT struct pw_core * pw_context_connect(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: core.c:401
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:428
Registry events.
Definition: core.h:409
int(* error)(void *object, uint32_t id, int seq, int res, const char *message)
Fatal error event.
Definition: core.h:267
Represents an object on the client side.
const char * version
version of the core
Definition: core.h:57
struct pw_mempool * pw_core_get_mempool(struct pw_core *core)
Get the core mempool object.
Definition: core.c:482
int(* sync)(void *object, uint32_t id, int seq)
Do server roundtrip.
Definition: core.h:242
static uint32_t int seq
Definition: core.h:322
void(* info)(void *object, const struct pw_core_info *info)
Notify new core info.
Definition: core.h:114
const char * user_name
name of the user that started the core
Definition: core.h:55
int pw_core_set_paused(struct pw_core *core, bool paused)
Pause or resume the core.
Definition: core.c:475
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_core_events *events, void *data)
Definition: core.h:221
uint32_t version
Definition: core.h:447
static uint32_t int int const char va_list args
Definition: core.h:324
int(* destroy)(void *object, uint32_t id)
Attempt to destroy a global object.
Definition: core.h:475
struct pw_proxy * pw_core_find_proxy(struct pw_core *core, uint32_t id)
Get the proxy with the given id.
Definition: core.c:267
int pw_core_steal_fd(struct pw_core *core)
Steal the fd of the core connection or < 0 on error.
Definition: core.c:467
Registry methods.
Definition: core.h:445
void pw_core_info_free(struct pw_core_info *info)
Free a pw_core_info.
Definition: introspect.c:156
uint32_t version
Definition: core.h:219
Definition: pipewire.c:66
void(* global_remove)(void *object, uint32_t id)
Notify of a global object removal.
Definition: core.h:436
int(* pong)(void *object, uint32_t id, int seq)
Reply to a server ping event.
Definition: core.h:250
void(* done)(void *object, uint32_t id, int seq)
Emit a done event.
Definition: core.h:123
static uint32_t id
Definition: core.h:322
void(* remove_id)(void *object, uint32_t id)
Remove an object ID.
Definition: core.h:161
#define pw_core_error(c,...)
Definition: core.h:317
int(* hello)(void *object, uint32_t version)
Start a conversation with the server.
Definition: core.h:230
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:273
int pw_core_disconnect(struct pw_core *core)
disconnect and destroy a core
Definition: core.c:488
void(* ping)(void *object, uint32_t id, int seq)
Emit a ping event.
Definition: core.h:130
struct pw_context * pw_core_get_context(struct pw_core *core)
Get the context object used to created this core.
Definition: core.c:133
const char * name
name of the core
Definition: core.h:58
struct pw_core_info * pw_core_info_update(struct pw_core_info *info, const struct pw_core_info *update)
Update and existing pw_core_info with update.
Definition: introspect.c:127
vsnprintf(buffer, sizeof(buffer), message, args)
void(* remove_mem)(void *object, uint32_t id)
Remove memory for a client.
Definition: core.h:196