trtc-sdk-v5 5.4.2-beta.2 → 5.4.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -858,4 +858,875 @@
858
858
  track: MediaStreamTrack;
859
859
  }];
860
860
  }
861
+ class TRTC extends EventEmitter<TRTCEventTypes> {
862
+ /**
863
+ * Create a TRTC object for implementing functions such as entering a room, previewing, publishing, and subscribing streams.<br>
864
+ *
865
+ * **Note:**
866
+ * - You must create a TRTC object first and call its methods and listen to its events to implement various functions required by the business.
867
+ * @example
868
+ * // Create a TRTC object
869
+ * const trtc = TRTC.create();
870
+ *
871
+ * @returns {TRTC} TRTC object
872
+ */
873
+ static create(options?: TRTCOptions): TRTC;
874
+ /**
875
+ * @typedef TurnServer
876
+ * @property {string} url TURN server url
877
+ * @property {string=} username TURN server auth user name
878
+ * @property {string=} credential TURN server password
879
+ * @property {string=} [credentialType=password] TURN server verify password type
880
+ */
881
+ /**
882
+ * @typedef ProxyServer
883
+ * @property {string} [websocketProxy] websocket service proxy
884
+ * @property {string} [loggerProxy] log service agent
885
+ * @property {TurnServer[]} [turnServer] media data transmission agent
886
+ * @property {'all'|'relay'} [iceTransportPolicy='all'] 'all' gives priority to directly connecting to TRTC, and tries to go to the turn server if the connection fails.<br>
887
+ * 'relay' forces the connection through the TURN server.
888
+ */
889
+ /**
890
+ * Enter a video call room.<br>
891
+ * - Entering a room means starting a video call session. Only after entering the room successfully can you make audio and video calls with other users in the room.
892
+ * - You can publish local audio and video streams through {@link TRTC#startLocalVideo startLocalVideo()} and {@link TRTC#startLocalAudio startLocalAudio()} respectively. After successful publishing, other users in the room will receive the {@link module:EVENT.REMOTE_AUDIO_AVAILABLE REMOTE_AUDIO_AVAILABLE} and {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} event notifications.
893
+ * - By default, the SDK automatically plays remote audio. You need to call {@link TRTC#startRemoteVideo startRemoteVideo()} to play remote video.
894
+ *
895
+ * @param {object} options Enter room parameters
896
+ * @param {number} options.sdkAppId sdkAppId <br>
897
+ * You can obtain the sdkAppId information in the **Application Information** section after creating a new application by clicking **Application Management** > **Create Application** in the [TRTC Console](https://console.intl.cloud.tencent.com/trtc).
898
+ * @param {string} options.userId User ID <br>
899
+ * It is recommended to limit the length to 32 bytes, and only allow uppercase and lowercase English letters (a-zA-Z), numbers (0-9), underscores, and hyphens.
900
+ * @param {string} options.userSig UserSig signature <br>
901
+ * Please refer to [UserSig related](https://www.tencentcloud.com/document/product/647/35166) for the calculation method of userSig.
902
+ * @param {number=} options.roomId
903
+ * the value must be an integer between 1 and 4294967294<br>
904
+ * <font color="red">If you need to use a string type room id, please use the strRoomId parameter. One of roomId and strRoomId must be passed in. If both are passed in, the roomId will be selected first.</font>
905
+ * @param {string=} options.strRoomId
906
+ * String type room id, the length is limited to 64 bytes, and only supports the following characters:
907
+ * - Uppercase and lowercase English letters (a-zA-Z)
908
+ * - Numbers (0-9)
909
+ * - Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ ,
910
+ * <font color="red">Note: It is recommended to use a numeric type roomId. The string type room id "123" is not the same room as the numeric type room id 123.</font>
911
+ * @param {string} [options.scene] Application scene, currently supports the following two scenes:
912
+ * - {@link module:TYPE.SCENE_RTC TRTC.TYPE.SCENE_RTC} (default) Real-time call scene, which is suitable for 1-to-1 audio and video calls, or online meetings with up to 300 participants. {@tutorial 04-info-uplink-limits}.
913
+ * - {@link module:TYPE.SCENE_LIVE TRTC.TYPE.SCENE_LIVE} Interactive live streaming scene, which is suitable for online live streaming scenes with up to 100,000 people, but you need to specify the role field in the options parameter introduced next.
914
+ * @param {string=} [options.role] User role, only meaningful in the {@link module:TYPE.SCENE_LIVE TRTC.TYPE.SCENE_LIVE} scene, and the {@link module:TYPE.SCENE_RTC TRTC.TYPE.SCENE_RTC} scene does not need to specify the role. Currently supports two roles:
915
+ * - {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} (default) Anchor
916
+ * - {@link module:TYPE.ROLE_AUDIENCE TRTC.TYPE.ROLE_AUDIENCE} Audience
917
+ * Note: The audience role does not have the permission to publish local audio and video, only the permission to watch remote streams. If the audience wants to interact with the anchor by connecting to the microphone, please switch the role to the anchor through {@link TRTC#switchRole switchRole()} before publishing local audio and video.
918
+ * @param {boolean} [options.autoReceiveAudio=true] Whether to automatically receive audio. When a remote user publishes audio, the SDK automatically plays the remote user's audio.
919
+ * @param {boolean} [options.autoReceiveVideo=true] Whether to automatically receive video. When a remote user publishes video, the SDK automatically subscribes and decodes the remote video. You need to call {@link TRTC#startLocalVideo startLocalVideo} to play the remote video.
920
+ * @param {boolean} [options.enableAutoPlayDialog] Whether to enable the SDK's automatic playback failure dialog box, default: true.
921
+ * - Enabled by default. When automatic playback fails, the SDK will pop up a dialog box to guide the user to click the page to restore audio and video playback.
922
+ * - Can be set to false in order to turn off. Refer to {@tutorial 21-advanced-auto-play-policy}.
923
+ * @param {string|ProxyServer} [options.proxy] proxy config. Refer to {@tutorial 34-advanced-proxy}.
924
+ * @param {boolean} [options.privateMapKey] Key for entering a room. If permission control is required, please carry this parameter (empty or incorrect value will cause a failure in entering the room).<br>[privateMapKey permission configuration](https://www.tencentcloud.com/document/product/647/35157?lang=en&pg=).
925
+ * @throws
926
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
927
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
928
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
929
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
930
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
931
+ * @example
932
+ * const trtc = TRTC.create();
933
+ * await trtc.enterRoom({ roomId: 8888, sdkAppId, userId, userSig });
934
+ */
935
+ enterRoom(params: EnterRoomConfig): Promise<void>;
936
+ /**
937
+ * Exit the current audio and video call room.
938
+ * - After exiting the room, the connection with remote users will be closed, and remote audio and video will no longer be received and played, and the publishing of local audio and video will be stopped.
939
+ * - The capture and preview of the local camera and microphone will not stop. You can call {@link TRTC#stopLocalVideo stopLocalVideo()} and {@link TRTC#stopLocalAudio stopLocalAudio()} to stop capturing local microphone and camera.
940
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
941
+ * @memberof TRTC
942
+ * @example
943
+ * await trtc.exitRoom();
944
+ */
945
+ exitRoom(): Promise<void>;
946
+ /**
947
+ * Switches the user role, only effective in TRTC.TYPE.SCENE_LIVE interactive live streaming mode.
948
+ *
949
+ * In interactive live streaming mode, a user may need to switch between "audience" and "anchor".
950
+ * You can determine the role through the role field in {@link TRTC#enterRoom enterRoom()}, or switch roles after entering the room through switchRole.
951
+ * - Audience switches to anchor, call trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR) to convert the user role to TRTC.TYPE.ROLE_ANCHOR anchor role, and then call {@link TRTC#startLocalVideo startLocalVideo()} and {@link TRTC#startLocalAudio startLocalAudio()} to publish local audio and video as needed.
952
+ * - Anchor switches to audience, call trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE) to convert the user role to TRTC.TYPE.ROLE_AUDIENCE audience role. If there is already published local audio and video, the SDK will cancel the publishing of local audio and video.
953
+ * > !
954
+ * > - This interface can only be called after entering the room successfully.
955
+ * > - After closing the camera and microphone, it is recommended to switch to the audience role in time to avoid the anchor role occupying the resources of 50 upstreams.
956
+ * @param {string} role User role
957
+ * - TRTC.TYPE.ROLE_ANCHOR anchor, can publish local audio and video, up to 50 anchors can publish local audio and video in a single room at the same time.
958
+ * - TRTC.TYPE.ROLE_AUDIENCE audience, cannot publish local audio and video, can only watch remote streams, and there is no upper limit on the number of audience members in a single room.
959
+ * @param {object} [option]
960
+ * @param {string} [option.privateMapKey] `Since v5.3.0+` <br>
961
+ * The privateMapKey may expire after a timeout, so you can use this parameter to update the privateMapKey.
962
+ * @throws
963
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
964
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
965
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
966
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
967
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
968
+ * @memberof TRTC
969
+ * @example
970
+ * // After entering the room successfully
971
+ * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, audience switches to anchor
972
+ * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR);
973
+ * // Switch from audience role to anchor role and start streaming
974
+ * await trtc.startLocalVideo();
975
+ *
976
+ * // TRTC.TYPE.SCENE_LIVE interactive live streaming mode, anchor switches to audience
977
+ * await trtc.switchRole(TRTC.TYPE.ROLE_AUDIENCE);
978
+ * @example
979
+ * // Since v5.3.0+
980
+ * await trtc.switchRole(TRTC.TYPE.ROLE_ANCHOR, { privateMapKey: 'your new privateMapKey' });
981
+ */
982
+ switchRole(role: UserRole, option?: {
983
+ privateMapKey: string;
984
+ }): Promise<void>;
985
+ /**
986
+ * Destroy the TRTC instance <br/>
987
+ *
988
+ * After exiting the room, if the business side no longer needs to use trtc, you need to call this interface to destroy the trtc instance in time and release related resources.
989
+ *
990
+ * Note:
991
+ * - The trtc instance after destruction cannot be used again.
992
+ * - If you have entered the room, you need to call the {@link TRTC#exitRoom TRTC.exitRoom} interface to exit the room successfully before calling this interface to destroy trtc.
993
+ *
994
+ * @example
995
+ * // When the call is over
996
+ * await trtc.exitRoom();
997
+ * // If the trtc is no longer needed, destroy the trtc and release the reference.
998
+ * trtc.destroy();
999
+ * trtc = null;
1000
+ * @throws {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1001
+ * @memberof TRTC
1002
+ */
1003
+ destroy(): void;
1004
+ /**
1005
+ * Start collecting audio from the local microphone and publish it to the current room.
1006
+ * - When to call: can be called before or after entering the room, cannot be called repeatedly.
1007
+ * - Only one microphone can be opened for a trtc instance. If you need to open another microphone for testing in the case of already opening one microphone, you can create multiple trtc instances to achieve it.
1008
+ *
1009
+ * @param {object} [config] - Configuration item
1010
+ * @param {boolean} [config.publish] - Whether to publish local audio to the room, default is true. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1011
+ * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1012
+ * @param {object} [config.option] - Local audio options
1013
+ * @param {string} [config.option.microphoneId]- Specify which microphone to use
1014
+ * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1015
+ * @param {number} [config.option.captureVolume] - Set the capture volume of microphone. The default value is 100. Setting above 100 enlarges the capture volume. Since v5.2.1+.
1016
+ * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1017
+ * @param {string} [config.option.profile] - Audio encoding configuration, default {@link module:TYPE.AUDIO_PROFILE_STANDARD TRTC.TYPE.AUDIO_PROFILE_STANDARD}
1018
+ * @throws
1019
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1020
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1021
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1022
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1023
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1024
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1025
+ * @example
1026
+ * // Collect the default microphone and publish
1027
+ * await trtc.startLocalAudio();
1028
+ * @example
1029
+ * // The following is a code example for testing microphone volume, which can be used for microphone volume detection.
1030
+ * trtc.enableAudioVolumeEvaluation();
1031
+ * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => { });
1032
+ * // No need to publish audio for testing microphone
1033
+ * await trtc.startLocalAudio({ publish: false });
1034
+ * // After the test is completed, turn off the microphone
1035
+ * await trtc.stopLocalAudio();
1036
+ * @memberof TRTC
1037
+ */
1038
+ startLocalAudio(config?: LocalAudioConfig): Promise<void>;
1039
+ /**
1040
+ * Update the configuration of the local microphone.
1041
+ * - When to call: This interface needs to be called after {@link TRTC#startLocalAudio startLocalAudio()} is successful and can be called multiple times.
1042
+ * - This method uses incremental update: only update the passed parameters, and keep the parameters that are not passed unchanged.
1043
+ * @param {object} [config]
1044
+ * @param {boolean} [config.publish] - Whether to publish local audio to the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1045
+ * @param {boolean} [config.mute] - Whether to mute microphone. Refer to: {@tutorial 15-basic-dynamic-add-video}.
1046
+ * @param {object} [config.option] - Local audio configuration
1047
+ * @param {string} [config.option.microphoneId] - Specify which microphone to use to switch microphones.
1048
+ * @param {MediaStreamTrack} [config.option.audioTrack] - Custom audioTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1049
+ * @param {number} [config.option.captureVolume] - Set the capture volume of microphone. The default value is 100. Setting above 100 enlarges the capture volume. Since v5.2.1+.
1050
+ * @param {number} [config.option.earMonitorVolume] - Set the ear return volume, value range [0, 100], the local microphone is muted by default.
1051
+ * @throws
1052
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1053
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1054
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1055
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1056
+ * @example
1057
+ * // Switch microphone
1058
+ * const microphoneList = await TRTC.getMicrophoneList();
1059
+ * if (microphoneList[1]) {
1060
+ * await trtc.updateLocalAudio({ option: { microphoneId: microphoneList[1].deviceId }});
1061
+ * }
1062
+ * @memberof TRTC
1063
+ */
1064
+ updateLocalAudio(config: UpdateLocalAudioConfig): Promise<void>;
1065
+ /**
1066
+ * Stop collecting and publishing the local microphone.
1067
+ * - If you just want to mute the microphone, please use updateLocalAudio({ mute: true }). Refer to: {@tutorial 15-basic-dynamic-add-video}.
1068
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1069
+ * @example
1070
+ * await trtc.stopLocalAudio();
1071
+ */
1072
+ stopLocalAudio(): Promise<void>;
1073
+ /**
1074
+ * @typedef {object|string} VideoProfile - Configuration for local video stream
1075
+ *
1076
+ * Video configuration parameters, can use preset values in string format or custom resolution and other parameters
1077
+ * | Video Profile | Resolution (Width x Height) | Frame Rate (fps) | Bitrate (kbps) | Remarks |
1078
+ * | :--- | :--- | :--- | :--- | :--- |
1079
+ * | 120p | 160 x 120 | 15 | 200 ||
1080
+ * | 180p | 320 x 180 | 15 | 350 ||
1081
+ * | 240p | 320 x 240 | 15 | 400 ||
1082
+ * | 360p | 640 x 360 | 15 | 800 ||
1083
+ * | 480p | 640 x 480 | 15 | 900 ||
1084
+ * | 720p | 1280 x 720 | 15 | 1500 ||
1085
+ * | 1080p | 1920 x 1080 | 15 | 2000 ||
1086
+ * | 1440p | 2560 x 1440 | 30 | 4860 ||
1087
+ * | 4K | 3840 x 2160 | 30 | 9000 ||
1088
+ * @property {number} width - Video width
1089
+ * @property {number} height - Video height
1090
+ * @property {number} frameRate - Video frame rate
1091
+ * @property {number} bitrate - Video bitrate
1092
+ * @example
1093
+ * const config = {
1094
+ * option: {
1095
+ * profile: '480p',
1096
+ * },
1097
+ * }
1098
+ * await trtc.startLocalVideo(config);
1099
+ * @example
1100
+ * const config = {
1101
+ * option: {
1102
+ * profile: {
1103
+ * width: 640,
1104
+ * height: 480,
1105
+ * frameRate: 15,
1106
+ * bitrate: 900,
1107
+ * }
1108
+ * }
1109
+ * }
1110
+ * await trtc.startLocalVideo(config);
1111
+ */
1112
+ /**
1113
+ * Start collecting video from the local camera, play the camera's video on the specified HTMLElement tag, and publish the camera's video to the current room.
1114
+ * - When to call: can be called before or after entering the room, but cannot be called repeatedly.
1115
+ * - Only one camera can be started per trtc instance. If you need to start another camera for testing while one camera is already started, you can create multiple trtc instances to achieve this.
1116
+
1117
+ * @param {object} [config]
1118
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or ID for local video preview. If not passed or passed as null, the video will not be played.
1119
+ * @param {boolean} [config.publish] - Whether to publish the local video to the room. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1120
+ * @param {boolean | string} [config.mute] - Whether to mute camera. Supports passing in image url string, the image will be published instead of origin camera stream, Other users in the room will receive the REMOTE_AUDIO_AVAILABLE event. It does not support calling when the camera is turned off. More information: {@tutorial 15-basic-dynamic-add-video}.
1121
+ * @param {object} [config.option] - Local video configuration
1122
+ * @param {string} [config.option.cameraId] - Specify which camera to use for switching cameras.
1123
+ * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera.
1124
+ * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1125
+ * @param {'view' | 'publish' | 'both' | boolean} [config.option.mirror] - Video mirroring mode, default is 'view'.
1126
+ * - 'view': Local preview mirroring
1127
+ * - 'publish': Remote viewing of self mirroring
1128
+ * - 'both': Both local preview and remote viewing of self mirroring
1129
+ * - false: Boolean value, represents no mirroring
1130
+ *
1131
+ * <font color="orange"> Note: Before version 5.3.2, only boolean can be passed, where true represents local preview mirroring, and false represents no mirroring.</font>
1132
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `cover`. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1133
+ * @param {VideoProfile} [config.option.profile] - Video encoding parameters for the main video.
1134
+ * @param {VideoProfile} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1135
+ * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first(default) ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1136
+ * @throws
1137
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1138
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1139
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1140
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1141
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1142
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1143
+ * @example
1144
+ * // Preview and publish the camera
1145
+ * await trtc.startLocalVideo({
1146
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1147
+ * });
1148
+ * @example
1149
+ * // Preview the camera without publishing. Can be used for camera testing.
1150
+ * const config = {
1151
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1152
+ * publish: false // Do not publish the camera
1153
+ * }
1154
+ * await trtc.startLocalVideo(config);
1155
+ * // Call updateLocalVideo when you need to publish the video
1156
+ * await trtc.updateLocalVideo({ publish:true });
1157
+ * @example
1158
+ * // Use a specified camera.
1159
+ * const cameraList = await TRTC.getCameraList();
1160
+ * if (cameraList[0]) {
1161
+ * await trtc.startLocalVideo({
1162
+ * view: document.getElementById('localVideo'), // Preview the video on the element with the DOM elementId of localVideo.
1163
+ * option: {
1164
+ * cameraId: cameraList[0].deviceId,
1165
+ * }
1166
+ * });
1167
+ * }
1168
+ *
1169
+ * // use front camera on mobile device.
1170
+ * await trtc.startLocalVideo({ view, option: { useFrontCamera: true }});
1171
+ * // use rear camera on mobile device.
1172
+ * await trtc.startLocalVideo({ view, option: { useFrontCamera: false }});
1173
+ * @memberof TRTC
1174
+ */
1175
+ startLocalVideo(config?: LocalVideoConfig): Promise<void>;
1176
+ /**
1177
+ * Update the local camera configuration.
1178
+ * - This interface needs to be called after {@link TRTC#startLocalVideo startLocalVideo()} is successful.
1179
+ * - This interface can be called multiple times.
1180
+ * - This method uses incremental update: only updates the passed-in parameters, and keeps the parameters that are not passed in unchanged.
1181
+ * @param {object} [config]
1182
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id of the preview camera. If not passed in or passed in null, the video will not be rendered, but the container that consumes bandwidth will still be pushed.
1183
+ * @param {boolean} [config.publish] - Whether to publish the local video to the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1184
+ * @param {boolean | string} [config.mute] - Whether to mute camera. Supports passing in image url string, the image will be published instead of origin camera stream, Other users in the room will receive the REMOTE_AUDIO_AVAILABLE event. It does not support calling when the camera is turned off. More information: {@tutorial 15-basic-dynamic-add-video}.
1185
+ * @param {object} [config.option] - Local video configuration
1186
+ * @param {string} [config.option.cameraId] - Specify which camera to use
1187
+ * @param {boolean} [config.option.useFrontCamera] - Whether to use the front camera
1188
+ * @param {MediaStreamTrack} [config.option.videoTrack] - Custom videoTrack. {@tutorial 20-advanced-customized-capture-rendering}.
1189
+ * @param {boolean} [config.option.mirror] - Whether to enable mirror
1190
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit| CSS object-fit} property
1191
+ * @param {VideoProfile} [config.option.profile] - Video encoding parameters for the main stream
1192
+ * @param {VideoProfile|boolean} [config.option.small] - Video encoding parameters for the small video. Refer to {@tutorial 27-advanced-small-stream}
1193
+ * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1194
+ * @throws
1195
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1196
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1197
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1198
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1199
+ * @example
1200
+ * // Switch camera
1201
+ * const cameraList = await TRTC.getCameraList();
1202
+ * if (cameraList[1]) {
1203
+ * await trtc.updateLocalVideo({ option: { cameraId: cameraList[1].deviceId }});
1204
+ * }
1205
+ * @example
1206
+ * // Stop publishing video, but keep local preview
1207
+ * await trtc.updateLocalVideo({ publish:false });
1208
+ * @memberof TRTC
1209
+ */
1210
+ updateLocalVideo(config: LocalVideoConfig): Promise<void>;
1211
+ /**
1212
+ * Stop capturing, previewing, and publishing the local camera.
1213
+ * - If you only want to stop publishing video but keep the local camera preview, you can use the {@link TRTC#updateLocalVideo updateLocalVideo({ publish:false })} method.<br>
1214
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1215
+ * @example
1216
+ * await trtc.stopLocalVideo();
1217
+ */
1218
+ stopLocalVideo(): Promise<void>;
1219
+ /**
1220
+ * @typedef {object|string} ScreenShareProfile - Screen sharing resolution, bit rate, and frame rate configuration
1221
+ * Screen sharing configuration parameters, can use preset values or custom resolution and other parameters
1222
+ * | Screen Profile | Resolution (width x height) | Frame Rate (fps) | Bitrate (kbps) |
1223
+ * | :--- | :--- | :--- | :--- |
1224
+ * | 480p | 640 x 480 | 5 | 900 |
1225
+ * | 480p_2 | 640 x 480 | 30 | 1000 |
1226
+ * | 720p | 1280 x 720 | 5 | 1200 |
1227
+ * | 720p_2 | 1280 x 720 | 30 | 3000 |
1228
+ * | 1080p | 1920 x 1080 | 5 | 1600 |
1229
+ * | 1080p_2 | 1920 x 1080 | 30 | 4000 |
1230
+ * - The default resolution for screen sharing is `1080p`.
1231
+ * - If the above profiles do not meet your business needs, you can also specify custom resolution, frame rate, and bitrate.
1232
+
1233
+ * @property {number} width - Screen sharing width
1234
+ * @property {number} height - Screen sharing height
1235
+ * @property {number} frameRate - Screen sharing frame rate
1236
+ * @property {number} bitrate - Screen sharing bitrate
1237
+ * @example
1238
+ * const config = {
1239
+ * option: {
1240
+ * profile: '720p',
1241
+ * },
1242
+ * }
1243
+ * await trtc.startScreenShare(config);
1244
+ */
1245
+ /**
1246
+ * Start screen sharing.
1247
+ *
1248
+ * - After starting screen sharing, other users in the room will receive the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} event, with streamType as {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB}, and other users can play screen sharing through {@link TRTC#startRemoteVideo startRemoteVideo}.
1249
+ * @param {object} [config]
1250
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id for previewing local screen sharing. If not passed or passed as null, local screen sharing will not be rendered.
1251
+ * @param {boolean} [config.publish] - Whether to publish screen sharing to the room. The default is true. If you call this interface before entering the room and publish = true, the SDK will automatically publish after entering the room. You can get the publish state by listening this event {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}.
1252
+ * @param {object} [config.option] - Screen sharing configuration
1253
+ * @param {boolean} [config.option.systemAudio] - Whether to capture system audio. The default is false.
1254
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `contain`, refer to {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1255
+ * @param {ScreenShareProfile} [config.option.profile] - Screen sharing encoding configuration.
1256
+ * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first(default) ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1257
+ * @param {HTMLElement} [config.option.captureElement] - Capture screen from the specified element of current tab. Available on Chrome 104+.
1258
+ * @param {'current-tab' | 'tab' | 'window' | 'monitor'} [config.option.preferDisplaySurface='monitor'] - The prefer display surface for screen sharing. Available on Chrome 94+.
1259
+ * - The default is monitor, which means that monitor capture will be displayed first in the Screen Sharing Capture pre-checkbox。
1260
+ * - If you fill in 'current-tab', the pre-checkbox will only show the current page.
1261
+ * @throws
1262
+ * - {@link module:ERROR_CODE.ENV_NOT_SUPPORTED ENV_NOT_SUPPORTED}
1263
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1264
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1265
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1266
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1267
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1268
+ * @example
1269
+ * // Start screen sharing
1270
+ * await trtc.startScreenShare();
1271
+ * @memberof TRTC
1272
+ */
1273
+ startScreenShare(config?: ScreenShareConfig): Promise<void>;
1274
+ /**
1275
+ * Update screen sharing configuration
1276
+ * - This interface needs to be called after {@link TRTC#startScreenShare startScreenShare()} is successful.
1277
+ * - This interface can be called multiple times.
1278
+ * - This method uses incremental update: only update the passed-in parameters, and keep the parameters that are not passed-in unchanged.
1279
+ * @param {object} [config]
1280
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id for screen sharing preview. If not passed in or passed in null, the screen sharing will not be rendered.
1281
+ * @param {boolean} [config.publish=true] - Whether to publish screen sharing to the room
1282
+ * @param {object} [config.option] - Screen sharing configuration
1283
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. The default is `contain`, refer to {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1284
+ * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - Set the video encoding strategy for weak networks. Smooth first ({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH}) or Clear first ({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_ PREFERENCE_SMOOTH})
1285
+ * @throws
1286
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1287
+ * - {@link module:ERROR_CODE.DEVICE_ERROR DEVICE_ERROR}
1288
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1289
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1290
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1291
+ * @example
1292
+ * // Stop screen sharing, but keep the local preview of screen sharing
1293
+ * await trtc.updateScreenShare({ publish:false });
1294
+ * @memberof TRTC
1295
+ */
1296
+ updateScreenShare(config: UpdateScreenShareConfig): Promise<void>;
1297
+ /**
1298
+ * Stop screen sharing.
1299
+
1300
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1301
+ * @example
1302
+ * await trtc.stopScreenShare();
1303
+ */
1304
+ stopScreenShare(): Promise<void>;
1305
+ /**
1306
+ * Play remote video
1307
+ *
1308
+ * - When to call: Call after receiving the {@link module:EVENT.REMOTE_VIDEO_AVAILABLE TRTC.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE)} event.
1309
+ * @param {object} [config]
1310
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id used to play remote video. If not passed or passed null, the video will not be rendered, but the bandwidth will still be consumed.
1311
+ * @param {string} config.userId - Remote user ID
1312
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1313
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1314
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1315
+ * @param {object} [config.option] - Remote video configuration
1316
+ * @param {boolean} [config.option.small] - Whether to subscribe small streams
1317
+ * @param {boolean} [config.option.mirror] - Whether to enable mirror
1318
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1319
+ * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1320
+ * @param {HTMLElement} [config.option.viewRoot=document.body] - Since v5.4.0 <br>The root element is the parent element of the view and is used to calculate whether the view is visible relative to the root. The default value is document.body, and it is recommended that you use the first-level parent of the video view list. Refer to: {@tutorial 27-advanced-small-stream}.
1321
+ * @throws
1322
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1323
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1324
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1325
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1326
+ * - {@link module:ERROR_CODE.SERVER_ERROR SERVER_ERROR}
1327
+ * @example
1328
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, ({ userId, streamType }) => {
1329
+ * // You need to place the video container in the DOM in advance, and it is recommended to use `${userId}_${streamType}` as the element id.
1330
+ * trtc.startRemoteVideo({ userId, streamType, view: `${userId}_${streamType}` });
1331
+ * })
1332
+ * @memberof TRTC
1333
+ */
1334
+ startRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1335
+ /**
1336
+ * Update remote video playback configuration<br>
1337
+ * - This method should be called after {@link TRTC#startRemoteVideo startRemoteVideo} is successful.
1338
+ * - This method can be called multiple times.
1339
+ * - This method uses incremental updates, so only the configuration items that need to be updated need to be passed in.
1340
+ * @param {object} [config]
1341
+ * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - The HTMLElement instance or Id used to play remote video. If not passed or passed null, the video will not be rendered, but the bandwidth will still be consumed.
1342
+ * @param {string} config.userId - Remote user ID
1343
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType - Remote stream type
1344
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1345
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1346
+ * @param {object} [config.option] - Remote video configuration
1347
+ * @param {boolean} [config.option.small] - Whether to subscribe small streams. Refer to: {@tutorial 27-advanced-small-stream}.
1348
+ * @param {boolean} [config.option.mirror] - Whether to enable mirror
1349
+ * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - Video fill mode. Refer to the {@link https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit CSS object-fit} property.
1350
+ * @param {boolean} [config.option.receiveWhenViewVisible] - Since v5.4.0 <br>Subscribe video only when view is visible. Refer to: {@tutorial 27-advanced-small-stream}.
1351
+ * @param {HTMLElement} [config.option.viewRoot=document.body] - Since v5.4.0 <br>The root element is the parent element of the view and is used to calculate whether the view is visible relative to the root. The default value is document.body, and it is recommended that you use the first-level parent of the video view list. Refer to: {@tutorial 27-advanced-small-stream}.
1352
+ * @throws
1353
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1354
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1355
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1356
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1357
+ * @example
1358
+ * const config = {
1359
+ * view: document.getElementById(userId),
1360
+ * userId,
1361
+ * }
1362
+ * await trtc.updateRemoteVideo(config);
1363
+ * @memberof TRTC
1364
+ */
1365
+ updateRemoteVideo(config: RemoteVideoConfig): Promise<void>;
1366
+ /**
1367
+ * Used to stop remote video playback.<br>
1368
+ * @param {object} config - Remote video configuration
1369
+ * @param {string} config.userId - Remote user ID, '*' represents all users.
1370
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} [config.streamType] - Remote stream type. This field is required when userId is not '*'.
1371
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)
1372
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1373
+ * @throws {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1374
+ * @example
1375
+ * // Stop playing all remote users
1376
+ * await trtc.stopRemoteVideo({ userId: '*' });
1377
+ */
1378
+ stopRemoteVideo(config: StopRemoteVideoConfig): Promise<void>;
1379
+ /**
1380
+ * Mute a remote user and stop subscribing audio data from that user. Only effective for the current user, other users in the room can still hear the muted user's voice.<br>
1381
+ *
1382
+ * Note:
1383
+ * - By default, after entering the room, the SDK will automatically play remote audio. You can call this interface to mute or unmute remote users.
1384
+ * - If the parameter autoReceiveAudio = false is passed in when entering the room, remote audio will not be played automatically. When audio playback is required, you need to call this method (mute is passed in false) to play remote audio.
1385
+ * - This interface is effective before or after entering the room (enterRoom), and the mute state will be reset to false after exiting the room (exitRoom).
1386
+ * - If you want to continue subscribing audio data from the user but not play it, you can call setRemoteAudioVolume(userId, 0)
1387
+ * @param {string} userId - Remote user ID, '*' represents all users.
1388
+ * @param {boolean} mute - Whether to mute
1389
+ * @throws
1390
+ * - {@link module:ERROR_CODE.INVALID_PARAMETER INVALID_PARAMETER}
1391
+ * - {@link module:ERROR_CODE.INVALID_OPERATION INVALID_OPERATION}
1392
+ * - {@link module:ERROR_CODE.OPERATION_FAILED OPERATION_FAILED}
1393
+ * - {@link module:ERROR_CODE.OPERATION_ABORT OPERATION_ABORT}
1394
+ * @example
1395
+ * // Mute all remote users
1396
+ * await trtc.muteRemoteAudio('*', true);
1397
+ */
1398
+ muteRemoteAudio(userId: string, mute: boolean): Promise<void>;
1399
+ /**
1400
+ * Used to control the playback volume of remote audio.<br>
1401
+ *
1402
+ * - Not supported by iOS Safari
1403
+ * @param {string} userId - Remote user ID。'*' represents all remote users.
1404
+ * @param {number} volume - Volume, ranging from 0 to 100. The default value is 100.<br>
1405
+ * Since `v5.1.3+`, the volume can be set higher than 100.
1406
+ * @example
1407
+ * await trtc.setRemoteAudioVolume('123', 90);
1408
+ */
1409
+ setRemoteAudioVolume(userId: string, volume: number): void;
1410
+ startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1411
+ startPlugin<T extends keyof PluginStartOptionsMap, O extends PluginStartOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1412
+ updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1413
+ updatePlugin<T extends keyof PluginUpdateOptionsMap, O extends PluginUpdateOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1414
+ stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? never : T, options: O): Promise<any>;
1415
+ stopPlugin<T extends keyof PluginStopOptionsMap, O extends PluginStopOptionsMap[T]>(plugin: O extends undefined ? T : never): Promise<any>;
1416
+ /**
1417
+ * Enables or disables the volume callback.<br>
1418
+ *
1419
+ * - After enabling this function, whether someone is speaking in the room or not, the SDK will regularly throw the {@link module:EVENT.AUDIO_VOLUME TRTC.on(TRTC.EVENT.AUDIO_VOLUME)} event, which feedbacks the volume evaluation value of each user.<br>
1420
+ *
1421
+ * @param {number} [interval=2000] Used to set the time interval for triggering the volume callback event. The default is 2000(ms), and the minimum value is 100(ms). If set to less than or equal to 0, the volume callback will be turned off.
1422
+ * @param {boolean} [enableInBackground=false] For performance reasons, when the page switches to the background, the SDK will not throw volume callback events. If you need to receive volume callback events when the page is switched to the background, you can set this parameter to true.
1423
+ * @memberof TRTC
1424
+ * @example
1425
+ * trtc.on(TRTC.EVENT.AUDIO_VOLUME, event => {
1426
+ * event.result.forEach(({ userId, volume }) => {
1427
+ * const isMe = userId === ''; // When userId is an empty string, it represents the local microphone volume.
1428
+ * if (isMe) {
1429
+ * console.log(`my volume: ${volume}`);
1430
+ * } else {
1431
+ * console.log(`user: ${userId} volume: ${volume}`);
1432
+ * }
1433
+ * })
1434
+ * });
1435
+ *
1436
+ * // Enable volume callback and trigger the event every 1000ms
1437
+ * trtc.enableAudioVolumeEvaluation(1000);
1438
+ *
1439
+ * // To turn off the volume callback, pass in an interval value less than or equal to 0
1440
+ * trtc.enableAudioVolumeEvaluation(-1);
1441
+ */
1442
+ enableAudioVolumeEvaluation(interval?: number, enableInBackground?: boolean): void;
1443
+ /**
1444
+ * Listen to TRTC events<br><br>
1445
+ * For a detailed list of events, please refer to: {@link module:EVENT TRTC.EVENT}
1446
+ *
1447
+ * @param {string} eventName Event name
1448
+ * @param {function} handler Event callback function
1449
+ * @param {context} context Context
1450
+ * @memberof TRTC
1451
+ * @example
1452
+ * trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {
1453
+ * // REMOTE_VIDEO_AVAILABLE event handler
1454
+ * });
1455
+ */
1456
+ on<T extends keyof TRTCEventTypes>(event: T, handler: (...args: TRTCEventTypes[T]) => void, context?: any): this;
1457
+ /**
1458
+ * Remove event listener<br>
1459
+ *
1460
+ * @param {string} eventName Event name. Passing in the wildcard '*' will remove all event listeners.
1461
+ * @param {function} handler Event callback function
1462
+ * @param {context} context Context
1463
+ * @memberof TRTC
1464
+ * @example
1465
+ * trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, function peerJoinHandler(event) {
1466
+ * // REMOTE_USER_ENTER event handler
1467
+ * console.log('remote user enter');
1468
+ *
1469
+ * trtc.off(TRTC.EVENT.REMOTE_USER_ENTER, peerJoinHandler);
1470
+ * });
1471
+ *
1472
+ * // Remove all event listeners
1473
+ * trtc.off('*');
1474
+ */
1475
+ off<T extends keyof TRTCEventTypes>(event: T | '*', handler: T extends '*' ? never : (...args: TRTCEventTypes[T]) => void, context?: any): this;
1476
+ /**
1477
+ * Get video track
1478
+ *
1479
+ * @param {string} [config] If not passed, get the local camera videoTrack
1480
+ * @param {string} [config.userId] If not passed or passed an empty string, get the local videoTrack. Pass the userId of the remote user to get the remote user's videoTrack.
1481
+ * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - Remote stream type:
1482
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (remote user's camera)(default)
1483
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (remote user's screen sharing)
1484
+ * @returns {MediaStreamTrack|null} Video track
1485
+ * @memberof TRTC
1486
+ * @example
1487
+ * // Get local camera videoTrack
1488
+ * const videoTrack = trtc.getVideoTrack();
1489
+ * // Get local screen sharing videoTrack
1490
+ * const screenVideoTrack = trtc.getVideoTrack({ streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1491
+ * // Get remote user's main stream videoTrack
1492
+ * const remoteMainVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_MAIN });
1493
+ * // Get remote user's sub stream videoTrack
1494
+ * const remoteSubVideoTrack = trtc.getVideoTrack({ userId: 'test', streamType: TRTC.TYPE.STREAM_TYPE_SUB });
1495
+ */
1496
+ getVideoTrack(config?: {
1497
+ userId?: string;
1498
+ streamType?: TRTCStreamType;
1499
+ }): MediaStreamTrack | null;
1500
+ /**
1501
+ * Get audio track
1502
+ *
1503
+ * @returns {MediaStreamTrack?} Audio track
1504
+ * @param {string} [userId] If not passed, get the local audioTrack
1505
+ * @memberof TRTC
1506
+ */
1507
+ getAudioTrack(userId?: string): MediaStreamTrack | null;
1508
+ setCurrentSpeaker(speakerId: string): void;
1509
+ /**
1510
+ * Send SEI Message <br>
1511
+ *
1512
+ * > The header of a video frame has a header block called SEI.
1513
+ * > The principle of this interface is to use the SEI to embed the custom data you want to send along with the video frame.
1514
+ * > SEI messages can accompany video frames all the way to the live CDN.
1515
+ *
1516
+ * Applicable scenarios: synchronization of lyrics, live answering questions, etc.
1517
+ *
1518
+ * When to call: call after {@link TRTC#startLocalVideo trtc.startLocalVideo} successfully.
1519
+ *
1520
+ * Note:
1521
+ * 1. Maximum 1KB(Byte) sent in a single call, maximum 30 calls per second, maximum 8KB sent per second.
1522
+ * 2. Currently only support Chrome 86+, Edge 86+, Opera 72+ browsers.
1523
+ * 3. Since SEI is sent along with video frames, there is a possibility that video frames may be lost, and therefore SEI may be lost as well. The number of times it can be sent can be increased within the frequency limit, and the business side needs to do message de-duplication on the receiving side.
1524
+ * 4. SEI cannot be sent without trtc.startLocalVideo; SEI cannot be received without startRemoteVideo.
1525
+ * 5. Only H264 encoder is supported to send SEI.
1526
+ * 6. SEI sending and receiving is not supported for small streams for the time being.
1527
+ * @see {@link module:EVENT.SEI_MESSAGE TRTC.EVENT.SEI_MESSAGE}
1528
+ * @since v5.3.0
1529
+ * @param {ArrayBuffer} buffer SEI data to be sent
1530
+ * @param {Object=} options
1531
+ * @param {Number} options.seiPayloadType Set the SEI payload type. SDK uses the custom payloadType 243 by default, the business side can use this parameter to set the payloadType to the standard 5. When the business side uses the 5 payloadType, you need to follow the specification to make sure that the first 16 bytes of the `buffer` are the business side's customized uuid.
1532
+ * @example
1533
+ * // 1. enable SEI
1534
+ * const trtc = TRTC.create({
1535
+ * enableSEI: true
1536
+ * })
1537
+ *
1538
+ * // 2. send SEI
1539
+ * try {
1540
+ * await trtc.enterRoom({
1541
+ * userId: 'user_1',
1542
+ * roomId: 12345,
1543
+ * })
1544
+ * await trtc.startLocalVideo();
1545
+ * const unit8Array = new Uint8Array([1, 2, 3]);
1546
+ * trtc.sendSEIMessage(unit8Array.buffer);
1547
+ * } catch(error) {
1548
+ * console.warn(error);
1549
+ * }
1550
+ *
1551
+ * // 3. receive SEI
1552
+ * trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
1553
+ * console.warn(`sei ${event.data} from ${event.userId}`);
1554
+ * })
1555
+ */
1556
+ sendSEIMessage(buffer: ArrayBuffer, options?: {
1557
+ seiPayloadType: number;
1558
+ }): void;
1559
+ /**
1560
+ * Get video snapshot <br>
1561
+ * Notice: must play the video before it can obtain the snapshot. If there is no playback, an empty string will be returned.
1562
+ * @param {string} config.userId - Remote user ID
1563
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType
1564
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream
1565
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream
1566
+ * @since 5.4.0
1567
+ * @example
1568
+ * // get self main stream video frame
1569
+ * trtc.getVideoSnapshot()
1570
+ * // get self sub stream video frame
1571
+ * trtc.getVideoSnapshot({streamType:TRTC.TYPE.STREAM_TYPE_SUB})
1572
+ * // get remote user main stream video frame
1573
+ * trtc.getVideoSnapshot({userId: 'remote userId', streamType:TRTC.TYPE.STREAM_TYPE_MAIN})
1574
+ * @memberof TRTC
1575
+ */
1576
+ getVideoSnapshot(config?: VideoFrameConfig): string;
1577
+ static EVENT: {
1578
+ readonly ERROR: "error";
1579
+ readonly AUTOPLAY_FAILED: "autoplay-failed";
1580
+ readonly KICKED_OUT: "kicked-out";
1581
+ readonly REMOTE_USER_ENTER: "remote-user-enter";
1582
+ readonly REMOTE_USER_EXIT: "remote-user-exit";
1583
+ readonly REMOTE_AUDIO_AVAILABLE: "remote-audio-available";
1584
+ readonly REMOTE_AUDIO_UNAVAILABLE: "remote-audio-unavailable";
1585
+ readonly REMOTE_VIDEO_AVAILABLE: "remote-video-available";
1586
+ readonly REMOTE_VIDEO_UNAVAILABLE: "remote-video-unavailable";
1587
+ readonly AUDIO_VOLUME: "audio-volume";
1588
+ readonly NETWORK_QUALITY: "network-quality";
1589
+ readonly CONNECTION_STATE_CHANGED: "connection-state-changed";
1590
+ readonly AUDIO_PLAY_STATE_CHANGED: "audio-play-state-changed";
1591
+ readonly VIDEO_PLAY_STATE_CHANGED: "video-play-state-changed";
1592
+ readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
1593
+ readonly DEVICE_CHANGED: "device-changed";
1594
+ readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
1595
+ readonly STATISTICS: "statistics";
1596
+ readonly SEI_MESSAGE: "sei-message";
1597
+ readonly TRACK: "track";
1598
+ };
1599
+ static ERROR_CODE: {
1600
+ INVALID_PARAMETER: number;
1601
+ INVALID_OPERATION: number;
1602
+ ENV_NOT_SUPPORTED: number;
1603
+ DEVICE_ERROR: number;
1604
+ SERVER_ERROR: number;
1605
+ OPERATION_FAILED: number;
1606
+ OPERATION_ABORT: number;
1607
+ UNKNOWN_ERROR: number;
1608
+ };
1609
+ static TYPE: {
1610
+ readonly SCENE_LIVE: Scene.LIVE;
1611
+ readonly SCENE_RTC: Scene.RTC;
1612
+ readonly ROLE_ANCHOR: UserRole.ANCHOR;
1613
+ readonly ROLE_AUDIENCE: UserRole.AUDIENCE;
1614
+ readonly STREAM_TYPE_MAIN: TRTCStreamType.Main;
1615
+ readonly STREAM_TYPE_SUB: TRTCStreamType.Sub;
1616
+ readonly AUDIO_PROFILE_STANDARD: "standard";
1617
+ readonly AUDIO_PROFILE_STANDARD_STEREO: "standard-stereo";
1618
+ readonly AUDIO_PROFILE_HIGH: "high";
1619
+ readonly AUDIO_PROFILE_HIGH_STEREO: "high-stereo";
1620
+ readonly QOS_PREFERENCE_SMOOTH: "smooth";
1621
+ readonly QOS_PREFERENCE_CLEAR: "clear";
1622
+ };
1623
+ static frameWorkType: number;
1624
+ /**
1625
+ * Set the log output level
1626
+ * <br>
1627
+ * It is recommended to set the DEBUG level during development and testing, which includes detailed prompt information.
1628
+ * The default output level is INFO, which includes the log information of the main functions of the SDK.
1629
+ *
1630
+ * @param {0-5} [level] Log output level 0: TRACE 1: DEBUG 2: INFO 3: WARN 4: ERROR 5: NONE
1631
+ * @param {boolean} [enableUploadLog=true] Whether to enable log upload, which is enabled by default. It is not recommended to turn it off, which will affect problem troubleshooting.
1632
+ * @example
1633
+ * // Output log levels above DEBUG
1634
+ * TRTC.setLogLevel(1);
1635
+ */
1636
+ static setLogLevel(level: LOG_LEVEL, enableUploadLog?: boolean): void;
1637
+ /**
1638
+ * Check if the TRTC Web SDK is supported by the current browser
1639
+ *
1640
+ * - Reference: {@tutorial 05-info-browser}.
1641
+ * @example
1642
+ * TRTC.isSupported().then((checkResult) => {
1643
+ * if(!checkResult.result) {
1644
+ * console.log('checkResult', checkResult.result, 'checkDetail', checkResult.detail);
1645
+ * // The SDK is not supported by the current browser, guide the user to use the latest version of Chrome browser.
1646
+ * }
1647
+ * });
1648
+ *
1649
+ * @returns {Promise.<object>} Promise returns the detection result
1650
+ * | Property | Type | Description |
1651
+ * |--------------------------------------------|---------|-------------------------------------|
1652
+ * | checkResult.result | boolean | Detection result |
1653
+ * | checkResult.detail.isBrowserSupported | boolean | Whether the current browser is supported by the SDK |
1654
+ * | checkResult.detail.isWebRTCSupported | boolean | Whether the current browser supports WebRTC |
1655
+ * | checkResult.detail.isWebCodecsSupported | boolean | Whether the current browser supports WebCodecs |
1656
+ * | checkResult.detail.isMediaDevicesSupported | boolean | Whether the current browser supports obtaining media devices and media streams |
1657
+ * | checkResult.detail.isScreenShareSupported | boolean | Whether the current browser supports screen sharing |
1658
+ * | checkResult.detail.isSmallStreamSupported | boolean | Whether the current browser supports small streams |
1659
+ * | checkResult.detail.isH264EncodeSupported | boolean | Whether the current browser supports H264 encoding for uplink |
1660
+ * | checkResult.detail.isH264DecodeSupported | boolean | Whether the current browser supports H264 decoding for downlink |
1661
+ * | checkResult.detail.isVp8EncodeSupported | boolean | Whether the current browser supports VP8 encoding for uplink |
1662
+ * | checkResult.detail.isVp8DecodeSupported | boolean | Whether the current browser supports VP8 decoding for downlink |
1663
+ */
1664
+ static isSupported(): Promise<{
1665
+ result: boolean;
1666
+ detail: {
1667
+ isBrowserSupported: boolean;
1668
+ isWebRTCSupported: boolean;
1669
+ isWebCodecsSupported: boolean;
1670
+ isMediaDevicesSupported: boolean;
1671
+ isScreenShareSupported: boolean;
1672
+ isSmallStreamSupported: boolean;
1673
+ isH264EncodeSupported: boolean;
1674
+ isVp8EncodeSupported: boolean;
1675
+ isH264DecodeSupported: boolean;
1676
+ isVp8DecodeSupported: boolean;
1677
+ };
1678
+ }>;
1679
+ /**
1680
+ * Returns the list of camera devices
1681
+ * <br>
1682
+ * **Note**
1683
+ * - This interface does not support use under the http protocol, please use the https protocol to deploy your website. {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security Privacy and security}
1684
+ * - Calling this method may temporarily open the camera to ensure that the camera list can be normally obtained, and the SDK will automatically stop the camera capture later.
1685
+ * - You can call the browser's native interface [getCapabilities](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities) to get the maximum resolutions supported by the camera, frame rate, mobile devices to distinguish between front and rear cameras, etc. This interface supports Chrome 67+, Edge 79+, Safari 17+, Opera 54+.
1686
+ * @example
1687
+ * const cameraList = await TRTC.getCameraList();
1688
+ * if (cameraList[0] && cameraList[0].getCapabilities) {
1689
+ * const { width, height, frameRate, facingMode } = cameraList[0].getCapabilities();
1690
+ * console.log(width.max, height.max, frameRate.max);
1691
+ * if (facingMode) {
1692
+ * if (facingMode[0] === 'user') {
1693
+ * // front camera
1694
+ * } else if (facingMode[0] === 'environment') {
1695
+ * // rear camera
1696
+ * }
1697
+ * }
1698
+ * }
1699
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1700
+ */
1701
+ static getCameraList(): Promise<DeviceInfo[]>;
1702
+ /**
1703
+ * Returns the list of microphone devices
1704
+ * <br>
1705
+ * **Note**
1706
+ * - This interface does not support use under the http protocol, please use the https protocol to deploy your website. {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Privacy_and_security Privacy and security}
1707
+ * - Calling this method may temporarily open the microphone to ensure that the microphone list can be normally obtained, and the SDK will automatically stop the microphone capture later.
1708
+ * - You can call the browser's native interface [getCapabilities](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities) to get information about the microphone's capabilities, e.g. the maximum number of channels supported, etc. This interface supports Chrome 67+, Edge 79+, Safari 17+, Opera 54+.
1709
+ * @example
1710
+ * const microphoneList = await TRTC.getMicrophoneList();
1711
+ * if (microphoneList[0] && microphoneList[0].getCapabilities) {
1712
+ * const { channelCount } = microphoneList[0].getCapabilities();
1713
+ * console.log(channelCount.max);
1714
+ * }
1715
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1716
+ */
1717
+ static getMicrophoneList(): Promise<DeviceInfo[]>;
1718
+ /**
1719
+ * Returns the list of speaker devices
1720
+ * <br>
1721
+ * Calling this method may temporarily open the microphone to ensure that the speaker list can be normally obtained, and the SDK will automatically release the microphone capture later.
1722
+ * @returns {Promise.<MediaDeviceInfo[]>} Promise returns an array of {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo|MediaDeviceInfo}
1723
+ */
1724
+ static getSpeakerList(): Promise<DeviceInfo[]>;
1725
+ /**
1726
+ * Set the current speaker for audio playback
1727
+ *
1728
+ * @param {string} speakerId Speaker ID
1729
+ */
1730
+ static setCurrentSpeaker(speakerId: string): Promise<void>;
1731
+ }
861
1732
  export default TRTC