nx_adaptive_bitrate.nx
buildroot/runtime/nx_adaptive_bitrate.nx
about
nx_adaptive_bitrate.nx -- pick a quality tier from observed link state.
Composes with nx_bandwidth_meter to turn raw bytes/sec + RTT + loss
observations into a sealed-enum verdict the game engine can act on:
NX_AB_TIER_DIALUP -- 56 kbps dial-up, satellite, deep rural mobile
NX_AB_TIER_3G -- mobile 3G / poor 4G / shared cafe wifi
NX_AB_TIER_BROADBAND -- home cable / good 4G / urban fibre
NX_AB_TIER_FIBRE -- gigabit / data centre
Plus a concrete recommended-settings struct (audio bitrate, video
bitrate, game tickrate, AOI radius) so downstream code can act
without re-deriving from raw metrics.
Hysteresis: once at a given tier, the meter must observe a decisive
improvement (one full band above) before stepping up; one full band
below before stepping down. This avoids tier-flapping at boundary
conditions where a single sample crosses a threshold.
Source references (open):
- Opus codec recommended bitrates (Xiph wiki / RFC 6716)
- Source/CS:GO rate settings progression (developer.valvesoftware.com)
- WebRTC simulcast ladder choices (W3C webrtc-pc, MDN simulcast docs)
genealogy_id: opus_voip_tiers + source_rate_settings + simulcast_ladder
lineage_id: poor_internet_quality_step_router
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_tier.nxnx_bandwidth_meter.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 31 | const NX_MAGIC_6000: i64 = 6000 |
| 32 | const NX_MAGIC_12000: i64 = 12000 |
| 33 | const NX_MAGIC_150000: i64 = 150000 |
| 34 | const NX_MAGIC_24000: i64 = 24000 |
| 35 | const NX_MAGIC_400000: i64 = 400000 |
| 36 | const NX_MAGIC_32000: i64 = 32000 |
| 37 | const NX_MAGIC_800000: i64 = 800000 |
| 38 | const NX_MAGIC_30000: i64 = 30000 |
| 39 | const NX_MAGIC_2000000: i64 = 2000000 |
| 42 | const NX_AB_TIER_DIALUP: nx_int = 0 |
| 43 | const NX_AB_TIER_3G: nx_int = 1 |
| 44 | const NX_AB_TIER_BROADBAND: nx_int = 2 |
| 45 | const NX_AB_TIER_FIBRE: nx_int = 3 |
| 48 | const NX_AB_BPS_DIALUP_MAX: i64 = 7000 // 56 kbps |
| 49 | const NX_AB_BPS_3G_MAX: i64 = 50000 // ~400 kbps |
| 50 | const NX_AB_BPS_BROADBAND_MAX: i64 = 625000 // 5 Mbps |
| 54 | const NX_AB_RTT_FIBRE_MAX: i64 = 50 |
| 55 | const NX_AB_RTT_BROADBAND_MAX: i64 = 150 |
| 56 | const NX_AB_RTT_3G_MAX: i64 = 500 |
| 60 | const NX_AB_LOSS_CLEAN_MAX_Q14: i64 = 164 // ~1.0% |
| 61 | const NX_AB_LOSS_LOSSY_MAX_Q14: i64 = 819 // ~5.0% |
| 68 | const NX_AB_REC_TIER: nx_int = 0 |
| 69 | const NX_AB_REC_VOICE_BPS: nx_int = 1 // Opus encode bitrate |
| 70 | const NX_AB_REC_VIDEO_BPS: nx_int = 2 // VP9 encode bitrate (0 = off) |
| 71 | const NX_AB_REC_TICKRATE_HZ: nx_int = 3 // sim tick rate to broadcast |
| 72 | const NX_AB_REC_AOI_RADIUS_M: nx_int = 4 // metres (not Q14) for streaming |
| 73 | const NX_AB_REC_SIZE: nx_int = 5 |
functions
| 77 | func _ab_tier_from_bps(bps: i64) -> nx_int {
called by 1: nx_adaptive_bitrate_classify |
| 84 | func _ab_tier_from_rtt(rtt_ms: i64) -> nx_int {
called by 1: nx_adaptive_bitrate_classify |
| 91 | func _ab_tier_from_loss(loss_q14: i64) -> nx_int {
called by 1: nx_adaptive_bitrate_classify |
| 98 | func _ab_min_tier(a: nx_int, b: nx_int, c: nx_int) -> nx_int {
called by 1: nx_adaptive_bitrate_classify |
| 109 | func nx_adaptive_bitrate_classify(meter: *i64) -> nx_int { |
| 129 | func nx_adaptive_bitrate_recommend(meter: *i64, out: *i64) -> nx_int { |
| 164 | func main() -> i64 { |