Overview
This issue tracks the potential migration of belacoder from C to Rust.
Current State
belacoder is a ~800-line C application that:
- Parses CLI arguments and a GStreamer pipeline file
- Constructs and runs a GStreamer pipeline
- Pulls samples from an
appsink and sends them over SRT
- Polls SRT statistics and adjusts encoder bitrate
- Handles signals for graceful shutdown and config reload
Why Rust?
- Memory safety - Eliminates buffer overflows, use-after-free at compile time
- Better error handling -
Result<T, E> forces explicit error handling
- No undefined behavior - Safer signal handling
- GStreamer bindings are mature -
gstreamer-rs is well-maintained
- No GC latency - Critical for real-time video
- Performance parity with C - Zero-cost abstractions
Key Dependencies
| Dependency |
C Binding |
Rust Binding |
| GStreamer |
Native |
gstreamer-rs (mature) |
| GLib |
Native |
glib-rs (mature) |
| libsrt |
Native |
srt-rs (exists, less active) |
| POSIX signals |
Native |
signal-hook (mature) |
Risks
- SRT bindings maturity -
srt-rs less actively maintained than libsrt
- Build complexity - Cross-compilation for Jetson ARM needs setup
- Team familiarity - Rust learning curve
Incremental Migration Path
Phase 1: Preparation (C) ✅
Phase 2: Bitrate Controller in Rust
Phase 3: SRT Sender in Rust
Phase 4: Full Port
Recommended Rust Crates
[dependencies]
gstreamer = "0.22"
gstreamer-app = "0.22"
glib = "0.19"
clap = "4"
anyhow = "1"
signal-hook = "0.3"
log = "0.4"
Effort Estimate
| Component |
Complexity |
Estimate |
| CLI parsing |
Low |
2-4 hours |
| Pipeline construction |
Medium |
1-2 days |
| Appsink + SRT send |
Medium |
1-2 days |
| Bitrate controller |
Low |
4-8 hours |
| Signal handling |
Low |
2-4 hours |
| Testing |
High |
2-3 days |
| Total |
|
1-2 weeks |
Recommendation
Short-term (0-6 months): Stay with C, focus on code quality and tests
Medium-term (6-12 months): Start with bitrate controller in Rust (self-contained, easy to test)
Long-term: Full port only if incremental modules succeed
Overview
This issue tracks the potential migration of belacoder from C to Rust.
Current State
belacoder is a ~800-line C application that:
appsinkand sends them over SRTWhy Rust?
Result<T, E>forces explicit error handlinggstreamer-rsis well-maintainedKey Dependencies
gstreamer-rs(mature)glib-rs(mature)srt-rs(exists, less active)signal-hook(mature)Risks
srt-rsless actively maintained than libsrtIncremental Migration Path
Phase 1: Preparation (C) ✅
Phase 2: Bitrate Controller in Rust
Phase 3: SRT Sender in Rust
srt-rsbindingsPhase 4: Full Port
clapsignal-hookRecommended Rust Crates
Effort Estimate
Recommendation
Short-term (0-6 months): Stay with C, focus on code quality and tests
Medium-term (6-12 months): Start with bitrate controller in Rust (self-contained, easy to test)
Long-term: Full port only if incremental modules succeed