Implementing Cloud Game Applications

This topic describes how to implement game mode for cloud-based gaming applications.


Related Info


Game mode uses WebRTC to enable Web applications to implement low-latency streaming for cloud-based games.

The following figure shows the general structure of cloud-based game implementation.

Figure 1: Cloud-based game structure

Prerequisites

To enable your application to use game mode, add the following metadata key to your "config.xml" file:

<tizen:metadata key="http://samsung.com/tv/metadata/use.game.mode" value="true" />

Implementing Game Mode

To implement cloud game streaming with the Web standard WebRTC Interface on Samsung TVs, you must consider the following requirements.

Video Resolution and Frame Rate Definition

To reduce latency, before game streaming starts, the Tizen platform requires the minimum and maximum video resolution and maximum frame rate to be defined in SDP (Session Description Protocol).
For example:

  • Dynamic resolution from 960 x 540 up to 1920 x 1080, maximum frame rate 60 frames per second:
    a=imageattr:<payload> send [x=[960:1920],y=[540:1080],fps=[60:60]] 
    
  • Dynamic resolution from 960 x 540 up to 3840 x 2160, maximum frame rate 60 frames per second:
    a=imageattr:<payload> send [x=[960:3840],y=[540:2160],fps=[60:60]] 
    
  • Constant 1920 x 1080 resolution, maximum frame rate 60 frames per second:
    a=imageattr:<payload> send [x=[1920:1920],y=[1080:1080],fps=[60:60]]
    

For more information, see Interpreting imageattr attributes.

Multitasking

In addition to the general Web application multitasking policy, applications supporting WebRTC streaming must also implement the following behaviors:

  • When the application goes to the background through a visibilityChange event, you must set the enabled property for all tracks to false.
  • When the application comes to the foreground through a visibilityChange event, you must set the enabled property for all tracks to true.
    The streaming server must also respond to the FIR (Full Intra Request) from the WebRTC engine using an RTP/RTSP message.

For more information about the enabled property, see the MediaStreamTrack Interface.

Single Audio and Video Tracks

Game streaming Web applications must use a single audio track and a single video track. Both audio and video tracks must be within the same Video element.

document.querySelector('audio').srcObject.getTracks().length; // Value must be 0
document.querySelector('video').srcObject.getTracks().length; // Value must be 2

Self-Diagnosis

You must provide the following features to enable users to verify and troubleshoot their connection to the cloud game service:

  • Menu item for checking the cloud service connection status
  • Notifications for the connection quality
  • Information about troubleshooting and improving connection quality

Gamepad Controls

For information on implementing gamepad controls for your application, see Gamepad.