Introduce base Camera class to support alternative camera implementations (#9285)

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
This commit is contained in:
DT-art1
2025-07-07 15:45:00 +12:00
committed by GitHub
co-authored by J. Nick Koston J. Nick Koston
parent bdd52dbaa4
commit e49b89a051
27 changed files with 254 additions and 132 deletions
+6 -6
View File
@@ -158,16 +158,16 @@ void ComponentIterator::advance() {
}
break;
#endif
#ifdef USE_ESP32_CAMERA
#ifdef USE_CAMERA
case IteratorState::CAMERA:
if (esp32_camera::global_esp32_camera == nullptr) {
if (camera::Camera::instance() == nullptr) {
advance_platform = true;
} else {
if (esp32_camera::global_esp32_camera->is_internal() && !this->include_internal_) {
if (camera::Camera::instance()->is_internal() && !this->include_internal_) {
advance_platform = success = true;
break;
} else {
advance_platform = success = this->on_camera(esp32_camera::global_esp32_camera);
advance_platform = success = this->on_camera(camera::Camera::instance());
}
}
break;
@@ -386,8 +386,8 @@ bool ComponentIterator::on_begin() { return true; }
#ifdef USE_API
bool ComponentIterator::on_service(api::UserServiceDescriptor *service) { return true; }
#endif
#ifdef USE_ESP32_CAMERA
bool ComponentIterator::on_camera(esp32_camera::ESP32Camera *camera) { return true; }
#ifdef USE_CAMERA
bool ComponentIterator::on_camera(camera::Camera *camera) { return true; }
#endif
#ifdef USE_MEDIA_PLAYER
bool ComponentIterator::on_media_player(media_player::MediaPlayer *media_player) { return true; }
+5 -5
View File
@@ -4,8 +4,8 @@
#include "esphome/core/controller.h"
#include "esphome/core/helpers.h"
#ifdef USE_ESP32_CAMERA
#include "esphome/components/esp32_camera/esp32_camera.h"
#ifdef USE_CAMERA
#include "esphome/components/camera/camera.h"
#endif
namespace esphome {
@@ -48,8 +48,8 @@ class ComponentIterator {
#ifdef USE_API
virtual bool on_service(api::UserServiceDescriptor *service);
#endif
#ifdef USE_ESP32_CAMERA
virtual bool on_camera(esp32_camera::ESP32Camera *camera);
#ifdef USE_CAMERA
virtual bool on_camera(camera::Camera *camera);
#endif
#ifdef USE_CLIMATE
virtual bool on_climate(climate::Climate *climate) = 0;
@@ -125,7 +125,7 @@ class ComponentIterator {
#ifdef USE_API
SERVICE,
#endif
#ifdef USE_ESP32_CAMERA
#ifdef USE_CAMERA
CAMERA,
#endif
#ifdef USE_CLIMATE
+1 -1
View File
@@ -23,6 +23,7 @@
#define USE_AREAS
#define USE_BINARY_SENSOR
#define USE_BUTTON
#define USE_CAMERA
#define USE_CLIMATE
#define USE_COVER
#define USE_DATETIME
@@ -144,7 +145,6 @@
#define USE_ESP32_BLE
#define USE_ESP32_BLE_CLIENT
#define USE_ESP32_BLE_SERVER
#define USE_ESP32_CAMERA
#define USE_I2C
#define USE_IMPROV
#define USE_MICROPHONE