Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

86 Commits

Folders and files

Repository files navigation

Monlight Tizen WebRtc client

Sunshine game streaming for Samsung Tizen TVs — straight from Sunshine

Moonlight WebRTC streams games from your PC to a Samsung TV at up to 4K, up to 120 FPS, with HDR, HEVC, AV1, gamepad support, rumble and a TV-first interface. The TV talks directly to Sunshine-Web-RTC, a Sunshine build that serves WebRTC itself, so nothing else runs between the game and the TV.

Note

This project is based on Moonlight WebRTC by tsoas. The TV application, its interface and the WebRTC design come from that project. This version changes the architecture: the separate Windows Gateway is gone, and its job now happens inside Sunshine. See What changed below.

Important

Moonlight WebRTC is in beta. It is intended for testing on compatible Samsung Tizen TVs and may still contain bugs or device-specific limitations.

Moonlight WebRTC application library

4K · up to 120 FPS · HDR · HEVC Main10 · AV1 · H.264 · Opus audio · Gamepad + rumble · No video transcoding


What is Moonlight WebRTC?

Moonlight WebRTC lets you play games from a Sunshine-powered Windows PC directly on a Samsung Tizen TV, with an experience that aims to match Moonlight with Sunshine:

  • the same applications, artwork and launch, resume and stop behaviour;
  • pairing with a PIN in Sunshine's Web UI;
  • every paired TV listed with your Moonlight clients;
  • Sunshine's encoder, display and controller settings applied to the TV as to any Moonlight client.
Gaming PC                                         Samsung TV
┌──────────────────────────────────┐             ┌──────────────────────┐
│ Sunshine-Web-RTC                 │   WebRTC    │ Moonlight WebRTC     │
│ capture → encode → WebRTC (RTP)  │ ──────────► │ hardware decode      │
│ GameStream for Moonlight clients │   your LAN  │ gamepad, remote      │
└──────────────────────────────────┘             └──────────────────────┘

Sunshine-Web-RTC is a fork of Sunshine. It keeps everything Sunshine does for Moonlight clients and adds a WebRTC server for the TV. Moonlight clients and the TV can use the same PC.


What changed from the original

The original Moonlight WebRTC put a Windows Gateway between Sunshine and the TV. The Gateway was a Moonlight client towards Sunshine and a WebRTC server towards the TV:

Original

Sunshine ── encode ── GameStream (RTP + FEC + encryption) ── loopback ──┐
                                                                        ▼
                              Gateway: receive, decrypt, reassemble each frame,
                              repacketize into WebRTC RTP
                                                                        │
TV ◄──────────────────────────── WebRTC ────────────────────────────────┘

Every frame Sunshine encoded therefore went through a full GameStream round trip on the same PC before the TV saw it:

  1. It was split into packets with forward error correction and encryption.
  2. It was sent over the loopback network.
  3. The Gateway received, decrypted and reassembled it.
  4. The Gateway packetized it again for WebRTC.

That hop costs time on every frame. It also makes frame delivery uneven: a frame can only be forwarded once the whole of it has been received, decrypted and reassembled, so frames left the PC at slightly irregular intervals. The TV's WebRTC jitter buffer absorbs that unevenness by holding frames longer, or, when it cannot, shows it as micro-stutter.

Sunshine-Web-RTC removes the hop entirely:

Now

Sunshine-Web-RTC: capture → encode → WebRTC RTP → TV
  • Less latency. Encoded frames go from Sunshine's encoder straight to the WebRTC packetizer, in the same process. Nothing is encrypted, decrypted, sent over loopback or reassembled on the way.
  • No micro-stutter from the bridge. Each frame is sent as soon as the encoder produces it. Its RTP timestamp comes from the moment it was captured, not from when another process finished reassembling it. The TV therefore receives evenly paced frames with accurate timing, which keeps its jitter buffer small and playback smooth.
  • More of the bitrate for the picture. There is no GameStream forward error correction to pay for on the PC, so the encoder gets the bitrate the TV asked for, less only audio and RTP overhead. WebRTC on the LAN repairs losses with retransmission and keyframe requests instead.
  • Faster recovery. When the TV asks for a keyframe, the request goes directly to Sunshine's encoder.
  • No waiting for the audio or the jitter buffer. Sunshine marks every video packet with a zero playout delay, so the TV shows each frame the moment it is decoded instead of buffering it, as Stadia did; the TV also asks for the shortest jitter buffer and does not hold the picture back to stay in sync with the audio, as Moonlight does not either. Screen to screen, 1080p60 dropped from 54 to 38 ms in Sunshine-Web-RTC's latency test.
  • Latency you can see. The stream overlay and the top of the statistics panel show the latency from the PC to the screen, drawing included, its session average, and the share of packets lost. The Performance overlay setting, also in the stream menu, keeps them fixed at the top right of the stream, with the frames per second actually arriving at the top left.
  • Nothing extra to install or keep running. There is no Windows service, tray application or second pairing. The TV pairs with Sunshine itself.

The goal is what Moonlight gives you with Sunshine on a PC or a phone: 4K 60 FPS HDR that feels local. The difference is that it now runs on the TV with nothing in between.

The server: Sunshine-Web-RTC and its patches

The server side is Sunshine-Web-RTC, a fork of LizardByte/Sunshine. It is kept as a small set of patches on top of upstream Sunshine, so it can follow new Sunshine releases.

Patch What it changes in Sunshine
0001-core-per-session-packet-queues Lets a session receive its own encoded video and audio packets, so frames go from the encoder to WebRTC without passing through the GameStream sender. Moonlight sessions are unaffected.
0002-core-webrtc-server-integration Starts the WebRTC server with Sunshine, adds the webrtc_enabled and webrtc_port options, and lists, pairs and manages TVs through Sunshine's existing PIN and client endpoints.
0003-build-libdatachannel Builds libdatachannel for WebRTC, SRTP and the RTP packetizers.
0004-webrtc-module The TV server itself (src/webrtc/): this protocol, TV pairing, sessions, the media pump and the gamepad input bridge.
0005-web-ui-tv-pairing-and-options TVs in the Web UI's PIN form, and the two options on the Network tab.
0006-tests Unit tests and a headless end-to-end test that pairs, streams and measures like a TV.
0007-docs The user guide and option documentation.
  • PATCHES.md explains every change file by file, the stream parameters, what has been verified and how to rebase onto a newer Sunshine.

  • patches/ holds the patches. Applied to the upstream Sunshine commit named in PATCHES.md, they reproduce the fork exactly:

    git clone https://github.com/LizardByte/Sunshine.git && cd Sunshine
    git checkout 0594f62d   # the upstream base named in PATCHES.md
    git apply /path/to/Sunshine-Web-RTC/patches/*.patch
  • docs/moonlight_webrtc_tizen.md covers building, installing and configuring it.


Features

🎮 Browse and launch your Sunshine library

Moonlight WebRTC retrieves your Sunshine applications and their artwork and presents them in a TV-friendly library.

From the TV you can:

  • browse Sunshine applications;
  • view application artwork;
  • launch a game;
  • resume an existing session;
  • disconnect from the stream while leaving the game running;
  • stop the Sunshine session when you actually want to close it;
  • switch to another application.

The session lifecycle behaves like a normal Moonlight client rather than simply killing the host application whenever the TV disconnects.


📺 Up to 4K and up to 120 FPS

Every resolution can stream at 30, 60, 90 or 120 FPS:

  • The TV asks its own decoder which frame rates it sustains for each resolution and codec, and streams at the highest one. A 120 Hz TV gets 120 FPS; a 60 Hz one stays at 60.
  • When the TV does not announce its maximum, Frame rate in Settings lets you choose.
Codec 720p 1080p 1440p 4K
H.264 ✅ ✅ — —
HEVC Main ✅ ✅ 🧪 ✅
HEVC Main10 HDR — ✅ 🧪 ✅
AV1 Main 8-bit ¹ ✅ ✅ 🧪 ✅
AV1 Main 10-bit HDR ¹ — ✅ 🧪 ✅

¹ AV1 is offered only when the PC's GPU can encode it and the TV can decode it over WebRTC.

🧪 1440p is experimental.

Resolution, codec, HDR mode and bitrate are selectable directly from the TV.

Moonlight WebRTC streaming settings


🌈 HDR

Moonlight WebRTC streams HEVC Main10 and AV1 Main 10-bit HDR without tone mapping or transcoding. The Main10 stream and its Rec.2020 signalling reach the Samsung TV as Sunshine encoded them.

If HDR was requested but the PC's display is not in HDR, the stream stops with an error instead of silently sending SDR.


⚡ No video transcoding

Sunshine encodes the game once, with your GPU's hardware encoder. That bitstream is what the TV decodes:

Sunshine-Web-RTC encodes (H.264 / HEVC / AV1)
   ↓
WebRTC RTP over your LAN
   ↓
Samsung hardware decoder

There is no decode and re-encode anywhere, so there is no second generation of compression, no quality loss from re-encoding and no transcoding delay.


🔊 Synchronized audio and video

Audio is delivered as Opus stereo at 48 kHz in 5 ms packets.

Audio and video share WebRTC's real-time media timeline. WebRTC handles:

  • media timing;
  • jitter buffering;
  • audio/video synchronization;
  • packet-loss feedback;
  • stream timing adjustments.

Both streams are timestamped by Sunshine when they are captured, so the TV can keep them in sync without a second custom synchronization layer.


🎮 Gamepad support

Xbox-compatible controllers can be used directly with the Samsung TV.

Supported input includes analog sticks, triggers, D-pad, face buttons, shoulder buttons, stick buttons, menu/view controls and controller rumble.

Gamepad input travels to Sunshine over a WebRTC DataChannel. Sunshine treats the controller as a Moonlight controller, so its controller emulation settings apply. Holding Start toggles mouse emulation.


🛋️ Designed for the TV

The Samsung application is built around a remote-first interface rather than adapting a desktop UI to a television.

It includes:

  • multiple saved PCs;
  • online/offline status for each PC;
  • Wake-on-LAN for a sleeping or powered-off PC;
  • PCs running Sunshine-Web-RTC found automatically on the local network;
  • remote-friendly address and port editing;
  • frame rate, from the TV's own maximum;
  • Sunshine application artwork;
  • resolution selection;
  • codec selection;
  • HDR selection;
  • bitrate configuration;
  • stream controls;
  • launch and resume progress feedback;
  • a notice when a new version is published.

No keyboard is required for normal use. The app still labels each PC a "Gateway"; that name predates the architecture change.

Moonlight WebRTC PC selection


⏻ Wake-on-LAN

The TV can turn on a PC that is asleep or shut down.

Select an offline PC and the TV sends a Wake-on-LAN magic packet, waits for the PC to boot and opens its library once Sunshine answers. Wake PC is also available from the PC's menu (the controller's Menu button).

The TV learns the PC's network adapter address the first time it connects, so connect once while the PC is on. Wake-on-LAN also has to be enabled on the PC:

  • in the BIOS/UEFI (often called Wake on LAN, Power On By PCI-E or Resume by LAN; waking from a full shutdown may also need ErP disabled);
  • in Windows, under the network adapter's Properties → Power Management (Allow this device to wake the computer, Only allow a magic packet to wake the computer) and Advanced (Wake on Magic Packet).

Use wired Ethernet on the PC: most Wi-Fi adapters cannot wake a computer. The TV and PC must be on the same local network.


🔐 Pairing and TV management like Moonlight

Pairing works the way it does for Moonlight:

  1. The TV shows a four-digit PIN.
  2. You select the TV in Sunshine's Web UI and enter that PIN.
  3. Only someone signed in to Sunshine's Web UI can approve a TV.

Once paired, the TV appears in Sunshine's client list next to your Moonlight clients. From there you can disable it, which keeps it paired but refuses it until you enable it again, or unpair it.


Quick start

You need:

  1. Sunshine-Web-RTC on your Windows gaming PC, in place of Sunshine.
  2. Moonlight WebRTC on your Samsung TV.

1 — Install Sunshine-Web-RTC

Install Sunshine-Web-RTC and complete Sunshine's usual first-run setup. Its guide covers building and installing it.

The TV connects to the PC on TCP port 8000, Sunshine's default webrtc_port, and finds it by broadcasting to UDP port 8000. Make sure nothing else uses those ports, such as the retired Moonlight WebRTC Gateway service. If you change webrtc_port, PCs found automatically use the new port, and a PC added by hand needs it entered on the TV.

2 — Install the Samsung TV application

Download MoonlightWebRTC.wgt from the Releases page and install it with Apps2Samsung, as described in Installing on the TV.

Each release has two packages:

  • MoonlightWebRTC.wgt asks the TV to switch to Game Mode while the app is open, for the lowest input lag.
  • MoonlightWebRTC-NoGameMode.wgt leaves the TV's picture mode alone. Use it if Game Mode causes problems on your TV or you prefer to choose the picture mode yourself.

Both install as the same app, so installing one replaces the other.

3 — Add your PC and pair

  1. Open Moonlight WebRTC on the TV. The TV looks for PCs running Sunshine-Web-RTC on the local network and adds the ones it finds. If yours does not appear, select Add Gateway: the TV searches again and fills in the PC it finds. Otherwise, enter the PC's LAN IPv4 address and port with the arrows.
  2. Select the PC. The TV and the PC must be on the same local network.
  3. The first time, the TV shows a four-digit PIN.
  4. On the PC, open Sunshine's Web UI and go to PIN.
  5. Select the TV in the list of devices waiting to pair (it appears as Samsung TV with its address).
  6. Enter the PIN, optionally change the device name, and select Send.

Your Sunshine application library appears on the TV. Select an application and start streaming.


Installing on the TV

The TV application is installed with Apps2Samsung, a free tool for Windows, macOS, Linux and Android that side-loads apps onto Samsung Tizen TVs. It finds the TV, creates and reuses the Samsung signing certificate, and installs the package, so Tizen Studio is not required.

  1. Put the TV in Developer Mode, as Apps2Samsung's FAQ explains, using the IP address of the computer or phone that will run Apps2Samsung.
  2. Install Apps2Samsung from its releases, on a computer or Android phone on the same network as the TV.
  3. Download MoonlightWebRTC.wgt from the latest release on this repository's Releases page.
  4. Open Apps2Samsung and select your TV. It can find the TV on the network, or you can enter its IP address. The first time, sign in to your Samsung account when asked so that Apps2Samsung can create the certificate.
  5. Choose a custom .wgt, select the downloaded MoonlightWebRTC.wgt, and install it.

Moonlight WebRTC then appears in the TV's app list.

To update, download the newer MoonlightWebRTC.wgt from Releases and install it the same way.


Streaming controls

Moonlight WebRTC distinguishes between disconnecting from a stream and stopping the host application.

Disconnect

Ends the stream to the TV. The application keeps running on the PC, so you can reconnect later and resume it.

Stop

Asks Sunshine to close the running application. Use this when you actually want to stop the game on the PC.

Launch another application

When switching to another application, Moonlight WebRTC ends the previous one before launching the new one.


Current beta limitations

Moonlight WebRTC is still under active development.

Current known limitations include:

  • frame rates above 60 FPS depend on the TV. They are offered only when the TV's decoder announces them, or when it announces nothing and you choose them;
  • 1440p is experimental, because Samsung does not list it among its supported game-streaming resolutions;
  • updates are announced on the TV but not installed by it: a Tizen app cannot install itself, so new versions are installed with Apps2Samsung;
  • automatic discovery finds PCs on the same network segment only, since broadcasts do not cross routers. PCs elsewhere are added by address.

Troubleshooting

The TV cannot connect to the PC

Check that:

  • Sunshine-Web-RTC is running and its log shows WebRTC: TV server listening on port 8000;
  • no other program uses port 8000, such as the retired Moonlight WebRTC Gateway service (stop or uninstall it);
  • the TV and PC are on the same LAN and the address and port entered on the TV are correct.

The TV does not find the PC by itself

Discovery uses a broadcast to UDP port 8000, which Sunshine-Web-RTC answers when its WebRTC server is enabled. Some networks block broadcasts, such as guest Wi-Fi, networks with client isolation, or a TV and PC on different subnets. In that case, add the PC by its address with Add Gateway.

Do not disable Windows Firewall as a troubleshooting step.

The TV says the PC runs the retired Gateway

The TV connected to the old Moonlight WebRTC Gateway instead of Sunshine-Web-RTC. Uninstall the Gateway, or stop its service, and make sure Sunshine-Web-RTC listens on port 8000.

The TV does not appear in Sunshine's PIN page

The TV asks to pair only while it shows the PIN. Make sure the PIN is on screen, then refresh the PIN page. A PIN that is not entered within five minutes is replaced by a new one. New PIN on the TV asks again at any time.

The TV says it is disabled

The TV was disabled in Sunshine's client list under Troubleshooting. Enable it there; it does not need to pair again.

The PC does not wake up

Check that:

  • the TV has connected to this PC at least once while it was on;
  • Wake-on-LAN is enabled in the PC's BIOS/UEFI and network adapter settings (see Wake-on-LAN);
  • the PC is connected by Ethernet rather than Wi-Fi.

If the PC wakes from sleep but not from a shutdown, look for a BIOS option allowing Wake-on-LAN from a powered-off state (and disable ErP), or try turning off Windows Fast startup.


Building from source

This repository contains the Samsung TV application (tizen/) and its tests (tests/Tizen*.js, run with Node.js). The server side lives in Sunshine-Web-RTC. The protocol between them is described in docs/protocol.md.

The TV package needs Samsung's Emscripten SDK (1.39.4.7) to build its Wake-on-LAN WebAssembly module. packaging/tizen/build-package.ps1 looks for it in %USERPROFILE%\samsung-emscripten\emscripten-release-bundle\emsdk; pass -EmsdkRoot or set SAMSUNG_EMSDK to use another location.

GitHub Actions (.github/workflows/build.yml) runs the tests and builds MoonlightWebRTC.wgt on every push and pull request. To publish a release, set the version in tizen/config.xml and tizen/update-check.js, then push a matching tag, such as v2.0.0 or v2.0.0-beta.1 (published as a pre-release). The workflow attaches both packages (MoonlightWebRTC.wgt and MoonlightWebRTC-NoGameMode.wgt) and SHA256SUMS.txt to the release. To build the package without Game Mode locally, pass -NoGameMode to packaging/tizen/build-package.ps1.


Acknowledgements

  • Moonlight WebRTC by tsoas The original project this one is based on: the Samsung TV application, its remote-first interface, the WebRTC streaming design and the Gateway protocol all come from it. This version replaces its Windows Gateway with a WebRTC server built into Sunshine.

  • BrightCraft / Moonlight Tizen An important reference for the TV application. Parts of its Tizen-side code were reused and adapted, and its UI concepts and implementation ideas guided how to build a modern Moonlight experience for Samsung TVs.

  • Sunshine and the Moonlight Game Streaming Project For the open-source game-streaming host and protocol that Sunshine-Web-RTC builds on.

  • Samsung Tizen / Samsung Developers For the Tizen platform, WebRTC APIs and developer tooling that make the Samsung TV client possible.


License

Moonlight WebRTC is licensed under the GNU General Public License version 3.

See:

for project licensing and third-party dependency information.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages