mirror of
https://github.com/rzeldent/esp32cam-rtsp.git
synced 2025-11-17 21:48:00 +00:00
Added checks for snapshot
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -150,13 +150,19 @@ void handle_snapshot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
cam.run();
|
cam.run();
|
||||||
|
if (cam.getSize() == 0 || cam.getfb() == nullptr)
|
||||||
|
{
|
||||||
|
web_server.send(404, "text/plain", "Unable to obtain framebuffer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto fb_len = cam.getSize();
|
auto fb_len = cam.getSize();
|
||||||
auto fb = (const char*)memcpy(new uint8_t[fb_len], cam.getfb(), fb_len);
|
auto fb = (const char *)memcpy(new uint8_t[fb_len], cam.getfb(), fb_len);
|
||||||
web_server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
web_server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||||
web_server.setContentLength(fb_len);
|
web_server.setContentLength(fb_len);
|
||||||
web_server.send(200, "image/jpeg", "");
|
web_server.send(200, "image/jpeg", "");
|
||||||
web_server.sendContent(fb, fb_len);
|
web_server.sendContent(fb, fb_len);
|
||||||
delete []fb;
|
delete[] fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_config_saved()
|
void on_config_saved()
|
||||||
|
|||||||
Reference in New Issue
Block a user