PipeWire: proxy.h Source File

PipeWire 0.3.5

proxy.h
Go to the documentation of this file.
1 /* PipeWire
2 *
3 * Copyright © 2018 Wim Taymans
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #ifndef PIPEWIRE_PROXY_H
26 #define PIPEWIRE_PROXY_H
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #include <spa/utils/hook.h>
33
101 struct pw_proxy;
102
103 #include <pipewire/protocol.h>
104
106 struct pw_proxy_events {
107 #define PW_VERSION_PROXY_EVENTS 0
108 uint32_t version;
109
111 void (*destroy) (void *data);
112
114 void (*bound) (void *data, uint32_t global_id);
115
118 void (*removed) (void *data);
119
121 void (*done) (void *data, int seq);
122
124 void (*error) (void *data, int seq, int res, const char *message);
125 };
126
129 struct pw_proxy *
130 pw_proxy_new(struct pw_proxy *factory,
131 const char *type,
132 uint32_t version,
133 size_t user_data_size );
134
136 void pw_proxy_add_listener(struct pw_proxy *proxy,
137 struct spa_hook *listener,
138 const struct pw_proxy_events *events,
139 void *data);
140
143 void pw_proxy_add_object_listener(struct pw_proxy *proxy,
144 struct spa_hook *listener,
145 const void *funcs,
146 void *data );
147
149 void pw_proxy_destroy(struct pw_proxy *proxy);
150
152 void *pw_proxy_get_user_data(struct pw_proxy *proxy);
153
155 uint32_t pw_proxy_get_id(struct pw_proxy *proxy);
156
158 const char *pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version);
159
161 struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy);
162
165 int pw_proxy_sync(struct pw_proxy *proxy, int seq);
166
169 int pw_proxy_set_bound_id(struct pw_proxy *proxy, uint32_t global_id);
172 uint32_t pw_proxy_get_bound_id(struct pw_proxy *proxy);
173
175 int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error);
176 int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error, ...) SPA_PRINTF_FUNC(3, 4);
177
179 struct spa_hook_list *pw_proxy_get_object_listeners(struct pw_proxy *proxy);
180
182 const struct pw_protocol_marshal *pw_proxy_get_marshal(struct pw_proxy *proxy);
183
185 int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor);
186
187 #define pw_proxy_notify(p,type,event,version,...) \
188 spa_hook_list_call(pw_proxy_get_object_listeners(p), \
189 type, event, version, ## __VA_ARGS__)
190
191 #define pw_proxy_call(p,type,method,version,...) \
192 spa_interface_call((struct spa_interface*)p, \
193 type, method, version, ##__VA_ARGS__)
194
195 #define pw_proxy_call_res(p,type,method,version,...) \
196 ({ \
197 int _res = -ENOTSUP; \
198 spa_interface_call_res((struct spa_interface*)p, \
199 type, _res, method, version, ##__VA_ARGS__); \
200 _res; \
201 })
202
203 #ifdef __cplusplus
204 }
205 #endif
206
207 #endif /* PIPEWIRE_PROXY_H */
res
static uint32_t int int res
Definition: core.h:323
pw_proxy_error
SPA_EXPORT int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error)
Generate an error for a proxy.
Definition: proxy.c:329
pw_proxy_set_bound_id
SPA_EXPORT 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:160
pw_map::pw_map_remove
static void pw_map_remove(struct pw_map *map, uint32_t id)
Remove an item at index.
Definition: map.h:157
pw_proxy_events::version
uint32_t version
Definition: proxy.h:108
pw_proxy_get_bound_id
uint32_t pw_proxy_get_bound_id(struct pw_proxy *proxy)
Get the global id bound to this proxy of SPA_ID_INVALID when not bound to a global.
Definition: proxy.c:168
pw_log::pw_log_error
#define pw_log_error(...)
pw_proxy_error
int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error)
Generate an error for a proxy.
Definition: proxy.c:329
pw_proxy_get_id
SPA_EXPORT uint32_t pw_proxy_get_id(struct pw_proxy *proxy)
Get the local id of the proxy.
Definition: proxy.c:154
pw_proxy_unref
SPA_EXPORT void pw_proxy_unref(struct pw_proxy *proxy)
Definition: proxy.c:288
pw_proxy_get_type
SPA_EXPORT const char * pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version)
Get the type and version of the proxy.
Definition: proxy.c:174
pw_core_error
return pw_core_error(core, id, seq, res, buffer)
pw_proxy_add_object_listener
void pw_proxy_add_object_listener(struct pw_proxy *proxy, struct spa_hook *listener, const void *funcs, void *data)
Add a listener for the events received from the remote object.
Definition: proxy.c:205
pw_protocol
Manages protocols and their implementation.
data
Definition: filter.c:70
pw_proxy_get_object_listeners
int struct spa_hook_list * pw_proxy_get_object_listeners(struct pw_proxy *proxy)
Get the listener of proxy.
Definition: proxy.c:340
pw_proxy_get_marshal
const struct pw_protocol_marshal * pw_proxy_get_marshal(struct pw_proxy *proxy)
Get the marshal functions for the proxy.
Definition: proxy.c:346
pw_proxy_events::destroy
void(* destroy)(void *data)
The proxy is destroyed.
Definition: proxy.h:111
pw_proxy_get_core
SPA_EXPORT struct pw_core * pw_proxy_get_core(struct pw_proxy *proxy)
Definition: proxy.c:182
pw_proxy_get_user_data
SPA_EXPORT void * pw_proxy_get_user_data(struct pw_proxy *proxy)
Get the user_data.
Definition: proxy.c:148
pw_protocol_get_marshal
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:160
pw_proxy_set_bound_id
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:160
pw_proxy_add_listener
SPA_EXPORT 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:196
pw_proxy::pw_proxy_destroy
SPA_EXPORT void pw_proxy_destroy(struct pw_proxy *proxy)
Destroy a proxy object.
Definition: proxy.c:231
impl
Definition: control.c:33
pw_proxy_events
Proxy events, use pw_proxy_add_listener.
Definition: proxy.h:106
pw_proxy::pw_proxy_new
SPA_EXPORT struct pw_proxy * pw_proxy_new(struct pw_proxy *factory, const char *type, uint32_t version, size_t user_data_size)
Create a proxy object with a given id and type.
Definition: proxy.c:91
r
static uint32_t int int const char int r
Definition: core.h:335
pw_map::pw_map_insert_new
static uint32_t pw_map_insert_new(struct pw_map *map, void *data)
Insert data in the map.
Definition: map.h:105
type.h
pw_proxy_remove
void pw_proxy_remove(struct pw_proxy *proxy)
called when cleaning up or when the server removed the resource.
Definition: proxy.c:263
protocol.h
pw_proxy_install_marshal
SPA_EXPORT int pw_proxy_install_marshal(struct pw_proxy *this, bool implementor)
Install a marshal function on a proxy.
Definition: proxy.c:123
pw_proxy_get_object_listeners
SPA_EXPORT struct spa_hook_list * pw_proxy_get_object_listeners(struct pw_proxy *proxy)
Get the listener of proxy.
Definition: proxy.c:340
pw_proxy_get_marshal
SPA_EXPORT const struct pw_protocol_marshal * pw_proxy_get_marshal(struct pw_proxy *proxy)
Get the marshal functions for the proxy.
Definition: proxy.c:346
message
static uint32_t int int const char * message
Definition: core.h:323
va_start
va_start(args, message)
pw_log::pw_log_debug
#define pw_log_debug(...)
pw_proxy
Represents an object on the client side.
pw_proxy_events::bound
void(* bound)(void *data, uint32_t global_id)
a proxy is bound to a global id
Definition: proxy.h:114
pw_proxy_events::done
void(* done)(void *data, int seq)
a reply to a sync method completed
Definition: proxy.h:121
pw_proxy_get_type
const char * pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version)
Get the type and version of the proxy.
Definition: proxy.c:174
pw_proxy_get_user_data
void * pw_proxy_get_user_data(struct pw_proxy *proxy)
Get the user_data.
Definition: proxy.c:148
pw_proxy_install_marshal
int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor)
Install a marshal function on a proxy.
Definition: proxy.c:123
pw_proxy_events::removed
void(* removed)(void *data)
a proxy is removed from the server.
Definition: proxy.h:118
pw_proxy_events::error
void(* error)(void *data, int seq, int res, const char *message)
an error occured on the proxy
Definition: proxy.h:124
pw_proxy_errorf
SPA_EXPORT int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error,...)
Definition: proxy.c:314
pw_proxy_errorf
int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error,...) SPA_PRINTF_FUNC(3
proxy.h
pw_core_destroy
#define pw_core_destroy(c,...)
Definition: core.h:370
pw_proxy_get_id
uint32_t pw_proxy_get_id(struct pw_proxy *proxy)
Get the local id of the proxy.
Definition: proxy.c:154
pw_proxy_sync
int pw_proxy_sync(struct pw_proxy *proxy, int seq)
Generate an sync method for a proxy.
Definition: proxy.c:301
pw_proxy_get_bound_id
SPA_EXPORT uint32_t pw_proxy_get_bound_id(struct pw_proxy *proxy)
Get the global id bound to this proxy of SPA_ID_INVALID when not bound to a global.
Definition: proxy.c:168
log.h
pw_proxy_add_listener
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:196
va_end
va_end(args)
NAME
#define NAME
Definition: proxy.c:35
pw_proxy_init
int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version)
Definition: proxy.c:43
pw_proxy_sync
SPA_EXPORT int pw_proxy_sync(struct pw_proxy *proxy, int seq)
Generate an sync method for a proxy.
Definition: proxy.c:301
pw_proxy_get_protocol
struct pw_protocol * pw_proxy_get_protocol(struct pw_proxy *proxy)
Get the protocol used for the proxy.
Definition: proxy.c:188
core.h
impl::this
struct pw_control this
Definition: control.c:34
pw_protocol_marshal
Definition: protocol.h:80
pw_proxy_get_protocol
SPA_EXPORT struct pw_protocol * pw_proxy_get_protocol(struct pw_proxy *proxy)
Get the protocol used for the proxy.
Definition: proxy.c:188
seq
static uint32_t int seq
Definition: core.h:322
PW_PROTOCOL_MARSHAL_FLAG_IMPL
#define PW_PROTOCOL_MARSHAL_FLAG_IMPL
marshal for implementations
Definition: protocol.h:83
pw_core_sync
#define pw_core_sync(c,...)
Definition: core.h:315
pw_protocol_marshal::type
const char * type
interface type
Definition: protocol.h:81
pw_protocol_marshal::version
uint32_t version
version
Definition: protocol.h:82
pw_proxy_add_object_listener
SPA_EXPORT void pw_proxy_add_object_listener(struct pw_proxy *proxy, struct spa_hook *listener, const void *funcs, void *data)
Add a listener for the events received from the remote object.
Definition: proxy.c:205