PipeWire: node.h Source File

PipeWire 0.3.70

Loading...
Searching...
No Matches
src/pipewire/node.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_NODE_H
6#define PIPEWIRE_NODE_H
7
8#ifdef __cplusplus
9extern "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/node/command.h>
18#include <spa/param/param.h>
19
20#include <pipewire/proxy.h>
21
30#define PW_TYPE_INTERFACE_Node PW_TYPE_INFO_INTERFACE_BASE "Node"
31
32#define PW_VERSION_NODE 3
33struct pw_node;
34
36enum pw_node_state {
37 PW_NODE_STATE_ERROR = -1,
38 PW_NODE_STATE_CREATING = 0,
39 PW_NODE_STATE_SUSPENDED = 1,
41 PW_NODE_STATE_IDLE = 2,
43 PW_NODE_STATE_RUNNING = 3,
44};
45
47 const char * pw_node_state_as_string(enum pw_node_state state);
48
50 struct pw_node_info {
51 uint32_t id;
52 uint32_t max_input_ports;
53 uint32_t max_output_ports;
54#define PW_NODE_CHANGE_MASK_INPUT_PORTS (1 << 0)
55#define PW_NODE_CHANGE_MASK_OUTPUT_PORTS (1 << 1)
56#define PW_NODE_CHANGE_MASK_STATE (1 << 2)
57#define PW_NODE_CHANGE_MASK_PROPS (1 << 3)
58#define PW_NODE_CHANGE_MASK_PARAMS (1 << 4)
59#define PW_NODE_CHANGE_MASK_ALL ((1 << 5)-1)
60 uint64_t change_mask;
61 uint32_t n_input_ports;
62 uint32_t n_output_ports;
63 enum pw_node_state state;
64 const char *error;
65 struct spa_dict *props;
66 struct spa_param_info *params;
67 uint32_t n_params;
68};
69
70 struct pw_node_info *
71 pw_node_info_update(struct pw_node_info *info,
72 const struct pw_node_info *update);
73
74 struct pw_node_info *
75 pw_node_info_merge(struct pw_node_info *info,
76 const struct pw_node_info *update, bool reset);
77
78void
79 pw_node_info_free(struct pw_node_info *info);
80
81#define PW_NODE_EVENT_INFO 0
82#define PW_NODE_EVENT_PARAM 1
83#define PW_NODE_EVENT_NUM 2
84
86struct pw_node_events {
87#define PW_VERSION_NODE_EVENTS 0
88 uint32_t version;
94 void (*info) (void *data, const struct pw_node_info *info);
106 void (*param) (void *data, int seq,
107 uint32_t id, uint32_t index, uint32_t next,
108 const struct spa_pod *param);
109};
110
111#define PW_NODE_METHOD_ADD_LISTENER 0
112#define PW_NODE_METHOD_SUBSCRIBE_PARAMS 1
113#define PW_NODE_METHOD_ENUM_PARAMS 2
114#define PW_NODE_METHOD_SET_PARAM 3
115#define PW_NODE_METHOD_SEND_COMMAND 4
116#define PW_NODE_METHOD_NUM 5
117
119struct pw_node_methods {
120#define PW_VERSION_NODE_METHODS 0
121 uint32_t version;
122
123 int (*add_listener) (void *object,
124 struct spa_hook *listener,
125 const struct pw_node_events *events,
126 void *data);
136 int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
137
150 int (*enum_params) (void *object, int seq, uint32_t id,
151 uint32_t start, uint32_t num,
152 const struct spa_pod *filter);
153
161 int (*set_param) (void *object, uint32_t id, uint32_t flags,
162 const struct spa_pod *param);
163
169 int (*send_command) (void *object, const struct spa_command *command);
170};
171
172#define pw_node_method(o,method,version,...) \
173({ \
174 int _res = -ENOTSUP; \
175 spa_interface_call_res((struct spa_interface*)o, \
176 struct pw_node_methods, _res, \
177 method, version, ##__VA_ARGS__); \
178 _res; \
179})
180
182#define pw_node_add_listener(c,...) pw_node_method(c,add_listener,0,__VA_ARGS__)
183#define pw_node_subscribe_params(c,...) pw_node_method(c,subscribe_params,0,__VA_ARGS__)
184#define pw_node_enum_params(c,...) pw_node_method(c,enum_params,0,__VA_ARGS__)
185#define pw_node_set_param(c,...) pw_node_method(c,set_param,0,__VA_ARGS__)
186#define pw_node_send_command(c,...) pw_node_method(c,send_command,0,__VA_ARGS__)
187
192#ifdef __cplusplus
193} /* extern "C" */
194#endif
195
196#endif /* PIPEWIRE_NODE_H */
defs.h
spa/utils/defs.h
pw_node_info_free
void pw_node_info_free(struct pw_node_info *info)
Definition: introspect.c:231
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:157
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:224
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:14
pw_node_state
pw_node_state
The different node states.
Definition: src/pipewire/node.h:43
PW_NODE_STATE_ERROR
@ PW_NODE_STATE_ERROR
error state
Definition: src/pipewire/node.h:44
PW_NODE_STATE_SUSPENDED
@ PW_NODE_STATE_SUSPENDED
the node is suspended, the device might be closed
Definition: src/pipewire/node.h:46
PW_NODE_STATE_IDLE
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: src/pipewire/node.h:48
PW_NODE_STATE_CREATING
@ PW_NODE_STATE_CREATING
the node is being created
Definition: src/pipewire/node.h:45
PW_NODE_STATE_RUNNING
@ PW_NODE_STATE_RUNNING
the node is running
Definition: src/pipewire/node.h:50
hook.h
spa/utils/hook.h
command.h
spa/node/command.h
param.h
spa/param/param.h
proxy.h
pipewire/proxy.h
pw_node_events
Node events.
Definition: src/pipewire/node.h:102
pw_node_events::info
void(* info)(void *data, const struct pw_node_info *info)
Notify node info.
Definition: src/pipewire/node.h:111
pw_node_events::version
uint32_t version
Definition: src/pipewire/node.h:105
pw_node_events::param
void(* param)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a node param.
Definition: src/pipewire/node.h:123
pw_node_info
The node information.
Definition: src/pipewire/node.h:57
pw_node_info::state
enum pw_node_state state
the current state of the node
Definition: src/pipewire/node.h:76
pw_node_info::max_input_ports
uint32_t max_input_ports
maximum number of inputs
Definition: src/pipewire/node.h:59
pw_node_info::error
const char * error
an error reason if state is error
Definition: src/pipewire/node.h:77
pw_node_info::id
uint32_t id
id of the global
Definition: src/pipewire/node.h:58
pw_node_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition: src/pipewire/node.h:73
pw_node_info::params
struct spa_param_info * params
parameters
Definition: src/pipewire/node.h:79
pw_node_info::n_output_ports
uint32_t n_output_ports
number of outputs
Definition: src/pipewire/node.h:75
pw_node_info::max_output_ports
uint32_t max_output_ports
maximum number of outputs
Definition: src/pipewire/node.h:60
pw_node_info::n_params
uint32_t n_params
number of items in params
Definition: src/pipewire/node.h:80
pw_node_info::n_input_ports
uint32_t n_input_ports
number of inputs
Definition: src/pipewire/node.h:74
pw_node_methods
Node methods.
Definition: src/pipewire/node.h:142
pw_node_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_node_events *events, void *data)
Definition: src/pipewire/node.h:147
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: src/pipewire/node.h:185
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: src/pipewire/node.h:174
pw_node_methods::version
uint32_t version
Definition: src/pipewire/node.h:145
pw_node_methods::subscribe_params
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: src/pipewire/node.h:160
pw_node_methods::send_command
int(* send_command)(void *object, const struct spa_command *command)
Send a command to the node.
Definition: src/pipewire/node.h:193
pw_node
spa_command
Definition: pod/command.h:29
spa_dict
Definition: utils/dict.h:39
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:331
spa_param_info
information about a parameter
Definition: param.h:50
spa_pod
Definition: pod/pod.h:43