Video Settings

this document primarily introduces how to use RTC Room Engine SDK to implement video setting related features.

Prerequisites

Before using the video setting related features provided by RTC Room Engine SDK, you need to log in to the SDK.

User Guide

Turn On/Off Local Camera

iOS
Android
You can turn on or off your local camera by calling two APIs: openLocalCamera and closeLocalCamera.
The openLocalCamera API requires the input of two parameters: select front or rear camera isFront and video quality quality. isFront is a Boolean value, where true means opening the front camera and false means opening the rear camera. quality is an enumeration of type TUIVideoQuality.
Enumeration Value Type
Meaning
quality360P
Low-definition 360P
quality540P
Standard-definition 540P
quality720P
HD 720P
quality1080P
Ultra HD 1080P
Below is an example code for opening the local microphone and closing the local camera, taking opening the front camera and setting the video quality to quality1080P as an example.
You can turn on or off your local camera by calling two APIs: openLocalCamera and closeLocalCamera.
The openLocalCamera API requires the input of two parameters: select front or rear camera isFront and video quality quality. isFront is a Boolean value, where true means opening the front camera and false means opening the rear camera. quality is an enumeration of type VideoQuality.
Enumeration Value Type
Meaning
Q_360P
Low-definition 360P
Q_540P
Standard-definition 540P
Q_720P
HD 720P
Q_1080P
Ultra HD 1080P
Below is an example code for opening the local microphone and closing the local camera, taking opening the front camera and setting the video quality to Q_1080P as an example.
iOS
Android
import RTCRoomEngine

let roomEngine = TUIRoomEngine.sharedInstance()

// Turn on local camera
let isFrontCamera = true
let videoQuality: TUIVideoQuality = .quality1080P
roomEngine.openLocalCamera(isFront: isFrontCamera, quality: videoQuality) {
// Successful activation
} onError: { code, message in
// Activation fail
}

// Turn off local camera
roomEngine.closeLocalCamera()
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();

// Turn on local camera
boolean isFrontCamera = true;
TUIRoomDefine.VideoQuality videoQuality = TUIRoomDefine.VideoQuality.Q_1080P;
roomEngine.openLocalCamera(isFrontCamera, videoQuality, new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
// Successful activation
}
@Override
public void onError(TUICommonDefine.Error error, String message) {
// Activation fail
}
});

// Turn off local camera
roomEngine.closeLocalCamera();

Set Local Video Image Mirror

The following is an example of turning on local video mirror. You can turn on/off the local video mirror through the following code.
iOS
Android
import RTCRoomEngine
import TXLiteAVSDK_Professional

let trtcCloud = TUIRoomEngine.sharedInstance().getTRTCCloud()

let params = TRTCRenderParams()
params.mirrorType =.enable // To turn off the mirror, just set this parameter to.disable here
trtcCloud.setLocalRenderParams(params)
trtcCloud.setVideoEncoderMirror(true)
TRTCCloud trtcCloud = TUIRoomEngine.sharedInstance().getTRTCCloud();
TRTCCloudDef.TRTCRenderParams params = new TRTCCloudDef.TRTCRenderParams();
params.mirrorType = TRTC_VIDEO_MIRROR_TYPE_ENABLE; // To turn off the mirror, just set this parameter to TRTC_VIDEO_MIRROR_TYPE_DISABLE here
trtcCloud.setLocalRenderParams(params);
trtcCloud.setVideoEncoderMirror(true);

Switch Camera

When calling the switchCamera API to switch the camera, a Bool parameter frontCamera is required. Passing in true switches to the front-facing camera, and passing in false switches to the rear camera. The following is the example code for switching to the front-facing camera:
iOS
Android
import RTCRoomEngine

TUIRoomEngine.sharedInstance().getMediaDeviceManager().switchCamera(true)
TUIRoomEngine.sharedInstance().getMediaDeviceManager().switchCamera(true);

Update Local Video Encoding Quality

iOS
Android
When updating the local video encoding quality, the parameter type TUIVideoQuality required is the same as mentioned above. Below is an example of using the default mode to call the updateVideoQuality API to update the encoding quality of the local video:
import RTCRoomEngine

let videoQuality: TUIVideoQuality = .quality1080P
TUIRoomEngine.sharedInstance().updateVideoQuality(videoQuality)
When updating the local video encoding quality, the parameter type VideoQuality required is the same as mentioned above. Below is an example of using the default mode to call the updateVideoQuality API to update the encoding quality of the local video:
TUIRoomDefine.VideoQuality videoQuality = TUIRoomDefine.VideoQuality.Q_1080P;
TUIRoomEngine.sharedInstance().updateVideoQuality(videoQuality);

Set Encoding Parameters for Video Encoder

iOS
Android
When setting the encoding parameters for the video encoder, the parameter type TUIRoomVideoEncoderParams is required. Below is an example of using the default mode to call the updateVideoQualityEx API to update the encoding quality of the local video:
Introduction to TUIRoomVideoEncoderParams Parameters
Parameter Item
Parameter Name
Resolution
videoResolution
Frame Rate
fps
Resolution Mode
resolutionMode
Maximum Bit Rate
bitrate
import RTCRoomEngine

let roomEngine = TUIRoomEngine.sharedInstance()

let params = TUIRoomVideoEncoderParams()
params.fps = 10 //Here replace it with the value actually required by you
params.resolutionMode =.portrait //Portrait resolution
params.bitrate =.1600 //Here replace it with the value actually required here
params.videoResolution =.quality720P //Here replace it with the value you need

roomEngine.updateVideoQualityEx(streamType: .screenStream, params: params)

When setting the encoding parameters for the video encoder, the parameter type TUIRoomDefine.RoomVideoEncoderParams is required. Below is an example of using the default mode to call the updateVideoQualityEx API to update the encoding quality of the local video:
Introduction to TUIRoomDefine.RoomVideoEncoderParams Parameters
Parameter Item
Parameter Name
Resolution
videoResolution
Frame Rate
fps
Resolution Mode
resolutionMode
Maximum Bit Rate
bitrate
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();

TUIRoomDefine.RoomVideoEncoderParams params = new TUIRoomDefine.RoomVideoEncoderParams();
params.videoResolution = TUIRoomDefine.VideoQuality.Q_720P; //Here replace it with the actual value you need
params.bitrate = 1600; //Here replace it with the actual value you need
params.fps = 10; //Here replace it with the actual value you need
params.resolutionMode = TUIRoomDefine.ResolutionMode.PORTRAIT; //Portrait resolution

roomEngine.updateVideoQualityEx(TUIRoomDefine.RoomVideoEncoderParams params)

Start/Stop Pushing Local Video

When you are in the live streaming room, you may need to start/stop pushing your local video. You can achieve this by calling the following APIs:
iOS
Android
import RTCRoomEngine

let roomEngine = TUIRoomEngine.sharedInstance()

// Start pushing local video (enabled by default)
roomEngine.startPushLocalVideo()

// Stop pushing local video
roomEngine.stopPushLocalVideo()
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();

// Start pushing local video (enabled by default)
roomEngine.startPushLocalVideo();

// Stop pushing local video
roomEngine.stopPushLocalVideo();
Note:
Inside the room, if you have already opened your camera and called the above API to start/stop pushing local video, the SDK will notify users in the room through TUIRoomObserver with the onUserVideoStateChanged callback.