PipeWire: remote.h Source File

PipeWire 0.2.7

remote.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_REMOTE_H__
21 #define __PIPEWIRE_REMOTE_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <spa/utils/hook.h>
28
107 struct pw_remote;
108
109 #include <pipewire/core.h>
110 #include <pipewire/properties.h>
111 #include <pipewire/protocol.h>
112 #include <pipewire/proxy.h>
113
115 enum pw_remote_state {
116 PW_REMOTE_STATE_ERROR = -1,
117 PW_REMOTE_STATE_UNCONNECTED = 0,
118 PW_REMOTE_STATE_CONNECTING = 1,
119 PW_REMOTE_STATE_CONNECTED = 2,
120 };
121
123 const char *pw_remote_state_as_string(enum pw_remote_state state);
124
126 struct pw_remote_events {
127 #define PW_VERSION_REMOTE_EVENTS 0
128 uint32_t version;
129
131 void (*destroy) (void *data);
133 void (*info_changed) (void *data, const struct pw_core_info *info);
135 void (*sync_reply) (void *data, uint32_t seq);
137 void (*state_changed) (void *data, enum pw_remote_state old,
138 enum pw_remote_state state, const char *error);
139 };
140
142 #define PW_REMOTE_PROP_PROTOCOL "pipewire.protocol"
143
144 #define PW_REMOTE_PROP_REMOTE_NAME "pipewire.remote.name"
145
148 struct pw_remote *
149 pw_remote_new(struct pw_core *core,
150 struct pw_properties *properties,
152 size_t user_data_size );
153
155 void pw_remote_destroy(struct pw_remote *remote);
156
158 struct pw_core *pw_remote_get_core(struct pw_remote *remote);
159
161 const struct pw_properties *pw_remote_get_properties(struct pw_remote *remote);
162
164 void *pw_remote_get_user_data(struct pw_remote *remote);
165
167 enum pw_remote_state pw_remote_get_state(struct pw_remote *remote, const char **error);
168
170 void pw_remote_add_listener(struct pw_remote *remote,
171 struct spa_hook *listener,
172 const struct pw_remote_events *events,
173 void *data);
174
177 int pw_remote_connect(struct pw_remote *remote);
178
183 int pw_remote_connect_fd(struct pw_remote *remote, int fd);
184
187 int pw_remote_steal_fd(struct pw_remote *remote);
188
190 struct pw_core_proxy * pw_remote_get_core_proxy(struct pw_remote *remote);
191
193 const struct pw_core_info *pw_remote_get_core_info(struct pw_remote *remote);
194
196 struct pw_proxy *pw_remote_find_proxy(struct pw_remote *remote, uint32_t id);
197
199 int pw_remote_disconnect(struct pw_remote *remote);
200
202 struct pw_proxy *pw_remote_export(struct pw_remote *remote, struct pw_node *node);
203
204 #ifdef __cplusplus
205 }
206 #endif
207
208 #endif /* __PIPEWIRE_REMOTE_H__ */
pw_map_range
parameters to map a memory range
Definition: mem.h:69
pw_remote_get_core_info
SPA_EXPORT const struct pw_core_info * pw_remote_get_core_info(struct pw_remote *remote)
Get the remote core info, can only be called when connected.
Definition: remote.c:386
pw_remote_add_listener
void pw_remote_add_listener(struct pw_remote *remote, struct spa_hook *listener, const struct pw_remote_events *events, void *data)
Add listener for events.
Definition: remote.c:346
PW_REMOTE_STATE_UNCONNECTED
not connected
Definition: remote.h:117
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_array::pw_array_ensure_size
static bool pw_array_ensure_size(struct pw_array *arr, size_t size)
Make sure size bytes can be added to the array.
Definition: array.h:76
PW_REMOTE_STATE_ERROR
remote is in error
Definition: remote.h:116
pw_remote_get_user_data
SPA_EXPORT void * pw_remote_get_user_data(struct pw_remote *remote)
Get the user_data.
Definition: remote.c:332
pw_map::pw_map_lookup
static void * pw_map_lookup(struct pw_map *map, uint32_t id)
Find an item in the map.
Definition: map.h:152
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
pw_module::pw_module_load
SPA_EXPORT struct pw_module * pw_module_load(struct pw_core *core, const char *name, const char *args, struct pw_client *owner, struct pw_global *parent, struct pw_properties *properties)
Load a module.
Definition: module.c:167
introspect.h
pw_remote::pw_remote_disconnect
int pw_remote_disconnect(struct pw_remote *remote)
Disconnect from the remote PipeWire.
Definition: remote.c:452
remote.h
pw_core_info
The core information.
Definition: introspect.h:76
pw_protocol_new_client
#define pw_protocol_new_client(p,...)
Definition: protocol.h:100
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
pw_remote
Represents a connection with a remote PipeWire instance.
pw_remote_find_proxy
struct pw_proxy * pw_remote_find_proxy(struct pw_remote *remote, uint32_t id)
Get the proxy with the given id.
Definition: remote.c:392
PW_STREAM_PROP_LATENCY_MIN
#define PW_STREAM_PROP_LATENCY_MIN
The minimum latency of the stream, int, default 0.
Definition: stream.h:251
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_protocol
Manages protocols and their implementation.
pw_loop_add_io
#define pw_loop_add_io(l,...)
Definition: loop.h:60
interfaces.h
pw_pipewire::pw_fill_remote_properties
SPA_EXPORT void pw_fill_remote_properties(struct pw_core *core, struct pw_properties *properties)
Fill remote properties.
Definition: pipewire.c:395
module.h
pw_proxy::pw_proxy_destroy
SPA_EXPORT void pw_proxy_destroy(struct pw_proxy *proxy)
Destroy a proxy object.
Definition: proxy.c:124
impl
Definition: control.c:25
pw_introspect::pw_core_info_update
struct pw_core_info * pw_core_info_update(struct pw_core_info *info, const struct pw_core_info *update)
Update and existing pw_core_info with update.
Definition: introspect.c:122
pw_proxy_events
Proxy events, use pw_proxy_add_listener.
Definition: proxy.h:102
pw_remote_steal_fd
int pw_remote_steal_fd(struct pw_remote *remote)
Steal the fd of the remote connection or < 0 on error.
Definition: remote.c:441
pw_array_for_each
#define pw_array_for_each(pos, array)
Definition: array.h:56
pw_type
PipeWire type support struct.
Definition: type.h:51
pw_log::pw_log_info
void pw_log_info(const char *format,...)
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_remote_export
struct pw_proxy * pw_remote_export(struct pw_remote *remote, struct pw_node *node)
run a local node in a remote graph
Definition: remote.c:1339
PW_VERSION_CORE_PROXY_EVENTS
#define PW_VERSION_CORE_PROXY_EVENTS
Definition: interfaces.h:271
pw_array
An array object.
Definition: array.h:36
pw_type::core
uint32_t core
Definition: type.h:54
pw_map::PW_MAP_ID_TO_PTR
#define PW_MAP_ID_TO_PTR(id)
Convert an id to a pointer that can be inserted into the map.
Definition: map.h:60
protocol.h
PW_MAP_RANGE_INIT
#define PW_MAP_RANGE_INIT
Definition: mem.h:75
PW_VERSION_PROXY_EVENTS
#define PW_VERSION_PROXY_EVENTS
Definition: proxy.h:103
pw_protocol_client_connect
#define pw_protocol_client_connect(c, cb, d)
Definition: protocol.h:53
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_core_proxy_events
Core events.
Definition: interfaces.h:270
pw_remote_get_user_data
void * pw_remote_get_user_data(struct pw_remote *remote)
Get the user_data.
Definition: remote.c:332
pw_log::pw_log_trace
void pw_log_trace(const char *format,...)
pw_remote::pw_remote_destroy
void pw_remote_destroy(struct pw_remote *remote)
Destroy a remote.
Definition: remote.c:294
pw_port
PW_REMOTE_STATE_CONNECTING
connecting to remote PipeWire
Definition: remote.h:118
pw_loop_destroy_source
#define pw_loop_destroy_source(l,...)
Definition: loop.h:69
pw_remote::pw_remote_state_as_string
const char * pw_remote_state_as_string(enum pw_remote_state state)
Convert a pw_remote_state to a readable string.
Definition: remote.c:107
pw_port_send_command
int pw_port_send_command(struct pw_port *port, bool block, const struct spa_command *command)
Definition: port.c:593
pw_remote_get_core
struct pw_core * pw_remote_get_core(struct pw_remote *remote)
Get the core used to construct this remote.
Definition: remote.c:320
pw_protocol_client_disconnect
#define pw_protocol_client_disconnect(c)
Definition: protocol.h:56
pw_remote_get_core_proxy
struct pw_core_proxy * pw_remote_get_core_proxy(struct pw_remote *remote)
Get the core proxy, can only be called when connected.
Definition: remote.c:380
pw_remote_get_properties
SPA_EXPORT const struct pw_properties * pw_remote_get_properties(struct pw_remote *remote)
Get the remote properties.
Definition: remote.c:326
pw_proxy
Represents an object on the client side.
pw_remote_add_listener
SPA_EXPORT void pw_remote_add_listener(struct pw_remote *remote, struct spa_hook *listener, const struct pw_remote_events *events, void *data)
Add listener for events.
Definition: remote.c:346
stream.h
pw_remote_get_state
SPA_EXPORT enum pw_remote_state pw_remote_get_state(struct pw_remote *remote, const char **error)
Get the current state, error is set when state is PW_REMOTE_STATE_ERROR.
Definition: remote.c:338
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_proxy_get_user_data
void * pw_proxy_get_user_data(struct pw_proxy *proxy)
Get the user_data.
Definition: proxy.c:80
pw_map::pw_map_clear
static void pw_map_clear(struct pw_map *map)
Clear a map.
Definition: map.h:81
pw_introspect::pw_core_info_free
void pw_core_info_free(struct pw_core_info *info)
Free a pw_core_info.
Definition: introspect.c:163
pw_remote_export
SPA_EXPORT struct pw_proxy * pw_remote_export(struct pw_remote *remote, struct pw_node *node)
run a local node in a remote graph
Definition: remote.c:1339
PW_REMOTE_STATE_CONNECTED
remote is connected and ready
Definition: remote.h:119
pw_proxy::pw_proxy_new
SPA_EXPORT struct pw_proxy * pw_proxy_new(struct pw_proxy *factory, uint32_t type, size_t user_data_size)
Create a proxy object with a given id and type.
Definition: proxy.c:47
pw_remote::pw_remote_connect
int pw_remote_connect(struct pw_remote *remote)
Connect to a remote PipeWire.
Definition: remote.c:410
pw_node_events
Node events, listen to them with pw_node_add_listener.
Definition: node.h:51
proxy.h
pw_properties::pw_properties_get
const SPA_EXPORT char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:361
pw_remote_get_core_info
const struct pw_core_info * pw_remote_get_core_info(struct pw_remote *remote)
Get the remote core info, can only be called when connected.
Definition: remote.c:386
pw_remote::pw_remote_new
struct pw_remote * pw_remote_new(struct pw_core *core, struct pw_properties *properties, size_t user_data_size)
Create a new unconnected remote.
Definition: remote.c:215
pw_remote_events::sync_reply
void(* sync_reply)(void *data, uint32_t seq)
emited when a reply to a sync was received
Definition: remote.h:135
pw_array::pw_array_add
static void * pw_array_add(struct pw_array *arr, size_t size)
Add ref size bytes to arr.
Definition: array.h:98
pw_core_find_protocol
struct pw_protocol * pw_core_find_protocol(struct pw_core *core, const char *name)
Definition: protocol.c:161
pw_node_get_core
struct pw_core * pw_node_get_core(struct pw_node *node)
Get the core of this node.
Definition: node.c:469
pw_array::pw_array_get_len
#define pw_array_get_len(a, t)
Get the number of items of type t in array.
Definition: array.h:50
pw_remote_events::state_changed
void(* state_changed)(void *data, enum pw_remote_state old, enum pw_remote_state state, const char *error)
emited when the state changes
Definition: remote.h:137
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_core_get_type
struct pw_type * pw_core_get_type(struct pw_core *core)
Get the type object of a core.
Definition: core.c:552
pw_protocol_client_steal_fd
#define pw_protocol_client_steal_fd(c)
Definition: protocol.h:55
pw_proxy_add_listener
void pw_proxy_add_listener(struct pw_proxy *proxy, struct spa_hook *listener, const struct pw_proxy_events *events, void *data)
Add an event listener to proxy.
Definition: proxy.c:98
pw_remote_get_core_proxy
SPA_EXPORT struct pw_core_proxy * pw_remote_get_core_proxy(struct pw_remote *remote)
Get the core proxy, can only be called when connected.
Definition: remote.c:380
pw_stream::pw_stream_disconnect
int pw_stream_disconnect(struct pw_stream *stream)
Disconnect stream.
Definition: stream.c:1339
pw_loop_update_io
#define pw_loop_update_io(l,...)
Definition: loop.h:61
pw_protocol_client_connect_fd
#define pw_protocol_client_connect_fd(c, fd, cl)
Definition: protocol.h:54
pw_remote_steal_fd
SPA_EXPORT int pw_remote_steal_fd(struct pw_remote *remote)
Steal the fd of the remote connection or < 0 on error.
Definition: remote.c:441
core.h
pw_remote_get_state
enum pw_remote_state pw_remote_get_state(struct pw_remote *remote, const char **error)
Get the current state, error is set when state is PW_REMOTE_STATE_ERROR.
Definition: remote.c:338
impl::this
struct pw_control this
Definition: control.c:26
pw_stream::pw_stream_destroy
void pw_stream_destroy(struct pw_stream *stream)
Destroy a stream.
Definition: stream.c:536
pw_remote_get_properties
const struct pw_properties * pw_remote_get_properties(struct pw_remote *remote)
Get the remote properties.
Definition: remote.c:326
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_STREAM_PROP_IS_LIVE
#define PW_STREAM_PROP_IS_LIVE
Indicates that the stream is live, boolean default false.
Definition: stream.h:249
pw_log::pw_log_error
void pw_log_error(const char *format,...)
pw_remote::pw_remote_connect_fd
int pw_remote_connect_fd(struct pw_remote *remote, int fd)
Connect to a remote PipeWire on the given socket.
Definition: remote.c:425
pw_type::data
struct spa_type_data data
Definition: type.h:73
pw_stream
PipeWire stream object class.
pipewire.h
properties.h
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_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_remote_get_core
SPA_EXPORT struct pw_core * pw_remote_get_core(struct pw_remote *remote)
Get the core used to construct this remote.
Definition: remote.c:320
pw_remote_events::info_changed
void(* info_changed)(void *data, const struct pw_core_info *info)
emited when the remote core info changed
Definition: remote.h:133
pw_remote_events
Events for the remote.
Definition: remote.h:126
pw_protocol_client_destroy
#define pw_protocol_client_destroy(c)
Definition: protocol.h:57
PW_REMOTE_PROP_PROTOCOL
#define PW_REMOTE_PROP_PROTOCOL
Specify the name of the protocol to use, default is using the native protocol.
Definition: remote.h:142
pw_type::port
uint32_t port
Definition: type.h:57
pw_remote_find_proxy
SPA_EXPORT struct pw_proxy * pw_remote_find_proxy(struct pw_remote *remote, uint32_t id)
Get the proxy with the given id.
Definition: remote.c:392
pw_remote_events::version
uint32_t version
Definition: remote.h:128
pw_log::pw_log_warn
void pw_log_warn(const char *format,...)
pw_log::pw_log_debug
void pw_log_debug(const char *format,...)
pw_remote_state
pw_remote_state
Definition: remote.h:115
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_remote_events::destroy
void(* destroy)(void *data)
The remote is destroyed.
Definition: remote.h:131
pw_array::pw_array_init
static void pw_array_init(struct pw_array *arr, size_t extend)
Initialize the array with given extend.
Definition: array.h:62