Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
/* PipeWire */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef PIPEWIRE_DEVICE_H
#define PIPEWIRE_DEVICE_H
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PW_TYPE_INTERFACE_Device PW_TYPE_INFO_INTERFACE_BASE "Device"
#define PW_DEVICE_PERM_MASK PW_PERM_RWXM
#define PW_VERSION_DEVICE 3
struct pw_device;
#ifndef PW_API_DEVICE_IMPL
#define PW_API_DEVICE_IMPL static inline
#endif
struct pw_device_info {
uint32_t id;
#define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0)
#define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1)
#define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1)
uint64_t change_mask;
struct spa_dict *props;
struct spa_param_info *params;
uint32_t n_params;
};
struct pw_device_info *
pw_device_info_update(struct pw_device_info *info,
const struct pw_device_info *update);
struct pw_device_info *
pw_device_info_merge(struct pw_device_info *info,
const struct pw_device_info *update, bool reset);
void pw_device_info_free(struct pw_device_info *info);
#define PW_DEVICE_EVENT_INFO 0
#define PW_DEVICE_EVENT_PARAM 1
#define PW_DEVICE_EVENT_NUM 2
struct pw_device_events {
#define PW_VERSION_DEVICE_EVENTS 0
uint32_t version;
void (*info) (void *data, const struct pw_device_info *info);
* \param id the param id
* \param index the param index
* \param next the param index of the next param
* \param param the parameter
*/
void (*param) (void *data, int seq,
uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param);
};
#define PW_DEVICE_METHOD_ADD_LISTENER 0
#define PW_DEVICE_METHOD_SUBSCRIBE_PARAMS 1
#define PW_DEVICE_METHOD_ENUM_PARAMS 2
#define PW_DEVICE_METHOD_SET_PARAM 3
#define PW_DEVICE_METHOD_NUM 4
struct pw_device_methods {
#define PW_VERSION_DEVICE_METHODS 0
uint32_t version;
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct pw_device_events *events,
void *data);
int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
/**
* Enumerate device parameters
*
* Start enumeration of device parameters. For each param, a
* param event will be emitted.
*
* \param seq a sequence number to place in the reply
* \param id the parameter id to enum or PW_ID_ANY for all
* \param start the start index or 0 for the first param
* \param num the maximum number of params to retrieve
* \param filter a param filter or NULL
*
* This requires X permissions on the device.
*/
int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter);
int (*set_param) (void *object, uint32_t id, uint32_t flags,
const struct spa_pod *param);
};
PW_API_DEVICE_IMPL int pw_device_add_listener(struct pw_device *object,
struct spa_hook *listener,
const struct pw_device_events *events,
void *data)
{
return spa_api_method_r(int, -ENOTSUP,
pw_device, (struct spa_interface*)object, add_listener, 0,
listener, events, data);
}
PW_API_DEVICE_IMPL int pw_device_subscribe_params(struct pw_device *object, uint32_t *ids, uint32_t n_ids)
{
return spa_api_method_r(int, -ENOTSUP,
pw_device, (struct spa_interface*)object, subscribe_params, 0,
ids, n_ids);
}
PW_API_DEVICE_IMPL int pw_device_enum_params(struct pw_device *object,
int seq, uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter)
{
return spa_api_method_r(int, -ENOTSUP,
pw_device, (struct spa_interface*)object, enum_params, 0,
seq, id, start, num, filter);
}
PW_API_DEVICE_IMPL int pw_device_set_param(struct pw_device *object, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return spa_api_method_r(int, -ENOTSUP,
pw_device, (struct spa_interface*)object, set_param, 0,
id, flags, param);
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PIPEWIRE_DEVICE_H */
defs.h
spa/utils/defs.h
seq
uint32_t int seq
Definition core.h:432
id
uint32_t id
Definition core.h:432
pw_device_add_listener
PW_API_DEVICE_IMPL int pw_device_add_listener(struct pw_device *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition device.h:172
pw_device_subscribe_params
PW_API_DEVICE_IMPL int pw_device_subscribe_params(struct pw_device *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition device.h:183
pw_device_info_free
void pw_device_info_free(struct pw_device_info *info)
Free a pw_device_info.
Definition introspect.c:472
pw_device_enum_params
PW_API_DEVICE_IMPL int pw_device_enum_params(struct pw_device *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter)
Enumerate device parameters.
Definition device.h:191
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_set_param
PW_API_DEVICE_IMPL int pw_device_set_param(struct pw_device *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on the device.
Definition device.h:201
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:465
PW_API_DEVICE_IMPL
#define PW_API_DEVICE_IMPL
Definition device.h:43
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
hook.h
spa/utils/hook.h
proxy.h
pipewire/proxy.h
pw_device_events
Device events.
Definition device.h:80
pw_device_events::version
uint32_t version
Definition device.h:83
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 device.h:101
pw_device_info
The device information.
Definition device.h:47
pw_device_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition device.h:55
pw_device_info::n_params
uint32_t n_params
number of items in params
Definition device.h:58
pw_device_info::params
struct spa_param_info * params
parameters
Definition device.h:57
pw_device_methods
Device methods.
Definition device.h:119
pw_device_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition device.h:139
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 device.h:155
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 device.h:166
pw_device_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_device_events *events, void *data)
Definition device.h:124
pw_device
spa_dict
Definition dict.h:51
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_interface
Definition hook.h:148
spa_param_info
information about a parameter
Definition param.h:56
spa_pod
Definition pod.h:57