fix(core): harden OpenXR/Vulkan lifecycle, DVR composited mode, and telemetry CRC validation

- Accept 'composited' and 'osd' in DvrMode::from_str, set filesink location via GObject property, and avoid overwriting files within the same second
- Validate MAVLink v1/v2 CRC-16 and CRSF CRC-8 DVB-S2 in TelemetryReceiver, join UDP worker thread on Drop, and preserve UTF-8 char boundaries in StackStr
- Ensure OpenXR swapchain image release and session.end() on error paths, reuse pre-allocated raw frame buffer in render loops, and remove forced monado.service stop
- Make egui SSH/RNDIS helper scripts non-blocking and flush log file buffer only on Warn/Error
This commit is contained in:
bleackstorm committed 2026-11-15 13:53:13 +01:00
1 parent b8f2f00f09
commit 26279836d9
7 files changed
+568 -473

No files matched your search

+37 -20
View File
@@ -51,7 +51,7 @@ pub enum DvrMode {
impl DvrMode {
pub fn from_str(s: &str) -> Self {
if s.eq_ignore_ascii_case("osd") {
if s.eq_ignore_ascii_case("osd") || s.eq_ignore_ascii_case("composited") {
Self::CompositedOsd
} else {
Self::StreamCopy
@@ -92,9 +92,6 @@ impl DvrRecorder {
.with_context(|| format!("Impossible de créer le répertoire DVR '{}'", dir))?;
let file_path = Self::generate_filepath(dir, container);
let path_str = file_path
.to_str()
.ok_or_else(|| anyhow::anyhow!("Chemin DVR invalide"))?;
let codec_lower = codec.to_lowercase();
let is_h264 = codec_lower == "h264";
@@ -110,7 +107,7 @@ impl DvrRecorder {
"appsrc name=dvr_src is-live=true format=time do-timestamp=true caps={caps} ! \
{parser} config-interval=-1 ! \
{muxer} ! \
filesink location=\"{path_str}\" sync=false"
filesink name=dvr_sink sync=false"
);
log::info!(
@@ -135,10 +132,6 @@ impl DvrRecorder {
.with_context(|| format!("Impossible de créer le répertoire DVR '{}'", dir))?;
let file_path = Self::generate_filepath(dir, container);
let path_str = file_path
.to_str()
.ok_or_else(|| anyhow::anyhow!("Chemin DVR invalide"))?;
let muxer = container.muxer_element();
let pipeline_str = format!(
@@ -148,7 +141,7 @@ impl DvrRecorder {
x264enc tune=zerolatency speed-preset=ultrafast bitrate=8000 key-int-max=60 ! \
h264parse config-interval=-1 ! \
{muxer} ! \
filesink location=\"{path_str}\" sync=false"
filesink name=dvr_sink sync=false"
);
log::info!(
@@ -175,6 +168,14 @@ impl DvrRecorder {
.dynamic_cast::<gst_app::AppSrc>()
.map_err(|_| anyhow::anyhow!("Impossible de convertir dvr_src en AppSrc"))?;
let filesink = pipeline
.by_name("dvr_sink")
.context("Filesink 'dvr_sink' introuvable dans le pipeline DVR")?;
let path_str = file_path
.to_str()
.ok_or_else(|| anyhow::anyhow!("Chemin DVR invalide"))?;
filesink.set_property("location", path_str);
pipeline
.set_state(gst::State::Playing)
.map_err(|e| anyhow::anyhow!("Impossible de démarrer le pipeline DVR : {}", e))?;
@@ -191,15 +192,23 @@ impl DvrRecorder {
}))
}
/// Génère un nom de fichier horodaté `fpv_YYYYMMDD_HHMMSS.<ext>`
/// Génère un nom de fichier horodaté `fpv_YYYYMMDD_HHMMSS.<ext>` sans écrasement
pub fn generate_filepath(dir: &str, container: DvrContainer) -> PathBuf {
let now = Local::now();
let filename = format!(
"fpv_{}.{}",
now.format("%Y%m%d_%H%M%S"),
container.extension()
);
Path::new(dir).join(filename)
let stamp = now.format("%Y%m%d_%H%M%S");
let ext = container.extension();
let base_dir = Path::new(dir);
let candidate = base_dir.join(format!("fpv_{}.{}", stamp, ext));
if !candidate.exists() {
return candidate;
}
for n in 1..1000 {
let numbered = base_dir.join(format!("fpv_{}_{}.{}", stamp, n, ext));
if !numbered.exists() {
return numbered;
}
}
candidate
}
pub fn mode(&self) -> DvrMode {
@@ -313,10 +322,18 @@ mod tests {
assert!(path_mp4.to_str().unwrap().ends_with(".mp4"));
}
#[test]
fn test_dvr_mode_parsing() {
assert_eq!(DvrMode::from_str("composited"), DvrMode::CompositedOsd);
assert_eq!(DvrMode::from_str("COMPOSITED"), DvrMode::CompositedOsd);
assert_eq!(DvrMode::from_str("osd"), DvrMode::CompositedOsd);
assert_eq!(DvrMode::from_str("copy"), DvrMode::StreamCopy);
}
#[test]
fn test_dvr_recording_mkv_and_stop() {
let dir = "/tmp/test_dvr_run";
let dvr = DvrRecorder::start_composited_osd(dir, DvrContainer::Mkv, 320, 240)
let dir = format!("/tmp/test_dvr_run_{}", std::process::id());
let dvr = DvrRecorder::start_composited_osd(&dir, DvrContainer::Mkv, 320, 240)
.expect("start dvr failed");
let fake_rgba = vec![0u8; 320 * 240 * 4];
for _ in 0..10 {
@@ -328,6 +345,6 @@ mod tests {
assert!(path.exists());
let meta = std::fs::metadata(&path).expect("file metadata");
assert!(meta.len() > 0);
let _ = std::fs::remove_file(&path);
let _ = std::fs::remove_dir_all(&dir);
}
}