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