Commit graph

122 commits

Author SHA1 Message Date
Sergey Stepanov
f557d16997
Fix broken link 2024-03-31 22:08:32 +03:00
Sergey Stepanov
4e241d0448 Swap x264-git dep to libx264 in Msys2/Arch 2024-02-10 21:13:49 +03:00
sergystepanov
f7d12e65e5
Update README.md
Add some additional libyuv notes.
2023-12-22 16:09:59 +03:00
sergystepanov
27c9ce681b
Update README.md 2023-12-04 18:39:26 +03:00
Sergey Stepanov
1993950cd7
Downgrade requirements for an old Ubuntu 2023-12-04 18:20:05 +03:00
Himaj333
ad07ad2014 Fixed README.md 2023-10-26 16:57:19 +03:00
Sergey Stepanov
9c768277c7 Use sudo static Docker builds 2023-10-17 19:23:00 +03:00
Sergey Stepanov
f11cad157b Use static libyuv for macs 2023-10-16 01:50:06 +03:00
Sergey Stepanov
b1b33713d6 Add the initial libyuv support
The main benefit of libyuv, apart from shortening the video pipeline, is quite noticeable latency and CPU usage decrease due to various assembler/SIMD optimizations of the library. However, there is a drawback for macOS systems: libyuv cannot be downloaded as a compiled library and can only be built from the source, which means we should include a cropped source code of the library (~10K LoC) into the app or rise the complexity of macOS dev and run toolchains. The main target system -- Linux, and Windows will use compiled lib from the package managers and macOS will use the lib included as a shortened source-code.

Building the app with the no_libyuv tag will force it to use libyuv from the provided source files.
2023-10-15 18:55:53 +03:00
Sergey Stepanov
1dc0cabc2b Add special Dockerfile for tiny coordinator (<10Mib) and worker (<150Mib) containers 2023-05-12 14:31:21 +03:00
sergystepanov
3175747ee5
Update README.md 2023-05-02 00:20:07 +03:00
sergystepanov
3bd959b4ef
Refactored v3 (#350)
This PR contains refactored code.

**Changelog**
- Added new net code (the communication architecture was left intact).
- All network client IDs now have custom type `network.Uid` backed by github.com/rs/xid lib.
  ```
  The string representation of a UUID takes 32 bytes, and the new type will take just 16.
  Because of Golang JSON serialization problems with omitting zero-length empty slices (it can't) 
  and the need to use UID values as map keys (maps don't support slices as keys), 
  IDs are stored as strings (for now).
  ```
- A whole new WebSocket client/server implementation was added, as well as a new communication layer with synchronous and async call handlers.
  - WebSocket connections now support dedicated Ping/Pong frames as opposed to original ping text messages.
  - Used Gorilla WebSocket library doesn't allow concurrent (simultaneous) reads and writes, so this part was handled via send channel synchronization.
- New API structures can be found in the `pkg/api` folder.
- New communication protocol can be found in the `pkg/com/*` folder.
- Updated communication protocol is based on JSON-encoded messaging through WebSocket and has the following structure:
  ```
  Packet
    [id] string — a globally unique identification tag for the packet to track it trough a chain of requests.
    t uint8 — contains packet type information (i.e. INIT_PACKET, SDP_OFFER_PACKET, ...).
    [p] any — contains packet data (any type).

  Each packet is a text message in JSON-serialized form (WebSocket control frames obviously not).
  ```
  ```
  The main principle of this protocol and the duplex data exchange is:
  the one who initializes connection is called a client, and 
  the one who is being connected to is called a server. 
  With the current architecture, the coordinator is the server, the user browsers and workers are the clients.

            ____           ____
           ↓    ↑         ↑    ↓
     browser ⟶ coordinator ⟵ worker
       (c)          (s)         (c)

  One of the most crucial performance vise parts of these interactions is that 
  all the server-initiated calls to clients should be asynchronous!
  ```
  - In order to track synchronous calls (packets) with an asynchronous protocol, such as WebSocket, each packet may have an `id` that should be copied in all subsequent requests/responses.
  - The old `sessionID` param was replaced by `id` that should be stored inside the `p` (payload) part of the packet.
- It is possible to skip the default ping check for all connected workers on every user connection and just pick the first available with the new roundRobin param in the coordinator config file `coordinator.roundRobin: true/false`.
- Added a dedicated package for the system API (pkg/api/*).
- Added structured logging system (zerolog) for better logging and cloud services integration.
- Added a visual representation of the network message exchange in logs:
  ```
  ...
  01:00:01.1078 3f98 INF w → c Handshake ws://localhost:8000/wso
  01:00:01.1138  994 INF c ← w Handshake localhost:8000
  01:00:01.1148  994 INF c ← w Connect cid=cep.hrg
  01:00:01.1158  994 DBG c     connection id has been changed to cepl7obdrc3jv66kp2ug cid=cep.hrg
  01:00:01.1158 3f98 INF w → c Connect cid=cep.2ug
  01:00:01.1158  994 INF c     New worker / addr: localhost, ...
  01:00:01.1158 3f98 INF w     Connected to the coordinator localhost:8000 cid=cep.2ug
  01:00:02.5834  994 INF c ← u Handshake localhost:8000
  01:00:02.6175  994 INF c ← u Connect cid=cep.hs0
  01:00:02.6209  994 INF c     Search available workers cid=cep.hs0
  01:00:02.6214  994 INF c     Found next free worker cid=cep.hs0
  01:00:02.6220  994 INF c → u InitSession cid=cep.hs0
  01:00:02.6527  994 INF c ← u WebrtcInit cid=cep.hs0
  01:00:02.6527  994 INF c → w ᵇWebrtcInit cid=cep.hrg
  01:00:02.6537 3f98 INF w ← c WebrtcInit cid=cep.2ug
  01:00:02.6537 3f98 INF w     WebRTC start cid=cep.2ug
  ...
  ```
- Replaced a monstrous Prometheus metrics lib.
- Removed spflag dependency.
- Added new `version` config file param/constant for compatibility reasons.
- Bump the minimum required version for Go to 1.18 due to use of generics.
- Opus encoder now is cached and the default config is 96Kbps, complexity 5 (was 196Kbps, 8).
- Changed the default x264 quality parameters to `crf 23 / superfast / baseline` instead of `crf 17 / veryfast / main`.
- Added a separate WebRTC logging config param `webrtc.logLevel`.
- Worker now allocates much less memory.
- Optimized and fixed RGB to YUV converter.
- `--v=5` logging cmd flag was removed and replaced with the `debug` config parameter.


**Breaking changes (migration to v3)**
- Coordinator server API changes, see web/js/api/api.js.
- Coordinator client event API changes:
  - c `GAME_PLAYER_IDX_CHANGE` (string) -> `GAME_PLAYER_IDX` (number)
  - c `GAME_PLAYER_IDX` -> `GAME_PLAYER_IDX_SET`
  - c `MEDIA_STREAM_INITIALIZED` -> `WEBRTC_NEW_CONNECTION`
  - c `MEDIA_STREAM_SDP_AVAILABLE` -> `WEBRTC_SDP_OFFER`
  - c `MEDIA_STREAM_CANDIDATE_ADD` -> `WEBRTC_ICE_CANDIDATE_RECEIVED`
  - c `MEDIA_STREAM_CANDIDATE_FLUSH` -> `WEBRTC_ICE_CANDIDATES_FLUSH`
  - x `MEDIA_STREAM_READY` -> **removed**
  - c `CONNECTION_READY` -> `WEBRTC_CONNECTION_READY`
  - c `CONNECTION_CLOSED` -> `WEBRTC_CONNECTION_CLOSED`
  - c `GET_SERVER_LIST` -> `WORKER_LIST_FETCHED`
  - x `KEY_STATE_UPDATED` -> **removed**
  - n `WEBRTC_ICE_CANDIDATE_FOUND`
  - n `WEBRTC_SDP_ANSWER`
  - n `MESSAGE`
- `rtcp` module renamed to `webrtc`.
- Controller state equals Libretro controller state (changed order of bits), see: web/js/input/input.js.
- Added new `coordintaor.selector` config param that changes the selection algorithm for workers. By default it will select any free worker. Set this param to `ping` for the old behavior.
- Changed the name of the `webrtc.iceServers.url` config param to `webrtc.iceServers.urls`.
2023-01-09 23:20:22 +03:00
giongto35
7d355611eb
Update README.md 2022-11-13 12:38:26 -08:00
giongto35
be445d281a
Update README.md 2022-11-13 12:38:04 -08:00
giongto35
b7c437e5c0
Update README.md 2022-05-21 15:58:32 +08:00
sergystepanov
9b2e41ff86
[skip ci] Update the game example link 2022-04-17 23:36:10 +03:00
sergystepanov
89b1683438
[skip ci] Update the game example link 2022-04-17 23:34:46 +03:00
Sergey Stepanov
db52ca3f2f
Remove unused IDE/Git files 2021-10-17 19:52:43 +03:00
Sergey Stepanov
2aa33529e1
Update readme 2021-08-26 14:15:49 +03:00
Sergey Stepanov
875673c661
Remove mingw-w64-x86_64-pkg-config and mingw-w64-x86_64-pkgconf conflict in MSYS2 2021-06-26 22:41:28 +03:00
giongto35
c3c3351feb
Update README.md 2021-06-05 09:46:32 +08:00
giongto35
46d2ca5a62
Update README.md 2021-05-13 03:09:20 +08:00
sergystepanov
602b9ea47c
Make executables ready for static linking (#307)
* Disable CGO (C libs) for coordinator

Needed for static linking.

* Fix "error strings should not be capitalized (ST1005)"

* Fix SA1015

Using time.Tick leaks the underlying ticker, consider using it only in endless functions, tests and the main package, and use time.NewTicker here (SA1015)

* Fix SA9004

Only the first constant in this group has an explicit type (SA9004).

* Remove unused code in the webrtc package

* Fix S1000

Should use a simple channel send/receive instead of select with a single case (S1000).

* Force dir creation/check for core downloader

* Update Makefile release script

* Disable ASLR for worker builds

* Remove WORKER_BUILD_PARAMS flag from the CI

* Don't force recompilation in release

* Add Debian packages installer script

* Build worker app without libopusfile

* Test worker app without libopusfile

* Add opus wrapper without opusfile

* Make install.sh executable

* Add opus lib in Win builds

* Make insecure HTTPS requests when downloading libs

* Add ca-certificates for Docker build stage

go mod download works only with SSL certificates installed.

* Move libx264 wrapper into the repo

That way we can get rid of a lot of not needed external Go dependencies.

* Update the dependencies
2021-04-06 18:16:52 +03:00
sergystepanov
cbab5a1c71
Add deprecation note for libx264 < v160 (#301)
Deprecation due to libx264 version below v160 shouldn't work properly, and it's hard to support both v155, v160 in Golang.
2021-03-26 18:51:10 +03:00
sergystepanov
bd701f10fc
Use modified x264 lib (#275)
* Use modified x264 lib

* Add x264 system lib

* Set x264 version 155 for Debian (Buster)

* Add h264 config params

* Set vp8 codec
2021-02-21 13:51:44 +03:00
sergystepanov
924d6ade67
Fix Docker run for bridged Docker network in Windows, macOS (#259)
* Add port and IP config and env params for bridged Docker network in Windows, macOS

- CLOUD_GAME_WEBRTC_ICEIPMAP -- replaces IP of any ICE candidates on the server
- CLOUD_GAME_WEBRTC_ICEPORTS_MIN/MAX -- limits WebRTC random port range on the server
2021-01-08 22:43:15 +03:00
sergystepanov
162c4b9bc8
Update README.md
Add disclaimer about Docker.
2021-01-06 18:59:49 +03:00
sergystepanov
1fcf34ee02
Add new Libretro core manager module (#249)
* Add initial external configuration files support.

These external configuration files allow changing app params at the runtime without recompilation.

* Find config files with specified directory in the tests

* Add aspect ratio recalculation config

* Clean code

* Add new configuration files into the Docker container image

* Add shared core and config paths into the Libretro cores config

* Split ROM <-> Emulator mapping between workers and coordinators

* Extract coordinator config

* Add shared worker/coordinator server config

* Add explicit embedded shared worker/coordinator struct for auto-config reflection fill

* Remove default stun/turn servers from the config

* Extract and add new ice servers config structures

* Update coordinator config params

* Add auto emulation lib loader based on the runtime OS/arch

* Update configuration structures

* Remove shared config embedding

* Add missing network config params

* Add game library external config

* Remove unused config parameters

* Add WebRTC encoder external options

* Add user dir for config search

* Update config loader

* Update config

* Add generic downloader with Grab lib implementation

* Add a simple file downloader backed by the grab lib

* Add initial Libretro core repos abstractions

* Expose compression info for Libretro cores repository records

* Add pipe-based abstract file downloader

* Refactor downloader

* Refactor Libretro repos

* Add worker coresync stubs

* Add multiprocess-safe HTTP-based core manager implementation

* Remove Libretro cores from the repo

* Keep custom N64 cores in te repo for now

* Add Libretro cores repo select in the config

* Fix http manager repo switch

* Cleanup code

* Add greedy Libretro lib loader

* Don't crash when arch map is not set

* Disable dynamic recompiler for pcsx core by default since it's could cause a crash

* Use global Libretro dynalib handler

* Shorten the default Libretro cores store path

* Update zip extractor implementation

* Remove explicit fig lib field markings

* Add config note to the README file

* Add GitHub repo backend for the core downloader

* Fix GitHub repo param list in the manager factory

* Add env variables reader with CLOUD_GAME prefix

* Re-optimize ice server info struct custom marshaler
2020-12-31 13:24:27 +03:00
Sergey Stepanov
7299ecc6d1
Add art credits 2020-11-25 20:57:46 +03:00
giongto35
569c76a2f8
Update README.md 2020-11-13 19:21:10 +08:00
giongto35
b945e81895
Update README.md 2020-11-13 19:20:35 +08:00
sergystepanov
5d28d6f94b
Add missing Ubuntu packages in the guide (#243)
* Add missing Ubuntu packages in the guide

* Bump expected Go language version for the app
2020-10-31 01:38:45 +08:00
giongto35
ea0a433ee9
Update README.md 2020-10-20 11:24:52 +08:00
giongto35
a31652c6cc
Update README.md 2020-10-17 03:44:23 +08:00
sergystepanov
04d21ef420
Add .editorconfig file for proper Markdown trailing spaces handling (#229) 2020-09-20 19:07:45 +08:00
sergystepanov
fdbeb32303
Force OpenGL compatible profile for the Docker compose config (#228) 2020-09-19 11:52:12 +08:00
sergystepanov
b9dc56d85a
Add initial xvfb system dependency for OpenGL cores support in the cloud environment (#226) 2020-09-16 23:26:06 +08:00
giongto35
3d4e5c532b Update cloud morph announcement 2020-08-24 03:17:24 +08:00
giongto35
be0eb458ad
Update README.md 2020-06-17 23:45:55 +08:00
Sergey Stepanov
8b27445458
Integrate SDL2 into CI / Project 2020-06-17 14:00:50 +03:00
sergystepanov
9d3e9c1a3b
Initial Docker rewrite (#190)
* Initial Docker rewrite

* Add rebuild

* Up

* Up

* Up

* Pre-release

* Pack assets with ext games

* Remove Makefile Docker because it's broken on Windows and a dup

* Add default container name

* Update docker-compose.yml

* Add app binaries into the system bin folder

* Update

* Update
2020-06-09 20:38:43 +08:00
Sergey Stepanov
ee9088a065
Update deps for WSL2 support 2020-05-29 15:22:28 +03:00
giongto35
e948174a8f Update README remove chrome 2020-04-28 02:57:59 +08:00
Sergey Stepanov
ffd4007bd2
Update MSYS2 pre-build step 2020-04-27 12:29:45 +03:00
giongto35
7e8ebd5f74 Minor fix + Update more collaborate games for fun 2020-04-19 03:35:28 +08:00
giongto35
27cee3976a
Update Readme format (#162) 2020-04-17 03:35:49 +08:00
giongto35
d8d3658783 Update Technical wrapup from WebRTChacks 2020-04-17 02:27:14 +08:00
sergystepanov
e547b69bb7
Add build workflow (#161)
* Add build workflow

* Fix markdown
2020-04-11 00:26:12 +08:00
sergystepanov
da39545824
Fix release badge in the README.md 2020-04-08 23:34:18 +03:00
sergystepanov
e2fc8696c8
Add multi-os Github release workflow (#159) 2020-04-09 04:01:02 +08:00