Files
sunnypilot/selfdrive/loggerd/loggerd.h
Willem Melching f49a9c9fd2 less TICI when not needed (#24698)
* less TICI when not needed

* fix process replay

* move reading voltages into hw abstraction layer

* Update selfdrive/hardware/tici/hardware.h

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* Update selfdrive/hardware/hw.h

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* Update selfdrive/hardware/base.h

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* rename init function

* Update selfdrive/athena/athenad.py

Co-authored-by: Robbe Derks <robbe.derks@gmail.com>

* Update selfdrive/boardd/boardd.cc

* Apply suggestions from code review

* Update selfdrive/thermald/thermald.py

* update ref

* fix alert width if all cameras are bad

* add ecam to test_loggerd

* bump cereal

* bump cereal

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Robbe Derks <robbe.derks@gmail.com>
2022-06-02 15:20:51 +02:00

108 lines
2.5 KiB
C++

#pragma once
#include <unistd.h>
#include <atomic>
#include <cassert>
#include <cerrno>
#include <condition_variable>
#include <mutex>
#include <string>
#include <thread>
#include <unordered_map>
#include "cereal/messaging/messaging.h"
#include "cereal/services.h"
#include "cereal/visionipc/visionipc.h"
#include "cereal/visionipc/visionipc_client.h"
#include "selfdrive/camerad/cameras/camera_common.h"
#include "common/params.h"
#include "common/swaglog.h"
#include "common/timing.h"
#include "common/util.h"
#include "selfdrive/hardware/hw.h"
#include "selfdrive/loggerd/encoder/encoder.h"
#include "selfdrive/loggerd/logger.h"
#ifdef QCOM2
#include "selfdrive/loggerd/encoder/v4l_encoder.h"
#define Encoder V4LEncoder
#else
#include "selfdrive/loggerd/encoder/ffmpeg_encoder.h"
#define Encoder FfmpegEncoder
#endif
constexpr int MAIN_FPS = 20;
const int MAIN_BITRATE = 10000000;
const int DCAM_BITRATE = MAIN_BITRATE;
#define NO_CAMERA_PATIENCE 500 // fall back to time-based rotation if all cameras are dead
const bool LOGGERD_TEST = getenv("LOGGERD_TEST");
const int SEGMENT_LENGTH = LOGGERD_TEST ? atoi(getenv("LOGGERD_SEGMENT_LENGTH")) : 60;
struct LogCameraInfo {
CameraType type;
const char *filename;
VisionStreamType stream_type;
int frame_width, frame_height;
int fps;
int bitrate;
bool is_h265;
bool has_qcamera;
bool enable;
bool record;
};
const LogCameraInfo cameras_logged[] = {
{
.type = RoadCam,
.stream_type = VISION_STREAM_ROAD,
.filename = "fcamera.hevc",
.fps = MAIN_FPS,
.bitrate = MAIN_BITRATE,
.is_h265 = true,
.has_qcamera = true,
.enable = true,
.record = true,
.frame_width = 1928,
.frame_height = 1208,
},
{
.type = DriverCam,
.stream_type = VISION_STREAM_DRIVER,
.filename = "dcamera.hevc",
.fps = MAIN_FPS,
.bitrate = DCAM_BITRATE,
.is_h265 = true,
.has_qcamera = false,
.enable = true,
.record = Params().getBool("RecordFront"),
.frame_width = 1928,
.frame_height = 1208,
},
{
.type = WideRoadCam,
.stream_type = VISION_STREAM_WIDE_ROAD,
.filename = "ecamera.hevc",
.fps = MAIN_FPS,
.bitrate = MAIN_BITRATE,
.is_h265 = true,
.has_qcamera = false,
.enable = true,
.record = true,
.frame_width = 1928,
.frame_height = 1208,
},
};
const LogCameraInfo qcam_info = {
.filename = "qcamera.ts",
.fps = MAIN_FPS,
.bitrate = 256000,
.is_h265 = false,
.enable = true,
.record = true,
.frame_width = 526,
.frame_height = 330,
};