PipeWire: node.h Source File

PipeWire 0.3.37

pipewire/src/pipewire/node.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_NODE_H
26#define PIPEWIRE_NODE_H
27
28#ifdef __cplusplus
29extern "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/node/command.h>
38#include <spa/param/param.h>
39
40#include <pipewire/proxy.h>
41
50#define PW_TYPE_INTERFACE_Node PW_TYPE_INFO_INTERFACE_BASE "Node"
51
52#define PW_VERSION_NODE 3
53struct pw_node;
54
56 enum pw_node_state {
57 PW_NODE_STATE_ERROR = -1,
58 PW_NODE_STATE_CREATING = 0,
59 PW_NODE_STATE_SUSPENDED = 1,
61 PW_NODE_STATE_IDLE = 2,
63 PW_NODE_STATE_RUNNING = 3,
64};
65
67const char * pw_node_state_as_string(enum pw_node_state state);
68
70 struct pw_node_info {
71 uint32_t id;
72 uint32_t max_input_ports;
73 uint32_t max_output_ports;
74#define PW_NODE_CHANGE_MASK_INPUT_PORTS (1 << 0)
75#define PW_NODE_CHANGE_MASK_OUTPUT_PORTS (1 << 1)
76#define PW_NODE_CHANGE_MASK_STATE (1 << 2)
77#define PW_NODE_CHANGE_MASK_PROPS (1 << 3)
78#define PW_NODE_CHANGE_MASK_PARAMS (1 << 4)
79#define PW_NODE_CHANGE_MASK_ALL ((1 << 5)-1)
80 uint64_t change_mask;
81 uint32_t n_input_ports;
82 uint32_t n_output_ports;
83 enum pw_node_state state;
84 const char *error;
85 struct spa_dict *props;
86 struct spa_param_info *params;
87 uint32_t n_params;
88};
89
90struct pw_node_info *
91 pw_node_info_update(struct pw_node_info *info,
92 const struct pw_node_info *update);
93
94struct pw_node_info *
95 pw_node_info_merge(struct pw_node_info *info,
96 const struct pw_node_info *update, bool reset);
97
98void
99 pw_node_info_free(struct pw_node_info *info);
100
101#define PW_NODE_EVENT_INFO 0
102#define PW_NODE_EVENT_PARAM 1
103#define PW_NODE_EVENT_NUM 2
104
106 struct pw_node_events {
107#define PW_VERSION_NODE_EVENTS 0
108 uint32_t version;
114 void (*info) (void *object, const struct pw_node_info *info);
126 void (*param) (void *object, int seq,
127 uint32_t id, uint32_t index, uint32_t next,
128 const struct spa_pod *param);
129};
130
131#define PW_NODE_METHOD_ADD_LISTENER 0
132#define PW_NODE_METHOD_SUBSCRIBE_PARAMS 1
133#define PW_NODE_METHOD_ENUM_PARAMS 2
134#define PW_NODE_METHOD_SET_PARAM 3
135#define PW_NODE_METHOD_SEND_COMMAND 4
136#define PW_NODE_METHOD_NUM 5
137
139 struct pw_node_methods {
140#define PW_VERSION_NODE_METHODS 0
141 uint32_t version;
142
143 int (*add_listener) (void *object,
144 struct spa_hook *listener,
145 const struct pw_node_events *events,
146 void *data);
156 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
157
170 int (*enum_params) (void *object, int seq, uint32_t id,
171 uint32_t start, uint32_t num,
172 const struct spa_pod *filter);
173
181 int (*set_param) (void *object, uint32_t id, uint32_t flags,
182 const struct spa_pod *param);
183
189 int (*send_command) (void *object, const struct spa_command *command);
190};
191
192#define pw_node_method(o,method,version,...) \
193({ \
194 int _res = -ENOTSUP; \
195 spa_interface_call_res((struct spa_interface*)o, \
196 struct pw_node_methods, _res, \
197 method, version, ##__VA_ARGS__); \
198 _res; \
199})
200
202#define pw_node_add_listener(c,...) pw_node_method(c,add_listener,0,__VA_ARGS__)
203#define pw_node_subscribe_params(c,...) pw_node_method(c,subscribe_params,0,__VA_ARGS__)
204#define pw_node_enum_params(c,...) pw_node_method(c,enum_params,0,__VA_ARGS__)
205#define pw_node_set_param(c,...) pw_node_method(c,set_param,0,__VA_ARGS__)
206#define pw_node_send_command(c,...) pw_node_method(c,send_command,0,__VA_ARGS__)
207
212#ifdef __cplusplus
213} /* extern "C" */
214#endif
215
216#endif /* PIPEWIRE_NODE_H */
defs.h
pw_node_info_free
void pw_node_info_free(struct pw_node_info *info)
Definition: introspect.c:243
pw_node_info_merge
struct pw_node_info * pw_node_info_merge(struct pw_node_info *info, const struct pw_node_info *update, bool reset)
Definition: introspect.c:177
pw_node_info_update
struct pw_node_info * pw_node_info_update(struct pw_node_info *info, const struct pw_node_info *update)
Definition: introspect.c:236
pw_node_state_as_string
const char * pw_node_state_as_string(enum pw_node_state state)
Convert a pw_node_state to a readable string.
Definition: introspect.c:34
pw_node_state
pw_node_state
The different node states.
Definition: pipewire/src/pipewire/node.h:56
PW_NODE_STATE_ERROR
@ PW_NODE_STATE_ERROR
error state
Definition: pipewire/src/pipewire/node.h:57
PW_NODE_STATE_SUSPENDED
@ PW_NODE_STATE_SUSPENDED
the node is suspended, the device might be closed
Definition: pipewire/src/pipewire/node.h:59
PW_NODE_STATE_IDLE
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: pipewire/src/pipewire/node.h:61
PW_NODE_STATE_CREATING
@ PW_NODE_STATE_CREATING
the node is being created
Definition: pipewire/src/pipewire/node.h:58
PW_NODE_STATE_RUNNING
@ PW_NODE_STATE_RUNNING
the node is running
Definition: pipewire/src/pipewire/node.h:63
hook.h
start
int(* start)(struct sm_media_session *sess)
Definition: media-session.c:2382
command.h
param.h
proxy.h
data
user data to add to an object
Definition: media-session.c:110
filter
Definition: filter.c:126
param
Definition: media-session.c:116
pw_node_events
Node events.
Definition: pipewire/src/pipewire/node.h:106
pw_node_events::param
void(* param)(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a node param.
Definition: pipewire/src/pipewire/node.h:126
pw_node_events::version
uint32_t version
Definition: pipewire/src/pipewire/node.h:108
pw_node_events::info
void(* info)(void *object, const struct pw_node_info *info)
Notify node info.
Definition: pipewire/src/pipewire/node.h:114
pw_node_info
The node information.
Definition: pipewire/src/pipewire/node.h:70
pw_node_info::state
enum pw_node_state state
the current state of the node
Definition: pipewire/src/pipewire/node.h:83
pw_node_info::max_input_ports
uint32_t max_input_ports
maximum number of inputs
Definition: pipewire/src/pipewire/node.h:72
pw_node_info::error
const char * error
an error reason if state is error
Definition: pipewire/src/pipewire/node.h:84
pw_node_info::id
uint32_t id
id of the global
Definition: pipewire/src/pipewire/node.h:71
pw_node_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: pipewire/src/pipewire/node.h:80
pw_node_info::params
struct spa_param_info * params
parameters
Definition: pipewire/src/pipewire/node.h:86
pw_node_info::n_output_ports
uint32_t n_output_ports
number of outputs
Definition: pipewire/src/pipewire/node.h:82
pw_node_info::props
struct spa_dict * props
the properties of the node
Definition: pipewire/src/pipewire/node.h:85
pw_node_info::max_output_ports
uint32_t max_output_ports
maximum number of outputs
Definition: pipewire/src/pipewire/node.h:73
pw_node_info::n_params
uint32_t n_params
number of items in params
Definition: pipewire/src/pipewire/node.h:87
pw_node_info::n_input_ports
uint32_t n_input_ports
number of inputs
Definition: pipewire/src/pipewire/node.h:81
pw_node_methods
Node methods.
Definition: pipewire/src/pipewire/node.h:139
pw_node_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_node_events *events, void *data)
Definition: pipewire/src/pipewire/node.h:143
pw_node_methods::set_param
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a parameter on the node.
Definition: pipewire/src/pipewire/node.h:181
pw_node_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 node parameters.
Definition: pipewire/src/pipewire/node.h:170
pw_node_methods::version
uint32_t version
Definition: pipewire/src/pipewire/node.h:141
pw_node_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: pipewire/src/pipewire/node.h:156
pw_node_methods::send_command
int(* send_command)(void *object, const struct spa_command *command)
Send a command to the node.
Definition: pipewire/src/pipewire/node.h:189
spa_command
Definition: pod/command.h:44
spa_dict
Definition: utils/dict.h:48
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:295
spa_param_info
information about a parameter
Definition: param.h:64
spa_pod
Definition: pod/pod.h:50