PipeWire  0.3.15
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 
54 struct pw_global;
55 
56 #include <pipewire/impl.h>
57 
58 typedef int (*pw_global_bind_func_t) (void *object,
59  struct pw_impl_client *client,
60  uint32_t permissions,
61  uint32_t version,
62  uint32_t id );
63 
66 #define PW_VERSION_GLOBAL_EVENTS 0
67  uint32_t version;
68 
70  void (*destroy) (void *data);
72  void (*free) (void *data);
74  void (*permissions_changed) (void *data,
75  struct pw_impl_client *client,
76  uint32_t old_permissions,
77  uint32_t new_permissions);
78 };
79 
81 struct pw_global *
82 pw_global_new(struct pw_context *context,
83  const char *type,
84  uint32_t version,
85  struct pw_properties *properties,
87  void *object );
88 
90 int pw_global_register(struct pw_global *global);
91 
93 void pw_global_add_listener(struct pw_global *global,
94  struct spa_hook *listener,
95  const struct pw_global_events *events,
96  void *data);
97 
99 uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_impl_client *client);
100 
102 struct pw_context *pw_global_get_context(struct pw_global *global);
103 
105 const char *pw_global_get_type(struct pw_global *global);
106 
108 bool pw_global_is_type(struct pw_global *global, const char *type);
109 
111 uint32_t pw_global_get_version(struct pw_global *global);
112 
114 const struct pw_properties *pw_global_get_properties(struct pw_global *global);
115 
117 int pw_global_update_keys(struct pw_global *global,
118  const struct spa_dict *dict, const char *keys[]);
119 
122 void *pw_global_get_object(struct pw_global *global);
123 
125 uint32_t pw_global_get_id(struct pw_global *global);
126 
128 int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource);
129 
134 int pw_global_for_each_resource(struct pw_global *global,
135  int (*callback) (void *data, struct pw_resource *resource),
136  void *data);
137 
139 int pw_global_bind(struct pw_global *global,
140  struct pw_impl_client *client,
141  uint32_t permissions,
142  uint32_t version,
143  uint32_t id);
144 
145 int pw_global_update_permissions(struct pw_global *global, struct pw_impl_client *client,
146  uint32_t old_permissions, uint32_t new_permissions);
147 
149 void pw_global_destroy(struct pw_global *global);
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif /* PIPEWIRE_GLOBAL_H */
res
static uint32_t int int res
Definition: core.h:326
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:185
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:58
pw_map::pw_map_remove
static void pw_map_remove(struct pw_map *map, uint32_t id)
Remove an item at index.
Definition: map.h:157
pw_global_for_each_resource
SPA_EXPORT 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:248
pw_global_events::destroy
void(* destroy)(void *data)
The global is destroyed.
Definition: global.h:70
pw_global_add_listener
SPA_EXPORT 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:262
pw_log::pw_log_error
#define pw_log_error(...)
pw_global_get_version
uint32_t pw_global_get_version(struct pw_global *global)
Get the global version.
Definition: global.c:203
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:377
data
Definition: filter.c:71
pw_global_events::free
void(* free)(void *data)
The global is freed.
Definition: global.h:72
pw_global_get_version
SPA_EXPORT uint32_t pw_global_get_version(struct pw_global *global)
Get the global version.
Definition: global.c:203
pw_global_events::version
uint32_t version
Definition: global.h:67
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:65
pw_impl_client
PipeWire client object class.
impl
Definition: control.c:33
PW_PERM_IS_R
#define PW_PERM_IS_R(p)
Definition: permission.h:53
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_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:262
pw_global_get_properties
SPA_EXPORT const struct pw_properties * pw_global_get_properties(struct pw_global *global)
Get the global properties.
Definition: global.c:209
pw_global
A global object visible to remote clients.
pw_map::pw_map_insert_new
static uint32_t pw_map_insert_new(struct pw_map *map, void *data)
Insert data in the map.
Definition: map.h:105
impl.h
pw_global_is_type
SPA_EXPORT bool pw_global_is_type(struct pw_global *global, const char *type)
Check a global type.
Definition: global.c:197
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
pw_global_get_id
SPA_EXPORT uint32_t pw_global_get_id(struct pw_global *global)
Get the unique id of the global.
Definition: global.c:231
pw_map::pw_map_insert_at
static int pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
Insert data in the map at an index.
Definition: map.h:133
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:248
pw_global_get_object
SPA_EXPORT void * pw_global_get_object(struct pw_global *global)
Get the object associated with the global.
Definition: global.c:225
pw_global_update_keys
int pw_global_update_keys(struct pw_global *global, const struct spa_dict *dict, const char *keys[])
Update the global properties, must be done when unregistered.
Definition: global.c:215
pw_log::pw_log_debug
#define pw_log_debug(...)
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_get_object
void * pw_global_get_object(struct pw_global *global)
Get the object associated with the global.
Definition: global.c:225
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:74
PW_PERM_ALL
#define PW_PERM_ALL
Definition: permission.h:58
pw_global_get_id
uint32_t pw_global_get_id(struct pw_global *global)
Get the unique id of the global.
Definition: global.c:231
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:237
pw_global_add_resource
SPA_EXPORT int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource)
Add a resource to a global.
Definition: global.c:237
pw_context
the PipeWire context
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:321
pw_resource
Client owned objects.
pw_global_update_keys
SPA_EXPORT int pw_global_update_keys(struct pw_global *global, const struct spa_dict *dict, const char *keys[])
Update the global properties, must be done when unregistered.
Definition: global.c:215
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:264
pw_global_is_type
bool pw_global_is_type(struct pw_global *global, const char *type)
Check a global type.
Definition: global.c:197
registry
Definition: pipewire.c:66
pw_global_get_type
const char * pw_global_get_type(struct pw_global *global)
Get the global type.
Definition: global.c:191
pw_global_update_permissions
SPA_EXPORT 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:321
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_global_get_context
SPA_EXPORT struct pw_context * pw_global_get_context(struct pw_global *global)
Get the context object of this global.
Definition: global.c:185
pw_global_get_type
const SPA_EXPORT char * pw_global_get_type(struct pw_global *global)
Get the global type.
Definition: global.c:191
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:98
PW_ID_CORE
#define PW_ID_CORE
Definition: core.h:49
pw_global_get_permissions
SPA_EXPORT 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::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_global_get_properties
const struct pw_properties * pw_global_get_properties(struct pw_global *global)
Get the global properties.
Definition: global.c:209
pw_global::pw_global_bind
SPA_EXPORT 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:284
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:220
NAME
#define NAME
Definition: global.c:35
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:335