SmolRTSP  0.1.3
A small, portable, extensible RTSP 1.0 implementation in C99
util.h File Reference

Utilitary stuff. More...

#include <smolrtsp/option.h>
#include <smolrtsp/types/error.h>
#include <stdint.h>
#include <slice99.h>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SmolRTSP_PortPair
 An RTP/RTCP port pair specified as a range, e.g., client_port=3456-3457. More...
 
struct  SmolRTSP_ChannelPair
 An RTP/RTCP channel pair specified as a range, e.g., interleaved=4-5. More...
 
struct  SmolRTSP_TransportConfig
 The RTSP transport configuration. More...
 

Macros

#define SMOLRTSP_CRLF   (CharSlice99_from_str("\r\n"))
 Carriage-return + new-line represented as a data slice.
 
#define SMOLRTSP_DEFAULT_PORT   554
 The default RTSP port.
 

Enumerations

enum  SmolRTSP_LowerTransport { SmolRTSP_LowerTransport_TCP , SmolRTSP_LowerTransport_UDP }
 An RTSP lower transport. More...
 

Functions

const char * SmolRTSP_LowerTransport_str (SmolRTSP_LowerTransport self)
 Converts self to a string representation ("TCP" for SmolRTSP_LowerTransport_TCP and "UDP" for SmolRTSP_LowerTransport_UDP).
 
 SMOLRTSP_DEF_OPTION (SmolRTSP_PortPair)
 Defines SmolRTSP_PortPairOption. More...
 
 SMOLRTSP_DEF_OPTION (SmolRTSP_ChannelPair)
 Defines SmolRTSP_ChannelPairOption. More...
 
int smolrtsp_parse_transport (SmolRTSP_TransportConfig *restrict config, CharSlice99 header_value) SMOLRTSP_PRIV_MUST_USE
 Parses the Transport header. More...
 
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. More...
 
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. More...
 

Detailed Description

Utilitary stuff.

Enumeration Type Documentation

◆ SmolRTSP_LowerTransport

An RTSP lower transport.

Enumerator
SmolRTSP_LowerTransport_TCP 

TCP.

SmolRTSP_LowerTransport_UDP 

UDP.

Function Documentation

◆ SMOLRTSP_DEF_OPTION() [1/2]

SMOLRTSP_DEF_OPTION ( SmolRTSP_ChannelPair  )

Defines SmolRTSP_ChannelPairOption.

See Datatype99 for the macro usage.

◆ SMOLRTSP_DEF_OPTION() [2/2]

SMOLRTSP_DEF_OPTION ( SmolRTSP_PortPair  )

Defines SmolRTSP_PortPairOption.

See Datatype99 for the macro usage.

◆ smolrtsp_interleaved_header()

uint32_t smolrtsp_interleaved_header ( uint8_t  channel_id,
uint16_t  payload_len 
)

Returns a four-octet interleaved binary data header.

Parameters
[in]channel_idThe one-byte channel identifier.
[in]payload_lenThe length of the encapsulated binary data (network byte order).
See also
https://datatracker.ietf.org/doc/html/rfc2326#section-10.12

◆ smolrtsp_parse_interleaved_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.

Parameters
[in]dataThe header to parse.
[out]channel_idThe one-byte channel identifier.
[out]payload_lenThe length of the encapsulated binary data (host byte order).
Precondition
channel_id != NULL
payload_len != NULL
See also
https://datatracker.ietf.org/doc/html/rfc2326#section-10.12

◆ smolrtsp_parse_transport()

int smolrtsp_parse_transport ( SmolRTSP_TransportConfig *restrict  config,
CharSlice99  header_value 
)

Parses the Transport header.

Parameters
[out]configThe result of parsing. It remains unchanged on failure.
[in]header_valueThe value of the Transport header.
Returns
0 on success, -1 on failure.
Precondition
config != NULL