PipeWire  0.3.33
build-12683127/doc/spa/monitor/device.h
Go to the documentation of this file.
1 /* Simple Plugin API
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 SPA_DEVICE_H
26 #define SPA_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 #include <spa/utils/dict.h>
35 #include <spa/pod/event.h>
36 
50 #define SPA_TYPE_INTERFACE_Device SPA_TYPE_INFO_INTERFACE_BASE "Device"
51 
52 #define SPA_VERSION_DEVICE 0
53 struct spa_device { struct spa_interface iface; };
54 
61 #define SPA_VERSION_DEVICE_INFO 0
62  uint32_t version;
63 
64 #define SPA_DEVICE_CHANGE_MASK_FLAGS (1u<<0)
65 #define SPA_DEVICE_CHANGE_MASK_PROPS (1u<<1)
66 #define SPA_DEVICE_CHANGE_MASK_PARAMS (1u<<2)
67  uint64_t change_mask;
68  uint64_t flags;
69  const struct spa_dict *props;
71  uint32_t n_params;
72 };
73 
74 #define SPA_DEVICE_INFO_INIT() (struct spa_device_info){ SPA_VERSION_DEVICE_INFO, }
75 
82 #define SPA_VERSION_DEVICE_OBJECT_INFO 0
83  uint32_t version;
84 
85  const char *type;
86  const char *factory_name;
88 #define SPA_DEVICE_OBJECT_CHANGE_MASK_FLAGS (1u<<0)
89 #define SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS (1u<<1)
90  uint64_t change_mask;
91  uint64_t flags;
92  const struct spa_dict *props;
93 };
94 
95 #define SPA_DEVICE_OBJECT_INFO_INIT() (struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, }
96 
98 #define SPA_RESULT_TYPE_DEVICE_PARAMS 1
100  uint32_t id;
101  uint32_t index;
102  uint32_t next;
103  struct spa_pod *param;
104 };
105 
106 #define SPA_DEVICE_EVENT_INFO 0
107 #define SPA_DEVICE_EVENT_RESULT 1
108 #define SPA_DEVICE_EVENT_EVENT 2
109 #define SPA_DEVICE_EVENT_OBJECT_INFO 3
110 #define SPA_DEVICE_EVENT_NUM 4
111 
119 #define SPA_VERSION_DEVICE_EVENTS 0
120  uint32_t version;
121 
123  void (*info) (void *data, const struct spa_device_info *info);
124 
126  void (*result) (void *data, int seq, int res, uint32_t type, const void *result);
127 
129  void (*event) (void *data, const struct spa_event *event);
130 
133  void (*object_info) (void *data, uint32_t id,
134  const struct spa_device_object_info *info);
135 };
136 
137 #define SPA_DEVICE_METHOD_ADD_LISTENER 0
138 #define SPA_DEVICE_METHOD_SYNC 1
139 #define SPA_DEVICE_METHOD_ENUM_PARAMS 2
140 #define SPA_DEVICE_METHOD_SET_PARAM 3
141 #define SPA_DEVICE_METHOD_NUM 4
142 
147  /* the version of the methods. This can be used to expand this
148  * structure in the future */
149 #define SPA_VERSION_DEVICE_METHODS 0
150  uint32_t version;
151 
167  int (*add_listener) (void *object,
168  struct spa_hook *listener,
169  const struct spa_device_events *events,
170  void *data);
186  int (*sync) (void *object, int seq);
187 
213  int (*enum_params) (void *object, int seq,
214  uint32_t id, uint32_t index, uint32_t max,
215  const struct spa_pod *filter);
216 
238  int (*set_param) (void *object,
239  uint32_t id, uint32_t flags,
240  const struct spa_pod *param);
241 };
242 
243 #define spa_device_method(o,method,version,...) \
244 ({ \
245  int _res = -ENOTSUP; \
246  struct spa_device *_o = o; \
247  spa_interface_call_res(&_o->iface, \
248  struct spa_device_methods, _res, \
249  method, version, ##__VA_ARGS__); \
250  _res; \
251 })
252 
253 #define spa_device_add_listener(d,...) spa_device_method(d, add_listener, 0, __VA_ARGS__)
254 #define spa_device_sync(d,...) spa_device_method(d, sync, 0, __VA_ARGS__)
255 #define spa_device_enum_params(d,...) spa_device_method(d, enum_params, 0, __VA_ARGS__)
256 #define spa_device_set_param(d,...) spa_device_method(d, set_param, 0, __VA_ARGS__)
257 
258 #define SPA_KEY_DEVICE_ENUM_API "device.enum.api"
260 #define SPA_KEY_DEVICE_API "device.api"
262 #define SPA_KEY_DEVICE_NAME "device.name"
263 #define SPA_KEY_DEVICE_ALIAS "device.alias"
264 #define SPA_KEY_DEVICE_NICK "device.nick"
265 #define SPA_KEY_DEVICE_DESCRIPTION "device.description"
266 #define SPA_KEY_DEVICE_ICON "device.icon"
268 #define SPA_KEY_DEVICE_ICON_NAME "device.icon-name"
270 #define SPA_KEY_DEVICE_PLUGGED_USEC "device.plugged.usec"
272 #define SPA_KEY_DEVICE_BUS_ID "device.bus-id"
273 #define SPA_KEY_DEVICE_BUS_PATH "device.bus-path"
276 #define SPA_KEY_DEVICE_BUS "device.bus"
279 #define SPA_KEY_DEVICE_SUBSYSTEM "device.subsystem"
280 #define SPA_KEY_DEVICE_SYSFS_PATH "device.sysfs.path"
282 #define SPA_KEY_DEVICE_VENDOR_ID "device.vendor.id"
283 #define SPA_KEY_DEVICE_VENDOR_NAME "device.vendor.name"
284 #define SPA_KEY_DEVICE_PRODUCT_ID "device.product.id"
285 #define SPA_KEY_DEVICE_PRODUCT_NAME "device.product.name"
286 #define SPA_KEY_DEVICE_SERIAL "device.serial"
287 #define SPA_KEY_DEVICE_CLASS "device.class"
288 #define SPA_KEY_DEVICE_CAPABILITIES "device.capabilities"
289 #define SPA_KEY_DEVICE_FORM_FACTOR "device.form-factor"
294 #define SPA_KEY_DEVICE_PROFILE "device.profile "
295 #define SPA_KEY_DEVICE_PROFILE_SET "device.profile-set"
296 #define SPA_KEY_DEVICE_STRING "device.string"
303 #ifdef __cplusplus
304 } /* extern "C" */
305 #endif
306 
307 #endif /* SPA_DEVICE_H */
spa_interface
Definition: hook.h:146
spa_device_info::change_mask
uint64_t change_mask
Definition: build-12683127/doc/spa/monitor/device.h:67
spa_device
Definition: build-12683127/doc/spa/monitor/device.h:53
spa_device_methods::set_param
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set the configurable parameter in device.
Definition: build-12683127/doc/spa/monitor/device.h:238
data
user data to add to an object
Definition: filter.c:75
spa_device_object_info::props
const struct spa_dict * props
extra object properties
Definition: build-12683127/doc/spa/monitor/device.h:92
spa_device_info::props
const struct spa_dict * props
device properties
Definition: build-12683127/doc/spa/monitor/device.h:69
spa_device_methods
spa_device_methods:
Definition: build-12683127/doc/spa/monitor/device.h:146
spa_result_device_params::param
struct spa_pod * param
Definition: build-12683127/doc/spa/monitor/device.h:103
spa_result_device_params
Definition: build-12683127/doc/spa/monitor/device.h:99
spa_device_methods::version
uint32_t version
Definition: build-12683127/doc/spa/monitor/device.h:150
spa_device_events::version
uint32_t version
Definition: build-12683127/doc/spa/monitor/device.h:120
spa_pod
Definition: pod/pod.h:50
sync
Definition: media-session.c:119
filter
Definition: filter.c:126
spa_device_object_info::factory_name
const char * factory_name
a factory name that implements the object
Definition: build-12683127/doc/spa/monitor/device.h:86
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:295
spa_device_info::flags
uint64_t flags
Definition: build-12683127/doc/spa/monitor/device.h:68
spa_param_info
information about a parameter
Definition: param.h:64
spa_dict
Definition: utils/dict.h:48
spa_device_object_info::type
const char * type
the object type managed by this device
Definition: build-12683127/doc/spa/monitor/device.h:85
object_info
Definition: media-session.c:196
spa_device::iface
struct spa_interface iface
Definition: build-12683127/doc/spa/monitor/device.h:53
spa_device_object_info::flags
uint64_t flags
Definition: build-12683127/doc/spa/monitor/device.h:91
spa_device_events::result
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result
Definition: build-12683127/doc/spa/monitor/device.h:126
event.h
param
Definition: filter.c:80
spa_device_info::n_params
uint32_t n_params
number of elements in params
Definition: build-12683127/doc/spa/monitor/device.h:71
spa_device_info::version
uint32_t version
Definition: build-12683127/doc/spa/monitor/device.h:62
spa_device_events::info
void(* info)(void *data, const struct spa_device_info *info)
notify extra information about the device
Definition: build-12683127/doc/spa/monitor/device.h:123
spa_device_info
Information about the device and parameters it supports.
Definition: build-12683127/doc/spa/monitor/device.h:60
spa_device_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct spa_device_events *events, void *data)
Set events to receive asynchronous notifications from the device.
Definition: build-12683127/doc/spa/monitor/device.h:167
spa_device_events::event
void(* event)(void *data, const struct spa_event *event)
a device event
Definition: build-12683127/doc/spa/monitor/device.h:129
spa_event
Definition: pod/event.h:43
spa_result_device_params::next
uint32_t next
Definition: build-12683127/doc/spa/monitor/device.h:102
defs.h
spa_device_methods::enum_params
int(* enum_params)(void *object, int seq, uint32_t id, uint32_t index, uint32_t max, const struct spa_pod *filter)
Enumerate the parameters of a device.
Definition: build-12683127/doc/spa/monitor/device.h:213
spa_result_device_params::id
uint32_t id
Definition: build-12683127/doc/spa/monitor/device.h:100
spa_device_object_info::version
uint32_t version
Definition: build-12683127/doc/spa/monitor/device.h:83
spa_device_events
spa_device_events:
Definition: build-12683127/doc/spa/monitor/device.h:117
hook.h
spa_result_device_params::index
uint32_t index
Definition: build-12683127/doc/spa/monitor/device.h:101
spa_device_object_info::change_mask
uint64_t change_mask
Definition: build-12683127/doc/spa/monitor/device.h:90
spa_device_object_info
Information about a device object.
Definition: build-12683127/doc/spa/monitor/device.h:81
spa_device_info::params
struct spa_param_info * params
supported parameters
Definition: build-12683127/doc/spa/monitor/device.h:70
dict.h