PipeWire 1.7.0
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#include <spa/pod/command.h>
9#include <spa/utils/defs.h>
10#include <spa/utils/hook.h>
11
12#include <pipewire/proxy.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
21
26
27#define PW_TYPE_INTERFACE_Device PW_TYPE_INFO_INTERFACE_BASE "Device"
28
29#define PW_DEVICE_PERM_MASK PW_PERM_RWXM
30
31#define PW_VERSION_DEVICE 3
32struct pw_device;
33
34#ifndef PW_API_DEVICE_IMPL
35#define PW_API_DEVICE_IMPL static inline
36#endif
37
40 uint32_t id;
41#define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0)
42#define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1)
43#define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1)
44 uint64_t change_mask;
45 struct spa_dict *props;
46 struct spa_param_info *params;
47 uint32_t n_params;
48};
53 const struct pw_device_info *update);
57 const struct pw_device_info *update, bool reset);
60
61#define PW_DEVICE_EVENT_INFO 0
62#define PW_DEVICE_EVENT_PARAM 1
63#define PW_DEVICE_EVENT_NUM 2
64
66struct pw_device_events {
67#define PW_VERSION_DEVICE_EVENTS 0
68 uint32_t version;
74 void (*info) (void *data, const struct pw_device_info *info);
81 * \param id the param id
82 * \param index the param index
83 * \param next the param index of the next param
84 * \param param the parameter
85 */
86 void (*param) (void *data, int seq,
87 uint32_t id, uint32_t index, uint32_t next,
88 const struct spa_pod *param);
89};
91
92#define PW_DEVICE_METHOD_ADD_LISTENER 0
93#define PW_DEVICE_METHOD_SUBSCRIBE_PARAMS 1
94#define PW_DEVICE_METHOD_ENUM_PARAMS 2
95#define PW_DEVICE_METHOD_SET_PARAM 3
96#define PW_DEVICE_METHOD_SEND_COMMAND 4
97#define PW_DEVICE_METHOD_NUM 5
98
100struct pw_device_methods {
101#define PW_VERSION_DEVICE_METHODS 1
102 uint32_t version;
103
104 int (*add_listener) (void *object,
105 struct spa_hook *listener,
106 const struct pw_device_events *events,
107 void *data);
119 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
120
122 * Enumerate device parameters
123 *
124 * Start enumeration of device parameters. For each param, a
125 * param event will be emitted.
126 *
127 * \param seq a sequence number to place in the reply
128 * \param id the parameter id to enum or PW_ID_ANY for all
129 * \param start the start index or 0 for the first param
130 * \param num the maximum number of params to retrieve
131 * \param filter a param filter or NULL
132 *
133 * This requires X permissions on the device.
134 */
135 int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num,
136 const struct spa_pod *filter);
146 int (*set_param) (void *object, uint32_t id, uint32_t flags,
147 const struct spa_pod *param);
148
156 int (*send_command) (void *object, const struct spa_command *command);
157};
162 struct spa_hook *listener,
163 const struct pw_device_events *events,
164 void *data)
165{
166 return spa_api_method_r(int, -ENOTSUP,
167 pw_device, (struct spa_interface*)object, add_listener, 0,
168 listener, events, data);
172PW_API_DEVICE_IMPL int pw_device_subscribe_params(struct pw_device *object, uint32_t *ids, uint32_t n_ids)
173{
174 return spa_api_method_r(int, -ENOTSUP,
175 pw_device, (struct spa_interface*)object, subscribe_params, 0,
176 ids, n_ids);
177}
181 int seq, uint32_t id, uint32_t start, uint32_t num,
182 const struct spa_pod *filter)
183{
184 return spa_api_method_r(int, -ENOTSUP,
185 pw_device, (struct spa_interface*)object, enum_params, 0,
186 seq, id, start, num, filter);
187}
190PW_API_DEVICE_IMPL int pw_device_set_param(struct pw_device *object, uint32_t id, uint32_t flags,
191 const struct spa_pod *param)
192{
193 return spa_api_method_r(int, -ENOTSUP,
194 pw_device, (struct spa_interface*)object, set_param, 0,
195 id, flags, param);
196}
199PW_API_DEVICE_IMPL int pw_device_send_command(struct pw_device *object, const struct spa_command *command)
200{
201 return spa_api_method_r(int, -ENOTSUP,
202 pw_device, (struct spa_interface*)object, send_command, 0, command);
204
208
209#ifdef __cplusplus
210} /* extern "C" */
211#endif
212
213#endif /* PIPEWIRE_DEVICE_H */
spa/utils/defs.h
uint32_t int seq
Definition core.h:432
uint32_t id
Definition core.h:432
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:184
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:195
void pw_device_info_free(struct pw_device_info *info)
Free a pw_device_info.
Definition introspect.c:478
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:203
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:416
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:213
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:471
PW_API_DEVICE_IMPL int pw_device_send_command(struct pw_device *object, const struct spa_command *command)
Send a command to the device.
Definition device.h:222
#define PW_API_DEVICE_IMPL
Definition device.h:44
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
spa/utils/hook.h
spa/pod/command.h
pipewire/proxy.h
Device events.
Definition device.h:81
uint32_t version
Definition device.h:84
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:102
The device information.
Definition device.h:48
uint64_t change_mask
bitfield of changed fields since last call
Definition device.h:56
uint32_t n_params
number of items in params
Definition device.h:59
struct spa_param_info * params
parameters
Definition device.h:58
Device methods.
Definition device.h:122
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition device.h:142
int(* send_command)(void *object, const struct spa_command *command)
Send a command to the device.
Definition device.h:179
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:158
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:169
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition device.h:127
Definition command.h:29
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:56
Definition pod.h:57