- Fixed broken image cache for the first stage RGBA frames. It was not a thread-safe one, which led to image tearing (parts of old images in multiple consecutive frames). - 180 flip function for the OpenGL coordinate system has been moved into the rotation part. - Optimized YUV converter. - Optimized color converters: - Use __restrict pointers. - Draw image pixels with the faster bitwise operators and pointer arithmetic as 32/16bit LE numbers (may break on ARM devices like RPi). - Pass uints for less num conversions. - Much faster XRGB -> RGBA conversion with Go's stdlib 32bit flip. - Wrapped RGBA images into a custom struct in order to bypass opacity tests for the standard Go png functions, which needed for the PNG file export. Before that we set RGBx opacity byte explicitly during the pixel format conversions (much slower). - Made Libretro core shutdown more deterministic. When we run a C core separately from the main Go process we have to make sure that the C core is not doing anything in its syscall while we stopping the emulator. Basically, a blocking call may be suspended on the Go's side while the other goroutines have no knowledge of that. - Less info level logs. - Added recording user label. - Enabled RTCP sender reports by default, which may help with A/V sync. - Check onMessage webrtc handler if it's set. May crash the program if not. - Fixed some make dirs permissions. - Enabled console colors (since MS has finally fixed their bloody Terminal). - Disable log in some tests. - Updated deps. |
||
|---|---|---|
| .github | ||
| assets | ||
| cmd | ||
| configs | ||
| docs | ||
| pkg | ||
| scripts | ||
| web | ||
| .dockerignore | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
CloudRetro
Open-source Cloud Gaming Service For Retro Games
Video demo: https://www.youtube.com/watch?v=GUBrJGAxZZg
Technical wrapup: https://webrtchacks.com/open-source-cloud-gaming-with-webrtc/
CloudMorph: https://github.com/giongto35/cloud-morph: My current focus
on generic solution for cloudgaming
Discord: Join Us
Announcement
Due to the current economic recession, i'm unable to keep demo server. Google Stadia also shutdown the Cloud service because of high cost and low adoption. I still believe Cloud Gaming is a brilliant idea and it should keep getting more investment. I open source my works so that everyone can experience self-hosting cloud gaming service to hold this spirit. You can check the rest of idea in the wiki
Try the service at cloudretro.io
Direct play an existing game: Pokemon Emerald
Introduction
CloudRetro provides an open-source cloud gaming platform for retro games. It started as an experiment for testing cloud gaming performance with WebRTC and Libretro, and now it aims to deliver the most modern and convenient gaming experience through the technology.
Theoretically, in cloud gaming, games are run on remote servers and media are streamed to the player optimally to ensure
the most comfortable user interaction. It opens the ability to play any retro games on web-browser directly, which are
fully compatible with multi-platform like Desktop, Android, IOS.
In ideal network condition and less resource contention on servers, the game will run smoothly as in the video demo. Because I only hosted the platform on limited servers in US East, US West, Eu, Singapore, you may experience some latency issues + connection problem. You can try hosting the service following the instruction the next section to have a better sense of performance.
Feature
- Cloud gaming: Game logic and storage is hosted on cloud service. It reduces the cumbersome of game initialization. Images and audio are streamed to user in the most optimal way using advanced encoding technology.
- Cross-platform compatibility: The game is run on web browser, the most universal built-in app. No console, plugin, external app or devices are needed.
- Emulator agnostic: The game can be played directly without any extra effort to set up the gaming emulator or platform.
- Collaborate gameplay: Follow the idea of crowdplay(TwitchPlaysPokemon), multiple players can play the same game together by addressing the same deeplink. The game experience is powered by cloud-gaming, so the game is much smoother. Check CrowdPlay section
- Online multiplayer: The first time in history, you can play multiplayer on Retro games online. You can try Samurai Showndown with 2 players for fighting game example.
- Horizontally scaled: The infrastructure is designed to be able to scale under high traffic by adding more instances.
- Cloud storage: Game state is storing on online storage, so you can come back and continue playing your incomplete game later.
Development environment
# Ubuntu / Windows (WSL2)
apt-get install -y make gcc pkg-config libvpx-dev libx264-dev libopus-dev libsdl2-dev
# MacOS
brew install pkg-config libvpx x264 opus sdl2
# Windows (MSYS2)
pacman -Sy --noconfirm --needed git make mingw-w64-x86_64-{gcc,pkgconf,dlfcn,libvpx,opus,x264-git,SDL2}
Because the coordinator and workers need to run simultaneously. Workers connect to the coordinator.
- Script
make dev.run- The scripts spawns 2 processes one in the background and one in foreground
- Manual
- Need to run coordinator and worker separately in two session
go run cmd/coordinator/main.go- spawn coordinatorgo run cmd/worker/main.go --coordinatorhost localhost:8000- spawn workers connecting to coordinator
Additionally, you may install and configure an X Server display in order to be able to run OpenGL cores.
See the docker-compose.yml file for Xvfb example config.
Run with Docker
Use makefile script: make dev.run-docker or Docker Compose directly: docker-compose up --build
(CLOUD_GAME_GAMES_PATH is env variable for games on your host). It will spawn a docker environment and you can access
the service on localhost:8000.
Configuration
The configuration parameters are stored in the configs/config.yaml file which is shared for all
application instances on the same host system. It is possible to specify individual configuration files for each
instance as well as override some parameters, for that purpose, please refer to the list of command-line options of the
apps.
Deployment
See an example of deployment scripts if you want to try to host your own cloud-retro copy in the cloud. This script (deploy-app.sh) allows pushing configured application to the group of servers automatically. The cloud server should be any Debian-based system with the docker-compose application installed.
Technical documents
| High level | Worker internal |
|---|---|
![]() |
![]() |
FAQ
Crowd Play, play game together
By clicking these deep link, you can join the game directly and play it together with other people.
And you can host the new game by yourself by accessing cloudretro.io and click "share" button to generate a permanent link to your game.
Synchronize a game session on multiple devices
Credits
We are very much thankful to everyone we've been lucky to collaborate with and many people for help and inspiration from their awesome works.
Thanks:
- Pion team for the incredible Golang WebRTC library and their support.
- Libretro team for the greatest emulation lib.
- kivutar for go-nanoarch and ludo.
- gen2brain for the h264 and VPX encoder.
- poi5305 for the YUV video encoding.
- fogleman for the NES emulator.
Art
- October 2nd - Gameboy poltergeist by Wayne Kubiak (wanyo)
- 1978 by Simon C Page
- Linear Video game controller background Gadgets seamless pattern by Anna
Announcement
CloudMorph is a sibling project that offers a more generic to run any offline games/application on browser in Cloud Gaming approach: https://github.com/giongto35/cloud-morph)
Team
Authors:
- Nguyen Huu Thanh (https://www.linkedin.com/in/huuthanhnguyen)
- Tri Dang Minh (https://trich.im)
Maintainers:
- Sergey Stepanov (https://github.com/sergystepanov)

