This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

WebStream插件

警告
本文介绍的功能在 Community SDK 版本中不可用。
您应该升级到 Sim SDK版本才能使用它。
警告
The functionality described in this article is experimental.本文中描述的功能是实验性的。

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:一般来说,过程如下:

  1. 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应用程序。
  2. UNIGINE uses the resources available to that computer (like CPU, GPU, memory, etc.) to run application logic and render frames.UNIGINE使用该计算机可用的资源(如CPU,GPU,内存等)。来运行应用程序逻辑和渲染帧。
  3. The rendered output is continuously encoded into a media stream and passed through a lightweight stack of web services.呈现的输出被连续编码为媒体流,并通过一个轻量级的web服务堆栈传递。
  4. 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插件,请执行以下操作:

  1. 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
  2. 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

注意
You can specify a custom port in the webconfig.json file provided with the plugin.您可以在插件提供的 webconfig.json 文件中指定自定义端口。

Web Configuration File
Web配置文件#

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浏览器的用户输入。

注意
When the input is not allowed, the plugin can be used without the Offscreen mode without any issues.当不允许输入时,插件可以在没有Offscreen模式的情况下使用,没有任何问题。
最新更新: 2024-09-05
Build: ()