Skip to content

Commit

Permalink
asyncweb: reduce wait between SEND and CAPTURE
Browse files Browse the repository at this point in the history
refs #34
  • Loading branch information
yoursunny committed Jun 18, 2024
1 parent e44930c commit 00d1ddb
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/esp32cam-asyncweb.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ class MjpegResponse : public AsyncAbstractResponse {
size_t _fillBuffer(uint8_t* buf, size_t buflen) override {
auto act = m_ctrl.decideAction();
switch (act) {
case Ctrl::CAPTURE: {
xTaskNotify(m_task, 1, eSetValueWithOverwrite);
m_ctrl.notifyCapture();
ESP32CAM_ASYNCWEB_MJPEG_LOG("capturing");
return RESPONSE_TRY_AGAIN;
}
case Ctrl::RETURN: {
Frame* frame = nullptr;
if (xQueueReceive(m_queue, &frame, 0) == pdTRUE) {
Expand All @@ -187,6 +181,7 @@ class MjpegResponse : public AsyncAbstractResponse {
}
m_sendNext = SIPartHeader;
m_sendRemain = 0;

if (m_ctrl.decideAction() != Ctrl::SEND) {
return RESPONSE_TRY_AGAIN;
}
Expand All @@ -197,9 +192,20 @@ class MjpegResponse : public AsyncAbstractResponse {
if (len == 0 && m_sendNext == SINone) {
m_ctrl.notifySent(true);
ESP32CAM_ASYNCWEB_MJPEG_LOG("sent to client");
} else {
return len;
}

if (m_ctrl.decideAction() != Ctrl::CAPTURE) {
return RESPONSE_TRY_AGAIN;
}
return len;
// fallthrough
}
case Ctrl::CAPTURE: {
xTaskNotify(m_task, 1, eSetValueWithOverwrite);
m_ctrl.notifyCapture();
ESP32CAM_ASYNCWEB_MJPEG_LOG("capturing");
return RESPONSE_TRY_AGAIN;
}
case Ctrl::STOP:
ESP32CAM_ASYNCWEB_MJPEG_LOG("stopping");
Expand Down

0 comments on commit 00d1ddb

Please sign in to comment.