diff --git a/crates/client/src/share/session.rs b/crates/client/src/share/session.rs index 4ebd5fe..da30a52 100644 --- a/crates/client/src/share/session.rs +++ b/crates/client/src/share/session.rs @@ -60,6 +60,7 @@ const INITIAL_DELAY_MS: i64 = 100; const MIN_DELAY_MS: i64 = 20; const MAX_DELAY_MS: i64 = 200; const RESYNC_MS: i64 = 2000; +const CATCH_UP_MS: i64 = 1000; const DELAY_MARGIN_MS: i64 = 8; const DELAY_WINDOW_MS: i64 = 3000; const DELAY_PERCENTILE: usize = 98; @@ -1074,6 +1075,14 @@ fn watch_video( while !stop.load(Ordering::Relaxed) { match rx.recv_timeout(NACK_TICK) { Ok(bytes) => { + if let Some((_, Packet::Video { ts_ms, .. })) = split(&bytes) + && clock.now() - clock.origin(ts_ms) > CATCH_UP_MS + { + while rx.try_recv().is_ok() {} + reassembler = Reassembler::new(); + tracing::warn!("share watch fell behind, skipping to the next keyframe"); + continue; + } if let Some((_, packet)) = split(&bytes) && let Some(last) = reassembler .push(&packet, Instant::now())