Video Settings

This document mainly introduces how to use the RTC Room Engine SDK to implement video settings features.

Prerequisites

Before using the video settings features provided by the RTC Room Engine SDK, you need to complete the SDK login.

User Guide

Turning On/Off the Local Camera

iOS
Android
You can turn on or off your local camera by calling the openLocalCamera and closeLocalCamera APIs respectively.
The openLocalCamera API requires two parameters: isFront to select the front or rear camera, and quality for video quality. isFront is a boolean value, where true opens the front camera and false opens the rear camera. quality is an enumeration of type TUIVideoQuality.
Enumeration value types
Meaning
quality360P
360p: SD
quality540P
540p: SD
quality720P
720p: HD
quality1080P
1080p: FHD
Below is an example of turning on the front camera with video quality set to quality1080P, providing sample code for turning on the local microphone and turning off the local camera.
You can turn on or off your local camera by calling the openLocalCamera and closeLocalCamera APIs respectively.
The openLocalCamera API requires two parameters: select front or rear camera isFront and video quality quality. isFront is a boolean value, true for turning on the front-facing camera, false for turning on the rear camera. quality is an enumeration of type VideoQuality.
Enumeration value types
Meaning
Q_360P
360p: SD
Q_540P
540p: SD
Q_720P
720p: HD
Q_1080P
1080p: FHD
Below is an example of turning on the front camera with video quality set to Q_1080P, providing sample code for turning on the local microphone and turning off the local camera.
iOS
Android
import RTCRoomEngine

let roomEngine = TUIRoomEngine.sharedInstance()

// Turn on the local camera
let isFrontCamera = true
let videoQuality: TUIVideoQuality = .quality1080P
roomEngine.openLocalCamera(isFront: isFrontCamera, quality: videoQuality) {
// Turned on successfully
} onError: { code, message in
// Failed to enable
}

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

// Turn on the local camera
boolean isFrontCamera = true;
TUIRoomDefine.VideoQuality videoQuality = TUIRoomDefine.VideoQuality.Q_1080P;
roomEngine.openLocalCamera(isFrontCamera, videoQuality, new TUIRoomDefine.ActionCallback() {
@Override
public void onSuccess() {
// Enabled successfully
}
@Override
public void onError(TUICommonDefine.Error error, String message) {
// Failed to enable
}
});

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

Setting the Mirror Mode for Local Video

Here is an example of setting the mirror mode for local video. You can use the following code to turn on/off the mirror mode for local video.
iOS
Android
import RTCRoomEngine
import TXLiteAVSDK_Professional

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

let params = TRTCRenderParams()
params.mirrorType = .enable // To disable the mirror, set this parameter to .disable
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 disable the mirror, set this parameter to TRTC_VIDEO_MIRROR_TYPE_DISABLE
trtcCloud.setLocalRenderParams(params);
trtcCloud.setVideoEncoderMirror(true);

Switch camera

When calling the switchCamera API to switch the camera, you need to pass a Bool parameter frontCamera. Passing true switches to the front camera, and passing false switches to the rear camera. Here is an example code to switch to the front camera:
iOS
Android
import RTCRoomEngine

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

Updating the Local Video Encoding Quality

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

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

Starting/Stopping Local Video Push

When you are in a live 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:
In the room, if you have turned on your camera, after calling the above APIs to start/stop pushing local video, the SDK will notify the users in the room through the TUIRoomObserver callback onUserVideoStateChanged.