33 lines
744 B
C++
33 lines
744 B
C++
#ifndef BACKGROUND_CAPTURE_SERVICE_H
|
|
#define BACKGROUND_CAPTURE_SERVICE_H
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/task.h>
|
|
|
|
#include <atomic>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
class BackgroundCaptureService {
|
|
public:
|
|
BackgroundCaptureService();
|
|
~BackgroundCaptureService();
|
|
|
|
void Start();
|
|
void Stop();
|
|
bool IsRunning() const { return running_.load(); }
|
|
|
|
private:
|
|
TaskHandle_t task_handle_ = nullptr;
|
|
std::atomic<bool> running_ = false;
|
|
uint32_t consecutive_failures_ = 0;
|
|
|
|
static void TaskEntry(void* arg);
|
|
void Run();
|
|
bool CaptureAndSendFrame();
|
|
bool UploadJpegFrame(const std::string& jpeg_data);
|
|
uint32_t GetFailureDelayMs() const;
|
|
};
|
|
|
|
#endif // BACKGROUND_CAPTURE_SERVICE_H
|