diff --git a/src/redis_rtsp.rs b/src/redis_rtsp.rs index 71e3778..304147a 100644 --- a/src/redis_rtsp.rs +++ b/src/redis_rtsp.rs @@ -119,6 +119,7 @@ pub async fn run_redis_worker( let checked_at = timestamp_millis(); let probe = probe_rtsp(&attempt, config.capture_timeout_ms).await; + let stop_path_after_attempt = probe.is_dead_path(); let (status, screenshot_path, error, attempt_captured) = if probe .is_connectable() { @@ -177,6 +178,10 @@ pub async fn run_redis_worker( path_captured = true; break; } + + if stop_path_after_attempt { + break; + } } if path_captured { @@ -367,6 +372,13 @@ impl RtspProbe { "ok" | "auth_required" | "rtsp_200" | "rtsp_401" | "rtsp_403" ) } + + fn is_dead_path(&self) -> bool { + matches!( + self.status.as_str(), + "rtsp_400" | "rtsp_404" | "rtsp_451" | "bad_response" + ) + } } fn parse_rtsp_status(response: &[u8]) -> Result> {