PipeWire  0.1.5
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/hook.h>
28 #include <spa/format.h>
29 
38 struct pw_core;
39 
40 #include <pipewire/client.h>
41 #include <pipewire/global.h>
42 #include <pipewire/introspect.h>
43 #include <pipewire/loop.h>
44 #include <pipewire/factory.h>
45 #include <pipewire/port.h>
46 #include <pipewire/properties.h>
47 #include <pipewire/type.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 
84 typedef uint32_t (*pw_permission_func_t) (struct pw_global *global,
85  struct pw_client *client, void *data);
86 
87 #define PW_PERM_IS_R(p) (((p)&PW_PERM_R) == PW_PERM_R)
88 #define PW_PERM_IS_W(p) (((p)&PW_PERM_W) == PW_PERM_W)
89 #define PW_PERM_IS_X(p) (((p)&PW_PERM_X) == PW_PERM_X)
90 
92 struct pw_core_events {
93 #define PW_VERSION_CORE_EVENTS 0
94  uint32_t version;
95 
97  void (*destroy) (void *data);
99  void (*free) (void *data);
101  void (*info_changed) (void *data, struct pw_core_info *info);
103  void (*global_added) (void *data, struct pw_global *global);
105  void (*global_removed) (void *data, struct pw_global *global);
106 };
107 
109 #define PW_CORE_PROP_NAME "pipewire.core.name"
111 #define PW_CORE_PROP_VERSION "pipewire.core.version"
113 #define PW_CORE_PROP_DAEMON "pipewire.daemon"
116 struct pw_core * pw_core_new(struct pw_loop *main_loop, struct pw_properties *props);
117 
119 void pw_core_destroy(struct pw_core *core);
120 
122 void pw_core_add_listener(struct pw_core *core,
123  struct spa_hook *listener,
124  const struct pw_core_events *events,
125  void *data);
126 
129 void pw_core_set_permission_callback(struct pw_core *core,
130  pw_permission_func_t callback,
131  void *data);
132 
134 struct pw_type *pw_core_get_type(struct pw_core *core);
135 
137 const struct pw_core_info *pw_core_get_info(struct pw_core *core);
138 
140 struct pw_global *pw_core_get_global(struct pw_core *core);
141 
143 const struct pw_properties *pw_core_get_properties(struct pw_core *core);
144 
146 void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict);
147 
149 const struct spa_support *pw_core_get_support(struct pw_core *core, uint32_t *n_support);
150 
152 struct pw_loop *pw_core_get_main_loop(struct pw_core *core);
153 
155 bool pw_core_for_each_global(struct pw_core *core,
156  bool (*callback) (void *data, struct pw_global *global),
157  void *data);
158 
160 struct pw_global *pw_core_find_global(struct pw_core *core, uint32_t id);
161 
163 struct spa_format *
164 pw_core_find_format(struct pw_core *core,
165  struct pw_port *output,
166  struct pw_port *input,
167  struct pw_properties *props,
168  uint32_t n_format_filters,
169  struct spa_format **format_filters,
170  char **error);
171 
173 struct pw_port *
174 pw_core_find_port(struct pw_core *core,
175  struct pw_port *other_port,
176  uint32_t id,
177  struct pw_properties *props,
178  uint32_t n_format_filters,
179  struct spa_format **format_filters,
180  char **error);
181 
183 struct pw_factory *
184 pw_core_find_factory(struct pw_core *core, const char *name);
185 
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif /* __PIPEWIRE_CORE_H__ */
const struct pw_properties * pw_core_get_properties(struct pw_core *core)
Get the core properties.
Definition: core.c:553
A collection of key/value pairs.
Definition: properties.h:38
core events emited by the core object added with pw_core_add_listener
Definition: core.h:93
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_format **format_filters, char **error)
Find a ports compatible with other_port and the format filters.
PipeWire loop object provides an implementation of the spa loop interfaces.
Definition: loop.h:37
const struct pw_core_info * pw_core_get_info(struct pw_core *core)
Get the core info object.
Definition: core.c:511
struct spa_dict dict
Definition: properties.h:39
void(* destroy)(void *data)
The core is being destroyed.
Definition: core.h:98
void pw_core_set_permission_callback(struct pw_core *core, pw_permission_func_t callback, void *data)
Set a callback that will be called to check the permissions of a global object for a client...
Definition: core.c:529
const struct spa_support * pw_core_get_support(struct pw_core *core, uint32_t *n_support)
Get the core support objects.
Definition: core.c:542
uint32_t version
Definition: core.h:95
the core PipeWire object
struct pw_global * pw_core_find_global(struct pw_core *core, uint32_t id)
Find a core global by id.
Definition: core.c:598
The core information.
Definition: introspect.h:76
bool pw_core_for_each_global(struct pw_core *core, bool(*callback)(void *data, struct pw_global *global), void *data)
iterate the globals
Definition: core.c:586
uint32_t core
Definition: type.h:51
void(* global_removed)(void *data, struct pw_global *global)
a global object was removed
Definition: core.h:106
void(* free)(void *data)
The core is being freed.
Definition: core.h:100
PipeWire factory interface.
struct pw_global * pw_core_get_global(struct pw_core *core)
Get the core global object.
Definition: core.c:516
struct pw_core * pw_core_new(struct pw_loop *main_loop, struct pw_properties *props)
Make a new core object for a given main_loop.
PipeWire type support struct.
Definition: type.h:48
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:102
struct spa_format * 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_format **format_filters, char **error)
Find a good format between 2 ports.
void pw_core_destroy(struct pw_core *core)
destroy a core object, all resources except the main_loop will be destroyed
void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
Update the core properties.
PipeWire client object class.
struct pw_type * pw_core_get_type(struct pw_core *core)
Get the type object of a core.
Definition: core.c:537
A global object visible to remote clients.
struct pw_loop * pw_core_get_main_loop(struct pw_core *core)
get the core main loop
Definition: core.c:548
struct pw_factory * pw_core_find_factory(struct pw_core *core, const char *name)
Find a factory by name.
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:521
The port object.
uint32_t(* pw_permission_func_t)(struct pw_global *global, struct pw_client *client, void *data)
the permission function.
Definition: core.h:85
void(* global_added)(void *data, struct pw_global *global)
a new global object was added
Definition: core.h:104