PipeWire: pipewire/protocol.h Source File

PipeWire 1.4.7

Loading...
Searching...
No Matches
protocol.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_PROTOCOL_H
6#define PIPEWIRE_PROTOCOL_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/list.h>
13
18
23
24struct pw_protocol;
25
26#include <pipewire/context.h>
27#include <pipewire/properties.h>
28#include <pipewire/utils.h>
29
30#define PW_TYPE_INFO_Protocol "PipeWire:Protocol"
31#define PW_TYPE_INFO_PROTOCOL_BASE PW_TYPE_INFO_Protocol ":"
32
33struct pw_protocol_client {
34 struct spa_list link;
35 struct pw_protocol *protocol;
36
37 struct pw_core *core;
38
39 int (*connect) (struct pw_protocol_client *client,
40 const struct spa_dict *props,
41 void (*done_callback) (void *data, int result),
42 void *data);
43 int (*connect_fd) (struct pw_protocol_client *client, int fd, bool close);
44 int (*steal_fd) (struct pw_protocol_client *client);
45 void (*disconnect) (struct pw_protocol_client *client);
46 void (*destroy) (struct pw_protocol_client *client);
47 int (*set_paused) (struct pw_protocol_client *client, bool paused);
48};
49
50#define pw_protocol_client_connect(c,p,cb,d) ((c)->connect(c,p,cb,d))
51#define pw_protocol_client_connect_fd(c,fd,cl) ((c)->connect_fd(c,fd,cl))
52#define pw_protocol_client_steal_fd(c) ((c)->steal_fd(c))
53#define pw_protocol_client_disconnect(c) ((c)->disconnect(c))
54#define pw_protocol_client_destroy(c) ((c)->destroy(c))
55#define pw_protocol_client_set_paused(c,p) ((c)->set_paused(c,p))
56
57 struct pw_protocol_server {
58 struct spa_list link;
59 struct pw_protocol *protocol;
60
61 struct pw_impl_core *core;
62
63 struct spa_list client_list;
64
65 void (*destroy) (struct pw_protocol_server *listen);
66};
67
68#define pw_protocol_server_destroy(l) ((l)->destroy(l))
69
70 struct pw_protocol_marshal {
71 const char *type;
72 uint32_t version;
73#define PW_PROTOCOL_MARSHAL_FLAG_IMPL (1 << 0)
74 uint32_t flags;
75 uint32_t n_client_methods;
76 uint32_t n_server_methods;
77 const void *client_marshal;
78 const void *server_demarshal;
79 const void *server_marshal;
80 const void *client_demarshal;
81};
82
83 struct pw_protocol_implementation {
84#define PW_VERSION_PROTOCOL_IMPLEMENTATION 1
85 uint32_t version;
86
87 struct pw_protocol_client * (*new_client) (struct pw_protocol *protocol,
88 struct pw_core *core,
89 const struct spa_dict *props);
90 struct pw_protocol_server * (*add_server) (struct pw_protocol *protocol,
91 struct pw_impl_core *core,
92 const struct spa_dict *props);
93 struct pw_protocol_server * (*add_fd_server) (struct pw_protocol *protocol,
94 struct pw_impl_core *core,
95 int listen_fd, int close_fd,
96 const struct spa_dict *props);
97};
98
99struct pw_protocol_events {
100#define PW_VERSION_PROTOCOL_EVENTS 0
101 uint32_t version;
102
103 void (*destroy) (void *data);
104};
105
106#define pw_protocol_new_client(p,...) (pw_protocol_get_implementation(p)->new_client(p,__VA_ARGS__))
107#define pw_protocol_add_server(p,...) (pw_protocol_get_implementation(p)->add_server(p,__VA_ARGS__))
108#define pw_protocol_add_fd_server(p,...) (pw_protocol_get_implementation(p)->add_fd_server(p,__VA_ARGS__))
109#define pw_protocol_ext(p,type,method,...) (((type*)pw_protocol_get_extension(p))->method( __VA_ARGS__))
110
111 struct pw_protocol *pw_protocol_new(struct pw_context *context, const char *name, size_t user_data_size);
112
113 void pw_protocol_destroy(struct pw_protocol *protocol);
114
115struct pw_context *pw_protocol_get_context(struct pw_protocol *protocol);
116
117 void *pw_protocol_get_user_data(struct pw_protocol *protocol);
118
119 const struct pw_protocol_implementation *
120 pw_protocol_get_implementation(struct pw_protocol *protocol);
121
122const void *
123 pw_protocol_get_extension(struct pw_protocol *protocol);
124
125
126void pw_protocol_add_listener(struct pw_protocol *protocol,
127 struct spa_hook *listener,
128 const struct pw_protocol_events *events,
129 void *data);
130
131int pw_protocol_add_marshal(struct pw_protocol *protocol,
132 const struct pw_protocol_marshal *marshal);
133
134const struct pw_protocol_marshal *
135 pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t version, uint32_t flags);
136
137struct pw_protocol * pw_context_find_protocol(struct pw_context *context, const char *name);
138
142
143#ifdef __cplusplus
144} /* extern "C" */
145#endif
146
147#endif /* PIPEWIRE_PROTOCOL_H */
pw_context_find_protocol
struct pw_protocol * pw_context_find_protocol(struct pw_context *context, const char *name)
Definition protocol.c:160
pw_protocol_add_listener
void pw_protocol_add_listener(struct pw_protocol *protocol, struct spa_hook *listener, const struct pw_protocol_events *events, void *data)
Definition protocol.c:114
pw_protocol_get_context
struct pw_context * pw_protocol_get_context(struct pw_protocol *protocol)
Definition protocol.c:59
pw_protocol_get_marshal
const struct pw_protocol_marshal * pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t version, uint32_t flags)
Definition protocol.c:145
pw_protocol_add_marshal
int pw_protocol_add_marshal(struct pw_protocol *protocol, const struct pw_protocol_marshal *marshal)
Definition protocol.c:124
pw_protocol_new
struct pw_protocol * pw_protocol_new(struct pw_context *context, const char *name, size_t user_data_size)
Definition protocol.c:30
pw_protocol_destroy
void pw_protocol_destroy(struct pw_protocol *protocol)
Definition protocol.c:85
pw_protocol_get_user_data
void * pw_protocol_get_user_data(struct pw_protocol *protocol)
Definition protocol.c:65
pw_protocol_get_extension
const void * pw_protocol_get_extension(struct pw_protocol *protocol)
Definition protocol.c:79
pw_protocol_get_implementation
const struct pw_protocol_implementation * pw_protocol_get_implementation(struct pw_protocol *protocol)
Definition protocol.c:72
list.h
spa/utils/list.h
properties.h
pipewire/properties.h
context.h
pipewire/context.h
utils.h
pw_context
pw_core
pw_impl_core
pw_protocol_client
Definition protocol.h:40
pw_protocol_client::connect
int(* connect)(struct pw_protocol_client *client, const struct spa_dict *props, void(*done_callback)(void *data, int result), void *data)
Definition protocol.h:46
pw_protocol_client::core
struct pw_core * core
Definition protocol.h:44
pw_protocol_client::connect_fd
int(* connect_fd)(struct pw_protocol_client *client, int fd, bool close)
Definition protocol.h:50
pw_protocol_client::protocol
struct pw_protocol * protocol
the owner protocol
Definition protocol.h:42
pw_protocol_client::disconnect
void(* disconnect)(struct pw_protocol_client *client)
Definition protocol.h:52
pw_protocol_client::set_paused
int(* set_paused)(struct pw_protocol_client *client, bool paused)
Definition protocol.h:54
pw_protocol_client::destroy
void(* destroy)(struct pw_protocol_client *client)
Definition protocol.h:53
pw_protocol_client::link
struct spa_list link
link in protocol client_list
Definition protocol.h:41
pw_protocol_client::steal_fd
int(* steal_fd)(struct pw_protocol_client *client)
Definition protocol.h:51
pw_protocol_events
Definition protocol.h:108
pw_protocol_events::destroy
void(* destroy)(void *data)
Definition protocol.h:113
pw_protocol_events::version
uint32_t version
Definition protocol.h:111
pw_protocol_implementation
Definition protocol.h:91
pw_protocol_marshal
Definition protocol.h:77
pw_protocol_marshal::n_client_methods
uint32_t n_client_methods
number of client methods
Definition protocol.h:83
pw_protocol_marshal::server_demarshal
const void * server_demarshal
Definition protocol.h:86
pw_protocol_marshal::flags
uint32_t flags
version
Definition protocol.h:82
pw_protocol_marshal::type
const char * type
interface type
Definition protocol.h:78
pw_protocol_marshal::client_marshal
const void * client_marshal
Definition protocol.h:85
pw_protocol_marshal::version
uint32_t version
version
Definition protocol.h:79
pw_protocol_marshal::n_server_methods
uint32_t n_server_methods
number of server methods
Definition protocol.h:84
pw_protocol_marshal::client_demarshal
const void * client_demarshal
Definition protocol.h:88
pw_protocol_marshal::server_marshal
const void * server_marshal
Definition protocol.h:87
pw_protocol_server
Definition protocol.h:64
pw_protocol_server::client_list
struct spa_list client_list
list of clients of this protocol
Definition protocol.h:70
pw_protocol_server::link
struct spa_list link
link in protocol server_list
Definition protocol.h:65
pw_protocol_server::protocol
struct pw_protocol * protocol
the owner protocol
Definition protocol.h:66
pw_protocol_server::destroy
void(* destroy)(struct pw_protocol_server *listen)
Definition protocol.h:72
pw_protocol_server::core
struct pw_impl_core * core
Definition protocol.h:68
pw_protocol
spa_dict
Definition dict.h:51
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_list
Definition list.h:39