PipeWire: pipewire/port.h Source File

PipeWire 1.4.2 |

Loading...
Searching...
No Matches
port.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_PORT_H
6#define PIPEWIRE_PORT_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <stdarg.h>
13#include <errno.h>
14
15#include <spa/utils/defs.h>
16#include <spa/utils/hook.h>
17#include <spa/param/param.h>
18
19#include <pipewire/proxy.h>
20
24
29
30#define PW_TYPE_INTERFACE_Port PW_TYPE_INFO_INTERFACE_BASE "Port"
31
32#define PW_PORT_PERM_MASK PW_PERM_R|PW_PERM_X|PW_PERM_M
33
34#define PW_VERSION_PORT 3
35 struct pw_port;
36
37#ifndef PW_API_PORT_IMPL
38#define PW_API_PORT_IMPL static inline
39#endif
40
42#define pw_direction spa_direction
43#define PW_DIRECTION_INPUT SPA_DIRECTION_INPUT
44#define PW_DIRECTION_OUTPUT SPA_DIRECTION_OUTPUT
45
47 const char * pw_direction_as_string(enum pw_direction direction);
48
49struct pw_port_info {
50 uint32_t id;
51 enum pw_direction direction;
52#define PW_PORT_CHANGE_MASK_PROPS (1 << 0)
53#define PW_PORT_CHANGE_MASK_PARAMS (1 << 1)
54#define PW_PORT_CHANGE_MASK_ALL ((1 << 2)-1)
55 uint64_t change_mask;
56 struct spa_dict *props;
57 struct spa_param_info *params;
58 uint32_t n_params;
59};
60
61 struct pw_port_info *
62 pw_port_info_update(struct pw_port_info *info,
63 const struct pw_port_info *update);
64
65struct pw_port_info *
66 pw_port_info_merge(struct pw_port_info *info,
67 const struct pw_port_info *update, bool reset);
68
69 void
70 pw_port_info_free(struct pw_port_info *info);
71
72#define PW_PORT_EVENT_INFO 0
73#define PW_PORT_EVENT_PARAM 1
74#define PW_PORT_EVENT_NUM 2
75
77struct pw_port_events {
78#define PW_VERSION_PORT_EVENTS 0
79 uint32_t version;
85 void (*info) (void *data, const struct pw_port_info *info);
94 * \param next the param index of the next param
95 * \param param the parameter
96 */
97 void (*param) (void *data, int seq,
98 uint32_t id, uint32_t index, uint32_t next,
99 const struct spa_pod *param);
100};
101
102#define PW_PORT_METHOD_ADD_LISTENER 0
103#define PW_PORT_METHOD_SUBSCRIBE_PARAMS 1
104#define PW_PORT_METHOD_ENUM_PARAMS 2
105#define PW_PORT_METHOD_NUM 3
106
108struct pw_port_methods {
109#define PW_VERSION_PORT_METHODS 0
110 uint32_t version;
111
112 int (*add_listener) (void *object,
113 struct spa_hook *listener,
114 const struct pw_port_events *events,
115 void *data);
119
127 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
128
130 * Enumerate port parameters
131 *
132 * Start enumeration of port parameters. For each param, a
133 * param event will be emitted.
134 *
135 * \param seq a sequence number returned in the reply
136 * \param id the parameter id to enumerate
137 * \param start the start index or 0 for the first param
138 * \param num the maximum number of params to retrieve
139 * \param filter a param filter or NULL
140 *
141 * This requires X permissions on the port.
142 */
143 int (*enum_params) (void *object, int seq,
144 uint32_t id, uint32_t start, uint32_t num,
145 const struct spa_pod *filter);
146};
147
150 PW_API_PORT_IMPL int pw_port_add_listener(struct pw_port *object,
151 struct spa_hook *listener,
152 const struct pw_port_events *events,
153 void *data)
154{
155 return spa_api_method_r(int, -ENOTSUP,
156 pw_port, (struct spa_interface*)object, add_listener, 0,
157 listener, events, data);
158}
161 PW_API_PORT_IMPL int pw_port_subscribe_params(struct pw_port *object, uint32_t *ids, uint32_t n_ids)
162{
163 return spa_api_method_r(int, -ENOTSUP,
164 pw_port, (struct spa_interface*)object, subscribe_params, 0,
165 ids, n_ids);
166}
169 PW_API_PORT_IMPL int pw_port_enum_params(struct pw_port *object,
170 int seq, uint32_t id, uint32_t start, uint32_t num,
171 const struct spa_pod *filter)
172{
173 return spa_api_method_r(int, -ENOTSUP,
174 pw_port, (struct spa_interface*)object, enum_params, 0,
175 seq, id, start, num, filter);
176}
177
181
182#ifdef __cplusplus
183} /* extern "C" */
184#endif
185
186#endif /* PIPEWIRE_PORT_H */
defs.h
spa/utils/defs.h
seq
uint32_t int seq
Definition core.h:432
id
uint32_t id
Definition core.h:432
pw_port_add_listener
PW_API_PORT_IMPL int pw_port_add_listener(struct pw_port *object, struct spa_hook *listener, const struct pw_port_events *events, void *data)
Definition port.h:173
pw_direction_as_string
const char * pw_direction_as_string(enum pw_direction direction)
Convert a pw_direction to a readable string.
Definition introspect.c:33
pw_port_info_free
void pw_port_info_free(struct pw_port_info *info)
Definition introspect.c:307
PW_API_PORT_IMPL
#define PW_API_PORT_IMPL
Definition port.h:47
pw_port_subscribe_params
PW_API_PORT_IMPL int pw_port_subscribe_params(struct pw_port *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition port.h:184
pw_port_info_update
struct pw_port_info * pw_port_info_update(struct pw_port_info *info, const struct pw_port_info *update)
Definition introspect.c:300
pw_direction
#define pw_direction
The direction of a port.
Definition port.h:51
pw_port_enum_params
PW_API_PORT_IMPL int pw_port_enum_params(struct pw_port *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter)
Enumerate port parameters.
Definition port.h:192
pw_port_info_merge
struct pw_port_info * pw_port_info_merge(struct pw_port_info *info, const struct pw_port_info *update, bool reset)
Definition introspect.c:243
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
hook.h
spa/utils/hook.h
param.h
spa/param/param.h
proxy.h
pipewire/proxy.h
pw_port_events
Port events.
Definition port.h:94
pw_port_events::version
uint32_t version
Definition port.h:97
pw_port_events::param
void(* param)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a port param.
Definition port.h:115
pw_port_info
Definition port.h:60
pw_port_info::n_params
uint32_t n_params
number of items in params
Definition port.h:72
pw_port_info::params
struct spa_param_info * params
parameters
Definition port.h:71
pw_port_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition port.h:69
pw_port_info::direction
enum pw_direction direction
port direction
Definition port.h:62
pw_port_methods
Port methods.
Definition port.h:130
pw_port_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition port.h:150
pw_port_methods::enum_params
int(* enum_params)(void *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter)
Enumerate port parameters.
Definition port.h:166
pw_port_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_port_events *events, void *data)
Definition port.h:135
pw_port
spa_dict
Definition dict.h:51
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_interface
Definition hook.h:148
spa_param_info
information about a parameter
Definition param.h:51
spa_pod
Definition pod.h:43