PipeWire  0.3.66
impl-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_IMPL_NODE_H
6 #define PIPEWIRE_IMPL_NODE_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
22 struct pw_impl_node;
23 struct pw_impl_port;
24 
25 #include <spa/node/node.h>
26 #include <spa/node/event.h>
27 
28 #include <pipewire/impl.h>
29 
31 struct pw_impl_node_events {
32 #define PW_VERSION_IMPL_NODE_EVENTS 0
33  uint32_t version;
34 
36  void (*destroy) (void *data);
38  void (*free) (void *data);
40  void (*initialized) (void *data);
41 
43  void (*port_init) (void *data, struct pw_impl_port *port);
45  void (*port_added) (void *data, struct pw_impl_port *port);
47  void (*port_removed) (void *data, struct pw_impl_port *port);
48 
50  void (*info_changed) (void *data, const struct pw_node_info *info);
52  void (*port_info_changed) (void *data, struct pw_impl_port *port,
53  const struct pw_port_info *info);
55  void (*active_changed) (void *data, bool active);
56 
58  void (*state_request) (void *data, enum pw_node_state state);
60  void (*state_changed) (void *data, enum pw_node_state old,
61  enum pw_node_state state, const char *error);
62 
64  void (*result) (void *data, int seq, int res, uint32_t type, const void *result);
65 
67  void (*event) (void *data, const struct spa_event *event);
68 
70  void (*driver_changed) (void *data, struct pw_impl_node *old, struct pw_impl_node *driver);
71 
73  void (*peer_added) (void *data, struct pw_impl_node *peer);
75  void (*peer_removed) (void *data, struct pw_impl_node *peer);
76 };
77 
79 struct pw_impl_node *
81  struct pw_properties *properties,
82  size_t user_data_size );
83 
85 int pw_impl_node_register(struct pw_impl_node *node,
86  struct pw_properties *properties );
87 
89 void pw_impl_node_destroy(struct pw_impl_node *node);
90 
92 const struct pw_node_info *pw_impl_node_get_info(struct pw_impl_node *node);
93 
95 void * pw_impl_node_get_user_data(struct pw_impl_node *node);
96 
99 
101 struct pw_global *pw_impl_node_get_global(struct pw_impl_node *node);
102 
104 const struct pw_properties *pw_impl_node_get_properties(struct pw_impl_node *node);
105 
107 int pw_impl_node_update_properties(struct pw_impl_node *node, const struct spa_dict *dict);
108 
111 
114 
116 void pw_impl_node_add_listener(struct pw_impl_node *node,
117  struct spa_hook *listener,
118  const struct pw_impl_node_events *events,
119  void *data);
120 
126  enum pw_direction direction,
127  int (*callback) (void *data, struct pw_impl_port *port),
128  void *data);
129 
131  int seq, uint32_t param_id,
132  uint32_t index, uint32_t max,
133  const struct spa_pod *filter,
134  int (*callback) (void *data, int seq,
135  uint32_t id, uint32_t index, uint32_t next,
136  struct spa_pod *param),
137  void *data);
138 
141 struct pw_impl_port *
142 pw_impl_node_find_port(struct pw_impl_node *node, enum pw_direction direction, uint32_t port_id);
143 
145 uint32_t pw_impl_node_get_free_port_id(struct pw_impl_node *node, enum pw_direction direction);
146 
147 int pw_impl_node_initialized(struct pw_impl_node *node);
148 
151 int pw_impl_node_set_active(struct pw_impl_node *node, bool active);
152 
154 bool pw_impl_node_is_active(struct pw_impl_node *node);
155 
157 int pw_impl_node_send_command(struct pw_impl_node *node, const struct spa_command *command);
158 
160 int pw_impl_node_set_param(struct pw_impl_node *node,
161  uint32_t id, uint32_t flags, const struct spa_pod *param);
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* PIPEWIRE_IMPL_NODE_H */
int pw_impl_node_initialized(struct pw_impl_node *node)
Definition: impl-node.c:784
struct pw_impl_node * pw_context_create_node(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Create a new node.
Definition: impl-node.c:1220
const struct pw_node_info * pw_impl_node_get_info(struct pw_impl_node *node)
Get the node info.
Definition: impl-node.c:1335
int pw_impl_node_set_implementation(struct pw_impl_node *node, struct spa_node *spa_node)
Set the node implementation.
Definition: impl-node.c:1805
void pw_impl_node_add_listener(struct pw_impl_node *node, struct spa_hook *listener, const struct pw_impl_node_events *events, void *data)
Add an event listener.
Definition: impl-node.c:1834
const struct pw_properties * pw_impl_node_get_properties(struct pw_impl_node *node)
Get the node properties.
Definition: impl-node.c:1359
int pw_impl_node_send_command(struct pw_impl_node *node, const struct spa_command *command)
Check if a node is active, Since 0.3.39.
Definition: impl-node.c:2293
bool pw_impl_node_is_active(struct pw_impl_node *node)
Check if a node is active.
Definition: impl-node.c:2287
int pw_impl_node_register(struct pw_impl_node *node, struct pw_properties *properties)
Complete initialization of the node and register.
Definition: impl-node.c:704
int pw_impl_node_update_properties(struct pw_impl_node *node, const struct spa_dict *dict)
Update the node properties.
Definition: impl-node.c:1390
struct pw_impl_port * pw_impl_node_find_port(struct pw_impl_node *node, enum pw_direction direction, uint32_t port_id)
Find the port with direction and port_id or NULL when not found.
Definition: impl-node.c:2077
int pw_impl_node_set_active(struct pw_impl_node *node, bool active)
Set a node active.
Definition: impl-node.c:2265
struct pw_context * pw_impl_node_get_context(struct pw_impl_node *node)
Get the context of this node.
Definition: impl-node.c:1347
void pw_impl_node_destroy(struct pw_impl_node *node)
Destroy a node.
Definition: impl-node.c:1849
void * pw_impl_node_get_user_data(struct pw_impl_node *node)
Get node user_data.
Definition: impl-node.c:1341
struct spa_node * pw_impl_node_get_implementation(struct pw_impl_node *node)
Get the node implementation.
Definition: impl-node.c:1828
int pw_impl_node_set_param(struct pw_impl_node *node, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set a param on the node, Since 0.3.65.
Definition: impl-node.c:2067
struct pw_global * pw_impl_node_get_global(struct pw_impl_node *node)
Get the global of this node.
Definition: impl-node.c:1353
uint32_t pw_impl_node_get_free_port_id(struct pw_impl_node *node, enum pw_direction direction)
Get a free unused port_id from the node.
Definition: impl-node.c:2112
int pw_impl_node_for_each_port(struct pw_impl_node *node, enum pw_direction direction, int(*callback)(void *data, struct pw_impl_port *port), void *data)
Iterate the ports in the given direction.
Definition: impl-node.c:1931
int pw_impl_node_for_each_param(struct pw_impl_node *node, int seq, uint32_t param_id, uint32_t index, uint32_t max, const struct spa_pod *filter, int(*callback)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param), void *data)
Definition: impl-node.c:1986
pw_node_state
The different node states.
Definition: src/pipewire/node.h:43
#define pw_direction
The direction of a port.
Definition: port.h:43
pipewire/impl.h
spa/node/event.h
spa/node/node.h
Definition: src/pipewire/context.h:47
Node events, listen to them with pw_impl_node_add_listener.
Definition: impl-node.h:37
void(* peer_removed)(void *data, struct pw_impl_node *peer)
a peer was removed
Definition: impl-node.h:82
void(* state_request)(void *data, enum pw_node_state state)
a new state is requested on the node
Definition: impl-node.h:65
void(* destroy)(void *data)
the node is destroyed
Definition: impl-node.h:43
void(* port_init)(void *data, struct pw_impl_port *port)
a port is being initialized on the node
Definition: impl-node.h:50
void(* peer_added)(void *data, struct pw_impl_node *peer)
a peer was added
Definition: impl-node.h:80
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
a result was received
Definition: impl-node.h:71
uint32_t version
Definition: impl-node.h:40
void(* free)(void *data)
the node is about to be freed
Definition: impl-node.h:45
void(* port_info_changed)(void *data, struct pw_impl_port *port, const struct pw_port_info *info)
a port on the node changed info
Definition: impl-node.h:59
void(* active_changed)(void *data, bool active)
the node active state changed
Definition: impl-node.h:62
void(* port_removed)(void *data, struct pw_impl_port *port)
a port was removed
Definition: impl-node.h:54
void(* event)(void *data, const struct spa_event *event)
an event is emitted
Definition: impl-node.h:74
void(* info_changed)(void *data, const struct pw_node_info *info)
the node info changed
Definition: impl-node.h:57
void(* port_added)(void *data, struct pw_impl_port *port)
a port was added
Definition: impl-node.h:52
void(* initialized)(void *data)
the node is initialized
Definition: impl-node.h:47
void(* driver_changed)(void *data, struct pw_impl_node *old, struct pw_impl_node *driver)
the driver of the node changed
Definition: impl-node.h:77
void(* state_changed)(void *data, enum pw_node_state old, enum pw_node_state state, const char *error)
the state of the node changed
Definition: impl-node.h:67
Definition: impl.h:27
The node information.
Definition: src/pipewire/node.h:57
Definition: port.h:52
Definition: properties.h:33
struct spa_dict dict
dictionary of key/values
Definition: properties.h:34
Definition: pod/command.h:29
Definition: utils/dict.h:39
Definition: pod/event.h:28
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:331
Definition: spa/include/spa/node/node.h:41
Definition: pod/pod.h:43