PipeWire  0.3.15
client.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_CLIENT_H
26 #define PIPEWIRE_CLIENT_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <spa/utils/defs.h>
33 #include <spa/param/param.h>
34 
35 #include <pipewire/proxy.h>
36 #include <pipewire/permission.h>
37 
38 #define PW_TYPE_INTERFACE_Client PW_TYPE_INFO_INTERFACE_BASE "Client"
39 
40 #define PW_VERSION_CLIENT 3
41 struct pw_client;
42 
43 /* default ID of the current client after connect */
44 #define PW_ID_CLIENT 1
45 
48  uint32_t id;
49 #define PW_CLIENT_CHANGE_MASK_PROPS (1 << 0)
50 #define PW_CLIENT_CHANGE_MASK_ALL ((1 << 1)-1)
51  uint64_t change_mask;
52  struct spa_dict *props;
53 };
54 
56 struct pw_client_info *
58  const struct pw_client_info *update);
59 
61 void pw_client_info_free(struct pw_client_info *info);
62 
63 
64 #define PW_CLIENT_EVENT_INFO 0
65 #define PW_CLIENT_EVENT_PERMISSIONS 1
66 #define PW_CLIENT_EVENT_NUM 2
67 
70 #define PW_VERSION_CLIENT_EVENTS 0
71  uint32_t version;
77  void (*info) (void *object, const struct pw_client_info *info);
88  void (*permissions) (void *object,
89  uint32_t index,
90  uint32_t n_permissions,
91  const struct pw_permission *permissions);
92 };
93 
94 
95 #define PW_CLIENT_METHOD_ADD_LISTENER 0
96 #define PW_CLIENT_METHOD_ERROR 1
97 #define PW_CLIENT_METHOD_UPDATE_PROPERTIES 2
98 #define PW_CLIENT_METHOD_GET_PERMISSIONS 3
99 #define PW_CLIENT_METHOD_UPDATE_PERMISSIONS 4
100 #define PW_CLIENT_METHOD_NUM 5
101 
104 #define PW_VERSION_CLIENT_METHODS 0
105  uint32_t version;
106 
107  int (*add_listener) (void *object,
108  struct spa_hook *listener,
109  const struct pw_client_events *events,
110  void *data);
118  int (*error) (void *object, uint32_t id, int res, const char *message);
124  int (*update_properties) (void *object, const struct spa_dict *props);
125 
134  int (*get_permissions) (void *object, uint32_t index, uint32_t num);
148  int (*update_permissions) (void *object, uint32_t n_permissions,
149  const struct pw_permission *permissions);
150 };
151 
152 #define pw_client_method(o,method,version,...) \
153 ({ \
154  int _res = -ENOTSUP; \
155  spa_interface_call_res((struct spa_interface*)o, \
156  struct pw_client_methods, _res, \
157  method, version, ##__VA_ARGS__); \
158  _res; \
159 })
160 
161 #define pw_client_add_listener(c,...) pw_client_method(c,add_listener,0,__VA_ARGS__)
162 #define pw_client_error(c,...) pw_client_method(c,error,0,__VA_ARGS__)
163 #define pw_client_update_properties(c,...) pw_client_method(c,update_properties,0,__VA_ARGS__)
164 #define pw_client_get_permissions(c,...) pw_client_method(c,get_permissions,0,__VA_ARGS__)
165 #define pw_client_update_permissions(c,...) pw_client_method(c,update_permissions,0,__VA_ARGS__)
166 
167 #ifdef __cplusplus
168 } /* extern "C" */
169 #endif
170 
171 #endif /* PIPEWIRE_CLIENT_H */
res
static uint32_t int int res
Definition: core.h:326
id
static uint32_t id
Definition: core.h:325
pw_introspect::pw_client_info_update
struct pw_client_info * pw_client_info_update(struct pw_client_info *info, const struct pw_client_info *update)
Update and existing pw_client_info with update.
Definition: introspect.c:423
data
Definition: filter.c:71
pw_client_methods::version
uint32_t version
Definition: client.h:105
pw_permission
a PipeWire permission
Definition: permission.h:61
pw_client_info::id
uint32_t id
id of the global
Definition: client.h:48
permission.h
pw_client_events::info
void(* info)(void *object, const struct pw_client_info *info)
Notify client info.
Definition: client.h:77
message
static uint32_t int int const char * message
Definition: core.h:326
pw_client_events::version
uint32_t version
Definition: client.h:71
pw_permission::permissions
uint32_t permissions
bitmask of above permissions
Definition: permission.h:63
pw_client_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: client.h:51
pw_client_methods::error
int(* error)(void *object, uint32_t id, int res, const char *message)
Send an error to a client.
Definition: client.h:118
pw_client_info
The client information.
Definition: client.h:47
pw_client_events::permissions
void(* permissions)(void *object, uint32_t index, uint32_t n_permissions, const struct pw_permission *permissions)
Notify a client permission.
Definition: client.h:88
pw_client_info::props
struct spa_dict * props
extra properties
Definition: client.h:52
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:107
proxy.h
pw_introspect::pw_client_info_free
void pw_client_info_free(struct pw_client_info *info)
Free a pw_client_info.
Definition: introspect.c:447
pw_client_methods
Client methods.
Definition: client.h:103
pw_client_events
Client events.
Definition: client.h:69
pw_client_methods::update_properties
int(* update_properties)(void *object, const struct spa_dict *props)
Update client properties.
Definition: client.h:124
pw_client_methods::get_permissions
int(* get_permissions)(void *object, uint32_t index, uint32_t num)
Get client permissions.
Definition: client.h:134
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:148