PipeWire  0.3.59
device.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2018 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PIPEWIRE_DEVICE_H
26 #define PIPEWIRE_DEVICE_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <spa/utils/defs.h>
33 #include <spa/utils/hook.h>
34 
35 #include <pipewire/proxy.h>
36 
46 #define PW_TYPE_INTERFACE_Device PW_TYPE_INFO_INTERFACE_BASE "Device"
47 
48 #define PW_VERSION_DEVICE 3
49 struct pw_device;
50 
52 struct pw_device_info {
53  uint32_t id;
54 #define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0)
55 #define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1)
56 #define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1)
57  uint64_t change_mask;
58  struct spa_dict *props;
60  uint32_t n_params;
61 };
62 
66  const struct pw_device_info *update);
68 struct pw_device_info *
70  const struct pw_device_info *update, bool reset);
72 void pw_device_info_free(struct pw_device_info *info);
73 
74 #define PW_DEVICE_EVENT_INFO 0
75 #define PW_DEVICE_EVENT_PARAM 1
76 #define PW_DEVICE_EVENT_NUM 2
77 
79 struct pw_device_events {
80 #define PW_VERSION_DEVICE_EVENTS 0
81  uint32_t version;
87  void (*info) (void *data, const struct pw_device_info *info);
99  void (*param) (void *data, int seq,
100  uint32_t id, uint32_t index, uint32_t next,
101  const struct spa_pod *param);
102 };
103 
104 
105 #define PW_DEVICE_METHOD_ADD_LISTENER 0
106 #define PW_DEVICE_METHOD_SUBSCRIBE_PARAMS 1
107 #define PW_DEVICE_METHOD_ENUM_PARAMS 2
108 #define PW_DEVICE_METHOD_SET_PARAM 3
109 #define PW_DEVICE_METHOD_NUM 4
110 
112 struct pw_device_methods {
113 #define PW_VERSION_DEVICE_METHODS 0
114  uint32_t version;
115 
116  int (*add_listener) (void *object,
117  struct spa_hook *listener,
118  const struct pw_device_events *events,
119  void *data);
129  int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
130 
143  int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num,
144  const struct spa_pod *filter);
152  int (*set_param) (void *object, uint32_t id, uint32_t flags,
153  const struct spa_pod *param);
154 };
155 
156 #define pw_device_method(o,method,version,...) \
157 ({ \
158  int _res = -ENOTSUP; \
159  spa_interface_call_res((struct spa_interface*)o, \
160  struct pw_device_methods, _res, \
161  method, version, ##__VA_ARGS__); \
162  _res; \
163 })
164 
165 #define pw_device_add_listener(c,...) pw_device_method(c,add_listener,0,__VA_ARGS__)
166 #define pw_device_subscribe_params(c,...) pw_device_method(c,subscribe_params,0,__VA_ARGS__)
167 #define pw_device_enum_params(c,...) pw_device_method(c,enum_params,0,__VA_ARGS__)
168 #define pw_device_set_param(c,...) pw_device_method(c,set_param,0,__VA_ARGS__)
169 
174 #ifdef __cplusplus
175 } /* extern "C" */
176 #endif
177 
178 #endif /* PIPEWIRE_DEVICE_H */
spa/utils/defs.h
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:420
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
void pw_device_info_free(struct pw_device_info *info)
Free a pw_device_info.
Definition: introspect.c:478
spa/utils/hook.h
pipewire/proxy.h
Device events.
Definition: device.h:92
void(* info)(void *data, const struct pw_device_info *info)
Notify device info.
Definition: device.h:101
uint32_t version
Definition: device.h:95
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:113
The device information.
Definition: device.h:59
uint32_t id
id of the global
Definition: device.h:60
uint64_t change_mask
bitfield of changed fields since last call
Definition: device.h:67
uint32_t n_params
number of items in params
Definition: device.h:70
struct spa_param_info * params
parameters
Definition: device.h:69
Device methods.
Definition: device.h:131
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: device.h:149
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:163
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:172
uint32_t version
Definition: device.h:134
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition: device.h:136
Definition: dict.h:59
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351
information about a parameter
Definition: param.h:70
Definition: pod.h:63