PipeWire: spa/monitor/device.h Source File

PipeWire 1.0.0

Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_DEVICE_H
6#define SPA_DEVICE_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/defs.h>
13#include <spa/utils/hook.h>
14#include <spa/utils/dict.h>
15#include <spa/pod/event.h>
16
30#define SPA_TYPE_INTERFACE_Device SPA_TYPE_INFO_INTERFACE_BASE "Device"
31
32#define SPA_VERSION_DEVICE 0
33struct spa_device { struct spa_interface iface; };
34
40 struct spa_device_info {
41#define SPA_VERSION_DEVICE_INFO 0
42 uint32_t version;
43
44#define SPA_DEVICE_CHANGE_MASK_FLAGS (1u<<0)
45#define SPA_DEVICE_CHANGE_MASK_PROPS (1u<<1)
46#define SPA_DEVICE_CHANGE_MASK_PARAMS (1u<<2)
47 uint64_t change_mask;
48 uint64_t flags;
49 const struct spa_dict *props;
50 struct spa_param_info *params;
51 uint32_t n_params;
52};
53
54#define SPA_DEVICE_INFO_INIT() ((struct spa_device_info){ SPA_VERSION_DEVICE_INFO, })
55
61 struct spa_device_object_info {
62#define SPA_VERSION_DEVICE_OBJECT_INFO 0
63 uint32_t version;
64
65 const char *type;
66 const char *factory_name;
68#define SPA_DEVICE_OBJECT_CHANGE_MASK_FLAGS (1u<<0)
69#define SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS (1u<<1)
70 uint64_t change_mask;
71 uint64_t flags;
72 const struct spa_dict *props;
73};
74
75#define SPA_DEVICE_OBJECT_INFO_INIT() ((struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, })
76
78#define SPA_RESULT_TYPE_DEVICE_PARAMS 1
79 struct spa_result_device_params {
80 uint32_t id;
81 uint32_t index;
82 uint32_t next;
83 struct spa_pod *param;
84};
85
86#define SPA_DEVICE_EVENT_INFO 0
87#define SPA_DEVICE_EVENT_RESULT 1
88#define SPA_DEVICE_EVENT_EVENT 2
89#define SPA_DEVICE_EVENT_OBJECT_INFO 3
90#define SPA_DEVICE_EVENT_NUM 4
91
97 struct spa_device_events {
99#define SPA_VERSION_DEVICE_EVENTS 0
100 uint32_t version;
101
103 void (*info) (void *data, const struct spa_device_info *info);
104
106 void (*result) (void *data, int seq, int res, uint32_t type, const void *result);
107
109 void (*event) (void *data, const struct spa_event *event);
110
113 void (*object_info) (void *data, uint32_t id,
114 const struct spa_device_object_info *info);
115};
116
117#define SPA_DEVICE_METHOD_ADD_LISTENER 0
118#define SPA_DEVICE_METHOD_SYNC 1
119#define SPA_DEVICE_METHOD_ENUM_PARAMS 2
120#define SPA_DEVICE_METHOD_SET_PARAM 3
121#define SPA_DEVICE_METHOD_NUM 4
122
126 struct spa_device_methods {
127 /* the version of the methods. This can be used to expand this
128 * structure in the future */
129#define SPA_VERSION_DEVICE_METHODS 0
130 uint32_t version;
131
147 int (*add_listener) (void *object,
148 struct spa_hook *listener,
149 const struct spa_device_events *events,
150 void *data);
166 int (*sync) (void *object, int seq);
167
193 int (*enum_params) (void *object, int seq,
194 uint32_t id, uint32_t index, uint32_t max,
195 const struct spa_pod *filter);
196
218 int (*set_param) (void *object,
219 uint32_t id, uint32_t flags,
220 const struct spa_pod *param);
221};
222
223#define spa_device_method(o,method,version,...) \
224({ \
225 int _res = -ENOTSUP; \
226 struct spa_device *_o = (o); \
227 spa_interface_call_res(&_o->iface, \
228 struct spa_device_methods, _res, \
229 method, (version), ##__VA_ARGS__); \
230 _res; \
231})
232
233#define spa_device_add_listener(d,...) spa_device_method(d, add_listener, 0, __VA_ARGS__)
234#define spa_device_sync(d,...) spa_device_method(d, sync, 0, __VA_ARGS__)
235#define spa_device_enum_params(d,...) spa_device_method(d, enum_params, 0, __VA_ARGS__)
236#define spa_device_set_param(d,...) spa_device_method(d, set_param, 0, __VA_ARGS__)
237
238#define SPA_KEY_DEVICE_ENUM_API "device.enum.api"
240#define SPA_KEY_DEVICE_API "device.api"
242#define SPA_KEY_DEVICE_NAME "device.name"
243#define SPA_KEY_DEVICE_ALIAS "device.alias"
244#define SPA_KEY_DEVICE_NICK "device.nick"
245#define SPA_KEY_DEVICE_DESCRIPTION "device.description"
246#define SPA_KEY_DEVICE_ICON "device.icon"
248#define SPA_KEY_DEVICE_ICON_NAME "device.icon-name"
250#define SPA_KEY_DEVICE_PLUGGED_USEC "device.plugged.usec"
252#define SPA_KEY_DEVICE_BUS_ID "device.bus-id"
253#define SPA_KEY_DEVICE_BUS_PATH "device.bus-path"
256#define SPA_KEY_DEVICE_BUS "device.bus"
259#define SPA_KEY_DEVICE_SUBSYSTEM "device.subsystem"
260#define SPA_KEY_DEVICE_SYSFS_PATH "device.sysfs.path"
262#define SPA_KEY_DEVICE_VENDOR_ID "device.vendor.id"
263#define SPA_KEY_DEVICE_VENDOR_NAME "device.vendor.name"
264#define SPA_KEY_DEVICE_PRODUCT_ID "device.product.id"
265#define SPA_KEY_DEVICE_PRODUCT_NAME "device.product.name"
266#define SPA_KEY_DEVICE_SERIAL "device.serial"
267#define SPA_KEY_DEVICE_CLASS "device.class"
268#define SPA_KEY_DEVICE_CAPABILITIES "device.capabilities"
269#define SPA_KEY_DEVICE_FORM_FACTOR "device.form-factor"
274#define SPA_KEY_DEVICE_PROFILE "device.profile "
275#define SPA_KEY_DEVICE_PROFILE_SET "device.profile-set"
276#define SPA_KEY_DEVICE_STRING "device.string"
278#define SPA_KEY_DEVICE_DEVIDS "device.devids"
284#ifdef __cplusplus
285} /* extern "C" */
286#endif
287
288#endif /* SPA_DEVICE_H */
defs.h
spa/utils/defs.h
hook.h
spa/utils/hook.h
event.h
spa/pod/event.h
spa_device_events
spa_device_events:
Definition device.h:119
spa_device_events::result
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result
Definition device.h:129
spa_device_events::event
void(* event)(void *data, const struct spa_event *event)
a device event
Definition device.h:132
spa_device_events::info
void(* info)(void *data, const struct spa_device_info *info)
notify extra information about the device
Definition device.h:126
spa_device_events::object_info
void(* object_info)(void *data, uint32_t id, const struct spa_device_object_info *info)
info changed for an object managed by the device, info is NULL when the object is removed
Definition device.h:136
spa_device_events::version
uint32_t version
Definition device.h:123
spa_device_info
Information about the device and parameters it supports.
Definition device.h:47
spa_device_info::flags
uint64_t flags
Definition device.h:59
spa_device_info::params
struct spa_param_info * params
supported parameters
Definition device.h:61
spa_device_info::version
uint32_t version
Definition device.h:50
spa_device_info::n_params
uint32_t n_params
number of elements in params
Definition device.h:62
spa_device_info::change_mask
uint64_t change_mask
Definition device.h:58
spa_device_methods
spa_device_methods:
Definition device.h:154
spa_device_methods::version
uint32_t version
Definition device.h:159
spa_device_methods::sync
int(* sync)(void *object, int seq)
Perform a sync operation.
Definition device.h:195
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 device.h:222
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 device.h:247
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 device.h:176
spa_device_object_info
Information about a device object.
Definition device.h:73
spa_device_object_info::version
uint32_t version
Definition device.h:76
spa_device_object_info::type
const char * type
the object type managed by this device
Definition device.h:78
spa_device_object_info::change_mask
uint64_t change_mask
Definition device.h:85
spa_device_object_info::factory_name
const char * factory_name
a factory name that implements the object
Definition device.h:79
spa_device_object_info::flags
uint64_t flags
Definition device.h:86
spa_device
Definition device.h:40
spa_device::iface
struct spa_interface iface
Definition device.h:40
spa_dict
Definition dict.h:39
spa_event
Definition event.h:28
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:350
spa_interface
Definition hook.h:138
spa_param_info
information about a parameter
Definition param.h:51
spa_pod
Definition pod.h:43
spa_result_device_params
Definition device.h:96
spa_result_device_params::id
uint32_t id
Definition device.h:97
spa_result_device_params::index
uint32_t index
Definition device.h:98
spa_result_device_params::next
uint32_t next
Definition device.h:99
spa_result_device_params::param
struct spa_pod * param
Definition device.h:100
dict.h
spa/utils/dict.h