Loading...
Searching...
No Matches
port.h
Go to the documentation of this file.
/* PipeWire */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef PIPEWIRE_PORT_H
#define PIPEWIRE_PORT_H
#include <stdarg.h>
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/param/param.h>
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PW_TYPE_INTERFACE_Port PW_TYPE_INFO_INTERFACE_BASE "Port"
#define PW_PORT_PERM_MASK PW_PERM_R|PW_PERM_X|PW_PERM_M
#define PW_VERSION_PORT 3
struct pw_port;
#ifndef PW_API_PORT_IMPL
#define PW_API_PORT_IMPL static inline
#endif
#define pw_direction spa_direction
#define PW_DIRECTION_INPUT SPA_DIRECTION_INPUT
#define PW_DIRECTION_OUTPUT SPA_DIRECTION_OUTPUT
const char * pw_direction_as_string(enum pw_direction direction);
struct pw_port_info {
uint32_t id;
enum pw_direction direction;
#define PW_PORT_CHANGE_MASK_PROPS (1 << 0)
#define PW_PORT_CHANGE_MASK_PARAMS (1 << 1)
#define PW_PORT_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_port_info *
pw_port_info_update(struct pw_port_info *info,
const struct pw_port_info *update);
struct pw_port_info *
pw_port_info_merge(struct pw_port_info *info,
const struct pw_port_info *update, bool reset);
void
pw_port_info_free(struct pw_port_info *info);
#define PW_PORT_EVENT_INFO 0
#define PW_PORT_EVENT_PARAM 1
#define PW_PORT_EVENT_NUM 2
struct pw_port_events {
#define PW_VERSION_PORT_EVENTS 0
uint32_t version;
void (*info) (void *data, const struct pw_port_info *info);
* \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_PORT_METHOD_ADD_LISTENER 0
#define PW_PORT_METHOD_SUBSCRIBE_PARAMS 1
#define PW_PORT_METHOD_ENUM_PARAMS 2
#define PW_PORT_METHOD_NUM 3
struct pw_port_methods {
#define PW_VERSION_PORT_METHODS 0
uint32_t version;
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct pw_port_events *events,
void *data);
int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
* Enumerate port parameters
*
* Start enumeration of port parameters. For each param, a
* param event will be emitted.
*
* \param seq a sequence number returned in the reply
* \param id the parameter id to enumerate
* \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 port.
*/
int (*enum_params) (void *object, int seq,
uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter);
};
PW_API_PORT_IMPL int pw_port_add_listener(struct pw_port *object,
struct spa_hook *listener,
const struct pw_port_events *events,
void *data)
{
return spa_api_method_r(int, -ENOTSUP,
pw_port, (struct spa_interface*)object, add_listener, 0,
listener, events, data);
}
PW_API_PORT_IMPL int pw_port_subscribe_params(struct pw_port *object, uint32_t *ids, uint32_t n_ids)
{
return spa_api_method_r(int, -ENOTSUP,
pw_port, (struct spa_interface*)object, subscribe_params, 0,
ids, n_ids);
}
PW_API_PORT_IMPL int pw_port_enum_params(struct pw_port *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_port, (struct spa_interface*)object, enum_params, 0,
seq, id, start, num, filter);
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PIPEWIRE_PORT_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_port_add_listener
PW_API_PORT_IMPL int pw_port_add_listener(struct pw_port *object, struct spa_hook *listener, const struct pw_port_events *events, void *data)
Definition port.h:173
pw_direction_as_string
const char * pw_direction_as_string(enum pw_direction direction)
Convert a pw_direction to a readable string.
Definition introspect.c:33
pw_port_info_free
void pw_port_info_free(struct pw_port_info *info)
Definition introspect.c:308
PW_API_PORT_IMPL
#define PW_API_PORT_IMPL
Definition port.h:47
pw_port_subscribe_params
PW_API_PORT_IMPL int pw_port_subscribe_params(struct pw_port *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition port.h:184
pw_port_info_update
struct pw_port_info * pw_port_info_update(struct pw_port_info *info, const struct pw_port_info *update)
Definition introspect.c:301
pw_direction
#define pw_direction
The direction of a port.
Definition port.h:51
pw_port_enum_params
PW_API_PORT_IMPL int pw_port_enum_params(struct pw_port *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter)
Enumerate port parameters.
Definition port.h:192
pw_port_info_merge
struct pw_port_info * pw_port_info_merge(struct pw_port_info *info, const struct pw_port_info *update, bool reset)
Definition introspect.c:244
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
param.h
spa/param/param.h
proxy.h
pipewire/proxy.h
pw_port_events
Port events.
Definition port.h:94
pw_port_events::version
uint32_t version
Definition port.h:97
pw_port_events::param
void(* param)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a port param.
Definition port.h:115
pw_port_info
Definition port.h:60
pw_port_info::n_params
uint32_t n_params
number of items in params
Definition port.h:72
pw_port_info::params
struct spa_param_info * params
parameters
Definition port.h:71
pw_port_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition port.h:69
pw_port_info::direction
enum pw_direction direction
port direction
Definition port.h:62
pw_port_methods
Port methods.
Definition port.h:130
pw_port_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition port.h:150
pw_port_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 port parameters.
Definition port.h:166
pw_port_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_port_events *events, void *data)
Definition port.h:135
pw_port
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