PipeWire: pipewire/link.h Source File

PipeWire 1.2.0

Loading...
Searching...
No Matches
link.h
Go to the documentation of this file.
1/* PipeWire */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef PIPEWIRE_LINK_H
6#define PIPEWIRE_LINK_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/defs.h>
13#include <spa/utils/hook.h>
14
15#include <pipewire/proxy.h>
16
32#define PW_TYPE_INTERFACE_Link PW_TYPE_INFO_INTERFACE_BASE "Link"
33
34#define PW_LINK_PERM_MASK PW_PERM_R | PW_PERM_X
35
36#define PW_VERSION_LINK 3
37 struct pw_link;
38
40 enum pw_link_state {
41 PW_LINK_STATE_ERROR = -2,
42 PW_LINK_STATE_UNLINKED = -1,
43 PW_LINK_STATE_INIT = 0,
44 PW_LINK_STATE_NEGOTIATING = 1,
45 PW_LINK_STATE_ALLOCATING = 2,
46 PW_LINK_STATE_PAUSED = 3,
47 PW_LINK_STATE_ACTIVE = 4,
48};
49
51 const char * pw_link_state_as_string(enum pw_link_state state);
53 struct pw_link_info {
54 uint32_t id;
55 uint32_t output_node_id;
56 uint32_t output_port_id;
57 uint32_t input_node_id;
58 uint32_t input_port_id;
59#define PW_LINK_CHANGE_MASK_STATE (1 << 0)
60#define PW_LINK_CHANGE_MASK_FORMAT (1 << 1)
61#define PW_LINK_CHANGE_MASK_PROPS (1 << 2)
62#define PW_LINK_CHANGE_MASK_ALL ((1 << 3)-1)
63 uint64_t change_mask;
64 enum pw_link_state state;
65 const char *error;
66 struct spa_pod *format;
67 struct spa_dict *props;
68};
69
70 struct pw_link_info *
71 pw_link_info_update(struct pw_link_info *info,
72 const struct pw_link_info *update);
73
74 struct pw_link_info *
75 pw_link_info_merge(struct pw_link_info *info,
76 const struct pw_link_info *update, bool reset);
77
78 void
79 pw_link_info_free(struct pw_link_info *info);
80
81
82#define PW_LINK_EVENT_INFO 0
83#define PW_LINK_EVENT_NUM 1
84
86struct pw_link_events {
87#define PW_VERSION_LINK_EVENTS 0
88 uint32_t version;
94 void (*info) (void *data, const struct pw_link_info *info);
95};
96
97#define PW_LINK_METHOD_ADD_LISTENER 0
98#define PW_LINK_METHOD_NUM 1
99
101struct pw_link_methods {
102#define PW_VERSION_LINK_METHODS 0
103 uint32_t version;
104
105 int (*add_listener) (void *object,
106 struct spa_hook *listener,
107 const struct pw_link_events *events,
108 void *data);
109};
110
111#define pw_link_method(o,method,version,...) \
112({ \
113 int _res = -ENOTSUP; \
114 spa_interface_call_res((struct spa_interface*)o, \
115 struct pw_link_methods, _res, \
116 method, version, ##__VA_ARGS__); \
117 _res; \
118})
119
120#define pw_link_add_listener(c,...) pw_link_method(c,add_listener,0,__VA_ARGS__)
121
126#ifdef __cplusplus
127} /* extern "C" */
128#endif
129
130#endif /* PIPEWIRE_LINK_H */
defs.h
spa/utils/defs.h
pw_link_state_as_string
const char * pw_link_state_as_string(enum pw_link_state state)
Convert a pw_link_state to a readable string.
Definition introspect.c:45
pw_link_info_merge
struct pw_link_info * pw_link_info_merge(struct pw_link_info *info, const struct pw_link_info *update, bool reset)
Definition introspect.c:521
pw_link_info_free
void pw_link_info_free(struct pw_link_info *info)
Definition introspect.c:567
pw_link_info_update
struct pw_link_info * pw_link_info_update(struct pw_link_info *info, const struct pw_link_info *update)
Definition introspect.c:560
pw_link_state
pw_link_state
The different link states.
Definition link.h:48
PW_LINK_STATE_ACTIVE
@ PW_LINK_STATE_ACTIVE
the link is active
Definition link.h:55
PW_LINK_STATE_ERROR
@ PW_LINK_STATE_ERROR
the link is in error
Definition link.h:49
PW_LINK_STATE_UNLINKED
@ PW_LINK_STATE_UNLINKED
the link is unlinked
Definition link.h:50
PW_LINK_STATE_PAUSED
@ PW_LINK_STATE_PAUSED
the link is paused
Definition link.h:54
PW_LINK_STATE_NEGOTIATING
@ PW_LINK_STATE_NEGOTIATING
the link is negotiating formats
Definition link.h:52
PW_LINK_STATE_INIT
@ PW_LINK_STATE_INIT
the link is initialized
Definition link.h:51
PW_LINK_STATE_ALLOCATING
@ PW_LINK_STATE_ALLOCATING
the link is allocating buffers
Definition link.h:53
hook.h
spa/utils/hook.h
proxy.h
pipewire/proxy.h
pw_link_events
Link events.
Definition link.h:100
pw_link_events::version
uint32_t version
Definition link.h:103
pw_link_events::info
void(* info)(void *data, const struct pw_link_info *info)
Notify link info.
Definition link.h:109
pw_link_info
The link information.
Definition link.h:61
pw_link_info::output_port_id
uint32_t output_port_id
output port id
Definition link.h:64
pw_link_info::id
uint32_t id
id of the global
Definition link.h:62
pw_link_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition link.h:75
pw_link_info::output_node_id
uint32_t output_node_id
server side output node id
Definition link.h:63
pw_link_info::state
enum pw_link_state state
the current state of the link
Definition link.h:76
pw_link_info::error
const char * error
an error reason if state is error
Definition link.h:77
pw_link_info::input_node_id
uint32_t input_node_id
server side input node id
Definition link.h:65
pw_link_info::format
struct spa_pod * format
format over link
Definition link.h:78
pw_link_info::input_port_id
uint32_t input_port_id
input port id
Definition link.h:66
pw_link_methods
Link methods.
Definition link.h:118
pw_link_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_link_events *events, void *data)
Definition link.h:123
pw_link
spa_dict
Definition dict.h:39
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:350
spa_pod
Definition pod.h:43