PipeWire: pipewire/link.h Source File

PipeWire 0.3.51

link.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_LINK_H
26#define PIPEWIRE_LINK_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <spa/utils/defs.h>
33#include <spa/utils/hook.h>
34
35#include <pipewire/proxy.h>
36
52#define PW_TYPE_INTERFACE_Link PW_TYPE_INFO_INTERFACE_BASE "Link"
53
54#define PW_VERSION_LINK 3
55struct pw_link;
56
58enum pw_link_state {
59 PW_LINK_STATE_ERROR = -2,
60 PW_LINK_STATE_UNLINKED = -1,
61 PW_LINK_STATE_INIT = 0,
62 PW_LINK_STATE_NEGOTIATING = 1,
63 PW_LINK_STATE_ALLOCATING = 2,
64 PW_LINK_STATE_PAUSED = 3,
65 PW_LINK_STATE_ACTIVE = 4,
66};
67
69 const char * pw_link_state_as_string(enum pw_link_state state);
71 struct pw_link_info {
72 uint32_t id;
73 uint32_t output_node_id;
74 uint32_t output_port_id;
75 uint32_t input_node_id;
76 uint32_t input_port_id;
77#define PW_LINK_CHANGE_MASK_STATE (1 << 0)
78#define PW_LINK_CHANGE_MASK_FORMAT (1 << 1)
79#define PW_LINK_CHANGE_MASK_PROPS (1 << 2)
80#define PW_LINK_CHANGE_MASK_ALL ((1 << 3)-1)
81 uint64_t change_mask;
82 enum pw_link_state state;
83 const char *error;
84 struct spa_pod *format;
85 struct spa_dict *props;
86};
87
88struct pw_link_info *
89 pw_link_info_update(struct pw_link_info *info,
90 const struct pw_link_info *update);
91
92 struct pw_link_info *
93 pw_link_info_merge(struct pw_link_info *info,
94 const struct pw_link_info *update, bool reset);
95
96void
97 pw_link_info_free(struct pw_link_info *info);
98
99
100#define PW_LINK_EVENT_INFO 0
101#define PW_LINK_EVENT_NUM 1
102
104struct pw_link_events {
105#define PW_VERSION_LINK_EVENTS 0
106 uint32_t version;
112 void (*info) (void *data, const struct pw_link_info *info);
113};
114
115#define PW_LINK_METHOD_ADD_LISTENER 0
116#define PW_LINK_METHOD_NUM 1
117
119 struct pw_link_methods {
120#define PW_VERSION_LINK_METHODS 0
121 uint32_t version;
122
123 int (*add_listener) (void *object,
124 struct spa_hook *listener,
125 const struct pw_link_events *events,
126 void *data);
127};
128
129#define pw_link_method(o,method,version,...) \
130({ \
131 int _res = -ENOTSUP; \
132 spa_interface_call_res((struct spa_interface*)o, \
133 struct pw_link_methods, _res, \
134 method, version, ##__VA_ARGS__); \
135 _res; \
136})
137
138#define pw_link_add_listener(c,...) pw_link_method(c,add_listener,0,__VA_ARGS__)
139
144#ifdef __cplusplus
145} /* extern "C" */
146#endif
147
148#endif /* PIPEWIRE_LINK_H */
defs.h
spa/utils/defs.h
pw_link_state_as_string
const char * pw_link_state_as_string(enum pw_link_state state)
Convert a pw_link_state to a readable string.
Definition: introspect.c:64
pw_link_info_merge
struct pw_link_info * pw_link_info_merge(struct pw_link_info *info, const struct pw_link_info *update, bool reset)
Definition: introspect.c:528
pw_link_info_free
void pw_link_info_free(struct pw_link_info *info)
Definition: introspect.c:574
pw_link_info_update
struct pw_link_info * pw_link_info_update(struct pw_link_info *info, const struct pw_link_info *update)
Definition: introspect.c:567
pw_link_state
pw_link_state
The different link states.
Definition: link.h:65
PW_LINK_STATE_ACTIVE
@ PW_LINK_STATE_ACTIVE
the link is active
Definition: link.h:72
PW_LINK_STATE_ERROR
@ PW_LINK_STATE_ERROR
the link is in error
Definition: link.h:66
PW_LINK_STATE_UNLINKED
@ PW_LINK_STATE_UNLINKED
the link is unlinked
Definition: link.h:67
PW_LINK_STATE_PAUSED
@ PW_LINK_STATE_PAUSED
the link is paused
Definition: link.h:71
PW_LINK_STATE_NEGOTIATING
@ PW_LINK_STATE_NEGOTIATING
the link is negotiating formats
Definition: link.h:69
PW_LINK_STATE_INIT
@ PW_LINK_STATE_INIT
the link is initialized
Definition: link.h:68
PW_LINK_STATE_ALLOCATING
@ PW_LINK_STATE_ALLOCATING
the link is allocating buffers
Definition: link.h:70
hook.h
spa/utils/hook.h
proxy.h
pipewire/proxy.h
pw_link_events
Link events.
Definition: link.h:117
pw_link_events::version
uint32_t version
Definition: link.h:120
pw_link_events::info
void(* info)(void *data, const struct pw_link_info *info)
Notify link info.
Definition: link.h:126
pw_link_info
The link information.
Definition: link.h:78
pw_link_info::output_port_id
uint32_t output_port_id
output port id
Definition: link.h:81
pw_link_info::id
uint32_t id
id of the global
Definition: link.h:79
pw_link_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: link.h:92
pw_link_info::output_node_id
uint32_t output_node_id
server side output node id
Definition: link.h:80
pw_link_info::state
enum pw_link_state state
the current state of the link
Definition: link.h:93
pw_link_info::error
const char * error
an error reason if state is error
Definition: link.h:94
pw_link_info::input_node_id
uint32_t input_node_id
server side input node id
Definition: link.h:82
pw_link_info::format
struct spa_pod * format
format over link
Definition: link.h:95
pw_link_info::input_port_id
uint32_t input_port_id
input port id
Definition: link.h:83
pw_link_methods
Link methods.
Definition: link.h:135
pw_link_methods::version
uint32_t version
Definition: link.h:138
pw_link_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_link_events *events, void *data)
Definition: link.h:140
pw_link
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:351
spa_pod
Definition: pod.h:63