TcrSdk-Windows V1.0
|
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< CustomDataChannel > | CreateCustomDataChannel (int32_t port, std::shared_ptr< CustomDataChannel::Observer >observer) |
Creates a custom data channel. | |
const Keyboard * | GetKeyboard () |
Return the interface to interact with the cloud keyboard in this session. | |
const Mouse * | GetMouse () |
Return the interface to interact with the cloud Mouse in this session. | |
const Gamepad * | GetGamepad () |
Return the interface to interact with the cloud Gamepad in this session. | |
This interface represents a session between the client and the TCR server.
|
strong |
Session event definitions.
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' |
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: // |
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: // |
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: // |
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 |
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 |
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 } |
TcrSession | ( | std::shared_ptr< TcrSession::Observer > | observer | ) |
~TcrSession | ( | ) |
std::shared_ptr< CustomDataChannel > CreateCustomDataChannel | ( | int32_t | port, |
std::shared_ptr< CustomDataChannel::Observer > | observer | ||
) |
Creates a custom data channel.
port | The cloud port number uniquely identifying the data channel. |
CustomDataChannel.Observer. |
const Gamepad * GetGamepad | ( | ) |
const Keyboard * GetKeyboard | ( | ) |
Return the interface to interact with the cloud keyboard in this session.
const Mouse * GetMouse | ( | ) |
void Init | ( | ) |
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.
msg | The text to be pasted |
void PauseStreaming | ( | ) |
Resume the media stream.
void RestartCloudApp | ( | ) |
Restart the cloud application process.
void ResumeStreaming | ( | ) |
Resume the media stream.
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.
width | Width of cloud desktop. |
height | Height of cloud desktop. |
void SetRemoteVideoProfile | ( | int32_t | fps, |
int32_t | minBitrate, | ||
int32_t | maxBitrate, | ||
std::shared_ptr< AsyncCallback > | callback | ||
) |
Set the local video profile.
width | The frame width. Suggested value: 640. |
height | The frame height. Suggested value: 480. |
fps | The frame rate. Suggested value: 30. |
minBitrate | The minimum bitrate in kbps. Suggested value: 512. |
maxBitrate | The maximum bitrate in kbps. Suggested value: 1024. |
isFrontCamera | whether to use the front camera. Suggested value: true. |
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.
video_frame_observer | This observer will callback the decoded frame. |
bool Start | ( | const char * | serverSession | ) |
Starts the session.
This method should only be called once.
serverSession | The ServerSession returned from CreateSession API. Check out the https://cloud.tencent.com/document/api/1162/40740 website for details. |