PipeWire  0.1.6
node.h
Go to the documentation of this file.
1 /* PipeWire
2  * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __PIPEWIRE_NODE_H__
21 #define __PIPEWIRE_NODE_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define PW_TYPE__Node PW_TYPE_OBJECT_BASE "Node"
28 #define PW_TYPE_NODE_BASE PW_TYPE__Node ":"
29 
42 struct pw_node;
43 
44 #include <pipewire/core.h>
45 #include <pipewire/global.h>
46 #include <pipewire/introspect.h>
47 #include <pipewire/port.h>
48 #include <pipewire/resource.h>
49 
52 #define PW_VERSION_NODE_EVENTS 0
53  uint32_t version;
54 
56  void (*destroy) (void *data);
58  void (*free) (void *data);
60  void (*initialized) (void *data);
61 
63  void (*port_added) (void *data, struct pw_port *port);
65  void (*port_removed) (void *data, struct pw_port *port);
66 
68  void (*info_changed) (void *data, struct pw_node_info *info);
70  void (*active_changed) (void *data, bool active);
71 
73  void (*state_request) (void *data, enum pw_node_state state);
75  void (*state_changed) (void *data, enum pw_node_state old,
76  enum pw_node_state state, const char *error);
77 
79  void (*async_complete) (void *data, uint32_t seq, int res);
80 
82  void (*event) (void *data, const struct spa_event *event);
83 
85  void (*need_input) (void *data);
87  void (*have_output) (void *data);
89  void (*reuse_buffer) (void *data, uint32_t port_id, uint32_t buffer_id);
90 };
91 
93 #define PW_NODE_PROP_AUTOCONNECT "pipewire.autoconnect"
94 
95 #define PW_NODE_PROP_TARGET_NODE "pipewire.target.node"
96 
98 struct pw_node *
99 pw_node_new(struct pw_core *core,
100  const char *name,
101  struct pw_properties *properties,
102  size_t user_data_size );
103 
105 void pw_node_register(struct pw_node *node,
106  struct pw_client *owner,
107  struct pw_global *parent );
108 
110 void pw_node_destroy(struct pw_node *node);
111 
113 const struct pw_node_info *pw_node_get_info(struct pw_node *node);
114 
116 void * pw_node_get_user_data(struct pw_node *node);
117 
119 struct pw_core *pw_node_get_core(struct pw_node *node);
120 
122 struct pw_global *pw_node_get_global(struct pw_node *node);
123 
125 const struct pw_properties *pw_node_get_properties(struct pw_node *node);
126 
128 void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict);
129 
131 void pw_node_set_implementation(struct pw_node *node, struct spa_node *spa_node);
133 struct spa_node *pw_node_get_implementation(struct pw_node *node);
134 
136 void pw_node_add_listener(struct pw_node *node,
137  struct spa_hook *listener,
138  const struct pw_node_events *events,
139  void *data);
140 
142 bool pw_node_for_each_port(struct pw_node *node,
143  enum pw_direction direction,
144  bool (*callback) (void *data, struct pw_port *port),
145  void *data);
146 
147 
149 struct pw_port *
150 pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id);
151 
153 uint32_t pw_node_get_free_port_id(struct pw_node *node, enum pw_direction direction);
154 
157 struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction direction);
158 
161 bool pw_node_set_active(struct pw_node *node, bool active);
162 
164 bool pw_node_is_active(struct pw_node *node);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* __PIPEWIRE_NODE_H__ */
A collection of key/value pairs.
Definition: properties.h:38
void(* state_request)(void *data, enum pw_node_state state)
a new state is requested on the node
Definition: node.h:73
void(* port_removed)(void *data, struct pw_port *port)
a port was removed
Definition: node.h:65
struct pw_port * pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id)
Find the port with direction and port_id or NULL when not found.
Definition: node.c:630
void(* info_changed)(void *data, struct pw_node_info *info)
the node info changed
Definition: node.h:68
pw_node_state
The different node states.
Definition: introspect.h:33
bool pw_node_is_active(struct pw_node *node)
Check is a node is active.
Definition: node.c:872
struct spa_dict dict
Definition: properties.h:39
void * pw_node_get_user_data(struct pw_node *node)
Get node user_data.
Definition: node.c:416
struct pw_node * pw_node_new(struct pw_core *core, const char *name, struct pw_properties *properties, size_t user_data_size)
Definition: node.c:357
the core PipeWire object
bool pw_node_set_active(struct pw_node *node, bool active)
Set a node active.
Definition: node.c:856
void(* initialized)(void *data)
the node is initialized
Definition: node.h:60
enum pw_node_state state
the current state of the node
Definition: introspect.h:161
void(* need_input)(void *data)
the node wants input
Definition: node.h:85
void(* event)(void *data, const struct spa_event *event)
an event is emited
Definition: node.h:82
void(* active_changed)(void *data, bool active)
the node active state changed
Definition: node.h:70
bool pw_node_for_each_port(struct pw_node *node, enum pw_direction direction, bool(*callback)(void *data, struct pw_port *port), void *data)
iterate the ports in the given direction
Definition: node.c:610
void pw_node_destroy(struct pw_node *node)
Destroy a node.
uint32_t pw_node_get_free_port_id(struct pw_node *node, enum pw_direction direction)
Get a free unused port_id from the node.
Definition: node.c:642
struct pw_core * pw_node_get_core(struct pw_node *node)
Get the core of this node.
Definition: node.c:421
void(* async_complete)(void *data, uint32_t seq, int res)
an async operation completed on the node
Definition: node.h:79
void pw_node_register(struct pw_node *node, struct pw_client *owner, struct pw_global *parent)
Complete initialization of the node and register.
Definition: node.c:333
PipeWire client object class.
void(* have_output)(void *data)
the node has output
Definition: node.h:87
struct pw_global * pw_node_get_global(struct pw_node *node)
Get the global of this node.
Definition: node.c:426
uint32_t version
Definition: node.h:53
void(* port_added)(void *data, struct pw_port *port)
a port was added
Definition: node.h:63
PipeWire node class.
void(* free)(void *data)
the node is about to be freed
Definition: node.h:58
A global object visible to remote clients.
void pw_node_set_implementation(struct pw_node *node, struct spa_node *spa_node)
Set the node implementation.
Definition: node.c:518
const struct pw_node_info * pw_node_get_info(struct pw_node *node)
Get the node info.
Definition: node.c:411
const struct pw_properties * pw_node_get_properties(struct pw_node *node)
Get the node properties.
Definition: node.c:431
struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction direction)
Get a free unused port from the node, this can be an old unused existing port or a new port...
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: node.h:75
void pw_node_add_listener(struct pw_node *node, struct spa_hook *listener, const struct pw_node_events *events, void *data)
Add an event listener.
Definition: node.c:534
void(* destroy)(void *data)
the node is destroyed
Definition: node.h:56
The port object.
void(* reuse_buffer)(void *data, uint32_t port_id, uint32_t buffer_id)
the node has a buffer to reuse
Definition: node.h:89
The node information.
Definition: introspect.h:142
struct spa_node * pw_node_get_implementation(struct pw_node *node)
Get the node implementation.
Definition: node.c:529
pw_direction
The direction of a port.
Definition: introspect.h:47
Node events, listen to them with pw_node_add_listener.
Definition: node.h:51
const char * error
an error reason if state is error
Definition: introspect.h:162
void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
Update the node properties.
Definition: node.c:436