pull/34892/head
Trey Moen 5 months ago
parent a8d296f856
commit 78c125d946
  1. 6
      selfdrive/ui/qt/onroad/onroad_home.cc
  2. 2
      selfdrive/ui/qt/onroad/onroad_home.h
  3. 3
      tools/clip/application.cc
  4. 30
      tools/clip/recorder/moc_widget.cc
  5. 13
      tools/clip/recorder/widget.cc
  6. 5
      tools/clip/recorder/widget.h

@ -6,6 +6,8 @@
#include "selfdrive/ui/qt/util.h"
OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
qRegisterMetaType<std::shared_ptr<QPixmap>>("std::shared_ptr<QPixmap>");
QVBoxLayout *main_layout = new QVBoxLayout(this);
main_layout->setMargin(UI_BORDER_SIZE);
QStackedLayout *stacked_layout = new QStackedLayout;
@ -44,8 +46,6 @@ void OnroadWindow::updateState(const UIState &s) {
return;
}
emit drewOnroadFrame(new QImage(grab().toImage()));
alerts->updateState(s);
nvg->updateState(s);
@ -55,6 +55,8 @@ void OnroadWindow::updateState(const UIState &s) {
bg = bgColor;
update();
}
emit drewOnroadFrame(std::make_shared<QPixmap>(std::move(grab())));
}
void OnroadWindow::offroadTransition(bool offroad) {

@ -10,7 +10,7 @@ public:
OnroadWindow(QWidget* parent = 0);
signals:
void drewOnroadFrame(QImage *frame);
void drewOnroadFrame(const std::shared_ptr<QPixmap> &frame);
private:
void paintEvent(QPaintEvent *event);

@ -46,7 +46,8 @@ void Application::initReplay() {
std::vector<std::string> allow;
std::vector<std::string> block;
replay = std::make_unique<Replay>("a2a0ccea32023010|2023-07-27--13-01-19", allow, block, nullptr,
REPLAY_FLAG_NONE & REPLAY_FLAG_ECAM & REPLAY_FLAG_DCAM);
REPLAY_FLAG_NONE);
replay->setSegmentCacheLimit(10);
}
void Application::startReplay() {

@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_Recorder_t {
QByteArrayData data[6];
char stringdata0[39];
QByteArrayData data[5];
char stringdata0[51];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
@ -35,13 +35,12 @@ static const qt_meta_stringdata_Recorder_t qt_meta_stringdata_Recorder = {
QT_MOC_LITERAL(0, 0, 8), // "Recorder"
QT_MOC_LITERAL(1, 9, 9), // "saveFrame"
QT_MOC_LITERAL(2, 19, 0), // ""
QT_MOC_LITERAL(3, 20, 7), // "QImage*"
QT_MOC_LITERAL(4, 28, 5), // "frame"
QT_MOC_LITERAL(5, 34, 4) // "stop"
QT_MOC_LITERAL(3, 20, 24), // "std::shared_ptr<QPixmap>"
QT_MOC_LITERAL(4, 45, 5) // "frame"
},
"Recorder\0saveFrame\0\0QImage*\0frame\0"
"stop"
"Recorder\0saveFrame\0\0std::shared_ptr<QPixmap>\0"
"frame"
};
#undef QT_MOC_LITERAL
@ -51,7 +50,7 @@ static const uint qt_meta_data_Recorder[] = {
8, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
@ -59,12 +58,10 @@ static const uint qt_meta_data_Recorder[] = {
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 1, 24, 2, 0x0a /* Public */,
5, 0, 27, 2, 0x0a /* Public */,
1, 1, 19, 2, 0x0a /* Public */,
// slots: parameters
QMetaType::Void, 0x80000000 | 3, 4,
QMetaType::Void,
0 // eod
};
@ -75,8 +72,7 @@ void Recorder::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, vo
auto *_t = static_cast<Recorder *>(_o);
(void)_t;
switch (_id) {
case 0: _t->saveFrame((*reinterpret_cast< QImage*(*)>(_a[1]))); break;
case 1: _t->stop(); break;
case 0: _t->saveFrame((*reinterpret_cast< const std::shared_ptr<QPixmap>(*)>(_a[1]))); break;
default: ;
}
}
@ -111,13 +107,13 @@ int Recorder::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
if (_id < 1)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
_id -= 1;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 2)
if (_id < 1)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 2;
_id -= 1;
}
return _id;
}

@ -10,7 +10,7 @@ Recorder::~Recorder() {
delete encoder;
}
void Recorder::saveFrame(QImage *frame) {
void Recorder::saveFrame(const std::shared_ptr<QPixmap> &frame) {
QMutexLocker locker(&mutex);
frameQueue.enqueue(frame); // Add frame to queue
if (!isProcessing) {
@ -21,7 +21,7 @@ void Recorder::saveFrame(QImage *frame) {
void Recorder::processQueue() {
while (true) {
QImage *frame;
std::shared_ptr<QPixmap> frame;
{
QMutexLocker locker(&mutex);
if (frameQueue.isEmpty() || !keepRunning) {
@ -31,16 +31,9 @@ void Recorder::processQueue() {
frame = frameQueue.dequeue();
}
if (!encoder->writeFrame(frame->convertToFormat(QImage::Format_ARGB32_Premultiplied))) {
if (!encoder->writeFrame(frame->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied))) {
fprintf(stderr, "did not write\n");
}
delete frame;
}
}
void Recorder::stop() {
QMutexLocker locker(&mutex);
keepRunning = false;
}

@ -16,12 +16,11 @@ public:
~Recorder() override;
public slots:
void saveFrame(QImage *frame);
void stop();
void saveFrame(const std::shared_ptr<QPixmap> &frame);
private:
FFmpegEncoder *encoder;
QQueue<QImage *> frameQueue;
QQueue<std::shared_ptr<QPixmap>> frameQueue;
QMutex mutex;
bool isProcessing = false;
bool keepRunning = true;

Loading…
Cancel
Save