Compy 0.2.0
A lightweight RTSP 1.0 server library for embedded systems
Loading...
Searching...
No Matches
transport.h File Reference

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

#include <compy/droppable.h>
#include <compy/io_vec.h>
#include <compy/writer.h>
#include <interface99.h>
#include <compy/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 Compy_Transport_IFACE
 A transport-level RTSP data transmitter.
 
#define Compy_Transport_EXTENDS   (Compy_Droppable)
 The superinterfaces of Compy_Transport_IFACE.
 

Functions

 interface99 (Compy_Transport)
 Defines the Compy_Transport interface.
 
Compy_Transport compy_transport_tcp (Compy_Writer w, uint8_t channel_id, size_t max_buffer) COMPY_PRIV_MUST_USE
 Creates a new TCP transport.
 
Compy_Transport compy_transport_udp (int fd) COMPY_PRIV_MUST_USE
 Creates a new UDP transport.
 
int compy_dgram_socket (int af, const void *restrict addr, uint16_t port) COMPY_PRIV_MUST_USE
 Creates a new datagram socket suitable for compy_transport_udp.
 
int compy_recv_dgram_socket (int af, uint16_t port) COMPY_PRIV_MUST_USE
 Creates a new datagram socket bound to a local port for receiving.
 
void * compy_sockaddr_ip (const struct sockaddr *restrict addr) COMPY_PRIV_MUST_USE
 Returns a pointer to the IP address of addr.
 

Detailed Description

RTSP data transport (level 4) implementations.

Macro Definition Documentation

◆ Compy_Transport_IFACE

#define Compy_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, Compy_IoVecSlice bufs) \
vfunc99(bool, is_full, VSelf99)

A transport-level RTSP data transmitter.

See Interface99 for the macro usage.

Function Documentation

◆ compy_dgram_socket()

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

Creates a new datagram socket suitable for compy_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).

◆ compy_recv_dgram_socket()

int compy_recv_dgram_socket ( int  af,
uint16_t  port 
)

Creates a new datagram socket bound to a local port for receiving.

Mirrors compy_dgram_socket (which creates a connected send socket). Suitable for receiving backchannel RTP or RTCP data.

Parameters
[in]afThe address family (AF_INET or AF_INET6).
[in]portThe local port to bind to (host byte order).
Returns
A valid file descriptor or -1 on error.

◆ compy_sockaddr_ip()

void * compy_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

◆ compy_transport_tcp()

Compy_Transport compy_transport_tcp ( Compy_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

◆ compy_transport_udp()

Compy_Transport compy_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

◆ interface99()

interface99 ( Compy_Transport  )

Defines the Compy_Transport interface.

See Interface99 for the macro usage.