@byteplus/rtc 4.36.0 → 4.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -2,551 +2,571 @@
2
2
 
3
3
  import { EventArgs, EventEmitter, EventNames, ValidEventTypes } from 'eventemitter3';
4
4
 
5
- /**
6
- * @list 104477
7
- * @detail 104478
8
- */
9
- /**
10
- * @list 104477
11
- * @detail 104478
12
- */
13
- export interface IAudioMixingManager {
5
+ declare enum ErrorCode {
14
6
 
15
7
  /**
16
- * Start playing audio files and mixes. <br>
17
- * This method can be called many times by passing in different IDs and filepath to realize simultaneous playback of multiple mixing files and mixing overlay.
18
- * @param id Mix ID. For identifying the mix, please ensure that the mix ID is unique. <br>
19
- * If this method is repeatedly called with the same ID, the previous mix stops and the next mix starts.
20
- * @param filePath Specify the file path either the absolute path of a local file or the url of online audio. Files with the extension of mp3 and aac are supported.
21
- * @param config Mix Sound configuration <br>
22
- * You can set the number of times the mix is played, whether the mix is played locally, and whether the mix is sent to the remote end. For details.
23
- * @return
24
- * @notes <br>
25
- * + If you have already loaded the sound effect into memory through preloadAudioMixing{@link #preloadAudioMixing}, make sure that the ID here is the same as the ID set by preloadAudioMixing{@link #preloadAudioMixing}. <br>
26
- * + After you start playing the audio file and mixing, you can call the stopAudioMixing{@link #stopAudioMixing} method to stop playing the audio file. <br>
27
- * + The mixing data of this method comes from an external file, while the mixing data of enableAudioMixingFrame{@link #enableAudioMixingFrame} comes from an external cache and the audio format is PCM. These two mixing methods can coexist.
28
- * @region Advanced Feature
8
+ * Invalid argument of the `engine` object for calling destroyEngine
29
9
  */
30
- startAudioMixing(id: number, filePath: string, options: MixOption): Promise<void>;
10
+ INVALID_ENGINE = "INVALID_ENGINE",
31
11
 
32
12
  /**
33
- * Stop playing audio files and mixes
34
- * @param id ID of the mixing
35
- * @notes <br>
36
- * + After calling startAudioMixing{@link #startAudioMixing} method to start playing audio files and mixes, you can call this method to stop playing audio files and mixes. <br>
37
- * + After calling this method to stop playing the audio file, the audio file will be automatically uninstalled.
38
- * @region Advanced Feature
13
+ * Invalid argument
39
14
  */
40
- stopAudioMixing(id: number): void;
15
+ INVALID_PARAMS = "INVALID_PARAMS",
41
16
 
42
17
  /**
43
- * Pause playing audio files and mixes
44
- * @param id ID of the mixing
45
- * @notes <br>
46
- * + After calling startAudioMixing{@link #startAudioMixing} method to start playing audio files and mixes, you can call this method to pause playing audio files and mixes. <br>
47
- * + After calling this method to pause playing audio files and mixing, you can call the resumeAudioMixing{@link #resumeAudioMixing} method to resume playing and mixing. <br>
48
- * @region Advanced Feature
18
+ * Token is invalid or has expired.
49
19
  */
50
- pauseAudioMixing(id: number): void;
20
+ INVALID_TOKEN = "INVALID_TOKEN",
51
21
 
52
22
  /**
53
- * Resume playing audio files and mixing
54
- * @param id Mixing ID
55
- * @notes After calling the pauseAudioMixing{@link #pauseAudioMixing} method to pause playing audio files and mixing, you can resume playing and mixing by calling this method. <br>
56
- * @region Advanced Feature
23
+ * Failure of joining room
57
24
  */
58
- resumeAudioMixing(id: number): void;
25
+ JOIN_ROOM_FAILED = "JOIN_ROOM_FAILED",
59
26
 
60
27
  /**
61
- * Preload the specified audio file into memory
62
- * @param id Mix ID. For identifying the mix, please ensure that the mix ID is unique. <br>
63
- * If this method is called repeatedly with the same ID, the latter overrides the previous. <br>
64
- * If you call startAudioMixing{@link #startAudioMixing} and then call this method with the same ID, the previous mix stopped, and then the next mix was loaded. <br>
65
- * After calling this method with an ID to preload A.mp3, if you need to call startAudioMixing{@link #startAudioMixing} to play B.mp3 with the same ID, please call unloadAudioMixing{@link #unloadAudioMixing} to uninstall A.mp3 first, otherwise you will report an error AUDIO_MIXING_ERROR_LOAD_CONFLICT.
66
- * @param filePath Used for mixing file paths. It can be the absolute path of the local file or the url of the online audio. <br>
67
- * @return
68
- * @notes <br>
69
- * + When you need to play an audio file frequently, call this method to preload the file. When playing, you can only load the file once to reduce CPU usage. <br>
70
- * + This method pre-loads the specified audio file, and only calling startAudioMixing{@link #startAudioMixing} API can you start playing the specified audio file. <br>
71
- * + The specified audio file preloaded by calling this method can be unloaded through unloadAudioMixing{@link #unloadAudioMixing}.
72
- * @region Advanced Feature
28
+ * Join the same room repeatedly.
73
29
  */
74
- preloadAudioMixing(id: number, filePath: string): Promise<void>;
30
+ REPEAT_JOIN = "REPEAT_JOIN",
75
31
 
76
32
  /**
77
- * Uninstall the specified audio file
78
- * @param id Mix ID
79
- * @region Advanced Feature
33
+ * Publish media stream repeatedly.
80
34
  */
81
- unloadAudioMixing(id: number): void;
35
+ REPEAT_PUBLISH = "REPEAT_PUBLISH",
82
36
 
83
37
  /**
84
- * Adjust the volume of audio mixing, including audio files and PCM data.
85
- * @param id Mixing ID
86
- * @param volume The ratio of the mixing volume to the original volume. The range is `[0, 400]`. The recommended range is `[0, 100]`. <br>
87
- * + 0: Mute <br>
88
- * + 100: Original volume <br>
89
- * + 400: Maximum volume (with overflow protection)
90
- * @region Advanced Feature
38
+ * Publish before joining a room.
91
39
  */
92
- setAudioMixingVolume(id: number, volume: number): void;
40
+ PUBLISH_BEFORE_JOIN = "PUBLISH_BEFORE_JOIN",
93
41
 
94
42
  /**
95
- * Get volume of the audio files.
96
- * @param id Audio mix id
97
- * @return <br>
98
- * + `0`: Failure<br>
99
- * + `>0`: Successful. Volume<br>
100
- * @region Advanced Feature
43
+ * Un-publish before joining a room.
101
44
  */
102
- getAudioMixingVolume(id: number): number;
45
+ UNPUBLISH_BEFORE_JOIN = "UNPUBLISH_BEFORE_JOIN",
103
46
 
104
47
  /**
105
- * Get audio file duration
106
- * @param id Mix ID
107
- * @return <br>
108
- * + > 0: Success, audio file duration, in milliseconds. <br>
109
- * + < 0: Failure
110
- * @notes Before calling this method to obtain the length of the audio file, you need to call preloadAudioMixing{@link #preloadAudioMixing} or startAudioMixing{@link #startAudioMixing}.
111
- * @region Advanced Feature
48
+ * Subscribe before joining a room.
112
49
  */
113
- getAudioMixingDuration(id: number): number;
50
+ SUBSCRIBE_BEFORE_JOIN = "SUBSCRIBE_BEFORE_JOIN",
114
51
 
115
52
  /**
116
- * Get audio file playback progress
117
- * @param id Mix ID
118
- * @return <br>
119
- * + > 0: Success, audio file playback progress, in milliseconds. <br>
120
- * + < 0: Failed
121
- * @notes Before calling this method to get the audio file playback progress, you need to call startAudioMixing{@link #startAudioMixing} to start playing the audio file.
122
- * @region Advanced Feature
53
+ * Unsubscribe before joining a room.
123
54
  */
124
- getAudioMixingCurrentPosition(id: number): number;
55
+ UNSUBSCRIBE_BEFORE_JOIN = "UNSUBSCRIBE_BEFORE_JOIN",
125
56
 
126
57
  /**
127
- * Set the starting playback position of the audio file
128
- * @param id Mixing ID
129
- * @param position The starting playback position of the audio file in milliseconds.
130
- * @notes <br>
131
- * + This method allows you to play an audio file from a specified position as appropriate, without having to play an audio file in its entirety from the beginning to finish. <br>
132
- * + Before calling this method to set the playback position of the audio file, you need to call startAudioMixing{@link #startAudioMixing} to start playing the audio file.
133
- * @region Advanced Feature
58
+ * Request to publish media stream as an invisible user.
134
59
  */
135
- setAudioMixingPosition(id: number, position: number): void;
60
+ NO_PUBLISH_PERMISSION = "NO_PUBLISH_PERMISSION",
136
61
 
137
62
  /**
138
- * Start PCM mixing. <br>
139
- * To mix multiple PCM audio data, call this API multiple times with different ids.
140
- * @param type Mixing type <br>
141
- * Whether the PCM data is mixed locally and sent to the remotes.
142
- * @notes <br>
143
- * + After this API, you must call pushAudioMixingFrame{@link #pushAudioMixingFrame} to start mixing. <br>
144
- * + To end PCM mixing, use disableAudioMixingFrame{@link #disableAudioMixingFrame}.
145
- * @region Advanced Feature
63
+ * Request to subscribe or unsubscribe a stream that doesn't exist.
146
64
  */
147
- enableAudioMixingBuffer(type: AudioMixingType): void;
65
+ STREAM_NOT_EXIST = "STREAM_NOT_EXIST",
148
66
 
149
67
  /**
150
- * Disable PCM mixing.
151
- * @region Advanced Feature
68
+ * Request to publish an empty stream.
152
69
  */
153
- disableAudioMixingBuffer(): void;
70
+ EMPTY_STREAM = "EMPTY_STREAM",
154
71
 
155
72
  /**
156
- * Push PCM audio frame data for mixing
157
- * @param buffer Refer to [Browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer)
158
- * @notes Before calling this method, you must start the external audio stream mixing through enableAudioMixingFrame{@link #enableAudioMixingFrame}. <br>
159
- * @region Advanced Feature
73
+ * Network disconnected. RTC SDk will emit this error code if you call publish, subscribe or the other related methods while the user has not joined a room.
160
74
  */
161
- pushAudioMixingBuffer(buffer: AudioBuffer): void;
162
- }
163
-
164
- /**
165
- * @type keytype
166
- * Mix playback channel type
167
- */
168
- export declare enum AudioMixingDualMonoMode {
75
+ NOT_CONNECTED_YET = "NOT_CONNECTED_YET",
169
76
 
170
77
  /**
171
- * Consistent with audio files
78
+ * Request to send message before the user has joined a room.
172
79
  */
173
- AUTO = 0,
80
+ IM_BEFORE_JOIN = "IM_BEFORE_JOIN",
174
81
 
175
82
  /**
176
- * Only the left channel audio in the audio file can be heard
83
+ * The user does not exist.
177
84
  */
178
- MODE_L = 1,
85
+ USER_NOT_EXIST = "USER_NOT_EXIST",
179
86
 
180
87
  /**
181
- * Only the right channel audio in the audio file can be heard
88
+ * The user has joined the room.
182
89
  */
183
- MODE_R = 2,
90
+ ALREADY_IN_ROOM = "ALREADY_IN_ROOM",
184
91
 
185
92
  /**
186
- * Can hear the left and right audio channels in the audio file at the same time
93
+ * The user is kicked out because a user with the same userId joined the room.
187
94
  */
188
- MODE_MIX = 3
189
- }
190
-
191
- /**
192
- * @type keytype
193
- * Mixing type
194
- */
195
- export declare enum AudioMixingType {
95
+ DUPLICATE_LOGIN = "DUPLICATE_LOGIN",
196
96
 
197
97
  /**
198
- * Played at the local device only
98
+ * Enable capture repeatedly.
199
99
  */
200
- PLAYOUT = 0,
100
+ REPEAT_CAPTURE = "REPEAT_CAPTURE",
201
101
 
202
102
  /**
203
- * Sent to the remote devices only
103
+ * Failure of video capture
204
104
  */
205
- PUBLISH = 1,
105
+ GET_VIDEO_TRACK_FAILED = "GET_VIDEO_TRACK_FAILED",
206
106
 
207
107
  /**
208
- * Played at the local device and sent to the remote devices.
108
+ * Failure of getting audio track
209
109
  */
210
- PLAYOUT_AND_PUBLISH = 2
211
- }
212
- declare enum AudioMixingState {
213
-
214
- AUDIO_MIXING_STATE_PRELOADED = 0,
215
-
216
- AUDIO_MIXING_STATE_PLAYING = 1,
110
+ GET_AUDIO_TRACK_FAILED = "GET_AUDIO_TRACK_FAILED",
217
111
 
218
- AUDIO_MIXING_STATE_PAUSED = 2,
112
+ /**
113
+ * Failure of getting screen track
114
+ */
115
+ GET_SCREEN_TRACK_FAILED = "GET_SCREEN_TRACK_FAILED",
219
116
 
220
- AUDIO_MIXING_STATE_STOPPED = 3,
117
+ /**
118
+ * Stream type mismatched. RTC SDK will emit this error code when you enable the local media device after enabling the custom video module.
119
+ */
120
+ STREAM_TYPE_NOT_MATCH = "STREAM_TYPE_NOT_MATCH",
221
121
 
222
- AUDIO_MIXING_STATE_FAILED = 4,
122
+ /**
123
+ * Cannot find the DOM specified to play the video.
124
+ */
125
+ CANT_FIND_DOM = "CANT_FIND_DOM",
223
126
 
224
- AUDIO_MIXING_STATE_FINISHED = 5,
127
+ /**
128
+ * Invalid device ID
129
+ */
130
+ INVALID_DEVICE_ID = "INVALID_DEVICE_ID",
225
131
 
226
- AUDIO_MIXING_STATE_PCM_ENABLED = 6,
132
+ /**
133
+ * No permission for capture
134
+ */
135
+ NO_PERMISSION = "NO_PERMISSION",
227
136
 
228
- AUDIO_MIXING_STATE_PCM_DISABLED = 7
229
- }
230
-
231
- /**
232
- * @type keytype
233
- * Mixing configuration
234
- */
235
- export interface MixOption {
137
+ /**
138
+ * The browser does not support capture.
139
+ */
140
+ NOT_SUPPORTED = "NOT_SUPPORTED",
236
141
 
237
142
  /**
238
- * Mix playback times
239
- * @notes <br>
240
- * + Play_count < = 0: Infinite loop <br>
241
- * + Play_count == 1: Play once (default) <br>
242
- * + Play_count > 1: Play play_count times
143
+ * Failure of requesting an ICE node
243
144
  */
244
- playCount: number;
145
+ ICE_SERVER_WRONG = "ICE_SERVER_WRONG",
245
146
 
246
147
  /**
247
- * For mixing playback types. Refer to [AudioMixingType](#audiomixingtype).
148
+ * Failure of establishing a datachannel
248
149
  */
249
- type?: AudioMixingType;
250
- }
251
- declare class EnhancedEventEmitter<EventTypes extends ValidEventTypes = string | symbol> extends EventEmitter<EventTypes> {
252
- constructor();
253
- safeEmit<T extends EventNames<EventTypes>>(event: T, ...args: EventArgs<EventTypes, T>): boolean;
254
- safeEmitAsPromise(event: string, ...args: any[]): Promise<any>;
255
- }
256
-
257
- /**
258
- * Information of media device
259
- */
260
- export interface RTCDevice {
150
+ ESTABLISH_DATACHANNEL_FAILED = "ESTABLISH_DATACHANNEL_FAILED",
261
151
 
262
152
  /**
263
- * Device ID
264
- * Refer to the [browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)
153
+ * Failure of loading network resource
265
154
  */
266
- deviceId: MediaDeviceInfo["deviceId"];
155
+ LOAD_RESOURCES_FAILED = "LOAD_RESOURCES_FAILED",
267
156
 
268
157
  /**
269
- * Device type
270
- * Refer to the [browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)
158
+ * Failure of building the signal channel
271
159
  */
272
- deviceType: MediaDeviceInfo["kind"];
160
+ SIGNALING_CHANNEL_NOT_OPEN = "SIGNALING_CHANNEL_NOT_OPEN",
273
161
 
274
162
  /**
275
- * Device information
276
- * Refer to the [browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)
163
+ * Request timeout
277
164
  */
278
- deviceInfo: MediaDeviceInfo;
165
+ TIME_OUT = "TIME_OUT",
279
166
 
280
167
  /**
281
- * Device label
282
- * Refer to the [browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)
168
+ * Request is denied for the reason of network disconnected.
283
169
  */
284
- deviceName: MediaDeviceInfo["label"];
170
+ REFUSE_OPERATION_IN_DISCONNECT = "REFUSE_OPERATION_IN_DISCONNECT",
285
171
 
286
172
  /**
287
- * Device state
173
+ * Failure of building a peer-connection to the signal server for the failure of building transceiver
288
174
  */
289
- deviceState: "active" | "inactive";
290
- }
291
- declare enum ErrorCode {
175
+ ADD_TRANSCEIVER_FAILED = "ADD_TRANSCEIVER_FAILED",
292
176
 
293
177
  /**
294
- * Invalid argument of the `engine` object for calling destroyEngine
178
+ * Failure of updating media track
295
179
  */
296
- INVALID_ENGINE = "INVALID_ENGINE",
180
+ UPDATE_TRACK_FAILED = "UPDATE_TRACK_FAILED",
297
181
 
298
182
  /**
299
- * Invalid argument
183
+ * Failure of publishing a media stream
300
184
  */
301
- INVALID_PARAMS = "INVALID_PARAMS",
185
+ PUBLISH_FAILED = "PUBLISH_FAILED",
302
186
 
303
187
  /**
304
- * Token is invalid or has expired.
188
+ * Failure of un-publishing a media stream
305
189
  */
306
- INVALID_TOKEN = "INVALID_TOKEN",
190
+ UNPUBLISH_FAILED = "UNPUBLISH_FAILED",
307
191
 
308
192
  /**
309
- * Failure of joining room
193
+ * Failure of subscribing a media stream
310
194
  */
311
- JOIN_ROOM_FAILED = "JOIN_ROOM_FAILED",
195
+ SUBSCRIBE_FAILED = "SUBSCRIBE_FAILED",
312
196
 
313
197
  /**
314
- * Join the same room repeatedly.
198
+ * Failure of unsubscribing a media stream
315
199
  */
316
- REPEAT_JOIN = "REPEAT_JOIN",
200
+ UNSUBSCRIBE_FAILED = "UNSUBSCRIBE_FAILED",
317
201
 
318
202
  /**
319
- * Publish media stream repeatedly.
203
+ * Call [leaveRoom](#leaveroom)Process of publishing and subscribing will
204
+ * RTC SDK will emit this error code when you call the [leaveRoom](#leaveroom) during the process of publishing or subscribing.
320
205
  */
321
- REPEAT_PUBLISH = "REPEAT_PUBLISH",
206
+ OPERATION_CANCEL = "OPERATION_CANCEL",
322
207
 
323
208
  /**
324
- * Publish before joining a room.
209
+ * Unknown error
325
210
  */
326
- PUBLISH_BEFORE_JOIN = "PUBLISH_BEFORE_JOIN",
211
+ UNEXPECTED_ERROR = "UNEXPECTED_ERROR",
212
+ ALREADY_LOGIN = "ALREADY_LOGIN",
213
+ LOGIN_FAILED = "LOGIN_FAILED",
214
+ NOT_LOGIN = "NOT_LOGIN",
215
+ RTM_DUPLICATE_LOGIN = "RTM_DUPLICATE_LOGIN",
216
+ RTM_TOKEN_ERROR = "RTM_TOKEN_ERROR",
217
+ /** RTM p2p消息错误码 */
218
+ USER_MESSAGE_TIMEOUT = "USER_MESSAGE_TIMEOUT",
219
+ USER_MESSAGE_BROKEN = "USER_MESSAGE_BROKEN",
220
+ USER_MESSAGE_NO_RECEIVER = "USER_MESSAGE_NO_RECEIVER",
221
+ USER_MESSAGE_NO_RELAYPATH = "USER_MESSAGE_NO_RELAYPATH",
222
+ USER_MESSAGE_SEND_TO_SERVER_ERROR = "USER_MESSAGE_SEND_TO_SERVER_ERROR",
223
+ USER_MESSAGE_SERVER_RESPONSE_ERROR = "USER_MESSAGE_SERVER_RESPONSE_ERROR",
224
+ USER_MESSAGE_NOT_JOIN = "USER_MESSAGE_NOT_JOIN",
225
+ USER_MESSAGE_INIT = "USER_MESSAGE_INIT",
226
+ USER_MESSAGE_NO_CONNECTION = "USER_MESSAGE_NO_CONNECTION",
227
+ USER_MESSAGE_EXCEED_MAX_LENGTH = "USER_MESSAGE_EXCEED_MAX_LENGTH",
228
+ USER_MESSAGE_EMPTY_USER = "USER_MESSAGE_EMPTY_USER",
229
+ USER_MESSAGE_NOT_LOGIN = "USER_MESSAGE_NOT_LOGIN",
230
+ USER_MESSAGE_SERVER_PARAMS_NOTSET = "USER_MESSAGE_SERVER_PARAMS_NOTSET",
231
+ USER_MESSAGE_UNKNOWN = "USER_MESSAGE_UNKNOWN"
232
+ }
233
+ declare enum AudioMixingError {
327
234
 
328
235
  /**
329
- * Un-publish before joining a room.
236
+ * Normal
330
237
  */
331
- UNPUBLISH_BEFORE_JOIN = "UNPUBLISH_BEFORE_JOIN",
238
+ AUDIO_MIXING_ERROR_OK = 0,
332
239
 
333
240
  /**
334
- * Subscribe before joining a room.
241
+ * Pre-load fails because of missing audio file or the length of the audio file exceeding 20s.
335
242
  */
336
- SUBSCRIBE_BEFORE_JOIN = "SUBSCRIBE_BEFORE_JOIN",
243
+ AUDIO_MIXING_ERROR_PRELOAD_FAILED = 1,
337
244
 
338
245
  /**
339
- * Unsubscribe before joining a room.
246
+ * Audio mixing starts fails because of missing audio file or failure of reading the audio file.
340
247
  */
341
- UNSUBSCRIBE_BEFORE_JOIN = "UNSUBSCRIBE_BEFORE_JOIN",
248
+ AUDIO_MIXING_ERROR_START_FAILED = 2,
342
249
 
343
250
  /**
344
- * Request to publish media stream as an invisible user.
251
+ * Invalid audio mixing ID
345
252
  */
346
- NO_PUBLISH_PERMISSION = "NO_PUBLISH_PERMISSION",
253
+ AUDIO_MIXING_ERROR_ID_NOT_FOUND = 3,
347
254
 
348
255
  /**
349
- * Request to subscribe or unsubscribe a stream that doesn't exist.
256
+ * Invalid start position
350
257
  */
351
- STREAM_NOT_EXIST = "STREAM_NOT_EXIST",
258
+ AUDIO_MIXING_ERROR_SET_POSITION_FAILED = 4,
352
259
 
353
260
  /**
354
- * Request to publish an empty stream.
261
+ * Invalid volume argument. The volume value ranges [0, 400].
355
262
  */
356
- EMPTY_STREAM = "EMPTY_STREAM",
263
+ AUDIO_MIXING_ERROR_INVALID_VOLUME = 5,
357
264
 
358
265
  /**
359
- * Network disconnected. RTC SDk will emit this error code if you call publish, subscribe or the other related methods while the user has not joined a room.
266
+ * The audio file to be played does not match to the preload one. Call `unloadAudioMixing` to unload file and proceed.
360
267
  */
361
- NOT_CONNECTED_YET = "NOT_CONNECTED_YET",
268
+ AUDIO_MIXING_ERROR_LOAD_CONFLICT = 6,
362
269
 
363
270
  /**
364
- * Request to send message before the user has joined a room.
271
+ * Type of the audio file to be played is not supported.
365
272
  */
366
- IM_BEFORE_JOIN = "IM_BEFORE_JOIN",
273
+ AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH = 7,
367
274
 
368
275
  /**
369
- * The user does not exist.
276
+ * Invalid audio pitch
370
277
  */
371
- USER_NOT_EXIST = "USER_NOT_EXIST",
278
+ AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH = 8,
372
279
 
373
280
  /**
374
- * The user has joined the room.
281
+ * Invalid audio track
375
282
  */
376
- ALREADY_IN_ROOM = "ALREADY_IN_ROOM",
283
+ AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK = 9
284
+ }
285
+ /**
286
+ * @list 104477
287
+ * @detail 104478
288
+ */
289
+ /**
290
+ * @list 104477
291
+ * @detail 104478
292
+ */
293
+ export interface IAudioMixingManager {
377
294
 
378
295
  /**
379
- * The user is kicked out because a user with the same userId joined the room.
296
+ * Start playing audio files and mixes. <br>
297
+ * This method can be called many times by passing in different IDs and filepath to realize simultaneous playback of multiple mixing files and mixing overlay.
298
+ * @param id Mix ID. For identifying the mix, please ensure that the mix ID is unique. <br>
299
+ * If this method is repeatedly called with the same ID, the previous mix stops and the next mix starts.
300
+ * @param filePath Specify the file path either the absolute path of a local file or the url of online audio. Files with the extension of mp3 and aac are supported.
301
+ * @param config Mix Sound configuration <br>
302
+ * You can set the number of times the mix is played, whether the mix is played locally, and whether the mix is sent to the remote end. For details.
303
+ * @return
304
+ * @notes <br>
305
+ * + If you have already loaded the sound effect into memory through preloadAudioMixing{@link #preloadAudioMixing}, make sure that the ID here is the same as the ID set by preloadAudioMixing{@link #preloadAudioMixing}. <br>
306
+ * + After you start playing the audio file and mixing, you can call the stopAudioMixing{@link #stopAudioMixing} method to stop playing the audio file. <br>
307
+ * + The mixing data of this method comes from an external file, while the mixing data of enableAudioMixingFrame{@link #enableAudioMixingFrame} comes from an external cache and the audio format is PCM. These two mixing methods can coexist.
308
+ * @region Advanced Feature
380
309
  */
381
- DUPLICATE_LOGIN = "DUPLICATE_LOGIN",
310
+ startAudioMixing(id: number, filePath: string, options: MixOption): Promise<void>;
382
311
 
383
312
  /**
384
- * Enable capture repeatedly.
313
+ * Stop playing audio files and mixes
314
+ * @param id ID of the mixing
315
+ * @notes <br>
316
+ * + After calling startAudioMixing{@link #startAudioMixing} method to start playing audio files and mixes, you can call this method to stop playing audio files and mixes. <br>
317
+ * + After calling this method to stop playing the audio file, the audio file will be automatically uninstalled.
318
+ * @region Advanced Feature
385
319
  */
386
- REPEAT_CAPTURE = "REPEAT_CAPTURE",
320
+ stopAudioMixing(id: number): void;
387
321
 
388
322
  /**
389
- * Failure of video capture
323
+ * Pause playing audio files and mixes
324
+ * @param id ID of the mixing
325
+ * @notes <br>
326
+ * + After calling startAudioMixing{@link #startAudioMixing} method to start playing audio files and mixes, you can call this method to pause playing audio files and mixes. <br>
327
+ * + After calling this method to pause playing audio files and mixing, you can call the resumeAudioMixing{@link #resumeAudioMixing} method to resume playing and mixing. <br>
328
+ * @region Advanced Feature
390
329
  */
391
- GET_VIDEO_TRACK_FAILED = "GET_VIDEO_TRACK_FAILED",
330
+ pauseAudioMixing(id: number): void;
392
331
 
393
332
  /**
394
- * Failure of getting audio track
333
+ * Resume playing audio files and mixing
334
+ * @param id Mixing ID
335
+ * @notes After calling the pauseAudioMixing{@link #pauseAudioMixing} method to pause playing audio files and mixing, you can resume playing and mixing by calling this method. <br>
336
+ * @region Advanced Feature
395
337
  */
396
- GET_AUDIO_TRACK_FAILED = "GET_AUDIO_TRACK_FAILED",
338
+ resumeAudioMixing(id: number): void;
397
339
 
398
340
  /**
399
- * Failure of getting screen track
341
+ * Preload the specified audio file into memory
342
+ * @param id Mix ID. For identifying the mix, please ensure that the mix ID is unique. <br>
343
+ * If this method is called repeatedly with the same ID, the latter overrides the previous. <br>
344
+ * If you call startAudioMixing{@link #startAudioMixing} and then call this method with the same ID, the previous mix stopped, and then the next mix was loaded. <br>
345
+ * After calling this method with an ID to preload A.mp3, if you need to call startAudioMixing{@link #startAudioMixing} to play B.mp3 with the same ID, please call unloadAudioMixing{@link #unloadAudioMixing} to uninstall A.mp3 first, otherwise you will report an error AUDIO_MIXING_ERROR_LOAD_CONFLICT.
346
+ * @param filePath Used for mixing file paths. It can be the absolute path of the local file or the url of the online audio. <br>
347
+ * @return
348
+ * @notes <br>
349
+ * + When you need to play an audio file frequently, call this method to preload the file. When playing, you can only load the file once to reduce CPU usage. <br>
350
+ * + This method pre-loads the specified audio file, and only calling startAudioMixing{@link #startAudioMixing} API can you start playing the specified audio file. <br>
351
+ * + The specified audio file preloaded by calling this method can be unloaded through unloadAudioMixing{@link #unloadAudioMixing}.
352
+ * @region Advanced Feature
400
353
  */
401
- GET_SCREEN_TRACK_FAILED = "GET_SCREEN_TRACK_FAILED",
354
+ preloadAudioMixing(id: number, filePath: string): Promise<void>;
402
355
 
403
356
  /**
404
- * Stream type mismatched. RTC SDK will emit this error code when you enable the local media device after enabling the custom video module.
357
+ * Uninstall the specified audio file
358
+ * @param id Mix ID
359
+ * @region Advanced Feature
405
360
  */
406
- STREAM_TYPE_NOT_MATCH = "STREAM_TYPE_NOT_MATCH",
361
+ unloadAudioMixing(id: number): void;
407
362
 
408
363
  /**
409
- * Cannot find the DOM specified to play the video.
364
+ * Adjust the volume of audio mixing, including audio files and PCM data.
365
+ * @param id Mixing ID
366
+ * @param volume The ratio of the mixing volume to the original volume. The range is `[0, 400]`. The recommended range is `[0, 100]`. <br>
367
+ * + 0: Mute <br>
368
+ * + 100: Original volume <br>
369
+ * + 400: Maximum volume (with overflow protection)
370
+ * @region Advanced Feature
410
371
  */
411
- CANT_FIND_DOM = "CANT_FIND_DOM",
372
+ setAudioMixingVolume(id: number, volume: number): void;
412
373
 
413
374
  /**
414
- * Invalid device ID
375
+ * Get volume of the audio files.
376
+ * @param id Audio mix id
377
+ * @return <br>
378
+ * + `0`: Failure<br>
379
+ * + `>0`: Successful. Volume<br>
380
+ * @region Advanced Feature
415
381
  */
416
- INVALID_DEVICE_ID = "INVALID_DEVICE_ID",
382
+ getAudioMixingVolume(id: number): number;
417
383
 
418
384
  /**
419
- * No permission for capture
385
+ * Get audio file duration
386
+ * @param id Mix ID
387
+ * @return <br>
388
+ * + > 0: Success, audio file duration, in milliseconds. <br>
389
+ * + < 0: Failure
390
+ * @notes Before calling this method to obtain the length of the audio file, you need to call preloadAudioMixing{@link #preloadAudioMixing} or startAudioMixing{@link #startAudioMixing}.
391
+ * @region Advanced Feature
420
392
  */
421
- NO_PERMISSION = "NO_PERMISSION",
393
+ getAudioMixingDuration(id: number): number;
422
394
 
423
395
  /**
424
- * The browser does not support capture.
396
+ * Get audio file playback progress
397
+ * @param id Mix ID
398
+ * @return <br>
399
+ * + > 0: Success, audio file playback progress, in milliseconds. <br>
400
+ * + < 0: Failed
401
+ * @notes Before calling this method to get the audio file playback progress, you need to call startAudioMixing{@link #startAudioMixing} to start playing the audio file.
402
+ * @region Advanced Feature
425
403
  */
426
- NOT_SUPPORTED = "NOT_SUPPORTED",
404
+ getAudioMixingCurrentPosition(id: number): number;
427
405
 
428
406
  /**
429
- * Failure of requesting an ICE node
407
+ * Set the starting playback position of the audio file
408
+ * @param id Mixing ID
409
+ * @param position The starting playback position of the audio file in milliseconds.
410
+ * @notes <br>
411
+ * + This method allows you to play an audio file from a specified position as appropriate, without having to play an audio file in its entirety from the beginning to finish. <br>
412
+ * + Before calling this method to set the playback position of the audio file, you need to call startAudioMixing{@link #startAudioMixing} to start playing the audio file.
413
+ * @region Advanced Feature
430
414
  */
431
- ICE_SERVER_WRONG = "ICE_SERVER_WRONG",
415
+ setAudioMixingPosition(id: number, position: number): void;
432
416
 
433
417
  /**
434
- * Failure of establishing a datachannel
418
+ * Start PCM mixing. <br>
419
+ * To mix multiple PCM audio data, call this API multiple times with different ids.
420
+ * @param type Mixing type <br>
421
+ * Whether the PCM data is mixed locally and sent to the remotes.
422
+ * @notes <br>
423
+ * + After this API, you must call pushAudioMixingFrame{@link #pushAudioMixingFrame} to start mixing. <br>
424
+ * + To end PCM mixing, use disableAudioMixingFrame{@link #disableAudioMixingFrame}.
425
+ * @region Advanced Feature
435
426
  */
436
- ESTABLISH_DATACHANNEL_FAILED = "ESTABLISH_DATACHANNEL_FAILED",
427
+ enableAudioMixingBuffer(type: AudioMixingType): void;
437
428
 
438
429
  /**
439
- * Failure of loading network resource
430
+ * Disable PCM mixing.
431
+ * @region Advanced Feature
440
432
  */
441
- LOAD_RESOURCES_FAILED = "LOAD_RESOURCES_FAILED",
433
+ disableAudioMixingBuffer(): void;
442
434
 
443
435
  /**
444
- * Failure of building the signal channel
436
+ * Push PCM audio frame data for mixing
437
+ * @param buffer Refer to [Browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer)
438
+ * @notes Before calling this method, you must start the external audio stream mixing through enableAudioMixingFrame{@link #enableAudioMixingFrame}. <br>
439
+ * @region Advanced Feature
445
440
  */
446
- SIGNALING_CHANNEL_NOT_OPEN = "SIGNALING_CHANNEL_NOT_OPEN",
441
+ pushAudioMixingBuffer(buffer: AudioBuffer): void;
442
+ }
443
+
444
+ /**
445
+ * @type keytype
446
+ * Mix playback channel type
447
+ */
448
+ export declare enum AudioMixingDualMonoMode {
447
449
 
448
450
  /**
449
- * Request timeout
451
+ * Consistent with audio files
450
452
  */
451
- TIME_OUT = "TIME_OUT",
453
+ AUTO = 0,
452
454
 
453
455
  /**
454
- * Request is denied for the reason of network disconnected.
456
+ * Only the left channel audio in the audio file can be heard
455
457
  */
456
- REFUSE_OPERATION_IN_DISCONNECT = "REFUSE_OPERATION_IN_DISCONNECT",
458
+ MODE_L = 1,
457
459
 
458
460
  /**
459
- * Failure of building a peer-connection to the signal server for the failure of building transceiver
461
+ * Only the right channel audio in the audio file can be heard
460
462
  */
461
- ADD_TRANSCEIVER_FAILED = "ADD_TRANSCEIVER_FAILED",
463
+ MODE_R = 2,
462
464
 
463
465
  /**
464
- * Failure of updating media track
466
+ * Can hear the left and right audio channels in the audio file at the same time
465
467
  */
466
- UPDATE_TRACK_FAILED = "UPDATE_TRACK_FAILED",
468
+ MODE_MIX = 3
469
+ }
470
+
471
+ /**
472
+ * @type keytype
473
+ * Mixing type
474
+ */
475
+ export declare enum AudioMixingType {
467
476
 
468
477
  /**
469
- * Failure of publishing a media stream
478
+ * Played at the local device only
470
479
  */
471
- PUBLISH_FAILED = "PUBLISH_FAILED",
480
+ PLAYOUT = 0,
472
481
 
473
482
  /**
474
- * Failure of un-publishing a media stream
483
+ * Sent to the remote devices only
475
484
  */
476
- UNPUBLISH_FAILED = "UNPUBLISH_FAILED",
485
+ PUBLISH = 1,
477
486
 
478
487
  /**
479
- * Failure of subscribing a media stream
488
+ * Played at the local device and sent to the remote devices.
480
489
  */
481
- SUBSCRIBE_FAILED = "SUBSCRIBE_FAILED",
490
+ PLAYOUT_AND_PUBLISH = 2
491
+ }
492
+ declare enum AudioMixingState {
482
493
 
483
- /**
484
- * Failure of unsubscribing a media stream
485
- */
486
- UNSUBSCRIBE_FAILED = "UNSUBSCRIBE_FAILED",
494
+ AUDIO_MIXING_STATE_PRELOADED = 0,
487
495
 
488
- /**
489
- * Call [leaveRoom](#leaveroom)Process of publishing and subscribing will
490
- * RTC SDK will emit this error code when you call the [leaveRoom](#leaveroom) during the process of publishing or subscribing.
491
- */
492
- OPERATION_CANCEL = "OPERATION_CANCEL",
496
+ AUDIO_MIXING_STATE_PLAYING = 1,
493
497
 
494
- /**
495
- * Unknown error
496
- */
497
- UNEXPECTED_ERROR = "UNEXPECTED_ERROR"
498
- }
499
- declare enum AudioMixingError {
498
+ AUDIO_MIXING_STATE_PAUSED = 2,
500
499
 
501
- /**
502
- * Normal
503
- */
504
- AUDIO_MIXING_ERROR_OK = 0,
500
+ AUDIO_MIXING_STATE_STOPPED = 3,
505
501
 
506
- /**
507
- * Pre-load fails because of missing audio file or the length of the audio file exceeding 20s.
508
- */
509
- AUDIO_MIXING_ERROR_PRELOAD_FAILED = 1,
502
+ AUDIO_MIXING_STATE_FAILED = 4,
510
503
 
511
- /**
512
- * Audio mixing starts fails because of missing audio file or failure of reading the audio file.
513
- */
514
- AUDIO_MIXING_ERROR_START_FAILED = 2,
504
+ AUDIO_MIXING_STATE_FINISHED = 5,
505
+
506
+ AUDIO_MIXING_STATE_PCM_ENABLED = 6,
507
+
508
+ AUDIO_MIXING_STATE_PCM_DISABLED = 7
509
+ }
510
+
511
+ /**
512
+ * @type keytype
513
+ * Mixing configuration
514
+ */
515
+ export interface MixOption {
515
516
 
516
517
  /**
517
- * Invalid audio mixing ID
518
+ * Mix playback times
519
+ * @notes <br>
520
+ * + Play_count < = 0: Infinite loop <br>
521
+ * + Play_count == 1: Play once (default) <br>
522
+ * + Play_count > 1: Play play_count times
518
523
  */
519
- AUDIO_MIXING_ERROR_ID_NOT_FOUND = 3,
524
+ playCount: number;
520
525
 
521
526
  /**
522
- * Invalid start position
527
+ * For mixing playback types. Refer to [AudioMixingType](#audiomixingtype).
523
528
  */
524
- AUDIO_MIXING_ERROR_SET_POSITION_FAILED = 4,
529
+ type?: AudioMixingType;
530
+ }
531
+ declare class EnhancedEventEmitter<EventTypes extends ValidEventTypes = string | symbol> extends EventEmitter<EventTypes> {
532
+ constructor();
533
+ safeEmit<T extends EventNames<EventTypes>>(event: T, ...args: EventArgs<EventTypes, T>): boolean;
534
+ safeEmitAsPromise(event: string, ...args: any[]): Promise<any>;
535
+ }
536
+
537
+ /**
538
+ * Information of media device
539
+ */
540
+ export interface RTCDevice {
525
541
 
526
542
  /**
527
- * Invalid volume argument. The volume value ranges [0, 400].
543
+ * Device ID
544
+ * Refer to the [browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)
528
545
  */
529
- AUDIO_MIXING_ERROR_INVALID_VOLUME = 5,
546
+ deviceId: MediaDeviceInfo["deviceId"];
530
547
 
531
548
  /**
532
- * The audio file to be played does not match to the preload one. Call `unloadAudioMixing` to unload file and proceed.
549
+ * Device type
550
+ * Refer to the [browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)
533
551
  */
534
- AUDIO_MIXING_ERROR_LOAD_CONFLICT = 6,
552
+ deviceType: MediaDeviceInfo["kind"];
535
553
 
536
554
  /**
537
- * Type of the audio file to be played is not supported.
555
+ * Device information
556
+ * Refer to the [browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)
538
557
  */
539
- AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH = 7,
558
+ deviceInfo: MediaDeviceInfo;
540
559
 
541
560
  /**
542
- * Invalid audio pitch
561
+ * Device label
562
+ * Refer to the [browser documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)
543
563
  */
544
- AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH = 8,
564
+ deviceName: MediaDeviceInfo["label"];
545
565
 
546
566
  /**
547
- * Invalid audio track
567
+ * Device state
548
568
  */
549
- AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK = 9
569
+ deviceState: "active" | "inactive";
550
570
  }
551
571
 
552
572
  /**
@@ -1209,7 +1229,9 @@ declare enum EngineEventsTypes {
1209
1229
  onLiveTranscodingResult = "onLiveTranscodingResult",
1210
1230
  onSEIMessageReceived = "onSEIMessageReceived",
1211
1231
  onError = "onError",
1212
- onAudioMixingStateChanged = "onAudioMixingStateChanged"
1232
+ onAudioMixingStateChanged = "onAudioMixingStateChanged",
1233
+ onUserMessageReceivedOutsideRoom = "onUserMessageReceivedOutsideRoom",
1234
+ onUserBinaryMessageReceivedOutsideRoom = "onUserBinaryMessageReceivedOutsideRoom"
1213
1235
  }
1214
1236
 
1215
1237
  /**
@@ -1601,7 +1623,7 @@ export interface IEngineEvents {
1601
1623
  * @region Room Management Event
1602
1624
  */
1603
1625
  [EngineEventsTypes.onError]: (event: {
1604
- errorCode: ErrorCode.DUPLICATE_LOGIN;
1626
+ errorCode: ErrorCode.DUPLICATE_LOGIN | ErrorCode.RTM_DUPLICATE_LOGIN | ErrorCode.RTM_TOKEN_ERROR;
1605
1627
  }) => void;
1606
1628
 
1607
1629
  /**
@@ -1610,6 +1632,8 @@ export interface IEngineEvents {
1610
1632
  * @region Advanced Feature
1611
1633
  */
1612
1634
  [EngineEventsTypes.onAudioMixingStateChanged]: (event: AudioMixingStateChangedEvent) => void;
1635
+ [EngineEventsTypes.onUserMessageReceivedOutsideRoom]: (event: UserMessageEvent) => void;
1636
+ [EngineEventsTypes.onUserBinaryMessageReceivedOutsideRoom]: (event: UserBinaryMessageEvent) => void;
1613
1637
  }
1614
1638
 
1615
1639
  /**
@@ -2125,6 +2149,15 @@ export interface IRTCEngine extends EnhancedEventEmitter<IEngineEvents> {
2125
2149
  * @region Video Management
2126
2150
  */
2127
2151
  setVideoCaptureConfig(config: TrackCaptureConfig): Promise<void>;
2152
+ login(token: string | null, userId: string): Promise<void>;
2153
+ logout(): Promise<void>;
2154
+ updateLoginToken(token: string | null): Promise<void>;
2155
+ getPeerOnlineStatus(userId: string): Promise<USER_ONLINE_STATUS>;
2156
+ sendUserMessageOutsideRoom(userId: string, message: string): Promise<any>;
2157
+ sendUserBinaryMessageOutsideRoom(userId: string, message: ArrayBuffer): Promise<any>;
2158
+ setServerParams(signature: string, url: string): Promise<any>;
2159
+ sendServerMessage(message: string): Promise<any>;
2160
+ sendServerBinaryMessage(message: ArrayBuffer): Promise<any>;
2128
2161
  }
2129
2162
 
2130
2163
  /**
@@ -2741,7 +2774,7 @@ export interface LiveTranscodeAudioConfig {
2741
2774
  /**
2742
2775
  * The AAC profile to be set
2743
2776
  */
2744
- AACProfile?: "LC" | "MAIN" | "HEv1" | "HEv2";
2777
+ AACProfile?: "LC" | "HEv1" | "HEv2";
2745
2778
  }
2746
2779
 
2747
2780
  /**
@@ -2852,6 +2885,11 @@ export interface RemoteStreamKey {
2852
2885
  */
2853
2886
  streamIndex: StreamIndex;
2854
2887
  }
2888
+ export declare enum USER_ONLINE_STATUS {
2889
+ OFFLINE = 0,
2890
+ ONLINE = 1,
2891
+ UNREACHABLE = 2
2892
+ }
2855
2893
 
2856
2894
  /**
2857
2895
  * Point-to-point text message
@@ -3004,7 +3042,7 @@ export interface IVERTC {
3004
3042
  * - `False`: Not Supported
3005
3043
  * @region Engine Management
3006
3044
  */
3007
- isSupported: () => boolean;
3045
+ isSupported: () => Promise<boolean>;
3008
3046
  }
3009
3047
  declare class VERTC implements IVERTC {
3010
3048
  getSdkVersion: () => string;
@@ -3023,7 +3061,7 @@ declare class VERTC implements IVERTC {
3023
3061
  getAudioPlayback: () => Promise<RTCDevice[]>;
3024
3062
  getParameter: typeof getParameter;
3025
3063
  setParameter: typeof setParameter;
3026
- isSupported: () => boolean;
3064
+ isSupported: () => Promise<boolean>;
3027
3065
  events: typeof EngineEventsTypes;
3028
3066
  ErrorCode: typeof ErrorCode;
3029
3067
  platform: string;