FrogAi 14cd89f704 Visuals - Screen Management - Screenrecorder
Enable the ability to record the screen while onroad.

Credit goes to Neokii!

https: //github.com/neokii
Co-Authored-By: neokii <3665951+neokii@users.noreply.github.com>
2024-06-01 02:47:22 -07:00

56 lines
1.1 KiB
C++

#pragma once
#include <QPushButton>
#include "omx_encoder.h"
#include "blocking_queue.h"
#include "selfdrive/ui/ui.h"
class ScreenRecorder : public QPushButton {
#ifdef NO_SR
public:
explicit ScreenRecorder(QWidget *parent = nullptr){}
~ScreenRecorder() override{}
void update_screen(){}
void toggle(){}
#else
Q_OBJECT
public:
explicit ScreenRecorder(QWidget *parent = nullptr);
~ScreenRecorder() override;
void update_screen();
void toggle();
protected:
void paintEvent(QPaintEvent *event) override;
private:
void applyColor();
void closeEncoder();
void encoding_thread_func();
void initializeEncoder();
void openEncoder(const char *filename);
void start();
void stop();
bool recording;
int frame;
int recording_height;
int recording_width;
int screen_height;
int screen_width;
long long started = 0;
std::unique_ptr<OmxEncoder> encoder;
std::unique_ptr<uint8_t[]> rgb_scale_buffer;
std::thread encoding_thread;
BlockingQueue<QImage> image_queue;
QColor recording_color;
QWidget *rootWidget;
#endif //NO_SR
};