Repository navigation
Conversation
Add `lfa web start|status|stop|doctor`. The share captures display :1, encodes H.264 with h264_mediacodec when available, and streams Annex-B NAL units over an authenticated WebSocket. The browser decodes them with WebCodecs and sends pointer and keyboard events back over the same socket, which the server injects with XTEST. One 8-character passcode from /dev/urandom protects the page. It stays in memory and is compared with hmac.compare_digest. The server binds to the Wi-Fi address, serves a self-signed HTTPS page by default, and limits failed logins. `--transport webrtc` keeps a go2rtc path for hosts where pion can enumerate interfaces; Android 16 denies the netlink query, so WebCodecs is the default. The share stops from `lfa web stop`, `lfa stop`, stop-linux, and uninstall. Also run the generated pd_login sessions in a subshell so `nohup` no longer fails on a shell function.
A killed X server can leave $PREFIX/tmp/.X11-unix/X1 behind. The old check accepted the socket and started ffmpeg against a dead display. Probe with xdpyinfo or python-xlib first and fall back to the socket only when neither tool is available.
Termux:X11 resizes its virtual screen when the Android window changes. The share read the size once at startup, so a viewer that connected after a resize made ffmpeg fail with "Capture area ... outside the screen size", which the player showed as a reconnect loop. Run ffmpeg without -video_size so x11grab reads the current screen, and let the canvas take its size from the decoded frames. --size now scales the output instead of cropping the capture.
Reconnect the XTEST display when the desktop is restarted after the share starts, and read the root geometry for each pointer move so a resized screen still maps to the right pixels. Round the captured size to even dimensions so h264_mediacodec accepts screens with an odd height. Blur the player buttons after a click so they do not keep keyboard focus.
When VideoDecoder is missing, the player asks for ?mode=mjpeg on the same authenticated WebSocket that carries input. The server runs ffmpeg's mjpeg encoder, splits complete JPEG images, and sends them to the browser. The player draws them through an <img> element, so any browser can view the desktop. It uses more bandwidth than the H.264 path.
The MJPEG fallback draws each frame from an <img> with a blob: URL. img-src did not include blob:, so the browser blocked every frame and the player stayed on "Waiting for video". Add blob: to img-src.
Touch devices show a floating menu with a relative touchpad, tap-to- position, mouse buttons, hold-drag, scrolling, arrows, and modifier latches. A text field opens the on-screen keyboard and translates its input into key events. Add the relative `mr` pointer event on the server.
Avoid a blob URL and an <img> load per frame. createImageBitmap decodes off the main thread, which helps the fallback keep up at 60 fps.
The canvas is now sized explicitly instead of relying on object-fit, so the desktop keeps its aspect ratio by default. The touch panel adds Fit, Stretch, Fill, and 1:1 modes plus a 50-200% zoom control, and remembers the choice in localStorage. Input mapping uses the displayed element rect, so it follows every mode.
Add `lfa codec`, a bridge between VA-API in the container and the phone's MediaCodec decoders. A Termux daemon drives AMediaCodec over a Unix socket in the shared /tmp, and a standalone libva driver in the guest turns decode calls into that protocol and copies NV12 frames into VA surfaces. Commands: install, status, start, stop, doctor, test, play, env, run. The daemon follows the desktop through start-linux/stop-linux, and existing launchers are patched on install. The driver installs under /usr/local/lib/lfa-codec/dri and does not touch the distro's Mesa files. H.264 (Baseline/Main/High), HEVC Main, VP9 Profile 0, and VP8 are supported. This is the CPU copy path, so Chromium and Firefox stay on software decode; mpv, VLC, and ffmpeg use the bridge. Vendored sources: the daemon from lfdevs/termux-va (GPL-3.0) and the driver from Re-s/droidspaces-media-decode (Apache-2.0).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
lfa web start|status|stop|doctorshares the running desktop (:1) with another device on the same Wi-Fi. The viewer opens the URL, enters one 8-character passcode, and gets video plus mouse and keyboard control.How it works
ffmpegcaptures:1withx11grab/xcbgraband encodes H.264 (h264_mediacodecwhen available,libx264 -preset ultrafast -tune zerolatencyotherwise).python-xlib./dev/urandom(uppercase letters and digits, no0/O/1/I), kept in memory, compared withhmac.compare_digest, and never written to disk.--transport webrtckeeps a go2rtc path. It is not the default because Android 16 denies the netlink route query pion uses to enumerate interfaces.--sizecaptures the full display by default and scales to the requested output size.--view-only,--fps,--encoder,--http,--detach, and--bindare available.Tests
tests/test-all.sh:PASS=1022 FAIL=0(README assertions updated).shellcheck -S warning: clean onlib/lfa-web.sh,install_linux.sh, andtests/test-all.sh.lfa web doctorall green; login, player page, H.264 config (avc1.640020, 1280x1024), 30 fps frames, and XTEST pointer moves to the expected pixels.Notes
start-linuxscripts now runpd_loginin a subshell instead of undernohup, which failed becausepd_loginis a shell function.