interface EngineOptions {
serverSignature: string;
createEngine = async (props: EngineOptions) => {
this.engine = VERTC.createEngine(this.config.appId);
joinWithRTS = async () => {
await this.engine.login(this.config.rtmToken, this.config.rtsUid);
await this.engine.setServerParams(this.config.serverSignature, this.config.serverUrl);
joinRoom = (token: string | null, username: string): Promise<void> => {
this.engine.enableAudioPropertiesReport({ interval: 2000 });
return this.engine.joinRoom(
`${this.config.roomId!}`,
userId: this.config.uid!,
extraInfo: JSON.stringify({
user_id: this.config.uid,
isAutoSubscribeAudio: true,
isAutoSubscribeVideo: true,
roomProfileType: RoomProfileType.meeting,
this.engine.leaveRoom();
VERTC.destroyEngine(this.engine);
this._videoCaptureDevice = undefined;
this._audioCaptureDevice = undefined;
this._audioPlaybackDevice = undefined;
this._captureConfig = DefaultCaptureConfig;
this._encoderConfig = DefaultEncoderConfig;
const handleStart = async (formValues: FormProps) => {
await RtcClient.createEngine({
await RtcClient.joinWithRTS();
const joinRes: any = await RtcClient.sendServerMessage('videocallJoinRoom');
await RtcClient.joinRoom(rtc_token, formValues.username);
const mediaDevices = await RtcClient.getDevices();
// 根据设备权限和是否启用,开启/关闭视频采集
if (devicePermissions.video && formValues.publishVideo) {
await RtcClient.startVideoCapture();
RtcClient.setMirrorType(MirrorType.MIRROR_TYPE_RENDER);
if (devicePermissions.audio) {
await RtcClient.startAudioCapture();
if (!formValues.publishAudio) {
RtcClient.unpublishStream(MediaType.AUDIO);