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
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.import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()// Turn on local cameralet isFrontCamera = truelet videoQuality: TUIVideoQuality = .quality1080ProomEngine.openLocalCamera(isFront: isFrontCamera, quality: videoQuality) {// Successful activation} onError: { code, message in// Activation fail}// Turn off local cameraroomEngine.closeLocalCamera
()
TUIRoomEngine roomEngine = TUIRoomEngine.sharedInstance();// Turn on local cameraboolean isFrontCamera = true;TUIRoomDefine.VideoQuality videoQuality = TUIRoomDefine.VideoQuality.Q_1080P;roomEngine.openLocalCamera(isFrontCamera, videoQuality, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {// Successful activation}@Overridepublic void onError(TUICommonDefine.Error error, String message) {// Activation fail}});// Turn off local cameraroomEngine.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.
import RTCRoomEngineimport TXLiteAVSDK_Professionallet trtcCloud = TUIRoomEngine.sharedInstance().getTRTCCloud()let params = TRTCRenderParams()params.mirrorType =.enable // To turn off the mirror, just set this parameter to.disable heretrtcCloud.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 heretrtcCloud.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:import RTCRoomEngineTUIRoomEngine.sharedInstance().getMediaDeviceManager().switchCamera(true)
TUIRoomEngine.sharedInstance().getMediaDeviceManager().switchCamera(true);
Update Local Video Encoding Quality
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 RTCRoomEnginelet videoQuality: TUIVideoQuality = .quality1080PTUIRoomEngine.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
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
ParametersParameter Item | Parameter Name |
Resolution | videoResolution |
Frame Rate | fps |
Resolution Mode | resolutionMode |
Maximum Bit Rate | bitrate |
import RTCRoomEnginelet roomEngine = TUIRoomEngine.sharedInstance()let params = TUIRoomVideoEncoderParams()params.fps = 10 //Here replace it with the value actually required by youparams.resolutionMode =.portrait //Portrait resolutionparams.bitrate =.1600 //Here replace it with the value actually required hereparams.videoResolution =.quality720P //Here replace it with the value you needroomEngine.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
ParametersParameter 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 needparams.bitrate = 1600; //Here replace it with the actual value you needparams.fps = 10; //Here replace it with the actual value you needparams.resolutionMode = TUIRoomDefine.ResolutionMode.PORTRAIT; //Portrait resolutionroomEngine.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:
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:
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.