PipeWire  0.3.15
impl-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_IMPL_NODE_H
26 #define PIPEWIRE_IMPL_NODE_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
44 struct pw_impl_node;
45 struct pw_impl_port;
46 
47 #include <spa/node/node.h>
48 #include <spa/node/event.h>
49 
50 #include <pipewire/impl.h>
51 
54 #define PW_VERSION_IMPL_NODE_EVENTS 0
55  uint32_t version;
56 
58  void (*destroy) (void *data);
60  void (*free) (void *data);
62  void (*initialized) (void *data);
63 
65  void (*port_init) (void *data, struct pw_impl_port *port);
67  void (*port_added) (void *data, struct pw_impl_port *port);
69  void (*port_removed) (void *data, struct pw_impl_port *port);
70 
72  void (*info_changed) (void *data, const struct pw_node_info *info);
74  void (*port_info_changed) (void *data, struct pw_impl_port *port,
75  const struct pw_port_info *info);
77  void (*active_changed) (void *data, bool active);
78 
80  void (*state_request) (void *data, enum pw_node_state state);
82  void (*state_changed) (void *data, enum pw_node_state old,
83  enum pw_node_state state, const char *error);
84 
86  void (*result) (void *data, int seq, int res, uint32_t type, const void *result);
87 
89  void (*event) (void *data, const struct spa_event *event);
90 
92  void (*driver_changed) (void *data, struct pw_impl_node *old, struct pw_impl_node *driver);
93 
95  void (*peer_added) (void *data, struct pw_impl_node *peer);
97  void (*peer_removed) (void *data, struct pw_impl_node *peer);
98 };
99 
101 struct pw_impl_node *
102 pw_context_create_node(struct pw_context *context,
103  struct pw_properties *properties,
104  size_t user_data_size );
105 
107 int pw_impl_node_register(struct pw_impl_node *node,
108  struct pw_properties *properties );
109 
111 void pw_impl_node_destroy(struct pw_impl_node *node);
112 
114 const struct pw_node_info *pw_impl_node_get_info(struct pw_impl_node *node);
115 
117 void * pw_impl_node_get_user_data(struct pw_impl_node *node);
118 
120 struct pw_context *pw_impl_node_get_context(struct pw_impl_node *node);
121 
123 struct pw_global *pw_impl_node_get_global(struct pw_impl_node *node);
124 
126 const struct pw_properties *pw_impl_node_get_properties(struct pw_impl_node *node);
127 
129 int pw_impl_node_update_properties(struct pw_impl_node *node, const struct spa_dict *dict);
130 
132 int pw_impl_node_set_implementation(struct pw_impl_node *node, struct spa_node *spa_node);
133 
135 struct spa_node *pw_impl_node_get_implementation(struct pw_impl_node *node);
136 
138 void pw_impl_node_add_listener(struct pw_impl_node *node,
139  struct spa_hook *listener,
140  const struct pw_impl_node_events *events,
141  void *data);
142 
148  enum pw_direction direction,
149  int (*callback) (void *data, struct pw_impl_port *port),
150  void *data);
151 
153  int seq, uint32_t param_id,
154  uint32_t index, uint32_t max,
155  const struct spa_pod *filter,
156  int (*callback) (void *data, int seq,
157  uint32_t id, uint32_t index, uint32_t next,
158  struct spa_pod *param),
159  void *data);
160 
163 struct pw_impl_port *
164 pw_impl_node_find_port(struct pw_impl_node *node, enum pw_direction direction, uint32_t port_id);
165 
167 uint32_t pw_impl_node_get_free_port_id(struct pw_impl_node *node, enum pw_direction direction);
168 
169 int pw_impl_node_initialized(struct pw_impl_node *node);
170 
173 int pw_impl_node_set_active(struct pw_impl_node *node, bool active);
174 
176 bool pw_impl_node_is_active(struct pw_impl_node *node);
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 #endif /* PIPEWIRE_IMPL_NODE_H */
void(* event)(void *data, const struct spa_event *event)
an event is emitted
Definition: impl-node.h:89
Definition: buffers.c:44
A collection of key/value pairs.
Definition: properties.h:45
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:614
static uint32_t int int res
Definition: core.h:325
SPA_EXPORT struct pw_impl_node * pw_context_create_node(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: impl-node.c:1056
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
pw_node_state
The different node states.
Definition: node.h:48
Definition: port.h:61
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:1697
uint32_t version
Definition: impl-node.h:55
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:1822
PipeWire node class.
void(* peer_added)(void *data, struct pw_impl_node *peer)
a peer was added
Definition: impl-node.h:95
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:74
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:1742
void(* port_added)(void *data, struct pw_impl_port *port)
a port was added
Definition: impl-node.h:67
bool pw_impl_node_is_active(struct pw_impl_node *node)
Check if a node is active.
Definition: impl-node.c:1994
void(* state_request)(void *data, enum pw_node_state state)
a new state is requested on the node
Definition: impl-node.h:80
const struct pw_node_info * pw_impl_node_get_info(struct pw_impl_node *node)
Get the node info.
Definition: impl-node.c:1174
static uint32_t int seq
Definition: core.h:325
int pw_impl_node_initialized(struct pw_impl_node *node)
Definition: impl-node.c:691
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:82
void(* info_changed)(void *data, const struct pw_node_info *info)
the node info changed
Definition: impl-node.h:72
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:1608
Definition: filter.c:76
void pw_impl_node_destroy(struct pw_impl_node *node)
Destroy a node.
#define pw_direction
Definition: port.h:47
int pw_impl_node_set_implementation(struct pw_impl_node *node, struct spa_node *spa_node)
Set the node implementation.
Definition: impl-node.c:1579
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
a result was received
Definition: impl-node.h:86
struct pw_global * pw_impl_node_get_global(struct pw_impl_node *node)
Get the global of this node.
Definition: impl-node.c:1192
Definition: filter.c:113
struct pw_context * pw_impl_node_get_context(struct pw_impl_node *node)
Get the context of this node.
Definition: impl-node.c:1186
A global object visible to remote clients.
int pw_impl_node_set_active(struct pw_impl_node *node, bool active)
Set a node active.
Definition: impl-node.c:1976
void(* active_changed)(void *data, bool active)
the node active state changed
Definition: impl-node.h:77
the PipeWire context
struct spa_node * pw_impl_node_get_implementation(struct pw_impl_node *node)
Get the node implementation.
Definition: impl-node.c:1602
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:92
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:1787
The port object.
void(* peer_removed)(void *data, struct pw_impl_node *peer)
a peer was removed
Definition: impl-node.h:97
const struct pw_properties * pw_impl_node_get_properties(struct pw_impl_node *node)
Get the node properties.
Definition: impl-node.c:1198
void(* initialized)(void *data)
the node is initialized
Definition: impl-node.h:62
void(* free)(void *data)
the node is about to be freed
Definition: impl-node.h:60
The node information.
Definition: node.h:62
void(* port_init)(void *data, struct pw_impl_port *port)
a port is being initialized on the node
Definition: impl-node.h:65
void(* port_removed)(void *data, struct pw_impl_port *port)
a port was removed
Definition: impl-node.h:69
Node events, listen to them with pw_impl_node_add_listener.
Definition: impl-node.h:53
void * pw_impl_node_get_user_data(struct pw_impl_node *node)
Get node user_data.
Definition: impl-node.c:1180
Definition: filter.c:71
int pw_impl_node_update_properties(struct pw_impl_node *node, const struct spa_dict *dict)
Update the node properties.
Definition: impl-node.c:1220
void(* destroy)(void *data)
the node is destroyed
Definition: impl-node.h:58