TcrSdk-Windows V1.0
Classes | Public Types | Public Member Functions | List of all members
TcrSession Class Reference

This interface represents a session between the client and the TCR server. More...

#include <tcr_session.h>

Classes

class  Observer
 The Observer class is used to receive events from TcrSession. More...
 

Public Types

enum class  Event {
  STATE_INITED , STATE_CONNECTED , STATE_CLOSED , CLIENT_STATS ,
  GAME_START_COMPLETE , ARCHIVE_LOAD_STATUS , ARCHIVE_SAVE_STATUS , INPUT_STATUS_CHANGED ,
  REMOTE_DESKTOP_INFO , SCREEN_CONFIG_CHANGE , CURSOR_IMAGE_INFO , CURSOR_STATE_CHANGE
}
 Session event definitions. More...
 

Public Member Functions

 TcrSession (std::shared_ptr< TcrSession::Observer > observer)
 
 ~TcrSession ()
 
void Init ()
 
bool Start (const char *serverSession)
 Starts the session.
 
void PauseStreaming ()
 Resume the media stream.
 
void ResumeStreaming ()
 Resume the media stream.
 
void SetRemoteVideoProfile (int32_t fps, int32_t minBitrate, int32_t maxBitrate, std::shared_ptr< AsyncCallback > callback)
 Set the local video profile.
 
void SetRemoteDesktopResolution (int32_t width, int32_t height)
 Set the resolution of Cloud Desktop.
 
void SetVideoFrameObserver (std::shared_ptr< VideoFrameObserver > video_frame_observer)
 Set the callback of the video frame.
 
void RestartCloudApp ()
 Restart the cloud application process.
 
void PasteText (const char *msg)
 Copy the text to the input box in the cloud application.
 
std::shared_ptr< CustomDataChannelCreateCustomDataChannel (int32_t port, std::shared_ptr< CustomDataChannel::Observer >observer)
 Creates a custom data channel.
 
const KeyboardGetKeyboard ()
 Return the interface to interact with the cloud keyboard in this session.
 
const MouseGetMouse ()
 Return the interface to interact with the cloud Mouse in this session.
 
const GamepadGetGamepad ()
 Return the interface to interact with the cloud Gamepad in this session.
 

Detailed Description

This interface represents a session between the client and the TCR server.

Member Enumeration Documentation

◆ Event

enum class Event
strong

Session event definitions.

See also
Observer::onEvent(Event, Object)
Enumerator
STATE_INITED 

This event indicates that the session has been initialized.

The associated event data is of type String and represents the 'ClientSession' which is further used as a parameter to call the Cloud API 'CreateSession'

See also
https://cloud.tencent.com/document/api/1162/40740
STATE_CONNECTED 

This event indicates that the session is connected.

This event has no associated data.

STATE_CLOSED 

This event indicates that the session is closed, and thus it can not be used any more.

The associated event data is of type String and represents the reason for the close.

CLIENT_STATS 

This event indicates that the performance data is updated.

The associated event data is of type string in json format: { "bitrate":number, // The calculated bitrate of the audio and video bytes received over the network. "cpu":string, // CPU usage of the remote device "fps":number, // The frame rate of the decoded video "gpu":string, // GPU usage of the remote device "packet_lost":number, // The number of discarded packets "rtt":number // The round-trip event to STUN }

GAME_START_COMPLETE 

This event indicates that the status of the game process on the server has been changed.

The associated event data is of type string in json format: { user_id: string, // The user ID game_id: string, // The game ID app_id: number, request_id: string, status: number, // The game start error code. Valid values: // 0: Started the game successfully; // 1: Failed to start the game; // 2: The game status changed from not running to running; // 3: The game status changed from running to not running. }

ARCHIVE_LOAD_STATUS 

This event indicates the status of the archive loading in the server.

The associated event data is of type String in json format: { user_id: string, // The user ID game_id: string, // The game ID name: string, // The eventual filename of the archive url: string, // The archive download address status: number, // The error code of the archive loading status. // Valid values: // 0: loaded the archive successfully; // 1: Failed to download the archive; // 2: Failed to verify the archive; // 3: Failed to extract the archive; // 4: Other error; // 5: The archive was being downloaded. save_type: string, // "`Auto` or `Normal`", category_id: string, // The archive category ID archive_size: number, // The archive size loaded_size: number // The size of the downloaded archive }

ARCHIVE_SAVE_STATUS 

This event indicates the status of the archive saving in the server.

The associated event data is of type String in json format: { user_id: String // The user ID game_id: String // The game ID name: String // The eventual filename of the archive md5: String // The MD5 value of the archive status: number // The error code of the archive saving status. // Valid values: // 0: saved the archive successfully; // 1: Failed to save the archive; // 2: Failed to compress the archive; // 3: Other error; // 4: The archive was being uploaded; // 5: The archive could not be found; // 6: The archive operations were too frequent. save_type: String // "`Auto` or `Normal`", category_id: String // The archive category ID archive_size: number // The archive size saved_size: number // The size of the saved archive }

INPUT_STATUS_CHANGED 

This event indicates that the input status of the server has changed.

The associated event data is of type string in json format: { status: String // If the status distributed by the cloud is disabled, input is disabled. }

REMOTE_DESKTOP_INFO 

This event indicates that the remote desktop information is updated.

The associated event data is of type string in json format: { "app_window_left_offset":number, // Offset of the horizontal axis of the remote desktop. // The picture received locally is an offset picture, so the coordinates to be sent need to be converted // according to the width of the remote desktop and an offset needs to be added.

"app_window_top_offset":number, // Vertical offset of the remote desktop. // The image received locally is an offset image, so the coordinates to be sent need to be converted // according to the height of the remote desktop and then offset. "cursor_showing":bool, // cursor show status true:showing false:hidden. "screen_height":number, // The width of the remote desktop, which is used to calculate the ratio of the local and remote coordinate transformations. "screen_width":number // The height of the remote desktop, which is used to calculate the ratio of the local and remote coordinate transformations. }

SCREEN_CONFIG_CHANGE 

This event indicates that the configuration of the cloud screen configuration has been changed.


The associated event data is of type ScreenConfig: { "orientation":string, // Activity direction of cloud application "width":number, // The width of the video screen resolution "height":number // The height of the video screen resolution }

CURSOR_IMAGE_INFO 

This event indicates that the remote cursor image information is updated.

The associated event data is of type string in json format: { "cursor_bitmap":string, // cursorBitmap mouse pointer picture, is a base64 encoded bitmap. "hot_spot_x":number, // hot_spot_x mouse x coordinate offset, default value is 0 (The mouse pointer points to the upper left vertex) "hot_spot_y":number // hot_spot_y mouse y coordinate offset, default value is 0 (The mouse pointer points to the upper left vertex) }

CURSOR_STATE_CHANGE 

This event indicates that the showing status of cloud cursor is changed.

The associated event data is of type string in json format: { "cursor_show_state":bool // Cloud cursor showing state }

Constructor & Destructor Documentation

◆ TcrSession()

TcrSession ( std::shared_ptr< TcrSession::Observer observer)

◆ ~TcrSession()

~TcrSession ( )

Member Function Documentation

◆ CreateCustomDataChannel()

std::shared_ptr< CustomDataChannel > CreateCustomDataChannel ( int32_t  port,
std::shared_ptr< CustomDataChannel::Observer observer 
)

Creates a custom data channel.

Parameters
portThe cloud port number uniquely identifying the data channel.
CustomDataChannel.Observer.
Returns
the created data channel.
See also
CustomDataChannel

◆ GetGamepad()

const Gamepad * GetGamepad ( )

Return the interface to interact with the cloud Gamepad in this session.

Returns
The interface to interact with the cloud Gamepad in this session.

◆ GetKeyboard()

const Keyboard * GetKeyboard ( )

Return the interface to interact with the cloud keyboard in this session.

Returns
The interface to interact with the cloud keyboard in this session.

◆ GetMouse()

const Mouse * GetMouse ( )

Return the interface to interact with the cloud Mouse in this session.

Returns
The interface to interact with the cloud Mouse in this session.

◆ Init()

void Init ( )

◆ PasteText()

void PasteText ( const char *  msg)

Copy the text to the input box in the cloud application.

The input box of the cloud application must have obtained the focus and allow the user to paste text from the clipboard.

Parameters
msgThe text to be pasted

◆ PauseStreaming()

void PauseStreaming ( )

Resume the media stream.

◆ RestartCloudApp()

void RestartCloudApp ( )

Restart the cloud application process.

◆ ResumeStreaming()

void ResumeStreaming ( )

Resume the media stream.

◆ SetRemoteDesktopResolution()

void SetRemoteDesktopResolution ( int32_t  width,
int32_t  height 
)

Set the resolution of Cloud Desktop.

If the cloud PC application is in full-screen mode, the resolution of the downstream video stream will also change accordingly.

This method is currently only valid for scenarios where the cloud is a PC application, and the scenario where the cloud is a mobile application is to be supported.

Parameters
widthWidth of cloud desktop.
heightHeight of cloud desktop.

◆ SetRemoteVideoProfile()

void SetRemoteVideoProfile ( int32_t  fps,
int32_t  minBitrate,
int32_t  maxBitrate,
std::shared_ptr< AsyncCallback callback 
)

Set the local video profile.

Parameters
widthThe frame width. Suggested value: 640.
heightThe frame height. Suggested value: 480.
fpsThe frame rate. Suggested value: 30.
minBitrateThe minimum bitrate in kbps. Suggested value: 512.
maxBitrateThe maximum bitrate in kbps. Suggested value: 1024.
isFrontCamerawhether to use the front camera. Suggested value: true.

◆ SetVideoFrameObserver()

void SetVideoFrameObserver ( std::shared_ptr< VideoFrameObserver video_frame_observer)

Set the callback of the video frame.

This observer will callback the decoded frame, which contains I420Buffer frame data and some frame information.

Parameters
video_frame_observerThis observer will callback the decoded frame.
See also
VideoFrameObserver

◆ Start()

bool Start ( const char *  serverSession)

Starts the session.

This method should only be called once.

Parameters
serverSessionThe ServerSession returned from CreateSession API. Check out the https://cloud.tencent.com/document/api/1162/40740 website for details.
Returns
true if success, false otherwise.

The documentation for this class was generated from the following file: