PipeWire: pipewire/context.h Source File

PipeWire 0.3.51

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
29extern "C" {
30#endif
31
32#include <spa/utils/defs.h>
33#include <spa/utils/hook.h>
34
62struct pw_context;
63
64struct pw_global;
65struct pw_impl_client;
66
67#include <pipewire/core.h>
68#include <pipewire/loop.h>
69#include <pipewire/properties.h>
70
72struct pw_context_events {
73#define PW_VERSION_CONTEXT_EVENTS 0
74 uint32_t version;
75
77 void (*destroy) (void *data);
79 void (*free) (void *data);
81 void (*check_access) (void *data, struct pw_impl_client *client);
83 void (*global_added) (void *data, struct pw_global *global);
85 void (*global_removed) (void *data, struct pw_global *global);
86};
87
89 struct pw_context * pw_context_new(struct pw_loop *main_loop,
90 struct pw_properties *props,
91 size_t user_data_size );
92
94void pw_context_destroy(struct pw_context *context);
95
97void *pw_context_get_user_data(struct pw_context *context);
98
100void pw_context_add_listener(struct pw_context *context,
101 struct spa_hook *listener,
102 const struct pw_context_events *events,
103 void *data);
104
106const struct pw_properties *pw_context_get_properties(struct pw_context *context);
107
109int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict);
110
113const char *pw_context_get_conf_section(struct pw_context *context, const char *section);
115int pw_context_parse_conf_section(struct pw_context *context,
116 struct pw_properties *conf, const char *section);
117
119int pw_context_conf_update_props(struct pw_context *context, const char *section,
120 struct pw_properties *props);
122int pw_context_conf_section_for_each(struct pw_context *context, const char *section,
123 int (*callback) (void *data, const char *location, const char *section,
124 const char *str, size_t len),
125 void *data);
127int pw_context_conf_section_match_rules(struct pw_context *context, const char *section,
128 const struct spa_dict *props,
129 int (*callback) (void *data, const char *location, const char *action,
130 const char *str, size_t len),
131 void *data);
132
134const struct spa_support *pw_context_get_support(struct pw_context *context, uint32_t *n_support);
135
137struct pw_loop *pw_context_get_main_loop(struct pw_context *context);
138
140struct pw_work_queue *pw_context_get_work_queue(struct pw_context *context);
141
146int pw_context_for_each_global(struct pw_context *context,
147 int (*callback) (void *data, struct pw_global *global),
148 void *data);
149
151struct pw_global *pw_context_find_global(struct pw_context *context,
152 uint32_t id );
153
155int pw_context_add_spa_lib(struct pw_context *context, const char *factory_regex, const char *lib);
156
158const char * pw_context_find_spa_lib(struct pw_context *context, const char *factory_name);
159
160struct spa_handle *pw_context_load_spa_handle(struct pw_context *context,
161 const char *factory_name,
162 const struct spa_dict *info);
163
164
166struct pw_export_type {
167 struct spa_list link;
168 const char *type;
169 struct pw_proxy * (*func) (struct pw_core *core,
170 const char *type, const struct spa_dict *props, void *object,
171 size_t user_data_size);
172};
173
176 int pw_context_register_export_type(struct pw_context *context, struct pw_export_type *type);
178const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type);
179
181int pw_context_set_object(struct pw_context *context, const char *type, void *value);
183void *pw_context_get_object(struct pw_context *context, const char *type);
184
188#ifdef __cplusplus
189}
190#endif
191
192#endif /* PIPEWIRE_CONTEXT_H */
core.h
pipewire/core.h
defs.h
spa/utils/defs.h
pw_context_get_user_data
void * pw_context_get_user_data(struct pw_context *context)
Get the context user data.
Definition: context.c:518
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)
Definition: context.c:1445
pw_context_set_object
int pw_context_set_object(struct pw_context *context, const char *type, void *value)
add an object to the context
Definition: context.c:1513
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.
Definition: context.c:1475
pw_context_destroy
void pw_context_destroy(struct pw_context *context)
destroy a context object, all resources except the main_loop will be destroyed
Definition: context.c:434
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.
Definition: context.c:524
pw_context_get_conf_section
const char * pw_context_get_conf_section(struct pw_context *context, const char *section)
Get a config section for this context.
Definition: context.c:558
pw_context_update_properties
int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict)
Update the context properties.
Definition: context.c:571
pw_context_conf_section_for_each
int pw_context_conf_section_for_each(struct pw_context *context, const char *section, int(*callback)(void *data, const char *location, const char *section, const char *str, size_t len), void *data)
emit callback for all config sections.
Definition: conf.c:831
pw_context_get_object
void * pw_context_get_object(struct pw_context *context, const char *type)
get an object from the context
Definition: context.c:1541
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
Definition: context.c:1487
pw_context_conf_section_match_rules
int pw_context_conf_section_match_rules(struct pw_context *context, const char *section, const struct spa_dict *props, int(*callback)(void *data, const char *location, const char *action, const char *str, size_t len), void *data)
emit callback for all matched properties.
Definition: conf.c:1050
pw_context_conf_update_props
int pw_context_conf_update_props(struct pw_context *context, const char *section, struct pw_properties *props)
update properties from a section into props.
Definition: conf.c:895
pw_context_get_properties
const struct pw_properties * pw_context_get_properties(struct pw_context *context)
Get the context properties.
Definition: context.c:552
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
Definition: context.c:1433
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.
Definition: context.c:590
pw_context_get_main_loop
struct pw_loop * pw_context_get_main_loop(struct pw_context *context)
get the context main loop
Definition: context.c:540
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.
Definition: context.c:208
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
Definition: context.c:1408
pw_context_get_work_queue
struct pw_work_queue * pw_context_get_work_queue(struct pw_context *context)
Get the work queue from the context: Since 0.3.26.
Definition: context.c:546
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.
Definition: context.c:533
pw_context_find_global
struct pw_global * pw_context_find_global(struct pw_context *context, uint32_t id)
Find a context global by id.
Definition: context.c:607
pw_context_parse_conf_section
int pw_context_parse_conf_section(struct pw_context *context, struct pw_properties *conf, const char *section)
Parse a standard config section for this context.
Definition: conf.c:862
hook.h
spa/utils/hook.h
properties.h
pipewire/properties.h
loop.h
pipewire/loop.h
pw_context_events
context events emitted by the context object added with pw_context_add_listener
Definition: context.h:79
pw_context_events::global_added
void(* global_added)(void *data, struct pw_global *global)
a new global object was added
Definition: context.h:91
pw_context_events::destroy
void(* destroy)(void *data)
The context is being destroyed.
Definition: context.h:85
pw_context_events::global_removed
void(* global_removed)(void *data, struct pw_global *global)
a global object was removed
Definition: context.h:93
pw_context_events::free
void(* free)(void *data)
The context is being freed.
Definition: context.h:87
pw_context_events::version
uint32_t version
Definition: context.h:82
pw_context_events::check_access
void(* check_access)(void *data, struct pw_impl_client *client)
a new client object is added
Definition: context.h:89
pw_context
pw_core
pw_export_type
data for registering export functions
Definition: context.h:174
pw_export_type::type
const char * type
Definition: context.h:176
pw_export_type::link
struct spa_list link
Definition: context.h:175
pw_global
Definition: context.h:67
pw_impl_client
pw_loop
Definition: loop.h:51
pw_properties
Definition: properties.h:53
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:54
pw_proxy
pw_work_queue
spa_dict
Definition: dict.h:59
spa_handle
Definition: plugin.h:50
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351
spa_list
Definition: list.h:47
spa_support
Extra supporting infrastructure passed to the init() function of a factory.
Definition: plugin.h:96