Skip to content

Cameras Subsystem & Lifecycle Architecture ​

RUSEON Core provides a high-concurrency camera management engine (internal/stream/manager.go) capable of supervising hundreds of simultaneous RTSP video streams with automated health monitoring, auto-recovery, and zero-transcoding distribution.


1. Camera Lifecycle State Machine ​

Each configured camera runs as an isolated supervisor loop in its own goroutine:

StateDescriptionTransition Triggers
ConfiguredCamera record exists in BadgerDBProcess startup or camera created via API/UI
ConnectingEstablishing TCP connection and performing RTSP handshakeAcquisition of dialSemaphore token
StreamingReceiving video/audio packets and pushing into RingBufferSuccessful RTSP PLAY response
ReconnectingWaiting for retry interval after network dropSocket closed, EOF, or TCP timeout
DisabledCamera explicitly paused by administratorUpdated via REST API (enabled: false)

2. Lazy Ingestion Mode (lazy_hls) ​

For cellular (4G/5G) connections or installations with hundreds of passive cameras:

  • When lazy_hls: true is set, RUSEON does not maintain an active RTSP connection to the camera while no operator is watching.
  • When an operator opens the camera in the Web UI, RUSEON establishes the RTSP connection within milliseconds.
  • After 30 seconds of inactivity (all viewers closed), the stream is gracefully disconnected to save network bandwidth.

3. Dual-Stream Architecture (Main vs. Sub) ​

RUSEON Core supports multi-profile setups per camera:

  • Main Stream: High resolution (4K / 1080p @ 4–8 Mbps) configured for fMP4 disk archiving and single-camera full-screen viewing.
  • Sub Stream: Low resolution (720p / 360p @ 512 Kbps) for multi-camera video walls and low-bandwidth mobile viewing.

Released under the MIT License.