replay: add flag to disable video (#23353)

old-commit-hash: 1e309a51f53a7678f42f40010fb0371b20c2f213
This commit is contained in:
Dean Lee
2022-01-03 03:54:49 +08:00
committed by GitHub
parent e58562bcb6
commit 2a3a9e0bef
4 changed files with 20 additions and 12 deletions
+1
View File
@@ -107,6 +107,7 @@ int main(int argc, char *argv[]) {
{"qcam", REPLAY_FLAG_QCAMERA, "load qcamera"},
{"yuv", REPLAY_FLAG_SEND_YUV, "send yuv frame"},
{"no-cuda", REPLAY_FLAG_NO_CUDA, "disable CUDA"},
{"no-vipc", REPLAY_FLAG_NO_VIPC, "do not output video"},
};
QCommandLineParser parser;
+17 -11
View File
@@ -58,8 +58,10 @@ bool Replay::load() {
}
for (auto &[n, f] : route_->segments()) {
if ((!f.rlog.isEmpty() || !f.qlog.isEmpty()) && (!f.road_cam.isEmpty() || !f.qcamera.isEmpty())) {
segments_[n] = nullptr;
bool has_log = !f.rlog.isEmpty() || !f.qlog.isEmpty();
bool has_video = !f.road_cam.isEmpty() || !f.qcamera.isEmpty();
if (has_log && (has_video || hasFlag(REPLAY_FLAG_NO_VIPC))) {
segments_.insert({n, nullptr});
}
}
if (segments_.empty()) {
@@ -218,13 +220,15 @@ void Replay::startStream(const Segment *cur_segment) {
}
// start camera server
std::pair<int, int> camera_size[MAX_CAMERAS] = {};
for (auto type : ALL_CAMERAS) {
if (auto &fr = cur_segment->frames[type]) {
camera_size[type] = {fr->width, fr->height};
if (!hasFlag(REPLAY_FLAG_NO_VIPC)) {
std::pair<int, int> camera_size[MAX_CAMERAS] = {};
for (auto type : ALL_CAMERAS) {
if (auto &fr = cur_segment->frames[type]) {
camera_size[type] = {fr->width, fr->height};
}
}
camera_server_ = std::make_unique<CameraServer>(camera_size, hasFlag(REPLAY_FLAG_SEND_YUV));
}
camera_server_ = std::make_unique<CameraServer>(camera_size, hasFlag(REPLAY_FLAG_SEND_YUV));
// start stream thread
stream_thread_ = new QThread();
@@ -318,18 +322,20 @@ void Replay::stream() {
precise_nano_sleep(behind_ns);
}
if (evt->frame) {
if (!evt->frame) {
publishMessage(evt);
} else if (camera_server_) {
if (hasFlag(REPLAY_FLAG_FULL_SPEED)) {
camera_server_->waitFinish();
}
publishFrame(evt);
} else {
publishMessage(evt);
}
}
}
// wait for frame to be sent before unlock.(frameReader may be deleted after unlock)
camera_server_->waitFinish();
if (camera_server_) {
camera_server_->waitFinish();
}
if (eit == events_->end() && !hasFlag(REPLAY_FLAG_NO_LOOP)) {
int last_segment = segments_.rbegin()->first;
+1
View File
@@ -18,6 +18,7 @@ enum REPLAY_FLAGS {
REPLAY_FLAG_SEND_YUV = 0x0080,
REPLAY_FLAG_NO_CUDA = 0x0100,
REPLAY_FLAG_FULL_SPEED = 0x0200,
REPLAY_FLAG_NO_VIPC = 0x0400,
};
class Replay : public QObject {
+1 -1
View File
@@ -98,7 +98,7 @@ Segment::Segment(int n, const SegmentFile &files, uint32_t flags) : seg_num(n),
files.rlog.isEmpty() ? files.qlog : files.rlog,
};
for (int i = 0; i < file_list.size(); ++i) {
if (!file_list[i].isEmpty()) {
if (!file_list[i].isEmpty() && (!(flags & REPLAY_FLAG_NO_VIPC) || i >= MAX_CAMERAS)) {
++loading_;
synchronizer_.addFuture(QtConcurrent::run(this, &Segment::loadFile, i, file_list[i].toStdString()));
}