TcrSession Class Reference

Inherits from NSObject
Declared in TcrSession.h
TcrSession.m

– initWithParams:andDelegate:

Initialize local resources, asynchronously callback results

- (instancetype)initWithParams:(NSDictionary *)params andDelegate:(id<TcrSessionObserver>)Observer

Parameters

params

Optional, the following key-value pairs can be selected: - @“preferredCodec”: Optional values are @“H264”, @“H265”, @“VP8”, and @“VP9”. Used to set the preferred codec. If this field is set, the session will try to use the preferred codec for communication. If the preferred codec is not available, other available codecs will be used. If this field is not set or the setting is invalid, the session will use the default codec.

  • @“preferredCodecList”: The value is an NSArray, which contains the optional values @“H264”, @“H265”, @“VP8”, and @“VP9”. Indicate preferred codecs, where the order of the elements in the list represents priority, such as index 0 being the highest priority preferred codec. If the set codecs cannot be selected for various reasons, other available codecs will be chosen.

  • @“local_video”: Optional value is of bool type. Used to enable the local camera.

  • @“local_audio”: Optional value is of bool type. Used to enable the local microphone.

  • @“enableCustomAudioCapture”:@{@“sampleRate”:NSInteger, @“useStereoInput”: BOOL}, enable custom audio capture and bring the sample rate and channel count of the custom captured audio (both parameters are required). e.g. @“enableCustomAudioCapture”:@{@“sampleRate”:@(48000), @“useStereoInput”:@(false)} means a sample rate of 48000 and mono data. In addition, to enable custom audio capture, you also need to set @“local_audio” to enable local audio upstream.

  • @“remoteDesktopResolution”:@{@“width”:NSInteger , @“height”:NSInteger} ,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. NOTEļ¼šThis param is only for PC application, and the mobile application is not supported.

Observer

The delegate of the TcrSession, listening for callback of events.

Discussion

Initialize local resources, asynchronously callback results

Declared In

TcrSession.h

– setTcrSessionObserver:

setOberServer for session

- (void)setTcrSessionObserver:(id<TcrSessionObserver>)Observer

Parameters

Observer

session Observer

Discussion

setOberServer for session

Declared In

TcrSession.h

– start:

Starts the session. This method should only be called once.

- (BOOL)start:(NSString *_Nonnull)serverSession

Parameters

serverSession

The ServerSessionreturned from CreateSessionAPI.

Return Value

true if success, false otherwise.

Discussion

Starts the session. This method should only be called once.

Declared In

TcrSession.h

– getRequestId

Get the current connection’s requestId.

- (NSString *_Nonnull)getRequestId

Discussion

Get the current connection’s requestId.

It takes effect after calling TcrSession.start().

Declared In

TcrSession.h

– createCustomDataChannel:observer:

Creates a custom data channel.

- (CustomDataChannel *_Nonnull)createCustomDataChannel:(int)port observer:(id<CustomDataChannelObserver> _Nullable)observer

Parameters

port

The cloud port number uniquely identifying the data channel.

observer

The CustomDataChannel.CustomDataChannelObserver object .

Return Value

the created data channel.

Discussion

Creates a custom data channel.

Declared In

TcrSession.h

– getKeyboard

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

- (id<Keyboard> _Nonnull)getKeyboard

Return Value

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

Discussion

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

Declared In

TcrSession.h

– getMouse

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

- (id<Mouse> _Nonnull)getMouse

Return Value

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

Discussion

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

Declared In

TcrSession.h

– getGamepad

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

- (id<Gamepad> _Nonnull)getGamepad

Return Value

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

Discussion

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

Declared In

TcrSession.h

– getTouchScreen

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

- (id<TouchScreen> _Nonnull)getTouchScreen

Return Value

The interface to interact with the cloud TouchScreen in this session.

Discussion

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

Declared In

TcrSession.h

– sendKeycodeMessage:

send keycode message to cloud

- (void)sendKeycodeMessage:(NSDictionary *_Nonnull)msg

Discussion

send keycode message to cloud

Declared In

TcrSession.h

– pasteText:

Send 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.

- (void)pasteText:(NSString *_Nonnull)text

Parameters

text

The text to be sent

Discussion

Send 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.

For Android cloud applications, sent text replaces the input box content.
For Windows cloud applications, sent text is added to the existing content in the input box.

Declared In

TcrSession.h

– pauseStreaming

Pause the media stream.

- (void)pauseStreaming

Discussion

Pause the media stream.

Declared In

TcrSession.h

– resumeStreaming

Resume the media stream.

- (void)resumeStreaming

Discussion

Resume the media stream.

Declared In

TcrSession.h

– releaseSession

Release the session.
The session will disconnect from the sever, and the local resources of this session will be released. Once released, this session instance cannot be used anymore.

- (void)releaseSession

Discussion

Release the session.
The session will disconnect from the sever, and the local resources of this session will be released. Once released, this session instance cannot be used anymore.

Declared In

TcrSession.h

– setEnableAudioPlaying:

Set whether the SDK plays audio.

- (void)setEnableAudioPlaying:(BOOL)enable

Parameters

enable

true to enable audio playback, false otherwise.

Discussion

Set whether the SDK plays audio.

Declared In

TcrSession.h

– setEnableLocalAudio:

Enable or disable the local audio track that is captured from the mic.

- (void)setEnableLocalAudio:(BOOL)enable

Parameters

enable

true to enable the local audio, false otherwise.

Discussion

Enable or disable the local audio track that is captured from the mic.

Declared In

TcrSession.h

– setEnableLocalVideo:

Enable or disable the local video track that is captured from the camera.

- (void)setEnableLocalVideo:(BOOL)enable

Parameters

enable

true to enable the local video, false otherwise.

Discussion

Enable or disable the local video track that is captured from the camera.

Declared In

TcrSession.h

– setLocalVideoProfile:height:fps:minBitrate:maxBitrate:isFrontCamera:

Set the local video profile.

- (void)setLocalVideoProfile:(int)width height:(int)height fps:(int)fps minBitrate:(int)minBitrate maxBitrate:(int)maxBitrate isFrontCamera:(BOOL)isFrontCamera

Parameters

width

The frame width, range[128, 1920]. Suggested value: 1280.

height

The frame height, range[128, 1920]. Suggested value: 720.

fps

The frame rate must be greater than 0 Default value: 30.

minBitrate

The minimum bitrate in Kbps. Value range: [1000,15000]. Default value: 1000.

maxBitrate

The maximum bitrate in Kbps. Value range: [1000,15000]. Default value: 15000.

Discussion

Set the local video profile.

Declared In

TcrSession.h

– setDisableCloudInput:

Disable the Cloud input.
When the cloud input is disable, the cloud application’s soft keyboard won’t appear.

This function is only supported for mobile cloud applications.

- (void)setDisableCloudInput:(BOOL)disableCloudInput

Parameters

disableCloudInput

true disables the cloud input.
false enables the cloud input, allowing the soft keyboard to appear for user interaction with the cloud application via touch screen.

Discussion

Disable the Cloud input.
When the cloud input is disable, the cloud application’s soft keyboard won’t appear.

This function is only supported for mobile cloud applications.

Declared In

TcrSession.h

– setAudioSink:

Sets a audio sink for this session. After that, the SDK will callback the audio data to the audioSink

- (void)setAudioSink:(id<AudioSink> _Nullable)audioSink

Parameters

audioSink

The audio sink to be set.

Discussion

Sets a audio sink for this session. After that, the SDK will callback the audio data to the audioSink

Declared In

TcrSession.h

– restartCloudApp

Restart the cloud application process.

- (void)restartCloudApp

Discussion

Restart the cloud application process.

Declared In

TcrSession.h

– setRemoteAudioProfile:

Set the playing profile of the remote audio.

- (void)setRemoteAudioProfile:(float)volume

Parameters

volume

The volume scalar in the range of [0,10] that will be set on this remote audio stream.

Discussion

Set the playing profile of the remote audio.

Declared In

TcrSession.h

– setRemoteDesktopResolution: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.

- (void)setRemoteDesktopResolution:(int)width height:(int)height

Parameters

width

Width of cloud desktop.

height

Height of cloud desktop.

Discussion

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.

Declared In

TcrSession.h

– setRemoteVideoProfile:minBitrate:maxBitrate:

Set the remote video profile.

- (void)setRemoteVideoProfile:(int)fps minBitrate:(int)minBitrate maxBitrate:(int)maxBitrate

Parameters

fps

The frame rate. Value range: [10,60]. Default value: 60.

minBitrate

The minimum bitrate in Kbps. Value range: [1000,15000]. Default value: 1000.

maxBitrate

The maximum bitrate in Kbps. Value range: [1000,15000]. Default value: 15000.

Discussion

Set the remote video profile.

Declared In

TcrSession.h

– sendCustomAudioData:captureTimeNs:

Send custom audio data.
This method is only effective when custom audio capture is enabled.
To enable custom audio capture, see initWithParams

- (BOOL)sendCustomAudioData:(NSData *_Nonnull)audioData captureTimeNs:(uint64_t)captureTimeNs

Parameters

audioData

The non-null NSData object containing the PCM data(16-bit) to be sent.

captureTimeNs

The capture time of the audio data in nanoseconds.

Return Value

The result of send custom audio data.

Discussion

Send custom audio data.
This method is only effective when custom audio capture is enabled.
To enable custom audio capture, see initWithParams

Declared In

TcrSession.h

– setRenderView:

Set the rendering view for this session, and thus the SDK will render the streaming content to the view.

- (void)setRenderView:(TcrRenderView *_Nullable)renderView

Parameters

renderView

The rendering view to be set. This can be null to remove any existing renderView.

Discussion

Set the rendering view for this session, and thus the SDK will render the streaming content to the view.

Declared In

TcrSession.h

– setVideoSink:

Sets a video sink for this session. After that, the SDK will callback the decoded video frame data to the videoSink.

- (void)setVideoSink:(id<VideoSink> _Nullable)videoSink

Parameters

videoSink

The view sink to be set.This can be null to remove any existing one.

Discussion

Sets a video sink for this session. After that, the SDK will callback the decoded video frame data to the videoSink.

You may use this interface to post-process or render video images.

Declared In

TcrSession.h

– syncRoomInfo

Apply to synchronize room information and return the result through TcrEvent#MULTI_USER_SEAT_INFO

- (void)syncRoomInfo

Discussion

Apply to synchronize room information and return the result through TcrEvent#MULTI_USER_SEAT_INFO

Declared In

TcrSession.h

– requestChangeSeat:targetRole:targetPlayerIndex:blk:

Apply to the room owner to switch the role and seat of a player (userID) to targetRole and targetPlayerIndex respectively.

- (void)requestChangeSeat:(NSString *_Nonnull)userId targetRole:(NSString *_Nonnull)targetRole targetPlayerIndex:(int)targetPlayerIndex blk:(void ( ^ ) ( int retCode ))finishBlk

Parameters

userId

The target user ID

targetRole

The target role,. valid value: ( ‘player’ / ‘viewer’ )

targetPlayerIndex

The target seat. This parameter can take effect only for the Player role and will be 0 for the Viewer role.

finishBlk

Execution result callback. retcode: TcrCode#ErrMultiPlayerBaseCode

Discussion

Apply to the room owner to switch the role and seat of a player (userID) to targetRole and targetPlayerIndex respectively.

Declared In

TcrSession.h

– setMicMute:micStatus:blk:

Apply to the room owner to switch the role and seat of a player (userID) to targetRole and targetPlayerIndex respectively.

- (void)setMicMute:(NSString *)userId micStatus:(int)micStatus blk:(void ( ^ ) ( int retCode ))finishBlk

Parameters

userId

The target user ID

micStatus

The mic Status set.

finishBlk

Execution result callback. retcode: TcrCode#ErrMultiPlayerBaseCode

Discussion

Apply to the room owner to switch the role and seat of a player (userID) to targetRole and targetPlayerIndex respectively.

Declared In

TcrSession.h

– changeSeat:targetRole:targetPlayerIndex:blk:

Switch the role and seat of a user (userID) to targetRole and targetPlayerIndex respectively.

- (void)changeSeat:(NSString *_Nonnull)userId targetRole:(NSString *_Nonnull)targetRole targetPlayerIndex:(int)targetPlayerIndex blk:(void ( ^ ) ( int retCode ))finishBlk

Parameters

userId

The target user ID

targetRole

The target role,. valid value: ( ‘player’ / ‘viewer’ )

targetPlayerIndex

The target seat. This parameter can take effect only for the Player role and will be 0 for the Viewer role.

finishBlk

Execution result callback. retcode: TcrCode#ErrMultiPlayerBaseCode

Discussion

Switch the role and seat of a user (userID) to targetRole and targetPlayerIndex respectively.

Declared In

TcrSession.h

+ setAudioSessionDelegate:

Set audiosession proxy

+ (void)setAudioSessionDelegate:(id<TCRAudioSessionDelegate>)delegate

Parameters

delegate

The delegate to set

Discussion

Set audiosession proxy

Declared In

TcrSession.h