Skip to content

Commit

Permalink
mjpeg: MjpegController logging
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed Jan 7, 2025
1 parent e7d68e6 commit 12ca367
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/esp32cam/asyncweb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ MjpegResponse::_fillBuffer(uint8_t* buf, size_t buflen) {
switch (act) {
case Ctrl::RETURN: {
if (auto frame = m_task.retrieve(); frame) {
MJPEG_LOG("frame has %zu octets", frame->size());
m_ctrl.notifyReturn(std::move(frame));
}
m_sendNext = SIPartHeader;
Expand All @@ -160,7 +159,6 @@ MjpegResponse::_fillBuffer(uint8_t* buf, size_t buflen) {
size_t len = sendPart(buf, buflen);
if (len == 0 && m_sendNext == SINone) {
m_ctrl.notifySent(true);
MJPEG_LOG("sent to client");
} else {
return len;
}
Expand All @@ -173,11 +171,9 @@ MjpegResponse::_fillBuffer(uint8_t* buf, size_t buflen) {
case Ctrl::CAPTURE: {
m_task.request();
m_ctrl.notifyCapture();
MJPEG_LOG("capturing");
return RESPONSE_TRY_AGAIN;
}
case Ctrl::STOP:
MJPEG_LOG("stopping");
return 0;
default:
return RESPONSE_TRY_AGAIN;
Expand Down
4 changes: 0 additions & 4 deletions src/esp32cam/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

namespace esp32cam {

// extern ESP32CAM_SPECIALIZE_SENSOR_SETTING(framesize_t, framesize_t);

// static SensorSetting<framesize_t, framesize_t> frameSize(ESP32CAM_SENSOR_OFFSETS(framesize));

Print* LogOutput = nullptr;
CameraClass Camera;

Expand Down
9 changes: 8 additions & 1 deletion src/esp32cam/mjpeg.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mjpeg.hpp"
#include "logger.hpp"

#include <Arduino.h>
#define MC_LOG(fmt, ...) ESP32CAM_LOG("MjpegController(%p) " fmt, this, ##__VA_ARGS__)

namespace esp32cam {
namespace detail {
Expand All @@ -25,21 +26,26 @@ void
MjpegController::notifyCapture() {
m_nextAction = RETURN;
m_nextCaptureTime = millis() + static_cast<unsigned long>(m_cfg.minInterval);
MC_LOG("notifyCapture next=%lu", m_nextCaptureTime);
}

void
MjpegController::notifyReturn(std::unique_ptr<Frame> frame) {
if (frame == nullptr) {
MC_LOG("notifyReturn frame=nullptr");
notifyFail();
return;
}
m_frame = std::move(frame);
MC_LOG("notifyReturn frame=%p size=%zu dimension=%dx%d", m_frame->data(), m_frame->size(),
m_frame->getWidth(), m_frame->getHeight());
m_nextAction = SEND;
}

void
MjpegController::notifySent(bool ok) {
++m_count;
MC_LOG("notifySent count=%d ok=%d", m_count, static_cast<int>(ok));
if (!ok) {
notifyFail();
return;
Expand All @@ -50,6 +56,7 @@ MjpegController::notifySent(bool ok) {

void
MjpegController::notifyFail() {
MC_LOG("notifyFail");
m_frame.reset();
m_nextAction = STOP;
}
Expand Down

0 comments on commit 12ca367

Please sign in to comment.