PipeWire  0.2.7
port.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_PORT_H__
21 #define __PIPEWIRE_PORT_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define PW_TYPE__Port "PipeWire:Object:Port"
28 #define PW_TYPE_PORT_BASE PW_TYPE__Port ":"
29 
30 #include <spa/utils/hook.h>
31 
42 struct pw_port;
43 struct pw_link;
44 struct pw_control;
45 
46 #include <pipewire/core.h>
47 #include <pipewire/introspect.h>
48 #include <pipewire/node.h>
49 
57 };
58 
61 #define PW_VERSION_PORT_EVENTS 0
62  uint32_t version;
63 
65  void (*destroy) (void *data);
66 
68  void (*free) (void *data);
69 
71  void (*info_changed) (void *data, struct pw_port_info *info);
72 
74  void (*link_added) (void *data, struct pw_link *link);
75 
77  void (*link_removed) (void *data, struct pw_link *link);
78 
80  void (*state_changed) (void *data, enum pw_port_state state);
81 
83  void (*control_added) (void *data, struct pw_control *control);
84 
86  void (*control_removed) (void *data, struct pw_control *control);
87 };
88 
90 enum pw_direction pw_port_get_direction(struct pw_port *port);
91 
93 const struct pw_properties *pw_port_get_properties(struct pw_port *port);
94 
96 int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict);
97 
99 uint32_t pw_port_get_id(struct pw_port *port);
100 
102 struct pw_node *pw_port_get_node(struct pw_port *port);
103 
105 void pw_port_add_listener(struct pw_port *port,
106  struct spa_hook *listener,
107  const struct pw_port_events *events,
108  void *data);
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* __PIPEWIRE_PORT_H__ */
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_get_node
SPA_EXPORT struct pw_node * pw_port_get_node(struct pw_port *port)
Get the port parent node or NULL when not yet set.
Definition: port.c:278
pw_port_get_properties
const struct pw_properties * pw_port_get_properties(struct pw_port *port)
Get the port properties.
Definition: port.c:246
pw_port_events::link_removed
void(* link_removed)(void *data, struct pw_link *link)
a link is removed from this port
Definition: port.h:77
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_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
introspect.h
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_map::pw_map_init
static void pw_map_init(struct pw_map *map, size_t size, size_t extend)
Initialize a map.
Definition: map.h:70
pw_node
PipeWire node class.
resource_data
Definition: factory.c:26
pw_client
PipeWire client object class.
PW_DIRECTION_INPUT
@ PW_DIRECTION_INPUT
an input port direction
Definition: introspect.h:48
pw_port_events::version
uint32_t version
Definition: port.h:62
pw_control
The control object.
resource_data::resource_listener
struct spa_hook resource_listener
Definition: factory.c:27
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_resource_set_implementation
void pw_resource_set_implementation(struct pw_resource *resource, const void *implementation, void *data)
Set the resource implementation.
Definition: resource.c:128
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:45
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_direction
pw_direction
The direction of a port.
Definition: introspect.h:47
pw_port_get_direction
enum pw_direction pw_port_get_direction(struct pw_port *port)
Get the port direction.
Definition: port.c:234
PW_PORT_STATE_ERROR
@ PW_PORT_STATE_ERROR
the port is in error
Definition: port.h:51
pw_global
A global object visible to remote clients.
pw_port_events::link_added
void(* link_added)(void *data, struct pw_link *link)
a new link is added on this port
Definition: port.h:74
pw_type
PipeWire type support struct.
Definition: type.h:51
pw_properties::dict
struct spa_dict dict
Definition: properties.h:39
pw_type::core
uint32_t core
Definition: type.h:54
param_filter::n_params
uint32_t n_params
Definition: port.c:640
PW_PORT_STATE_READY
@ PW_PORT_STATE_READY
the port is ready for buffer allocation
Definition: port.h:54
pw_port_update_properties
SPA_EXPORT int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict)
Update the port properties.
Definition: port.c:252
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_type::io
struct spa_type_io io
Definition: type.h:70
pw_port_info
Definition: introspect.h:168
param_filter::in_port
struct pw_port * in_port
Definition: port.c:634
pw_port_register
int pw_port_register(struct pw_port *port, struct pw_client *owner, struct pw_global *parent, struct pw_properties *properties)
Definition: port.c:402
pw_port_update_properties
int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict)
Update the port properties.
Definition: port.c:252
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_log::pw_log_trace
void pw_log_trace(const char *format,...)
Log a trace message.
pw_port
The port object.
PW_VERSION_PORT
#define PW_VERSION_PORT
Definition: interfaces.h:561
pw_port_get_node
struct pw_node * pw_port_get_node(struct pw_port *port)
Get the port parent node or NULL when not yet set.
Definition: port.c:278
pw_port_for_each_filtered_param
int pw_port_for_each_filtered_param(struct pw_port *in_port, struct pw_port *out_port, uint32_t in_param_id, uint32_t out_param_id, int(*callback)(void *data, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param), void *data)
Definition: port.c:650
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_port_send_command
int pw_port_send_command(struct pw_port *port, bool block, const struct spa_command *command)
Definition: port.c:593
node.h
pw_control_destroy
void pw_control_destroy(struct pw_control *control)
Definition: control.c:85
PW_VERSION_RESOURCE_EVENTS
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:63
pw_port_for_each_param
int pw_port_for_each_param(struct pw_port *port, 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: port.c:599
pw_port_events::destroy
void(* destroy)(void *data)
The port is destroyed.
Definition: port.h:65
param_filter::data
void * data
Definition: port.c:639
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_PORT_CHANGE_MASK_PROPS
#define PW_PORT_CHANGE_MASK_PROPS
Definition: introspect.h:171
pw_control_new
struct pw_control * pw_control_new(struct pw_core *core, struct pw_port *port, const struct spa_pod *param, size_t user_data_size)
Definition: control.c:32
pw_port_events::info_changed
void(* info_changed)(void *data, struct pw_port_info *info)
the port info changed
Definition: port.h:71
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
pw_port_get_direction
SPA_EXPORT enum pw_direction pw_port_get_direction(struct pw_port *port)
Get the port direction.
Definition: port.c:234
PW_NODE_CHANGE_MASK_OUTPUT_PORTS
#define PW_NODE_CHANGE_MASK_OUTPUT_PORTS
Definition: introspect.h:146
PW_PORT_STATE_INIT
@ PW_PORT_STATE_INIT
the port is being created
Definition: port.h:52
PW_VERSION_NODE_PROXY_METHODS
#define PW_VERSION_NODE_PROXY_METHODS
Definition: interfaces.h:535
param_filter::out_param_id
uint32_t out_param_id
Definition: port.c:637
pw_map::pw_map_clear
static void pw_map_clear(struct pw_map *map)
Clear a map.
Definition: map.h:81
param_filter
Definition: port.c:633
param_filter::in_param_id
uint32_t in_param_id
Definition: port.c:636
pw_port_proxy_methods
Port methods.
Definition: interfaces.h:608
pw_port_get_properties
SPA_EXPORT const struct pw_properties * pw_port_get_properties(struct pw_port *port)
Get the port properties.
Definition: port.c:246
pw_port_get_id
SPA_EXPORT uint32_t pw_port_get_id(struct pw_port *port)
Get the port id.
Definition: port.c:240
pw_port_destroy
void pw_port_destroy(struct pw_port *port)
Definition: port.c:546
pw_properties::pw_properties_copy
SPA_EXPORT struct pw_properties * pw_properties_copy(const struct pw_properties *properties)
Copy a properties object.
Definition: properties.c:183
pw_properties::pw_properties_set
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:308
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_add
int pw_port_add(struct pw_port *port, struct pw_node *node)
Definition: port.c:422
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_port_events::state_changed
void(* state_changed)(void *data, enum pw_port_state state)
the state of the port changed
Definition: port.h:80
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:60
pw_port_new
struct pw_port * pw_port_new(enum pw_direction direction, uint32_t port_id, struct pw_properties *properties, size_t user_data_size)
Definition: port.c:163
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_events::free
void(* free)(void *data)
The port is freed.
Definition: port.h:68
PW_PORT_STATE_PAUSED
@ PW_PORT_STATE_PAUSED
the port is paused
Definition: port.h:55
pw_port_resource_param
#define pw_port_resource_param(r,...)
Definition: interfaces.h:602
pw_type::param
struct spa_type_param param
Definition: type.h:71
param_filter::out_port
struct pw_port * out_port
Definition: port.c:635
core.h
pw_core_resource_error
#define pw_core_resource_error(r,...)
Definition: interfaces.h:338
pw_type::param_io
struct spa_type_param_io param_io
Definition: type.h:79
impl::this
struct pw_control this
Definition: control.c:26
PW_NODE_CHANGE_MASK_INPUT_PORTS
#define PW_NODE_CHANGE_MASK_INPUT_PORTS
Definition: introspect.h:145
PW_PORT_STATE_STREAMING
@ PW_PORT_STATE_STREAMING
the port is streaming
Definition: port.h:56
pw_port_proxy_methods::version
uint32_t version
Definition: interfaces.h:610
pw_type::node
uint32_t node
Definition: type.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.
param_filter::callback
int(* callback)(void *data, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param)
Definition: port.c:638
pw_port_state
pw_port_state
Definition: port.h:50
pw_port_events::control_added
void(* control_added)(void *data, struct pw_control *control)
a control was added to the port
Definition: port.h:83
pipewire.h
pw_port_unlink
void pw_port_unlink(struct pw_port *port)
Definition: port.c:491
pw_map::pw_map_insert_at
static bool pw_map_insert_at(struct pw_map *map, uint32_t id, void *data)
Insert data in the map at an index.
Definition: map.h:119
pw_port_get_id
uint32_t pw_port_get_id(struct pw_port *port)
Get the port id.
Definition: port.c:240
pw_loop_invoke
#define pw_loop_invoke(l,...)
Definition: loop.h:52
pw_port_resource_info
#define pw_port_resource_info(r,...)
Definition: interfaces.h:601
pw_port_add_listener
SPA_EXPORT 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_resource_events
Resource events.
Definition: resource.h:62
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_type::port
uint32_t port
Definition: type.h:57
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_PORT_STATE_CONFIGURE
@ PW_PORT_STATE_CONFIGURE
the port is ready for format negotiation
Definition: port.h:53
pw_port_get_user_data
void * pw_port_get_user_data(struct pw_port *port)
Definition: port.c:292
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
pw_port_events::control_removed
void(* control_removed)(void *data, struct pw_control *control)
a control was removed from the port
Definition: port.h:86