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

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