Debian Codegraph @

modules/lsp-3rd-party/include/pw-headers/pipewire/extensions/session-manager/impl-interfaces.h

raw
1 /* PipeWire */
2 /* SPDX-FileCopyrightText: Copyright © 2019 Collabora Ltd. */
3 /* @author George Kiagiadakis <[email protected]> */
4 /* SPDX-License-Identifier: MIT */
5
6 #ifndef PIPEWIRE_EXT_SESSION_MANAGER_IMPL_INTERFACES_H
7 #define PIPEWIRE_EXT_SESSION_MANAGER_IMPL_INTERFACES_H
8
9 #include <pw-headers/spa/utils/defs.h>
10 #include <pw-headers/spa/utils/hook.h>
11 #include <errno.h>
12
13 #include <pw-headers/pipewire/extensions/session-manager/introspect.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 /**
20 * \addtogroup pw_session_manager
21 * \{
22 */
23
24 #define PW_TYPE_INTERFACE_ClientEndpoint PW_TYPE_INFO_INTERFACE_BASE "ClientEndpoint"
25
26 #define PW_VERSION_CLIENT_ENDPOINT 0
27 struct pw_client_endpoint;
28
29 #define PW_CLIENT_ENDPOINT_EVENT_SET_SESSION_ID 0
30 #define PW_CLIENT_ENDPOINT_EVENT_SET_PARAM 1
31 #define PW_CLIENT_ENDPOINT_EVENT_STREAM_SET_PARAM 2
32 #define PW_CLIENT_ENDPOINT_EVENT_CREATE_LINK 3
33 #define PW_CLIENT_ENDPOINT_EVENT_NUM 4
34
35 struct pw_client_endpoint_events {
36 #define PW_VERSION_CLIENT_ENDPOINT_EVENTS 0
37 uint32_t version; /**< version of this structure */
38
39 /**
40 * Sets the session id of the \a endpoint.
41 *
42 * On endpoints that are not session masters, this method notifies
43 * the implementation that it has been associated with a session.
44 * The implementation is obliged to set this id in the
45 * #struct pw_endpoint_info \a session_id field.
46 *
47 * \param endpoint a #pw_endpoint
48 * \param id the session id associated with this endpoint
49 *
50 * \return 0 on success
51 * -EINVAL when the session id has already been set
52 * -ENOTSUP when the endpoint is a session master
53 */
54 int (*set_session_id) (void *data, uint32_t session_id);
55
56 /**
57 * Set the configurable parameter in \a endpoint.
58 *
59 * Usually, \a param will be obtained from enum_params and then
60 * modified but it is also possible to set another spa_pod
61 * as long as its keys and types match a supported object.
62 *
63 * Objects with property keys that are not known are ignored.
64 *
65 * This function must be called from the main thread.
66 *
67 * \param endpoint a #struct pw_endpoint
68 * \param id the parameter id to configure
69 * \param flags additional flags
70 * \param param the parameter to configure
71 *
72 * \return 0 on success
73 * -EINVAL when \a endpoint is NULL
74 * -ENOTSUP when there are no parameters implemented on \a endpoint
75 * -ENOENT the parameter is unknown
76 */
77 int (*set_param) (void *data,
78 uint32_t id, uint32_t flags,
79 const struct spa_pod *param);
80
81 /**
82 * Set a parameter on \a stream_id of \a endpoint.
83 *
84 * When \a param is NULL, the parameter will be unset.
85 *
86 * This function must be called from the main thread.
87 *
88 * \param endpoint a #struct pw_endpoint
89 * \param stream_id the stream to configure
90 * \param id the parameter id to set
91 * \param flags optional flags
92 * \param param a #struct spa_pod with the parameter to set
93 * \return 0 on success
94 * 1 on success, the value of \a param might have been
95 * changed depending on \a flags and the final value can
96 * be found by doing stream_enum_params.
97 * -EINVAL when \a endpoint is NULL or invalid arguments are given
98 * -ESRCH when the type or size of a property is not correct.
99 * -ENOENT when the param id is not found
100 */
101 int (*stream_set_param) (void *data, uint32_t stream_id,
102 uint32_t id, uint32_t flags,
103 const struct spa_pod *param);
104
105 int (*create_link) (void *data, const struct spa_dict *props);
106 };
107
108 #define PW_CLIENT_ENDPOINT_METHOD_ADD_LISTENER 0
109 #define PW_CLIENT_ENDPOINT_METHOD_UPDATE 1
110 #define PW_CLIENT_ENDPOINT_METHOD_STREAM_UPDATE 2
111 #define PW_CLIENT_ENDPOINT_METHOD_NUM 3
112
113 struct pw_client_endpoint_methods {
114 #define PW_VERSION_CLIENT_ENDPOINT_METHODS 0
115 uint32_t version; /**< version of this structure */
116
117 int (*add_listener) (void *object,
118 struct spa_hook *listener,
119 const struct pw_client_endpoint_events *events,
120 void *data);
121
122 /** Update endpoint information */
123 int (*update) (void *object,
124 #define PW_CLIENT_ENDPOINT_UPDATE_PARAMS (1 << 0)
125 #define PW_CLIENT_ENDPOINT_UPDATE_INFO (1 << 1)
126 uint32_t change_mask,
127 uint32_t n_params,
128 const struct spa_pod **params,
129 const struct pw_endpoint_info *info);
130
131 /** Update stream information */
132 int (*stream_update) (void *object,
133 uint32_t stream_id,
134 #define PW_CLIENT_ENDPOINT_STREAM_UPDATE_PARAMS (1 << 0)
135 #define PW_CLIENT_ENDPOINT_STREAM_UPDATE_INFO (1 << 1)
136 #define PW_CLIENT_ENDPOINT_STREAM_UPDATE_DESTROYED (1 << 2)
137 uint32_t change_mask,
138 uint32_t n_params,
139 const struct spa_pod **params,
140 const struct pw_endpoint_stream_info *info);
141 };
142
143 #define pw_client_endpoint_method(o,method,version,...) \
144 ({ \
145 int _res = -ENOTSUP; \
146 spa_interface_call_res((struct spa_interface*)o, \
147 struct pw_client_endpoint_methods, _res, \
148 method, version, ##__VA_ARGS__); \
149 _res; \
150 })
151
152 #define pw_client_endpoint_add_listener(o,...) pw_client_endpoint_method(o,add_listener,0,__VA_ARGS__)
153 #define pw_client_endpoint_update(o,...) pw_client_endpoint_method(o,update,0,__VA_ARGS__)
154 #define pw_client_endpoint_stream_update(o,...) pw_client_endpoint_method(o,stream_update,0,__VA_ARGS__)
155
156 #define PW_TYPE_INTERFACE_ClientSession PW_TYPE_INFO_INTERFACE_BASE "ClientSession"
157
158 #define PW_VERSION_CLIENT_SESSION 0
159 struct pw_client_session;
160
161 #define PW_CLIENT_SESSION_EVENT_SET_PARAM 0
162 #define PW_CLIENT_SESSION_EVENT_LINK_SET_PARAM 1
163 #define PW_CLIENT_SESSION_EVENT_LINK_REQUEST_STATE 2
164 #define PW_CLIENT_SESSION_EVENT_NUM 3
165
166 struct pw_client_session_events {
167 #define PW_VERSION_CLIENT_SESSION_EVENTS 0
168 uint32_t version; /**< version of this structure */
169
170 /**
171 * Set the configurable parameter in \a session.
172 *
173 * Usually, \a param will be obtained from enum_params and then
174 * modified but it is also possible to set another spa_pod
175 * as long as its keys and types match a supported object.
176 *
177 * Objects with property keys that are not known are ignored.
178 *
179 * This function must be called from the main thread.
180 *
181 * \param session a #struct pw_session
182 * \param id the parameter id to configure
183 * \param flags additional flags
184 * \param param the parameter to configure
185 *
186 * \return 0 on success
187 * -EINVAL when \a session is NULL
188 * -ENOTSUP when there are no parameters implemented on \a session
189 * -ENOENT the parameter is unknown
190 */
191 int (*set_param) (void *data,
192 uint32_t id, uint32_t flags,
193 const struct spa_pod *param);
194
195 /**
196 * Set a parameter on \a link_id of \a session.
197 *
198 * When \a param is NULL, the parameter will be unset.
199 *
200 * This function must be called from the main thread.
201 *
202 * \param session a #struct pw_session
203 * \param link_id the link to configure
204 * \param id the parameter id to set
205 * \param flags optional flags
206 * \param param a #struct spa_pod with the parameter to set
207 * \return 0 on success
208 * 1 on success, the value of \a param might have been
209 * changed depending on \a flags and the final value can
210 * be found by doing link_enum_params.
211 * -EINVAL when \a session is NULL or invalid arguments are given
212 * -ESRCH when the type or size of a property is not correct.
213 * -ENOENT when the param id is not found
214 */
215 int (*link_set_param) (void *data, uint32_t link_id,
216 uint32_t id, uint32_t flags,
217 const struct spa_pod *param);
218
219 int (*link_request_state) (void *data, uint32_t link_id, uint32_t state);
220 };
221
222 #define PW_CLIENT_SESSION_METHOD_ADD_LISTENER 0
223 #define PW_CLIENT_SESSION_METHOD_UPDATE 1
224 #define PW_CLIENT_SESSION_METHOD_LINK_UPDATE 2
225 #define PW_CLIENT_SESSION_METHOD_NUM 3
226
227 struct pw_client_session_methods {
228 #define PW_VERSION_CLIENT_SESSION_METHODS 0
229 uint32_t version; /**< version of this structure */
230
231 int (*add_listener) (void *object,
232 struct spa_hook *listener,
233 const struct pw_client_session_events *events,
234 void *data);
235
236 /** Update session information */
237 int (*update) (void *object,
238 #define PW_CLIENT_SESSION_UPDATE_PARAMS (1 << 0)
239 #define PW_CLIENT_SESSION_UPDATE_INFO (1 << 1)
240 uint32_t change_mask,
241 uint32_t n_params,
242 const struct spa_pod **params,
243 const struct pw_session_info *info);
244
245 /** Update link information */
246 int (*link_update) (void *object,
247 uint32_t link_id,
248 #define PW_CLIENT_SESSION_LINK_UPDATE_PARAMS (1 << 0)
249 #define PW_CLIENT_SESSION_LINK_UPDATE_INFO (1 << 1)
250 #define PW_CLIENT_SESSION_LINK_UPDATE_DESTROYED (1 << 2)
251 uint32_t change_mask,
252 uint32_t n_params,
253 const struct spa_pod **params,
254 const struct pw_endpoint_link_info *info);
255 };
256
257 #define pw_client_session_method(o,method,version,...) \
258 ({ \
259 int _res = -ENOTSUP; \
260 spa_interface_call_res((struct spa_interface*)o, \
261 struct pw_client_session_methods, _res, \
262 method, version, ##__VA_ARGS__); \
263 _res; \
264 })
265
266 #define pw_client_session_add_listener(o,...) pw_client_session_method(o,add_listener,0,__VA_ARGS__)
267 #define pw_client_session_update(o,...) pw_client_session_method(o,update,0,__VA_ARGS__)
268 #define pw_client_session_link_update(o,...) pw_client_session_method(o,link_update,0,__VA_ARGS__)
269
270 /**
271 * \}
272 */
273
274 #ifdef __cplusplus
275 } /* extern "C" */
276 #endif
277
278 #endif /* PIPEWIRE_EXT_SESSION_MANAGER_IMPL_INTERFACES_H */