From 12ca367d0f097a9304cb84c339139cf454bff8f6 Mon Sep 17 00:00:00 2001 From: Junxiao Shi Date: Tue, 7 Jan 2025 06:29:43 -0500 Subject: [PATCH] mjpeg: MjpegController logging --- src/esp32cam/asyncweb.cpp | 4 ---- src/esp32cam/camera.cpp | 4 ---- src/esp32cam/mjpeg.cpp | 9 ++++++++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/esp32cam/asyncweb.cpp b/src/esp32cam/asyncweb.cpp index e3b30c1..3d58250 100644 --- a/src/esp32cam/asyncweb.cpp +++ b/src/esp32cam/asyncweb.cpp @@ -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; @@ -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; } @@ -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; diff --git a/src/esp32cam/camera.cpp b/src/esp32cam/camera.cpp index e503038..f376907 100644 --- a/src/esp32cam/camera.cpp +++ b/src/esp32cam/camera.cpp @@ -5,10 +5,6 @@ namespace esp32cam { -// extern ESP32CAM_SPECIALIZE_SENSOR_SETTING(framesize_t, framesize_t); - -// static SensorSetting frameSize(ESP32CAM_SENSOR_OFFSETS(framesize)); - Print* LogOutput = nullptr; CameraClass Camera; diff --git a/src/esp32cam/mjpeg.cpp b/src/esp32cam/mjpeg.cpp index e7dc731..17235e6 100644 --- a/src/esp32cam/mjpeg.cpp +++ b/src/esp32cam/mjpeg.cpp @@ -1,6 +1,7 @@ #include "mjpeg.hpp" +#include "logger.hpp" -#include +#define MC_LOG(fmt, ...) ESP32CAM_LOG("MjpegController(%p) " fmt, this, ##__VA_ARGS__) namespace esp32cam { namespace detail { @@ -25,21 +26,26 @@ void MjpegController::notifyCapture() { m_nextAction = RETURN; m_nextCaptureTime = millis() + static_cast(m_cfg.minInterval); + MC_LOG("notifyCapture next=%lu", m_nextCaptureTime); } void MjpegController::notifyReturn(std::unique_ptr 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(ok)); if (!ok) { notifyFail(); return; @@ -50,6 +56,7 @@ MjpegController::notifySent(bool ok) { void MjpegController::notifyFail() { + MC_LOG("notifyFail"); m_frame.reset(); m_nextAction = STOP; }