WebStream插件
The WebStream plugin allows broadcasting audio data and video frames rendered by a UNIGINE-based application to an unlimited number of devices via WebRTC (Web Real-Time Communication).WebStream插件允许广播音频数据和视频帧呈现基于UNIGINE的应用程序通过 WebRTC(Web Real-Time Communication,网络实时通信)无限数量的设备。
In general, the process is as follows:一般来说,过程如下:
- You run the UNIGINE application on a remote computer, a desktop inside your organization, a container, or a virtual machine provided by a cloud hosting service.您可以在远程计算机、组织内部的桌面、容器或云托管服务提供的虚拟机上运行UNIGINE应用程序。
- UNIGINE uses the resources available to that computer (like CPU, GPU, memory, etc.) to run the application logic and render frames.UNIGINE使用该计算机可用的资源(如CPU,GPU,内存等)。来运行应用程序逻辑和渲染帧。
- The rendered output is continuously encoded into a media stream and passed through a lightweight stack of web services.呈现的输出被连续编码为媒体流,并通过一个轻量级的web服务堆栈传递。
- Users view this stream in standard web browsers running on other computers and mobile devices and control the experience from their browsers, sending keyboard, mouse, and touch events, as well as custom events emitted from the client's web page, back to UNIGINE.用户在其他计算机和移动设备上运行的标准web浏览器中查看此流,并从浏览器控制体验,将键盘,鼠标和触摸事件以及从客户端网页发出的自定义事件发送回UNIGINE。
Launching Plugin启动插件#
To use the WebStream plugin with your project, do the following:要在项目中使用WebStream插件,请执行以下操作:
-
Add it via UNIGINE SDK Browser on the project creation: click Plugins, check the WebStream plugin option, and click Add.在项目创建时通过UNIGINE SDK浏览器添加:单击Plugins,选择WebStream plugin选项,然后单击Add。
For the existing project, choose Other Actions -> Configure Project, add the plugin as described above, and click Update Configuration.对于现有项目,选择Other Actions -> Configure Project,按照上面的描述添加插件,然后单击 Update Configuration。 -
Launch the plugin: specify the extern_plugin command line option on the application start-up.启动插件:在应用程序启动时指定extern_plugin命令行选项。
main_x64 -extern_plugin "UnigineWebStream"
In addition, you can enable the Offscreen mode by specifying the -video_offscreen command-line option. It will allow you to run the application in the headless mode without displaying a visible window.此外,您可以通过指定-video_offscreen命令行选项来打开Offscreen模式。 它将允许您以无头模式运行应用程序,而不显示可见窗口。
main_x64 -extern_plugin "UnigineWebStream" -video_offscreen 1
- If you skip this parameter, the application window will be rendered alongside the video and input streams. However, in this case, inputs from remote clients may be processed incorrectly.如果跳过此参数,则应用程序窗口将与视频和输入流一起呈现。然而,在这种情况下,输入可能会被错误地处理。
- For cases where user input is not allowed in a remote client application, there is no need to enable Offscreen mode.对于不允许用户输入的远程客户端应用程序,无需启用Offscreen模式。
Viewing Output查看输出#
To render the output from the main viewport in a web browser, use the http address data specified in the web configuration file in the address bar as follows:要在Web浏览器中渲染主视口的输出,请在地址栏中使用Web配置文件中指定的HTTP地址数据,如下所示:
localhost:8000 | if the application runs on the same PC.如果应用程序运行在同一台PC上 |
---|---|
[设备IP地址]:8000 |
if the application runs on another PC in the network.如果应用程序运行在网络中的另一台PC上 To make the application accessible from other PCs in the network, specify the IP address of the host PC in the web configuration file.要使应用程序可从网络中的其他PC访问,请在Web配置文件中指定主机PC的IP地址。 |
If the player name is not set in the address at all, i.e. the link looks like:如果地址中未设置Player名称(即链接如下所示):
-
localhost:8000/index.html?video=
or或者
- localhost:8000
the image is streamed as rendered by Main Player.则图像将以 Main Player 的渲染方式进行流式传输。
Engine image:引擎图像: | Streamed image:流式图像: |
|
|
To render from the specific camera, add /index.html?video=PlayerName to the address:要从特定摄像机渲染,请在地址中添加它的名称(/index.html?video=Player名称):
-
localhost:8000/index.html?video=Player名称
or或者
- [设备IP地址]:8000/index.html?video=Player名称
If the player with the specified name does not exist in the current world on the streaming server computer, you'll see a fallback view from the current camera on the streaming server, but without any post-effects and GUI.如果在流式传输服务器计算机的当前场景中不存在指定名称的Player,则会看到来自流式传输服务器当前摄像机的备用视图,但没有任何后期特效和GUI。
Web Configuration FileWeb配置文件#
The plugin comes with the webconfig.json file, which contains settings allowing you to configure the broadcasting process. You can change the server settings (for example, specify a custom HTTP address to view the output in a browser) and enable or disable the user input.该插件附带 webconfig.json 文件,其中包含允许您配置广播过程的设置。您可以更改服务器设置(例如,指定自定义HTTP地址以在浏览器中查看输出),并允许或禁止用户输入。
Here is an example of the default configuration file:以下是默认配置文件的示例:
{
"server":{
"document_root":"./plugins/Unigine/WebStream/html",
"http_address":"0.0.0.0:8000",
"enable_directory_listing" : false,
"num_threads" : 4,
"disable_xframe_options" : false,
"access_control_allow_origin" : "*",
"enable_keep_alive" : true,
"keep_alive_timeout_ms" : 1000,
"decode_url" : false,
"ssl_certificate" : "",
"global_auth_file" : "",
"authentication_domain" : "",
"extra_options" : []
},
"input":{
"enabled" : true
}
}
The server settings are the following:服务器设置如下:
There is also a section with settings of the user input:还有一个部分包含用户输入的设置:
enabled |
Allows or forbids processing of the user input from the web browser by the server.允许或禁止服务器处理来自web浏览器的用户输入。 |
---|