PipeWire: pipewire/device.h Source File

PipeWire 1.4.1 |

Loading...
Searching...
No Matches
device.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_DEVICE_H
6#define PIPEWIRE_DEVICE_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/defs.h>
13#include <spa/utils/hook.h>
14
15#include <pipewire/proxy.h>
16
20
25
26#define PW_TYPE_INTERFACE_Device PW_TYPE_INFO_INTERFACE_BASE "Device"
27
28#define PW_DEVICE_PERM_MASK PW_PERM_RWXM
29
30#define PW_VERSION_DEVICE 3
31 struct pw_device;
32
33#ifndef PW_API_DEVICE_IMPL
34#define PW_API_DEVICE_IMPL static inline
35#endif
36
38 struct pw_device_info {
39 uint32_t id;
40#define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0)
41#define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1)
42#define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1)
43 uint64_t change_mask;
44 struct spa_dict *props;
45 struct spa_param_info *params;
46 uint32_t n_params;
47};
48
50 struct pw_device_info *
51 pw_device_info_update(struct pw_device_info *info,
52 const struct pw_device_info *update);
54 struct pw_device_info *
55 pw_device_info_merge(struct pw_device_info *info,
56 const struct pw_device_info *update, bool reset);
58 void pw_device_info_free(struct pw_device_info *info);
59
60#define PW_DEVICE_EVENT_INFO 0
61#define PW_DEVICE_EVENT_PARAM 1
62#define PW_DEVICE_EVENT_NUM 2
63
65struct pw_device_events {
66#define PW_VERSION_DEVICE_EVENTS 0
67 uint32_t version;
73 void (*info) (void *data, const struct pw_device_info *info);
80 * \param id the param id
81 * \param index the param index
82 * \param next the param index of the next param
83 * \param param the parameter
84 */
85 void (*param) (void *data, int seq,
86 uint32_t id, uint32_t index, uint32_t next,
87 const struct spa_pod *param);
88};
89
90
91#define PW_DEVICE_METHOD_ADD_LISTENER 0
92#define PW_DEVICE_METHOD_SUBSCRIBE_PARAMS 1
93#define PW_DEVICE_METHOD_ENUM_PARAMS 2
94#define PW_DEVICE_METHOD_SET_PARAM 3
95#define PW_DEVICE_METHOD_NUM 4
96
98struct pw_device_methods {
99#define PW_VERSION_DEVICE_METHODS 0
100 uint32_t version;
101
102 int (*add_listener) (void *object,
103 struct spa_hook *listener,
104 const struct pw_device_events *events,
105 void *data);
117 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
118
119 /**
120 * Enumerate device parameters
121 *
122 * Start enumeration of device parameters. For each param, a
123 * param event will be emitted.
124 *
125 * \param seq a sequence number to place in the reply
126 * \param id the parameter id to enum or PW_ID_ANY for all
127 * \param start the start index or 0 for the first param
128 * \param num the maximum number of params to retrieve
129 * \param filter a param filter or NULL
130 *
131 * This requires X permissions on the device.
132 */
133 int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num,
134 const struct spa_pod *filter);
144 int (*set_param) (void *object, uint32_t id, uint32_t flags,
145 const struct spa_pod *param);
146};
147
150 PW_API_DEVICE_IMPL int pw_device_add_listener(struct pw_device *object,
151 struct spa_hook *listener,
152 const struct pw_device_events *events,
153 void *data)
154{
155 return spa_api_method_r(int, -ENOTSUP,
156 pw_device, (struct spa_interface*)object, add_listener, 0,
157 listener, events, data);
158}
161 PW_API_DEVICE_IMPL int pw_device_subscribe_params(struct pw_device *object, uint32_t *ids, uint32_t n_ids)
162{
163 return spa_api_method_r(int, -ENOTSUP,
164 pw_device, (struct spa_interface*)object, subscribe_params, 0,
165 ids, n_ids);
166}
169 PW_API_DEVICE_IMPL int pw_device_enum_params(struct pw_device *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_device, (struct spa_interface*)object, enum_params, 0,
175 seq, id, start, num, filter);
176}
179 PW_API_DEVICE_IMPL int pw_device_set_param(struct pw_device *object, uint32_t id, uint32_t flags,
180 const struct spa_pod *param)
181{
182 return spa_api_method_r(int, -ENOTSUP,
183 pw_device, (struct spa_interface*)object, set_param, 0,
184 id, flags, param);
185}
186
189
190
191#ifdef __cplusplus
192} /* extern "C" */
193#endif
194
195#endif /* PIPEWIRE_DEVICE_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_device_add_listener
PW_API_DEVICE_IMPL int pw_device_add_listener(struct pw_device *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition device.h:172
pw_device_subscribe_params
PW_API_DEVICE_IMPL int pw_device_subscribe_params(struct pw_device *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition device.h:183
pw_device_info_free
void pw_device_info_free(struct pw_device_info *info)
Free a pw_device_info.
Definition introspect.c:471
pw_device_enum_params
PW_API_DEVICE_IMPL int pw_device_enum_params(struct pw_device *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter)
Enumerate device parameters.
Definition device.h:191
pw_device_info_merge
struct pw_device_info * pw_device_info_merge(struct pw_device_info *info, const struct pw_device_info *update, bool reset)
Merge and existing pw_device_info with update.
Definition introspect.c:409
pw_device_set_param
PW_API_DEVICE_IMPL int pw_device_set_param(struct pw_device *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on the device.
Definition device.h:201
pw_device_info_update
struct pw_device_info * pw_device_info_update(struct pw_device_info *info, const struct pw_device_info *update)
Update and existing pw_device_info with update and reset.
Definition introspect.c:464
PW_API_DEVICE_IMPL
#define PW_API_DEVICE_IMPL
Definition device.h:43
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
proxy.h
pipewire/proxy.h
pw_device_events
Device events.
Definition device.h:80
pw_device_events::version
uint32_t version
Definition device.h:83
pw_device_events::param
void(* param)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a device param.
Definition device.h:101
pw_device_info
The device information.
Definition device.h:47
pw_device_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition device.h:55
pw_device_info::n_params
uint32_t n_params
number of items in params
Definition device.h:58
pw_device_info::params
struct spa_param_info * params
parameters
Definition device.h:57
pw_device_methods
Device methods.
Definition device.h:119
pw_device_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition device.h:139
pw_device_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 device parameters.
Definition device.h:155
pw_device_methods::set_param
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on the device.
Definition device.h:166
pw_device_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition device.h:124
pw_device
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