PipeWire  0.3.80
src/pipewire/context.h
Go to the documentation of this file.
1 /* PipeWire */
2 /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3 /* SPDX-License-Identifier: MIT */
4 
5 #ifndef PIPEWIRE_CONTEXT_H
6 #define PIPEWIRE_CONTEXT_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include <spa/utils/defs.h>
13 #include <spa/utils/hook.h>
14 
42 struct pw_context;
43 
44 struct pw_global;
45 struct pw_impl_client;
46 struct pw_impl_node;
47 
48 #include <pipewire/core.h>
49 #include <pipewire/loop.h>
50 #include <pipewire/properties.h>
51 
54 #define PW_VERSION_CONTEXT_EVENTS 1
55  uint32_t version;
56 
58  void (*destroy) (void *data);
60  void (*free) (void *data);
62  void (*check_access) (void *data, struct pw_impl_client *client);
64  void (*global_added) (void *data, struct pw_global *global);
66  void (*global_removed) (void *data, struct pw_global *global);
67 
69  void (*driver_added) (void *data, struct pw_impl_node *node);
71  void (*driver_removed) (void *data, struct pw_impl_node *node);
72 };
73 
75 struct pw_context * pw_context_new(struct pw_loop *main_loop,
76  struct pw_properties *props,
77  size_t user_data_size );
78 
80 void pw_context_destroy(struct pw_context *context);
81 
83 void *pw_context_get_user_data(struct pw_context *context);
84 
86 void pw_context_add_listener(struct pw_context *context,
87  struct spa_hook *listener,
88  const struct pw_context_events *events,
89  void *data);
90 
92 const struct pw_properties *pw_context_get_properties(struct pw_context *context);
93 
95 int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict);
96 
99 const char *pw_context_get_conf_section(struct pw_context *context, const char *section);
101 int pw_context_parse_conf_section(struct pw_context *context,
102  struct pw_properties *conf, const char *section);
103 
105 int pw_context_conf_update_props(struct pw_context *context, const char *section,
106  struct pw_properties *props);
108 int pw_context_conf_section_for_each(struct pw_context *context, const char *section,
109  int (*callback) (void *data, const char *location, const char *section,
110  const char *str, size_t len),
111  void *data);
113 int pw_context_conf_section_match_rules(struct pw_context *context, const char *section,
114  const struct spa_dict *props,
115  int (*callback) (void *data, const char *location, const char *action,
116  const char *str, size_t len),
117  void *data);
118 
120 const struct spa_support *pw_context_get_support(struct pw_context *context, uint32_t *n_support);
121 
123 struct pw_loop *pw_context_get_main_loop(struct pw_context *context);
124 
126 struct pw_data_loop *pw_context_get_data_loop(struct pw_context *context);
127 
129 struct pw_work_queue *pw_context_get_work_queue(struct pw_context *context);
130 
132 struct pw_mempool *pw_context_get_mempool(struct pw_context *context);
133 
138 int pw_context_for_each_global(struct pw_context *context,
139  int (*callback) (void *data, struct pw_global *global),
140  void *data);
141 
143 struct pw_global *pw_context_find_global(struct pw_context *context,
144  uint32_t id );
145 
147 int pw_context_add_spa_lib(struct pw_context *context, const char *factory_regex, const char *lib);
148 
150 const char * pw_context_find_spa_lib(struct pw_context *context, const char *factory_name);
151 
152 struct spa_handle *pw_context_load_spa_handle(struct pw_context *context,
153  const char *factory_name,
154  const struct spa_dict *info);
155 
156 
158 struct pw_export_type {
159  struct spa_list link;
160  const char *type;
161  struct pw_proxy * (*func) (struct pw_core *core,
162  const char *type, const struct spa_dict *props, void *object,
163  size_t user_data_size);
164 };
165 
168 int pw_context_register_export_type(struct pw_context *context, struct pw_export_type *type);
170 const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type);
171 
173 int pw_context_set_object(struct pw_context *context, const char *type, void *value);
175 void *pw_context_get_object(struct pw_context *context, const char *type);
176 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* PIPEWIRE_CONTEXT_H */
pipewire/core.h
spa/utils/defs.h
struct pw_data_loop * pw_context_get_data_loop(struct pw_context *context)
get the context data loop.
Definition: context.c:496
struct pw_mempool * pw_context_get_mempool(struct pw_context *context)
Get the memmory pool from the context: Since 0.3.74.
Definition: context.c:509
int pw_context_set_object(struct pw_context *context, const char *type, void *value)
add an object to the context
Definition: context.c:1633
void * pw_context_get_object(struct pw_context *context, const char *type)
get an object from the context
Definition: context.c:1662
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:1595
void pw_context_destroy(struct pw_context *context)
destroy a context object, all resources except the main_loop will be destroyed
Definition: context.c:384
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:474
int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict)
Update the context properties.
Definition: context.c:534
const struct spa_support * pw_context_get_support(struct pw_context *context, uint32_t *n_support)
Get the context support objects.
Definition: context.c:483
struct pw_global * pw_context_find_global(struct pw_context *context, uint32_t id)
Find a context global by id.
Definition: context.c:570
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:1206
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:172
const char * pw_context_get_conf_section(struct pw_context *context, const char *section)
Get a config section for this context.
Definition: context.c:521
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:1241
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:1198
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:1607
struct spa_handle * pw_context_load_spa_handle(struct pw_context *context, const char *factory_name, const struct spa_dict *info)
Definition: context.c:1565
void * pw_context_get_user_data(struct pw_context *context)
Get the context user data.
Definition: context.c:468
const struct pw_properties * pw_context_get_properties(struct pw_context *context)
Get the context properties.
Definition: context.c:515
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:553
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:1553
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:1528
struct pw_loop * pw_context_get_main_loop(struct pw_context *context)
get the context main loop
Definition: context.c:490
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:1216
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:503
spa/utils/hook.h
pipewire/properties.h
pipewire/loop.h
context events emitted by the context object added with pw_context_add_listener
Definition: src/pipewire/context.h:61
void(* global_added)(void *data, struct pw_global *global)
a new global object was added
Definition: src/pipewire/context.h:73
void(* destroy)(void *data)
The context is being destroyed.
Definition: src/pipewire/context.h:67
void(* driver_removed)(void *data, struct pw_impl_node *node)
a driver was removed, since 0.3.75 version:1
Definition: src/pipewire/context.h:80
void(* global_removed)(void *data, struct pw_global *global)
a global object was removed
Definition: src/pipewire/context.h:75
void(* free)(void *data)
The context is being freed.
Definition: src/pipewire/context.h:69
uint32_t version
Definition: src/pipewire/context.h:64
void(* check_access)(void *data, struct pw_impl_client *client)
a new client object is added
Definition: src/pipewire/context.h:71
void(* driver_added)(void *data, struct pw_impl_node *node)
a driver was added, since 0.3.75 version:1
Definition: src/pipewire/context.h:78
data for registering export functions
Definition: src/pipewire/context.h:167
const char * type
Definition: src/pipewire/context.h:169
struct spa_list link
Definition: src/pipewire/context.h:168
Definition: src/pipewire/context.h:47
Definition: src/pipewire/context.h:52
Definition: src/pipewire/loop.h:31
A memory pool is a collection of pw_memblocks.
Definition: src/pipewire/mem.h:57
Definition: properties.h:33
struct spa_dict dict
dictionary of key/values
Definition: properties.h:34
Definition: utils/dict.h:39
Definition: plugin.h:30
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:350
Definition: list.h:27
Extra supporting infrastructure passed to the init() function of a factory.
Definition: plugin.h:76