PipeWire 1.2.6

Loading...
Searching...
No Matches
port.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_PORT_H
6#define PIPEWIRE_PORT_H
7
8#ifdef __cplusplus
9 extern "C" {
10#endif
11
12#include <stdarg.h>
13#include <errno.h>
14
15#include <spa/utils/defs.h>
16#include <spa/utils/hook.h>
17#include <spa/param/param.h>
18
19#include <pipewire/proxy.h>
20
30#define PW_TYPE_INTERFACE_Port PW_TYPE_INFO_INTERFACE_BASE "Port"
31
32#define PW_PORT_PERM_MASK PW_PERM_R|PW_PERM_X|PW_PERM_M
33
34#define PW_VERSION_PORT 3
35 struct pw_port;
36
38#define pw_direction spa_direction
39#define PW_DIRECTION_INPUT SPA_DIRECTION_INPUT
40#define PW_DIRECTION_OUTPUT SPA_DIRECTION_OUTPUT
41
43 const char * pw_direction_as_string(enum pw_direction direction);
44
45 struct pw_port_info {
46 uint32_t id;
47 enum pw_direction direction;
48#define PW_PORT_CHANGE_MASK_PROPS (1 << 0)
49#define PW_PORT_CHANGE_MASK_PARAMS (1 << 1)
50#define PW_PORT_CHANGE_MASK_ALL ((1 << 2)-1)
51 uint64_t change_mask;
52 struct spa_dict *props;
53 struct spa_param_info *params;
54 uint32_t n_params;
55};
56
57 struct pw_port_info *
58 pw_port_info_update(struct pw_port_info *info,
59 const struct pw_port_info *update);
60
61 struct pw_port_info *
62 pw_port_info_merge(struct pw_port_info *info,
63 const struct pw_port_info *update, bool reset);
64
65 void
66 pw_port_info_free(struct pw_port_info *info);
67
68#define PW_PORT_EVENT_INFO 0
69#define PW_PORT_EVENT_PARAM 1
70#define PW_PORT_EVENT_NUM 2
71
73 struct pw_port_events {
74#define PW_VERSION_PORT_EVENTS 0
75 uint32_t version;
81 void (*info) (void *data, const struct pw_port_info *info);
93 void (*param) (void *data, int seq,
94 uint32_t id, uint32_t index, uint32_t next,
95 const struct spa_pod *param);
96};
97
98#define PW_PORT_METHOD_ADD_LISTENER 0
99#define PW_PORT_METHOD_SUBSCRIBE_PARAMS 1
100#define PW_PORT_METHOD_ENUM_PARAMS 2
101#define PW_PORT_METHOD_NUM 3
102
104 struct pw_port_methods {
105#define PW_VERSION_PORT_METHODS 0
106 uint32_t version;
107
108 int (*add_listener) (void *object,
109 struct spa_hook *listener,
110 const struct pw_port_events *events,
111 void *data);
123 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
124
139 int (*enum_params) (void *object, int seq,
140 uint32_t id, uint32_t start, uint32_t num,
141 const struct spa_pod *filter);
142};
143
144#define pw_port_method(o,method,version,...) \
145({ \
146 int _res = -ENOTSUP; \
147 spa_interface_call_res((struct spa_interface*)o, \
148 struct pw_port_methods, _res, \
149 method, version, ##__VA_ARGS__); \
150 _res; \
151})
152
153#define pw_port_add_listener(c,...) pw_port_method(c,add_listener,0,__VA_ARGS__)
154#define pw_port_subscribe_params(c,...) pw_port_method(c,subscribe_params,0,__VA_ARGS__)
155#define pw_port_enum_params(c,...) pw_port_method(c,enum_params,0,__VA_ARGS__)
156
161#ifdef __cplusplus
162} /* extern "C" */
163#endif
164
165#endif /* PIPEWIRE_PORT_H */
defs.h
spa/utils/defs.h
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:307
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:300
pw_direction
#define pw_direction
The direction of a port.
Definition port.h:46
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:243
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:89
pw_port_events::info
void(* info)(void *data, const struct pw_port_info *info)
Notify port info.
Definition port.h:98
pw_port_events::version
uint32_t version
Definition port.h:92
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:110
pw_port_info
Definition port.h:55
pw_port_info::n_params
uint32_t n_params
number of items in params
Definition port.h:67
pw_port_info::params
struct spa_param_info * params
parameters
Definition port.h:66
pw_port_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition port.h:64
pw_port_info::id
uint32_t id
id of the global
Definition port.h:56
pw_port_info::direction
enum pw_direction direction
port direction
Definition port.h:57
pw_port_methods
Port methods.
Definition port.h:125
pw_port_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition port.h:145
pw_port_methods::version
uint32_t version
Definition port.h:128
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:161
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:130
pw_port
spa_dict
Definition 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:51
spa_pod
Definition pod.h:43