PipeWire: context.h Source File

PipeWire 0.3.20

context.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_CONTEXT_H
26 #define PIPEWIRE_CONTEXT_H
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #include <spa/utils/defs.h>
33 #include <spa/utils/hook.h>
34
59 struct pw_context;
60
61 struct pw_global;
62 struct pw_impl_client;
63
64 #include <pipewire/core.h>
65 #include <pipewire/loop.h>
66 #include <pipewire/properties.h>
67
96 struct pw_context_events {
97 #define PW_VERSION_CONTEXT_EVENTS 0
98 uint32_t version;
99
101 void (*destroy) (void *data);
103 void (*free) (void *data);
105 void (*check_access) (void *data, struct pw_impl_client *client);
107 void (*global_added) (void *data, struct pw_global *global);
109 void (*global_removed) (void *data, struct pw_global *global);
110 };
111
113 struct pw_context * pw_context_new(struct pw_loop *main_loop,
114 struct pw_properties *props,
115 size_t user_data_size );
116
118 void pw_context_destroy(struct pw_context *context);
119
121 void *pw_context_get_user_data(struct pw_context *context);
122
124 void pw_context_add_listener(struct pw_context *context,
125 struct spa_hook *listener,
126 const struct pw_context_events *events,
127 void *data);
128
130 const struct pw_properties *pw_context_get_properties(struct pw_context *context);
131
133 int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict);
134
136 const struct spa_support *pw_context_get_support(struct pw_context *context, uint32_t *n_support);
137
139 struct pw_loop *pw_context_get_main_loop(struct pw_context *context);
140
145 int pw_context_for_each_global(struct pw_context *context,
146 int (*callback) (void *data, struct pw_global *global),
147 void *data);
148
150 struct pw_global *pw_context_find_global(struct pw_context *context,
151 uint32_t id );
152
154 int pw_context_add_spa_lib(struct pw_context *context, const char *factory_regex, const char *lib);
155
157 const char * pw_context_find_spa_lib(struct pw_context *context, const char *factory_name);
158
159 struct spa_handle *pw_context_load_spa_handle(struct pw_context *context,
160 const char *factory_name,
161 const struct spa_dict *info);
162
163
165 struct pw_export_type {
166 struct spa_list link;
167 const char *type;
168 struct pw_proxy * (*func) (struct pw_core *core,
169 const char *type, const struct spa_dict *props, void *object,
170 size_t user_data_size);
171 };
172
175 int pw_context_register_export_type(struct pw_context *context, struct pw_export_type *type);
177 const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type);
178
180 int pw_context_set_object(struct pw_context *context, const char *type, void *value);
182 void *pw_context_get_object(struct pw_context *context, const char *type);
183
184 #ifdef __cplusplus
185 }
186 #endif
187
188 #endif /* PIPEWIRE_CONTEXT_H */
pw_context
the PipeWire context
pw_global
A global object visible to remote clients.
pw_impl_client
PipeWire client object class.
pw_proxy
Represents an object on the client side.
pw_context_set_object
int pw_context_set_object(struct pw_context *context, const char *type, void *value)
add an object to the context
pw_context_get_object
void * pw_context_get_object(struct pw_context *context, const char *type)
get an object from the context
pw_context_register_export_type
int pw_context_register_export_type(struct pw_context *context, struct pw_export_type *type)
register a type that can be exported on a context_proxy.
pw_context_destroy
void pw_context_destroy(struct pw_context *context)
destroy a context object, all resources except the main_loop will be destroyed
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_context_update_properties
int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict)
Update the context properties.
pw_context_get_support
const struct spa_support * pw_context_get_support(struct pw_context *context, uint32_t *n_support)
Get the context support objects.
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_context_new
struct pw_context * pw_context_new(struct pw_loop *main_loop, struct pw_properties *props, size_t user_data_size)
Make a new context object for a given main_loop.
pw_context_find_export_type
const struct pw_export_type * pw_context_find_export_type(struct pw_context *context, const char *type)
find information about registered export type
pw_context_load_spa_handle
struct spa_handle * pw_context_load_spa_handle(struct pw_context *context, const char *factory_name, const struct spa_dict *info)
pw_context_get_user_data
void * pw_context_get_user_data(struct pw_context *context)
Get the context user data.
pw_context_get_properties
const struct pw_properties * pw_context_get_properties(struct pw_context *context)
Get the context properties.
pw_context_for_each_global
int pw_context_for_each_global(struct pw_context *context, int(*callback)(void *data, struct pw_global *global), void *data)
Iterate the globals of the context.
pw_context_find_spa_lib
const char * pw_context_find_spa_lib(struct pw_context *context, const char *factory_name)
find the library name for a spa factory
pw_context_add_spa_lib
int pw_context_add_spa_lib(struct pw_context *context, const char *factory_regex, const char *lib)
add a spa library for the given factory_name regex
pw_context_get_main_loop
struct pw_loop * pw_context_get_main_loop(struct pw_context *context)
get the context main loop
core.h
loop.h
properties.h
data
Definition: filter.c:74
pw_context_events
context events emitted by the context object added with pw_context_add_listener
Definition: context.h:96
pw_context_events::global_added
void(* global_added)(void *data, struct pw_global *global)
a new global object was added
Definition: context.h:107
pw_context_events::destroy
void(* destroy)(void *data)
The context is being destroyed.
Definition: context.h:101
pw_context_events::global_removed
void(* global_removed)(void *data, struct pw_global *global)
a global object was removed
Definition: context.h:109
pw_context_events::free
void(* free)(void *data)
The context is being freed.
Definition: context.h:103
pw_context_events::version
uint32_t version
Definition: context.h:98
pw_context_events::check_access
void(* check_access)(void *data, struct pw_impl_client *client)
a new client object is added
Definition: context.h:105
pw_export_type
data for registering export functions
Definition: context.h:165
pw_export_type::type
const char * type
Definition: context.h:167
pw_export_type::link
struct spa_list link
Definition: context.h:166
pw_loop
PipeWire loop object provides an implementation of the spa loop interfaces.
Definition: loop.h:41
pw_properties
A collection of key/value pairs.
Definition: properties.h:45
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46