PipeWire  0.2.7
link.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_LINK_H__
21 #define __PIPEWIRE_LINK_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
31 struct pw_link;
32 
33 #include <pipewire/core.h>
34 #include <pipewire/introspect.h>
35 #include <pipewire/port.h>
36 
37 #define PW_TYPE__Link PW_TYPE_OBJECT_BASE "Link"
38 #define PW_TYPE_LINK_BASE PW_TYPE__Link ":"
39 
53 #define PW_VERSION_LINK_EVENTS 0
54  uint32_t version;
55 
57  void (*destroy) (void *data);
58 
60  void (*free) (void *data);
61 
63  void (*info_changed) (void *data, const struct pw_link_info *info);
64 
67  void (*state_changed) (void *data, enum pw_link_state old,
68  enum pw_link_state state, const char *error);
69 
71  void (*port_unlinked) (void *data, struct pw_port *port);
72 };
73 
76 #define PW_LINK_PROP_PASSIVE "pipewire.link.passive"
77 
80 struct pw_link *
81 pw_link_new(struct pw_core *core,
82  struct pw_port *output,
83  struct pw_port *input,
84  struct spa_pod *format_filter,
85  struct pw_properties *properties ,
86  char **error,
87  size_t user_data_size );
88 
90 void pw_link_destroy(struct pw_link *link);
91 
93 void pw_link_add_listener(struct pw_link *link,
94  struct spa_hook *listener,
95  const struct pw_link_events *events,
96  void *data);
97 
99 int pw_link_register(struct pw_link *link,
100  struct pw_client *owner,
101  struct pw_global *parent,
102  struct pw_properties *properties );
103 
105 struct pw_core *pw_link_get_core(struct pw_link *link);
106 
109 void *pw_link_get_user_data(struct pw_link *link);
110 
112 const struct pw_link_info *pw_link_get_info(struct pw_link *link);
113 
115 struct pw_global *pw_link_get_global(struct pw_link *link);
116 
118 struct pw_port *pw_link_get_output(struct pw_link *link);
119 
121 struct pw_port *pw_link_get_input(struct pw_link *link);
122 
124 struct pw_link *pw_link_find(struct pw_port *output, struct pw_port *input);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* __PIPEWIRE_LINK_H__ */
pw_work_queue
PipeWire work queue object.
pw_global::pw_global_register
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
pw_port_use_buffers
int pw_port_use_buffers(struct pw_port *port, struct spa_buffer **buffers, uint32_t n_buffers)
Definition: port.c:696
pw_log::pw_log_level_enabled
#define pw_log_level_enabled(lev)
Check if a loglevel is enabled.
Definition: log.h:62
pw_type::param_buffers
struct spa_type_param_buffers param_buffers
Definition: type.h:77
pw_map::pw_map_remove
static void pw_map_remove(struct pw_map *map, uint32_t id)
Remove an item at index.
Definition: map.h:140
port.h
pw_work_queue::pw_work_queue_complete
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
introspect.h
PW_MEMBLOCK_FLAG_MAP_READWRITE
#define PW_MEMBLOCK_FLAG_MAP_READWRITE
Definition: mem.h:39
PW_DIRECTION_OUTPUT
@ PW_DIRECTION_OUTPUT
an output port direction
Definition: introspect.h:49
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:241
pw_node
PipeWire node class.
resource_data
Definition: factory.c:26
pw_client
PipeWire client object class.
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_memblock::pw_memblock_alloc
SPA_EXPORT int pw_memblock_alloc(enum pw_memblock_flags flags, size_t size, struct pw_memblock **mem)
Create a new memblock.
Definition: mem.c:154
interfaces.h
pw_memblock::size
size_t size
size of mapped memory
Definition: mem.h:48
resource_data::resource_listener
struct spa_hook resource_listener
Definition: factory.c:27
pw_work_queue::pw_work_queue_add
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
PW_NODE_STATE_IDLE
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: introspect.h:38
pw_port_events
Port events, use pw_port_add_listener.
Definition: port.h:60
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:59
PW_LINK_STATE_UNLINKED
@ PW_LINK_STATE_UNLINKED
the link is unlinked
Definition: introspect.h:58
PW_LINK_STATE_NEGOTIATING
@ PW_LINK_STATE_NEGOTIATING
the link is negotiating formats
Definition: introspect.h:60
impl
Definition: control.c:25
pw_type::map
struct spa_type_map * map
the type mapper
Definition: type.h:52
pw_global_add_listener
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_link_state
pw_link_state
The different link states.
Definition: introspect.h:56
work-queue.h
PW_PORT_STATE_ERROR
@ PW_PORT_STATE_ERROR
the port is in error
Definition: port.h:51
PW_LINK_STATE_ALLOCATING
@ PW_LINK_STATE_ALLOCATING
the link is allocating buffers
Definition: introspect.h:61
pw_work_queue::pw_work_queue_new
struct pw_work_queue * pw_work_queue_new(struct pw_loop *loop)
Create a new pw_work_queue.
Definition: work-queue.c:88
pw_global
A global object visible to remote clients.
pw_type
PipeWire type support struct.
Definition: type.h:51
pw_map::pw_map_insert_new
static uint32_t pw_map_insert_new(struct pw_map *map, void *data)
Insert data in the map.
Definition: map.h:92
pw_properties::dict
struct spa_dict dict
Definition: properties.h:39
PW_NODE_STATE_RUNNING
@ PW_NODE_STATE_RUNNING
the node is running
Definition: introspect.h:40
pw_utils::pw_spa_pod_copy
static struct spa_pod * pw_spa_pod_copy(const struct spa_pod *pod)
Copy a pod structure
Definition: utils.h:52
PW_MEMBLOCK_FLAG_SEAL
@ PW_MEMBLOCK_FLAG_SEAL
Definition: mem.h:33
pw_type::core
uint32_t core
Definition: type.h:54
PW_PORT_STATE_READY
@ PW_PORT_STATE_READY
the port is ready for buffer allocation
Definition: port.h:54
pw_global::pw_global_new
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
pw_node::pw_node_set_state
SPA_EXPORT int pw_node_set_state(struct pw_node *node, enum pw_node_state state)
Set th node state.
Definition: node.c:876
pw_properties::pw_properties_setf
SPA_EXPORT int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...)
Set a property value by format.
Definition: properties.c:338
PW_LINK_STATE_RUNNING
@ PW_LINK_STATE_RUNNING
the link is running
Definition: introspect.h:63
pw_log::pw_log_trace
void pw_log_trace(const char *format,...)
Log a trace message.
pw_port
The port object.
pw_resource_new
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
pw_memblock::fd
int fd
memfd if any
Definition: mem.h:45
pw_memblock::ptr
void * ptr
ptr to mapped memory
Definition: mem.h:47
pw_core::pw_core_find_format
int pw_core_find_format(struct pw_core *core, struct pw_port *output, struct pw_port *input, struct pw_properties *props, uint32_t n_format_filters, struct spa_pod **format_filters, struct spa_pod **format, struct spa_pod_builder *builder, char **error)
Find a common format between two ports.
Definition: core.c:755
pw_link_resource_info
#define pw_link_resource_info(r,...)
Definition: interfaces.h:721
PW_VERSION_RESOURCE_EVENTS
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:63
PW_PERM_IS_R
#define PW_PERM_IS_R(p)
Definition: core.h:82
pw_port_set_param
int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags, const struct spa_pod *param)
Definition: port.c:671
pw_work_queue::pw_work_queue_destroy
void pw_work_queue_destroy(struct pw_work_queue *queue)
Destroy a work queue.
Definition: work-queue.c:110
pw_resource_get_user_data
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
param_filter
Definition: port.c:633
pw_node_events
Node events, listen to them with pw_node_add_listener.
Definition: node.h:51
PW_LINK_STATE_PAUSED
@ PW_LINK_STATE_PAUSED
the link is paused
Definition: introspect.h:62
pw_type::param_meta
struct spa_type_param_meta param_meta
Definition: type.h:78
pw_global_get_permissions
uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_client *client)
Get the permissions of the global for a given client.
Definition: global.c:37
pw_memblock
Memory block structure.
Definition: mem.h:43
pw_core
the core PipeWire object
pw_resource
Client owned objects.
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:169
pw_port_alloc_buffers
int pw_port_alloc_buffers(struct pw_port *port, struct spa_pod **params, uint32_t n_params, struct spa_buffer **buffers, uint32_t *n_buffers)
Definition: port.c:727
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:60
pw_work_func_t
void(* pw_work_func_t)(void *obj, void *data, int res, uint32_t id)
Definition: work-queue.h:35
pw_properties::pw_properties_get
SPA_EXPORT const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:361
PW_PORT_STATE_PAUSED
@ PW_PORT_STATE_PAUSED
the port is paused
Definition: port.h:55
PW_MEMBLOCK_FLAG_WITH_FD
@ PW_MEMBLOCK_FLAG_WITH_FD
Definition: mem.h:32
pw_type::param
struct spa_type_param param
Definition: type.h:71
pw_type::link
uint32_t link
Definition: type.h:59
core.h
pw_core_resource_error
#define pw_core_resource_error(r,...)
Definition: interfaces.h:338
impl::this
struct pw_control this
Definition: control.c:26
PW_PORT_STATE_STREAMING
@ PW_PORT_STATE_STREAMING
the port is streaming
Definition: port.h:56
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:89
pw_log::pw_log_error
void pw_log_error(const char *format,...)
Log an error message.
pw_type::data
struct spa_type_data data
Definition: type.h:73
pw_node::pw_node_update_state
void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *error)
Update the node state.
Definition: node.c:928
pipewire.h
PW_LINK_STATE_ERROR
@ PW_LINK_STATE_ERROR
the link is in error
Definition: introspect.h:57
PW_VERSION_LINK
#define PW_VERSION_LINK
Definition: interfaces.h:694
pw_loop_invoke
#define pw_loop_invoke(l,...)
Definition: loop.h:52
PW_VERSION_NODE_EVENTS
#define PW_VERSION_NODE_EVENTS
Definition: node.h:52
pw_resource_events
Resource events.
Definition: resource.h:62
PW_LINK_CHANGE_MASK_FORMAT
#define PW_LINK_CHANGE_MASK_FORMAT
Definition: introspect.h:208
PW_NODE_STATE_ERROR
@ PW_NODE_STATE_ERROR
error state
Definition: introspect.h:34
pw_resource_add_listener
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
pw_resource_events::version
uint32_t version
Definition: resource.h:64
pw_log::pw_log_warn
void pw_log_warn(const char *format,...)
Log a warning message.
PW_VERSION_PORT_EVENTS
#define PW_VERSION_PORT_EVENTS
Definition: control.h:50
pw_port_add_listener
void pw_port_add_listener(struct pw_port *port, struct spa_hook *listener, const struct pw_port_events *events, void *data)
Add an event listener on the port.
Definition: port.c:284
pw_log::pw_log_debug
void pw_log_debug(const char *format,...)
Log a debug message.
PW_LINK_STATE_INIT
@ PW_LINK_STATE_INIT
the link is initialized
Definition: introspect.h:59
PW_NODE_STATE_SUSPENDED
@ PW_NODE_STATE_SUSPENDED
the node is suspended, the device might be closed
Definition: introspect.h:36
PW_PORT_STATE_CONFIGURE
@ PW_PORT_STATE_CONFIGURE
the port is ready for format negotiation
Definition: port.h:53
pw_properties
A collection of key/value pairs.
Definition: properties.h:38
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:245