PipeWire: pipewire/resource.h Source File

PipeWire 1.4.1 |

Loading...
Searching...
No Matches
resource.h
Go to the documentation of this file.
1/* PipeWire */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef PIPEWIRE_RESOURCE_H
6#define PIPEWIRE_RESOURCE_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/hook.h>
13
29
30
35struct pw_resource;
36
37#include <pipewire/impl-client.h>
38
40struct pw_resource_events {
41#define PW_VERSION_RESOURCE_EVENTS 0
42 uint32_t version;
43
45 void (*destroy) (void *data);
46
48 void (*pong) (void *data, int seq);
49
51 void (*error) (void *data, int seq, int res, const char *message);
52};
53
55struct pw_resource *
56 pw_resource_new(struct pw_impl_client *client,
57 uint32_t id,
58 uint32_t permissions,
59 const char *type,
60 uint32_t version,
61 size_t user_data_size );
62
64void pw_resource_destroy(struct pw_resource *resource);
65
68void pw_resource_remove(struct pw_resource *resource);
69
71struct pw_impl_client *pw_resource_get_client(struct pw_resource *resource);
72
74uint32_t pw_resource_get_id(struct pw_resource *resource);
75
77uint32_t pw_resource_get_permissions(struct pw_resource *resource);
78
80const char *pw_resource_get_type(struct pw_resource *resource, uint32_t *version);
81
83struct pw_protocol *pw_resource_get_protocol(struct pw_resource *resource);
84
86void *pw_resource_get_user_data(struct pw_resource *resource);
87
89void pw_resource_add_listener(struct pw_resource *resource,
90 struct spa_hook *listener,
91 const struct pw_resource_events *events,
92 void *data);
93
95void pw_resource_add_object_listener(struct pw_resource *resource,
96 struct spa_hook *listener,
97 const void *funcs,
98 void *data);
99
102int pw_resource_ping(struct pw_resource *resource, int seq);
103
105void pw_resource_ref(struct pw_resource *resource);
106void pw_resource_unref(struct pw_resource *resource);
107
109int pw_resource_set_bound_id(struct pw_resource *resource, uint32_t global_id);
110
112uint32_t pw_resource_get_bound_id(struct pw_resource *resource);
113
115void pw_resource_error(struct pw_resource *resource, int res, const char *error);
116void pw_resource_errorf(struct pw_resource *resource, int res, const char *error, ...) SPA_PRINTF_FUNC(3, 4);
117void pw_resource_errorf_id(struct pw_resource *resource, uint32_t id, int res, const char *error, ...) SPA_PRINTF_FUNC(4, 5);
118
120struct spa_hook_list *pw_resource_get_object_listeners(struct pw_resource *resource);
121
123const struct pw_protocol_marshal *pw_resource_get_marshal(struct pw_resource *resource);
124
126int pw_resource_install_marshal(struct pw_resource *resource, bool implementor);
127
128#define pw_resource_notify(r,type,event,version,...) \
129 spa_hook_list_call(pw_resource_get_object_listeners(r), \
130 type, event, version, ## __VA_ARGS__)
131
132#define pw_resource_call(r,type,method,version,...) \
133 spa_interface_call((struct spa_interface*)r, \
134 type, method, version, ##__VA_ARGS__)
135
136#define pw_resource_call_res(r,type,method,version,...) \
137({ \
138 int _res = -ENOTSUP; \
139 spa_interface_call_res((struct spa_interface*)r, \
140 type, _res, method, version, ##__VA_ARGS__); \
141 _res; \
142})
143
144
148
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif /* PIPEWIRE_RESOURCE_H */
seq
uint32_t int seq
Definition core.h:432
message
uint32_t int int const char * message
Definition core.h:433
res
uint32_t int int res
Definition core.h:433
pw_resource_unref
void pw_resource_unref(struct pw_resource *resource)
Definition resource.c:282
pw_resource_add_listener
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:149
pw_resource_remove
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:338
pw_resource_get_permissions
uint32_t pw_resource_get_permissions(struct pw_resource *resource)
Get the permissions of this resource.
Definition resource.c:123
pw_resource_get_protocol
struct pw_protocol * pw_resource_get_protocol(struct pw_resource *resource)
Get the protocol used for this resource.
Definition resource.c:137
pw_resource_install_marshal
int pw_resource_install_marshal(struct pw_resource *resource, bool implementor)
install a marshal function on a resource
Definition resource.c:89
pw_resource_get_bound_id
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:216
pw_resource_errorf
void pw_resource_errorf(struct pw_resource *resource, int res, const char *error,...)
Definition resource.c:237
pw_resource_get_client
struct pw_impl_client * pw_resource_get_client(struct pw_resource *resource)
Get the client owning this resource.
Definition resource.c:111
pw_resource_get_marshal
const struct pw_protocol_marshal * pw_resource_get_marshal(struct pw_resource *resource)
Get the marshal functions for the resource.
Definition resource.c:173
pw_resource_get_object_listeners
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:167
pw_resource_error
void pw_resource_error(struct pw_resource *resource, int res, const char *error)
Generate an error for a resource.
Definition resource.c:261
pw_resource_ping
int pw_resource_ping(struct pw_resource *resource, int seq)
Generate an ping event for a resource.
Definition resource.c:179
pw_resource_add_object_listener
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:158
pw_resource_ref
void pw_resource_ref(struct pw_resource *resource)
ref/unref a resource, Since 0.3.52
Definition resource.c:275
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition resource.c:313
pw_resource_errorf_id
void pw_resource_errorf_id(struct pw_resource *resource, uint32_t id, int res, const char *error,...)
Definition resource.c:249
pw_resource_new
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:26
pw_resource_set_bound_id
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:193
pw_resource_get_id
uint32_t pw_resource_get_id(struct pw_resource *resource)
Get the unique id of this resource.
Definition resource.c:117
pw_resource_get_user_data
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:143
pw_resource_get_type
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:129
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition defs.h:295
hook.h
spa/utils/hook.h
impl-client.h
pipewire/impl-client.h
pw_impl_client
pw_protocol_marshal
Definition protocol.h:77
pw_protocol
pw_resource_events
Resource events.
Definition resource.h:45
pw_resource_events::destroy
void(* destroy)(void *data)
The resource is destroyed.
Definition resource.h:51
pw_resource_events::pong
void(* pong)(void *data, int seq)
a reply to a ping event completed
Definition resource.h:54
pw_resource_events::version
uint32_t version
Definition resource.h:48
pw_resource_events::error
void(* error)(void *data, int seq, int res, const char *message)
an error occurred on the resource
Definition resource.h:57
pw_resource
spa_hook_list
A list of hooks.
Definition hook.h:416
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427