Repository navigation
Proposal: native WebRTC streaming on Linux hosts, for the Moonlight WebRTC app on Samsung Tizen TVs #442
luisotavio-dev
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Vibeshine streams well from Linux over GameStream. What Linux does not have yet is WebRTC. Today the only WebRTC path is the browser stream, and it builds only on Windows (
SUNSHINE_ENABLE_WEBRTC, libwebrtc). On a Linux host, the browser stream page reports "WebRTC support is disabled in this build".In a fork, I added native WebRTC desktop streaming to the Linux host. It serves the Moonlight WebRTC app on Samsung Tizen TVs directly. Until now that app needed the Moonlight WebRTC Gateway on the PC: the Gateway connected to Vibeshine as a Moonlight client and re-sent the stream over WebRTC, so WebRTC ran in the Gateway, not in the host.
This is not the browser stream, and it does not change it. It speaks the TV app's protocol (version 2, unchanged).
I'd like to know if you want this upstream, and if I may open PRs for it. Before I rebase onto
canary, I'd rather agree on the shape with you.proposal/tizen-webrtc, on top of 2.18.9 (95254e272). Diff against upstream.docs/moonlight_webrtc_tizen.md.Why WebRTC
On Tizen 9, Samsung limited Game Mode to devices connected over HDMI. An app on the TV that receives a network stream no longer gets it, so the TV keeps its normal picture processing and the stream has visible delay.
The TV's WebRTC stack is the one path I found that still reaches Game Mode. An
imageattrattribute from Samsung's Cloud Gaming setup, in the video section of the SDP, puts the Tizen decoder in Game Mode. Together with a zero playout-delay RTP extension, WebRTC was the only solution I could get working on the TV without delay.What it does
webrtc_port(default 8000). Media uses a configurable UDP range.webrtc_tv_clients.json(mode 0600).stream_protocol(moonlight,webrtcorboth),webrtc_port,webrtc_media_port_minandwebrtc_media_port_max. Withwebrtconly, the GameStream ports and mDNS stay closed.Dependency
WebRTC on Linux comes from libdatachannel v0.24.6. It is small, packaged by Arch, and includes the WebSocket server the signaling needs. The TV path only packetizes frames that are already encoded, so it needs no media engine. When no system package is found, the build fetches it with FetchContent and links it statically, because the Linux host links libgcc statically. The fetched source is patched to widen libSRTP's outbound replay window to 16384 packets, so NACK resends at 4K bitrates are not rejected.
The libwebrtc browser stream stays as it is.
Test setup
hevc_vulkan) with KMS capture.Current state and known gaps
stream_protocoltoboth. For upstream I would make it opt-in (moonlightby default), so an upgrade opens no new ports.enableTls = false). I have not checked whether the TV app can connect overwss://. After pairing, the TV authenticates with an HMAC, but the PIN exchange can be read on the LAN. The fork declines two pending TVs that show the same PIN for that reason.packaging/is untouched. Flatpak, PKGBUILD, Homebrew, FreeBSD and Docker would each need libdatachannel.Proposed shape for upstream
Target
canary, split into reviewable PRs:mail::packet_queue()), with no behavior change.SUNSHINE_ENABLE_TV_WEBRTC), on by default only on Linux, with the unit tests.Later: browser stream on Linux
Once libdatachannel is in the Linux build, I would consider implementing the browser stream on Linux with it too, so the browser stream page works on Linux hosts. For now my focus is desktop streaming to the TV, and the browser stream is not part of this proposal.
Questions
third-party/, or system packages only?tizen_webrtcormoonlight_webrtc)?All reactions