PipeWire: device.h Source File

PipeWire 0.3.71

Loading...
Searching...
No Matches
src/pipewire/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
9extern "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_VERSION_DEVICE 3
29struct pw_device;
30
32struct pw_device_info {
33 uint32_t id;
34#define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0)
35#define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1)
36#define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1)
37 uint64_t change_mask;
38 struct spa_dict *props;
39 struct spa_param_info *params;
40 uint32_t n_params;
41};
42
44 struct pw_device_info *
45 pw_device_info_update(struct pw_device_info *info,
46 const struct pw_device_info *update);
48struct pw_device_info *
49 pw_device_info_merge(struct pw_device_info *info,
50 const struct pw_device_info *update, bool reset);
52void pw_device_info_free(struct pw_device_info *info);
53
54#define PW_DEVICE_EVENT_INFO 0
55#define PW_DEVICE_EVENT_PARAM 1
56#define PW_DEVICE_EVENT_NUM 2
57
59struct pw_device_events {
60#define PW_VERSION_DEVICE_EVENTS 0
61 uint32_t version;
67 void (*info) (void *data, const struct pw_device_info *info);
79 void (*param) (void *data, int seq,
80 uint32_t id, uint32_t index, uint32_t next,
81 const struct spa_pod *param);
82};
83
84
85#define PW_DEVICE_METHOD_ADD_LISTENER 0
86#define PW_DEVICE_METHOD_SUBSCRIBE_PARAMS 1
87#define PW_DEVICE_METHOD_ENUM_PARAMS 2
88#define PW_DEVICE_METHOD_SET_PARAM 3
89#define PW_DEVICE_METHOD_NUM 4
90
92struct pw_device_methods {
93#define PW_VERSION_DEVICE_METHODS 0
94 uint32_t version;
95
96 int (*add_listener) (void *object,
97 struct spa_hook *listener,
98 const struct pw_device_events *events,
99 void *data);
109 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
110
123 int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num,
124 const struct spa_pod *filter);
132 int (*set_param) (void *object, uint32_t id, uint32_t flags,
133 const struct spa_pod *param);
134};
135
136#define pw_device_method(o,method,version,...) \
137({ \
138 int _res = -ENOTSUP; \
139 spa_interface_call_res((struct spa_interface*)o, \
140 struct pw_device_methods, _res, \
141 method, version, ##__VA_ARGS__); \
142 _res; \
143})
144
145#define pw_device_add_listener(c,...) pw_device_method(c,add_listener,0,__VA_ARGS__)
146#define pw_device_subscribe_params(c,...) pw_device_method(c,subscribe_params,0,__VA_ARGS__)
147#define pw_device_enum_params(c,...) pw_device_method(c,enum_params,0,__VA_ARGS__)
148#define pw_device_set_param(c,...) pw_device_method(c,set_param,0,__VA_ARGS__)
149
154#ifdef __cplusplus
155} /* extern "C" */
156#endif
157
158#endif /* PIPEWIRE_DEVICE_H */
defs.h
spa/utils/defs.h
pw_device_info_free
void pw_device_info_free(struct pw_device_info *info)
Free a pw_device_info.
Definition introspect.c:467
pw_device_info_merge
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:406
pw_device_info_update
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:460
hook.h
spa/utils/hook.h
proxy.h
pipewire/proxy.h
pw_device_events
Device events.
Definition src/pipewire/device.h:72
pw_device_events::info
void(* info)(void *data, const struct pw_device_info *info)
Notify device info.
Definition src/pipewire/device.h:81
pw_device_events::version
uint32_t version
Definition src/pipewire/device.h:75
pw_device_events::param
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 src/pipewire/device.h:93
pw_device_info
The device information.
Definition src/pipewire/device.h:39
pw_device_info::id
uint32_t id
id of the global
Definition src/pipewire/device.h:40
pw_device_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition src/pipewire/device.h:47
pw_device_info::n_params
uint32_t n_params
number of items in params
Definition src/pipewire/device.h:50
pw_device_info::params
struct spa_param_info * params
parameters
Definition src/pipewire/device.h:49
pw_device_methods
Device methods.
Definition src/pipewire/device.h:111
pw_device_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition src/pipewire/device.h:129
pw_device_methods::enum_params
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 src/pipewire/device.h:143
pw_device_methods::set_param
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on the device.
Definition src/pipewire/device.h:152
pw_device_methods::version
uint32_t version
Definition src/pipewire/device.h:114
pw_device_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition src/pipewire/device.h:116
pw_device
spa_dict
Definition utils/dict.h:39
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:350
spa_param_info
information about a parameter
Definition param.h:50
spa_pod
Definition pod/pod.h:43