You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					104 lines
				
				2.4 KiB
			
		
		
			
		
	
	
					104 lines
				
				2.4 KiB
			| 
								 
											4 years ago
										 
									 | 
							
								#pragma once
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include <unistd.h>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include <atomic>
							 | 
						||
| 
								 | 
							
								#include <cassert>
							 | 
						||
| 
								 | 
							
								#include <cerrno>
							 | 
						||
| 
								 | 
							
								#include <condition_variable>
							 | 
						||
| 
								 | 
							
								#include <mutex>
							 | 
						||
| 
								 | 
							
								#include <string>
							 | 
						||
| 
								 | 
							
								#include <thread>
							 | 
						||
| 
								 | 
							
								#include <unordered_map>
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								#include <utility>
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "cereal/messaging/messaging.h"
							 | 
						||
| 
								 | 
							
								#include "cereal/services.h"
							 | 
						||
| 
								 | 
							
								#include "cereal/visionipc/visionipc.h"
							 | 
						||
| 
								 | 
							
								#include "cereal/visionipc/visionipc_client.h"
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								#include "system/camerad/cameras/camera_common.h"
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								#include "common/params.h"
							 | 
						||
| 
								 | 
							
								#include "common/swaglog.h"
							 | 
						||
| 
								 | 
							
								#include "common/timing.h"
							 | 
						||
| 
								 | 
							
								#include "common/util.h"
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								#include "system/hardware/hw.h"
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								#include "system/loggerd/encoder/encoder.h"
							 | 
						||
| 
								 | 
							
								#include "system/loggerd/logger.h"
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								#ifdef QCOM2
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								#include "system/loggerd/encoder/v4l_encoder.h"
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								#define Encoder V4LEncoder
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								#else
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								#include "system/loggerd/encoder/ffmpeg_encoder.h"
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								#define Encoder FfmpegEncoder
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								constexpr int MAIN_FPS = 20;
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								const int MAIN_BITRATE = 10000000;
							 | 
						||
| 
								 | 
							
								const int DCAM_BITRATE = MAIN_BITRATE;
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								#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;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								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 record;
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								const LogCameraInfo cameras_logged[] = {
							 | 
						||
| 
								 | 
							
								  {
							 | 
						||
| 
								 | 
							
								    .type = RoadCam,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .stream_type = VISION_STREAM_ROAD,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .filename = "fcamera.hevc",
							 | 
						||
| 
								 | 
							
								    .fps = MAIN_FPS,
							 | 
						||
| 
								 | 
							
								    .bitrate = MAIN_BITRATE,
							 | 
						||
| 
								 | 
							
								    .is_h265 = true,
							 | 
						||
| 
								 | 
							
								    .has_qcamera = true,
							 | 
						||
| 
								 | 
							
								    .record = true,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .frame_width = 1928,
							 | 
						||
| 
								 | 
							
								    .frame_height = 1208,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  },
							 | 
						||
| 
								 | 
							
								  {
							 | 
						||
| 
								 | 
							
								    .type = DriverCam,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .stream_type = VISION_STREAM_DRIVER,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .filename = "dcamera.hevc",
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .fps = MAIN_FPS,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .bitrate = DCAM_BITRATE,
							 | 
						||
| 
								 | 
							
								    .is_h265 = true,
							 | 
						||
| 
								 | 
							
								    .has_qcamera = false,
							 | 
						||
| 
								 | 
							
								    .record = Params().getBool("RecordFront"),
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .frame_width = 1928,
							 | 
						||
| 
								 | 
							
								    .frame_height = 1208,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  },
							 | 
						||
| 
								 | 
							
								  {
							 | 
						||
| 
								 | 
							
								    .type = WideRoadCam,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .stream_type = VISION_STREAM_WIDE_ROAD,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .filename = "ecamera.hevc",
							 | 
						||
| 
								 | 
							
								    .fps = MAIN_FPS,
							 | 
						||
| 
								 | 
							
								    .bitrate = MAIN_BITRATE,
							 | 
						||
| 
								 | 
							
								    .is_h265 = true,
							 | 
						||
| 
								 | 
							
								    .has_qcamera = false,
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								    .record = true,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								    .frame_width = 1928,
							 | 
						||
| 
								 | 
							
								    .frame_height = 1208,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  },
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								const LogCameraInfo qcam_info = {
							 | 
						||
| 
								 | 
							
								  .filename = "qcamera.ts",
							 | 
						||
| 
								 | 
							
								  .fps = MAIN_FPS,
							 | 
						||
| 
								 | 
							
								  .bitrate = 256000,
							 | 
						||
| 
								 | 
							
								  .is_h265 = false,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  .record = true,
							 | 
						||
| 
								 
											3 years ago
										 
									 | 
							
								  .frame_width = 526,
							 | 
						||
| 
								 | 
							
								  .frame_height = 330,
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								};
							 |