11#include "RTSPAudioStreamer.h"
12#include "RTSPServerBase.h"
17#include "AudioTools/Concurrency/RTOS.h"
39template <
typename Platform>
51 bool begin(
const char* ssid,
const char* password) {
58 if (!serverTask.begin([
this]() { serverThreadLoop(); })) {
59 LOGE(
"Couldn't start server thread");
76 void serverThreadLoop() {
77 unsigned long lastCheck =
millis();
78 LOGD(
"Server thread listening... (numClients: %d)", this->client_count);
79 int prevClientCount = this->client_count;
82 if (this->client_count > prevClientCount) {
83 LOGI(
"Client connected");
84 if (!sessionTask.begin([
this]() { sessionThreadLoop(); })) {
85 LOGE(
"Couldn't start sessionThread");
86 Platform::closeSocket(&this->client);
89 LOGI(
"Number of clients: %d", this->client_count);
91 }
else if (this->client_count > 0) {
92 LOGD(
"Waiting for current session to end (numClients: %d)", this->client_count);
94 int time = 200 - (
millis() - lastCheck);
95 if (time < 0) time = 0;
99 void sessionThreadLoop() {
100 LOGD(
"RTSP Task running");
101 while (this->rtspSession && this->rtspSession->isSessionOpen()) {
106 LOGI(
"Session cleaned up: (numClients: %d)", this->client_count);