PipeWire  0.2.7
core.h
Go to the documentation of this file.
1 /* PipeWire
2  * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __PIPEWIRE_CORE_H__
21 #define __PIPEWIRE_CORE_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <spa/utils/defs.h>
28 #include <spa/utils/hook.h>
29 
38 struct pw_core;
39 
40 #include <pipewire/type.h>
41 #include <pipewire/client.h>
42 #include <pipewire/global.h>
43 #include <pipewire/introspect.h>
44 #include <pipewire/loop.h>
45 #include <pipewire/factory.h>
46 #include <pipewire/port.h>
47 #include <pipewire/properties.h>
48 
76 #define PW_PERM_R 0400
77 #define PW_PERM_W 0200
78 #define PW_PERM_X 0100
80 #define PW_PERM_RWX (PW_PERM_R|PW_PERM_W|PW_PERM_X)
81 
82 #define PW_PERM_IS_R(p) (((p)&PW_PERM_R) == PW_PERM_R)
83 #define PW_PERM_IS_W(p) (((p)&PW_PERM_W) == PW_PERM_W)
84 #define PW_PERM_IS_X(p) (((p)&PW_PERM_X) == PW_PERM_X)
85 
87 struct pw_core_events {
88 #define PW_VERSION_CORE_EVENTS 0
89  uint32_t version;
90 
92  void (*destroy) (void *data);
94  void (*free) (void *data);
96  void (*info_changed) (void *data, struct pw_core_info *info);
98  void (*global_added) (void *data, struct pw_global *global);
100  void (*global_removed) (void *data, struct pw_global *global);
101 };
102 
104 #define PW_CORE_PROP_USER_NAME "pipewire.core.user-name"
105 
106 #define PW_CORE_PROP_HOST_NAME "pipewire.core.host-name"
107 
108 #define PW_CORE_PROP_NAME "pipewire.core.name"
109 
110 #define PW_CORE_PROP_VERSION "pipewire.core.version"
111 
112 #define PW_CORE_PROP_DAEMON "pipewire.daemon"
113 
115 struct pw_core * pw_core_new(struct pw_loop *main_loop, struct pw_properties *props);
116 
118 void pw_core_destroy(struct pw_core *core);
119 
121 void pw_core_add_listener(struct pw_core *core,
122  struct spa_hook *listener,
123  const struct pw_core_events *events,
124  void *data);
125 
127 struct pw_type *pw_core_get_type(struct pw_core *core);
128 
130 const struct pw_core_info *pw_core_get_info(struct pw_core *core);
131 
133 struct pw_global *pw_core_get_global(struct pw_core *core);
134 
136 const struct pw_properties *pw_core_get_properties(struct pw_core *core);
137 
139 int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict);
140 
142 const struct spa_support *pw_core_get_support(struct pw_core *core, uint32_t *n_support);
143 
145 struct pw_loop *pw_core_get_main_loop(struct pw_core *core);
146 
151 int pw_core_for_each_global(struct pw_core *core,
152  int (*callback) (void *data, struct pw_global *global),
153  void *data);
154 
156 struct pw_global *pw_core_find_global(struct pw_core *core,
157  uint32_t id );
158 
160 struct pw_factory *
161 pw_core_find_factory(struct pw_core *core ,
162  const char *name );
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* __PIPEWIRE_CORE_H__ */
PW_CORE_PROP_USER_NAME
#define PW_CORE_PROP_USER_NAME
The user name that started the core.
Definition: core.h:105
pw_global::pw_global_register
SPA_EXPORT int pw_global_register(struct pw_global *global, struct pw_client *owner, struct pw_global *parent)
register a global to the core registry
Definition: global.c:102
pw_registry_proxy_methods
Registry methods.
Definition: interfaces.h:380
pw_core_add_listener
SPA_EXPORT void pw_core_add_listener(struct pw_core *core, struct spa_hook *listener, const struct pw_core_events *events, void *data)
Add a new event listener to a core.
Definition: core.c:543
global.h
PW_VERSION_CORE_PROXY_METHODS
#define PW_VERSION_CORE_PROXY_METHODS
Definition: interfaces.h:115
pw_log::pw_log_level_enabled
#define pw_log_level_enabled(lev)
Check if a loglevel is enabled.
Definition: log.h:62
PW_CORE_PROP_VERSION
#define PW_CORE_PROP_VERSION
The version of the core.
Definition: core.h:111
data-loop.h
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:152
port.h
introspect.h
pw_pipewire::pw_get_host_name
const SPA_EXPORT char * pw_get_host_name(void)
Get the host name.
Definition: pipewire.c:353
factory.h
PW_DIRECTION_OUTPUT
an output port direction
Definition: introspect.h:49
pw_core_info
The core information.
Definition: introspect.h:76
pw_factory
PipeWire factory interface.
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:128
pw_core_get_type
SPA_EXPORT struct pw_type * pw_core_get_type(struct pw_core *core)
Get the type object of a core.
Definition: core.c:552
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:241
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:70
pw_node
pw_core_for_each_global
int pw_core_for_each_global(struct pw_core *core, int(*callback)(void *data, struct pw_global *global), void *data)
Iterate the globals of the core.
Definition: core.c:613
pw_core_events::destroy
void(* destroy)(void *data)
The core is being destroyed.
Definition: core.h:93
pw_remote
Represents a connection with a remote PipeWire instance.
resource_data
Definition: factory.c:26
pw_client
PipeWire client object class.
pw_core_add_listener
void pw_core_add_listener(struct pw_core *core, struct spa_hook *listener, const struct pw_core_events *events, void *data)
Add a new event listener to a core.
Definition: core.c:543
interfaces.h
pw_core_get_support
const struct spa_support * pw_core_get_support(struct pw_core *core, uint32_t *n_support)
Get the core support objects.
Definition: core.c:558
pw_core_events::version
uint32_t version
Definition: core.h:90
resource_data::resource_listener
struct spa_hook resource_listener
Definition: factory.c:27
pw_node::pw_node_destroy
SPA_EXPORT void pw_node_destroy(struct pw_node *node)
Destroy a node.
Definition: node.c:626
pw_global::pw_global_bind
SPA_EXPORT int pw_global_bind(struct pw_global *global, struct pw_client *client, uint32_t permissions, uint32_t version, uint32_t id)
Bind to a global.
Definition: global.c:213
pw_loop
Definition: loop.h:37
PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: introspect.h:38
pw_core_resource_remove_id
#define pw_core_resource_remove_id(r,...)
Definition: interfaces.h:339
PW_VERSION_CORE
#define PW_VERSION_CORE
Definition: interfaces.h:69
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:59
pw_resource_set_implementation
void pw_resource_set_implementation(struct pw_resource *resource, const void *implementation, void *data)
Set the resource implementation.
Definition: resource.c:128
pw_registry_resource_global
#define pw_registry_resource_global(r,...)
Definition: interfaces.h:455
pw_factory_create_object
void * pw_factory_create_object(struct pw_factory *factory, struct pw_resource *resource, uint32_t type, uint32_t version, struct pw_properties *properties, uint32_t new_id)
Definition: factory.c:213
pw_get_library_version
const SPA_EXPORT char * pw_get_library_version(void)
Get the currently running version.
Definition: pipewire.c:452
PW_VERSION_REGISTRY_PROXY_METHODS
#define PW_VERSION_REGISTRY_PROXY_METHODS
Definition: interfaces.h:381
pw_core_find_global
SPA_EXPORT struct pw_global * pw_core_find_global(struct pw_core *core, uint32_t id)
Find a core global by id.
Definition: core.c:631
pw_loop::utils
struct spa_loop_utils * utils
loop utils
Definition: loop.h:40
pw_core_resource_done
#define pw_core_resource_done(r,...)
Definition: interfaces.h:337
PW_PERM_RWX
#define PW_PERM_RWX
Definition: core.h:81
pw_type::pw_type_init
int pw_type_init(struct pw_type *type)
Initializes the type system.
Definition: type.c:44
pw_global_add_listener
void pw_global_add_listener(struct pw_global *global, struct spa_hook *listener, const struct pw_global_events *events, void *data)
Add an event listener on the global.
Definition: global.c:190
pw_core_events::global_removed
void(* global_removed)(void *data, struct pw_global *global)
a global object was removed
Definition: core.h:101
pw_global
A global object visible to remote clients.
pw_core_get_info
SPA_EXPORT const struct pw_core_info * pw_core_get_info(struct pw_core *core)
Get the core info object.
Definition: core.c:531
pw_type
PipeWire type support struct.
Definition: type.h:51
pw_properties::dict
struct spa_dict dict
Definition: properties.h:39
pw_core_events::free
void(* free)(void *data)
The core is being freed.
Definition: core.h:95
type.h
pw_map::pw_map_for_each
static int pw_map_for_each(struct pw_map *map, int(*func)(void *item_data, void *data), void *data)
Iterate all map items.
Definition: map.h:171
pw_type::core
uint32_t core
Definition: type.h:54
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:114
pw_core_resource_info
#define pw_core_resource_info(r,...)
Definition: interfaces.h:340
pw_map::PW_MAP_ID_TO_PTR
#define PW_MAP_ID_TO_PTR(id)
Convert an id to a pointer that can be inserted into the map.
Definition: map.h:60
pw_global::pw_global_new
SPA_EXPORT struct pw_global * pw_global_new(struct pw_core *core, uint32_t type, uint32_t version, struct pw_properties *properties, void *object)
Create a new global.
Definition: global.c:61
protocol.h
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:338
pw_core_for_each_global
SPA_EXPORT int pw_core_for_each_global(struct pw_core *core, int(*callback)(void *data, struct pw_global *global), void *data)
Iterate the globals of the core.
Definition: core.c:613
pw_remote::pw_remote_destroy
void pw_remote_destroy(struct pw_remote *remote)
Destroy a remote.
Definition: remote.c:294
pw_data_loop::pw_data_loop_new
SPA_EXPORT struct pw_data_loop * pw_data_loop_new(struct pw_properties *properties)
Create a new pw_data_loop.
Definition: data-loop.c:60
pw_port
pw_module
pw_core_events::info_changed
void(* info_changed)(void *data, struct pw_core_info *info)
The core info changed, use pw_core_get_info() to get the updated info.
Definition: core.h:97
pw_core::pw_core_find_port
struct pw_port * pw_core_find_port(struct pw_core *core, struct pw_port *other_port, uint32_t id, struct pw_properties *props, uint32_t n_format_filters, struct spa_pod **format_filters, char **error)
Find a port to link with.
Definition: core.c:659
pw_resource_new
struct pw_resource * pw_resource_new(struct pw_client *client, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:34
pw_core_get_main_loop
SPA_EXPORT struct pw_loop * pw_core_get_main_loop(struct pw_core *core)
get the core main loop
Definition: core.c:565
pw_pipewire::pw_get_user_name
const SPA_EXPORT char * pw_get_user_name(void)
Get the user name.
Definition: pipewire.c:341
pw_module::pw_module_destroy
SPA_EXPORT void pw_module_destroy(struct pw_module *module)
Destroy a module.
Definition: module.c:287
pw_core::pw_core_find_format
int pw_core_find_format(struct pw_core *core, struct pw_port *output, struct pw_port *input, struct pw_properties *props, uint32_t n_format_filters, struct spa_pod **format_filters, struct spa_pod **format, struct spa_pod_builder *builder, char **error)
Find a common format between two ports.
Definition: core.c:755
PW_VERSION_RESOURCE_EVENTS
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:63
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:90
pw_properties::pw_properties_new_dict
SPA_EXPORT struct pw_properties * pw_properties_new_dict(const struct spa_dict *dict)
Make a new properties object from the given dictionary.
Definition: properties.c:119
PW_PERM_IS_R
#define PW_PERM_IS_R(p)
Definition: core.h:83
pw_core::pw_core_new
SPA_EXPORT struct pw_core * pw_core_new(struct pw_loop *main_loop, struct pw_properties *properties)
Create a new core object.
Definition: core.c:377
pw_resource_get_user_data
void * pw_resource_get_user_data(struct pw_resource *resource)
Get the user data for the resource, the size was given in pw_resource_new.
Definition: resource.c:113
PW_CORE_PROP_HOST_NAME
#define PW_CORE_PROP_HOST_NAME
The host name of the machine.
Definition: core.h:107
pw_core::pw_core_destroy
SPA_EXPORT void pw_core_destroy(struct pw_core *core)
Destroy a core object.
Definition: core.c:486
pw_map::pw_map_clear
static void pw_map_clear(struct pw_map *map)
Clear a map.
Definition: map.h:81
PW_CORE_CHANGE_MASK_ALL
#define PW_CORE_CHANGE_MASK_ALL
Definition: introspect.h:84
pw_properties::pw_properties_get
const SPA_EXPORT char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:361
pw_core_get_main_loop
struct pw_loop * pw_core_get_main_loop(struct pw_core *core)
get the core main loop
Definition: core.c:565
pw_client_update_permissions
int pw_client_update_permissions(struct pw_client *client, const struct spa_dict *dict)
Update the client permissions.
Definition: client.c:452
pw_log::pw_log_get
SPA_EXPORT struct spa_log * pw_log_get(void)
Get the global log interface.
Definition: log.c:45
PW_CORE_CHANGE_MASK_PROPS
#define PW_CORE_CHANGE_MASK_PROPS
Definition: introspect.h:83
pw_core_get_support
SPA_EXPORT const struct spa_support * pw_core_get_support(struct pw_core *core, uint32_t *n_support)
Get the core support objects.
Definition: core.c:558
pw_global_get_permissions
uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_client *client)
Get the permissions of the global for a given client.
Definition: global.c:37
pw_core_proxy_methods
Core methods.
Definition: interfaces.h:114
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:308
pw_node::pw_node_get_free_port
struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction direction)
pw_node_get_free_port:
Definition: node.c:760
pw_core
the core PipeWire object
pw_resource
Client owned objects.
log.h
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:169
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:60
pw_core_get_properties
const struct pw_properties * pw_core_get_properties(struct pw_core *core)
Get the core properties.
Definition: core.c:571
pw_core_get_type
struct pw_type * pw_core_get_type(struct pw_core *core)
Get the type object of a core.
Definition: core.c:552
pw_pipewire::pw_direction_reverse
enum pw_direction pw_direction_reverse(enum pw_direction direction)
Reverse the direction.
Definition: pipewire.c:441
loop.h
pw_core::pw_core_find_factory
SPA_EXPORT struct pw_factory * pw_core_find_factory(struct pw_core *core, const char *name)
Find a factory by name.
Definition: core.c:883
pw_type::param
struct spa_type_param param
Definition: type.h:71
core.h
pw_core_get_info
const struct pw_core_info * pw_core_get_info(struct pw_core *core)
Get the core info object.
Definition: core.c:531
pw_core_resource_error
#define pw_core_resource_error(r,...)
Definition: interfaces.h:338
pw_core_get_global
struct pw_global * pw_core_get_global(struct pw_core *core)
Get the core global object.
Definition: core.c:537
pw_core::pw_core_update_properties
SPA_EXPORT int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
Update core properties.
Definition: core.c:586
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:89
pw_log::pw_log_error
void pw_log_error(const char *format,...)
pw_core_get_properties
SPA_EXPORT const struct pw_properties * pw_core_get_properties(struct pw_core *core)
Get the core properties.
Definition: core.c:571
pipewire.h
properties.h
pw_core_find_global
struct pw_global * pw_core_find_global(struct pw_core *core, uint32_t id)
Find a core global by id.
Definition: core.c:631
pw_map::pw_map_insert_at
static bool pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
Insert data in the map at an index.
Definition: map.h:119
pw_loop::loop
struct spa_loop * loop
wrapped loop
Definition: loop.h:38
pw_release_spa_dbus
int pw_release_spa_dbus(void *dbus)
Definition: pipewire.c:236
pw_client::pw_client_update_properties
SPA_EXPORT int pw_client_update_properties(struct pw_client *client, const struct spa_dict *dict)
Update client properties.
Definition: client.c:353
pw_resource_events
Resource events.
Definition: resource.h:62
PW_CORE_PROP_NAME
#define PW_CORE_PROP_NAME
The name of the core.
Definition: core.h:109
pw_resource_add_listener
void pw_resource_add_listener(struct pw_resource *resource, struct spa_hook *listener, const struct pw_resource_events *events, void *data)
Add an event listener.
Definition: resource.c:119
pw_get_spa_dbus
void * pw_get_spa_dbus(struct pw_loop *loop)
Definition: pipewire.c:202
pw_resource_events::version
uint32_t version
Definition: resource.h:64
client.h
pw_log::pw_log_debug
void pw_log_debug(const char *format,...)
PW_PORT_STATE_CONFIGURE
the port is ready for format negotiation
Definition: port.h:53
pw_core_events::global_added
void(* global_added)(void *data, struct pw_global *global)
a new global object was added
Definition: core.h:99
pw_properties
A collection of key/value pairs.
Definition: properties.h:38
pw_core_get_global
SPA_EXPORT struct pw_global * pw_core_get_global(struct pw_core *core)
Get the core global object.
Definition: core.c:537
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:245
pw_core_events
core events emited by the core object added with pw_core_add_listener
Definition: core.h:88