Commit graph

47 commits

Author SHA1 Message Date
sergystepanov
b02cd5c4f0
It is time to update the copyright year 2025-01-04 10:41:51 +03:00
Sergey Stepanov
6de1828ffe Wait user click when autoplay fails 2024-11-29 14:51:33 +03:00
Sergey Stepanov
2ef1a93eaf
Add playsinline video attribute for Safari 2024-10-23 12:25:29 +03:00
Sergey Stepanov
7ee98c1b03 Add keyboard and mouse support
Keyboard and mouse controls will now work if you use the kbMouseSupport parameter in the config for Libretro cores. Be aware that capturing mouse and keyboard controls properly is only possible in fullscreen mode.

Note: In the case of DOSBox, a virtual filesystem handler is not yet implemented, thus each game state will be shared between all rooms (DOS game instances) of CloudRetro.
2024-08-02 11:04:44 +03:00
Sergey Stepanov
d922e58278 Fix UI 2024-04-22 11:43:38 +03:00
Sergey Stepanov
22d1bd7620 Add screen component 2024-04-07 00:20:47 +03:00
Sergey Stepanov
8654604b9b Fix index.html warnings 2024-03-17 22:09:43 +03:00
Sergey Stepanov
2bc64a3be8 Migrate from IIFE to modern ES modules
These modules should be supported by all contemporary browsers, and this transition should resolve most issues related to the explicit import order of the .js files.
2024-03-17 22:09:43 +03:00
Sergey Stepanov
47bd72e1cd
Fix broken options button 2024-03-16 13:15:05 +03:00
Sergey Stepanov
29eedee3ec
Fix keybindings for options 2024-03-15 14:38:30 +03:00
Sergey Stepanov
a349fdd0cf Add 'force full-screen' option 2024-03-14 12:24:39 +03:00
Sergey Stepanov
cf5248ec54 Fix missing gameList transition handler 2024-03-14 12:24:39 +03:00
Sergey Stepanov
4fc53e7220 Update options UI 2024-03-14 12:24:39 +03:00
Sergey Stepanov
72e846894e
Use case-insensitive sort for games 2024-03-07 23:18:42 +03:00
Sergey Stepanov
608da9f64b
Track fullscreen for <video> 2024-03-05 22:07:12 +03:00
Sergey Stepanov
91ace06f8b
Replace the hasMultitap option with a more general solution
The new hid option enables users to map a specific Libretro device (or multiple devices) to the input ports. For instance, this allows users to map a Multitap controller with the snes9x core.
2024-03-05 21:34:37 +03:00
Sergey Stepanov
cdbb5e98f5
Clean 2024-03-02 16:46:08 +03:00
Sergey Stepanov
92e59672f9
Expose scale factor value 2024-03-02 16:38:53 +03:00
Sergey Stepanov
c699455b58
Hide video element controls in fullscreen 2024-02-25 12:51:37 +03:00
Sergey Stepanov
e7e281083f
Add ugly persistent volume option 2024-02-16 22:47:54 +03:00
Sergey Stepanov
a77069a634
Add L2, R2, L3, R3 mappings to keyboard 2023-11-26 22:39:43 +03:00
Sergey Stepanov
2e91feb861 Add initial automatic aspect ratio change
Depending on the configuration param coreAspectRatio, video streams may have automatic aspect ratio correction in the browser with the value provided by the cores themselves.
2023-11-03 01:12:22 +03:00
Sergey Stepanov
6106eee97e Update game list module 2023-06-16 14:12:41 +03:00
Sergey Stepanov
3815e18027
Remove the hack involving the /static route 2023-05-03 11:11:08 +03:00
Sergey Stepanov
dc48c93804
Hide load/save by default 2023-04-27 13:33:07 +03:00
Sergey Stepanov
40bd57c9a0
Remove not needed browser prefixes 2023-04-27 12:28:28 +03:00
Sergey Stepanov
ea3263ca6c
Remove unselected 2023-04-27 12:24: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
Sergey Stepanov
be0e00c7bf
Use display: none in the hide function, so it won't take any space 2022-04-18 22:47:35 +03:00
Sergey Stepanov
ed60ccf41e
Fix visibility of the help overlay 2022-04-18 19:13:26 +03:00
Sergey Stepanov
4baccc4701
Allow adjusting log levels on the fly 2022-04-11 17:46:10 +03:00
sergystepanov
9ad3c98a7d
Rework worker selection feature (#365)
We add a new option for manual worker or machine (server with multiple workers) select, depending on the new coordinator option `coordinator.debug` which by default allows machine selection.
2022-04-07 21:04:30 +03:00
Sergey Stepanov
12352d5677
Open GitHub links in a new tab 2022-03-22 22:08:36 +03:00
Sergey Stepanov
3292964f01
Fix pubsub listeners indexing overlap 2022-01-02 06:58:55 +03:00
Sergey Stepanov
24ff0f2ea2
Close WebRTC connections on disconnect
Not closing RTCPeerConnection and co will cause eventually high processor load in Chrome.
Also, Chrome has some GC issues related to WebRTC, see: https://bugs.chromium.org/p/chromium/issues/detail?id=825576.
2021-12-17 16:10:51 +03:00
sergystepanov
1271aa8438
Game recording support (#356)
This feature adds the ability to record game sessions as raw a/v media files.
2021-12-04 14:20:38 +03:00
Sergey Stepanov
b916b0bf19
Add RTT stats 2021-09-02 23:58:05 +03:00
Sergey Stepanov
e7a2b6a33e
Prevent client favicon requests 2021-08-30 16:30:03 +03:00
sergystepanov
54deb3607d
Remove font-awesome CSS ref from the index page 2021-07-30 22:56:16 +03:00
sergystepanov
d3e16a4a09
Make Google Analytics injection optional (#336)
This allows switching GA client statistics on the client by setting these params in the config.yaml file:
 analytics:
   inject: false/true
   gtag: (your tag)
By default, GA analytics will be disabled.
2021-07-30 12:29:16 +03:00
sergystepanov
3abb1d4818
Use orientation-based video / canvas stretching (#335) 2021-07-28 02:13:03 +03:00
sergystepanov
30d104ee98
Add version info into the apps (#330)
Both worker and coordinator display version number in the console during startup. Coordinator displays its version number in the top right corner of the index.html page.
2021-07-16 18:13:20 +03:00
sergystepanov
7ebd945344
Remove jQuery (#299)
* Remove jQuery

* Remove browser (vendor) prefixes for some CSS properties

* Use simple device orientation test

* Realign D-pad pointers

* Make GameBoy text unselectable

* Cleanup console.log

* Keep 90% size on mobile browsers due to gh-ribbon overlap

* Remove legacy `unselectable="on"` attributes

* Align UI buttons

* Remove not used UI elements

* Change Options button

* Don't show player change message when not in a game

* Add click/touch handler for circle-pad
2021-03-26 11:07:49 +03:00
sergystepanov
92d0dd76f4
Refactor input for safe concurrency (#278)
* Extract input stuff

* Move d-pad option into the main screen

* Add mutex lock on the whole input user sessions struct
2021-02-19 20:33:58 +03:00
sergystepanov
816b210150
Client game screen configuration support (#269)
* Move game screen to a separate [stream] module

* Add a simple canvas video mirror for post-processing

* Add video mirroring to the options
2021-01-25 12:58:05 +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
Sadlil Rhythom
0e17092acb Refactor of cloud game overlord and overworker (#70)
* Introduce Makefile and go vendor directory for faster build

* WIP: Refactor cloud-game codebase with spliting overlord and worker binary

* Fix all issues and have a running build

* Complete first version of refactor
2019-09-12 03:35:21 +08:00
Renamed from static/index.html (Browse further)