PipeWire  1.4.6
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
9 extern "C" {
10 #endif
11 
12 #include <spa/utils/defs.h>
13 #include <spa/utils/hook.h>
14 
15 #include <pipewire/proxy.h>
16 
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 
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 
52  const struct pw_device_info *update);
56  const struct pw_device_info *update, bool reset);
59 
60 #define PW_DEVICE_EVENT_INFO 0
61 #define PW_DEVICE_EVENT_PARAM 1
62 #define PW_DEVICE_EVENT_NUM 2
63 
65 struct 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);
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 
98 struct 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 
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 
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 }
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 
191 #ifdef __cplusplus
192 } /* extern "C" */
193 #endif
194 
195 #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:172
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_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
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
void pw_device_info_free(struct pw_device_info *info)
Free a pw_device_info.
Definition: introspect.c:471
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_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
#define PW_API_DEVICE_IMPL
Definition: device.h:43
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition: hook.h:291
spa/utils/hook.h
pipewire/proxy.h
Device events.
Definition: device.h:80
void(* info)(void *data, const struct pw_device_info *info)
Notify device info.
Definition: device.h:89
uint32_t version
Definition: device.h:83
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
The device information.
Definition: device.h:47
uint32_t id
id of the global
Definition: device.h:48
uint64_t change_mask
bitfield of changed fields since last call
Definition: device.h:55
uint32_t n_params
number of items in params
Definition: device.h:58
struct spa_param_info * params
parameters
Definition: device.h:57
Device methods.
Definition: device.h:119
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: device.h:139
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
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
uint32_t version
Definition: device.h:122
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition: device.h:124
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