PipeWire  0.3.5
impl-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_IMPL_CLIENT_H
26 #define PIPEWIRE_IMPL_CLIENT_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <spa/utils/hook.h>
33 
44 struct pw_impl_client;
45 
46 #include <pipewire/context.h>
47 #include <pipewire/global.h>
48 #include <pipewire/properties.h>
49 #include <pipewire/resource.h>
50 #include <pipewire/permission.h>
51 
84 #define PW_VERSION_IMPL_CLIENT_EVENTS 0
85  uint32_t version;
86 
88  void (*destroy) (void *data);
89 
91  void (*free) (void *data);
92 
94  void (*initialized) (void *data);
95 
97  void (*info_changed) (void *data, const struct pw_client_info *info);
98 
100  void (*resource_added) (void *data, struct pw_resource *resource);
101 
103  void (*resource_removed) (void *data, struct pw_resource *resource);
104 
108  void (*busy_changed) (void *data, bool busy);
109 };
110 
112 struct pw_impl_client *
114  struct pw_protocol *prototol,
115  struct pw_properties *properties,
116  size_t user_data_size );
117 
120 
122 int pw_impl_client_register(struct pw_impl_client *client,
123  struct pw_properties *properties);
124 
126 void *pw_impl_client_get_user_data(struct pw_impl_client *client);
127 
129 const struct pw_client_info *pw_impl_client_get_info(struct pw_impl_client *client);
130 
132 int pw_impl_client_update_properties(struct pw_impl_client *client, const struct spa_dict *dict);
133 
135 int pw_impl_client_update_permissions(struct pw_impl_client *client, uint32_t n_permissions,
136  const struct pw_permission *permissions);
137 
139 const struct pw_properties *pw_impl_client_get_properties(struct pw_impl_client *client);
140 
145 
148 
150 struct pw_resource *pw_impl_client_find_resource(struct pw_impl_client *client, uint32_t id);
151 
153 struct pw_global *pw_impl_client_get_global(struct pw_impl_client *client);
154 
156 void pw_impl_client_add_listener(struct pw_impl_client *client,
157  struct spa_hook *listener,
158  const struct pw_impl_client_events *events,
159  void *data);
160 
161 
164 void pw_impl_client_set_busy(struct pw_impl_client *client, bool busy);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* PIPEWIRE_IMPL_CLIENT_H */
PW_MEMBLOCK_FLAG_READWRITE
@ PW_MEMBLOCK_FLAG_READWRITE
Definition: mem.h:43
res
static uint32_t int int res
Definition: core.h:323
PW_VERSION_CLIENT
#define PW_VERSION_CLIENT
Definition: client.h:40
global.h
resource_data::resource
struct pw_resource * resource
Definition: impl-device.c:52
NAME
#define NAME
Definition: impl-client.c:31
pw_map::pw_map_lookup
static void * pw_map_lookup(struct pw_map *map, uint32_t id)
Find an item in the map.
Definition: map.h:169
pw_impl_client_set_busy
SPA_EXPORT void pw_impl_client_set_busy(struct pw_impl_client *client, bool busy)
Mark the client busy.
Definition: impl-client.c:636
pw_memblock::id
uint32_t id
unique id
Definition: mem.h:66
pw_impl_client_get_core_resource
SPA_EXPORT struct pw_resource * pw_impl_client_get_core_resource(struct pw_impl_client *client)
Get the client core resource.
Definition: impl-client.c:437
pw_log::pw_log_error
#define pw_log_error(...)
pw_impl_client::pw_impl_client_update_properties
SPA_EXPORT int pw_impl_client_update_properties(struct pw_impl_client *client, const struct spa_dict *dict)
Update client properties.
Definition: impl-client.c:539
PW_PERM_INVALID
#define PW_PERM_INVALID
Definition: permission.h:54
pw_impl_client_get_global
SPA_EXPORT struct pw_global * pw_impl_client_get_global(struct pw_impl_client *client)
Get the global associated with this client.
Definition: impl-client.c:449
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:367
pw_impl_client_find_resource
SPA_EXPORT struct pw_resource * pw_impl_client_find_resource(struct pw_impl_client *client, uint32_t id)
Get a resource with the given id.
Definition: impl-client.c:443
pw_mempool_destroy
void pw_mempool_destroy(struct pw_mempool *pool)
Clear and destroy a pool.
Definition: mem.c:167
pw_map::pw_map_init
static void pw_map_init(struct pw_map *map, size_t size, size_t extend)
Initialize a map.
Definition: map.h:76
resource_data
Definition: impl-core.c:37
PW_KEY_OBJECT_ID
#define PW_KEY_OBJECT_ID
a global object id
Definition: keys.h:70
pw_impl_client_get_properties
SPA_EXPORT const struct pw_properties * pw_impl_client_get_properties(struct pw_impl_client *client)
Get the client properties.
Definition: impl-client.c:455
pw_protocol
Manages protocols and their implementation.
pw_impl_client_find_resource
struct pw_resource * pw_impl_client_find_resource(struct pw_impl_client *client, uint32_t id)
Get a resource with the given id.
Definition: impl-client.c:443
data
Definition: filter.c:70
pw_impl_client_events::resource_added
void(* resource_added)(void *data, struct pw_resource *resource)
emited when a new resource is added for client
Definition: impl-client.h:100
resource_data::resource_listener
struct spa_hook resource_listener
Definition: impl-core.c:38
pw_memblock::flags
uint32_t flags
flags for the memory block on of enum pw_memblock_flags
Definition: mem.h:68
pw_impl_client_get_protocol
SPA_EXPORT struct pw_protocol * pw_impl_client_get_protocol(struct pw_impl_client *client)
Get the protocol used to create this client.
Definition: impl-client.c:431
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:65
pw_impl_client
PipeWire client object class.
PW_KEY_SEC_PID
#define PW_KEY_SEC_PID
Various keys related to the identity of a client process and its security.
Definition: keys.h:60
impl
Definition: control.c:33
pw_mempool_add_listener
void pw_mempool_add_listener(struct pw_mempool *pool, struct spa_hook *listener, const struct pw_mempool_events *events, void *data)
Listen for events.
Definition: mem.c:186
pw_impl_client_get_user_data
SPA_EXPORT void * pw_impl_client_get_user_data(struct pw_impl_client *client)
Get the client user data.
Definition: impl-client.c:461
PW_KEY_MODULE_ID
#define PW_KEY_MODULE_ID
module properties
Definition: keys.h:205
pw_global_add_listener
void pw_global_add_listener(struct pw_global *global, struct spa_hook *listener, const struct pw_global_events *events, void *data)
Add an event listener on the global.
Definition: global.c:252
r
static uint32_t int int const char int r
Definition: core.h:335
pw_impl_client_events
The events that a client can emit.
Definition: impl-client.h:83
pw_global
A global object visible to remote clients.
pw_permission
a PipeWire permission
Definition: permission.h:56
impl.h
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
pw_impl_client_get_global
struct pw_global * pw_impl_client_get_global(struct pw_impl_client *client)
Get the global associated with this client.
Definition: impl-client.c:449
PW_PERMISSION_INIT
#define PW_PERMISSION_INIT(id, p)
Definition: permission.h:61
pw_map::pw_map_for_each
static int pw_map_for_each(struct pw_map *map, int(*func)(void *item_data, void *data), void *data)
Iterate all map items.
Definition: map.h:188
pw_array
An array object.
Definition: array.h:43
pw_impl_client_get_user_data
void * pw_impl_client_get_user_data(struct pw_impl_client *client)
Get the client user data.
Definition: impl-client.c:461
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:256
permission.h
pw_impl_client_get_context
struct pw_context * pw_impl_client_get_context(struct pw_impl_client *client)
Get the context used to create this client.
Definition: impl-client.c:425
pw_properties::pw_properties_setf
SPA_EXPORT int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...)
Set a property value by format.
Definition: properties.c:428
pw_context_events
context events emited by the context object added with pw_context_add_listener
Definition: context.h:96
PW_KEY_SEC_UID
#define PW_KEY_SEC_UID
Client uid, set by protocol.
Definition: keys.h:61
pw_mempool_events
Definition: mem.h:85
pw_impl_client::pw_impl_client_destroy
SPA_EXPORT void pw_impl_client_destroy(struct pw_impl_client *client)
Destroy a client object.
Definition: impl-client.c:481
pw_memblock::fd
int fd
fd
Definition: mem.h:70
resource_data::object_listener
struct spa_hook object_listener
Definition: impl-core.c:39
pw_impl_client_events::busy_changed
void(* busy_changed)(void *data, bool busy)
emited when the client becomes busy processing an asynchronous message.
Definition: impl-client.h:108
PW_KEY_SEC_GID
#define PW_KEY_SEC_GID
client gid, set by protocol
Definition: keys.h:62
pw_context_find_global
struct pw_global * pw_context_find_global(struct pw_context *context, uint32_t id)
Find a context global by id.
pw_log::pw_log_debug
#define pw_log_debug(...)
pw_log::pw_log_warn
#define pw_log_warn(...)
pw_permission::permissions
uint32_t permissions
bitmask of above permissions
Definition: permission.h:58
PW_VERSION_RESOURCE_EVENTS
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:65
PW_CLIENT_CHANGE_MASK_PROPS
#define PW_CLIENT_CHANGE_MASK_PROPS
Definition: client.h:49
pw_impl_client_update_permissions
int pw_impl_client_update_permissions(struct pw_impl_client *client, uint32_t n_permissions, const struct pw_permission *permissions)
Update the client permissions.
Definition: impl-client.c:566
pw_impl_core
PipeWire core interface.
pw_client_info
The client information.
Definition: client.h:47
resource.h
pw_properties::pw_properties_update
SPA_EXPORT int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:258
PW_KEY_SEC_LABEL
#define PW_KEY_SEC_LABEL
client security label, set by protocol
Definition: keys.h:63
PW_VERSION_MEMPOOL_EVENTS
#define PW_VERSION_MEMPOOL_EVENTS
Definition: mem.h:86
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:160
pw_impl_client_get_properties
const struct pw_properties * pw_impl_client_get_properties(struct pw_impl_client *client)
Get the client properties.
Definition: impl-client.c:455
pw_impl_client_register
SPA_EXPORT int pw_impl_client_register(struct pw_impl_client *client, struct pw_properties *properties)
Finish configuration and register a client.
Definition: impl-client.c:369
pw_map::pw_map_clear
static void pw_map_clear(struct pw_map *map)
Clear a map.
Definition: map.h:87
pw_impl_client_add_listener
void pw_impl_client_add_listener(struct pw_impl_client *client, struct spa_hook *listener, const struct pw_impl_client_events *events, void *data)
listen to events from this client
Definition: impl-client.c:513
pw_global_add_resource
int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource)
Add a resource to a global.
Definition: global.c:227
pw_impl_client_events::free
void(* free)(void *data)
emited right before the client is freed
Definition: impl-client.h:91
pw_impl_client_get_protocol
struct pw_protocol * pw_impl_client_get_protocol(struct pw_impl_client *client)
Get the protocol used to create this client.
Definition: impl-client.c:431
pw_context
the PipeWire context
pw_impl_client_get_info
const struct pw_client_info * pw_impl_client_get_info(struct pw_impl_client *client)
Get the client information.
Definition: impl-client.c:522
pw_array::pw_array_add
static void * pw_array_add(struct pw_array *arr, size_t size)
Add ref size bytes to arr.
Definition: array.h:127
pw_array::pw_array_get_len
#define pw_array_get_len(a, t)
Get the number of items of type t in array.
Definition: array.h:57
pw_impl_client_events::initialized
void(* initialized)(void *data)
the client is initialized
Definition: impl-client.h:94
pw_global_update_permissions
int pw_global_update_permissions(struct pw_global *global, struct pw_impl_client *client, uint32_t old_permissions, uint32_t new_permissions)
Definition: global.c:311
pw_memblock
Definition: mem.h:64
pw_resource
Client owned objects.
pw_impl_client_register
int pw_impl_client_register(struct pw_impl_client *client, struct pw_properties *properties)
Finish configuration and register a client.
Definition: impl-client.c:369
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:175
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:265
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:66
resource_data::data
struct result_device_params_data data
Definition: impl-device.c:63
pw_context_add_listener
void pw_context_add_listener(struct pw_context *context, struct spa_hook *listener, const struct pw_context_events *events, void *data)
Add a new event listener to a context.
pw_client_methods
Client methods.
Definition: client.h:103
pw_impl_client::pw_context_create_client
SPA_EXPORT struct pw_impl_client * pw_context_create_client(struct pw_impl_core *core, struct pw_protocol *protocol, struct pw_properties *properties, size_t user_data_size)
Make a new client object.
Definition: impl-client.c:279
pw_array::pw_array_get_unchecked
#define pw_array_get_unchecked(a, idx, t)
Get the item with index idx and type t from array.
Definition: array.h:59
pw_impl_client_events::info_changed
void(* info_changed)(void *data, const struct pw_client_info *info)
emited when the client info changed
Definition: impl-client.h:97
PW_VERSION_CLIENT_METHODS
#define PW_VERSION_CLIENT_METHODS
Definition: client.h:104
PW_TYPE_INTERFACE_Client
#define PW_TYPE_INTERFACE_Client
Definition: client.h:38
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:43
pw_mempool_new
struct pw_mempool * pw_mempool_new(struct pw_properties *props)
Create a new memory pool.
Definition: mem.c:133
context.h
pw_global::pw_global_new
SPA_EXPORT struct pw_global * pw_global_new(struct pw_context *context, const char *type, uint32_t version, struct pw_properties *properties, pw_global_bind_func_t func, void *object)
Create a new global.
Definition: global.c:67
impl::this
struct pw_control this
Definition: control.c:34
pw_impl_client_events::resource_removed
void(* resource_removed)(void *data, struct pw_resource *resource)
emited when a resource is removed
Definition: impl-client.h:103
pw_impl_client_events::version
uint32_t version
Definition: impl-client.h:85
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:95
pw_array::pw_array_check_index
#define pw_array_check_index(a, idx, t)
Check if an item with index idx and type t exist in array.
Definition: array.h:61
PW_VERSION_CONTEXT_EVENTS
#define PW_VERSION_CONTEXT_EVENTS
Definition: context.h:97
PW_ID_ANY
#define PW_ID_ANY
Definition: core.h:49
properties.h
pw_impl_client_get_info
SPA_EXPORT const struct pw_client_info * pw_impl_client_get_info(struct pw_impl_client *client)
Get the client information.
Definition: impl-client.c:522
pw_global::pw_global_register
SPA_EXPORT int pw_global_register(struct pw_global *global)
register a global to the context registry
Definition: global.c:128
pw_impl_client_get_context
SPA_EXPORT struct pw_context * pw_impl_client_get_context(struct pw_impl_client *client)
Get the context used to create this client.
Definition: impl-client.c:425
pw_impl_client_update_permissions
SPA_EXPORT int pw_impl_client_update_permissions(struct pw_impl_client *client, uint32_t n_permissions, const struct pw_permission *permissions)
Update the client permissions.
Definition: impl-client.c:566
pw_impl_client_events::destroy
void(* destroy)(void *data)
emited when the client is destroyed
Definition: impl-client.h:88
pw_memblock::type
uint32_t type
type of the fd, one of enum spa_data_type
Definition: mem.h:69
pw_resource_events
Resource events.
Definition: resource.h:64
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:166
pw_resource_events::version
uint32_t version
Definition: resource.h:66
pw_impl_client_set_busy
void pw_impl_client_set_busy(struct pw_impl_client *client, bool busy)
Mark the client busy.
Definition: impl-client.c:636
pw_impl_client_add_listener
SPA_EXPORT void pw_impl_client_add_listener(struct pw_impl_client *client, struct spa_hook *listener, const struct pw_impl_client_events *events, void *data)
listen to events from this client
Definition: impl-client.c:513
pw_impl_client_get_core_resource
struct pw_resource * pw_impl_client_get_core_resource(struct pw_impl_client *client)
Get the client core resource.
Definition: impl-client.c:437
pw_properties::pw_properties_update_keys
SPA_EXPORT int pw_properties_update_keys(struct pw_properties *props, const struct spa_dict *dict, const char *keys[])
Copy multiple keys from one property to another.
Definition: properties.c:215
pw_properties
A collection of key/value pairs.
Definition: properties.h:45
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:330
pw_permission::id
uint32_t id
id of object, PW_ID_ANY for default permission
Definition: permission.h:57
PW_KEY_PROTOCOL
#define PW_KEY_PROTOCOL
The protocol key is usually set on a pw_client and contains a string describing the protocol used by ...
Definition: keys.h:54
pw_array::pw_array_init
static void pw_array_init(struct pw_array *arr, size_t extend)
Initialize the array with given extend.
Definition: array.h:85