PipeWire 0.3.77
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
24struct pw_protocol;
25
26#include <pipewire/context.h>
27#include <pipewire/properties.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;
37 struct pw_core *core;
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
58 struct spa_list link;
63 struct spa_list client_list;
65 void (*destroy) (struct pw_protocol_server *listen);
66};
67
68#define pw_protocol_server_destroy(l) ((l)->destroy(l))
69
71 const char *type;
72 uint32_t version;
73#define PW_PROTOCOL_MARSHAL_FLAG_IMPL (1 << 0)
74 uint32_t flags;
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};
84#define PW_VERSION_PROTOCOL_IMPLEMENTATION 0
85 uint32_t version;
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};
95struct pw_protocol_events {
96#define PW_VERSION_PROTOCOL_EVENTS 0
97 uint32_t version;
98
99 void (*destroy) (void *data);
100};
101
102#define pw_protocol_new_client(p,...) (pw_protocol_get_implementation(p)->new_client(p,__VA_ARGS__))
103#define pw_protocol_add_server(p,...) (pw_protocol_get_implementation(p)->add_server(p,__VA_ARGS__))
104#define pw_protocol_ext(p,type,method,...) (((type*)pw_protocol_get_extension(p))->method( __VA_ARGS__))
105
106struct pw_protocol *pw_protocol_new(struct pw_context *context, const char *name, size_t user_data_size);
108void pw_protocol_destroy(struct pw_protocol *protocol);
110struct pw_context *pw_protocol_get_context(struct pw_protocol *protocol);
111
116
117const void *
118pw_protocol_get_extension(struct pw_protocol *protocol);
119
120
121void pw_protocol_add_listener(struct pw_protocol *protocol,
122 struct spa_hook *listener,
123 const struct pw_protocol_events *events,
124 void *data);
125
126int pw_protocol_add_marshal(struct pw_protocol *protocol,
127 const struct pw_protocol_marshal *marshal);
128
129const struct pw_protocol_marshal *
130pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t version, uint32_t flags);
131
132struct pw_protocol * pw_context_find_protocol(struct pw_context *context, const char *name);
133
138#ifdef __cplusplus
139} /* extern "C" */
140#endif
141
142#endif /* PIPEWIRE_PROTOCOL_H */
struct pw_protocol * pw_context_find_protocol(struct pw_context *context, const char *name)
Definition: protocol.c:159
void pw_protocol_add_listener(struct pw_protocol *protocol, struct spa_hook *listener, const struct pw_protocol_events *events, void *data)
Definition: protocol.c:113
struct pw_context * pw_protocol_get_context(struct pw_protocol *protocol)
Definition: protocol.c:58
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:144
int pw_protocol_add_marshal(struct pw_protocol *protocol, const struct pw_protocol_marshal *marshal)
Definition: protocol.c:123
struct pw_protocol * pw_protocol_new(struct pw_context *context, const char *name, size_t user_data_size)
Definition: protocol.c:29
void pw_protocol_destroy(struct pw_protocol *protocol)
Definition: protocol.c:84
void * pw_protocol_get_user_data(struct pw_protocol *protocol)
Definition: protocol.c:64
const void * pw_protocol_get_extension(struct pw_protocol *protocol)
Definition: protocol.c:78
const struct pw_protocol_implementation * pw_protocol_get_implementation(struct pw_protocol *protocol)
Definition: protocol.c:71
spa/utils/list.h
pipewire/properties.h
pipewire/context.h
Definition: protocol.h:40
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
struct pw_core * core
Definition: protocol.h:44
int(* connect_fd)(struct pw_protocol_client *client, int fd, bool close)
Definition: protocol.h:50
struct pw_protocol * protocol
the owner protocol
Definition: protocol.h:42
void(* disconnect)(struct pw_protocol_client *client)
Definition: protocol.h:52
int(* set_paused)(struct pw_protocol_client *client, bool paused)
Definition: protocol.h:54
void(* destroy)(struct pw_protocol_client *client)
Definition: protocol.h:53
struct spa_list link
link in protocol client_list
Definition: protocol.h:41
int(* steal_fd)(struct pw_protocol_client *client)
Definition: protocol.h:51
Definition: protocol.h:104
void(* destroy)(void *data)
Definition: protocol.h:109
uint32_t version
Definition: protocol.h:107
Definition: protocol.h:91
uint32_t version
Definition: protocol.h:94
Definition: protocol.h:77
uint32_t n_client_methods
number of client methods
Definition: protocol.h:83
const void * server_demarshal
Definition: protocol.h:86
uint32_t flags
version
Definition: protocol.h:82
const char * type
interface type
Definition: protocol.h:78
const void * client_marshal
Definition: protocol.h:85
uint32_t version
version
Definition: protocol.h:79
uint32_t n_server_methods
number of server methods
Definition: protocol.h:84
const void * client_demarshal
Definition: protocol.h:88
const void * server_marshal
Definition: protocol.h:87
Definition: protocol.h:64
struct spa_list client_list
list of clients of this protocol
Definition: protocol.h:70
struct spa_list link
link in protocol server_list
Definition: protocol.h:65
struct pw_protocol * protocol
the owner protocol
Definition: protocol.h:66
void(* destroy)(struct pw_protocol_server *listen)
Definition: protocol.h:72
struct pw_impl_core * core
Definition: protocol.h:68
Definition: utils/dict.h:39
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:350
Definition: list.h:27