$ show NOALBS/nginx-obs-automatic-low-bitrate-switching
NOALBS is a Rust application that automatically manages OBS stream quality by monitoring real-time stream health (bitrate, RTT, offline detection) from various stream servers (Nginx-RTMP, SLS, Xiu, Mediamtx, etc.) and switching scenes in OBS accordingly. It also functions as a Twitch/Kick chat bot, allowing streamers to control streaming behavior via commands. The architecture is a single async binary using Tokio, with modular traits for stream servers (StreamServersCommands), broadcasting software (BroadcastingSoftwareLogic), chat platforms, and configuration. Key data flows: config loading → state initialization → polling stream server stats via HTTP → receiving OBS WebSocket events → switching logic updates OBS scenes. External dependencies include OBS WebSocket, Twitch IRC/PubSub, and various streaming server APIs. The codebase demonstrates non-obvious Rust patterns such as using `typetag::serde` for serializable trait objects and a localization system with YAML files. However, some commented-out code, hardcoded delays, and a warning about an OBS source feature being broken indicate areas of incomplete refactoring.
The LLM identified 2 files worth highlighting for reuse:
Implements an event system using `typetag::serde` to serialize and deserialize polymorphic trait objects without a common wrapper enum. This pattern enables extensible event handling where new event types can be added without modifying serialization logic. It is a non-obvious Rust pattern that could be reused in any project requiring dynamic event serialization over WebSocket or IPC.
WebSocket server module using tokio-tungstenite for bidirectional communication with external clients. It handles connection setup, TLS support, and message serialization/deserialization via serde. The pattern of separating requests and responses into dedicated files and using a handler trait is reusable for any Rust application needing a WebSocket interface for command/response or event streaming.