LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Remote desktop: the browser's bandwidth estimate (REMB) is a ceiling only when it falls or right after loss, and the rate climbs 25 % a second without loss, so a new connection reaches the top in ~10 s instead of ~3 min at 3 Mbit/s; x264 keeps the deblocking filter ultrafast turns off (~5 % of the encoder), so software video no longer shows blocks
Federico Pereira40ae74fc36bb
diff --git a/docs/REMOTE.md b/docs/REMOTE.mdindex 6628d8d..aa55e9d 100644--- a/docs/REMOTE.md+++ b/docs/REMOTE.md@@ -242,11 +242,14 @@ the session's rectangle (`enc.c`, the only image code left); it keeps no copy ofdesktop sees (protected windows in black, from `media_composed`, or the GPU's read-back) goes to alive encoder: `lord-media` in `MK_STREAM` mode, through a sealed memfd of 3 slots, like the screenrecording. It uses H.264 with VA-API when the card encodes it, else libx264 (`ultrafast`,-`zerolatency`, CRF 22 with a bit-rate cap), or VP8 with libvpx (`realtime`) for browsers without+`zerolatency`, CRF 22 with a bit-rate cap, and the deblocking filter that `ultrafast` turns off), or VP8 with libvpx (`realtime`) for browsers withoutH.264. Every viewer of the session gets the same encoded frames over the session socket(`RP_VFRAME`, `RP_AFRAME`); the bridge only packetizes and encrypts. The bit rate is the slowest-viewer's: each bridge lowers its target on loss reported by the browser (receiver reports, REMB)-and raises it slowly when there is none (300 kbit/s to 12 Mbit/s). A viewer that falls more than+viewer's: each bridge lowers its target on loss reported by the browser (receiver reports) and+raises it by 25 % a second when there is none (6 % for 5 s after congestion; 300 kbit/s to 12 Mbit/s).+The browser's estimate (REMB) is a ceiling only when it falls by more than 15 % or right after loss:+it only grows with what the browser receives, so as a fixed ceiling it kept a new connection near+3 Mbit/s for about three minutes (video in blocks); now a LAN reaches the top in about 10 s. A viewer that falls more than3 MB behind skips frames until the next keyframe; a lost frame (PLI, FIR) asks for one, and thecurrent screen is encoded again for it. Two users means two sessions, two `lord-server`s and twoencoders, each as its own user.diff --git a/server/src/media/helper/lm_stream.c b/server/src/media/helper/lm_stream.cindex bf7be48..405c1ac 100644--- a/server/src/media/helper/lm_stream.c+++ b/server/src/media/helper/lm_stream.c@@ -130,7 +130,9 @@ static AVCodecContext *open_sw(Vid *e, const char *name, int fps) {av_dict_set(&o, "profile", "baseline", 0);av_dict_set(&o, "crf", "22", 0);av_dict_set(&o, "forced-idr", "1", 0);- av_dict_set(&o, "x264-params", "repeat-headers=1:annexb=1:aud=0:scenecut=0", 0);+ /* ultrafast turns the deblocking filter off, which left video in visible blocks at a few+ * Mbit/s; it costs ~5 % of the encoder (1280x800 on a 1.8 GHz Xeon: 88 → 84 fps, 2 threads) */+ av_dict_set(&o, "x264-params", "repeat-headers=1:annexb=1:aud=0:scenecut=0:deblock=1", 0);} else {c->thread_count = 2;c->bit_rate = (int64_t)e->kbps * 1000;diff --git a/server/src/remote/rtc.c b/server/src/remote/rtc.cindex 7f457ad..6b97b8f 100644--- a/server/src/remote/rtc.c+++ b/server/src/remote/rtc.c@@ -145,8 +145,8 @@ struct Rtc {double sctp_t;Track v, a;/* congestion: the viewer's target */- unsigned kbps;- double rate_at, kf_at, lost;+ unsigned kbps, remb; /* remb: the browser's last estimate (kbit/s) */+ double rate_at, kf_at, lost, congested_at;unsigned long nacks, plis, resent, dtls_rx;double last_sr, created, last_consent, stun_win;int stun_n, failed;@@ -744,9 +744,11 @@ static void on_fb(void *ud, const RwFb *f) {case RW_FB_RR:if (f->ssrc != r->v.ssrc) break;r->lost = r->lost * 0.7 + f->lost_frac / 256.0 * 0.3;- if (f->lost_frac > 25) set_rate(r, r->kbps * 0.75);- else if (f->lost_frac > 5) set_rate(r, r->kbps * 0.92);- else if (f->lost_frac == 0 && t - r->rate_at > 1000) set_rate(r, r->kbps * 1.06 + 50);+ if (f->lost_frac > 25) { r->congested_at = t; set_rate(r, r->kbps * 0.75); }+ else if (f->lost_frac > 5) { r->congested_at = t; set_rate(r, r->kbps * 0.92); }+ else if (f->lost_frac == 0 && t - r->rate_at > 1000)+ /* no loss: up fast (a LAN reaches the top in about 10 s), slowly for 5 s after congestion */+ set_rate(r, r->kbps * (t - r->congested_at > 5000 ? 1.25 : 1.06) + 50);break;case RW_FB_PLI:case RW_FB_FIR:@@ -764,10 +766,17 @@ static void on_fb(void *ud, const RwFb *f) {if (h->len && h->seq == seq) { send_sel(r, h->b, h->len); r->resent++; }}break;- case RW_FB_REMB:- if (f->bitrate / 1000 < r->kbps) set_rate(r, (double)(f->bitrate / 1000));+ case RW_FB_REMB: {+ /* The browser's estimate only grows with what it receives, so as a fixed ceiling it kept a+ * new connection at ~3 Mbit/s for minutes. It counts as congestion when it falls (the+ * browser saw the delay grow) or right after loss; then it is a ceiling. */+ unsigned b = (unsigned)(f->bitrate / 1000);+ if (r->remb && b < r->remb * 0.85) r->congested_at = t;+ if (t - r->congested_at < 5000 && b < r->kbps) set_rate(r, b);+ r->remb = b;break;}+ }}/* ---- ICE-lite, the built-in STUN server, external STUN and TURN ---- */