📦 Moves camera to own namespace
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
#include <CameraService.h>
|
#include <CameraService.h>
|
||||||
|
|
||||||
|
namespace Camera {
|
||||||
|
|
||||||
|
static const char *const TAG = "CameraService";
|
||||||
|
|
||||||
static const char *_STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
|
static const char *_STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
|
||||||
static const char *_STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
|
static const char *_STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
|
||||||
static const char *_STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
|
static const char *_STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
|
||||||
@@ -36,8 +40,8 @@ void CameraService::begin() {
|
|||||||
_securityManager->wrapRequest(std::bind(&CameraService::cameraStream, this, std::placeholders::_1),
|
_securityManager->wrapRequest(std::bind(&CameraService::cameraStream, this, std::placeholders::_1),
|
||||||
AuthenticationPredicates::IS_AUTHENTICATED));
|
AuthenticationPredicates::IS_AUTHENTICATED));
|
||||||
|
|
||||||
ESP_LOGV("CameraService", "Registered GET endpoint: %s", STILL_SERVICE_PATH);
|
ESP_LOGV(TAG, "Registered GET endpoint: %s", STILL_SERVICE_PATH);
|
||||||
ESP_LOGV("CameraService", "Registered GET endpoint: %s", STREAM_SERVICE_PATH);
|
ESP_LOGV(TAG, "Registered GET endpoint: %s", STREAM_SERVICE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t CameraService::InitializeCamera() {
|
esp_err_t CameraService::InitializeCamera() {
|
||||||
@@ -80,9 +84,9 @@ esp_err_t CameraService::InitializeCamera() {
|
|||||||
log_i("Initializing camera");
|
log_i("Initializing camera");
|
||||||
esp_err_t err = esp_camera_init(&camera_config);
|
esp_err_t err = esp_camera_init(&camera_config);
|
||||||
if (err == ESP_OK)
|
if (err == ESP_OK)
|
||||||
ESP_LOGI("CameraService", "Camera probe successful");
|
ESP_LOGI(TAG, "Camera probe successful");
|
||||||
else
|
else
|
||||||
ESP_LOGE("CameraService", "Camera probe failed with error 0x%x", err);
|
ESP_LOGE(TAG, "Camera probe failed with error 0x%x", err);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -90,7 +94,7 @@ esp_err_t CameraService::InitializeCamera() {
|
|||||||
esp_err_t CameraService::cameraStill(PsychicRequest *request) {
|
esp_err_t CameraService::cameraStill(PsychicRequest *request) {
|
||||||
camera_fb_t *fb = safe_camera_fb_get();
|
camera_fb_t *fb = safe_camera_fb_get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
ESP_LOGE("CameraService", "Camera capture failed");
|
ESP_LOGE(TAG, "Camera capture failed");
|
||||||
request->reply(500, "text/plain", "Camera capture failed");
|
request->reply(500, "text/plain", "Camera capture failed");
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
@@ -160,4 +164,6 @@ esp_err_t CameraService::cameraStream(PsychicRequest *request) {
|
|||||||
_taskManager->createTask(streamTask, "Stream client task", 4096, request, 4);
|
_taskManager->createTask(streamTask, "Stream client task", 4096, request, 4);
|
||||||
vTaskDelay(pdMS_TO_TICKS(100));
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Camera
|
||||||
@@ -6,10 +6,13 @@
|
|||||||
#include <SecurityManager.h>
|
#include <SecurityManager.h>
|
||||||
#include <TaskManager.h>
|
#include <TaskManager.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <esp_camera.h>
|
|
||||||
#include <async_worker.h>
|
#include <async_worker.h>
|
||||||
#include <Features.h>
|
#include <Features.h>
|
||||||
|
|
||||||
|
namespace Camera {
|
||||||
|
|
||||||
|
#include <esp_camera.h>
|
||||||
|
|
||||||
#if USE_CAMERA
|
#if USE_CAMERA
|
||||||
#include <CameraPins.h>
|
#include <CameraPins.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -37,5 +40,6 @@ class CameraService {
|
|||||||
esp_err_t cameraStream(PsychicRequest *request);
|
esp_err_t cameraStream(PsychicRequest *request);
|
||||||
esp_err_t InitializeCamera();
|
esp_err_t InitializeCamera();
|
||||||
};
|
};
|
||||||
|
} // namespace Camera
|
||||||
|
|
||||||
#endif // end CameraService_h
|
#endif // end CameraService_h
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef CameraSettingsService_h
|
#ifndef CameraSettingsService_h
|
||||||
#define CameraSettingsService_h
|
#define CameraSettingsService_h
|
||||||
|
|
||||||
|
namespace Camera {
|
||||||
|
|
||||||
#include <CameraService.h>
|
#include <CameraService.h>
|
||||||
#include <EventEndpoint.h>
|
#include <EventEndpoint.h>
|
||||||
#include <FSPersistence.h>
|
#include <FSPersistence.h>
|
||||||
@@ -203,4 +205,6 @@ class CameraSettingsService : public StatefulService<CameraSettings> {
|
|||||||
FSPersistence<CameraSettings> _fsPersistence;
|
FSPersistence<CameraSettings> _fsPersistence;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Camera
|
||||||
|
|
||||||
#endif // end CameraSettingsService_h
|
#endif // end CameraSettingsService_h
|
||||||
|
|||||||
@@ -111,9 +111,9 @@ class ESP32SvelteKit {
|
|||||||
MotionService *getMotionService() { return &_motionService; }
|
MotionService *getMotionService() { return &_motionService; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CameraService *getCameraService() { return &_cameraService; }
|
|
||||||
CameraSettingsService *getCameraSettingsService() { return &_cameraSettingsService; }
|
|
||||||
#if FT_ENABLED(USE_CAMERA)
|
#if FT_ENABLED(USE_CAMERA)
|
||||||
|
Camera::CameraService *getCameraService() { return &_cameraService; }
|
||||||
|
Camera::CameraSettingsService *getCameraSettingsService() { return &_cameraSettingsService; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Peripherals *getPeripherals() { return &_peripherals; }
|
Peripherals *getPeripherals() { return &_peripherals; }
|
||||||
@@ -171,9 +171,9 @@ class ESP32SvelteKit {
|
|||||||
#if FT_ENABLED(USE_MOTION)
|
#if FT_ENABLED(USE_MOTION)
|
||||||
MotionService _motionService;
|
MotionService _motionService;
|
||||||
#endif
|
#endif
|
||||||
CameraService _cameraService;
|
|
||||||
CameraSettingsService _cameraSettingsService;
|
|
||||||
#if FT_ENABLED(USE_CAMERA)
|
#if FT_ENABLED(USE_CAMERA)
|
||||||
|
Camera::CameraService _cameraService;
|
||||||
|
Camera::CameraSettingsService _cameraSettingsService;
|
||||||
#endif
|
#endif
|
||||||
Peripherals _peripherals;
|
Peripherals _peripherals;
|
||||||
ServoController _servoController;
|
ServoController _servoController;
|
||||||
|
|||||||
Reference in New Issue
Block a user