Commit graph

102 commits

Author SHA1 Message Date
Sergey Stepanov
31c670252c Update dependencies 2024-11-26 19:35:31 +03:00
Sergey Stepanov
71f5de3bf9 Update dependencies 2024-11-26 19:35:31 +03:00
Sergey Stepanov
0ab6f58d36
Update dependencies 2024-10-18 21:56:54 +03:00
Sergey Stepanov
2084d0958b
Update dependencies 2024-09-24 22:59:11 +03:00
Sergey Stepanov
fd34d5a972
Update dependencies 2024-09-14 20:38:11 +03:00
Sergey Stepanov
ddb16f899f
Update dependencies 2024-08-17 18:13:46 +03:00
Sergey Stepanov
1ff7be38eb
Update x/image 2024-08-06 20:36:15 +03:00
Sergey Stepanov
c87b5cec65
Revert "Update dependencies"
This reverts commit 80afc18892.
2024-08-06 20:34:34 +03:00
Sergey Stepanov
80afc18892
Update dependencies 2024-08-06 20:01:01 +03:00
Sergey Stepanov
af8569a605
Update dependencies 2024-07-26 17:43:33 +03:00
Sergey Stepanov
d8a3e82f1e
Update dependencies 2024-07-14 19:31:44 +03:00
Sergey Stepanov
daf6a20e1d
Update dependencies 2024-07-09 21:19:41 +03:00
Sergey Stepanov
3989a735ac
Update dependencies 2024-05-20 22:46:59 +03:00
Sergey Stepanov
b843538fea
Update dependencies 2024-05-07 21:08:35 +03:00
Sergey Stepanov
8caad44ade Update dependencies 2024-04-22 11:34:56 +03:00
Sergey Stepanov
7377b4f15b
Update dependencies 2024-03-31 21:30:46 +03:00
Sergey Stepanov
ff6c344a15 Update dependencies 2024-03-21 16:10:09 +03:00
Sergey Stepanov
f8392ab0be
Update dependencies 2024-03-08 18:46:46 +03:00
Sergey Stepanov
3568b7a12a
Update dependencies 2024-03-02 16:23:11 +03:00
Sergey Stepanov
b903700077
Update dependencies 2024-02-11 15:30:45 +03:00
Sergey Stepanov
ccb0f410ab Revert "Revert Go version back to 1.20"
This reverts commit 1a44b94c85.
2024-02-10 21:13:49 +03:00
Sergey Stepanov
1a44b94c85
Revert Go version back to 1.20
Go 1.22 crashes under Windows with h264 encoder.
2024-02-08 16:38:40 +03:00
Sergey Stepanov
a3f07057f4
Update dependencies 2024-02-07 12:23:14 +03:00
Sergey Stepanov
fca46f1a32 Update dependencies 2023-12-22 20:49:16 +03:00
Sergey Stepanov
f475dbabb7
Update dependencies 2023-12-04 01:38:30 +03:00
Sergey Stepanov
e6e537d799 Add a generic S3 provider for cloud saves 2023-11-13 21:33:12 +03:00
Sergey Stepanov
d805ba8eb8 Update dependencies 2023-11-03 01:12:22 +03:00
Sergey Stepanov
9ec6541322 Update dependencies 2023-10-20 22:43:51 +03:00
Sergey Stepanov
92aea18a8c
Update dependencies 2023-10-13 11:13:27 +03:00
Sergey Stepanov
a901c84d99
Update dependencies 2023-09-26 21:01:19 +03:00
Sergey Stepanov
d7e7112e25 Update dependencies 2023-09-16 20:12:24 +03:00
Sergey Stepanov
cc414881ea
Update dependencies 2023-07-06 00:01:27 +03:00
Sergey Stepanov
42b82a368c Update deps 2023-06-16 14:12:41 +03:00
sergystepanov
7668ef7bd8
Refactor media (#401)
* Encapsulate media
* Write audio by 4 bytes instead 2
* Update deps
2023-05-27 17:34:35 +03:00
Sergey Stepanov
d237a5b6ea
Update dependencies 2023-05-21 13:59:33 +03:00
Sergey Stepanov
70d9ff32b7
Update dependencies 2023-05-12 21:21:51 +03:00
Sergey Stepanov
8893e1e5bf Update config manager 2023-04-22 17:05:28 +03:00
Sergey Stepanov
df980c5cf4
Update versions 2023-04-20 14:19:40 +03:00
Sergey Stepanov
b0b7966b47
Bump minimum Go version to 1.20 2023-04-06 20:37:56 +03:00
sergystepanov
cfd5b1ae8d
Libretro cores config in yaml (#392)
Removes separate config files for Libretro cores stored in the cores folder and replaces them with options in the main config.yaml file.
2023-04-06 11:25:49 +03:00
Sergey Stepanov
c8f5bdbcdb
Update dependencies 2023-03-16 23:49:40 +03:00
Sergey Stepanov
cd056ee976
Bump to v3 2023-03-16 23:46:53 +03:00
Sergey Stepanov
c237ee1a47
Update dependencies 2023-02-17 17:56:32 +03:00
Sergey Stepanov
8b4b238cf9
Update dependencies 2023-02-10 14:20:02 +03:00
Sergey Stepanov
8006939d69
Update versions 2023-02-04 22:54:18 +03:00
Sergey Stepanov
652ffe37cc
Do not track DTLS errors (client disconnect) on WebRTC close 2023-02-04 20:32:16 +03:00
Sergey Stepanov
0c3b8ab8d7
Update dependencies 2023-01-31 22:55:11 +03:00
sergystepanov
2b81c3fb87
Some optimizations (#387)
- 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.
2023-01-31 22:22:03 +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
sergystepanov
d79e772471
Use custom OpenGL bindings (#378) 2022-08-18 22:18:25 +03:00