PipeWire 1.4.1
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
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
35struct 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
47const char * pw_direction_as_string(enum pw_direction direction);
48
49struct pw_port_info {
50 uint32_t id;
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};
63 const struct pw_port_info *update);
65struct pw_port_info *
67 const struct pw_port_info *update, bool reset);
69void
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);
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);
127 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
128
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
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}
161PW_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);
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
182#ifdef __cplusplus
183} /* extern "C" */
184#endif
185
186#endif /* PIPEWIRE_PORT_H */
spa/utils/defs.h
uint32_t int seq
Definition core.h:432
uint32_t id
Definition core.h:432
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
const char * pw_direction_as_string(enum pw_direction direction)
Convert a pw_direction to a readable string.
Definition introspect.c:33
void pw_port_info_free(struct pw_port_info *info)
Definition introspect.c:307
#define PW_API_PORT_IMPL
Definition port.h:47
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
struct pw_port_info * pw_port_info_update(struct pw_port_info *info, const struct pw_port_info *update)
Definition introspect.c:300
#define pw_direction
The direction of a port.
Definition port.h:51
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
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
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
spa/utils/hook.h
spa/param/param.h
pipewire/proxy.h
Port events.
Definition port.h:94
void(* info)(void *data, const struct pw_port_info *info)
Notify port info.
Definition port.h:103
uint32_t version
Definition port.h:97
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
Definition port.h:60
uint32_t n_params
number of items in params
Definition port.h:72
struct spa_param_info * params
parameters
Definition port.h:71
uint64_t change_mask
bitfield of changed fields since last call
Definition port.h:69
uint32_t id
id of the global
Definition port.h:61
enum pw_direction direction
port direction
Definition port.h:62
Port methods.
Definition port.h:130
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition port.h:150
uint32_t version
Definition port.h:133
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
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_port_events *events, void *data)
Definition port.h:135
Definition dict.h:51
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
Definition hook.h:148
information about a parameter
Definition param.h:51
Definition pod.h:43