ESPHome  2024.12.2
camera_web_server.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef USE_ESP32
4 
5 #include <cinttypes>
6 #include <freertos/FreeRTOS.h>
7 #include <freertos/semphr.h>
8 
10 #include "esphome/core/component.h"
11 #include "esphome/core/helpers.h"
13 
14 struct httpd_req; // NOLINT(readability-identifier-naming)
15 
16 namespace esphome {
17 namespace esp32_camera_web_server {
18 
19 enum Mode { STREAM, SNAPSHOT };
20 
21 class CameraWebServer : public Component {
22  public:
25 
26  void setup() override;
27  void on_shutdown() override;
28  void dump_config() override;
29  float get_setup_priority() const override;
30  void set_port(uint16_t port) { this->port_ = port; }
31  void set_mode(Mode mode) { this->mode_ = mode; }
32  void loop() override;
33 
34  protected:
35  std::shared_ptr<esphome::esp32_camera::CameraImage> wait_for_image_();
36  esp_err_t handler_(struct httpd_req *req);
37  esp_err_t streaming_handler_(struct httpd_req *req);
38  esp_err_t snapshot_handler_(struct httpd_req *req);
39 
40  uint16_t port_{0};
41  void *httpd_{nullptr};
42  SemaphoreHandle_t semaphore_;
43  std::shared_ptr<esphome::esp32_camera::CameraImage> image_;
44  bool running_{false};
46 };
47 
48 } // namespace esp32_camera_web_server
49 } // namespace esphome
50 
51 #endif // USE_ESP32
esp_err_t streaming_handler_(struct httpd_req *req)
std::shared_ptr< esphome::esp32_camera::CameraImage > image_
BedjetMode mode
BedJet operating mode.
Definition: bedjet_codec.h:183
std::shared_ptr< esphome::esp32_camera::CameraImage > wait_for_image_()
esp_err_t snapshot_handler_(struct httpd_req *req)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7