Skip to content

fix: improve rtsp reconnect and fallback#16

Merged
lan17 merged 31 commits intomainfrom
lev/rtsparch
Jan 27, 2026
Merged

fix: improve rtsp reconnect and fallback#16
lan17 merged 31 commits intomainfrom
lev/rtsparch

Conversation

@lan17
Copy link
Copy Markdown
Owner

@lan17 lan17 commented Jan 25, 2026

Summary

  • Major RTSP robustness work: improved reconnect/fallback behavior, more resilient recording lifecycle, and clearer state handling.
  • Large RTSP refactor into focused components (MotionDetector / FramePipeline / Recorder / Clock) and then split into a sources/rtsp/ package for maintainability.
  • Added extensive hermetic RTSP runtime tests plus a DB logs querying skill and planning doc.

Key Changes

  • Reconnect and fallback logic hardened: exact max attempts, aggressive reconnect when idle, detect-stream fallback with probe/backoff, and deferred fallback while recording.
  • Recording robustness: restart backoff, restart while motion is recent, rotation safety, centralized recording state transitions, and more sensitive thresholds while recording.
  • Timeout handling: ffmpeg/ffprobe fallback when -rw_timeout/-stimeout unsupported, with log severity reduced to WARN for the timeout-option case.
  • RTSP implementation split into src/homesec/sources/rtsp/{core,frame_pipeline,recorder,motion,hardware,clock,utils}.py and import paths updated.
  • Tests: new hermetic coverage for reconnects, fallback activation/defer, detect recovery, recording backoff, and ffmpeg/ffprobe timeout fallback.
  • Misc: align config validation for recording_sensitivity_factor, update example config, add rtsp_improvements_plan.md, add skills/local/homesec-db-logs/SKILL.md, refresh uv.lock.

Testing

  • make check

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 78.61635% with 272 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.66%. Comparing base (36952bc) to head (7ffa7a4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/homesec/sources/rtsp/core.py 78.10% 150 Missing ⚠️
src/homesec/sources/rtsp/frame_pipeline.py 76.19% 50 Missing ⚠️
src/homesec/sources/rtsp/recorder.py 71.42% 30 Missing ⚠️
src/homesec/sources/rtsp/hardware.py 65.78% 26 Missing ⚠️
src/homesec/sources/rtsp/motion.py 85.96% 8 Missing ⚠️
src/homesec/sources/rtsp/utils.py 82.60% 4 Missing ⚠️
src/homesec/models/source/ftp.py 93.93% 2 Missing ⚠️
src/homesec/models/source/rtsp.py 97.87% 1 Missing ⚠️
src/homesec/sources/rtsp/clock.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #16      +/-   ##
==========================================
+ Coverage   72.77%   81.66%   +8.88%     
==========================================
  Files          59       69      +10     
  Lines        4849     5263     +414     
==========================================
+ Hits         3529     4298     +769     
+ Misses       1320      965     -355     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lan17 lan17 marked this pull request as ready for review January 27, 2026 19:32
@lan17 lan17 merged commit 8ac42d2 into main Jan 27, 2026
4 checks passed
@lan17 lan17 deleted the lev/rtsparch branch January 27, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant