PipeWire  0.3.33
global.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_GLOBAL_H
26 #define PIPEWIRE_GLOBAL_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
57 struct pw_global;
58 
59 #include <pipewire/impl.h>
60 
61 typedef int (*pw_global_bind_func_t) (void *object,
62  struct pw_impl_client *client,
63  uint32_t permissions,
64  uint32_t version,
65  uint32_t id );
66 
69 #define PW_VERSION_GLOBAL_EVENTS 0
70  uint32_t version;
71 
73  void (*destroy) (void *data);
75  void (*free) (void *data);
77  void (*permissions_changed) (void *data,
78  struct pw_impl_client *client,
79  uint32_t old_permissions,
80  uint32_t new_permissions);
81 };
82 
84 struct pw_global *
85 pw_global_new(struct pw_context *context,
86  const char *type,
87  uint32_t version,
88  struct pw_properties *properties,
90  void *object );
91 
93 int pw_global_register(struct pw_global *global);
94 
96 void pw_global_add_listener(struct pw_global *global,
97  struct spa_hook *listener,
98  const struct pw_global_events *events,
99  void *data);
100 
102 uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_impl_client *client);
103 
105 struct pw_context *pw_global_get_context(struct pw_global *global);
106 
108 const char *pw_global_get_type(struct pw_global *global);
109 
111 bool pw_global_is_type(struct pw_global *global, const char *type);
112 
114 uint32_t pw_global_get_version(struct pw_global *global);
115 
117 const struct pw_properties *pw_global_get_properties(struct pw_global *global);
118 
120 int pw_global_update_keys(struct pw_global *global,
121  const struct spa_dict *dict, const char * const keys[]);
122 
125 void *pw_global_get_object(struct pw_global *global);
126 
128 uint32_t pw_global_get_id(struct pw_global *global);
129 
131 int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource);
132 
137 int pw_global_for_each_resource(struct pw_global *global,
138  int (*callback) (void *data, struct pw_resource *resource),
139  void *data);
140 
142 int pw_global_bind(struct pw_global *global,
143  struct pw_impl_client *client,
144  uint32_t permissions,
145  uint32_t version,
146  uint32_t id);
147 
148 int pw_global_update_permissions(struct pw_global *global, struct pw_impl_client *client,
149  uint32_t old_permissions, uint32_t new_permissions);
150 
152 void pw_global_destroy(struct pw_global *global);
153 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* PIPEWIRE_GLOBAL_H */
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:314
PW_PERM_IS_R
#define PW_PERM_IS_R(p)
Definition: permission.h:56
pw_global_bind_func_t
int(* pw_global_bind_func_t)(void *object, struct pw_impl_client *client, uint32_t permissions, uint32_t version, uint32_t id)
Definition: global.h:61
pw_global_get_context
struct pw_context * pw_global_get_context(struct pw_global *global)
Get the context object of this global.
Definition: global.c:179
pw_global_events::destroy
void(* destroy)(void *data)
The global is destroyed.
Definition: global.h:73
pw_global_is_type
bool pw_global_is_type(struct pw_global *global, const char *type)
Check a global type.
Definition: global.c:191
pw_global_register
int pw_global_register(struct pw_global *global)
register a global to the context registry
Definition: global.c:125
types.h
pw_global_for_each_resource
int pw_global_for_each_resource(struct pw_global *global, int(*callback)(void *data, struct pw_resource *resource), void *data)
Iterate all resources added to the global The callback should return 0 to fetch the next item,...
Definition: global.c:241
string.h
data
user data to add to an object
Definition: filter.c:75
pw_global_new
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:66
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:230
spa_streq
bool spa_streq(const char *s1, const char *s2)
Definition: string.h:50
pw_global_events::free
void(* free)(void *data)
The global is freed.
Definition: global.h:75
spa_list_for_each
#define spa_list_for_each(pos, head, member)
Definition: list.h:111
pw_global_get_permissions
uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_impl_client *client)
Get the permissions of the global for a given client.
Definition: global.c:45
pw_global_events::version
uint32_t version
Definition: global.h:70
SPA_EXPORT
#define SPA_EXPORT
Definition: defs.h:208
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:68
impl
Definition: control.c:33
client::id
uint32_t id
Definition: access-flatpak.c:54
spa_hook_list_append
void spa_hook_list_append(struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
Append a hook.
Definition: hook.h:316
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:264
pw_global_get_properties
const struct pw_properties * pw_global_get_properties(struct pw_global *global)
Get the global properties.
Definition: global.c:203
pw_global_get_object
void * pw_global_get_object(struct pw_global *global)
Get the object associated with the global.
Definition: global.c:218
impl.h
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:50
spa_list_consume
#define spa_list_consume(pos, head, member)
Definition: list.h:96
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:255
spa_list_remove
void spa_list_remove(struct spa_list *elem)
Definition: list.h:69
pw_global_bind
int pw_global_bind(struct pw_global *global, struct pw_impl_client *client, uint32_t permissions, uint32_t version, uint32_t id)
Bind to a global.
Definition: global.c:277
PW_PERM_ALL
#define PW_PERM_ALL
Definition: permission.h:61
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:295
pw_properties_update_keys
int pw_properties_update_keys(struct pw_properties *props, const struct spa_dict *dict, const char *const keys[])
Copy multiple keys from one property to another.
Definition: properties.c:235
pw_global_events::permissions_changed
void(* permissions_changed)(void *data, struct pw_impl_client *client, uint32_t old_permissions, uint32_t new_permissions)
The permissions changed for a client.
Definition: global.h:77
spa_list_init
void spa_list_init(struct spa_list *list)
Definition: list.h:44
spa_list_for_each_safe
#define spa_list_for_each_safe(pos, tmp, head, member)
Definition: list.h:129
spa_dict
Definition: utils/dict.h:48
pw_resource_set_bound_id
int pw_resource_set_bound_id(struct pw_resource *resource, uint32_t global_id)
Notify global id this resource is bound to.
Definition: resource.c:209
pw_global_update_keys
int pw_global_update_keys(struct pw_global *global, const struct spa_dict *dict, const char *const keys[])
Update the global properties, must be done when unregistered.
Definition: global.c:209
spa_strerror
#define spa_strerror(err)
Definition: result.h:51
PW_ID_CORE
#define PW_ID_CORE
default ID for the core object after connect
Definition: core.h:66
pw_log_debug
#define pw_log_debug(...)
Definition: src/pipewire/log.h:89
client
Definition: module-protocol-native.c:103
pw_global_destroy
void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:369
SPA_ID_INVALID
#define SPA_ID_INVALID
Definition: defs.h:182
registry
Definition: pipewire.c:76
pw_global_get_type
const char * pw_global_get_type(struct pw_global *global)
Get the global type.
Definition: global.c:185
impl::this
struct pw_control this
Definition: control.c:34
spa_hook_list_init
void spa_hook_list_init(struct spa_hook_list *list)
Initialize a hook list to the empty list.
Definition: hook.h:305
pw_global_get_version
uint32_t pw_global_get_version(struct pw_global *global)
Get the global version.
Definition: global.c:197
pw_global_get_id
uint32_t pw_global_get_id(struct pw_global *global)
Get the unique id of the global.
Definition: global.c:224
pw_properties_new
struct pw_properties * pw_properties_new(const char *key,...) 1
Make a new properties object.
Definition: properties.c:98
NAME
#define NAME
Definition: global.c:36
pw_properties
Definition: properties.h:49
spa_hook_list_clean
void spa_hook_list_clean(struct spa_hook_list *list)
Remove all hooks from the list.
Definition: hook.h:344
pw_properties_free
void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:364
pw_log_error
#define pw_log_error(...)
Definition: src/pipewire/log.h:86
spa_list_append
#define spa_list_append(list, item)
Definition: list.h:81