mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(android-video): avoid mid-frame NAL truncation in AnnexBFramer while keeping Qualcomm low_latency decoder
This commit is contained in:
1 parent
19cdf982c4
commit
fe71cdd2e9
1 file changed
+4
-36
@@ -471,13 +471,7 @@ impl UdpVideoReceiver {
|
||||
{
|
||||
let addr = format!("{}:{}", bind_ip, port);
|
||||
let socket = UdpSocket::bind(&addr)?;
|
||||
// En mode Raw Annex-B (RubyFPV), un timeout de 2 ms permet de flusher immédiatement
|
||||
// la dernière trame dès la fin d'un burst UDP sans attendre le start code suivant.
|
||||
let read_timeout = match transport {
|
||||
StreamTransport::Raw => Duration::from_millis(2),
|
||||
StreamTransport::Rtp => Duration::from_millis(50),
|
||||
};
|
||||
socket.set_read_timeout(Some(read_timeout))?;
|
||||
socket.set_read_timeout(Some(Duration::from_millis(50)))?;
|
||||
log::info!(
|
||||
"[UDP Video] En écoute sur {} ({:?}, {:?})",
|
||||
addr,
|
||||
@@ -539,16 +533,13 @@ impl UdpVideoReceiver {
|
||||
);
|
||||
}
|
||||
StreamTransport::Raw => {
|
||||
// Émettre uniquement des unités NAL complètes délimitées par start code
|
||||
// pour éviter de tronquer une trame en plein milieu d'un burst radio (artefacts).
|
||||
annex_b_framer.push_chunk(
|
||||
&buf[..len],
|
||||
pts_us,
|
||||
&mut emit_and_track,
|
||||
);
|
||||
// RubyFPV découpe en paquets de 1024 octets (`video_usb: 1 5600 1024`) :
|
||||
// un paquet plus court marque la fin immédiate de la trame.
|
||||
if len < 1024 {
|
||||
annex_b_framer.flush_pending(pts_us, &mut emit_and_track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,30 +548,7 @@ impl UdpVideoReceiver {
|
||||
m.dropped_packets = depacketizer.dropped_packets;
|
||||
m.signal_live = true;
|
||||
}
|
||||
_ => {
|
||||
if transport == StreamTransport::Raw {
|
||||
let now = Instant::now();
|
||||
let pts_us = start_time.elapsed().as_micros() as u64;
|
||||
annex_b_framer.flush_pending(pts_us, |nal| {
|
||||
if !nal.is_codec_config {
|
||||
fps_frames = fps_frames.saturating_add(1);
|
||||
if let Some(prev_f) = last_frame_at {
|
||||
let dt_ms =
|
||||
now.duration_since(prev_f).as_secs_f32() * 1000.0;
|
||||
if dt_ms > 1.0 && dt_ms < 250.0 {
|
||||
expected_interval_ms =
|
||||
expected_interval_ms * 0.9 + dt_ms * 0.1;
|
||||
let diff = (dt_ms - expected_interval_ms).abs();
|
||||
jitter_ms_ewma =
|
||||
jitter_ms_ewma * 0.85 + diff * 0.15;
|
||||
}
|
||||
}
|
||||
last_frame_at = Some(now);
|
||||
}
|
||||
on_nal(nal);
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let win_elapsed = fps_window_start.elapsed();
|
||||
|
||||
Reference in new issue
Block a user