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 page's top bar shows frames a second shown/encoded, the browser screen's refresh rate, GPU or CPU composition and the encoder in hardware or software (hover: ms per frame), from a fixed-size RP_VINFO the session sends when it changes
Federico Pereirac016068f5aef
diff --git a/docs/REMOTE.md b/docs/REMOTE.mdindex 2fb7746..95e8dbc 100644--- a/docs/REMOTE.md+++ b/docs/REMOTE.md@@ -261,6 +261,12 @@ without a monitor composes at that rate too (at least 60); on the monitor, the mpaces composition. Measured on VM 116 (no GPU, 1280×800, a 60 fps video window under blurred windows):18 frames a second before 0.8.5's work on the CPU path, 35 after.+**The page's top bar says how the video is made:** codec, encoder in hardware (VA-API) or software,+path (UDP, TCP, relay), frames a second shown by the browser / encoded by the computer, the browser+screen's refresh rate, and whether the session composes on the GPU or the CPU (hover: the encoding+time per frame). The session sends it as `RP_VINFO` (fixed-size numbers, when they change), the bridge+turns it into `{"t":"vinfo"}` with numbers only.+**The GPU keeps composing.** Until 0.8.3 a remote viewer switched the session to CPU composition.Now `gpu_frame` reads the composed frame back (`gpu_read_next`) once, for the encoder and the tiles,and the screen keeps its GPU composition. Only two cases still use the CPU path: protected windows ondiff --git a/server/src/main.c b/server/src/main.cindex 61ec0f6..000be29 100644--- a/server/src/main.c+++ b/server/src/main.c@@ -1242,6 +1242,7 @@ static void present_cpu(Server *s, Out *o, int index, Rect r, int feed) {view_of(o, index);const Canvas *seen = media_composed(&out, mirror_watchers() > 0, &mc);view_reset();+ mirror_composed_on_gpu(0); /* this frame was painted on the CPU */mirror_frame(seen->px, seen->stride, W, H);mirror_cursor(px_, py_, k.mode, k.px, k.w, k.h, k.hx, k.hy, k.gen);}@@ -1297,6 +1298,7 @@ static void present_memory(Server *s, Out *o, int index, int feed) {/* what the browser sees and what is recorded: with the protected windows in black */MediaCursor mc = { x, y, k.mode, k.px, k.w, k.h, k.hx, k.hy };const Canvas *seen = media_composed(&out, mirror_watchers() > 0, &mc);+ mirror_composed_on_gpu(0); /* this frame was painted on the CPU */mirror_frame(seen->px, seen->stride, o->scene.w, o->scene.h);mirror_cursor(x, y, k.mode, k.px, k.w, k.h, k.hx, k.hy, k.gen);}@@ -1384,6 +1386,7 @@ static void render_frame(Server *s) {cursor_now(s, &k, out_scale(o));int cx, cy;pointer_phys(s, o, &cx, &cy);+ mirror_composed_on_gpu(1);mirror_frame(rb, o->scene.w, o->scene.w, o->scene.h);mirror_cursor(cx, cy, k.mode, k.px, k.w, k.h, k.hx, k.hy, k.gen);}diff --git a/server/src/media/mstream.c b/server/src/media/mstream.cindex 1c0c59d..7264818 100644--- a/server/src/media/mstream.c+++ b/server/src/media/mstream.c@@ -152,6 +152,14 @@ static int start(Enc *e, int codec) {return 0;}+int mstream_info(int codec, int *hw, int *fps, long *enc100) {+ if (codec < 1 || codec >= MS_CODECS || !E[codec].id) return 0;+ *hw = E[codec].hw;+ *fps = E[codec].fps;+ *enc100 = E[codec].enc100;+ return 1;+}+int mstream_active(void) {for (int c = 1; c < MS_CODECS; c++) if (E[c].id) return 1;return 0;diff --git a/server/src/media/mstream.h b/server/src/media/mstream.hindex c3fcc8b..8279abc 100644--- a/server/src/media/mstream.h+++ b/server/src/media/mstream.h@@ -23,6 +23,9 @@ void mstream_keyframe(int codec);void mstream_tick(void);double mstream_timeout(void); /* ms until mstream_tick has work, or -1 */int mstream_active(void); /* an encoder is running */+/* The running encoder of that codec: hardware or not, frames a second, encoding time in 1/100 ms per+ * frame. 0 if none runs. */+int mstream_info(int codec, int *hw, int *fps, long *enc100);/* "H.264 (VA-API) 30 fps 2.1 ms/frame" for the logs */void mstream_describe(int codec, char *out, size_t n);diff --git a/server/src/remote/client.html b/server/src/remote/client.htmlindex 5c563ca..4cc053f 100644--- a/server/src/remote/client.html+++ b/server/src/remote/client.html@@ -60,6 +60,8 @@ const L = {en: {full: 'Full screen', out: 'Disconnect', conn: 'Connecting…', reconn: 'Reconnecting…', retry: 'Try again', signout: 'Sign out',sndOn: 'Turn sound on', sndOff: 'Turn sound off', video: 'Video', bye: 'The session ended.',+ hwEnc: 'hardware', swEnc: 'software',+ vinfoTip: (comp, enc, ms) => `Screen composed on the ${comp}; video encoded in ${enc} (${ms} ms per frame). Frames a second: shown here / sent by the computer.`,unsupTitle: 'This browser can’t show the remote desktop',unsupText: 'The remote desktop arrives as live video over WebRTC. This browser is missing something it needs:',reqRtc: 'WebRTC (RTCPeerConnection) with data channels', reqCodec: 'H.264 or VP8 video decoding', reqSecure: 'A secure (https) page — this one is',@@ -78,6 +80,8 @@ const L = {es: {full: 'Pantalla completa', out: 'Desconectar', conn: 'Conectando…', reconn: 'Reconectando…', retry: 'Reintentar', signout: 'Cerrar sesión',sndOn: 'Activar el sonido', sndOff: 'Silenciar', video: 'Video', bye: 'La sesión terminó.',+ hwEnc: 'por hardware', swEnc: 'por software',+ vinfoTip: (comp, enc, ms) => `Pantalla compuesta en la ${comp}; video codificado ${enc} (${ms} ms por cuadro). Cuadros por segundo: mostrados aquí / enviados por la computadora.`,unsupTitle: 'Este navegador no puede mostrar el escritorio remoto',unsupText: 'El escritorio remoto llega como video en vivo por WebRTC. A este navegador le falta algo que necesita:',reqRtc: 'WebRTC (RTCPeerConnection) con canales de datos', reqCodec: 'Decodificar video H.264 o VP8', reqSecure: 'Una página segura (https): esta lo es',@@ -96,6 +100,8 @@ const L = {pt: {full: 'Tela cheia', out: 'Desconectar', conn: 'Conectando…', reconn: 'Reconectando…', retry: 'Tentar de novo', signout: 'Sair',sndOn: 'Ativar o som', sndOff: 'Silenciar', video: 'Vídeo', bye: 'A sessão terminou.',+ hwEnc: 'por hardware', swEnc: 'por software',+ vinfoTip: (comp, enc, ms) => `Tela composta na ${comp}; vídeo codificado ${enc} (${ms} ms por quadro). Quadros por segundo: mostrados aqui / enviados pelo computador.`,unsupTitle: 'Este navegador não consegue mostrar a área de trabalho remota',unsupText: 'A área de trabalho remota chega como vídeo ao vivo por WebRTC. Falta a este navegador algo de que ela precisa:',reqRtc: 'WebRTC (RTCPeerConnection) com canais de dados', reqCodec: 'Decodificar vídeo H.264 ou VP8', reqSecure: 'Uma página segura (https): esta é',@@ -167,7 +173,7 @@ function measureHz() {const raw = n * 1000 / (t - t0);if (document.hidden || raw < 24) return; // a hidden tab is throttled: no measureconst hz = [30, 48, 50, 60, 72, 75, 90, 100, 120, 144, 165, 180, 240].reduce((a, b) => (Math.abs(b - raw) < Math.abs(a - raw) ? b : a));- if (hz !== screenHz) { screenHz = hz; sendSize(); }+ if (hz !== screenHz) { screenHz = hz; sendSize(); setMode(); }};requestAnimationFrame(step);}@@ -239,7 +245,26 @@ function failure(why, detail) {// of still areas over data channels ----let pc = null, dcIn = null, vmode = false, codec = '', iceServers = [], offering = false, offersSent = 0, answersGot = 0, peerNo = 0;let playTimer = 0, discTimer = 0, restartTimer = 0, restartTries = 0, peerFails = 0, everPlayed = false, serverWhy = '';-function setMode() { $('mode').textContent = vmode ? `${T.video} · ${codec.toUpperCase()}${rd.path ? ' · ' + rd.path.toUpperCase() : ''}` : ''; }+// The top bar: codec and path, frames a second shown / what the computer encodes, this screen's+// refresh rate, and how the computer makes the video (GPU or CPU composition, encoder in hardware or software)+let vinfo = null, shownFps = 0;+function setMode() {+ if (!vmode) { $('mode').textContent = ''; $('mode').title = ''; return; }+ const parts = [T.video, codec.toUpperCase() + (vinfo ? ' ' + (vinfo.hw ? T.hwEnc : T.swEnc) : '')];+ if (rd.path) parts.push(rd.path.toUpperCase());+ if (vinfo) parts.push(`${shownFps}/${vinfo.fps} fps`);+ if (screenHz) parts.push(`${screenHz} Hz`);+ if (vinfo) parts.push(vinfo.gpu ? 'GPU' : 'CPU');+ $('mode').textContent = parts.join(' · ');+ $('mode').title = vinfo ? T.vinfoTip(vinfo.gpu ? 'GPU' : 'CPU', vinfo.hw ? T.hwEnc : T.swEnc, vinfo.ms) : '';+}+setInterval(() => {+ if (!vmode || !pc) return;+ pc.getStats().then((st) => {+ st.forEach((s) => { if (s.type === 'inbound-rtp' && s.kind === 'video') shownFps = Math.round(s.framesPerSecond || 0); });+ setMode();+ }).catch(() => {});+}, 1000);function clearTimers() { clearTimeout(playTimer); clearTimeout(discTimer); clearTimeout(restartTimer); }function closePeer() {clearTimers();@@ -465,6 +490,7 @@ function retryAll() {function onText(m) {if (m.t === 'size') { W = m.w; H = m.h; cv.width = W; cv.height = H; ctx.clearRect(0, 0, W, H); fit(); }+ else if (m.t === 'vinfo') { vinfo = { hw: !!m.hw, gpu: !!m.gpu, fps: m.fps | 0, ms: Number(m.ms) || 0 }; setMode(); }else if (m.t === 'hello') {helloSeen = true;wsTries = 0;diff --git a/server/src/remote/conn.c b/server/src/remote/conn.cindex 5cc17cf..a443c95 100644--- a/server/src/remote/conn.c+++ b/server/src/remote/conn.c@@ -696,6 +696,15 @@ static void from_session(int type, const unsigned char *d, uint32_t n) {rtc_audio(rtc, d + 4, n - 4, smp);}break;+ case RP_VINFO:+ /* u8 hardware encoder, u8 GPU composition, u16 fps, u16 1/100 ms per frame: numbers only, to the page */+ if (n >= 6) {+ uint16_t f, e;+ memcpy(&f, d + 2, 2);+ memcpy(&e, d + 4, 2);+ ws_text("{\"t\":\"vinfo\",\"hw\":%d,\"gpu\":%d,\"fps\":%u,\"ms\":%u.%02u}", d[0] != 0, d[1] != 0, (unsigned)f, e / 100u, e % 100u);+ }+ break;case RP_DAMAGE:/* [2][u16 BE x, y, w, h …]: the browser drops its lossless layer there */if (vmode && rtc && n >= 8 && n % 8 == 0 && n <= 8 * 256) {diff --git a/server/src/remote/mirror.c b/server/src/remote/mirror.cindex bb970ad..0ae0794 100644--- a/server/src/remote/mirror.c+++ b/server/src/remote/mirror.c@@ -51,6 +51,7 @@ typedef struct {int vcodec, vaudio, vneed_key; /* subscribed to the session's encoder (1 H.264, 2 VP8) */unsigned vkbps;int vfps; /* the frame rate this viewer's screen shows (its refresh; 30 if unknown) */+ int vinfo_sent; /* RP_VINFO went to it at least once */int vmode; /* the video plays: lossless tiles once still, damage right away */} Client;@@ -643,10 +644,40 @@ static void send_damage(void) {}}+/* What the viewers' top bar shows about the video (RP_VINFO): sent when it changes, checked once a second. */+static int on_gpu;+void mirror_composed_on_gpu(int on) { on_gpu = on != 0; }+static void vinfo_update(void) {+ static double at;+ static unsigned char last[8];+ double t = now_ms();+ if (t - at < 1000) return;+ at = t;+ for (int k = 1; k <= 2; k++) {+ int hw = 0, fps = 0;+ long enc = 0;+ if (!mstream_info(k, &hw, &fps, &enc)) continue;+ uint16_t f = (uint16_t)fps, e = (uint16_t)(enc < 0 ? 0 : enc > 65535 ? 65535 : enc);+ unsigned char m[8] = { (unsigned char)hw, (unsigned char)on_gpu, 0, 0, 0, 0, (unsigned char)k, 0 };+ memcpy(m + 2, &f, 2);+ memcpy(m + 4, &e, 2);+ int fresh = memcmp(m, last, 8) != 0;+ memcpy(last, m, 8);+ for (int i = 0; i < MAX_CLIENTS; i++) {+ Client *c = &cl[i];+ if (c->fd < 0 || c->vcodec != k || (!fresh && c->vinfo_sent)) continue;+ msg(c, RP_VINFO, m, 6, NULL, 0);+ c->vinfo_sent = 1;+ flush(c);+ }+ }+}+/* Video mode clients get their lossless tiles once the screen is still; the encoder may have a* frame waiting for a free slot. */void mirror_tick(void) {if (lfd < 0) return;+ vinfo_update();if (still()) for (int i = 0; i < MAX_CLIENTS; i++) if (cl[i].fd >= 0 && cl[i].vmode && cl[i].ready) pump(&cl[i]);mstream_tick();}diff --git a/server/src/remote/mirror.h b/server/src/remote/mirror.hindex 1c11e62..eec6031 100644--- a/server/src/remote/mirror.h+++ b/server/src/remote/mirror.h@@ -57,6 +57,7 @@ void mirror_cursor(int x, int y, int mode, const uint32_t *argb, int w, int h, i/* Lossless tiles for viewers whose video plays once the screen is still, the encoder's* pending frame. Called on every loop iteration; mirror_timeout says when it has work (ms, -1 none). */void mirror_tick(void);+void mirror_composed_on_gpu(int on); /* how the session composes now (shown to remote viewers) */double mirror_timeout(void);/* Session text clipboard (called on every loop iteration; sends only if it changed). */void mirror_clipboard(const char *text, unsigned gen);diff --git a/server/src/remote/proto.h b/server/src/remote/proto.hindex 5a58cdb..4c6b536 100644--- a/server/src/remote/proto.h+++ b/server/src/remote/proto.h@@ -25,6 +25,8 @@ enum {RP_VFRAME = 40, /* u8 codec (1 H.264, 2 VP8), u8 keyframe, u16 0, u32 ms + the encoded frame */RP_AFRAME = 41, /* u32 first sample (48 kHz) + one Opus packet */RP_DAMAGE = 42, /* video mode: u16 x, y, w, h per rectangle that changed in this frame */+ RP_VINFO = 43, /* u8 encoder in hardware (VA-API), u8 composed on the GPU, u16 the encoder's frames a+ * second, u16 encoding time per frame in 1/100 ms: shown in the page's top bar */};/* bridge → session */