PipeWire  0.2.7
client.h
Go to the documentation of this file.
1 /* PipeWire
2  * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __PIPEWIRE_CLIENT_H__
21 #define __PIPEWIRE_CLIENT_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <spa/utils/hook.h>
28 
39 struct pw_client;
40 
41 #include <pipewire/core.h>
42 #include <pipewire/global.h>
43 #include <pipewire/introspect.h>
44 #include <pipewire/properties.h>
45 #include <pipewire/resource.h>
46 
47 #define PW_TYPE__Client PW_TYPE_OBJECT_BASE "Client"
48 #define PW_TYPE_CLIENT_BASE PW_TYPE__Client ":"
49 
82 #define PW_VERSION_CLIENT_EVENTS 0
83  uint32_t version;
84 
86  void (*destroy) (void *data);
87 
89  void (*free) (void *data);
90 
92  void (*info_changed) (void *data, struct pw_client_info *info);
93 
95  void (*resource_added) (void *data, struct pw_resource *resource);
96 
99  void (*resource_impl) (void *data, struct pw_resource *resource);
100 
102  void (*resource_removed) (void *data, struct pw_resource *resource);
103 
107  void (*busy_changed) (void *data, bool busy);
108 };
109 
111 #define PW_CLIENT_PROP_PROTOCOL "pipewire.protocol"
112 
113 #define PW_CLIENT_PROP_UCRED_PID "pipewire.ucred.pid"
114 #define PW_CLIENT_PROP_UCRED_UID "pipewire.ucred.uid"
115 #define PW_CLIENT_PROP_UCRED_GID "pipewire.ucred.gid"
116 #define PW_CLIENT_PROP_SEC_LABEL "pipewire.sec.label"
119 struct pw_client *
120 pw_client_new(struct pw_core *core,
121  struct pw_properties *properties,
122  size_t user_data_size );
123 
125 void pw_client_destroy(struct pw_client *client);
126 
128 int pw_client_register(struct pw_client *client,
129  struct pw_client *owner,
130  struct pw_global *parent,
131  struct pw_properties *properties);
132 
134 void *pw_client_get_user_data(struct pw_client *client);
135 
137 const struct pw_client_info *pw_client_get_info(struct pw_client *client);
138 
140 int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict);
141 
143 int pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict);
144 
146 const struct pw_properties *pw_client_get_properties(struct pw_client *client);
147 
149 struct pw_core *pw_client_get_core(struct pw_client *client);
150 
152 struct pw_resource *pw_client_get_core_resource(struct pw_client *client);
153 
155 struct pw_resource *pw_client_find_resource(struct pw_client *client, uint32_t id);
156 
158 struct pw_global *pw_client_get_global(struct pw_client *client);
159 
161 void pw_client_add_listener(struct pw_client *client,
162  struct spa_hook *listener,
163  const struct pw_client_events *events,
164  void *data);
165 
166 
169 void pw_client_set_busy(struct pw_client *client, bool busy);
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #endif /* __PIPEWIRE_CLIENT_H__ */
pw_global::pw_global_register
SPA_EXPORT int pw_global_register(struct pw_global *global, struct pw_client *owner, struct pw_global *parent)
register a global to the core registry
Definition: global.c:102
pw_client_events::busy_changed
void(* busy_changed)(void *data, bool busy)
emited when the client becomes busy processing an asynchronous message.
Definition: client.h:107
global.h
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:152
introspect.h
permission::permissions
uint32_t permissions
Definition: client.c:32
pw_client_get_core_resource
struct pw_resource * pw_client_get_core_resource(struct pw_client *client)
Get the client core resource.
Definition: client.c:247
pw_client_get_properties
const struct pw_properties * pw_client_get_properties(struct pw_client *client)
Get the client properties.
Definition: client.c:265
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:241
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:70
pw_core_for_each_global
int pw_core_for_each_global(struct pw_core *core, int(*callback)(void *data, struct pw_global *global), void *data)
Iterate the globals of the core.
Definition: core.c:613
pw_client_register
SPA_EXPORT int pw_client_register(struct pw_client *client, struct pw_client *owner, struct pw_global *parent, struct pw_properties *properties)
Finish configuration and register a client.
Definition: client.c:211
resource_data
Definition: factory.c:26
pw_client_find_resource
SPA_EXPORT struct pw_resource * pw_client_find_resource(struct pw_client *client, uint32_t id)
Get a resource with the given id.
Definition: client.c:253
pw_client
PipeWire client object class.
pw_core_add_listener
void pw_core_add_listener(struct pw_core *core, struct spa_hook *listener, const struct pw_core_events *events, void *data)
Add a new event listener to a core.
Definition: core.c:543
interfaces.h
resource_data::resource_listener
struct spa_hook resource_listener
Definition: factory.c:27
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:59
permissions_update::permissions
uint32_t permissions
Definition: client.c:390
PW_CORE_PROXY_PERMISSIONS_EXISTING
#define PW_CORE_PROXY_PERMISSIONS_EXISTING
Key to update specific permissions of all existing globals.
Definition: interfaces.h:99
impl
Definition: control.c:25
PW_PERM_RWX
#define PW_PERM_RWX
Definition: core.h:81
pw_client_events::resource_impl
void(* resource_impl)(void *data, struct pw_resource *resource)
emited when an implementation is set on a resource.
Definition: client.h:99
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:190
pw_client_update_permissions
SPA_EXPORT int pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict)
Update the client permissions.
Definition: client.c:452
pw_global
A global object visible to remote clients.
pw_client_get_user_data
void * pw_client_get_user_data(struct pw_client *client)
Get the client user data.
Definition: client.c:271
pw_client_set_busy
void pw_client_set_busy(struct pw_client *client, bool busy)
Mark the client busy.
Definition: client.c:514
pw_client_get_core
struct pw_core * pw_client_get_core(struct pw_client *client)
Get the core used to create this client.
Definition: client.c:241
PW_PERM_R
#define PW_PERM_R
object can be seen and events can be received
Definition: core.h:76
pw_properties::dict
struct spa_dict dict
Definition: properties.h:39
pw_client_add_listener
void pw_client_add_listener(struct pw_client *client, struct spa_hook *listener, const struct pw_client_events *events, void *data)
listen to events from this client
Definition: client.c:327
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:171
pw_array
An array object.
Definition: array.h:36
pw_global::pw_global_new
SPA_EXPORT struct pw_global * pw_global_new(struct pw_core *core, uint32_t type, uint32_t version, struct pw_properties *properties, void *object)
Create a new global.
Definition: global.c:61
pw_client_events::resource_added
void(* resource_added)(void *data, struct pw_resource *resource)
emited when a new resource is added for client
Definition: client.h:95
pw_client_get_global
struct pw_global * pw_client_get_global(struct pw_client *client)
Get the global associated with this client.
Definition: client.c:259
pw_client_register
int pw_client_register(struct pw_client *client, struct pw_client *owner, struct pw_global *parent, struct pw_properties *properties)
Finish configuration and register a client.
Definition: client.c:211
permissions_update::only_new
bool only_new
Definition: client.c:391
PW_VERSION_CLIENT
#define PW_VERSION_CLIENT
Definition: interfaces.h:664
pw_client_get_core_resource
SPA_EXPORT struct pw_resource * pw_client_get_core_resource(struct pw_client *client)
Get the client core resource.
Definition: client.c:247
PW_CORE_PROXY_PERMISSIONS_DEFAULT
#define PW_CORE_PROXY_PERMISSIONS_DEFAULT
Key to update default permissions of globals without specific permissions.
Definition: interfaces.h:84
pw_resource_new
struct pw_resource * pw_resource_new(struct pw_client *client, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:34
pw_client::pw_client_new
SPA_EXPORT struct pw_client * pw_client_new(struct pw_core *core, struct pw_properties *properties, size_t user_data_size)
Make a new client object.
Definition: client.c:152
pw_client_events::version
uint32_t version
Definition: client.h:83
PW_VERSION_RESOURCE_EVENTS
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:63
pw_client_info
The client information.
Definition: introspect.h:125
resource.h
pw_resource_error
void pw_resource_error(struct pw_resource *resource, int result, const char *error)
Generate an error for a resource.
Definition: resource.c:162
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:113
pw_map::pw_map_clear
static void pw_map_clear(struct pw_map *map)
Clear a map.
Definition: map.h:81
pw_properties::pw_properties_get
const SPA_EXPORT char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:361
PW_VERSION_CORE_EVENTS
#define PW_VERSION_CORE_EVENTS
Definition: core.h:89
PW_CORE_PROXY_PERMISSIONS_GLOBAL
#define PW_CORE_PROXY_PERMISSIONS_GLOBAL
Key to update specific permissions of a global.
Definition: interfaces.h:91
pw_client_update_permissions
int pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict)
Update the client permissions.
Definition: client.c:452
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:98
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:50
pw_properties::pw_properties_set
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:308
pw_client_get_core
SPA_EXPORT struct pw_core * pw_client_get_core(struct pw_client *client)
Get the core used to create this client.
Definition: client.c:241
pw_core
the core PipeWire object
pw_resource
Client owned objects.
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:169
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:60
pw_client_get_properties
SPA_EXPORT const struct pw_properties * pw_client_get_properties(struct pw_client *client)
Get the client properties.
Definition: client.c:265
pw_client_events::destroy
void(* destroy)(void *data)
emited when the client is destroyed
Definition: client.h:86
pw_client_get_global
SPA_EXPORT struct pw_global * pw_client_get_global(struct pw_client *client)
Get the global associated with this client.
Definition: client.c:259
permissions_update::client
struct pw_client * client
Definition: client.c:389
pw_client_events::free
void(* free)(void *data)
emited right before the client is freed
Definition: client.h:89
PW_PERM_W
#define PW_PERM_W
methods can be called that modify the object
Definition: core.h:77
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:52
core.h
permissions_update
Definition: client.c:388
impl::this
struct pw_control this
Definition: control.c:26
pw_client_events
The events that a client can emit.
Definition: client.h:81
pw_client_find_resource
struct pw_resource * pw_client_find_resource(struct pw_client *client, uint32_t id)
Get a resource with the given id.
Definition: client.c:253
permission
Definition: client.c:30
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:89
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:54
pw_log::pw_log_error
void pw_log_error(const char *format,...)
pipewire.h
properties.h
pw_core_find_global
struct pw_global * pw_core_find_global(struct pw_core *core, uint32_t id)
Find a core global by id.
Definition: core.c:631
pw_client_add_listener
SPA_EXPORT void pw_client_add_listener(struct pw_client *client, struct spa_hook *listener, const struct pw_client_events *events, void *data)
listen to events from this client
Definition: client.c:327
pw_client_events::info_changed
void(* info_changed)(void *data, struct pw_client_info *info)
emited when the client info changed
Definition: client.h:92
pw_client_resource_info
#define pw_client_resource_info(r,...)
Definition: interfaces.h:691
pw_client::pw_client_update_properties
SPA_EXPORT int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict)
Update client properties.
Definition: client.c:353
pw_client_events::resource_removed
void(* resource_removed)(void *data, struct pw_resource *resource)
emited when a resource is removed
Definition: client.h:102
pw_client::pw_client_destroy
SPA_EXPORT void pw_client_destroy(struct pw_client *client)
Destroy a client object.
Definition: client.c:291
PW_CLIENT_CHANGE_MASK_PROPS
#define PW_CLIENT_CHANGE_MASK_PROPS
Definition: introspect.h:127
pw_resource_events
Resource events.
Definition: resource.h:62
pw_client_get_info
SPA_EXPORT const struct pw_client_info * pw_client_get_info(struct pw_client *client)
Get the client information.
Definition: client.c:336
pw_client_set_busy
SPA_EXPORT void pw_client_set_busy(struct pw_client *client, bool busy)
Mark the client busy.
Definition: client.c:514
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:119
permission::id
uint32_t id
Definition: client.c:31
PW_PERM_X
#define PW_PERM_X
methods can be called on the object.
Definition: core.h:78
pw_resource_events::version
uint32_t version
Definition: resource.h:64
pw_log::pw_log_warn
void pw_log_warn(const char *format,...)
client.h
pw_log::pw_log_debug
void pw_log_debug(const char *format,...)
pw_client_get_user_data
SPA_EXPORT void * pw_client_get_user_data(struct pw_client *client)
Get the client user data.
Definition: client.c:271
pw_properties
A collection of key/value pairs.
Definition: properties.h:38
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:245
pw_client_get_info
const struct pw_client_info * pw_client_get_info(struct pw_client *client)
Get the client information.
Definition: client.c:336
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:62
pw_core_events
core events emited by the core object added with pw_core_add_listener
Definition: core.h:88