Skip to content

Commit 21d9a34

Browse files
committed
RTSPServerBase: comments
1 parent b820476 commit 21d9a34

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/AudioTools/Communication/RTSP/RTSPServerBase.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,23 @@ namespace audio_tools {
2828
template <typename Platform>
2929
class RTSPServerBase {
3030
public:
31+
/// Constructor
3132
RTSPServerBase(RTSPAudioStreamerBase<Platform>& streamer, int port = 8554)
3233
: streamer(&streamer), port(port) {
3334
server = nullptr;
3435
}
3536

37+
/// Destructor
3638
~RTSPServerBase() { stop(); }
3739

40+
/// Set callback for session path
3841
void setOnSessionPath(bool (*cb)(const char* path, void* ref), void* ref = nullptr) {
3942
onSessionPathCb = cb;
4043
onSessionPathRef = ref;
4144
}
4245

4346
#ifdef ESP32
47+
/// Start server and connect to WiFi (ESP32 only)
4448
bool begin(const char* ssid, const char* password) {
4549
WiFi.begin(ssid, password);
4650
while (WiFi.status() != WL_CONNECTED) {
@@ -58,6 +62,7 @@ class RTSPServerBase {
5862
}
5963
#endif
6064

65+
/// Start server
6166
virtual bool begin() {
6267
streamer->initAudioSource();
6368
if (server == nullptr) {
@@ -67,6 +72,7 @@ class RTSPServerBase {
6772
return server != nullptr;
6873
}
6974

75+
/// Stop server and clean up
7076
void end() {
7177
if (server) {
7278
delete server;
@@ -79,8 +85,11 @@ class RTSPServerBase {
7985
}
8086
}
8187

88+
/// Get number of connected clients
8289
int clientCount() { return client_count; }
90+
/// Returns true if any client is connected
8391
operator bool() { return client_count > 0; }
92+
/// Set session timeout in milliseconds
8493
void setSessionTimeoutMs(unsigned long ms) { sessionTimeoutMs = ms; }
8594

8695
protected:
@@ -95,7 +104,7 @@ class RTSPServerBase {
95104
unsigned long sessionTimeoutMs = 60000; // 60 seconds
96105
unsigned long lastRequestTime = 0;
97106

98-
// Accept new client if none is active
107+
/// Accept new client if none is active
99108
void acceptClient() {
100109
if (client_count == 0 && server) {
101110
auto newClient = Platform::getAvailableClient(server);
@@ -112,7 +121,7 @@ class RTSPServerBase {
112121
}
113122
}
114123

115-
// Handle session if active
124+
/// Handle requests session if active
116125
void handleSession() {
117126
if (client_count > 0 && rtspSession) {
118127
uint32_t timeout = 30;
@@ -125,10 +134,6 @@ class RTSPServerBase {
125134
if ((millis() - lastRequestTime) > sessionTimeoutMs) {
126135
// Timeout, mark session closed
127136
rtspSession->closeSession();
128-
/* If you want to trigger cleanup, you could also call:
129-
rtspSession->handleRtspTeardown();
130-
(if public, or expose a public method for teardown)
131-
*/
132137
}
133138
}
134139
// Clean up if session closed

0 commit comments

Comments
 (0)