PipeWire 1.6.8

Loading...
Searching...
No Matches
client.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_CLIENT_H
6#define PIPEWIRE_CLIENT_H
7
8#include <spa/utils/defs.h>
9#include <spa/param/param.h>
10
11#include <pipewire/type.h>
12#include <pipewire/proxy.h>
13#include <pipewire/permission.h>
14
15#ifdef __cplusplus
16 extern "C" {
17#endif
18
22
27#define PW_TYPE_INTERFACE_Client PW_TYPE_INFO_INTERFACE_BASE "Client"
28
29#define PW_CLIENT_PERM_MASK PW_PERM_RWXM
30
31#define PW_VERSION_CLIENT 3
32 struct pw_client;
33
34#ifndef PW_API_CLIENT_IMPL
35#define PW_API_CLIENT_IMPL static inline
36#endif
37
38/* default ID of the current client after connect */
39#define PW_ID_CLIENT 1
40
42 struct pw_client_info {
43 uint32_t id;
44#define PW_CLIENT_CHANGE_MASK_PROPS (1 << 0)
45#define PW_CLIENT_CHANGE_MASK_ALL ((1 << 1)-1)
46 uint64_t change_mask;
47 struct spa_dict *props;
48};
49
51 struct pw_client_info *
52 pw_client_info_update(struct pw_client_info *info,
53 const struct pw_client_info *update);
55 struct pw_client_info *
56 pw_client_info_merge(struct pw_client_info *info,
57 const struct pw_client_info *update, bool reset);
59 void pw_client_info_free(struct pw_client_info *info);
60
61
62#define PW_CLIENT_EVENT_INFO 0
63#define PW_CLIENT_EVENT_PERMISSIONS 1
64#define PW_CLIENT_EVENT_NUM 2
65
67 struct pw_client_events {
68#define PW_VERSION_CLIENT_EVENTS 0
69 uint32_t version;
75 void (*info) (void *data, const struct pw_client_info *info);
82 * \param index the index of the first permission entry
83 * \param n_permissions the number of permissions
84 * \param permissions the permissions
85 */
86 void (*permissions) (void *data,
87 uint32_t index,
88 uint32_t n_permissions,
89 const struct pw_permission *permissions);
90};
91
92
93#define PW_CLIENT_METHOD_ADD_LISTENER 0
94#define PW_CLIENT_METHOD_ERROR 1
95#define PW_CLIENT_METHOD_UPDATE_PROPERTIES 2
96#define PW_CLIENT_METHOD_GET_PERMISSIONS 3
97#define PW_CLIENT_METHOD_UPDATE_PERMISSIONS 4
98#define PW_CLIENT_METHOD_NUM 5
99
101 struct pw_client_methods {
102#define PW_VERSION_CLIENT_METHODS 0
103 uint32_t version;
104
105 int (*add_listener) (void *object,
106 struct spa_hook *listener,
107 const struct pw_client_events *events,
108 void *data);
118 int (*error) (void *object, uint32_t id, int res, const char *message);
123 *
124 * This requires W and X permissions on the client.
125 */
126 int (*update_properties) (void *object, const struct spa_dict *props);
127
138 int (*get_permissions) (void *object, uint32_t index, uint32_t num);
154 int (*update_permissions) (void *object, uint32_t n_permissions,
155 const struct pw_permission *permissions);
156};
157
160 PW_API_CLIENT_IMPL int pw_client_add_listener(struct pw_client *object,
161 struct spa_hook *listener,
162 const struct pw_client_events *events,
163 void *data)
164{
165 return spa_api_method_r(int, -ENOTSUP, pw_client, (struct spa_interface*)object, add_listener, 0,
166 listener, events, data);
167}
170 PW_API_CLIENT_IMPL int pw_client_error(struct pw_client *object, uint32_t id, int res, const char *message)
171{
172 return spa_api_method_r(int, -ENOTSUP, pw_client, (struct spa_interface*)object, error, 0,
173 id, res, message);
174}
177 PW_API_CLIENT_IMPL int pw_client_update_properties(struct pw_client *object, const struct spa_dict *props)
178{
179 return spa_api_method_r(int, -ENOTSUP, pw_client, (struct spa_interface*)object, update_properties, 0,
180 props);
181}
183 * \sa pw_client_methods.get_permissions */
184 PW_API_CLIENT_IMPL int pw_client_get_permissions(struct pw_client *object, uint32_t index, uint32_t num)
185{
186 return spa_api_method_r(int, -ENOTSUP, pw_client, (struct spa_interface*)object, get_permissions, 0,
187 index, num);
188}
191 PW_API_CLIENT_IMPL int pw_client_update_permissions(struct pw_client *object, uint32_t n_permissions,
192 const struct pw_permission *permissions)
193{
194 return spa_api_method_r(int, -ENOTSUP, pw_client, (struct spa_interface*)object, update_permissions, 0,
195 n_permissions, permissions);
196}
197
198
200 */
201
202#ifdef __cplusplus
203} /* extern "C" */
204#endif
205
206#endif /* PIPEWIRE_CLIENT_H */
defs.h
spa/utils/defs.h
pw_client_info_free
void pw_client_info_free(struct pw_client_info *info)
Free a pw_client_info.
Definition introspect.c:514
pw_client_add_listener
PW_API_CLIENT_IMPL int pw_client_add_listener(struct pw_client *object, struct spa_hook *listener, const struct pw_client_events *events, void *data)
Definition client.h:183
pw_client_info_update
struct pw_client_info * pw_client_info_update(struct pw_client_info *info, const struct pw_client_info *update)
Update an existing pw_client_info with update with reset.
Definition introspect.c:507
pw_client_info_merge
struct pw_client_info * pw_client_info_merge(struct pw_client_info *info, const struct pw_client_info *update, bool reset)
Merge an existing pw_client_info with update.
Definition introspect.c:481
pw_client_update_permissions
PW_API_CLIENT_IMPL int pw_client_update_permissions(struct pw_client *object, uint32_t n_permissions, const struct pw_permission *permissions)
Manage the permissions of the global objects for this client.
Definition client.h:214
pw_client_update_properties
PW_API_CLIENT_IMPL int pw_client_update_properties(struct pw_client *object, const struct spa_dict *props)
Update client properties.
Definition client.h:200
pw_client_get_permissions
PW_API_CLIENT_IMPL int pw_client_get_permissions(struct pw_client *object, uint32_t index, uint32_t num)
Get client permissions.
Definition client.h:207
pw_client_error
PW_API_CLIENT_IMPL int pw_client_error(struct pw_client *object, uint32_t id, int res, const char *message)
Send an error to a client.
Definition client.h:193
PW_API_CLIENT_IMPL
#define PW_API_CLIENT_IMPL
Definition client.h:44
id
uint32_t id
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
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
param.h
spa/param/param.h
permission.h
pipewire/permission.h
proxy.h
pipewire/proxy.h
type.h
pipewire/type.h
pw_client_events
Client events.
Definition client.h:82
pw_client_events::version
uint32_t version
Definition client.h:85
pw_client_events::permissions
void(* permissions)(void *data, uint32_t index, uint32_t n_permissions, const struct pw_permission *permissions)
Notify a client permission.
Definition client.h:102
pw_client_info
The client information.
Definition client.h:52
pw_client_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition client.h:58
pw_client_methods
Client methods.
Definition client.h:123
pw_client_methods::update_properties
int(* update_properties)(void *object, const struct spa_dict *props)
Update client properties.
Definition client.h:149
pw_client_methods::update_permissions
int(* update_permissions)(void *object, uint32_t n_permissions, const struct pw_permission *permissions)
Manage the permissions of the global objects for this client.
Definition client.h:177
pw_client_methods::get_permissions
int(* get_permissions)(void *object, uint32_t index, uint32_t num)
Get client permissions.
Definition client.h:161
pw_client_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_client_events *events, void *data)
Definition client.h:128
pw_client
pw_permission
Definition permission.h:69
pw_permission::permissions
uint32_t permissions
bitmask of above permissions
Definition permission.h:71
spa_dict
Definition dict.h:51
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_interface
Definition hook.h:148