PipeWire  0.3.29
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 
77 struct pw_context;
78 
79 struct pw_global;
80 struct pw_impl_client;
81 
82 #include <pipewire/core.h>
83 #include <pipewire/loop.h>
84 #include <pipewire/properties.h>
85 
88 #define PW_VERSION_CONTEXT_EVENTS 0
89  uint32_t version;
90 
92  void (*destroy) (void *data);
94  void (*free) (void *data);
96  void (*check_access) (void *data, struct pw_impl_client *client);
98  void (*global_added) (void *data, struct pw_global *global);
100  void (*global_removed) (void *data, struct pw_global *global);
101 };
102 
104 struct pw_context * pw_context_new(struct pw_loop *main_loop,
105  struct pw_properties *props,
106  size_t user_data_size );
107 
109 void pw_context_destroy(struct pw_context *context);
110 
112 void *pw_context_get_user_data(struct pw_context *context);
113 
115 void pw_context_add_listener(struct pw_context *context,
116  struct spa_hook *listener,
117  const struct pw_context_events *events,
118  void *data);
119 
121 const struct pw_properties *pw_context_get_properties(struct pw_context *context);
122 
124 int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict);
125 
127 const char *pw_context_get_conf_section(struct pw_context *context, const char *section);
128 
130 const struct spa_support *pw_context_get_support(struct pw_context *context, uint32_t *n_support);
131 
133 struct pw_loop *pw_context_get_main_loop(struct pw_context *context);
134 
136 struct pw_work_queue *pw_context_get_work_queue(struct pw_context *context);
137 
142 int pw_context_for_each_global(struct pw_context *context,
143  int (*callback) (void *data, struct pw_global *global),
144  void *data);
145 
147 struct pw_global *pw_context_find_global(struct pw_context *context,
148  uint32_t id );
149 
151 int pw_context_add_spa_lib(struct pw_context *context, const char *factory_regex, const char *lib);
152 
154 const char * pw_context_find_spa_lib(struct pw_context *context, const char *factory_name);
155 
156 struct spa_handle *pw_context_load_spa_handle(struct pw_context *context,
157  const char *factory_name,
158  const struct spa_dict *info);
159 
160 
163  struct spa_list link;
164  const char *type;
165  struct pw_proxy * (*func) (struct pw_core *core,
166  const char *type, const struct spa_dict *props, void *object,
167  size_t user_data_size);
168 };
169 
172 int pw_context_register_export_type(struct pw_context *context, struct pw_export_type *type);
174 const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type);
175 
177 int pw_context_set_object(struct pw_context *context, const char *type, void *value);
179 void *pw_context_get_object(struct pw_context *context, const char *type);
180 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #endif /* PIPEWIRE_CONTEXT_H */
int pw_context_set_object(struct pw_context *context, const char *type, void *value)
add an object to the context
Definition: context.c:1198
void * pw_context_get_object(struct pw_context *context, const char *type)
get an object from the context
Definition: context.c:1220
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:1160
void pw_context_destroy(struct pw_context *context)
destroy a context object, all resources except the main_loop will be destroyed
Definition: context.c:400
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:479
int pw_context_update_properties(struct pw_context *context, const struct spa_dict *dict)
Update the context properties.
Definition: context.c:528
const struct spa_support * pw_context_get_support(struct pw_context *context, uint32_t *n_support)
Get the context support objects.
Definition: context.c:488
struct pw_global * pw_context_find_global(struct pw_context *context, uint32_t id)
Find a context global by id.
Definition: context.c:564
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:192
const char * pw_context_get_conf_section(struct pw_context *context, const char *section)
Get a config section for this context.
Definition: context.c:515
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:1172
struct spa_handle * pw_context_load_spa_handle(struct pw_context *context, const char *factory_name, const struct spa_dict *info)
Definition: context.c:1130
void * pw_context_get_user_data(struct pw_context *context)
Get the context user data.
Definition: context.c:473
const struct pw_properties * pw_context_get_properties(struct pw_context *context)
Get the context properties.
Definition: context.c:509
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:547
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:1118
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:1093
struct pw_loop * pw_context_get_main_loop(struct pw_context *context)
get the context main loop
Definition: context.c:495
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:501
Definition: filter.c:75
context events emitted by the context object added with pw_context_add_listener
Definition: context.h:87
void(* global_added)(void *data, struct pw_global *global)
a new global object was added
Definition: context.h:98
void(* destroy)(void *data)
The context is being destroyed.
Definition: context.h:92
void(* global_removed)(void *data, struct pw_global *global)
a global object was removed
Definition: context.h:100
void(* free)(void *data)
The context is being freed.
Definition: context.h:94
uint32_t version
Definition: context.h:89
void(* check_access)(void *data, struct pw_impl_client *client)
a new client object is added
Definition: context.h:96
data for registering export functions
Definition: context.h:162
const char * type
Definition: context.h:164
struct spa_list link
Definition: context.h:163
Definition: src/pipewire/loop.h:47
Definition: properties.h:49
struct spa_dict dict
dictionary of key/values
Definition: properties.h:50
Definition: utils/dict.h:48
Definition: plugin.h:44
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:76
Definition: list.h:37
Extra supporting infrastructure passed to the init() function of a factory.
Definition: plugin.h:89