Go to the documentation of this file.
25 #ifndef PIPEWIRE_RESOURCE_H
26 #define PIPEWIRE_RESOURCE_H
32 #include <spa/utils/hook.h>
65 #define PW_VERSION_RESOURCE_EVENTS 0
85 size_t user_data_size );
114 struct spa_hook *listener,
120 struct spa_hook *listener,
148 #define pw_resource_notify(r,type,event,version,...) \
149 spa_hook_list_call(pw_resource_get_object_listeners(r), \
150 type, event, version, ## __VA_ARGS__)
152 #define pw_resource_call(r,type,method,version,...) \
153 spa_interface_call((struct spa_interface*)r, \
154 type, method, version, ##__VA_ARGS__)
156 #define pw_resource_call_res(r,type,method,version,...) \
158 int _res = -ENOTSUP; \
159 spa_interface_call_res((struct spa_interface*)r, \
160 type, _res, method, version, ##__VA_ARGS__); \
static uint32_t int int res
Definition: core.h:326
SPA_EXPORT void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:264
static uint32_t id
Definition: core.h:325
void(* destroy)(void *data)
The resource is destroyed.
Definition: resource.h:69
SPA_EXPORT struct spa_hook_list * pw_resource_get_object_listeners(struct pw_resource *resource)
Get the list of object listeners from a resource.
Definition: resource.c:183
#define NAME
Definition: resource.c:34
#define pw_log_error(...)
int pw_resource_install_marshal(struct pw_resource *resource, bool implementor)
install a marshal function on a resource
Definition: resource.c:105
const SPA_EXPORT char * pw_resource_get_type(struct pw_resource *resource, uint32_t *version)
Get the type and optionally the version of this resource.
Definition: resource.c:145
SPA_EXPORT void pw_resource_errorf(struct pw_resource *resource, int res, const char *error,...)
Definition: resource.c:237
Manages protocols and their implementation.
void pw_resource_remove(struct pw_resource *resource)
Remove a resource, like pw_resource_destroy but without sending a remove_id message to the client.
Definition: resource.c:291
SPA_EXPORT struct pw_impl_client * pw_resource_get_client(struct pw_resource *resource)
Get the client owning this resource.
Definition: resource.c:127
const struct pw_protocol_marshal * pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t version, uint32_t flags)
Definition: protocol.c:162
PipeWire client object class.
uint32_t pw_resource_get_id(struct pw_resource *resource)
Get the unique id of this resource.
Definition: resource.c:133
void pw_resource_errorf(struct pw_resource *resource, int res, const char *error,...) SPA_PRINTF_FUNC(3
void(* pong)(void *data, int seq)
a reply to a ping event completed
Definition: resource.h:72
SPA_EXPORT void pw_resource_error(struct pw_resource *resource, int res, const char *error)
Generate an error for a resource.
Definition: resource.c:255
uint32_t pw_resource_get_bound_id(struct pw_resource *resource)
Get the global id this resource is bound to or SPA_ID_INVALID when not bound.
Definition: resource.c:222
SPA_EXPORT uint32_t pw_resource_get_permissions(struct pw_resource *resource)
Get the permissions of this resource.
Definition: resource.c:139
SPA_EXPORT struct pw_resource * pw_resource_new(struct pw_impl_client *client, uint32_t id, uint32_t permissions, const char *type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:43
void pw_resource_error(struct pw_resource *resource, int res, const char *error)
Generate an error for a resource.
Definition: resource.c:255
static int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
Insert data in the map at an index.
Definition: map.h:133
SPA_EXPORT int pw_resource_set_bound_id(struct pw_resource *resource, uint32_t global_id)
Notify global id this resource is bound to.
Definition: resource.c:209
SPA_EXPORT struct pw_protocol * pw_resource_get_protocol(struct pw_resource *resource)
Get the protocol used for this resource.
Definition: resource.c:153
void(* error)(void *data, int seq, int res, const char *message)
an error occurred on the resource
Definition: resource.h:75
struct pw_protocol * pw_resource_get_protocol(struct pw_resource *resource)
Get the protocol used for this resource.
Definition: resource.c:153
SPA_EXPORT void pw_resource_add_listener(struct pw_resource *resource, struct spa_hook *listener, const struct pw_resource_events *events, void *data)
Add an event listener.
Definition: resource.c:165
static uint32_t int int const char * message
Definition: core.h:326
void void pw_resource_errorf_id(struct pw_resource *resource, uint32_t id, int res, const char *error,...) SPA_PRINTF_FUNC(4
uint32_t pw_resource_get_permissions(struct pw_resource *resource)
Get the permissions of this resource.
Definition: resource.c:139
#define pw_log_debug(...)
int pw_resource_set_bound_id(struct pw_resource *resource, uint32_t global_id)
Notify global id this resource is bound to.
Definition: resource.c:209
SPA_EXPORT void pw_resource_errorf_id(struct pw_resource *resource, uint32_t id, int res, const char *error,...)
Definition: resource.c:246
SPA_EXPORT void pw_resource_add_object_listener(struct pw_resource *resource, struct spa_hook *listener, const void *funcs, void *data)
Set the resource implementation.
Definition: resource.c:174
void * pw_resource_get_user_data(struct pw_resource *resource)
Get the user data for the resource, the size was given in pw_resource_new.
Definition: resource.c:159
SPA_EXPORT uint32_t pw_resource_get_id(struct pw_resource *resource)
Get the unique id of this resource.
Definition: resource.c:133
SPA_EXPORT int pw_resource_install_marshal(struct pw_resource *this, bool implementor)
install a marshal function on a resource
Definition: resource.c:105
void pw_resource_add_object_listener(struct pw_resource *resource, struct spa_hook *listener, const void *funcs, void *data)
Set the resource implementation.
Definition: resource.c:174
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:264
int pw_resource_ping(struct pw_resource *resource, int seq)
Generate an ping event for a resource.
Definition: resource.c:195
struct pw_impl_client * pw_resource_get_client(struct pw_resource *resource)
Get the client owning this resource.
Definition: resource.c:127
struct pw_resource * pw_resource_new(struct pw_impl_client *client, uint32_t id, uint32_t permissions, const char *type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:43
struct pw_control this
Definition: control.c:34
Definition: protocol.h:80
SPA_EXPORT const struct pw_protocol_marshal * pw_resource_get_marshal(struct pw_resource *resource)
Get the marshal functions for the resource.
Definition: resource.c:189
SPA_EXPORT void pw_resource_remove(struct pw_resource *resource)
Remove a resource, like pw_resource_destroy but without sending a remove_id message to the client.
Definition: resource.c:291
static uint32_t int seq
Definition: core.h:325
#define PW_PROTOCOL_MARSHAL_FLAG_IMPL
marshal for implementations
Definition: protocol.h:83
SPA_EXPORT void * pw_resource_get_user_data(struct pw_resource *resource)
Get the user data for the resource, the size was given in pw_resource_new.
Definition: resource.c:159
const char * pw_resource_get_type(struct pw_resource *resource, uint32_t *version)
Get the type and optionally the version of this resource.
Definition: resource.c:145
Resource events.
Definition: resource.h:64
SPA_EXPORT int pw_resource_ping(struct pw_resource *resource, int seq)
Generate an ping event for a resource.
Definition: resource.c:195
const char * type
interface type
Definition: protocol.h:81
void pw_resource_add_listener(struct pw_resource *resource, struct spa_hook *listener, const struct pw_resource_events *events, void *data)
Add an event listener.
Definition: resource.c:165
uint32_t version
Definition: resource.h:66
uint32_t version
version
Definition: protocol.h:82
void void struct spa_hook_list * pw_resource_get_object_listeners(struct pw_resource *resource)
Get the list of object listeners from a resource.
Definition: resource.c:183
const struct pw_protocol_marshal * pw_resource_get_marshal(struct pw_resource *resource)
Get the marshal functions for the resource.
Definition: resource.c:189
SPA_EXPORT uint32_t pw_resource_get_bound_id(struct pw_resource *resource)
Get the global id this resource is bound to or SPA_ID_INVALID when not bound.
Definition: resource.c:222