System Architecture & Subsystem Blueprint
RUSEON Core is an ultra-high performance video infrastructure engine written in Go. It is architected from the ground up for high throughput, sub-500ms streaming latency, predictable memory usage, and hardware fault resilience.
Architectural Guarantees & Principles
- Zero Transcoding Overhead: RUSEON Core never decodes video frames into raw RGB/YUV pixel buffers for streaming. It repackages compressed NAL units directly in RAM, reducing CPU usage by >90% compared to traditional VMS software.
- Subsystem Fault Isolation: A slow disk write or an unclosed network socket on a single WebRTC viewer can never block the main RTSP ingestion pipeline. The Ring Buffer drops non-keyframe packets per slow subscriber independently.
- Memory Safety & Determinism: All packet buffers are managed via bounded pools and ring queues, preventing unbounded heap growth and eliminating memory fragmentation under sustained load.
- Crash Resilience: All video archives are stored in Fragmented MP4 (fMP4) with automated startup atom boundary recovery, guaranteeing zero unplayable video files after sudden power loss.
Architecture Subsystems Guide
| Subsystem | Core Responsibilities | Implementation Files | Deep Dive |
|---|---|---|---|
| Ring Buffer | Shared memory frame hub, atomic.Pointer[CodecParams], KeyFrame backfill, slow consumer isolation | internal/buffer/ring.go | Ring Buffer Deep Dive |
| Stream Pipeline | RTSP ingestion, NAL unit parsing, SPS/PPS extraction, dial throttler | internal/stream/ | Stream Pipeline |
| Recording Pipeline | fMP4 box serialization, Linux sync_file_range, FADV_DONTNEED, atomic recovery | internal/recorder/ | Recording Pipeline |
| LL-HLS Pipeline | On-demand playlist generation, singleflight caching, lazy muxer lifecycle | internal/api/hls.go | HLS Pipeline |
| WebRTC Pipeline | WHEP negotiation, Pion WebRTC integration, ICE candidate gathering | internal/webrtc/ | WebRTC Pipeline |
| Storage Architecture | BadgerDB v4 LSM store, hierarchical disk directory partitioning | pkg/storage/ | Storage Architecture |
| Concurrency Model | Goroutine lifecycle, channel ownership, mutex contention prevention | Core codebase | Concurrency Model |
| Internal Event Bus | Async pub/sub event router, topic matching, drop metrics | internal/events/bus.go | Event Bus |
| Architecture Decisions (ADR) | Why Go, why fMP4, why BadgerDB, why WHEP instead of WHIP | Architectural record | Decisions Log |