Files
StarPilot/selfdrive/ui/replay/camera.h
T
Willem Melching 2291683728 replay: do not use OpenCL (#22431)
old-commit-hash: 94afd0ea0f8bc17fc9d24e122f6447116ca75525
2021-10-04 19:43:52 +02:00

40 lines
1.1 KiB
C++

#pragma once
#include <unistd.h>
#include "cereal/visionipc/visionipc_server.h"
#include "selfdrive/common/queue.h"
#include "selfdrive/ui/replay/framereader.h"
#include "selfdrive/ui/replay/logreader.h"
class CameraServer {
public:
CameraServer();
~CameraServer();
inline void pushFrame(CameraType type, FrameReader* fr, const cereal::EncodeIndex::Reader& eidx) {
queue_.push({type, fr, eidx});
}
inline void waitFinish() {
while (!queue_.empty()) usleep(0);
}
protected:
void startVipcServer();
void thread();
struct Camera {
VisionStreamType rgb_type;
VisionStreamType yuv_type;
int width;
int height;
};
Camera cameras_[MAX_CAMERAS] = {
{.rgb_type = VISION_STREAM_RGB_BACK, .yuv_type = VISION_STREAM_YUV_BACK},
{.rgb_type = VISION_STREAM_RGB_FRONT, .yuv_type = VISION_STREAM_YUV_FRONT},
{.rgb_type = VISION_STREAM_RGB_WIDE, .yuv_type = VISION_STREAM_YUV_WIDE},
};
std::thread camera_thread_;
std::unique_ptr<VisionIpcServer> vipc_server_;
SafeQueue<std::tuple<CameraType, FrameReader*, const cereal::EncodeIndex::Reader>> queue_;
};