PipeWire: proxy.h Source File

PipeWire 0.3.70

Loading...
Searching...
No Matches
proxy.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_PROXY_H
6#define PIPEWIRE_PROXY_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/hook.h>
13
86struct pw_proxy;
87
88#include <pipewire/protocol.h>
89
91struct pw_proxy_events {
92#define PW_VERSION_PROXY_EVENTS 1
93 uint32_t version;
94
96 void (*destroy) (void *data);
97
99 void (*bound) (void *data, uint32_t global_id);
100
103 void (*removed) (void *data);
104
106 void (*done) (void *data, int seq);
107
109 void (*error) (void *data, int seq, int res, const char *message);
110
111 void (*bound_props) (void *data, uint32_t global_id, const struct spa_dict *props);
112};
113
114/* Make a new proxy object. The id can be used to bind to a remote object and
115 * can be retrieved with \ref pw_proxy_get_id . */
116struct pw_proxy *
117 pw_proxy_new(struct pw_proxy *factory,
118 const char *type, /* interface type */
119 uint32_t version, /* interface version */
120 size_t user_data_size /* size of user data */);
121
123void pw_proxy_add_listener(struct pw_proxy *proxy,
124 struct spa_hook *listener,
125 const struct pw_proxy_events *events,
126 void *data);
127
130void pw_proxy_add_object_listener(struct pw_proxy *proxy,
131 struct spa_hook *listener,
132 const void *funcs,
133 void *data );
134
136void pw_proxy_destroy(struct pw_proxy *proxy);
137
138void pw_proxy_ref(struct pw_proxy *proxy);
139void pw_proxy_unref(struct pw_proxy *proxy);
140
142void *pw_proxy_get_user_data(struct pw_proxy *proxy);
143
145uint32_t pw_proxy_get_id(struct pw_proxy *proxy);
146
148const char *pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version);
149
151struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy);
152
155int pw_proxy_sync(struct pw_proxy *proxy, int seq);
156
159int pw_proxy_set_bound_id(struct pw_proxy *proxy, uint32_t global_id);
162uint32_t pw_proxy_get_bound_id(struct pw_proxy *proxy);
163
165int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error);
166int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error, ...) SPA_PRINTF_FUNC(3, 4);
167
169struct spa_hook_list *pw_proxy_get_object_listeners(struct pw_proxy *proxy);
170
172const struct pw_protocol_marshal *pw_proxy_get_marshal(struct pw_proxy *proxy);
173
175int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor);
176
177#define pw_proxy_notify(p,type,event,version,...) \
178 spa_hook_list_call(pw_proxy_get_object_listeners(p), \
179 type, event, version, ## __VA_ARGS__)
180
181#define pw_proxy_call(p,type,method,version,...) \
182 spa_interface_call((struct spa_interface*)p, \
183 type, method, version, ##__VA_ARGS__)
184
185#define pw_proxy_call_res(p,type,method,version,...) \
186({ \
187 int _res = -ENOTSUP; \
188 spa_interface_call_res((struct spa_interface*)p, \
189 type, _res, method, version, ##__VA_ARGS__); \
190 _res; \
191})
192
197#ifdef __cplusplus
198}
199#endif
200
201#endif /* PIPEWIRE_PROXY_H */
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:140
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:177
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:351
pw_proxy_get_user_data
void * pw_proxy_get_user_data(struct pw_proxy *proxy)
Get the user_data.
Definition: proxy.c:128
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:155
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:186
pw_proxy_new
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:71
pw_proxy_unref
void pw_proxy_unref(struct pw_proxy *proxy)
Definition: proxy.c:269
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:333
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:149
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:169
pw_proxy_sync
int pw_proxy_sync(struct pw_proxy *proxy, int seq)
Generate an sync method for a proxy.
Definition: proxy.c:305
pw_proxy_get_id
uint32_t pw_proxy_get_id(struct pw_proxy *proxy)
Get the local id of the proxy.
Definition: proxy.c:134
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:345
pw_proxy_ref
void pw_proxy_ref(struct pw_proxy *proxy)
Definition: proxy.c:298
pw_proxy_errorf
int pw_proxy_errorf(struct pw_proxy *proxy, int res, const char *error,...) 1(3
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:103
pw_proxy_destroy
void pw_proxy_destroy(struct pw_proxy *proxy)
destroy a proxy
Definition: proxy.c:211
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:273
hook.h
spa/utils/hook.h
protocol.h
pipewire/protocol.h
pw_protocol_marshal
Definition: protocol.h:77
pw_protocol
pw_proxy_events
Proxy events, use pw_proxy_add_listener.
Definition: proxy.h:96
pw_proxy_events::done
void(* done)(void *data, int seq)
a reply to a sync method completed
Definition: proxy.h:112
pw_proxy_events::bound_props
void(* bound_props)(void *data, uint32_t global_id, const struct spa_dict *props)
Definition: proxy.h:117
pw_proxy_events::version
uint32_t version
Definition: proxy.h:99
pw_proxy_events::removed
void(* removed)(void *data)
a proxy is removed from the server.
Definition: proxy.h:109
pw_proxy_events::bound
void(* bound)(void *data, uint32_t global_id)
a proxy is bound to a global id
Definition: proxy.h:105
pw_proxy_events::destroy
void(* destroy)(void *data)
The proxy is destroyed.
Definition: proxy.h:102
pw_proxy_events::error
void(* error)(void *data, int seq, int res, const char *message)
an error occurred on the proxy
Definition: proxy.h:115
pw_proxy
spa_dict
Definition: utils/dict.h:39
spa_hook_list
A list of hooks.
Definition: hook.h:320
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:331