Go to the documentation of this file.
20 #ifndef __PIPEWIRE_NODE_H__
21 #define __PIPEWIRE_NODE_H__
27 #define PW_TYPE__Node PW_TYPE_OBJECT_BASE "Node"
28 #define PW_TYPE_NODE_BASE PW_TYPE__Node ":"
52 #define PW_VERSION_NODE_EVENTS 0
84 void (*
event) (
void *data,
const struct spa_event *
event);
91 void (*
reuse_buffer) (
void *data, uint32_t port_id, uint32_t buffer_id);
95 #define PW_NODE_PROP_MEDIA "pipewire.media"
97 #define PW_NODE_PROP_CATEGORY "pipewire.category"
100 #define PW_NODE_PROP_ROLE "pipewire.role"
102 #define PW_NODE_PROP_EXCLUSIVE "pipewire.exclusive"
104 #define PW_NODE_PROP_AUTOCONNECT "pipewire.autoconnect"
106 #define PW_NODE_PROP_TARGET_NODE "pipewire.target.node"
113 size_t user_data_size );
149 struct spa_hook *listener,
159 int (*callback) (
void *data,
struct pw_port *port),
164 uint32_t index, uint32_t max,
165 const struct spa_pod *filter,
166 int (*callback) (
void *data,
167 uint32_t
id, uint32_t index, uint32_t next,
168 struct spa_pod *param),
PipeWire work queue object.
SPA_EXPORT int pw_global_register(struct pw_global *global, struct pw_client *owner, struct pw_global *parent)
register a global to the core registry
Definition: global.c:102
int pw_link_deactivate(struct pw_link *this)
Definition: link.c:967
#define PW_VERSION_NODE
Definition: interfaces.h:487
@ PW_NODE_STATE_CREATING
the node is being created
Definition: introspect.h:35
static void * pw_map_lookup(struct pw_map *map, uint32_t id)
Find an item in the map.
Definition: map.h:152
int pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq, int res)
Complete a work item.
Definition: work-queue.c:220
const struct pw_properties * pw_node_get_properties(struct pw_node *node)
Get the node properties.
Definition: node.c:481
void(* port_removed)(void *data, struct pw_port *port)
a port was removed
Definition: node.h:65
@ PW_DIRECTION_OUTPUT
an output port direction
Definition: introspect.h:49
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:742
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:241
static void pw_map_init(struct pw_map *map, size_t size, size_t extend)
Initialize a map.
Definition: map.h:70
PipeWire client object class.
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:596
@ PW_DIRECTION_INPUT
an input port direction
Definition: introspect.h:48
struct spa_hook resource_listener
Definition: factory.c:27
uint32_t pw_work_queue_add(struct pw_work_queue *queue, void *obj, int res, pw_work_func_t func, void *data)
Add an item to the work queue.
Definition: work-queue.c:140
SPA_EXPORT void pw_node_destroy(struct pw_node *node)
Destroy a node.
Definition: node.c:626
struct spa_node * pw_node_get_implementation(struct pw_node *node)
Get the node implementation.
Definition: node.c:590
SPA_EXPORT void * pw_node_get_user_data(struct pw_node *node)
Get node user_data.
Definition: node.c:463
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: introspect.h:38
int pw_node_set_enabled(struct pw_node *node, bool enabled)
Set a node enabled.
Definition: node.c:988
#define PW_NODE_CHANGE_MASK_PROPS
Definition: introspect.h:148
SPA_EXPORT int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
Update the node properties.
Definition: node.c:487
Global events, use pw_global_add_listener.
Definition: global.h:59
void pw_resource_set_implementation(struct pw_resource *resource, const void *implementation, void *data)
Set the resource implementation.
Definition: resource.c:128
SPA_EXPORT struct pw_core * pw_node_get_core(struct pw_node *node)
Get the core of this node.
Definition: node.c:469
const char * pw_direction_as_string(enum pw_direction direction)
Convert a pw_direction to a readable string.
Definition: introspect.c:45
void(* info_changed)(void *data, struct pw_node_info *info)
the node info changed
Definition: node.h:68
void(* initialized)(void *data)
the node is initialized
Definition: node.h:60
#define pw_map_get_size(m)
Definition: map.h:51
void pw_global_add_listener(struct pw_global *global, struct spa_hook *listener, const struct pw_global_events *events, void *data)
Add an event listener on the global.
Definition: global.c:190
pw_direction
The direction of a port.
Definition: introspect.h:47
struct pw_work_queue * pw_work_queue_new(struct pw_loop *loop)
Create a new pw_work_queue.
Definition: work-queue.c:88
A global object visible to remote clients.
static uint32_t pw_map_insert_new(struct pw_map *map, void *data)
Insert data in the map.
Definition: map.h:92
int pw_link_activate(struct pw_link *this)
Definition: link.c:937
struct spa_dict dict
Definition: properties.h:39
SPA_EXPORT int pw_node_for_each_param(struct pw_node *node, uint32_t param_id, uint32_t index, uint32_t max, const struct spa_pod *filter, int(*callback)(void *data, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param), void *data)
Definition: node.c:696
@ PW_NODE_STATE_RUNNING
the node is running
Definition: introspect.h:40
void(* event)(void *data, const struct spa_event *event)
an event is emited
Definition: node.h:84
struct pw_global * pw_node_get_global(struct pw_node *node)
Get the global of this node.
Definition: node.c:475
bool pw_node_is_enabled(struct pw_node *node)
Check if a node is enabled.
Definition: node.c:1009
SPA_EXPORT struct pw_global * pw_global_new(struct pw_core *core, uint32_t type, uint32_t version, struct pw_properties *properties, void *object)
Create a new global.
Definition: global.c:61
SPA_EXPORT int pw_node_set_state(struct pw_node *node, enum pw_node_state state)
Set th node state.
Definition: node.c:876
int pw_port_register(struct pw_port *port, struct pw_client *owner, struct pw_global *parent, struct pw_properties *properties)
Definition: port.c:402
int pw_node_set_active(struct pw_node *node, bool active)
Set a node active.
Definition: node.c:963
bool pw_node_is_active(struct pw_node *node)
Check if a node is active.
Definition: node.c:982
SPA_EXPORT struct pw_global * pw_node_get_global(struct pw_node *node)
Get the global of this node.
Definition: node.c:475
void pw_log_trace(const char *format,...)
Log a trace message.
const char * pw_node_state_as_string(enum pw_node_state state)
Convert a pw_node_state to a readable string.
Definition: introspect.c:27
struct pw_resource * pw_resource_new(struct pw_client *client, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:34
void * pw_node_get_user_data(struct pw_node *node)
Get node user_data.
Definition: node.c:463
void(* active_changed)(void *data, bool active)
the node active state changed
Definition: node.h:70
const struct pw_node_info * pw_node_get_info(struct pw_node *node)
Get the node info.
Definition: node.c:457
SPA_EXPORT int pw_node_register(struct pw_node *this, struct pw_client *owner, struct pw_global *parent, struct pw_properties *properties)
Complete initialization of the node and register.
Definition: node.c:329
SPA_EXPORT bool pw_node_is_active(struct pw_node *node)
Check if a node is active.
Definition: node.c:982
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:63
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:742
int pw_node_for_each_port(struct pw_node *node, enum pw_direction direction, int(*callback)(void *data, struct pw_port *port), void *data)
Iterate the ports in the given direction.
Definition: node.c:675
void(* need_input)(void *data)
the node wants input
Definition: node.h:87
int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags, const struct spa_pod *param)
Definition: port.c:671
SPA_EXPORT bool pw_node_is_enabled(struct pw_node *node)
Check if a node is enabled.
Definition: node.c:1009
void pw_work_queue_destroy(struct pw_work_queue *queue)
Destroy a work queue.
Definition: work-queue.c:110
void * pw_resource_get_user_data(struct pw_resource *resource)
Get the user data for the resource, the size was given in pw_resource_new.
Definition: resource.c:113
#define PW_NODE_CHANGE_MASK_OUTPUT_PORTS
Definition: introspect.h:146
#define PW_VERSION_NODE_PROXY_METHODS
Definition: interfaces.h:535
int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
Update the node properties.
Definition: node.c:487
static void pw_map_clear(struct pw_map *map)
Clear a map.
Definition: map.h:81
Node events, listen to them with pw_node_add_listener.
Definition: node.h:51
int pw_node_for_each_param(struct pw_node *node, uint32_t param_id, uint32_t index, uint32_t max, const struct spa_pod *filter, int(*callback)(void *data, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param), void *data)
Definition: node.c:696
void pw_port_destroy(struct pw_port *port)
Definition: port.c:546
void(* async_complete)(void *data, uint32_t seq, int res)
an async operation completed on the node
Definition: node.h:81
void(* have_output)(void *data)
the node has output
Definition: node.h:89
struct pw_core * pw_node_get_core(struct pw_node *node)
Get the core of this node.
Definition: node.c:469
void(* free)(void *data)
the node is about to be freed
Definition: node.h:58
SPA_EXPORT struct pw_properties * pw_properties_copy(const struct pw_properties *properties)
Copy a properties object.
Definition: properties.c:183
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:308
struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction direction)
pw_node_get_free_port:
Definition: node.c:760
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:169
void(* port_added)(void *data, struct pw_port *port)
a port was added
Definition: node.h:63
int pw_port_add(struct pw_port *port, struct pw_node *node)
Definition: port.c:422
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:60
uint32_t version
Definition: interfaces.h:536
void(* pw_work_func_t)(void *obj, void *data, int res, uint32_t id)
Definition: work-queue.h:35
struct pw_port * pw_port_new(enum pw_direction direction, uint32_t port_id, struct pw_properties *properties, size_t user_data_size)
Definition: port.c:163
SPA_EXPORT const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:361
int pw_node_register(struct pw_node *node, struct pw_client *owner, struct pw_global *parent, struct pw_properties *properties)
Complete initialization of the node and register.
Definition: node.c:329
void(* enabled_changed)(void *data, bool enabled)
the node enabled state changed
Definition: node.h:72
int pw_node_for_each_port(struct pw_node *node, enum pw_direction direction, int(*callback)(void *data, struct pw_port *port), void *data)
Iterate the ports in the given direction.
Definition: node.c:675
SPA_EXPORT 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:596
int pw_node_update_ports(struct pw_node *node)
Definition: node.c:191
enum pw_node_state state
the current state of the node
Definition: introspect.h:156
uint32_t version
Definition: node.h:53
#define pw_core_resource_error(r,...)
Definition: interfaces.h:338
struct pw_control this
Definition: control.c:26
A map.
Definition: map.h:44
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:730
#define PW_NODE_CHANGE_MASK_INPUT_PORTS
Definition: introspect.h:145
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:89
SPA_EXPORT const struct pw_properties * pw_node_get_properties(struct pw_node *node)
Get the node properties.
Definition: node.c:481
void pw_log_error(const char *format,...)
Log an error message.
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:730
SPA_EXPORT void pw_node_set_implementation(struct pw_node *node, struct spa_node *spa_node)
Set the node implementation.
Definition: node.c:578
void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *error)
Update the node state.
Definition: node.c:928
const char * error
an error reason if state is error
Definition: introspect.h:157
void pw_port_unlink(struct pw_port *port)
Definition: port.c:491
#define pw_loop_invoke(l,...)
Definition: loop.h:52
#define PW_NODE_CHANGE_MASK_STATE
Definition: introspect.h:147
SPA_EXPORT const struct pw_node_info * pw_node_get_info(struct pw_node *node)
Get the node info.
Definition: node.c:457
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:77
void(* state_request)(void *data, enum pw_node_state state)
a new state is requested on the node
Definition: node.h:75
SPA_EXPORT int pw_node_set_enabled(struct pw_node *node, bool enabled)
Set a node enabled.
Definition: node.c:988
Resource events.
Definition: resource.h:62
pw_node_state
The different node states.
Definition: introspect.h:33
void(* destroy)(void *data)
the node is destroyed
Definition: node.h:56
@ PW_NODE_STATE_ERROR
error state
Definition: introspect.h:34
void pw_node_set_implementation(struct pw_node *node, struct spa_node *spa_node)
Set the node implementation.
Definition: node.c:578
The node information.
Definition: introspect.h:142
void pw_resource_add_listener(struct pw_resource *resource, struct spa_hook *listener, const struct pw_resource_events *events, void *data)
Add an event listener.
Definition: resource.c:119
struct pw_node * pw_node_new(struct pw_core *core, const char *name, struct pw_properties *properties, size_t user_data_size)
Create a new node.
Definition: node.c:399
SPA_EXPORT int pw_node_set_active(struct pw_node *node, bool active)
Set a node active.
Definition: node.c:963
Node methods.
Definition: interfaces.h:534
void pw_log_warn(const char *format,...)
Log a warning message.
void pw_log_debug(const char *format,...)
Log a debug message.
#define pw_node_resource_param(r,...)
Definition: interfaces.h:528
@ PW_NODE_STATE_SUSPENDED
the node is suspended, the device might be closed
Definition: introspect.h:36
@ PW_PORT_STATE_CONFIGURE
the port is ready for format negotiation
Definition: port.h:53
void(* reuse_buffer)(void *data, uint32_t port_id, uint32_t buffer_id)
the node has a buffer to reuse
Definition: node.h:91
SPA_EXPORT struct spa_node * pw_node_get_implementation(struct pw_node *node)
Get the node implementation.
Definition: node.c:590
A collection of key/value pairs.
Definition: properties.h:38
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:245
#define pw_node_resource_info(r,...)
Definition: interfaces.h:527