arduino-audio-tools
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
RTSPPlatform< TcpServer, TcpClient, UdpSocket > Class Template Reference

Template-based platform abstraction for RTSP networking. More...

#include <RTSPPlatform.h>

Public Types

using TcpClientType = TcpClient
 
using TcpServerType = TcpServer
 
using UdpSocketType = UdpSocket
 

Static Public Member Functions

static void closeSocket (TcpClient *s)
 Close a TCP socket connection.
 
static void closeUdpSocket (UdpSocket *s)
 Close a UDP socket.
 
static TcpServerType * createServer (uint16_t port)
 Create a TCP server listening on provided port.
 
static UdpSocket * createUdpSocket (unsigned short portNum)
 Create and bind a UDP socket.
 
static TcpClientType getAvailableClient (TcpServerType *srv)
 Get next available client from server.
 
static void getSocketPeerAddr (TcpClient *s, IPAddress *addr, uint16_t *port)
 Get remote peer address and port from TCP socket.
 
static int readSocket (TcpClient *sock, char *buf, size_t buflen, int timeoutmsec)
 Read from TCP socket with timeout.
 
static ssize_t sendSocket (TcpClient *sockfd, const void *buf, size_t len)
 Send data over TCP socket.
 
static ssize_t sendUdpSocket (UdpSocket *sockfd, const void *buf, size_t len, IPAddress destaddr, uint16_t destport)
 Send UDP packet to specified destination.
 

Static Public Attributes

static constexpr TcpClient * NULL_TCP_SOCKET = nullptr
 
static constexpr UdpSocket * NULL_UDP_SOCKET = nullptr
 

Detailed Description

template<typename TcpServer, typename TcpClient, typename UdpSocket>
class audio_tools::RTSPPlatform< TcpServer, TcpClient, UdpSocket >

Template-based platform abstraction for RTSP networking.

This template class provides a unified interface for network operations across different platforms while maintaining type safety. The template parameters allow customization of the underlying network implementation.

Template Parameters
TcpClientTCP client implementation (e.g., WiFiClient, EthernetClient)
UdpSocketUDP socket implementation (e.g., WiFiUDP, EthernetUDP)

Member Function Documentation

◆ closeSocket()

template<typename TcpServer , typename TcpClient , typename UdpSocket >
static void closeSocket ( TcpClient *  s)
inlinestatic

Close a TCP socket connection.

Parameters
sTCP socket to close

◆ closeUdpSocket()

template<typename TcpServer , typename TcpClient , typename UdpSocket >
static void closeUdpSocket ( UdpSocket *  s)
inlinestatic

Close a UDP socket.

Parameters
sUDP socket to close

◆ createUdpSocket()

template<typename TcpServer , typename TcpClient , typename UdpSocket >
static UdpSocket * createUdpSocket ( unsigned short  portNum)
inlinestatic

Create and bind a UDP socket.

Parameters
portNumPort number to bind to
Returns
Pointer to created UDP socket, or nullptr on failure

◆ getSocketPeerAddr()

template<typename TcpServer , typename TcpClient , typename UdpSocket >
static void getSocketPeerAddr ( TcpClient *  s,
IPAddress *  addr,
uint16_t *  port 
)
inlinestatic

Get remote peer address and port from TCP socket.

Parameters
sTCP socket
addrOutput parameter for remote IP address
portOutput parameter for remote port

◆ readSocket()

template<typename TcpServer , typename TcpClient , typename UdpSocket >
static int readSocket ( TcpClient *  sock,
char *  buf,
size_t  buflen,
int  timeoutmsec 
)
inlinestatic

Read from TCP socket with timeout.

Parameters
sockTCP socket
bufBuffer to read into
buflenBuffer length
timeoutmsecTimeout in milliseconds
Returns
0=socket closed, -1=timeout, >0=number of bytes read

◆ sendSocket()

template<typename TcpServer , typename TcpClient , typename UdpSocket >
static ssize_t sendSocket ( TcpClient *  sockfd,
const void *  buf,
size_t  len 
)
inlinestatic

Send data over TCP socket.

Parameters
sockfdTCP socket
bufData buffer to send
lenLength of data
Returns
Number of bytes sent

◆ sendUdpSocket()

template<typename TcpServer , typename TcpClient , typename UdpSocket >
static ssize_t sendUdpSocket ( UdpSocket *  sockfd,
const void *  buf,
size_t  len,
IPAddress  destaddr,
uint16_t  destport 
)
inlinestatic

Send UDP packet to specified destination.

Parameters
sockfdUDP socket
bufData buffer to send
lenLength of data
destaddrDestination IP address
destportDestination port
Returns
Number of bytes sent

The documentation for this class was generated from the following file: