mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-07 22:52:06 +08:00
45 lines
873 B
C++
45 lines
873 B
C++
#pragma once
|
|
|
|
#include "omx_encoder.h"
|
|
#include "blocking_queue.h"
|
|
|
|
#include "selfdrive/ui/qt/onroad/buttons.h"
|
|
|
|
class ScreenRecorder : public QPushButton {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ScreenRecorder(QWidget *parent = nullptr);
|
|
|
|
void startRecording();
|
|
void stopRecording();
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
private slots:
|
|
void toggleRecording();
|
|
|
|
private:
|
|
void encodeImage();
|
|
void updateState();
|
|
|
|
bool recording;
|
|
|
|
qint64 startedTime;
|
|
|
|
std::thread encodingThread;
|
|
|
|
std::unique_ptr<OmxEncoder> encoder;
|
|
|
|
BlockingQueue<QImage> imageQueue{UI_FREQ};
|
|
|
|
QColor blackColor(int alpha = 255) { return QColor(0, 0, 0, alpha); }
|
|
QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
|
|
QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
|
|
|
|
QImage captureBuffer;
|
|
|
|
QWidget *rootWidget;
|
|
};
|