From a523f995acee8852af8ffefee0573083011d4f41 Mon Sep 17 00:00:00 2001 From: selikhov Date: Sun, 4 Oct 2026 14:04:19 +0300 Subject: [PATCH] voelin-stream: let the retransmission test survive a loss at the very end The relay drops every 25th RTP packet it forwards, retransmissions included, so which packet that is shifts with timing. Under load it can be the stream's last packet, and no later packet shows the viewer the hole to ask for, so the last of the 90 frames never arrived. One more, uncounted frame now follows them; a loss in the middle still shows up as a missing frame or a gap. Co-Authored-By: Claude Opus 5.5 --- crates/voelin-stream/tests/loopback.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/voelin-stream/tests/loopback.rs b/crates/voelin-stream/tests/loopback.rs index c2540ee..cda110b 100644 --- a/crates/voelin-stream/tests/loopback.rs +++ b/crates/voelin-stream/tests/loopback.rs @@ -232,19 +232,23 @@ async fn stream_noise( /// One media packet in 25 lost on the way to the viewer: the viewer asks /// again (NACK) and the streamer retransmits (RTX) before the depacketizer -/// gives up, so every frame arrives whole and in order. +/// gives up, so every frame arrives whole and in order. A NACK needs a later +/// packet to show the hole, so one more frame follows the 90 counted: a loss +/// at the very end (retransmissions shift which packet is the 25th) can only +/// cut that one. #[tokio::test(flavor = "multi_thread")] async fn losses_are_repaired_by_retransmission() { let _ = tracing_subscriber::fmt().with_env_filter("warn").with_test_writer().try_init(); let relay = Relay::new(Rule::LoseEvery(25)).await; let config = PeerConfig { bandwidth_estimation: false, ..PeerConfig::loopback() }; let (streamer, mut viewer) = connect(&config, &config, Some(&relay)).await; - // 3 s at 30 fps, 12 KB frames (about 10 packets each), keyframes of 60 KB. - let received = stream_noise(streamer, &mut viewer, (90, 30, 12_000), (30, 60_000)).await; + // 3 s at 30 fps, 12 KB frames (about 10 packets each), keyframes of 60 KB, + // and the one more frame. + let received = stream_noise(streamer, &mut viewer, (91, 30, 12_000), (30, 60_000)).await; let (media, lost) = relay.media(); eprintln!("{received:?}; relay: {lost} of {media} media packets lost"); assert!(lost >= 30, "the relay lost too little: {lost} of {media}"); - assert_eq!(received.frames, 90, "{received:?}"); + assert!(received.frames >= 90, "{received:?}"); assert_eq!(received.gaps, 0, "a loss reached the viewer: {received:?}"); }