2021-09-20 03:24:28 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2023-08-24 04:25:17 +08:00
|
|
|
#include <map>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
2024-04-23 10:21:42 +08:00
|
|
|
#include <vector>
|
2023-08-24 04:25:17 +08:00
|
|
|
|
2023-01-08 03:07:30 +08:00
|
|
|
#include <QDateTime>
|
2021-11-01 18:55:56 +08:00
|
|
|
#include <QFutureSynchronizer>
|
2021-09-20 03:24:28 +08:00
|
|
|
|
2022-06-28 22:12:42 +08:00
|
|
|
#include "tools/replay/framereader.h"
|
|
|
|
|
#include "tools/replay/logreader.h"
|
|
|
|
|
#include "tools/replay/util.h"
|
2021-09-20 03:24:28 +08:00
|
|
|
|
2021-10-19 20:45:07 +08:00
|
|
|
struct RouteIdentifier {
|
|
|
|
|
QString dongle_id;
|
|
|
|
|
QString timestamp;
|
2024-03-28 00:47:18 +08:00
|
|
|
int begin_segment = 0;
|
|
|
|
|
int end_segment = -1;
|
2021-10-19 20:45:07 +08:00
|
|
|
QString str;
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-20 03:24:28 +08:00
|
|
|
struct SegmentFile {
|
|
|
|
|
QString rlog;
|
|
|
|
|
QString qlog;
|
|
|
|
|
QString road_cam;
|
|
|
|
|
QString driver_cam;
|
|
|
|
|
QString wide_road_cam;
|
|
|
|
|
QString qcamera;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Route {
|
|
|
|
|
public:
|
2021-10-19 20:45:07 +08:00
|
|
|
Route(const QString &route, const QString &data_dir = {});
|
2021-09-20 03:24:28 +08:00
|
|
|
bool load();
|
2021-10-19 20:45:07 +08:00
|
|
|
inline const QString &name() const { return route_.str; }
|
2023-01-08 03:07:30 +08:00
|
|
|
inline const QDateTime datetime() const { return date_time_; }
|
2022-01-29 04:03:19 +08:00
|
|
|
inline const QString &dir() const { return data_dir_; }
|
2021-10-19 20:45:07 +08:00
|
|
|
inline const RouteIdentifier &identifier() const { return route_; }
|
2021-10-16 05:35:17 +08:00
|
|
|
inline const std::map<int, SegmentFile> &segments() const { return segments_; }
|
2021-11-10 06:08:24 +08:00
|
|
|
inline const SegmentFile &at(int n) { return segments_.at(n); }
|
2021-10-19 20:45:07 +08:00
|
|
|
static RouteIdentifier parseRoute(const QString &str);
|
2021-09-20 03:24:28 +08:00
|
|
|
|
|
|
|
|
protected:
|
2021-10-12 15:51:22 +08:00
|
|
|
bool loadFromLocal();
|
2024-03-31 08:37:14 +08:00
|
|
|
bool loadFromServer(int retries = 3);
|
2021-09-20 03:24:28 +08:00
|
|
|
bool loadFromJson(const QString &json);
|
2021-10-16 05:35:17 +08:00
|
|
|
void addFileToSegment(int seg_num, const QString &file);
|
2021-10-19 20:45:07 +08:00
|
|
|
RouteIdentifier route_ = {};
|
2021-10-12 15:51:22 +08:00
|
|
|
QString data_dir_;
|
2021-10-16 05:35:17 +08:00
|
|
|
std::map<int, SegmentFile> segments_;
|
2023-01-08 03:07:30 +08:00
|
|
|
QDateTime date_time_;
|
2021-09-20 03:24:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Segment : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2024-04-23 10:21:42 +08:00
|
|
|
Segment(int n, const SegmentFile &files, uint32_t flags, const std::vector<bool> &filters = {});
|
2021-09-20 03:24:28 +08:00
|
|
|
~Segment();
|
2021-11-01 18:55:56 +08:00
|
|
|
inline bool isLoaded() const { return !loading_ && !abort_; }
|
2021-09-20 03:24:28 +08:00
|
|
|
|
2021-10-16 05:35:17 +08:00
|
|
|
const int seg_num = 0;
|
2021-09-20 03:24:28 +08:00
|
|
|
std::unique_ptr<LogReader> log;
|
|
|
|
|
std::unique_ptr<FrameReader> frames[MAX_CAMERAS] = {};
|
|
|
|
|
|
|
|
|
|
signals:
|
2021-10-16 05:35:17 +08:00
|
|
|
void loadFinished(bool success);
|
2021-09-20 03:24:28 +08:00
|
|
|
|
|
|
|
|
protected:
|
2021-11-17 18:17:59 +08:00
|
|
|
void loadFile(int id, const std::string file);
|
2021-09-20 03:24:28 +08:00
|
|
|
|
2021-11-01 18:55:56 +08:00
|
|
|
std::atomic<bool> abort_ = false;
|
2021-10-16 05:35:17 +08:00
|
|
|
std::atomic<int> loading_ = 0;
|
2021-11-01 18:55:56 +08:00
|
|
|
QFutureSynchronizer<void> synchronizer_;
|
2021-11-17 18:17:59 +08:00
|
|
|
uint32_t flags;
|
2024-04-23 10:21:42 +08:00
|
|
|
std::vector<bool> filters_;
|
2021-09-20 03:24:28 +08:00
|
|
|
};
|