#642

feat(webrtc): add Linux support

DraftCodyECSLwants to merge intofrom

Summary

Make the browser WebRTC stream available on Linux as an opt-in build (-DSUNSHINE_ENABLE_WEBRTC=ON). No file under src/ changes: src/webrtc_stream.cpp already has the Linux paths and compiles and runs as is. The gaps were the libwebrtc build, CMake wiring, packaging and one runtime crash in the wrapper.

Commits

  1. feat(webrtc): add Linux libwebrtc build and CMake support
    • scripts/build_linux_webrtc.sh syncs, builds and stages libwebrtc.so in the same shared cache layout the Windows script uses.
    • cmake/dependencies/linux.cmake includes webrtc.cmake.
    • The non-Windows library lookup in webrtc.cmake never worked: find_library skips its search when the cache entry is empty, which the declaration above it leaves it as. The entry is now unset first.
    • libwebrtc.so is installed with the binary and found through an install RPATH of $ORIGIN/../lib.
    • docs/building.md documents the Linux build.
  2. fix(linux): accept libwebrtc.so in local deploy payloads
    • linux_local_deploy.py rejected usr/lib/libwebrtc.so as an unexpected artifact.
    • It also required vibepollo-profile-normalize.py and pairing_migration.py under usr/libexec/vibeshine. Nothing in the repo installs them, so every payload failed the required-artifact check. I removed those two names. This is not WebRTC-specific; say so if you want it split out.
  3. chore(webrtc): update libwebrtc for dummy audio device fallback
    • Submodule bump for Nonary/libwebrtc#1. Without that change the host process aborts on the first WebRTC session when no sound server is reachable (Check failed: 0 == adm->Init()).

Dependency

The submodule bump points at commit a5d6f75, which currently exists only on CodyECSL/libwebrtc through Nonary/libwebrtc#1. This PR is a draft until that is merged or the commit is otherwise reachable on Nonary/libwebrtc. If it is squashed, the pointer needs updating.

Changing the wrapper changes the cache key computed by scripts/get_webrtc_cache_keys.ps1 (it hashes HEAD:third-party/libwebrtc), so I expect Windows CI to rebuild libwebrtc. I have not run Windows CI.

Testing

Tested manually on one host. Arch-family CachyOS, kernel 7.2.9, RTX 3080 Ti, built through linux_local_deploy.py with the pinned CUDA 12.9.1 toolkit and GCC 14, installed as a package, WebRTC session started from the browser UI.

  • The session connected and the browser showed live H.264 video (overlay showed about 115 FPS).
  • Audio plays.
  • Mouse and keyboard work on the desktop.
  • Mouse input does not work properly inside a game (Red Dead Redemption 2). I did not investigate further.
  • Reconnect and teardown work.
  • Running a Moonlight session and a WebRTC session at the same time does not work.
  • A gamepad connects (the host log shows it emulated as an Xbox One or DualShock 5 controller). I did not try it in a game.
  • Rebuilding libwebrtc on the host with the script reproduces the same libwebrtc.so checksum as a second machine.
  • The script's argument handling, staging and cleanup guard were checked against stub gn and ninja.

Not tested: HEVC, AV1 and HDR, Linux firewall rules for the WebRTC UDP ports, and any Windows build.

Notes

  • The build script defaults to m125_release like the Windows script. docs/building.md also mentions m137_release plus custom_audio_source_m137.patch for a manual build; I did not determine which one is correct.
  • linux_local_deploy.py never passes -DSUNSHINE_ENABLE_WEBRTC=ON. To deploy a WebRTC build, preconfigure build/ with that option first.
  • Capture needs a CUDA build on this host. A --cuda off build gave a black stream because capture fell back to software GL. That is the same for any stream, not specific to WebRTC.
  • Existing gap, not addressed here: docs/building.md and docs/linux/local-development.md do not list the Arch packages the local deploy flow needs (vulkan-headers, appstream-glib, libxml2-legacy, and gcc14 from the Arch Linux Archive). They appear only in packaging/linux/Arch/PKGBUILD and ci-archlinux.yml. The docs also do not explain the private CUDA 12.9.1 toolkit setup.

This was written with AI assistance (Claude Code). The manual testing is described above.

🤖 Generated with Claude Code

Activity

3

This pull request is a draft

Merging is unavailable until it is marked ready for review.