SmolRTSP  0.1.3
A small, portable, extensible RTSP 1.0 implementation in C99
util.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <smolrtsp/option.h>
9 #include <smolrtsp/types/error.h>
10 
11 #include <stdint.h>
12 
13 #include <slice99.h>
14 
18 #define SMOLRTSP_CRLF (CharSlice99_from_str("\r\n"))
19 
23 #define SMOLRTSP_DEFAULT_PORT 554
24 
28 typedef enum {
33 
39 
45 
49 typedef struct {
53  uint16_t rtp_port;
54 
58  uint16_t rtcp_port;
60 
67 
71 typedef struct {
75  uint8_t rtp_channel;
76 
80  uint8_t rtcp_channel;
82 
89 
95 typedef struct {
100 
104  bool unicast;
105 
109  bool multicast;
110 
114  SmolRTSP_ChannelPairOption interleaved;
115 
119  SmolRTSP_PortPairOption client_port;
121 
135  SmolRTSP_TransportConfig *restrict config,
136  CharSlice99 header_value) SMOLRTSP_PRIV_MUST_USE;
137 
147 uint32_t smolrtsp_interleaved_header(uint8_t channel_id, uint16_t payload_len)
148  SMOLRTSP_PRIV_MUST_USE;
149 
164  const uint8_t data[restrict static 4], uint8_t *restrict channel_id,
165  uint16_t *restrict payload_len);
Possible parsing errors.
Optional values.
An RTP/RTCP channel pair specified as a range, e.g., interleaved=4-5.
Definition: util.h:71
uint8_t rtcp_channel
The RTCP channel identifier.
Definition: util.h:80
uint8_t rtp_channel
The RTP channel identifier.
Definition: util.h:75
An RTP/RTCP port pair specified as a range, e.g., client_port=3456-3457.
Definition: util.h:49
uint16_t rtcp_port
The RTCP port.
Definition: util.h:58
uint16_t rtp_port
The RTP port.
Definition: util.h:53
The RTSP transport configuration.
Definition: util.h:95
bool multicast
True if the multicast parameter is present.
Definition: util.h:109
SmolRTSP_ChannelPairOption interleaved
The interleaved parameter, if present.
Definition: util.h:114
SmolRTSP_LowerTransport lower
The lower level transport (TCP or UDP).
Definition: util.h:99
SmolRTSP_PortPairOption client_port
The client_port parameter, if present.
Definition: util.h:119
bool unicast
True if the unicast parameter is present.
Definition: util.h:104
SmolRTSP_LowerTransport
An RTSP lower transport.
Definition: util.h:28
@ SmolRTSP_LowerTransport_TCP
TCP.
Definition: util.h:32
@ SmolRTSP_LowerTransport_UDP
UDP.
Definition: util.h:37
SMOLRTSP_DEF_OPTION(SmolRTSP_PortPair)
Defines SmolRTSP_PortPairOption.
int smolrtsp_parse_transport(SmolRTSP_TransportConfig *restrict config, CharSlice99 header_value) SMOLRTSP_PRIV_MUST_USE
Parses the Transport header.
const char * SmolRTSP_LowerTransport_str(SmolRTSP_LowerTransport self)
Converts self to a string representation ("TCP" for SmolRTSP_LowerTransport_TCP and "UDP" for SmolRTS...
uint32_t smolrtsp_interleaved_header(uint8_t channel_id, uint16_t payload_len) SMOLRTSP_PRIV_MUST_USE
Returns a four-octet interleaved binary data header.
void smolrtsp_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.