arduino-audio-tools
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RTSPServer< Platform > Class Template Reference

RTSP Server - Multi-client Audio Streaming Server. More...

#include <RTSPServer.h>

Public Types

using streamer_t = RTSPAudioStreamerBase< Platform >
 

Public Member Functions

 RTSPServer (streamer_t &streamer, int port=8554, int core=1)
 Construct RTSP server.
 
 ~RTSPServer ()
 Destructor - ensures proper cleanup of server resources.
 
bool begin ()
 
bool begin (const char *ssid, const char *password)
 Initialize WiFi and start RTSP server.
 
int clientCount ()
 
audio_tools::TaskgetTaskHandle ()
 
 operator bool ()
 

Protected Member Functions

bool runAsync ()
 Start RTSP server asynchronously.
 
void serverThreadLoop ()
 Main server thread loop - listens for RTSP client connections.
 
void sessionThreadLoop ()
 Client session thread loop - handles RTSP protocol for individual clients.
 
void stop ()
 Stop the RTSP server and cleanup resources.
 

Protected Attributes

Platform::TcpClientType client
 
int client_count = 0
 
int core
 
int port
 
Platform::TcpServerType * server = nullptr
 
audio_tools::Task serverTask {"RTSPServerThread", 15000, 5, core}
 
audio_tools::Task sessionTask {"RTSPSessionTask", 15000, 8, core}
 
streamer_tstreamer = nullptr
 

Detailed Description

template<typename Platform>
class audio_tools::RTSPServer< Platform >

RTSP Server - Multi-client Audio Streaming Server.

The RTSPServer class implements a complete RTSP (Real Time Streaming Protocol) server that manages client connections and coordinates audio streaming sessions. This server:

RTSP Protocol Support

Note
Supports multiple platforms through AudioTools Task and Timer systems
Author
Thomas Pfitzinger
Version
0.2.0

Constructor & Destructor Documentation

◆ RTSPServer()

template<typename Platform >
RTSPServer ( streamer_t streamer,
int  port = 8554,
int  core = 1 
)
inline

Construct RTSP server.

Creates a new RTSP server instance configured to work with the specified RTSPAudioStreamer. The server will listen for client connections and coordinate streaming sessions.

Parameters
streamerPointer to RTSPAudioStreamer that provides the audio data source. Must remain valid for the server's lifetime.
portTCP port number for RTSP connections (default 8554 - standard RTSP port)
coreCore number to run server tasks on (platform-specific, default 1)
Note
The RTSPAudioStreamer must be properly configured with an audio source
Port 8554 is the IANA-assigned port for RTSP
See also
begin(), runAsync()

Member Function Documentation

◆ begin() [1/2]

template<typename Platform >
bool begin ( )
inline

Start the RTSP server

◆ begin() [2/2]

template<typename Platform >
bool begin ( const char *  ssid,
const char *  password 
)
inline

Initialize WiFi and start RTSP server.

Convenience method that connects to a WiFi network and then starts the RTSP server. This method blocks until WiFi connection is established, then starts the server asynchronously.

Parameters
ssidWiFi network name to connect to
passwordWiFi network password
Returns
0 on success, non-zero on failure
Note
Blocks until WiFi connection is established
Automatically calls runAsync() after WiFi setup
See also
runAsync()

◆ runAsync()

template<typename Platform >
bool runAsync ( )
inlineprotected

Start RTSP server asynchronously.

Begins listening for RTSP client connections on the configured port. The server runs in a separate FreeRTOS task, allowing the main program to continue executing. Client sessions are handled in additional tasks.

Returns
true on success, false on failure
Note
WiFi must be connected before calling this method
Server runs on the configured core (if platform supports it)
Use this method when WiFi is already established
See also
begin() for WiFi setup + server start

◆ serverThreadLoop()

template<typename Platform >
void serverThreadLoop ( )
inlineprotected

Main server thread loop - listens for RTSP client connections.

This member method implements the main server loop. It accepts incoming TCP connections from RTSP clients and creates session threads to handle each client's RTSP protocol communication.

Note
Currently supports one client at a time (single-threaded sessions)
Runs indefinitely in the task loop
Creates sessionThread tasks for each accepted client

◆ sessionThreadLoop()

template<typename Platform >
void sessionThreadLoop ( )
inlineprotected

Client session thread loop - handles RTSP protocol for individual clients.

This member method runs in a dedicated Task for each connected client. It creates an RTSPSession object and processes RTSP requests (DESCRIBE, SETUP, PLAY, TEARDOWN) until the client disconnects or an error occurs.

Note
Each client gets its own session thread
Thread automatically terminates when client disconnects
Manages RTSPSession lifecycle and socket cleanup

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