Skip to content

Multi-Algorithm Bitrate Control Support #3

@andrescera

Description

@andrescera

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

  • Define BalancerAlgorithm interface
  • Refactor current algorithm to use interface
  • Add --balancer=<name> CLI flag

Phase 2: Basic Algorithms

  • Add fixed mode (trivial, useful for testing)
  • Add aimd mode (simple alternative)

Phase 3: Advanced

  • Add latency_target mode
  • Add config file support for algorithm parameters
  • Consider BBR-style for advanced users

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions