WebStream Plugin
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:
- 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 uses the resources available to that computer (like CPU, GPU, memory, etc.) to run application logic and render frames.
- The rendered output is continuously encoded into a media stream and passed through a lightweight stack of web services.
- 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:
-
Add it via UNIGINE SDK Browser on project creation: click Plugins, check the WebStream plugin option, and click Add.
For the existing project, choose Other Actions -> Configure Project, add the plugin as described above, and click Update Configuration. -
Launch the plugin: specify the extern_plugin command line option on the application start-up.
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.
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.
Viewing Output#
To view the rendered output in a web browser, specify localhost:8000 or [device-IP-address]:8000 in the address bar.
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:
{
"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. When the input is not allowed, the plugin can be used without the Offscreen mode without any issues. |
---|