PipeWire: impl-link.h Source File

PipeWire 0.3.6

impl-link.h
Go to the documentation of this file.
1 /* PipeWire
2 *
3 * Copyright © 2018 Wim Taymans
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #ifndef PIPEWIRE_IMPL_LINK_H
26 #define PIPEWIRE_IMPL_LINK_H
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
36 struct pw_impl_link;
37 struct pw_impl_port;
38
39 #include <pipewire/impl.h>
40
53 struct pw_impl_link_events {
54 #define PW_VERSION_IMPL_LINK_EVENTS 0
55 uint32_t version;
56
58 void (*destroy) (void *data);
59
61 void (*free) (void *data);
62
64 void (*initialized) (void *data);
65
67 void (*info_changed) (void *data, const struct pw_link_info *info);
68
71 void (*state_changed) (void *data, enum pw_link_state old,
72 enum pw_link_state state, const char *error);
73
75 void (*port_unlinked) (void *data, struct pw_impl_port *port);
76 };
77
78
81 struct pw_impl_link *
82 pw_context_create_link(struct pw_context *context,
83 struct pw_impl_port *output,
84 struct pw_impl_port *input,
85 struct spa_pod *format_filter,
86 struct pw_properties *properties ,
87 size_t user_data_size );
88
90 void pw_impl_link_destroy(struct pw_impl_link *link);
91
93 void pw_impl_link_add_listener(struct pw_impl_link *link,
94 struct spa_hook *listener,
95 const struct pw_impl_link_events *events,
96 void *data);
97
99 int pw_impl_link_register(struct pw_impl_link *link,
100 struct pw_properties *properties );
101
103 struct pw_context *pw_impl_link_get_context(struct pw_impl_link *link);
104
107 void *pw_impl_link_get_user_data(struct pw_impl_link *link);
108
110 const struct pw_link_info *pw_impl_link_get_info(struct pw_impl_link *link);
111
113 struct pw_global *pw_impl_link_get_global(struct pw_impl_link *link);
114
116 struct pw_impl_port *pw_impl_link_get_output(struct pw_impl_link *link);
117
119 struct pw_impl_port *pw_impl_link_get_input(struct pw_impl_link *link);
120
122 struct pw_impl_link *pw_impl_link_find(struct pw_impl_port *output, struct pw_impl_port *input);
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif /* PIPEWIRE_IMPL_LINK_H */
PW_IMPL_PORT_STATE_READY
@ PW_IMPL_PORT_STATE_READY
the port is ready for buffer allocation
Definition: impl-port.h:54
res
static uint32_t int int res
Definition: core.h:323
pw_work_queue
PW_LINK_CHANGE_MASK_STATE
#define PW_LINK_CHANGE_MASK_STATE
Definition: link.h:61
pw_impl_port_state
pw_impl_port_state
Definition: impl-port.h:50
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:243
pw_log::pw_log_error
#define pw_log_error(...)
control
Definition: stream.c:80
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:367
PW_KEY_OBJECT_ID
#define PW_KEY_OBJECT_ID
a global object id
Definition: keys.h:70
PW_KEY_LINK_INPUT_PORT
#define PW_KEY_LINK_INPUT_PORT
input port id of a link
Definition: keys.h:160
pw_impl_link_get_context
SPA_EXPORT struct pw_context * pw_impl_link_get_context(struct pw_impl_link *link)
Get the context of a link.
Definition: impl-link.c:1277
pw_impl_link_events::initialized
void(* initialized)(void *data)
a Link is initialized
Definition: impl-link.h:64
data
Definition: filter.c:70
pw_impl_port_use_buffers
SPA_EXPORT int pw_impl_port_use_buffers(struct pw_impl_port *port, struct pw_impl_port_mix *mix, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers)
Definition: impl-port.c:1242
pw_control
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:163
pw_impl_link_events
link events added with pw_impl_link_add_listener
Definition: impl-link.h:53
pw_impl_link_add_listener
void pw_impl_link_add_listener(struct pw_impl_link *link, struct spa_hook *listener, const struct pw_impl_link_events *events, void *data)
Add an event listener to link.
Definition: impl-link.c:1256
pw_link_info::error
const char * error
an error reason if state is error
Definition: link.h:67
pw_impl_port_events
Port events, use pw_impl_port_add_listener.
Definition: impl-port.h:59
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:65
pw_impl_client
PipeWire client object class.
pw_impl_link_events::free
void(* free)(void *data)
A link is freed.
Definition: impl-link.h:61
pw_introspect::pw_direction_as_string
const char * pw_direction_as_string(enum pw_direction direction)
Convert a pw_direction to a readable string.
Definition: introspect.c:52
pw_link_resource_info
#define pw_link_resource_info(r,...)
Definition: impl-link.c:44
impl
Definition: control.c:33
pw_buffers_negotiate
int pw_buffers_negotiate(struct pw_context *context, uint32_t flags, struct spa_node *outnode, uint32_t out_port_id, struct spa_node *innode, uint32_t in_port_id, struct pw_buffers *result)
Definition: buffers.c:237
PW_KEY_FACTORY_ID
#define PW_KEY_FACTORY_ID
Factory properties.
Definition: keys.h:215
pw_global_get_permissions
uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_impl_client *client)
Get the permissions of the global for a given client.
Definition: global.c:45
PW_KEY_MODULE_ID
#define PW_KEY_MODULE_ID
module properties
Definition: keys.h:205
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:252
pw_impl_link_register
int pw_impl_link_register(struct pw_impl_link *link, struct pw_properties *properties)
Finish link configuration and register.
Definition: impl-link.c:1148
pw_impl_link_events::port_unlinked
void(* port_unlinked)(void *data, struct pw_impl_port *port)
A port is unlinked.
Definition: impl-link.h:75
pw_impl_link_get_global
struct pw_global * pw_impl_link_get_global(struct pw_impl_link *link)
Get the global of the link.
Definition: impl-link.c:1295
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:98
pw_global
A global object visible to remote clients.
pw_impl_link_get_info
SPA_EXPORT const struct pw_link_info * pw_impl_link_get_info(struct pw_impl_link *link)
Get the link info.
Definition: impl-link.c:1289
PW_DIRECTION_INPUT
#define PW_DIRECTION_INPUT
Definition: port.h:48
impl.h
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
PW_VERSION_IMPL_PORT_EVENTS
#define PW_VERSION_IMPL_PORT_EVENTS
Definition: impl-port.h:60
pw_log::pw_log_info
#define pw_log_info(...)
PW_KEY_CLIENT_ID
#define PW_KEY_CLIENT_ID
Client properties.
Definition: keys.h:118
pw_impl_link_events::version
uint32_t version
Definition: impl-link.h:55
pw_impl_link::pw_impl_link_destroy
void pw_impl_link_destroy(struct pw_impl_link *link)
Destroy a link.
Definition: impl-link.c:1215
port::port
struct pw_port * port
Definition: filter.c:91
pw_impl_node
pw_impl_node_add_listener
void pw_impl_node_add_listener(struct pw_impl_node *node, struct spa_hook *listener, const struct pw_impl_node_events *events, void *data)
Add an event listener.
Definition: impl-node.c:1543
PW_LINK_STATE_UNLINKED
@ PW_LINK_STATE_UNLINKED
the link is unlinked
Definition: link.h:45
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:433
pw_link_state
pw_link_state
Definition: link.h:43
NAME
#define NAME
Definition: impl-link.c:42
PW_KEY_OBJECT_PATH
#define PW_KEY_OBJECT_PATH
unique path to construct the object
Definition: keys.h:69
pw_impl_link_get_context
struct pw_context * pw_impl_link_get_context(struct pw_impl_link *link)
Get the context of a link.
Definition: impl-link.c:1277
port
Definition: buffers.c:44
pw_impl_link_events::destroy
void(* destroy)(void *data)
A link is destroyed.
Definition: impl-link.h:58
pw_link_info::state
enum pw_link_state state
the current state of the link
Definition: link.h:66
pw_impl_port_update_state
void pw_impl_port_update_state(struct pw_impl_port *port, enum pw_impl_port_state state, char *error)
Definition: impl-port.c:97
PW_VERSION_IMPL_NODE_EVENTS
#define PW_VERSION_IMPL_NODE_EVENTS
Definition: impl-node.h:54
pw_log::pw_log_debug
#define pw_log_debug(...)
pw_log::pw_log_warn
#define pw_log_warn(...)
pw_impl_link_get_user_data
void * pw_impl_link_get_user_data(struct pw_impl_link *link)
Get the user_data of a link, the size of the memory is given when constructing the link.
Definition: impl-link.c:1283
PW_BUFFERS_FLAG_SHARED
#define PW_BUFFERS_FLAG_SHARED
buffers can be shared
Definition: buffers.h:39
pw_impl_node_events
Node events, listen to them with pw_impl_node_add_listener.
Definition: impl-node.h:53
PW_LINK_STATE_NEGOTIATING
@ PW_LINK_STATE_NEGOTIATING
the link is negotiating formats
Definition: link.h:47
pw_control_add_link
SPA_EXPORT int pw_control_add_link(struct pw_control *control, uint32_t cmix, struct pw_control *other, uint32_t omix, struct pw_control_link *link)
Definition: control.c:164
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:133
buffer
Definition: filter.c:55
pw_impl_port_add_listener
void pw_impl_port_add_listener(struct pw_impl_port *port, struct spa_hook *listener, const struct pw_impl_port_events *events, void *data)
Add an event listener on the port.
Definition: impl-port.c:601
pw_global_add_resource
int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource)
Add a resource to a global.
Definition: global.c:227
PW_KEY_LINK_OUTPUT_PORT
#define PW_KEY_LINK_OUTPUT_PORT
output port id of a link
Definition: keys.h:162
pw_impl_link_add_listener
SPA_EXPORT void pw_impl_link_add_listener(struct pw_impl_link *link, struct spa_hook *listener, const struct pw_impl_link_events *events, void *data)
Add an event listener to link.
Definition: impl-link.c:1256
port::port_id
uint32_t port_id
Definition: buffers.c:47
pw_buffers_clear
void pw_buffers_clear(struct pw_buffers *buffers)
Definition: buffers.c:355
pw_context
the PipeWire context
pw_impl_link::pw_impl_link_find
struct pw_impl_link * pw_impl_link_find(struct pw_impl_port *output, struct pw_impl_port *input)
Find the link between 2 ports.
Definition: impl-link.c:1265
PW_LINK_STATE_ALLOCATING
@ PW_LINK_STATE_ALLOCATING
the link is allocating buffers
Definition: link.h:48
pw_global_update_permissions
int pw_global_update_permissions(struct pw_global *global, struct pw_impl_client *client, uint32_t old_permissions, uint32_t new_permissions)
Definition: global.c:311
pw_impl_link_get_output
SPA_EXPORT struct pw_impl_port * pw_impl_link_get_output(struct pw_impl_link *link)
Get the output port of the link.
Definition: impl-link.c:1301
pw_resource
Client owned objects.
pw_impl_port_release_mix
SPA_EXPORT int pw_impl_port_release_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix)
Definition: impl-port.c:235
PW_NODE_STATE_SUSPENDED
@ PW_NODE_STATE_SUSPENDED
the node is suspended, the device might be closed
Definition: node.h:51
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:66
pw_log::pw_log_trace
#define pw_log_trace(...)
pw_impl_link_register
SPA_EXPORT int pw_impl_link_register(struct pw_impl_link *link, struct pw_properties *properties)
Finish link configuration and register.
Definition: impl-link.c:1148
PW_IMPL_PORT_STATE_ERROR
@ PW_IMPL_PORT_STATE_ERROR
the port is in error
Definition: impl-port.h:51
PW_LINK_CHANGE_MASK_FORMAT
#define PW_LINK_CHANGE_MASK_FORMAT
Definition: link.h:62
pw_node_state_as_string
SPA_EXPORT const char * pw_node_state_as_string(enum pw_node_state state)
Definition: introspect.c:34
pw_work_func_t
void(* pw_work_func_t)(void *obj, void *data, int res, uint32_t id)
Definition: work-queue.h:40
impl-link.h
pw_impl_link_events::info_changed
void(* info_changed)(void *data, const struct pw_link_info *info)
The info changed on a link.
Definition: impl-link.h:67
PW_TYPE_INTERFACE_Link
#define PW_TYPE_INTERFACE_Link
Definition: link.h:37
PW_BUFFERS_FLAG_NO_MEM
#define PW_BUFFERS_FLAG_NO_MEM
don't allocate buffer memory
Definition: buffers.h:38
pw_resource_new
struct pw_resource * pw_resource_new(struct pw_impl_client *client, uint32_t id, uint32_t permissions, const char *type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:43
pw_link_info
The link information.
Definition: link.h:55
pw_global::pw_global_new
SPA_EXPORT struct pw_global * pw_global_new(struct pw_context *context, const char *type, uint32_t version, struct pw_properties *properties, pw_global_bind_func_t func, void *object)
Create a new global.
Definition: global.c:67
impl::this
struct pw_control this
Definition: control.c:34
pw_impl_link_activate
int pw_impl_link_activate(struct pw_impl_link *this)
Definition: impl-link.c:518
PW_LINK_STATE_INIT
@ PW_LINK_STATE_INIT
the link is initialized
Definition: link.h:46
pw_impl_link_get_input
SPA_EXPORT struct pw_impl_port * pw_impl_link_get_input(struct pw_impl_link *link)
Get the input port of the link.
Definition: impl-link.c:1307
pw_impl_link_prepare
int pw_impl_link_prepare(struct pw_impl_link *this)
Definition: impl-link.c:678
PW_IMPL_PORT_STATE_PAUSED
@ PW_IMPL_PORT_STATE_PAUSED
the port is paused
Definition: impl-port.h:55
pw_impl_link_get_info
const struct pw_link_info * pw_impl_link_get_info(struct pw_impl_link *link)
Get the link info.
Definition: impl-link.c:1289
pw_impl_link_events::state_changed
void(* state_changed)(void *data, enum pw_link_state old, enum pw_link_state state, const char *error)
The link state changed, error is only valid when the state is in error.
Definition: impl-link.h:71
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:98
seq
static uint32_t int seq
Definition: core.h:322
pw_control_remove_link
SPA_EXPORT int pw_control_remove_link(struct pw_control_link *link)
Definition: control.c:235
pw_impl_port_init_mix
SPA_EXPORT int pw_impl_port_init_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix)
Definition: impl-port.c:190
pw_impl_link
pw_impl_link_get_output
struct pw_impl_port * pw_impl_link_get_output(struct pw_impl_link *link)
Get the output port of the link.
Definition: impl-link.c:1301
PW_DIRECTION_OUTPUT
#define PW_DIRECTION_OUTPUT
Definition: port.h:49
pw_global::pw_global_register
SPA_EXPORT int pw_global_register(struct pw_global *global)
register a global to the context registry
Definition: global.c:128
pw_loop_invoke
#define pw_loop_invoke(l,...)
Definition: loop.h:57
PW_NODE_STATE_ERROR
@ PW_NODE_STATE_ERROR
error state
Definition: node.h:49
pw_impl_link_deactivate
int pw_impl_link_deactivate(struct pw_impl_link *this)
Definition: impl-link.c:721
PW_LINK_STATE_ERROR
@ PW_LINK_STATE_ERROR
the link is in error
Definition: link.h:44
PW_LINK_STATE_PAUSED
@ PW_LINK_STATE_PAUSED
the link is paused
Definition: link.h:49
PW_NODE_STATE_IDLE
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: node.h:53
PW_VERSION_LINK
#define PW_VERSION_LINK
Definition: link.h:39
port::direction
enum spa_direction direction
Definition: buffers.c:46
pw_impl_link_get_user_data
SPA_EXPORT void * pw_impl_link_get_user_data(struct pw_impl_link *link)
Get the user_data of a link, the size of the memory is given when constructing the link.
Definition: impl-link.c:1283
pw_impl_link::pw_context_create_link
struct pw_impl_link * pw_context_create_link(struct pw_context *context, struct pw_impl_port *output, struct pw_impl_port *input, struct spa_pod *format_filter, struct pw_properties *properties, size_t user_data_size)
Make a new link between two ports.
Definition: impl-link.c:988
pw_impl_port_set_param
SPA_EXPORT int pw_impl_port_set_param(struct pw_impl_port *port, uint32_t id, uint32_t flags, const struct spa_pod *param)
Definition: impl-port.c:1135
pw_impl_port
pw_link_state_as_string
SPA_EXPORT const char * pw_link_state_as_string(enum pw_link_state state)
Definition: introspect.c:66
pw_impl_node::pw_impl_node_set_state
SPA_EXPORT int pw_impl_node_set_state(struct pw_impl_node *node, enum pw_node_state state)
Set the node state.
Definition: impl-node.c:1847
pw_impl_link_get_global
SPA_EXPORT struct pw_global * pw_impl_link_get_global(struct pw_impl_link *link)
Get the global of the link.
Definition: impl-link.c:1295
pw_properties::pw_properties_update_keys
SPA_EXPORT int pw_properties_update_keys(struct pw_properties *props, const struct spa_dict *dict, const char *keys[])
Copy multiple keys from one property to another.
Definition: properties.c:220
pw_properties
A collection of key/value pairs.
Definition: properties.h:45
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:335
pw_impl_link_get_input
struct pw_impl_port * pw_impl_link_get_input(struct pw_impl_link *link)
Get the input port of the link.
Definition: impl-link.c:1307
PW_IMPL_PORT_STATE_CONFIGURE
@ PW_IMPL_PORT_STATE_CONFIGURE
the port is ready for format negotiation
Definition: impl-port.h:53