PipeWire  0.3.33
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 
41 struct pw_impl_link;
42 struct pw_impl_port;
43 
44 #include <pipewire/impl.h>
45 
48 #define PW_VERSION_IMPL_LINK_EVENTS 0
49  uint32_t version;
50 
52  void (*destroy) (void *data);
53 
55  void (*free) (void *data);
56 
58  void (*initialized) (void *data);
59 
61  void (*info_changed) (void *data, const struct pw_link_info *info);
62 
65  void (*state_changed) (void *data, enum pw_link_state old,
66  enum pw_link_state state, const char *error);
67 
69  void (*port_unlinked) (void *data, struct pw_impl_port *port);
70 };
71 
72 
75 struct pw_impl_link *
76 pw_context_create_link(struct pw_context *context,
77  struct pw_impl_port *output,
78  struct pw_impl_port *input,
79  struct spa_pod *format_filter,
80  struct pw_properties *properties ,
81  size_t user_data_size );
82 
84 void pw_impl_link_destroy(struct pw_impl_link *link);
85 
87 void pw_impl_link_add_listener(struct pw_impl_link *link,
88  struct spa_hook *listener,
89  const struct pw_impl_link_events *events,
90  void *data);
91 
93 int pw_impl_link_register(struct pw_impl_link *link,
94  struct pw_properties *properties );
95 
97 struct pw_context *pw_impl_link_get_context(struct pw_impl_link *link);
98 
101 void *pw_impl_link_get_user_data(struct pw_impl_link *link);
102 
104 const struct pw_link_info *pw_impl_link_get_info(struct pw_impl_link *link);
105 
107 struct pw_global *pw_impl_link_get_global(struct pw_impl_link *link);
108 
110 struct pw_impl_port *pw_impl_link_get_output(struct pw_impl_link *link);
111 
113 struct pw_impl_port *pw_impl_link_get_input(struct pw_impl_link *link);
114 
116 struct pw_impl_link *pw_impl_link_find(struct pw_impl_port *output, struct pw_impl_port *input);
117 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* PIPEWIRE_IMPL_LINK_H */
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:314
PW_IMPL_PORT_STATE_INIT
@ PW_IMPL_PORT_STATE_INIT
the port is being created
Definition: impl-port.h:51
PW_DIRECTION_INPUT
#define PW_DIRECTION_INPUT
Definition: port.h:57
pw_properties_get
int int const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:487
pw_work_queue_destroy
void pw_work_queue_destroy(struct pw_work_queue *queue)
Destroy a work queue.
Definition: work-queue.c:132
pw_impl_port_state
pw_impl_port_state
Definition: impl-port.h:49
pw_context_find_format
int pw_context_find_format(struct pw_context *context, struct pw_impl_port *output, struct pw_impl_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: context.c:800
pw_work_func_t
void(* pw_work_func_t)(void *obj, void *data, int res, uint32_t id)
Definition: work-queue.h:43
control
Definition: stream.c:86
PW_KEY_OBJECT_ID
#define PW_KEY_OBJECT_ID
a global object id
Definition: src/pipewire/keys.h:66
pw_control_remove_link
int pw_control_remove_link(struct pw_control_link *link)
Definition: control.c:237
pw_impl_port_set_param
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:1365
pw_global_register
int pw_global_register(struct pw_global *global)
Register a global object to the context registry.
Definition: global.c:125
PW_KEY_MODULE_ID
#define PW_KEY_MODULE_ID
module properties
Definition: src/pipewire/keys.h:249
name
const char * name
Definition: media-session.c:2379
string.h
pw_context_recalc_graph
int pw_context_recalc_graph(struct pw_context *context, const char *reason)
Definition: context.c:1092
SPA_PARAM_Latency
@ SPA_PARAM_Latency
latency reporting, a SPA_TYPE_OBJECT_ParamLatency
Definition: param.h:59
data
user data to add to an object
Definition: filter.c:75
pw_global_new
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 object.
Definition: global.c:66
impl::data
uint8_t data[MAX_BUFFER]
Definition: module-profiler.c:87
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:230
PW_KEY_OBJECT_PATH
#define PW_KEY_OBJECT_PATH
object properties
Definition: src/pipewire/keys.h:65
spa_list_for_each
#define spa_list_for_each(pos, head, member)
Definition: list.h:111
pw_node_state_as_string
const char * pw_node_state_as_string(enum pw_node_state state)
Convert a pw_node_state to a readable string.
Definition: introspect.c:34
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_impl_port_events
Port events, use pw_impl_port_add_listener.
Definition: impl-port.h:58
spa_aprintf
#define spa_aprintf(_fmt,...)
Definition: defs.h:323
SPA_EXPORT
#define SPA_EXPORT
Definition: defs.h:208
PW_NODE_STATE_IDLE
@ PW_NODE_STATE_IDLE
the node is running but there is no active port
Definition: src/pipewire/node.h:61
SPA_DIRECTION_INPUT
@ SPA_DIRECTION_INPUT
Definition: defs.h:79
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:68
impl::seq
int seq
Definition: policy-ep.c:65
pw_log_trace
#define pw_log_trace(...)
Definition: src/pipewire/log.h:90
PW_KEY_LINK_FEEDBACK
#define PW_KEY_LINK_FEEDBACK
indicate that a link is a feedback link and the target will receive data in the next cycle
Definition: src/pipewire/keys.h:205
pw_impl_port_recalc_latency
int pw_impl_port_recalc_latency(struct pw_impl_port *port)
Definition: impl-port.c:1301
impl::listener
struct spa_hook listener
Definition: access-flatpak.c:46
compare.h
impl
Definition: control.c:33
PW_NODE_STATE_ERROR
@ PW_NODE_STATE_ERROR
error state
Definition: src/pipewire/node.h:57
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:247
spa_node_port_enum_params_sync
int spa_node_port_enum_params_sync(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t *index, const struct spa_pod *filter, struct spa_pod **param, struct spa_pod_builder *builder)
Definition: build-12683127/doc/spa/node/utils.h:92
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:238
pw_impl_port_use_buffers
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:1485
spa_hook_list_append
void spa_hook_list_append(struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
Append a hook.
Definition: hook.h:316
SPA_PTROFF
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
port::node
struct spa_node * node
Definition: buffers.c:45
PW_IMPL_PORT_STATE_ERROR
@ PW_IMPL_PORT_STATE_ERROR
the port is in error
Definition: impl-port.h:50
SPA_POD_OBJECT_ID
#define SPA_POD_OBJECT_ID(obj)
Definition: pod/pod.h:167
SPA_RESULT_IS_ERROR
#define SPA_RESULT_IS_ERROR(res)
Definition: result.h:45
pw_control_add_link
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:166
SPA_POD_BUILDER_INIT
#define SPA_POD_BUILDER_INIT(buffer, size)
Definition: builder.h:71
impl::info
struct spa_audio_info_raw info
Definition: module-echo-cancel.c:145
pod.h
spa_pod_builder::data
void * data
Definition: builder.h:64
impl.h
spa_loop
Definition: build-12683127/doc/spa/support/loop.h:44
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:50
PW_VERSION_IMPL_PORT_EVENTS
#define PW_VERSION_IMPL_PORT_EVENTS
Definition: impl-port.h:59
SPA_CONTAINER_OF
#define SPA_CONTAINER_OF(p, t, m)
Definition: defs.h:170
SPA_PARAM_Format
@ SPA_PARAM_Format
configured format as SPA_TYPE_OBJECT_Format
Definition: param.h:48
pw_context_debug_port_params
int pw_context_debug_port_params(struct pw_context *this, struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t id, int err, const char *debug,...)
Definition: context.c:745
spa_io_buffers
IO area to exchange buffers.
Definition: io.h:93
port::port
struct pw_port * port
Definition: filter.c:96
spa_pod_copy
struct spa_pod * spa_pod_copy(const struct spa_pod *pod)
Copy a pod structure.
Definition: builder.h:676
PW_KEY_LINK_INPUT_NODE
#define PW_KEY_LINK_INPUT_NODE
input node id of a link
Definition: src/pipewire/keys.h:198
spa_pod
Definition: pod/pod.h:50
SPA_IO_Buffers
@ SPA_IO_Buffers
area to exchange buffers, struct spa_io_buffers
Definition: io.h:53
pw_impl_node_set_state
int pw_impl_node_set_state(struct pw_impl_node *node, enum pw_node_state state)
Set the node state.
Definition: impl-node.c:2057
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:255
spa_node_port_set_io
#define spa_node_port_set_io(n,...)
Definition: build-12683127/doc/spa/node/node.h:660
PW_DIRECTION_OUTPUT
#define PW_DIRECTION_OUTPUT
Definition: port.h:58
spa_pod_fixate
int spa_pod_fixate(struct spa_pod *pod)
Definition: iter.h:442
spa_list_remove
void spa_list_remove(struct spa_list *elem)
Definition: list.h:69
port
Definition: buffers.c:44
SPA_FLAG_SET
#define SPA_FLAG_SET(field, flag)
Definition: defs.h:74
PW_KEY_LINK_INPUT_PORT
#define PW_KEY_LINK_INPUT_PORT
input port id of a link
Definition: src/pipewire/keys.h:199
SPA_RESULT_IS_OK
#define SPA_RESULT_IS_OK(res)
Definition: result.h:44
PW_KEY_FACTORY_ID
#define PW_KEY_FACTORY_ID
Factory properties.
Definition: src/pipewire/keys.h:259
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:295
PW_VERSION_IMPL_NODE_EVENTS
#define PW_VERSION_IMPL_NODE_EVENTS
Definition: impl-node.h:52
param.h
impl::loop
struct pw_loop * loop
Definition: module-protocol-simple.c:86
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:51
format.h
spa_pod_compare
int spa_pod_compare(const struct spa_pod *pod1, const struct spa_pod *pod2)
Definition: compare.h:99
SPA_LOG_LEVEL_DEBUG
@ SPA_LOG_LEVEL_DEBUG
Definition: build-12683127/doc/spa/support/log.h:51
SPA_FLAG_IS_SET
#define SPA_FLAG_IS_SET(field, flag)
Definition: defs.h:73
buffer
Definition: filter.c:59
PW_KEY_LINK_OUTPUT_PORT
#define PW_KEY_LINK_OUTPUT_PORT
output port id of a link
Definition: src/pipewire/keys.h:201
spa_pod_builder_init
void spa_pod_builder_init(struct spa_pod_builder *builder, void *data, uint32_t size)
Definition: builder.h:96
SPA_RESULT_IS_ASYNC
#define SPA_RESULT_IS_ASYNC(res)
Definition: result.h:46
SPA_DIRECTION_OUTPUT
@ SPA_DIRECTION_OUTPUT
Definition: defs.h:80
pw_impl_port_init_mix
int pw_impl_port_init_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix)
Definition: impl-port.c:207
PW_NODE_STATE_SUSPENDED
@ PW_NODE_STATE_SUSPENDED
the node is suspended, the device might be closed
Definition: src/pipewire/node.h:59
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:691
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:356
SPA_RESULT_ASYNC_SEQ
#define SPA_RESULT_ASYNC_SEQ(res)
Definition: result.h:48
SPA_LOG_LEVEL_ERROR
@ SPA_LOG_LEVEL_ERROR
Definition: build-12683127/doc/spa/support/log.h:48
pw_global_update_keys
int pw_global_update_keys(struct pw_global *global, const struct spa_dict *dict, const char *const keys[])
Update the global properties, must be done when unregistered.
Definition: global.c:209
SPA_PARAM_EnumFormat
@ SPA_PARAM_EnumFormat
available formats as SPA_TYPE_OBJECT_Format
Definition: param.h:47
node.h
spa_strerror
#define spa_strerror(err)
Definition: result.h:51
impl::work
struct pw_work_queue * work
Definition: module-echo-cancel.c:136
utils.h
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_impl_port_update_state
void pw_impl_port_update_state(struct pw_impl_port *port, enum pw_impl_port_state state, int res, char *error)
Definition: impl-port.c:106
PW_IMPL_PORT_STATE_CONFIGURE
@ PW_IMPL_PORT_STATE_CONFIGURE
the port is ready for format negotiation
Definition: impl-port.h:52
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:162
pw_log_debug
#define pw_log_debug(...)
Definition: src/pipewire/log.h:89
client
Definition: module-protocol-native.c:103
spa_type_io
const struct spa_type_info spa_type_io[]
Definition: node/type-info.h:46
PW_KEY_LINK_OUTPUT_NODE
#define PW_KEY_LINK_OUTPUT_NODE
output node id of a link
Definition: src/pipewire/keys.h:200
SPA_FALLTHROUGH
#define SPA_FALLTHROUGH
SPA_FALLTHROUGH is an annotation to suppress compiler warnings about switch cases that fall through w...
Definition: defs.h:69
spa_node_sync
#define spa_node_sync(n,...)
Definition: build-12683127/doc/spa/node/node.h:650
pw_global_destroy
void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:369
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:69
SPA_ID_INVALID
#define SPA_ID_INVALID
Definition: defs.h:182
pw_properties_set
int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:435
PW_KEY_CLIENT_ID
#define PW_KEY_CLIENT_ID
Client properties.
Definition: src/pipewire/keys.h:131
parser.h
pw_resource_error
void pw_resource_error(struct pw_resource *resource, int res, const char *error)
Generate an error for a resource.
Definition: resource.c:255
pw_log_warn
#define pw_log_warn(...)
Definition: src/pipewire/log.h:87
PW_BUFFERS_FLAG_NO_MEM
#define PW_BUFFERS_FLAG_NO_MEM
don't allocate buffer memory
Definition: buffers.h:38
impl::properties
struct pw_properties * properties
Definition: module-access.c:141
pw_impl_port_release_mix
int pw_impl_port_release_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix)
Definition: impl-port.c:252
impl::this
struct pw_control this
Definition: control.c:34
pw_loop_invoke
#define pw_loop_invoke(l,...)
Definition: src/pipewire/loop.h:63
spa_type_param
const struct spa_type_info spa_type_param[]
Definition: param/type-info.h:46
spa_hook_remove
void spa_hook_remove(struct spa_hook *hook)
Remove a hook.
Definition: hook.h:336
pw_log_info
#define pw_log_info(...)
Definition: src/pipewire/log.h:88
PW_IMPL_PORT_STATE_PAUSED
@ PW_IMPL_PORT_STATE_PAUSED
the port is paused
Definition: impl-port.h:54
pw_work_queue_new
struct pw_work_queue * pw_work_queue_new(struct pw_loop *loop)
Create a new PipeWire Work Queue Object.
Definition: work-queue.c:98
SPA_PORT_FLAG_CAN_ALLOC_BUFFERS
#define SPA_PORT_FLAG_CAN_ALLOC_BUFFERS
the port can allocate buffer data
Definition: build-12683127/doc/spa/node/node.h:103
PW_KEY_LINK_PASSIVE
#define PW_KEY_LINK_PASSIVE
indicate that a link is passive and does not cause the graph to be runnable.
Definition: src/pipewire/keys.h:202
spa_hook_list_init
void spa_hook_list_init(struct spa_hook_list *list)
Initialize a hook list to the empty list.
Definition: hook.h:305
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:1692
spa_pod_builder::size
uint32_t size
Definition: builder.h:65
pw_work_queue_cancel
int pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
Cancel a work item.
Definition: work-queue.c:216
SPA_NODE_BUFFERS_FLAG_ALLOC
#define SPA_NODE_BUFFERS_FLAG_ALLOC
flags to pass to the use_buffers functions
Definition: build-12683127/doc/spa/node/node.h:256
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
SPA_IO_BUFFERS_INIT
#define SPA_IO_BUFFERS_INIT
Definition: io.h:103
SPA_PORT_FLAG_LIVE
#define SPA_PORT_FLAG_LIVE
output buffers from this port are timestamped against a live clock.
Definition: build-12683127/doc/spa/node/node.h:110
pw_properties_new
struct pw_properties * pw_properties_new(const char *key,...) 1
Make a new properties object.
Definition: properties.c:98
pw_properties_setf
int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...) 1(3
spa_pod_builder
Definition: builder.h:63
port::direction
enum spa_direction direction
Definition: buffers.c:46
port::id
uint32_t id
Definition: filter.c:94
pw_properties
Definition: properties.h:49
spa_hook_list_clean
void spa_hook_list_clean(struct spa_hook_list *list)
Remove all hooks from the list.
Definition: hook.h:344
pw_properties_free
void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:364
pw_log_error
#define pw_log_error(...)
Definition: src/pipewire/log.h:86
spa_debug_type_find_name
const char * spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
Definition: types.h:68
PW_IMPL_PORT_STATE_READY
@ PW_IMPL_PORT_STATE_READY
the port is ready for buffer allocation
Definition: impl-port.h:53
spa_list_append
#define spa_list_append(list, item)
Definition: list.h:81