Overview
Add support for multiple bitrate control ("balancing") algorithms at runtime.
Motivation
The current RTT + buffer heuristic is battle-tested but may not suit all network types. Different scenarios benefit from different algorithms:
- Stable networks → Fixed bitrate
- Variable mobile networks → BBR-style probing
- Ultra-low latency → Latency-target controller
Proposed CLI Interface
belacoder pipeline.txt host 4000 --balancer=rtt_buffer # Current (default)
belacoder pipeline.txt host 4000 --balancer=aimd
belacoder pipeline.txt host 4000 --balancer=latency_target --rtt-target=150
belacoder pipeline.txt host 4000 --balancer=fixed --fixed-bitrate=4000000
Controller Interface
typedef struct {
const char *name;
void* (*init)(BalancerConfig *config);
BalancerOutput (*step)(void *state, BalancerInput *input);
void (*cleanup)(void *state);
} BalancerAlgorithm;
Candidate Algorithms
| Algorithm |
Complexity |
Best For |
| RTT+Buffer (current) |
Low |
General use |
| AIMD |
Low |
Fair sharing |
| Fixed/Ladder |
Minimal |
Stable networks |
| Latency-Target |
Medium |
Ultra-low latency |
| BBR-style |
High |
Variable networks |
| PID |
Medium |
Fine control |
Implementation Tasks
Phase 1: Interface
Phase 2: Basic Algorithms
Phase 3: Advanced
Metrics Available to Algorithms
| Metric |
Source |
Frequency |
| RTT (ms) |
srt_bstats() |
Every 20 ms |
| Send buffer (packets) |
SRTO_SNDDATA |
Every 20 ms |
| Throughput (bps) |
mbpsSendRate |
Every 20 ms |
| Negotiated latency |
SRTO_PEERLATENCY |
Once at connect |
Overview
Add support for multiple bitrate control ("balancing") algorithms at runtime.
Motivation
The current RTT + buffer heuristic is battle-tested but may not suit all network types. Different scenarios benefit from different algorithms:
Proposed CLI Interface
belacoder pipeline.txt host 4000 --balancer=rtt_buffer # Current (default) belacoder pipeline.txt host 4000 --balancer=aimd belacoder pipeline.txt host 4000 --balancer=latency_target --rtt-target=150 belacoder pipeline.txt host 4000 --balancer=fixed --fixed-bitrate=4000000Controller Interface
Candidate Algorithms
Implementation Tasks
Phase 1: Interface
BalancerAlgorithminterface--balancer=<name>CLI flagPhase 2: Basic Algorithms
fixedmode (trivial, useful for testing)aimdmode (simple alternative)Phase 3: Advanced
latency_targetmodeMetrics Available to Algorithms
srt_bstats()SRTO_SNDDATAmbpsSendRateSRTO_PEERLATENCY