rtsp_server.cpp

This commit is contained in:
John Varghese
2025-06-03 18:44:55 +05:30
committed by GitHub
parent 03b14d3d0c
commit 71026fbd49

View File

@@ -0,0 +1,30 @@
#include "rtsp_server.h"
#include <WiFi.h>
#include "OV2640.h"
#include "CRtspSession.h"
WiFiServer rtspServer(554);
OV2640 cam;
String getRTSPUrl() {
return "rtsp://" + WiFi.localIP().toString() + ":554/mjpeg/1";
}
void rtsp_server_start() {
rtspServer.begin();
cam.init(esp_camera_sensor_get());
Serial.println("[INFO] RTSP server started at " + getRTSPUrl());
}
void rtsp_server_loop() {
WiFiClient client = rtspServer.available();
if (client) {
CRtspSession session(client, cam);
while (client.connected()) {
session.handleRequests(0);
session.broadcastCurrentFrame(0);
delay(10);
}
client.stop();
}
}