PipeWire: port.h Source File

PipeWire 0.3.1

port.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_PORT_H
26 #define PIPEWIRE_PORT_H
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #include <stdarg.h>
33 #include <errno.h>
34
35 #include <spa/utils/defs.h>
36 #include <spa/utils/hook.h>
37 #include <spa/param/param.h>
38
39 #include <pipewire/proxy.h>
40
41 #define PW_TYPE_INTERFACE_Port PW_TYPE_INFO_INTERFACE_BASE "Port"
42
43 #define PW_VERSION_PORT 3
44 struct pw_port;
45
47 enum pw_direction {
48 PW_DIRECTION_INPUT = SPA_DIRECTION_INPUT,
49 PW_DIRECTION_OUTPUT = SPA_DIRECTION_OUTPUT
50 };
51
53 const char * pw_direction_as_string(enum pw_direction direction);
54
55
62 struct pw_port_info {
63 uint32_t id;
64 enum pw_direction direction;
65 #define PW_PORT_CHANGE_MASK_PROPS (1 << 0)
66 #define PW_PORT_CHANGE_MASK_PARAMS (1 << 1)
67 #define PW_PORT_CHANGE_MASK_ALL ((1 << 2)-1)
68 uint64_t change_mask;
69 struct spa_dict *props;
70 struct spa_param_info *params;
71 uint32_t n_params;
72 };
73
74 struct pw_port_info *
75 pw_port_info_update(struct pw_port_info *info,
76 const struct pw_port_info *update);
77
78 void
79 pw_port_info_free(struct pw_port_info *info);
80
81 #define PW_PORT_EVENT_INFO 0
82 #define PW_PORT_EVENT_PARAM 1
83 #define PW_PORT_EVENT_NUM 2
84
86 struct pw_port_events {
87 #define PW_VERSION_PORT_EVENTS 0
88 uint32_t version;
94 void (*info) (void *object, const struct pw_port_info *info);
106 void (*param) (void *object, int seq,
107 uint32_t id, uint32_t index, uint32_t next,
108 const struct spa_pod *param);
109 };
110
111 #define PW_PORT_METHOD_ADD_LISTENER 0
112 #define PW_PORT_METHOD_SUBSCRIBE_PARAMS 1
113 #define PW_PORT_METHOD_ENUM_PARAMS 2
114 #define PW_PORT_METHOD_NUM 3
115
117 struct pw_port_methods {
118 #define PW_VERSION_PORT_METHODS 0
119 uint32_t version;
120
121 int (*add_listener) (void *object,
122 struct spa_hook *listener,
123 const struct pw_port_events *events,
124 void *data);
134 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
135
148 int (*enum_params) (void *object, int seq,
149 uint32_t id, uint32_t start, uint32_t num,
150 const struct spa_pod *filter);
151 };
152
153 #define pw_port_method(o,method,version,...) \
154 ({ \
155 int _res = -ENOTSUP; \
156 spa_interface_call_res((struct spa_interface*)o, \
157 struct pw_port_methods, _res, \
158 method, version, ##__VA_ARGS__); \
159 _res; \
160 })
161
162 #define pw_port_add_listener(c,...) pw_port_method(c,add_listener,0,__VA_ARGS__)
163 #define pw_port_subscribe_params(c,...) pw_port_method(c,subscribe_params,0,__VA_ARGS__)
164 #define pw_port_enum_params(c,...) pw_port_method(c,enum_params,0,__VA_ARGS__)
165
166 #ifdef __cplusplus
167 } /* extern "C" */
168 #endif
169
170 #endif /* PIPEWIRE_PORT_H */
id
static uint32_t id
Definition: core.h:322
pw_port_methods
Port methods.
Definition: port.h:117
pw_port_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: port.h:68
pw_port_info::direction
enum pw_direction direction
port direction
Definition: port.h:64
pw_port_info::n_params
uint32_t n_params
number of items in params
Definition: port.h:71
data
Definition: filter.c:71
pw_port_events::version
uint32_t version
Definition: port.h:88
pw_port_info_free
void pw_port_info_free(struct pw_port_info *info)
Definition: introspect.c:283
pw_port_events
Port events.
Definition: port.h:86
pw_introspect::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:52
PW_DIRECTION_INPUT
@ PW_DIRECTION_INPUT
an input port direction
Definition: port.h:48
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:237
pw_port_info::props
struct spa_dict * props
the properties of the port
Definition: port.h:69
pw_port_info
Definition: port.h:62
pw_port_methods::version
uint32_t version
Definition: port.h:119
filter
Definition: filter.c:113
pw_port_info::params
struct spa_param_info * params
parameters
Definition: port.h:70
proxy.h
pw_port_events::info
void(* info)(void *object, const struct pw_port_info *info)
Notify port info.
Definition: port.h:94
pw_direction
pw_direction
Definition: port.h:47
param
Definition: filter.c:76
pw_port_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: port.h:134
pw_port_info::id
uint32_t id
id of the global
Definition: port.h:63
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:121
seq
static uint32_t int seq
Definition: core.h:322
PW_DIRECTION_OUTPUT
@ PW_DIRECTION_OUTPUT
an output port direction
Definition: port.h:49
pw_port_events::param
void(* param)(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a port param.
Definition: port.h:106
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:148