PipeWire  0.1.4
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 
51 #define PW_VERSION_NODE_IMPLEMENTATION 0
52  uint32_t version;
53 
54  int (*get_props) (void *data, struct spa_props **props);
55 
56  int (*set_props) (void *data, const struct spa_props *props);
57 
58  int (*send_command) (void *data,
59  const struct spa_command *command);
60 
61  struct pw_port* (*add_port) (void *data,
63  uint32_t port_id);
64 
65  int (*process_input) (void *data);
66 
67  int (*process_output) (void *data);
68 };
69 
70 
72 #define PW_VERSION_NODE_EVENTS 0
73  uint32_t version;
74 
76  void (*destroy) (void *data);
78  void (*free) (void *data);
80  void (*initialized) (void *data);
81 
83  void (*port_added) (void *data, struct pw_port *port);
85  void (*port_removed) (void *data, struct pw_port *port);
86 
88  void (*info_changed) (void *data, struct pw_node_info *info);
90  void (*state_request) (void *data, enum pw_node_state state);
92  void (*state_changed) (void *data, enum pw_node_state old,
93  enum pw_node_state state, const char *error);
94 
96  void (*async_complete) (void *data, uint32_t seq, int res);
97 
99  void (*event) (void *data, const struct spa_event *event);
100 
102  void (*need_input) (void *data);
104  void (*have_output) (void *data);
106  void (*reuse_buffer) (void *data, uint32_t port_id, uint32_t buffer_id);
107 };
108 
110 struct pw_node *
111 pw_node_new(struct pw_core *core,
112  struct pw_resource *owner,
113  struct pw_global *parent,
114  const char *name,
115  struct pw_properties *properties,
116  size_t user_data_size );
117 
119 void pw_node_register(struct pw_node *node);
120 
122 void pw_node_destroy(struct pw_node *node);
123 
124 void pw_node_set_max_ports(struct pw_node *node,
125  uint32_t max_input_ports,
126  uint32_t max_output_ports);
127 
128 const struct pw_node_info *pw_node_get_info(struct pw_node *node);
129 
130 void * pw_node_get_user_data(struct pw_node *node);
131 
132 struct pw_core *pw_node_get_core(struct pw_node *node);
133 
134 struct pw_resource *pw_node_get_owner(struct pw_node *node);
135 
136 struct pw_global *pw_node_get_global(struct pw_node *node);
137 
138 const struct pw_properties *pw_node_get_properties(struct pw_node *node);
139 
140 void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict);
141 
142 void pw_node_set_implementation(struct pw_node *node,
143  const struct pw_node_implementation *implementation,
144  void *data);
145 
146 void pw_node_add_listener(struct pw_node *node,
147  struct spa_hook *listener,
148  const struct pw_node_events *events,
149  void *data);
150 
151 struct spa_hook_list *pw_node_get_listeners(struct pw_node *node);
152 
154 bool pw_node_for_each_port(struct pw_node *node,
155  enum pw_direction direction,
156  bool (*callback) (void *data, struct pw_port *port),
157  void *data);
158 
159 
161 struct pw_port *
162 pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id);
163 
165 struct pw_port *
166 pw_node_get_free_port(struct pw_node *node, enum pw_direction direction);
167 
169 int pw_node_set_state(struct pw_node *node, enum pw_node_state state);
170 
172 void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *error);
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* __PIPEWIRE_NODE_H__ */
A collection of key/value pairs.
Definition: properties.h:38
void pw_node_set_max_ports(struct pw_node *node, uint32_t max_input_ports, uint32_t max_output_ports)
Definition: node.c:578
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:612
pw_node_state
The different node states.
Definition: introspect.h:33
struct pw_core * core
core object
Definition: private.h:206
struct spa_dict dict
Definition: properties.h:39
void * pw_node_get_user_data(struct pw_node *node)
Definition: node.c:445
int(* process_input)(void *data)
Definition: node.h:65
struct pw_properties * properties
properties of the node
Definition: private.h:211
enum pw_port_state state
state of the port
Definition: private.h:255
A global object visible to all clients.
Definition: private.h:87
Definition: node.h:50
Client owned objects.
Definition: private.h:284
enum pw_node_state state
the current state of the node
Definition: introspect.h:153
struct spa_graph_node node
Definition: private.h:240
int(* process_output)(void *data)
Definition: node.h:67
struct pw_node * pw_node_new(struct pw_core *core, struct pw_resource *owner, struct pw_global *parent, const char *name, struct pw_properties *properties, size_t user_data_size)
Definition: node.c:378
PipeWire node class.
Definition: private.h:205
void(* event)(void *data, const struct spa_event *event)
an event is emited
Definition: node.h:99
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:592
void pw_node_destroy(struct pw_node *node)
Destroy a node.
uint32_t port_id
port id
Definition: private.h:252
struct pw_core * pw_node_get_core(struct pw_node *node)
Definition: node.c:450
void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *error)
Update the state of the node, mostly used by node implementations.
int pw_node_set_state(struct pw_node *node, enum pw_node_state state)
Change the state of the node.
struct pw_global * pw_node_get_global(struct pw_node *node)
Definition: node.c:460
uint32_t version
Definition: node.h:73
int(* get_props)(void *data, struct spa_props **props)
Definition: node.h:54
int(* set_props)(void *data, const struct spa_props *props)
Definition: node.h:56
struct spa_hook_list * pw_node_get_listeners(struct pw_node *node)
Definition: node.c:505
enum pw_direction direction
port direction
Definition: private.h:251
struct spa_graph_port port
Definition: private.h:275
void pw_node_set_implementation(struct pw_node *node, const struct pw_node_implementation *implementation, void *data)
Definition: node.c:489
int(* send_command)(void *data, const struct spa_command *command)
Definition: node.h:58
const struct pw_node_info * pw_node_get_info(struct pw_node *node)
Definition: node.c:440
const struct pw_properties * pw_node_get_properties(struct pw_node *node)
Definition: node.c:465
struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction direction)
Get a free unused port from the node.
struct pw_resource * pw_node_get_owner(struct pw_node *node)
Definition: node.c:455
The port object.
Definition: private.h:246
void pw_node_add_listener(struct pw_node *node, struct spa_hook *listener, const struct pw_node_events *events, void *data)
Definition: node.c:497
The node information.
Definition: introspect.h:135
uint32_t version
Definition: node.h:52
void pw_node_register(struct pw_node *node)
Complete initialization of the node and register.
Definition: node.c:316
the core PipeWire object
Definition: private.h:103
pw_direction
The direction of a port.
Definition: introspect.h:47
Definition: node.h:71
struct pw_resource * owner
owner resource if any
Definition: private.h:210
const char * error
an error reason if state is error
Definition: introspect.h:154
void pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
Definition: node.c:470