Skip to content

Commit

Permalink
v0.4 (#21)
Browse files Browse the repository at this point in the history
* protocol changed
* WebSocket for both stream and control
* Avoid singleton
* Improve debug message
* regame-authenticator
* Remove SDL_net
  • Loading branch information
UMU618 authored Sep 27, 2021
1 parent 95ebbc0 commit 81fc1ab
Show file tree
Hide file tree
Showing 56 changed files with 2,406 additions and 1,519 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# VS
.vs/
bin/
tmp/

*.vcxproj.user

# macOS
.DS_Store
48 changes: 23 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Cloud gaming engine is a core technology to host ordinary games on remote server

`Regame` is still under development. It would be great if you could help.

[Download Regame v0.3 here](https://ks3-cn-beijing.ksyun.com/liuguang/regame_v0.3.zip)
[Download Regame v0.4 here](https://ks3-cn-beijing.ksyun.com/liuguang/regame_v0.4.zip)

Demo videos (Chinese):

Expand Down Expand Up @@ -61,53 +61,50 @@ You can launch `cge` directly, which will apply default options.
Run `cge --help` to see all options:

```
KSYUN Edge Cloud Gaming Engine v0.3 Beta
KSYUN Edge Cloud Gaming Engine v0.4 Beta
Usage:
-h [ --help ] Produce help message
--audio-bitrate arg (=128000) Set audio bitrate
--audio-codec arg (=libopus) Set audio codec. Select one of {libopus, aac,
opus}
--bind-address arg (=::) Set bind address for listening. eg: 0.0.0.0
--control-port arg (=8080) Set the UDP port for control flow
--disable-keys arg Disable scan codes. eg: 226,230 disable ALT;
227,231 disable WIN
--donot-present arg (=0) Tell cgh don't present
--hardware-encoder arg Set video hardware encoder. Select one of
{amf, nvenc, qsv}
--keyboard-replay arg (=none) Set keyboard replay method. Select one of
{none, cgvhid}
--gamepad-replay arg (=none) Set gamepad replay method. Select one of
{none, cgvhid, vigem}
--keyboard-replay arg (=none) Set keyboard replay method. Select one of
{none, cgvhid}
--mouse-replay arg (=none) Set mouse replay method. Select one of {none,
cgvhid}
--log-level arg (=info) Set logging severity level. Select one of
{trace, debug, info, warning, error, fatal}
--stream-port arg (=8080) Set the websocket port for streaming, if port
is 0, disable stream out via network. Capture
and encode picture directly at startup but not
on connection establishing, and never stop
this until cge exit. stream port is not same
as control port, this port is only for media
output.
-p [ --port ] arg (=8080) Set the service port
--video-bitrate arg (=1000000) Set video bitrate
--video-codec arg (=h264) Set video codec. Select one of {h264, h265,
hevc}, h265 == hevc
--video-gop arg (=180) Set video gop. [1, 500]
--video-preset arg Set preset for video encoder. For AMF, select
one of {speed, balanced, quality}; For NVENC,
select one of {default, slow, medium, fast,
hp, hq, bd, ll, llhq, llhp, lossless,
losslesshp, p1, p2, p3, p4, p5, p6, p7}; For
QSV, select one of {veryfast, faster, fast,
medium, slow, slower, veryslow}; otherwise,
select one of {ultrafast, superfast, veryfast,
faster, fast, medium, slow, slower, veryslow,
placebo}
select one of {p1, p2, p3, p4, p5, p6, p7,
slow, medium, fast}; For QSV, select one of
{veryfast, faster, fast, medium, slow, slower,
veryslow}; otherwise, select one of
{ultrafast, superfast, veryfast, faster, fast,
medium, slow, slower, veryslow, placebo}
--video-quality arg (=23) Set video quality. [0, 51], lower is better, 0
is lossless
```

You can press `Ctrl+C` to stop it gracefully.

### regame-authenticator

`cge` uses [regame-authenticator](https://github.com/ksyun-kenc/regame-authenticator) to verify login.

### cgh

Some hook dlls for capturing pictures from D3D game.
Expand Down Expand Up @@ -168,8 +165,7 @@ Usage:
-l [ --list-hardware-decoder ] List hardware decoder
-d [ --hardware-decoder ] arg Set hardware decoder
-r [ --remote-host ] arg (=127.0.0.1) Set remote host
-c [ --control-port ] arg (=8080) Set remote control port
-s [ --stream-port ] arg (=8080) Set remote stream port
-p [ --remote-port ] arg (=8080) Set remote port
--top-most arg Keep the main window always on top
-u [ --username ] arg Set username
--verification-code arg Set verification code
Expand All @@ -186,6 +182,8 @@ A WebRTC server works together with `cge`, to serve web clients.

[Reference .vsconfig](doc/.vsconfig)

![VS2019](doc/vs2019.jpg)

### 4.2 Boost

Install [Boost](https://www.boost.org/) and set `BOOST_ROOT` environment variable to install directory. [Details](https://blog.umu618.com/2020/09/11/umutech-boost-1-installation/)
Expand Down Expand Up @@ -235,7 +233,7 @@ Video Reference (Chinese):

Set `SDL2_ROOT` environment variable to the path of your [SDL2](https://www.libsdl.org/) directory.

The same as [SDL_ttf 2.0](https://www.libsdl.org/projects/SDL_ttf/) and [SDL_net 2.0](https://www.libsdl.org/projects/SDL_net/).
The same as [SDL_ttf 2.0](https://www.libsdl.org/projects/SDL_ttf/).

The folder tree should be like:

Expand Down Expand Up @@ -268,7 +266,7 @@ Test steps:

- Run `video_source` on server.

- Run `cgc --server=<server_address>` on anther PC as long as it can access the server over the network.
- Run `cgc -r <server_address>` on anther PC as long as it can access the server over the network.

Test with games:

Expand All @@ -282,7 +280,7 @@ Assume you want to test USF4.

- Run `cgi -d true -e SSFIV.exe -i SSFIV.exe --lx86 .\captureyuv.dll` on server.

- Run `cgc --server=<server_address>` on anther PC as long as it can access the server over the network.
- Run `cgc -r <server_address>` on anther PC as long as it can access the server over the network.

**Note** that only support D3D9, D3D11, D3D12 games now.

Expand Down
48 changes: 23 additions & 25 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

云游戏引擎是一种将普通游戏云化的技术,分为服务端引擎和客户端引擎两部分,其中服务端最为复杂。鎏光还处于开发期,目前已经开源最为复杂的服务端引擎部分,客户端完善之后也将开源。

[按这里下载鎏光 v0.3](https://ks3-cn-beijing.ksyun.com/liuguang/regame_v0.3.zip)
[按这里下载鎏光 v0.4](https://ks3-cn-beijing.ksyun.com/liuguang/regame_v0.4.zip)

演示视频:

Expand Down Expand Up @@ -57,53 +57,50 @@
可以运行 `cge --help` 查看所有参数:

```
KSYUN Edge Cloud Gaming Engine v0.3 Beta
KSYUN Edge Cloud Gaming Engine v0.4 Beta
Usage:
-h [ --help ] Produce help message
--audio-bitrate arg (=128000) Set audio bitrate
--audio-codec arg (=libopus) Set audio codec. Select one of {libopus, aac,
opus}
--bind-address arg (=::) Set bind address for listening. eg: 0.0.0.0
--control-port arg (=8080) Set the UDP port for control flow
--disable-keys arg Disable scan codes. eg: 226,230 disable ALT;
227,231 disable WIN
--donot-present arg (=0) Tell cgh don't present
--hardware-encoder arg Set video hardware encoder. Select one of
{amf, nvenc, qsv}
--keyboard-replay arg (=none) Set keyboard replay method. Select one of
{none, cgvhid}
--gamepad-replay arg (=none) Set gamepad replay method. Select one of
{none, cgvhid, vigem}
--keyboard-replay arg (=none) Set keyboard replay method. Select one of
{none, cgvhid}
--mouse-replay arg (=none) Set mouse replay method. Select one of {none,
cgvhid}
--log-level arg (=info) Set logging severity level. Select one of
{trace, debug, info, warning, error, fatal}
--stream-port arg (=8080) Set the websocket port for streaming, if port
is 0, disable stream out via network. Capture
and encode picture directly at startup but not
on connection establishing, and never stop
this until cge exit. stream port is not same
as control port, this port is only for media
output.
-p [ --port ] arg (=8080) Set the service port
--video-bitrate arg (=1000000) Set video bitrate
--video-codec arg (=h264) Set video codec. Select one of {h264, h265,
hevc}, h265 == hevc
--video-gop arg (=180) Set video gop. [1, 500]
--video-preset arg Set preset for video encoder. For AMF, select
one of {speed, balanced, quality}; For NVENC,
select one of {default, slow, medium, fast,
hp, hq, bd, ll, llhq, llhp, lossless,
losslesshp, p1, p2, p3, p4, p5, p6, p7}; For
QSV, select one of {veryfast, faster, fast,
medium, slow, slower, veryslow}; otherwise,
select one of {ultrafast, superfast, veryfast,
faster, fast, medium, slow, slower, veryslow,
placebo}
select one of {p1, p2, p3, p4, p5, p6, p7,
slow, medium, fast}; For QSV, select one of
{veryfast, faster, fast, medium, slow, slower,
veryslow}; otherwise, select one of
{ultrafast, superfast, veryfast, faster, fast,
medium, slow, slower, veryslow, placebo}
--video-quality arg (=23) Set video quality. [0, 51], lower is better, 0
is lossless
```

可以按 `Ctrl+C` 优雅退出。

### regame-authenticator

`cge` 使用 [regame-authenticator](https://github.com/ksyun-kenc/regame-authenticator) 验证登录。

### cgh

一些用于捕捉 D3D 游戏画面的 Hook DLL。
Expand Down Expand Up @@ -164,8 +161,7 @@ Usage:
-l [ --list-hardware-decoder ] List hardware decoder
-d [ --hardware-decoder ] arg Set hardware decoder
-r [ --remote-host ] arg (=127.0.0.1) Set remote host
-c [ --control-port ] arg (=8080) Set remote control port
-s [ --stream-port ] arg (=8080) Set remote stream port
-p [ --remote-port ] arg (=8080) Set remote port
--top-most arg Keep the main window always on top
-u [ --username ] arg Set username
--verification-code arg Set verification code
Expand All @@ -182,6 +178,8 @@ WebRTC 服务端,配合 `cge` 使用,给 Web 客户端提供服务。

[参考配置](doc/.vsconfig)

![VS2019](doc/vs2019.jpg)

### 4.2 Boost

安装 [Boost](https://www.boost.org/),设置 `BOOST_ROOT` 环境变量,值为您的安装目录。[详情](https://blog.umu618.com/2020/09/11/umutech-boost-1-installation/)
Expand Down Expand Up @@ -231,7 +229,7 @@ Boost 的编译命令,参考:

设置 `SDL2_ROOT` 环境变量,值为您的 [SDL2](https://www.libsdl.org/) 目录的全路径名。

[SDL_ttf 2.0](https://www.libsdl.org/projects/SDL_ttf/) [SDL_net 2.0](https://www.libsdl.org/projects/SDL_net/) 也同样操作。
[SDL_ttf 2.0](https://www.libsdl.org/projects/SDL_ttf/) 也同样操作。

目录树应该类似这样:

Expand Down Expand Up @@ -264,7 +262,7 @@ git submodule update --init

- 服务器上运行 `video_source`

- 客户端上运行 `cgc --server=<server_address>`,请把 `<server_address>` 替换为服务器地址。
- 客户端上运行 `cgc -r <server_address>`,请把 `<server_address>` 替换为服务器地址。

测试游戏:

Expand All @@ -278,7 +276,7 @@ git submodule update --init

- 服务器上运行 `cgi -d true -e SSFIV.exe -i SSFIV.exe --lx86 .\captureyuv.dll`,其中 `-e SSFIV.exe` 处要填好正确的路径名。

- 客户端上运行 `cgc --server=<server_address>`
- 客户端上运行 `cgc -r <server_address>`

**注意** 目前只支持 D3D9、D3D11、D3D12 游戏。(D3D10 游戏没测试过,但可能也支持。)

Expand Down
5 changes: 2 additions & 3 deletions doc/cg.gv
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
digraph G {

subgraph cluster_0 {
style=filled;
color="#3FBFFF";
Expand Down Expand Up @@ -29,7 +28,7 @@ digraph G {
color="#F13929";
node [style=filled,color="#ADB9CA"];
label = "net";
websocket udp;
websocket;
}

subgraph cluster_4 {
Expand All @@ -42,5 +41,5 @@ digraph G {

audio -> audio_frames -> audio_encoder -> websocket -> audio_decoder -> player;
video -> video_frames -> video_encoder -> websocket -> video_decoder -> player;
controller -> udp -> control_replay;
controller -> websocket -> control_replay;
}
Binary file modified doc/cg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/vs2019.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/cgc/b2/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ exe cgc
packet_queue.cpp
stream_buffer.cpp
video_player.cpp
udp_client.cpp
ws_client.cpp
game_client.cpp
: <implicit-dependency>/boost//headers
<target-os>windows,<toolset>msvc:<find-static-library>shell32
<library>/boost//date_time
Expand Down
17 changes: 17 additions & 0 deletions src/cgc/cgc/cgc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2020-present Ksyun
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Enterprise version
6 changes: 2 additions & 4 deletions src/cgc/msvc/cgc/cgc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<ClCompile Include="..\..\cgc\arena.cpp" />
<ClCompile Include="..\..\cgc\audio_player.cpp" />
<ClCompile Include="..\..\cgc\cgc.cpp" />
<ClCompile Include="..\..\cgc\udp_client.cpp" />
<ClCompile Include="..\..\cgc\engine.cpp" />
<ClCompile Include="..\..\cgc\frame_pool.cpp" />
<ClCompile Include="..\..\cgc\frame_queue.cpp" />
Expand All @@ -46,12 +45,11 @@
</ClCompile>
<ClCompile Include="..\..\cgc\stream_buffer.cpp" />
<ClCompile Include="..\..\cgc\video_player.cpp" />
<ClCompile Include="..\..\cgc\ws_client.cpp" />
<ClCompile Include="..\..\cgc\game_client.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\cgc\arena.h" />
<ClInclude Include="..\..\cgc\audio_player.h" />
<ClInclude Include="..\..\cgc\udp_client.h" />
<ClInclude Include="..\..\cgc\engine.h" />
<ClInclude Include="..\..\cgc\ffmpeg.h" />
<ClInclude Include="..\..\cgc\frame_pool.h" />
Expand All @@ -62,7 +60,7 @@
<ClInclude Include="..\..\cgc\pch.h" />
<ClInclude Include="..\..\cgc\stream_buffer.h" />
<ClInclude Include="..\..\cgc\video_player.h" />
<ClInclude Include="..\..\cgc\ws_client.h" />
<ClInclude Include="..\..\cgc\game_client.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
Expand Down
10 changes: 2 additions & 8 deletions src/cgc/msvc/cgc/cgc.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ClCompile Include="..\..\cgc\arena.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cgc\ws_client.cpp">
<ClCompile Include="..\..\cgc\game_client.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cgc\media_player.cpp">
Expand All @@ -51,9 +51,6 @@
<ClCompile Include="..\..\cgc\frame_pool.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\cgc\udp_client.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\cgc\ffmpeg.h">
Expand All @@ -71,7 +68,7 @@
<ClInclude Include="..\..\cgc\pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\cgc\ws_client.h">
<ClInclude Include="..\..\cgc\game_client.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\cgc\media_player.h">
Expand All @@ -95,8 +92,5 @@
<ClInclude Include="..\..\cgc\frame_pool.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\cgc\udp_client.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
Loading

0 comments on commit 81fc1ab

Please sign in to comment.