Camera
Enable/Disable Camera
Call the enableCamera
method of RCRTCEngine
to turn the camera on or off. By default, the front camera is enabled. You can specify which camera to enable by passing the second parameter.
For Android embedded devices or when using external cameras, we recommend setting the onEnableCamera
callback to ensure the device is successfully enabled.
-
Sample code:
Set callback
engine.onEnableCamera = (bool enable, int code, String? errMsg) {
if (code != 0) {
// Operation failed
} else {
// Operation succeeded
}
};Enable camera
engine.enableCamera(true);
Enable specified camera
engine.enableCamera(true, RCRTCCamera.back);
Disable camera
engine.enableCamera(false);
Switch Camera
Call the switchCamera
method of RCRTCEngine
to toggle between front and rear cameras. Monitor camera switching success via the onSwitchCamera
callback.
-
Sample code:
Set callback
engine.onSwitchCamera = (RCRTCCamera camera, int code, String? errMsg) {
if (code != 0) {
// Switching failed
} else {
// Switching succeeded
}
};Switch camera
engine.switchCamera();
Configure Video Parameters
Call the setVideoConfig
method of RCRTCEngine
to configure video parameters. The video parameter object is created via RCRTCVideoConfig.create()
.
-
Sample code:
RCRTCVideoConfig config = RCRTCVideoConfig.create(
minBitrate: 500,
maxBitrate: 2200,
fps: RCRTCVideoFps.fps_24,
resolution: RCRTCVideoResolution.resolution_720_1280,
mirror: false,
);
engine.setVideoConfig(config);
Manual Focus
Call the isCameraFocusSupported
method of RCRTCEngine
to check whether the camera supports regional focus.
For supported devices, call setCameraFocusPositionInPreview
to manually set focus. The coordinate origin is the top-left corner of the video area.
-
Sample code:
bool supported = await engine.isCameraFocusSupported();
if (supported) {
engine.setCameraFocusPositionInPreview(100, 100);
}
Regional Exposure
Call the isCameraExposurePositionSupported
method of RCRTCEngine
to check whether the camera supports regional exposure.
For supported devices, call setCameraExposurePositionInPreview
to configure regional exposure. The coordinate origin is the top-left corner of the video area.
-
Sample code:
bool supported = await engine.isCameraExposurePositionSupported();
if (supported) {
engine.setCameraExposurePositionInPreview(100, 100);
}
Capture Orientation
Call the setCameraCaptureOrientation
method of RCRTCEngine
to set the camera capture orientation.
-
Sample code:
engine.setCameraCaptureOrientation(RCRTCCameraCaptureOrientation.landscape_right);