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 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 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 turn on 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 may be processed incorrectly.如果跳过此参数,则应用程序窗口将与视频和输入流一起呈现。然而,在这种情况下,输入可能会被错误地处理。
- When user input is not allowed, the plugin can be used without the Offscreen mode.当不允许用户输入时,插件可以在没有Offscreen模式的情况下使用。
Viewing Output查看输出#
To view the rendered output in a web browser, specify localhost:8000 or [device-IP-address]:8000 in the address bar.如果需要在浏览器中查看渲染后的输出,可以在地址栏中指定localhost:8000或[device-IP-address]:8000。
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 allow or forbid 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:服务器设置如下:
document_root | Directory from which the web server serves pages.web服务器为页面提供服务的目录。 |
---|---|
http_address | HTTP address and port for the web server.Web服务器的HTTP地址和端口。 |
enable_directory_listing | Flag indicating whether users can browse the contents of the folder specified in the document_root through the web browser or only access the predefined pages.标识用户是可以通过浏览器浏览 document_root 中指定文件夹的内容,还是只能访问预定义页面。 |
num_threads | Number of threads for the web server. It is not recommended to set this to fewer than 2.Web服务器的线程数。 不建议将其设置为小于2。 |
disable_xframe_options | Flag indicating whether the X-Frame-Option response header is enabled.X-Frame-Option响应头是否开启的标志。 |
access_control_allow_origin | Access-Control-Allow-Origin response header. By default, it is set to *, allowing a web browser to request code from any origin.Access-Control-Allow-Origin响应头。 默认情况下,它设置为*,允许web浏览器从任何来源请求代码。 |
enable_keep_alive | Value indicating whether the Keep-Alive header is enabled.指示是否启用Keep-Alive头的值。 |
keep_alive_timeout_ms | Time, in milliseconds, that the host will keep an idle connection open.主机保持空闲连接打开的时间(以毫秒为单位)。 |
decode_url | Flag indicating whether URL decoding is enabled.指示是否启用URL解码的标志。 |
ssl_certificate | Path to the certificate required for HTTPS.HTTPS所需证书的路径。 |
global_auth_file | Path to a global authentication file.全局身份验证文件的路径。 |
authentication_domain | Authentication domain.认证域。 |
extra_options | List of additional server settings.附加服务器设置列表。 |
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浏览器的用户输入。 |
---|