mirror of
https://github.com/rzeldent/esp32cam-rtsp.git
synced 2025-11-14 12:08:02 +00:00
Merge pull request #28 from rzeldent/bugfix/snapshot_update
Bugfix/snapshot update
This commit is contained in:
15
src/main.cpp
15
src/main.cpp
@@ -149,19 +149,23 @@ void handle_snapshot()
|
||||
return;
|
||||
}
|
||||
|
||||
if (cam.getfb() == nullptr)
|
||||
// Remove old images stored in the framebuffer
|
||||
auto frame_buffers = atoi(frame_buffers_val);
|
||||
while (frame_buffers--)
|
||||
cam.run();
|
||||
|
||||
auto fb_len = cam.getSize();
|
||||
auto fb = (const char*)cam.getfb();
|
||||
if (fb == nullptr)
|
||||
{
|
||||
web_server.send(404, "text/plain", "Unable to obtain frame buffer from the camera");
|
||||
return;
|
||||
}
|
||||
|
||||
auto fb_len = cam.getSize();
|
||||
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.setContentLength(fb_len);
|
||||
web_server.send(200, "image/jpeg", "");
|
||||
web_server.sendContent(fb, fb_len);
|
||||
delete[] fb;
|
||||
}
|
||||
|
||||
void handle_flash()
|
||||
@@ -188,7 +192,6 @@ void on_config_saved()
|
||||
log_v("on_config_saved");
|
||||
// Set flash led intensity
|
||||
analogWrite(LED_FLASH, atoi(flash_led_intensity_val));
|
||||
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
@@ -219,7 +222,7 @@ void start_rtsp_server()
|
||||
camera_init_result = initialize_camera();
|
||||
if (camera_init_result != ESP_OK)
|
||||
{
|
||||
log_e("Failed to initialize camera: 0x%0xd. Type: %s, frame size: %s, frame buffers: %s, frame rate: %s ms, jpeg quality: %s", camera_init_result, camera_config_val, frame_size_val, frame_buffers_val, frame_duration_val, jpeg_quality_val);
|
||||
log_e("Failed to initialize camera: 0x%0x. Type: %s, frame size: %s, frame buffers: %s, frame rate: %s ms, jpeg quality: %s", camera_init_result, camera_config_val, frame_size_val, frame_buffers_val, frame_duration_val, jpeg_quality_val);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user