PipeWire: context.h Source File

PipeWire 0.3.7

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 */
res
static uint32_t int int res
Definition: core.h:323
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_set_object
int pw_context_set_object(struct pw_context *context, const char *type, void *value)
add an object to the 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_main_loop
struct pw_loop * pw_context_get_main_loop(struct pw_context *context)
get the context main loop
pw_context_create_core
struct pw_impl_core * pw_context_create_core(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: impl-core.c:368
pw_export_type
data for registering export functions
Definition: context.h:165
pw_map::pw_map_lookup
static void * pw_map_lookup(struct pw_map *map, uint32_t id)
Find an item in the map.
Definition: map.h:169
pw_export_type::type
const char * type
Definition: context.h:167
pw_log::pw_log_error
#define pw_log_error(...)
pw_impl_module
pw_context_get_object
void * pw_context_get_object(struct pw_context *context, const char *type)
get an object from the context
pw_context_events::destroy
void(* destroy)(void *data)
The context is being destroyed.
Definition: context.h:101
pw_data_loop::pw_data_loop_start
SPA_EXPORT int pw_data_loop_start(struct pw_data_loop *loop)
Start a data loop.
Definition: data-loop.c:201
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:367
pw_mempool_destroy
void pw_mempool_destroy(struct pw_mempool *pool)
Clear and destroy a pool.
Definition: mem.c:172
pw_map::pw_map_init
static void pw_map_init(struct pw_map *map, size_t size, size_t extend)
Initialize a map.
Definition: map.h:76
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_KEY_CONTEXT_PROFILE_MODULES
#define PW_KEY_CONTEXT_PROFILE_MODULES
a context profile for modules
Definition: keys.h:61
pw_context_get_properties
const struct pw_properties * pw_context_get_properties(struct pw_context *context)
Get the context properties.
resource_data
Definition: impl-core.c:37
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.
data
Definition: filter.c:71
pw_pipewire::pw_get_user_name
SPA_EXPORT const char * pw_get_user_name(void)
Get the user name.
Definition: pipewire.c:492
PW_KEY_APP_PROCESS_ID
#define PW_KEY_APP_PROCESS_ID
process id (pid)
Definition: keys.h:100
resource_data::resource_listener
struct spa_hook resource_listener
Definition: impl-core.c:38
PW_KEY_CPU_MAX_ALIGN
#define PW_KEY_CPU_MAX_ALIGN
maximum alignment needed to support all CPU optimizations
Definition: keys.h:75
pw_core_disconnect
int pw_core_disconnect(struct pw_core *core)
disconnect and destroy a core
Definition: core.c:488
PW_KEY_CORE_VERSION
#define PW_KEY_CORE_VERSION
The version of the core.
Definition: keys.h:68
PW_KEY_APP_LANGUAGE
#define PW_KEY_APP_LANGUAGE
application language if applicable, in standard POSIX format.
Definition: keys.h:97
pw_array_remove
#define pw_array_remove(a, p)
Definition: array.h:77
pw_loop
Definition: loop.h:41
pw_impl_client
PipeWire client object class.
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_impl_node::pw_impl_node_destroy
SPA_EXPORT void pw_impl_node_destroy(struct pw_impl_node *node)
Destroy a node.
Definition: impl-node.c:1581
impl
Definition: control.c:33
PW_PERM_IS_R
#define PW_PERM_IS_R(p)
Definition: permission.h:50
pw_loop::utils
struct spa_loop_utils * utils
loop utils
Definition: loop.h:45
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_context_get_user_data
void * pw_context_get_user_data(struct pw_context *context)
Get the context user data.
pw_array_for_each
#define pw_array_for_each(pos, array)
Definition: array.h:67
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_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
handle
Definition: pipewire.c:58
pw_global
A global object visible to remote clients.
impl.h
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
pw_log::pw_log_info
#define pw_log_info(...)
PW_KEY_APP_PROCESS_USER
#define PW_KEY_APP_PROCESS_USER
user name
Definition: keys.h:102
pw_impl_device_destroy
void pw_impl_device_destroy(struct pw_impl_device *device)
Definition: impl-device.c:179
pw_data_loop_get_loop
struct pw_loop * pw_data_loop_get_loop(struct pw_data_loop *loop)
Get the loop implementation of this data loop.
Definition: data-loop.c:187
pw_pipewire::pw_get_host_name
SPA_EXPORT const char * pw_get_host_name(void)
Get the host name.
Definition: pipewire.c:504
CLOCK_MIN_QUANTUM
#define CLOCK_MIN_QUANTUM
Definition: context.c:46
pw_impl_node
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_properties::pw_properties_setf
SPA_EXPORT int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...)
Set a property value by format.
Definition: properties.c:433
pw_impl_module::pw_context_load_module
SPA_EXPORT struct pw_impl_module * pw_context_load_module(struct pw_context *context, const char *name, const char *args, struct pw_properties *properties)
Load a module.
Definition: impl-module.c:157
queue
Definition: filter.c:64
pw_pipewire::pw_get_prgname
SPA_EXPORT const char * pw_get_prgname(void)
Get the program name.
Definition: pipewire.c:477
PW_KEY_LIBRARY_NAME_DBUS
#define PW_KEY_LIBRARY_NAME_DBUS
name of the dbus library to use
Definition: keys.h:55
pw_pipewire::pw_get_client_name
SPA_EXPORT const char * pw_get_client_name(void)
Get the client name.
Definition: pipewire.c:528
pw_context_events
context events emited by the context object added with pw_context_add_listener
Definition: context.h:96
PW_NODE_STATE_RUNNING
@ PW_NODE_STATE_RUNNING
the node is running
Definition: node.h:55
DEFAULT_CLOCK_QUANTUM
#define DEFAULT_CLOCK_QUANTUM
Definition: context.c:50
PW_KEY_WINDOW_X11_DISPLAY
#define PW_KEY_WINDOW_X11_DISPLAY
window system
Definition: keys.h:110
resource_data::object_listener
struct spa_hook object_listener
Definition: impl-core.c:39
pw_utils::pw_split_walk
SPA_EXPORT const char * pw_split_walk(const char *str, const char *delimiter, size_t *len, const char **state)
Split a string based on delimiters.
Definition: utils.c:45
filter
Definition: filter.c:113
va_start
va_start(args, message)
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_KEY_APP_PROCESS_HOST
#define PW_KEY_APP_PROCESS_HOST
host name
Definition: keys.h:103
pw_log::pw_log_debug
#define pw_log_debug(...)
pw_log::pw_log_warn
#define pw_log_warn(...)
pw_proxy
Represents an object on the client side.
pw_impl_core
PipeWire core interface.
pw_loop::system
struct spa_system * system
system utils
Definition: loop.h:42
PW_KEY_APP_PROCESS_BINARY
#define PW_KEY_APP_PROCESS_BINARY
binary name
Definition: keys.h:101
pw_get_support
uint32_t pw_get_support(struct spa_support *support, uint32_t max_support)
Definition: pipewire.c:221
pw_data_loop::pw_data_loop_destroy
SPA_EXPORT void pw_data_loop_destroy(struct pw_data_loop *loop)
Destroy a data loop.
Definition: data-loop.c:162
pw_properties::pw_properties_update
SPA_EXPORT int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:263
pw_export_type::link
struct spa_list link
Definition: context.h:166
DEFAULT_VIDEO_WIDTH
#define DEFAULT_VIDEO_WIDTH
Definition: context.c:53
DEFAULT_CLOCK_MIN_QUANTUM
#define DEFAULT_CLOCK_MIN_QUANTUM
Definition: context.c:51
buffer
Definition: filter.c:55
pw_impl_core_destroy
void pw_impl_core_destroy(struct pw_impl_core *core)
Definition: impl-core.c:426
pw_map::pw_map_clear
static void pw_map_clear(struct pw_map *map)
Clear a map.
Definition: map.h:87
pw_context
the PipeWire 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_events::free
void(* free)(void *data)
The context is being freed.
Definition: context.h:103
args
static uint32_t int int const char va_list args
Definition: core.h:324
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_array::pw_array_add
static void * pw_array_add(struct pw_array *arr, size_t size)
Add ref size bytes to arr.
Definition: array.h:127
pw_properties::pw_properties_copy
SPA_EXPORT struct pw_properties * pw_properties_copy(const struct pw_properties *properties)
Copy a properties object.
Definition: properties.c:205
param
Definition: filter.c:76
pw_properties::pw_properties_set
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:400
DEFAULT_VIDEO_RATE_NUM
#define DEFAULT_VIDEO_RATE_NUM
Definition: context.c:55
pw_resource
Client owned objects.
log.h
NAME
#define NAME
Definition: context.c:44
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:264
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.
vsnprintf
vsnprintf(buffer, sizeof(buffer), message, args)
CLOCK_MAX_QUANTUM
#define CLOCK_MAX_QUANTUM
Definition: context.c:47
pw_impl_core_register
int pw_impl_core_register(struct pw_impl_core *core, struct pw_properties *properties)
Definition: impl-core.c:551
PW_KEY_LIBRARY_NAME_SYSTEM
#define PW_KEY_LIBRARY_NAME_SYSTEM
name of the system library to use
Definition: keys.h:53
loop.h
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_properties::pw_properties_get
SPA_EXPORT const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:456
pw_impl_node_set_driver
SPA_EXPORT int pw_impl_node_set_driver(struct pw_impl_node *node, struct pw_impl_node *driver)
Definition: impl-node.c:722
va_end
va_end(args)
DEFAULT_MEM_ALLOW_MLOCK
#define DEFAULT_MEM_ALLOW_MLOCK
Definition: context.c:58
PW_KEY_CORE_NAME
#define PW_KEY_CORE_NAME
The name of the core.
Definition: keys.h:66
core.h
pw_load_spa_handle
struct spa_handle * pw_load_spa_handle(const char *lib, const char *factory_name, const struct spa_dict *info, uint32_t n_support, const struct spa_support support[])
Definition: pipewire.c:230
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_mempool_new
struct pw_mempool * pw_mempool_new(struct pw_properties *props)
Create a new memory pool.
Definition: mem.c:135
DEFAULT_VIDEO_HEIGHT
#define DEFAULT_VIDEO_HEIGHT
Definition: context.c:54
impl::this
struct pw_control this
Definition: control.c:34
PW_KEY_APP_NAME
#define PW_KEY_APP_NAME
application keys
Definition: keys.h:90
PW_KEY_APP_PROCESS_SESSION_ID
#define PW_KEY_APP_PROCESS_SESSION_ID
login session of the application, on Unix the value of $XDG_SESSION_ID.
Definition: keys.h:106
pw_impl_link_prepare
int pw_impl_link_prepare(struct pw_impl_link *this)
Definition: impl-link.c:681
pw_impl_node_find_port
struct pw_impl_port * pw_impl_node_find_port(struct pw_impl_node *node, enum pw_direction direction, uint32_t port_id)
Find the port with direction and port_id or NULL when not found.
Definition: impl-node.c:1749
pw_context_events::version
uint32_t version
Definition: context.h:98
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_ANY
#define PW_ID_ANY
Definition: core.h:49
properties.h
pw_impl_module::pw_impl_module_destroy
SPA_EXPORT void pw_impl_module_destroy(struct pw_impl_module *module)
Destroy a module.
Definition: impl-module.c:304
pw_impl_link
pw_data_loop::pw_data_loop_new
SPA_EXPORT struct pw_data_loop * pw_data_loop_new(const struct spa_dict *props)
Create a new pw_data_loop.
Definition: data-loop.c:151
PW_DIRECTION_OUTPUT
#define PW_DIRECTION_OUTPUT
Definition: port.h:49
pw_loop::loop
struct spa_loop * loop
wrapped loop
Definition: loop.h:43
pw_node_state
pw_node_state
Definition: node.h:48
DEFAULT_CLOCK_MAX_QUANTUM
#define DEFAULT_CLOCK_MAX_QUANTUM
Definition: context.c:52
PW_NODE_STATE_IDLE
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: node.h:53
DEFAULT_LINK_MAX_BUFFERS
#define DEFAULT_LINK_MAX_BUFFERS
Definition: context.c:57
pw_context_events::global_added
void(* global_added)(void *data, struct pw_global *global)
a new global object was added
Definition: context.h:107
DEFAULT_VIDEO_RATE_DENOM
#define DEFAULT_VIDEO_RATE_DENOM
Definition: context.c:56
pw_pipewire::pw_direction_reverse
SPA_EXPORT enum pw_direction pw_direction_reverse(enum pw_direction direction)
Reverse the direction.
Definition: pipewire.c:547
pw_impl_port
pw_unload_spa_handle
int pw_unload_spa_handle(struct spa_handle *handle)
Definition: pipewire.c:311
DEFAULT_CLOCK_RATE
#define DEFAULT_CLOCK_RATE
Definition: context.c:49
pw_impl_node::pw_impl_node_set_state
SPA_EXPORT int pw_impl_node_set_state(struct pw_impl_node *node, enum pw_node_state state)
Set the node state.
Definition: impl-node.c:1868
support
Definition: pipewire.c:70
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
pw_impl_device
PipeWire device interface.
pw_array::pw_array_init
static void pw_array_init(struct pw_array *arr, size_t extend)
Initialize the array with given extend.
Definition: array.h:85
PW_IMPL_PORT_STATE_CONFIGURE
@ PW_IMPL_PORT_STATE_CONFIGURE
the port is ready for format negotiation
Definition: impl-port.h:53