mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 21:43:59 +08:00
* vipc support. modeld and dmonitoringmodeld configs * Update cereal * Add vision meta * Use vision meta in process replay * Exclude modeld and dmonitoringmodeld from test_processes * Refactor other pieces of code to use vision meta * remove unnecessary imports * Add MAX_FRAMES_PER_SEGMENT * cameraState migration * Move camera state migration to migration module * model_replay refactor * Fix lint issues * Reduce number of vipc buffers to 2 * Update spinner message * Update model replay ref * Support the new log order * Replace CameraFrameSizes with dict. Add encode_index field * Migrate camera states based on encode indices * Refactor process replay * Refactor model replay * Remove unnecessary print * Update model replay ref * Make camera state migration optional * Remove unused import * Add ignore_alive_pubs field * Add assertion for carParams inside fingerprinting callback * Remove WideCameraOnly param setup * Refactor ModeldCameraSyncRcvCallback * Update model replay ref commit * Fix camera state migration * Only migrate camera states when process has vision pubs * Refactor model replay again * Fix linter issues * One more linter fix * Update model replay ref commit
44 lines
1.9 KiB
Python
44 lines
1.9 KiB
Python
from collections import namedtuple
|
|
from cereal.visionipc import VisionStreamType
|
|
from common.realtime import DT_MDL, DT_DMON
|
|
from common.transformations.camera import tici_f_frame_size, tici_d_frame_size, tici_e_frame_size, eon_f_frame_size, eon_d_frame_size
|
|
|
|
VideoStreamMeta = namedtuple("VideoStreamMeta", ["camera_state", "encode_index", "stream", "dt", "frame_sizes"])
|
|
ROAD_CAMERA_FRAME_SIZES = {"tici": tici_f_frame_size, "tizi": tici_f_frame_size, "eon": eon_f_frame_size}
|
|
WIDE_ROAD_CAMERA_FRAME_SIZES = {"tici": tici_e_frame_size, "tizi": tici_e_frame_size}
|
|
DRIVER_FRAME_SIZES = {"tici": tici_d_frame_size, "tizi": tici_d_frame_size, "eon": eon_d_frame_size}
|
|
VIPC_STREAM_METADATA = [
|
|
# metadata: (state_msg_type, encode_msg_type, stream_type, dt, frame_sizes)
|
|
("roadCameraState", "roadEncodeIdx", VisionStreamType.VISION_STREAM_ROAD, DT_MDL, ROAD_CAMERA_FRAME_SIZES),
|
|
("wideRoadCameraState", "wideRoadEncodeIdx", VisionStreamType.VISION_STREAM_WIDE_ROAD, DT_MDL, WIDE_ROAD_CAMERA_FRAME_SIZES),
|
|
("driverCameraState", "driverEncodeIdx", VisionStreamType.VISION_STREAM_DRIVER, DT_DMON, DRIVER_FRAME_SIZES),
|
|
]
|
|
|
|
|
|
def meta_from_camera_state(state):
|
|
meta = next((VideoStreamMeta(*meta) for meta in VIPC_STREAM_METADATA if meta[0] == state), None)
|
|
return meta
|
|
|
|
|
|
def meta_from_encode_index(encode_index):
|
|
meta = next((VideoStreamMeta(*meta) for meta in VIPC_STREAM_METADATA if meta[1] == encode_index), None)
|
|
return meta
|
|
|
|
|
|
def meta_from_stream_type(stream_type):
|
|
meta = next((VideoStreamMeta(*meta) for meta in VIPC_STREAM_METADATA if meta[2] == stream_type), None)
|
|
return meta
|
|
|
|
|
|
def available_streams(lr=None):
|
|
if lr is None:
|
|
return [VideoStreamMeta(*meta) for meta in VIPC_STREAM_METADATA]
|
|
|
|
result = []
|
|
for meta in VIPC_STREAM_METADATA:
|
|
has_cam_state = next((True for m in lr if m.which() == meta[0]), False)
|
|
if has_cam_state:
|
|
result.append(VideoStreamMeta(*meta))
|
|
|
|
return result
|