Screenrecorder
Credit goes to Neokii! https: //github.com/neokii Co-Authored-By: neokii <3665951+neokii@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,7 @@ Import('qt_env', 'arch', 'common', 'messaging', 'visionipc',
|
||||
'cereal', 'transformations')
|
||||
|
||||
base_libs = [common, messaging, cereal, visionipc, transformations, 'zmq',
|
||||
'capnp', 'kj', 'm', 'OpenCL', 'ssl', 'crypto', 'pthread'] + qt_env["LIBS"]
|
||||
'capnp', 'kj', 'm', 'OpenCL', 'ssl', 'crypto', 'pthread', 'OmxCore', 'avformat', 'avcodec', 'avutil', 'yuv'] + qt_env["LIBS"]
|
||||
|
||||
if arch == 'larch64':
|
||||
base_libs.append('EGL')
|
||||
@@ -43,7 +43,23 @@ qt_libs = [widgets, qt_util] + base_libs
|
||||
qt_src = ["main.cc", "qt/sidebar.cc", "qt/onroad.cc", "qt/body.cc",
|
||||
"qt/window.cc", "qt/home.cc", "qt/offroad/settings.cc",
|
||||
"qt/offroad/software_settings.cc", "qt/offroad/onboarding.cc",
|
||||
"qt/offroad/driverview.cc", "qt/offroad/experimental_mode.cc"]
|
||||
"qt/offroad/driverview.cc", "qt/offroad/experimental_mode.cc",
|
||||
"../frogpilot/screenrecorder/omx_encoder.cc", "../frogpilot/screenrecorder/screenrecorder.cc"]
|
||||
|
||||
def is_running_on_wsl2():
|
||||
try:
|
||||
with open('/proc/version', 'r') as f:
|
||||
return 'WSL2' in f.read()
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
|
||||
if is_running_on_wsl2():
|
||||
qt_env.Append(CXXFLAGS=['-DWSL2'])
|
||||
base_libs.remove('OmxCore')
|
||||
qt_libs.remove('OmxCore')
|
||||
qt_src.remove("../frogpilot/screenrecorder/screenrecorder.cc")
|
||||
qt_src.remove("../frogpilot/screenrecorder/omx_encoder.cc")
|
||||
print("Building for WSL2. Removing Screen Recorder")
|
||||
|
||||
# build translation files
|
||||
with open(File("translations/languages.json").abspath) as f:
|
||||
@@ -86,6 +102,7 @@ if GetOption('extras'):
|
||||
qt_env.Program('tests/test_translations', [asset_obj, 'tests/test_runner.cc', 'tests/test_translations.cc'] + qt_src, LIBS=qt_libs)
|
||||
qt_env.Program('tests/ui_snapshot', [asset_obj, "tests/ui_snapshot.cc"] + qt_src, LIBS=qt_libs)
|
||||
|
||||
qt_env['CPPPATH'] += ["../frogpilot/screenrecorder/openmax/include/"]
|
||||
|
||||
if GetOption('extras') and arch != "Darwin":
|
||||
# setup and factory resetter
|
||||
|
||||
@@ -444,8 +444,17 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* par
|
||||
main_layout->setMargin(UI_BORDER_SIZE);
|
||||
main_layout->setSpacing(0);
|
||||
|
||||
// Neokii screen recorder
|
||||
QHBoxLayout *top_right_layout = new QHBoxLayout();
|
||||
top_right_layout->setSpacing(0);
|
||||
recorder_btn = new ScreenRecorder(this);
|
||||
top_right_layout->addWidget(recorder_btn);
|
||||
|
||||
experimental_btn = new ExperimentalButton(this);
|
||||
main_layout->addWidget(experimental_btn, 0, Qt::AlignTop | Qt::AlignRight);
|
||||
top_right_layout->addWidget(experimental_btn);
|
||||
|
||||
main_layout->addLayout(top_right_layout, 0);
|
||||
main_layout->setAlignment(top_right_layout, Qt::AlignTop | Qt::AlignRight);
|
||||
|
||||
map_settings_btn = new MapSettingsButton(this);
|
||||
main_layout->addWidget(map_settings_btn, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
@@ -962,8 +971,12 @@ void AnnotatedCameraWidget::drawLead(QPainter &painter, const cereal::RadarState
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::paintGL() {
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) {
|
||||
UIState *s = uiState();
|
||||
SubMaster &sm = *(s->sm);
|
||||
QPainter painter(this);
|
||||
const double start_draw_t = millis_since_boot();
|
||||
const cereal::ModelDataV2::Reader &model = sm["modelV2"].getModelV2();
|
||||
|
||||
@@ -1008,11 +1021,12 @@ void AnnotatedCameraWidget::paintGL() {
|
||||
} else {
|
||||
CameraWidget::updateCalibration(DEFAULT_CALIBRATION);
|
||||
}
|
||||
painter.beginNativePainting();
|
||||
CameraWidget::setFrameId(model.getFrameId());
|
||||
CameraWidget::paintGL();
|
||||
painter.endNativePainting();
|
||||
}
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
@@ -1110,6 +1124,15 @@ void AnnotatedCameraWidget::initializeFrogPilotWidgets() {
|
||||
connect(animationTimer, &QTimer::timeout, this, [this] {
|
||||
animationFrameIndex = (animationFrameIndex + 1) % totalFrames;
|
||||
});
|
||||
|
||||
// Initialize the timer for the screen recorder
|
||||
QTimer *record_timer = new QTimer(this);
|
||||
connect(record_timer, &QTimer::timeout, this, [this]() {
|
||||
if (this->recorder_btn) {
|
||||
this->recorder_btn->update_screen();
|
||||
}
|
||||
});
|
||||
record_timer->start(1000 / UI_FREQ);
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/qt/widgets/cameraview.h"
|
||||
|
||||
#include "selfdrive/frogpilot/screenrecorder/screenrecorder.h"
|
||||
|
||||
const int btn_size = 192;
|
||||
const int img_size = (btn_size / 4) * 3;
|
||||
@@ -151,6 +152,7 @@ private:
|
||||
UIScene &scene;
|
||||
|
||||
Compass *compass_img;
|
||||
ScreenRecorder *recorder_btn;
|
||||
|
||||
QHBoxLayout *bottom_layout;
|
||||
|
||||
@@ -201,6 +203,7 @@ protected:
|
||||
void drawLead(QPainter &painter, const cereal::RadarState::LeadData::Reader &lead_data, const QPointF &vd);
|
||||
void drawHud(QPainter &p);
|
||||
void drawDriverState(QPainter &painter, const UIState *s);
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
|
||||
inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
|
||||
inline QColor blackColor(int alpha = 255) { return QColor(0, 0, 0, alpha); }
|
||||
|
||||
Reference in New Issue
Block a user