PipeWire: device.h Source File

PipeWire 0.3.37

pipewire/src/pipewire/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
29extern "C" {
30#endif
31
32#include <spa/utils/defs.h>
33#include <spa/utils/hook.h>
34
35#include <pipewire/proxy.h>
36
37#define PW_TYPE_INTERFACE_Device PW_TYPE_INFO_INTERFACE_BASE "Device"
38
39#define PW_VERSION_DEVICE 3
40struct pw_device;
41
43 struct pw_device_info {
44 uint32_t id;
45#define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0)
46#define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1)
47#define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1)
48 uint64_t change_mask;
49 struct spa_dict *props;
50 struct spa_param_info *params;
51 uint32_t n_params;
52};
53
55struct pw_device_info *
56 pw_device_info_update(struct pw_device_info *info,
57 const struct pw_device_info *update);
59struct pw_device_info *
60 pw_device_info_merge(struct pw_device_info *info,
61 const struct pw_device_info *update, bool reset);
63void pw_device_info_free(struct pw_device_info *info);
64
65#define PW_DEVICE_EVENT_INFO 0
66#define PW_DEVICE_EVENT_PARAM 1
67#define PW_DEVICE_EVENT_NUM 2
68
70 struct pw_device_events {
71#define PW_VERSION_DEVICE_EVENTS 0
72 uint32_t version;
78 void (*info) (void *object, const struct pw_device_info *info);
90 void (*param) (void *object, int seq,
91 uint32_t id, uint32_t index, uint32_t next,
92 const struct spa_pod *param);
93};
94
95
96#define PW_DEVICE_METHOD_ADD_LISTENER 0
97#define PW_DEVICE_METHOD_SUBSCRIBE_PARAMS 1
98#define PW_DEVICE_METHOD_ENUM_PARAMS 2
99#define PW_DEVICE_METHOD_SET_PARAM 3
100#define PW_DEVICE_METHOD_NUM 4
101
103 struct pw_device_methods {
104#define PW_VERSION_DEVICE_METHODS 0
105 uint32_t version;
106
107 int (*add_listener) (void *object,
108 struct spa_hook *listener,
109 const struct pw_device_events *events,
110 void *data);
120 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
121
134 int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num,
135 const struct spa_pod *filter);
143 int (*set_param) (void *object, uint32_t id, uint32_t flags,
144 const struct spa_pod *param);
145};
146
147#define pw_device_method(o,method,version,...) \
148({ \
149 int _res = -ENOTSUP; \
150 spa_interface_call_res((struct spa_interface*)o, \
151 struct pw_device_methods, _res, \
152 method, version, ##__VA_ARGS__); \
153 _res; \
154})
155
156#define pw_device_add_listener(c,...) pw_device_method(c,add_listener,0,__VA_ARGS__)
157#define pw_device_subscribe_params(c,...) pw_device_method(c,subscribe_params,0,__VA_ARGS__)
158#define pw_device_enum_params(c,...) pw_device_method(c,enum_params,0,__VA_ARGS__)
159#define pw_device_set_param(c,...) pw_device_method(c,set_param,0,__VA_ARGS__)
160
161#ifdef __cplusplus
162} /* extern "C" */
163#endif
164
165#endif /* PIPEWIRE_DEVICE_H */
defs.h
hook.h
start
int(* start)(struct sm_media_session *sess)
Definition: media-session.c:2382
pw_device_info_free
void pw_device_info_free(struct pw_device_info *info)
Free a pw_device_info.
Definition: introspect.c:463
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:410
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:456
proxy.h
data
user data to add to an object
Definition: media-session.c:110
filter
Definition: filter.c:126
param
Definition: media-session.c:116
pw_device_events
Device events.
Definition: pipewire/src/pipewire/device.h:70
pw_device_events::info
void(* info)(void *object, const struct pw_device_info *info)
Notify device info.
Definition: pipewire/src/pipewire/device.h:78
pw_device_events::param
void(* param)(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a device param.
Definition: pipewire/src/pipewire/device.h:90
pw_device_events::version
uint32_t version
Definition: pipewire/src/pipewire/device.h:72
pw_device_info
The device information.
Definition: pipewire/src/pipewire/device.h:43
pw_device_info::id
uint32_t id
id of the global
Definition: pipewire/src/pipewire/device.h:44
pw_device_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: pipewire/src/pipewire/device.h:48
pw_device_info::props
struct spa_dict * props
extra properties
Definition: pipewire/src/pipewire/device.h:49
pw_device_info::n_params
uint32_t n_params
number of items in params
Definition: pipewire/src/pipewire/device.h:51
pw_device_info::params
struct spa_param_info * params
parameters
Definition: pipewire/src/pipewire/device.h:50
pw_device_methods
Device methods.
Definition: pipewire/src/pipewire/device.h:103
pw_device_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: pipewire/src/pipewire/device.h:120
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: pipewire/src/pipewire/device.h:134
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: pipewire/src/pipewire/device.h:143
pw_device_methods::version
uint32_t version
Definition: pipewire/src/pipewire/device.h:105
pw_device_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition: pipewire/src/pipewire/device.h:107
spa_dict
Definition: utils/dict.h:48
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:295
spa_param_info
information about a parameter
Definition: param.h:64
spa_pod
Definition: pod/pod.h:50