RTSP Ingestion
RUSEON Core connects to IP cameras and RTSP streaming sources using bluenviron/gortsplib/v4 and pion/rtp.
Connection Lifecycle
- Dial Throttling: Connection handshakes pass through a concurrency semaphore (
dialSemaphore, max 10 concurrent initial dials) to prevent Thundering Herd issues and network interface saturation when booting large camera fleets. - Describe & Setup: Issues RTSP
DESCRIBEand sets up tracks viaSETUP(using TCP interleaved transport by default, with configurable UDP mode). - Play & Read: Issues
PLAYand registers packet callbacks:OnPacketRTP: Parses RTP payload into NAL units.OnPacketLost: Increments error counters and logs warnings without dropping the session.OnDecodeError: Handles corrupted frames gracefully.
Video Codec Processing
RUSEON Core demuxes video streams without CPU-intensive decoding:
- H.264 (AVC): Extracts SPS (type 7), PPS (type 8), and IDR slices (type 5).
- H.265 (HEVC): Extracts VPS (type 32), SPS (type 33), PPS (type 34), and IRAP/IDR slices (types 16–21).
- Bitrate Calculation: Calculated over a rolling 1-second window and reported in camera telemetry.
Reconnection with Exponential Backoff & Jitter
When an RTSP connection drops:
- Emits a
camera_offlineevent over the EventBus and updates state tooffline. - Initiates reconnection using an exponential backoff algorithm with jitter: $$\text{delay} = \min(60\text{s}, 1\text{s} \times 2^{\text{reconnectCount}}) \pm 20% \text{ jitter}$$
- Prevents synchronised reconnect spikes against target camera servers.
- Upon successful re-establishment, emits
camera_onlineand transitions camera state back toonline.