PipeWire: pipewire/impl-port.h Source File

PipeWire 0.3.50

impl-port.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_PORT_H
26#define PIPEWIRE_IMPL_PORT_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <spa/utils/hook.h>
33
43struct pw_impl_port;
44struct pw_impl_link;
45struct pw_control;
46
47#include <pipewire/impl.h>
48
49enum pw_impl_port_state {
50 PW_IMPL_PORT_STATE_ERROR = -1,
51 PW_IMPL_PORT_STATE_INIT = 0,
52 PW_IMPL_PORT_STATE_CONFIGURE = 1,
53 PW_IMPL_PORT_STATE_READY = 2,
54 PW_IMPL_PORT_STATE_PAUSED = 3,
55};
56
58 struct pw_impl_port_events {
59#define PW_VERSION_IMPL_PORT_EVENTS 2
60 uint32_t version;
61
63 void (*destroy) (void *data);
64
66 void (*free) (void *data);
67
69 void (*initialized) (void *data);
70
72 void (*info_changed) (void *data, const struct pw_port_info *info);
73
75 void (*link_added) (void *data, struct pw_impl_link *link);
76
78 void (*link_removed) (void *data, struct pw_impl_link *link);
79
81 void (*state_changed) (void *data, enum pw_impl_port_state old,
82 enum pw_impl_port_state state, const char *error);
83
85 void (*control_added) (void *data, struct pw_control *control);
86
88 void (*control_removed) (void *data, struct pw_control *control);
89
91 void (*param_changed) (void *data, uint32_t id);
92
94 void (*latency_changed) (void *data);
95};
96
99 struct pw_impl_port *
100 pw_context_create_port(struct pw_context *context,
101 enum pw_direction direction,
102 uint32_t port_id,
103 const struct spa_port_info *info,
104 size_t user_data_size);
105
107enum pw_direction pw_impl_port_get_direction(struct pw_impl_port *port);
108
110const struct pw_properties *pw_impl_port_get_properties(struct pw_impl_port *port);
111
113int pw_impl_port_update_properties(struct pw_impl_port *port, const struct spa_dict *dict);
114
116const struct pw_port_info *pw_impl_port_get_info(struct pw_impl_port *port);
117
119uint32_t pw_impl_port_get_id(struct pw_impl_port *port);
120
122struct pw_impl_node *pw_impl_port_get_node(struct pw_impl_port *port);
123
125int pw_impl_port_is_linked(struct pw_impl_port *port);
126
128int pw_impl_port_add(struct pw_impl_port *port, struct pw_impl_node *node);
129
131void pw_impl_port_add_listener(struct pw_impl_port *port,
132 struct spa_hook *listener,
133 const struct pw_impl_port_events *events,
134 void *data);
135
140#ifdef __cplusplus
141}
142#endif
143
144#endif /* PIPEWIRE_IMPL_PORT_H */
pw_context_create_port
struct pw_impl_port * pw_context_create_port(struct pw_context *context, enum pw_direction direction, uint32_t port_id, const struct spa_port_info *info, size_t user_data_size)
Create a new port.
Definition: impl-port.c:458
pw_impl_port_update_properties
int pw_impl_port_update_properties(struct pw_impl_port *port, const struct spa_dict *dict)
Update the port properties.
Definition: impl-port.c:696
pw_impl_port_state
pw_impl_port_state
Definition: impl-port.h:56
pw_impl_port_is_linked
int pw_impl_port_is_linked(struct pw_impl_port *port)
check is a port has links, return 0 if not, 1 if it is linked
Definition: impl-port.c:1398
pw_impl_port_get_properties
const struct pw_properties * pw_impl_port_get_properties(struct pw_impl_port *port)
Get the port properties.
Definition: impl-port.c:690
pw_impl_port_add
int pw_impl_port_add(struct pw_impl_port *port, struct pw_impl_node *node)
Add a port to a node.
Definition: impl-port.c:954
pw_impl_port_get_node
struct pw_impl_node * pw_impl_port_get_node(struct pw_impl_port *port)
Get the port parent node or NULL when not yet set.
Definition: impl-port.c:710
pw_impl_port_get_direction
enum pw_direction pw_impl_port_get_direction(struct pw_impl_port *port)
Get the port direction.
Definition: impl-port.c:678
pw_impl_port_get_id
uint32_t pw_impl_port_get_id(struct pw_impl_port *port)
Get the port id.
Definition: impl-port.c:684
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:716
pw_impl_port_get_info
const struct pw_port_info * pw_impl_port_get_info(struct pw_impl_port *port)
Get the port info.
Definition: impl-port.c:725
PW_IMPL_PORT_STATE_READY
@ PW_IMPL_PORT_STATE_READY
the port is ready for buffer allocation
Definition: impl-port.h:60
PW_IMPL_PORT_STATE_ERROR
@ PW_IMPL_PORT_STATE_ERROR
the port is in error
Definition: impl-port.h:57
PW_IMPL_PORT_STATE_INIT
@ PW_IMPL_PORT_STATE_INIT
the port is being created
Definition: impl-port.h:58
PW_IMPL_PORT_STATE_PAUSED
@ PW_IMPL_PORT_STATE_PAUSED
the port is paused
Definition: impl-port.h:61
PW_IMPL_PORT_STATE_CONFIGURE
@ PW_IMPL_PORT_STATE_CONFIGURE
the port is ready for format negotiation
Definition: impl-port.h:59
pw_direction
#define pw_direction
The direction of a port.
Definition: port.h:63
hook.h
spa/utils/hook.h
impl.h
pipewire/impl.h
pw_context
pw_control
pw_impl_link
pw_impl_node
pw_impl_port_events
Port events, use pw_impl_port_add_listener.
Definition: impl-port.h:65
pw_impl_port_events::control_added
void(* control_added)(void *data, struct pw_control *control)
a control was added to the port
Definition: impl-port.h:93
pw_impl_port_events::destroy
void(* destroy)(void *data)
The port is destroyed.
Definition: impl-port.h:71
pw_impl_port_events::info_changed
void(* info_changed)(void *data, const struct pw_port_info *info)
the port info changed
Definition: impl-port.h:80
pw_impl_port_events::free
void(* free)(void *data)
The port is freed.
Definition: impl-port.h:74
pw_impl_port_events::link_added
void(* link_added)(void *data, struct pw_impl_link *link)
a new link is added on this port
Definition: impl-port.h:83
pw_impl_port_events::latency_changed
void(* latency_changed)(void *data)
latency changed.
Definition: impl-port.h:102
pw_impl_port_events::state_changed
void(* state_changed)(void *data, enum pw_impl_port_state old, enum pw_impl_port_state state, const char *error)
the state of the port changed
Definition: impl-port.h:89
pw_impl_port_events::version
uint32_t version
Definition: impl-port.h:68
pw_impl_port_events::param_changed
void(* param_changed)(void *data, uint32_t id)
a parameter changed, since version 1
Definition: impl-port.h:99
pw_impl_port_events::initialized
void(* initialized)(void *data)
The port is initialized.
Definition: impl-port.h:77
pw_impl_port_events::control_removed
void(* control_removed)(void *data, struct pw_control *control)
a control was removed from the port
Definition: impl-port.h:96
pw_impl_port_events::link_removed
void(* link_removed)(void *data, struct pw_impl_link *link)
a link is removed from this port
Definition: impl-port.h:86
pw_impl_port
Definition: impl.h:47
pw_port_info
Definition: port.h:72
pw_properties
Definition: properties.h:53
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:54
spa_dict
Definition: dict.h:59
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351
spa_port_info
Port information structure.
Definition: node.h:113