This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
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
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

WebStream Plugin

Warning
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).

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.
  2. UNIGINE uses the resources available to that computer (like CPU, GPU, memory, etc.) to run application logic and render frames.
  3. The rendered output is continuously encoded into a media stream and passed through a lightweight stack of web services.
  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.

Launching Plugin#

To use the WebStream plugin with your project, do the following:

  1. Add it via UNIGINE SDK Browser on project creation: click Plugins, check the WebStream plugin option, and click Add.

    Notice
    For the existing project, choose Other Actions -> Configure Project, add the plugin as described above, and click Update Configuration.
  2. Launch the plugin: specify the extern_plugin command line option on the application start-up.

    Source code
    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.

    Source code
    main_x64 -extern_plugin "UnigineWebStream" -video_offscreen 1
    Notice
    • 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.

Viewing Output#

To view the rendered output in a web browser, specify localhost:8000 or [device-IP-address]:8000 in the address bar.

Notice
You can specify a custom port in the webconfig.json file provided with the plugin.

Web Configuration File#

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.

Here is an example of the default configuration file:

Source code
{
	"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.
http_address HTTP address and port for the web server.
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.
num_threads Number of threads for the web server. It is not recommended to set this to fewer than 2.
disable_xframe_options Flag indicating whether the X-Frame-Option response header is enabled.
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.
enable_keep_alive Value indicating whether the Keep-Alive header is enabled.
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.
ssl_certificate Path to the certificate required for 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.

Notice
When the input is not allowed, the plugin can be used without the Offscreen mode without any issues.
Last update: 2024-09-05
Build: ()