node.h
Go to the documentation of this file.
/* PipeWire
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PIPEWIRE_NODE_H__
#define __PIPEWIRE_NODE_H__
#ifdef __cplusplus
extern "C" {
#endif
#define PW_TYPE__Node PW_TYPE_OBJECT_BASE "Node"
#define PW_TYPE_NODE_BASE PW_TYPE__Node ":"
struct pw_node;
#include <pipewire/core.h>
#include <pipewire/global.h>
#include <pipewire/introspect.h>
#include <pipewire/port.h>
#include <pipewire/resource.h>
struct pw_node_events {
#define PW_VERSION_NODE_EVENTS 0
uint32_t version;
void (*destroy) (void *data);
void (*free) (void *data);
void (*initialized) (void *data);
void (*port_added) (void *data, struct pw_port *port);
void (*port_removed) (void *data, struct pw_port *port);
void (*info_changed) (void *data, struct pw_node_info *info);
void (*active_changed) (void *data, bool active);
void (*enabled_changed) (void *data, bool enabled);
void (*state_request) (void *data, enum pw_node_state state);
void (*state_changed) (void *data, enum pw_node_state old,
enum pw_node_state state, const char *error);
void (*async_complete) (void *data, uint32_t seq, int res);
void (*event) (void *data, const struct spa_event *event);
void (*need_input) (void *data);
void (*have_output) (void *data);
void (*reuse_buffer) (void *data, uint32_t port_id, uint32_t buffer_id);
};
#define PW_NODE_PROP_MEDIA "pipewire.media"
#define PW_NODE_PROP_CATEGORY "pipewire.category"
#define PW_NODE_PROP_ROLE "pipewire.role"
#define PW_NODE_PROP_EXCLUSIVE "pipewire.exclusive"
#define PW_NODE_PROP_AUTOCONNECT "pipewire.autoconnect"
#define PW_NODE_PROP_TARGET_NODE "pipewire.target.node"
struct pw_node *
pw_node_new(struct pw_core *core,
const char *name,
struct pw_properties *properties,
size_t user_data_size );
int pw_node_register(struct pw_node *node,
struct pw_client *owner,
struct pw_global *parent,
struct pw_properties *properties );
void pw_node_destroy(struct pw_node *node);
const struct pw_node_info *pw_node_get_info(struct pw_node *node);
void * pw_node_get_user_data(struct pw_node *node);
struct pw_core *pw_node_get_core(struct pw_node *node);
struct pw_global *pw_node_get_global(struct pw_node *node);
const struct pw_properties *pw_node_get_properties(struct pw_node *node);
int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict);
void pw_node_set_implementation(struct pw_node *node, struct spa_node *spa_node);
struct spa_node *pw_node_get_implementation(struct pw_node *node);
void pw_node_add_listener(struct pw_node *node,
struct spa_hook *listener,
const struct pw_node_events *events,
void *data);
int pw_node_for_each_port(struct pw_node *node,
enum pw_direction direction,
int (*callback) (void *data, struct pw_port *port),
void *data);
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);
struct pw_port *
pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id);
uint32_t pw_node_get_free_port_id(struct pw_node *node, enum pw_direction direction);
struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction direction);
int pw_node_set_active(struct pw_node *node, bool active);
bool pw_node_is_active(struct pw_node *node);
int pw_node_set_enabled(struct pw_node *node, bool enabled);
bool pw_node_is_enabled(struct pw_node *node);
#ifdef __cplusplus
}
#endif
#endif /* __PIPEWIRE_NODE_H__ */
pw_properties
A collection of key/value pairs.
Definition: properties.h:38
pw_node_events::state_request
void(* state_request)(void *data, enum pw_node_state state)
a new state is requested on the node
Definition: node.h:75
pw_node_events::port_removed
void(* port_removed)(void *data, struct pw_port *port)
a port was removed
Definition: node.h:65
pw_node_set_active
int pw_node_set_active(struct pw_node *node, bool active)
Set a node active.
Definition: node.c:963
pw_node_find_port
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
pw_node_events::info_changed
void(* info_changed)(void *data, struct pw_node_info *info)
the node info changed
Definition: node.h:68
pw_node_state
pw_node_state
The different node states.
Definition: introspect.h:33
pw_node_register
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
pw_node_is_active
bool pw_node_is_active(struct pw_node *node)
Check if a node is active.
Definition: node.c:982
introspect.h
pw_properties::dict
struct spa_dict dict
Definition: properties.h:39
pw_node_get_user_data
void * pw_node_get_user_data(struct pw_node *node)
Get node user_data.
Definition: node.c:463
pw_node_is_enabled
bool pw_node_is_enabled(struct pw_node *node)
Check if a node is enabled.
Definition: node.c:1009
core.h
pw_core
the core PipeWire object
global.h
pw_node_events::initialized
void(* initialized)(void *data)
the node is initialized
Definition: node.h:60
pw_node_info::state
enum pw_node_state state
the current state of the node
Definition: introspect.h:156
pw_node_events::need_input
void(* need_input)(void *data)
the node wants input
Definition: node.h:87
pw_node_events::event
void(* event)(void *data, const struct spa_event *event)
an event is emited
Definition: node.h:84
pw_node_update_properties
int pw_node_update_properties(struct pw_node *node, const struct spa_dict *dict)
Update the node properties.
Definition: node.c:487
pw_node_events::active_changed
void(* active_changed)(void *data, bool active)
the node active state changed
Definition: node.h:70
pw_node_new
SPA_EXPORT 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:399
pw_node_set_enabled
int pw_node_set_enabled(struct pw_node *node, bool enabled)
Set a node enabled.
Definition: node.c:988
pw_node_destroy
void pw_node_destroy(struct pw_node *node)
Destroy a node.
pw_node_for_each_param
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_get_free_port_id
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
pw_node_get_core
struct pw_core * pw_node_get_core(struct pw_node *node)
Get the core of this node.
Definition: node.c:469
pw_node_events::async_complete
void(* async_complete)(void *data, uint32_t seq, int res)
an async operation completed on the node
Definition: node.h:81
resource.h
pw_client
PipeWire client object class.
pw_node_events::have_output
void(* have_output)(void *data)
the node has output
Definition: node.h:89
pw_node_get_global
struct pw_global * pw_node_get_global(struct pw_node *node)
Get the global of this node.
Definition: node.c:475
pw_node_events::version
uint32_t version
Definition: node.h:53
pw_node_events::port_added
void(* port_added)(void *data, struct pw_port *port)
a port was added
Definition: node.h:63
pw_node_for_each_port
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
pw_node
PipeWire node class.
port.h
pw_node_events::free
void(* free)(void *data)
the node is about to be freed
Definition: node.h:58
pw_global
A global object visible to remote clients.
pw_node_set_implementation
void pw_node_set_implementation(struct pw_node *node, struct spa_node *spa_node)
Set the node implementation.
Definition: node.c:578
pw_node_get_info
const struct pw_node_info * pw_node_get_info(struct pw_node *node)
Get the node info.
Definition: node.c:457
pw_node_get_properties
const struct pw_properties * pw_node_get_properties(struct pw_node *node)
Get the node properties.
Definition: node.c:481
pw_node_get_free_port
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...
pw_node_events::state_changed
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
pw_node_add_listener
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_node_events::destroy
void(* destroy)(void *data)
the node is destroyed
Definition: node.h:56
pw_node_events::enabled_changed
void(* enabled_changed)(void *data, bool enabled)
the node enabled state changed
Definition: node.h:72
pw_port
The port object.
pw_node_events::reuse_buffer
void(* reuse_buffer)(void *data, uint32_t port_id, uint32_t buffer_id)
the node has a buffer to reuse
Definition: node.h:91
pw_node_info
The node information.
Definition: introspect.h:142
pw_node_get_implementation
struct spa_node * pw_node_get_implementation(struct pw_node *node)
Get the node implementation.
Definition: node.c:590
pw_direction
pw_direction
The direction of a port.
Definition: introspect.h:47
pw_node_events
Node events, listen to them with pw_node_add_listener.
Definition: node.h:51
pw_node_info::error
const char * error
an error reason if state is error
Definition: introspect.h:157