trtc-sdk-v5 5.4.1-beta.7 → 5.4.1-beta.8

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