9#include "RTSPSession.h"
10#include "RTSPAudioStreamer.h"
28template <
typename Platform>
33 : streamer(&streamer), port(port) {
43 onSessionPathRef = ref;
48 bool begin(
const char* ssid,
const char* password) {
49 WiFi.begin(ssid, password);
50 while (WiFi.status() != WL_CONNECTED) {
54 WiFi.setSleep(WIFI_PS_NONE);
56 Serial.print(
"connect to rtsp://");
57 Serial.print(WiFi.localIP());
67 streamer->initAudioSource();
68 if (server ==
nullptr) {
69 server = Platform::createServer(port);
70 LOGI(
"RTSP server started on port %d", port);
72 return server !=
nullptr;
84 rtspSession =
nullptr;
91 operator bool() {
return client_count > 0; }
97 typename Platform::TcpServerType* server =
nullptr;
98 typename Platform::TcpClientType client;
100 int client_count = 0;
102 bool (*onSessionPathCb)(
const char*,
void*) =
nullptr;
103 void* onSessionPathRef =
nullptr;
104 unsigned long sessionTimeoutMs = 60000;
105 unsigned long lastRequestTime = 0;
109 if (client_count == 0 && server) {
110 auto newClient = Platform::getAvailableClient(server);
111 if (newClient.connected()) {
116 if (onSessionPathCb) {
119 lastRequestTime =
millis();
126 if (client_count > 0 && rtspSession) {
127 uint32_t timeout = 30;
130 lastRequestTime =
millis();
133 if (sessionTimeoutMs > 0 && rtspSession->isStreaming()) {
134 if ((
millis() - lastRequestTime) > sessionTimeoutMs) {
140 if (!rtspSession->isSessionOpen()) {
142 rtspSession =
nullptr;
143 if (client.connected()) {
144 Platform::closeSocket(&client);
void stop()
stops any further processing by spinning in an endless loop
Definition AudioRuntime.h:12