You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
706 B
29 lines
706 B
#pragma once
|
|
|
|
#include <QImage>
|
|
#include <QObject>
|
|
#include <QQueue>
|
|
#include <selfdrive/ui/ui.h>
|
|
#include <selfdrive/ui/qt/qt_window.h>
|
|
|
|
#include "ffmpeg.h"
|
|
|
|
class Recorder : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
Recorder(const std::string& outputFile, QObject *parent = nullptr);
|
|
~Recorder() override;
|
|
|
|
public slots:
|
|
void saveFrame(const std::shared_ptr<QPixmap> &frame);
|
|
|
|
private:
|
|
static constexpr int MAX_QUEUE_SIZE = 30; // Limit queue size to prevent memory growth
|
|
FFmpegEncoder *encoder;
|
|
QQueue<std::shared_ptr<QPixmap>> frameQueue;
|
|
QMutex mutex;
|
|
QAtomicInt isProcessing{0}; // Use atomic for thread safety
|
|
bool keepRunning = true;
|
|
void processQueue();
|
|
};
|
|
|