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
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.import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()// Turn on the local cameralet isFrontCamera = truelet videoQuality: TUIVideoQuality = .quality1080ProomEngine.openLocalCamera(isFront: isFrontCamera, quality: videoQuality) {// Turned on successfully} onError: { code, message in// Failed to enable}// Turn off the local cameraroomEngine.closeLocalCamera
()
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();// Turn on the local cameraboolean isFrontCamera = true;TUIRoomDefine.VideoQuality videoQuality = TUIRoomDefine.VideoQuality.Q_1080P;roomEngine.openLocalCamera(isFrontCamera, videoQuality, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Enabled successfully}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Failed to enable}});// Turn off the local cameraroomEngine.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.
import RTCRoomEngineimport TXLiteAVSDK_Professionallet trtcCloud = TUIRoomEngine.sharedInstance().getTRTCCloud()let params = TRTCRenderParams()params.mirrorType = .enable // To disable the mirror, set this parameter to .disabletrtcCloud.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_DISABLEtrtcCloud.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:import RTCRoomEngineTUIRoomEngine.sharedInstance().getMediaDeviceManager().switchCamera(true)
TUIRoomEngine.sharedInstance().getMediaDeviceManager().switchCamera(true);
Updating the Local Video Encoding Quality
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 RTCRoomEnginelet videoQuality: TUIVideoQuality = .quality1080PTUIRoomEngine.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:
import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()// Start pushing local video (enabled by default)roomEngine.startPushLocalVideo()// Stop pushing local videoroomEngine.stopPushLocalVideo()
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();// Start pushing local video (enabled by default)roomEngine.startPushLocalVideo();// Stop pushing local videoroomEngine.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.