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插件

警告
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 the 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 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
  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 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。

Image streamed without GUI because the specified player has not been found未找到指定Player时的无GUI流式图像

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 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:服务器设置如下:

document_root Directory from which the web server serves pages.web服务器为页面提供服务的目录。
http_address

HTTP address and port for the web server.Web服务器的HTTP地址和端口。

  • The default address 0.0.0.0 makes the application accessible only on the local machine. To allow access from other PCs in the network, specify the IP address of the host PC within the local network.默认地址 0.0.0.0 使应用程序仅在本地计算机上可访问。要允许网络中其他PC访问,请在本地网络中指定主机PC的IP地址。
  • Port 8000 is set by default. You can specify any other available port.默认端口为 8000。您也可以指定其他可用端口。
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-11-18
Build: ()