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

RTSP data transport (level 4) implementations. More...

#include <smolrtsp/droppable.h>
#include <smolrtsp/io_vec.h>
#include <smolrtsp/writer.h>
#include <interface99.h>
#include <smolrtsp/priv/compiler_attrs.h>
Include dependency graph for transport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SmolRTSP_Transport_IFACE
 A transport-level RTSP data transmitter. More...
 
#define SmolRTSP_Transport_EXTENDS   (SmolRTSP_Droppable)
 The superinterfaces of SmolRTSP_Transport_IFACE.
 

Functions

 interface99 (SmolRTSP_Transport)
 Defines the SmolRTSP_Transport interface. More...
 
SmolRTSP_Transport smolrtsp_transport_tcp (SmolRTSP_Writer w, uint8_t channel_id, size_t max_buffer) SMOLRTSP_PRIV_MUST_USE
 Creates a new TCP transport. More...
 
SmolRTSP_Transport smolrtsp_transport_udp (int fd) SMOLRTSP_PRIV_MUST_USE
 Creates a new UDP transport. More...
 
int smolrtsp_dgram_socket (int af, const void *restrict addr, uint16_t port) SMOLRTSP_PRIV_MUST_USE
 Creates a new datagram socket suitable for smolrtsp_transport_udp. More...
 
void * smolrtsp_sockaddr_ip (const struct sockaddr *restrict addr) SMOLRTSP_PRIV_MUST_USE
 Returns a pointer to the IP address of addr. More...
 

Detailed Description

RTSP data transport (level 4) implementations.

Macro Definition Documentation

◆ SmolRTSP_Transport_IFACE

#define SmolRTSP_Transport_IFACE
Value:
\
/* \
* Transmits a slice of I/O vectors @p bufs. \
* \
* @return -1 if an I/O error occurred and sets `errno` appropriately, 0 \
* on success. \
*/ \
vfunc99(int, transmit, VSelf99, SmolRTSP_IoVecSlice bufs) \
vfunc99(bool, is_full, VSelf99)

A transport-level RTSP data transmitter.

See Interface99 for the macro usage.

Function Documentation

◆ interface99()

interface99 ( SmolRTSP_Transport  )

Defines the SmolRTSP_Transport interface.

See Interface99 for the macro usage.

◆ smolrtsp_dgram_socket()

int smolrtsp_dgram_socket ( int  af,
const void *restrict  addr,
uint16_t  port 
)

Creates a new datagram socket suitable for smolrtsp_transport_udp.

The algorithm is:

  1. Create a socket using socket(af, SOCK_DGRAM, 0).
  2. Connect this socket to addr with port.
  3. Set the IP_PMTUDISC_WANT option to allow IP fragmentation.
Parameters
[in]afThe socket namespace. Can be AF_INET or AF_INET6; if none of them, returns -1 and sets errno to EAFNOSUPPORT.
[in]addrThe destination IP address: struct in_addr for AF_INET and struct in6_addr for AF_INET6.
[in]portThe destination IP port in the host byte order.
Returns
A valid file descriptor or -1 on error (and sets errno appropriately).

◆ smolrtsp_sockaddr_ip()

void* smolrtsp_sockaddr_ip ( const struct sockaddr *restrict  addr)

Returns a pointer to the IP address of addr.

Currently, only AF_INET and AF_INET6 are supported. Otherwise, NULL is returned.

Precondition
addr != NULL

◆ smolrtsp_transport_tcp()

SmolRTSP_Transport smolrtsp_transport_tcp ( SmolRTSP_Writer  w,
uint8_t  channel_id,
size_t  max_buffer 
)

Creates a new TCP transport.

Parameters
[in]wThe writer to be provided with data.
[in]channel_idA one-byte channel identifier, as defined in https://datatracker.ietf.org/doc/html/rfc2326#section-10.12.
Precondition
w.self && w.vptr

◆ smolrtsp_transport_udp()

SmolRTSP_Transport smolrtsp_transport_udp ( int  fd)

Creates a new UDP transport.

Strictly speaking, it can handle any datagram-oriented protocol, not necessarily UDP. E.g., you may use a SOCK_SEQPACKET socket for local communication.

Parameters
[in]fdThe socket file descriptor to be provided with data.
Precondition
fd >= 0