device.h
Go to the documentation of this file.
/* PipeWire
*
* Copyright © 2018 Wim Taymans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef PIPEWIRE_DEVICE_H
#define PIPEWIRE_DEVICE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <pipewire/proxy.h>
#define PW_TYPE_INTERFACE_Device PW_TYPE_INFO_INTERFACE_BASE "Device"
#define PW_VERSION_DEVICE 3
struct pw_device;
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 *object, const struct pw_device_info *info);
void (*param) (void *object, 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);
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);
};
#define pw_device_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
spa_interface_call_res((struct spa_interface*)o, \
struct pw_device_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define pw_device_add_listener(c,...) pw_device_method(c,add_listener,0,__VA_ARGS__)
#define pw_device_subscribe_params(c,...) pw_device_method(c,subscribe_params,0,__VA_ARGS__)
#define pw_device_enum_params(c,...) pw_device_method(c,enum_params,0,__VA_ARGS__)
#define pw_device_set_param(c,...) pw_device_method(c,set_param,0,__VA_ARGS__)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PIPEWIRE_DEVICE_H */
defs.h
spa/utils/defs.h
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
pw_device_info_free
void pw_device_info_free(struct pw_device_info *info)
Free a pw_device_info.
Definition: introspect.c:463
hook.h
spa/utils/hook.h
proxy.h
pipewire/proxy.h
pw_device_events
Device events.
Definition: device.h:92
pw_device_events::info
void(* info)(void *object, const struct pw_device_info *info)
Notify device info.
Definition: device.h:101
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: device.h:113
pw_device_events::version
uint32_t version
Definition: device.h:95
pw_device_info
The device information.
Definition: device.h:59
pw_device_info::id
uint32_t id
id of the global
Definition: device.h:60
pw_device_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: device.h:67
pw_device_info::n_params
uint32_t n_params
number of items in params
Definition: device.h:70
pw_device_info::params
struct spa_param_info * params
parameters
Definition: device.h:69
pw_device_methods
Device methods.
Definition: device.h:131
pw_device_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: device.h:149
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:163
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:172
pw_device_methods::version
uint32_t version
Definition: device.h:134
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:136
pw_device
spa_dict
Definition: dict.h:59
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:342
spa_param_info
information about a parameter
Definition: param.h:70
spa_pod
Definition: pod.h:63