summaryrefslogtreecommitdiffstats
path: root/lib/protocol.h
blob: 34a92a0080b6613c868cf8c456c8021a13b863e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* PipeWire AGL Cluster IPC
 *
 * Copyright © 2021 Collabora Ltd.
 *    @author Julian Bouzas <julian.bouzas@collabora.com>
 *
 * SPDX-License-Identifier: MIT
 */

#ifndef __ICIPC_PROTOCOL_H__
#define __ICIPC_PROTOCOL_H__

#include <spa/pod/pod.h>

#include "defs.h"

#ifdef __cplusplus
extern "C" {
#endif

/* request */

ICIPC_API
size_t icipc_protocol_calculate_request_size(
                const char *name,
                const struct spa_pod *args);

ICIPC_API
void icipc_protocol_build_request(
                uint8_t *buffer,
                size_t size,
                const char *name,
                const struct spa_pod *args);

ICIPC_API
bool icipc_protocol_parse_request(
                const uint8_t *buffer,
                size_t size,
                const char **name,
                const struct spa_pod **args);

/* reply */

ICIPC_API
size_t icipc_protocol_calculate_reply_ok_size(const struct spa_pod *value);

ICIPC_API
size_t icipc_protocol_calculate_reply_error_size(const char *msg);

ICIPC_API
void icipc_protocol_build_reply_ok(
                uint8_t *buffer,
                size_t size,
                const struct spa_pod *value);

ICIPC_API
void icipc_protocol_build_reply_error(
                uint8_t *buffer,
                size_t size,
                const char *msg);

ICIPC_API
bool icipc_protocol_is_reply_ok(const uint8_t *buffer, size_t size);

ICIPC_API
bool icipc_protocol_is_reply_error(const uint8_t *buffer, size_t size);

ICIPC_API
bool icipc_protocol_parse_reply_ok(
                const uint8_t *buffer,
                size_t size,
                const struct spa_pod **value);

ICIPC_API
bool icipc_protocol_parse_reply_error(
                const uint8_t *buffer,
                size_t size,
                const char **msg);

#ifdef __cplusplus
}
#endif

#endif