Compy 0.2.0
A lightweight RTSP 1.0 server library for embedded systems
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <compy/option.h>
9#include <compy/types/error.h>
11
12#include <stdbool.h>
13#include <stdint.h>
14
15#include <slice99.h>
16
17/* Forward declaration to avoid circular include with context.h */
18typedef struct Compy_Context Compy_Context;
19
23#define COMPY_CRLF (CharSlice99_from_str("\r\n"))
24
28#define COMPY_DEFAULT_PORT 554
29
33#define COMPY_DEFAULT_RTSPS_PORT 322
34
49
55
59typedef struct {
63 uint16_t rtp_port;
64
68 uint16_t rtcp_port;
70
77
81typedef struct {
85 uint8_t rtp_channel;
86
90 uint8_t rtcp_channel;
92
99
105typedef struct {
110
115
120
124 Compy_ChannelPairOption interleaved;
125
129 Compy_PortPairOption client_port;
130
134 Compy_PortPairOption server_port;
136
150 Compy_TransportConfig *restrict config,
151 CharSlice99 header_value) COMPY_PRIV_MUST_USE;
152
159#define COMPY_REQUIRE_ONVIF_BACKCHANNEL \
160 (CharSlice99_from_str("www.onvif.org/ver20/backchannel"))
161
177 const Compy_HeaderMap *restrict headers,
178 CharSlice99 tag) COMPY_PRIV_MUST_USE;
179
192void compy_respond_option_not_supported(Compy_Context *ctx, CharSlice99 tag);
193
203uint32_t compy_interleaved_header(uint8_t channel_id, uint16_t payload_len)
204 COMPY_PRIV_MUST_USE;
205
220 const uint8_t data[restrict static 4], uint8_t *restrict channel_id,
221 uint16_t *restrict payload_len);
Possible parsing errors.
An RTSP header map.
Optional values.
#define COMPY_DEF_OPTION(...)
Defines a typed optional value.
Definition option.h:21
An RTP/RTCP channel pair specified as a range, e.g., interleaved=4-5.
Definition util.h:81
uint8_t rtp_channel
The RTP channel identifier.
Definition util.h:85
uint8_t rtcp_channel
The RTCP channel identifier.
Definition util.h:90
Definition context.c:10
An RTSP header map.
Definition header_map.h:37
An RTP/RTCP port pair specified as a range, e.g., client_port=3456-3457.
Definition util.h:59
uint16_t rtp_port
The RTP port.
Definition util.h:63
uint16_t rtcp_port
The RTCP port.
Definition util.h:68
The RTSP transport configuration.
Definition util.h:105
Compy_PortPairOption client_port
The client_port parameter, if present.
Definition util.h:129
Compy_ChannelPairOption interleaved
The interleaved parameter, if present.
Definition util.h:124
Compy_PortPairOption server_port
The server_port parameter, if present.
Definition util.h:134
Compy_LowerTransport lower
The lower level transport (TCP or UDP).
Definition util.h:109
bool unicast
True if the unicast parameter is present.
Definition util.h:114
bool multicast
True if the multicast parameter is present.
Definition util.h:119
uint32_t compy_interleaved_header(uint8_t channel_id, uint16_t payload_len) COMPY_PRIV_MUST_USE
Returns a four-octet interleaved binary data header.
Definition util.c:150
bool compy_require_has_tag(const Compy_HeaderMap *restrict headers, CharSlice99 tag) COMPY_PRIV_MUST_USE
Checks whether a Require header is present in headers and contains the feature tag tag.
Definition util.c:174
const char * Compy_LowerTransport_str(Compy_LowerTransport self)
Converts self to a string representation ("TCP" for Compy_LowerTransport_TCP and "UDP" for Compy_Lowe...
Definition util.c:16
void compy_respond_option_not_supported(Compy_Context *ctx, CharSlice99 tag)
Responds with 551 Option not supported and an Unsupported header listing tag.
Definition util.c:186
void compy_parse_interleaved_header(const uint8_t data[restrict static 4], uint8_t *restrict channel_id, uint16_t *restrict payload_len)
Parses an four-octet interleaved binary data header data.
Definition util.c:162
Compy_LowerTransport
An RTSP lower transport.
Definition util.h:38
@ Compy_LowerTransport_TCP
TCP.
Definition util.h:42
@ Compy_LowerTransport_UDP
UDP.
Definition util.h:47
int compy_parse_transport(Compy_TransportConfig *restrict config, CharSlice99 header_value) COMPY_PRIV_MUST_USE
Parses the Transport header.
Definition util.c:41