Go to the documentation of this file.
25 #ifndef PIPEWIRE_CORE_H
26 #define PIPEWIRE_CORE_H
49 #define PW_TYPE_INTERFACE_Core PW_TYPE_INFO_INTERFACE_BASE "Core"
50 #define PW_TYPE_INTERFACE_Registry PW_TYPE_INFO_INTERFACE_BASE "Registry"
52 #define PW_VERSION_CORE 3
54 #define PW_VERSION_REGISTRY 3
58 #define PW_DEFAULT_REMOTE "pipewire-0"
64 #define PW_ID_ANY (uint32_t)(0xffffffff)
74 #define PW_CORE_CHANGE_MASK_PROPS (1 << 0)
75 #define PW_CORE_CHANGE_MASK_ALL ((1 << 1)-1)
94 #define PW_CORE_EVENT_INFO 0
95 #define PW_CORE_EVENT_DONE 1
96 #define PW_CORE_EVENT_PING 2
97 #define PW_CORE_EVENT_ERROR 3
98 #define PW_CORE_EVENT_REMOVE_ID 4
99 #define PW_CORE_EVENT_BOUND_ID 5
100 #define PW_CORE_EVENT_ADD_MEM 6
101 #define PW_CORE_EVENT_REMOVE_MEM 7
102 #define PW_CORE_EVENT_NUM 8
109 #define PW_VERSION_CORE_EVENTS 0
179 void (*
bound_id) (
void *object, uint32_t
id, uint32_t global_id);
195 void (*
add_mem) (
void *object, uint32_t
id, uint32_t type,
int fd, uint32_t flags);
205 #define PW_CORE_METHOD_ADD_LISTENER 0
206 #define PW_CORE_METHOD_HELLO 1
207 #define PW_CORE_METHOD_SYNC 2
208 #define PW_CORE_METHOD_PONG 3
209 #define PW_CORE_METHOD_ERROR 4
210 #define PW_CORE_METHOD_GET_REGISTRY 5
211 #define PW_CORE_METHOD_CREATE_OBJECT 6
212 #define PW_CORE_METHOD_DESTROY 7
213 #define PW_CORE_METHOD_NUM 8
224 #define PW_VERSION_CORE_METHODS 0
282 struct pw_registry * (*get_registry) (
void *object, uint32_t
version,
283 size_t user_data_size);
294 void * (*create_object) (
void *object,
295 const char *factory_name,
299 size_t user_data_size);
310 #define pw_core_method(o,method,version,...) \
312 int _res = -ENOTSUP; \
313 spa_interface_call_res((struct spa_interface*)o, \
314 struct pw_core_methods, _res, \
315 method, version, ##__VA_ARGS__); \
319 #define pw_core_add_listener(c,...) pw_core_method(c,add_listener,0,__VA_ARGS__)
320 #define pw_core_hello(c,...) pw_core_method(c,hello,0,__VA_ARGS__)
321 #define pw_core_sync(c,...) pw_core_method(c,sync,0,__VA_ARGS__)
322 #define pw_core_pong(c,...) pw_core_method(c,pong,0,__VA_ARGS__)
323 #define pw_core_error(c,...) pw_core_method(c,error,0,__VA_ARGS__)
328 pw_core_errorv(struct pw_core *core, uint32_t
id,
int seq,
339 pw_core_errorf(struct pw_core *core, uint32_t
id,
int seq,
350 static inline struct pw_registry *
351 pw_core_get_registry(
struct pw_core *core, uint32_t version,
size_t user_data_size)
353 struct pw_registry *
res = NULL;
356 get_registry, 0, version, user_data_size);
361 pw_core_create_object(
struct pw_core *core,
362 const char *factory_name,
366 size_t user_data_size)
371 create_object, 0, factory_name,
372 type, version, props, user_data_size);
376 #define pw_core_destroy(c,...) pw_core_method(c,destroy,0,__VA_ARGS__)
417 #define PW_REGISTRY_EVENT_GLOBAL 0
418 #define PW_REGISTRY_EVENT_GLOBAL_REMOVE 1
419 #define PW_REGISTRY_EVENT_NUM 2
423 #define PW_VERSION_REGISTRY_EVENTS 0
438 uint32_t permissions,
const char *type, uint32_t
version,
452 #define PW_REGISTRY_METHOD_ADD_LISTENER 0
453 #define PW_REGISTRY_METHOD_BIND 1
454 #define PW_REGISTRY_METHOD_DESTROY 2
455 #define PW_REGISTRY_METHOD_NUM 3
459 #define PW_VERSION_REGISTRY_METHODS 0
478 void * (*bind) (
void *object, uint32_t
id,
const char *type, uint32_t
version,
479 size_t use_data_size);
491 #define pw_registry_method(o,method,version,...) \
493 int _res = -ENOTSUP; \
494 spa_interface_call_res((struct spa_interface*)o, \
495 struct pw_registry_methods, _res, \
496 method, version, ##__VA_ARGS__); \
501 #define pw_registry_add_listener(p,...) pw_registry_method(p,add_listener,0,__VA_ARGS__)
504 pw_registry_bind(
struct pw_registry *
registry,
505 uint32_t
id,
const char *type, uint32_t
version,
506 size_t user_data_size)
511 bind, 0,
id, type,
version, user_data_size);
515 #define pw_registry_destroy(p,...) pw_registry_method(p,destroy,0,__VA_ARGS__)
533 size_t user_data_size );
547 size_t user_data_size);
555 size_t user_data_size );
598 size_t user_data_size );
struct pw_mempool * pool
owner pool
Definition: src/pipewire/mem.h:79
A memory pool is a collection of pw_memblocks.
Definition: src/pipewire/mem.h:72
int pw_filter_disconnect(struct pw_filter *filter)
Disconnect filter
Definition: filter.c:1357
SPA_EXPORT 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:428
void(* remove_mem)(void *object, uint32_t id)
Remove memory for a client.
Definition: core.h:202
static uint32_t int int const char int r
Definition: core.h:341
data for registering export functions
Definition: context.h:162
struct pw_proxy * pw_proxy_new(struct pw_proxy *factory, const char *type, uint32_t version, size_t user_data_size)
Make a new proxy object.
Definition: proxy.c:89
const char * type
Definition: context.h:164
uint32_t version
Definition: core.h:424
struct pw_mempool * pw_mempool_new(struct pw_properties *props)
Create a new memory pool.
Definition: mem.c:137
uint32_t id
unique id
Definition: src/pipewire/mem.h:80
SPA_EXPORT int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
Update the core properties.
Definition: core.c:143
The core information.
Definition: core.h:67
int(* destroy)(void *object, uint32_t id)
Attempt to destroy a global object.
Definition: core.h:488
void(* add_mem)(void *object, uint32_t id, uint32_t type, int fd, uint32_t flags)
Add memory for a client.
Definition: core.h:195
void pw_mempool_destroy(struct pw_mempool *pool)
Clear and destroy a pool.
Definition: mem.c:174
int(* hello)(void *object, uint32_t version)
Start a conversation with the server.
Definition: core.h:236
void(* error)(void *object, uint32_t id, int seq, int res, const char *message)
Fatal error event.
Definition: core.h:155
uint32_t version
Definition: core.h:110
SPA_EXPORT struct pw_client * pw_core_get_client(struct pw_core *core)
Get the client proxy of the connected core.
Definition: core.c:262
uint32_t flags
flags for the memory block on of enum pw_memblock_flags
Definition: src/pipewire/mem.h:82
#define PW_VERSION_CORE
Definition: core.h:52
#define pw_log_trace(...)
Definition: src/pipewire/log.h:90
#define SPA_EXPORT
Definition: defs.h:207
#define pw_log_debug(...)
Definition: src/pipewire/log.h:89
#define spa_interface_call_res(iface, type, res, method, vers,...)
Definition: hook.h:170
#define pw_protocol_client_destroy(c)
Definition: protocol.h:74
void pw_proxy_destroy(struct pw_proxy *proxy)
destroy a proxy
Definition: proxy.c:229
const char * user_name
name of the user that started the core
Definition: core.h:70
Proxy events, use pw_proxy_add_listener.
Definition: proxy.h:111
const char * version
version of the core
Definition: core.h:72
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
#define pw_core_error(c,...)
Definition: core.h:323
void spa_hook_remove(struct spa_hook *hook)
Remove a hook.
Definition: hook.h:117
#define pw_protocol_new_client(p,...)
Definition: protocol.h:122
void(* bound_id)(void *object, uint32_t id, uint32_t global_id)
Notify an object binding.
Definition: core.h:179
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:204
#define PW_TYPE_INTERFACE_Core
Definition: core.h:49
static uint32_t int int res
Definition: core.h:329
SPA_EXPORT struct pw_mempool * pw_core_get_mempool(struct pw_core *core)
Get the core mempool object.
Definition: core.c:482
struct spa_dict dict
dictionary of key/values
Definition: properties.h:50
const char * host_name
name of the machine the core is running on
Definition: core.h:71
SPA_EXPORT 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:401
#define spa_list_consume(pos, head, member)
Definition: list.h:96
#define pw_protocol_client_connect(c, p, cb, d)
Definition: protocol.h:70
void pw_proxy_remove(struct pw_proxy *proxy)
called when cleaning up or when the server removed the resource.
Definition: proxy.c:265
SPA_EXPORT 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 events.
Definition: core.h:422
static uint32_t int seq
Definition: core.h:328
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_core_events *events, void *data)
Definition: core.h:227
#define pw_log_error(...)
Definition: src/pipewire/log.h:86
#define PW_VERSION_PROXY_EVENTS
Definition: proxy.h:112
SPA_EXPORT 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:453
#define PW_KEY_REMOTE_NAME
The name of the remote to connect to, default pipewire-0, overwritten by env(PIPEWIRE_REMOTE)
Definition: src/pipewire/keys.h:91
void spa_list_remove(struct spa_list *elem)
Definition: list.h:69
int(* error)(void *object, uint32_t id, int seq, int res, const char *message)
Fatal error event.
Definition: core.h:273
int(* pong)(void *object, uint32_t id, int seq)
Reply to a server ping event.
Definition: core.h:256
int(* sync)(void *object, uint32_t id, int seq)
Do server roundtrip.
Definition: core.h:248
static uint32_t id
Definition: core.h:328
int fd
fd
Definition: src/pipewire/mem.h:84
uint64_t change_mask
bitfield of changed fields since last call
Definition: core.h:76
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_registry_events *events, void *data)
Definition: core.h:462
const struct pw_export_type * pw_context_find_export_type(struct pw_context *context, const char *type)
find information about registered export type
Definition: context.c:1177
void(* info)(void *object, const struct pw_core_info *info)
Notify new core info.
Definition: core.h:120
SPA_EXPORT 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
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:76
#define pw_protocol_client_steal_fd(c)
Definition: protocol.h:72
SPA_EXPORT struct pw_context * pw_core_get_context(struct pw_core *core)
Get the context object used to created this core.
Definition: core.c:131
int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error,...) SPA_PRINTF_FUNC(3
void pw_stream_destroy(struct pw_stream *stream)
Destroy a stream.
Definition: stream.c:1400
struct spa_dict * props
extra properties
Definition: core.h:77
#define pw_core_hello(c,...)
Definition: core.h:320
SPA_EXPORT 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(* destroy)(void *object, void *proxy)
Destroy an resource.
Definition: core.h:307
SPA_EXPORT int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:314
SPA_EXPORT int pw_core_disconnect(struct pw_core *core)
disconnect and destroy a core
Definition: core.c:488
Core methods.
Definition: core.h:223
SPA_EXPORT int pw_core_set_paused(struct pw_core *core, bool paused)
Pause or resume the core.
Definition: core.c:475
int pw_stream_disconnect(struct pw_stream *stream)
Disconnect stream
Definition: stream.c:1805
void spa_list_init(struct spa_list *list)
Definition: list.h:44
#define spa_list_for_each_safe(pos, tmp, head, member)
Definition: list.h:129
Definition: utils/dict.h:48
struct pw_protocol * pw_context_find_protocol(struct pw_context *context, const char *name)
Definition: protocol.c:179
void(* global_remove)(void *object, uint32_t id)
Notify of a global object removal.
Definition: core.h:449
int pw_mempool_remove_id(struct pw_mempool *pool, uint32_t id)
Remove a memblock for given id.
Definition: mem.c:675
#define pw_core_pong(c,...)
Definition: core.h:322
SPA_EXPORT const struct pw_properties * pw_core_get_properties(struct pw_core *core)
Get properties from the core.
Definition: core.c:137
const SPA_EXPORT char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:515
#define NAME
Definition: core.c:40
#define PW_VERSION_CORE_EVENTS
Definition: core.h:109
#define spa_strerror(err)
Definition: result.h:51
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:225
struct pw_memblock * pw_mempool_import(struct pw_mempool *pool, enum pw_memblock_flags flags, uint32_t type, int fd)
Import an fd into the pool.
Definition: mem.c:575
Memory block structure.
Definition: src/pipewire/mem.h:78
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:459
#define pw_protocol_client_set_paused(c, p)
Definition: protocol.h:75
#define SPA_ID_INVALID
Definition: defs.h:182
struct pw_proxy *(* func)(struct pw_core *core, const char *type, const struct spa_dict *props, void *object, size_t user_data_size)
Definition: context.h:165
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
void pw_filter_destroy(struct pw_filter *filter)
Destroy a filter
Definition: filter.c:1150
vsnprintf(buffer, sizeof(buffer), message, args)
#define PW_TYPE_INTERFACE_Client
Definition: client.h:46
int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version)
Definition: proxy.c:43
const char * name
name of the core
Definition: core.h:73
uint32_t cookie
a random cookie for identifying this instance of PipeWire
Definition: core.h:69
Definition: pipewire.c:75
static uint32_t int int const char * message
Definition: core.h:329
SPA_EXPORT int pw_properties_add(struct pw_properties *props, const struct spa_dict *dict)
Add properties.
Definition: properties.c:337
void pw_proxy_add_listener(struct pw_proxy *proxy, struct spa_hook *listener, const struct pw_proxy_events *events, void *data)
Add an event listener to proxy.
Definition: proxy.c:195
Registry methods.
Definition: core.h:458
void(* done)(void *object, uint32_t id, int seq)
Emit a done event.
Definition: core.h:129
#define pw_protocol_client_disconnect(c)
Definition: protocol.h:73
void(* remove_id)(void *object, uint32_t id)
Remove an object ID.
Definition: core.h:167
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:100
#define pw_client_update_properties(c,...)
Definition: client.h:171
#define PW_KEY_PROTOCOL
A collection of keys that are used to add extra information on objects.
Definition: src/pipewire/keys.h:42
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:437
void(* ping)(void *object, uint32_t id, int seq)
Emit a ping event.
Definition: core.h:136
#define pw_protocol_client_connect_fd(c, fd, cl)
Definition: protocol.h:71
#define PW_VERSION_CLIENT
Definition: client.h:48
SPA_EXPORT void * pw_core_get_user_data(struct pw_core *core)
Get the user_data.
Definition: core.c:161
uint32_t id
id of the global
Definition: core.h:68
uint32_t type
type of the fd, one of enum spa_data_type
Definition: src/pipewire/mem.h:83
#define pw_core_add_listener(c,...)
Definition: core.h:319
static uint32_t int int const char va_list args
Definition: core.h:330
int pw_proxy_set_bound_id(struct pw_proxy *proxy, uint32_t global_id)
Set the global id this proxy is bound to.
Definition: proxy.c:158
Definition: properties.h:49
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:386
Core events.
Definition: core.h:108
#define spa_list_append(list, item)
Definition: list.h:81
#define pw_log_warn(...)
Definition: src/pipewire/log.h:87
uint32_t version
Definition: core.h:460