esp32cam
OV2640 camera on ESP32-CAM
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mjpeg.hpp
Go to the documentation of this file.
1#ifndef ESP32CAM_MJPEG_HPP
2#define ESP32CAM_MJPEG_HPP
3
4#include "frame.hpp"
5
6#include <memory>
7
8namespace esp32cam {
9
17 int minInterval = 0;
18
24 int maxFrames = -1;
25
27 int frameTimeout = 10000;
28};
29
30namespace detail {
31
34public:
36
38 int countSentFrames() const {
39 return m_count;
40 }
41
50 int decideAction();
51
56 void notifyCapture();
57
63 void notifyReturn(std::unique_ptr<Frame> frame);
64
66 Frame* getFrame() const {
67 return m_frame.get();
68 }
69
78 void notifySent(bool ok);
79
85 void notifyFail();
86
87public:
88 enum Action {
89 CAPTURE = -1,
90 RETURN = -2,
91 SEND = -3,
92 STOP = -4,
93 };
94
96
97private:
98 std::unique_ptr<Frame> m_frame;
99 unsigned long m_nextCaptureTime;
100 int m_nextAction = CAPTURE;
101 int m_count = 0;
102};
103
106public:
108
110
111 void prepareBoundary(size_t contentLength);
112
113 void prepareTrailer();
114
115 size_t writeTo(Print& os);
116
117public:
118 size_t size = 0;
119 char buf[120];
120};
121
122} // namespace detail
123} // namespace esp32cam
124
125#endif // ESP32CAM_MJPEG_HPP
A frame of picture.
Definition frame.hpp:13
Control MJPEG stream timing.
Definition mjpeg.hpp:33
const MjpegConfig cfg
Definition mjpeg.hpp:95
Action
Definition mjpeg.hpp:88
@ RETURN
Definition mjpeg.hpp:90
@ STOP
Definition mjpeg.hpp:92
@ CAPTURE
Definition mjpeg.hpp:89
@ SEND
Definition mjpeg.hpp:91
void notifySent(bool ok)
Notify that a frame is sent to the client.
Definition mjpeg.cpp:46
int countSentFrames() const
Retrieve number of sent frames.
Definition mjpeg.hpp:38
void notifyCapture()
Notify that frame capture has started.
Definition mjpeg.cpp:26
void notifyFail()
Notify that an error has occurred.
Definition mjpeg.cpp:58
Frame * getFrame() const
Retrieve current frame.
Definition mjpeg.hpp:66
void notifyReturn(std::unique_ptr< Frame > frame)
Notify that frame capture has completed.
Definition mjpeg.cpp:33
int decideAction()
Decide what to do now.
Definition mjpeg.cpp:14
Prepare HTTP headers related to MJPEG streaming.
Definition mjpeg.hpp:105
void prepareTrailer()
Definition mjpeg.cpp:90
void prepareBoundary(size_t contentLength)
Definition mjpeg.cpp:80
size_t writeTo(Print &os)
Definition mjpeg.cpp:95
char buf[120]
Definition mjpeg.hpp:119
size_t size
Definition mjpeg.hpp:118
void prepareResponseContentType()
Definition mjpeg.cpp:75
void prepareResponseHeaders()
Definition mjpeg.cpp:67
Definition esp32cam.h:14
Definition mjpeg.hpp:11
int minInterval
Minimum interval between frame captures in millis.
Definition mjpeg.hpp:17
int frameTimeout
Time limit of writing one frame in millis.
Definition mjpeg.hpp:27
int maxFrames
Maximum number of frames before disconnecting.
Definition mjpeg.hpp:24