@agora-js/media 4.20.2-300 → 4.21.0

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.
@@ -1,14 +1,17 @@
1
1
  import { AgoraRTCError } from '@agora-js/shared';
2
2
  import { CheckVisibleResult } from '@agora-js/shared';
3
+ import { ElectronDesktopCapturerSource } from '@agora-js/shared';
3
4
  import { EventEmitter } from '@agora-js/shared';
4
5
  import { IAudioProcessor } from 'agora-rte-extension';
5
6
  import type { IAudioProcessorContext } from 'agora-rte-extension';
6
7
  import { IBaseProcessor } from 'agora-rte-extension';
7
8
  import type { IProcessorContext } from 'agora-rte-extension';
9
+ import { isElectron } from '@agora-js/shared';
8
10
  import type { Kind } from 'agora-rte-extension';
9
11
  import type { NetworkQuality } from '@agora-js/shared';
10
12
  import type { ProcessorStats } from 'agora-rte-extension';
11
13
  import { PromiseMutex } from '@agora-js/shared';
14
+ import { RequiredOnlyOneOf } from '@agora-js/shared';
12
15
  import { SDKStore } from '@agora-js/shared';
13
16
  import { UID } from '@agora-js/shared';
14
17
  import { Usage } from 'agora-rte-extension';
@@ -36,6 +39,8 @@ export declare interface AgoraRTCCompatibility {
36
39
  supportPCSetConfiguration: boolean;
37
40
  supportWebRTCEncodedTransform: boolean;
38
41
  supportWebRTCInsertableStream: boolean;
42
+ supportRequestVideoFrameCallback: boolean;
43
+ supportWebCrypto: boolean;
39
44
  }
40
45
 
41
46
  declare class AgoraRTCPlayer extends VideoPlayer {
@@ -106,6 +111,53 @@ export declare enum AUDIO_CONTEXT_EVENT {
106
111
  STATE_CHANGE = "state-change"
107
112
  }
108
113
 
114
+ /**
115
+ * @ignore
116
+ */
117
+ export declare const AUDIO_ENCODER_CONFIG_SETTINGS: {
118
+ speech_low_quality: AudioEncoderConfiguration;
119
+ speech_standard: AudioEncoderConfiguration;
120
+ music_standard: AudioEncoderConfiguration;
121
+ standard_stereo: AudioEncoderConfiguration;
122
+ high_quality: AudioEncoderConfiguration;
123
+ high_quality_stereo: AudioEncoderConfiguration;
124
+ };
125
+
126
+ export declare enum AUDIO_TRACK_EVENT {
127
+ UPDATE_TRACK_SOURCE = "update-track-source"
128
+ }
129
+
130
+ declare class AudioBufferSource extends AudioSource {
131
+ private audioBuffer;
132
+ protected sourceNode?: AudioBufferSourceNode;
133
+ private startPlayTime;
134
+ private startPlayOffset;
135
+ private pausePlayTime;
136
+ private options;
137
+ private currentLoopCount;
138
+ private currentPlaybackSpeed;
139
+ set currentState(state: AudioSourceState);
140
+ get currentState(): AudioSourceState;
141
+ private _currentState;
142
+ constructor(buffer: AudioBuffer, options?: AudioSourceOptions);
143
+ createWebAudioDiagram(): GainNode;
144
+ get duration(): number;
145
+ get playbackSpeed(): number;
146
+ get currentTime(): number;
147
+ updateOptions(options: AudioSourceOptions): void;
148
+ startProcessAudioBuffer(): void;
149
+ pauseProcessAudioBuffer(): void;
150
+ seekAudioBuffer(time: number): void;
151
+ resumeProcessAudioBuffer(): void;
152
+ stopProcessAudioBuffer(): void;
153
+ destroy(): void;
154
+ setAudioBufferPlaybackSpeed(speed: number): void;
155
+ private startSourceNode;
156
+ private createSourceNode;
157
+ private handleSourceNodeEnded;
158
+ private reset;
159
+ }
160
+
109
161
  export declare const audioContextState: AudioState;
110
162
 
111
163
  declare class AudioElementPlayCenter {
@@ -130,6 +182,59 @@ declare class AudioElementPlayCenter {
130
182
 
131
183
  export declare const audioElementPlayCenter: AudioElementPlayCenter;
132
184
 
185
+ /**
186
+ *
187
+ * `AudioEncoderConfiguration` is the interface that defines the audio encoder configurations.
188
+ *
189
+ * You can customize the audio encoder configurations when calling [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack}, [AgoraRTC.createMicrophoneAudioTrack]{@link IAgoraRTC.createMicrophoneAudioTrack} or [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack}.
190
+ */
191
+ export declare interface AudioEncoderConfiguration {
192
+ /**
193
+ * Sample rate of the audio (Hz).
194
+ */
195
+ sampleRate?: number;
196
+ /**
197
+ * Sample size of the audio.
198
+ */
199
+ sampleSize?: number;
200
+ /**
201
+ * Whether to enable stereo.
202
+ */
203
+ stereo?: boolean;
204
+ /**
205
+ * Bitrate of the audio (Kbps).
206
+ */
207
+ bitrate?: number;
208
+ }
209
+
210
+ /**
211
+ * The preset audio encoder configurations.
212
+ *
213
+ * You can pass the preset video encoder configurations when calling the following methods:
214
+ * - [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack}
215
+ * - [AgoraRTC.createMicrophoneAudioTrack]{@link IAgoraRTC.createMicrophoneAudioTrack}
216
+ * - [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack}
217
+ *
218
+ * The following table lists all the preset audio profiles. The SDK uses `"music_standard"` by default.
219
+ *
220
+ * | Audio Profile | Configurations |
221
+ * | -------- | --------------- |
222
+ * |`"speech_low_quality"`|Sample rate 16 kHz, mono, encoding bitrate 24 Kbps|
223
+ * |`"speech_standard"`|Sample rate 32 kHz, mono, encoding bitrate 24 Kbps|
224
+ * |`"music_standard"`|Sample rate 48 kHz, mono, encoding bitrate 32 Kbps|
225
+ * |`"standard_stereo"`|Sample rate 48 kHz, stereo, encoding bitrate 64 Kbps|
226
+ * |`"high_quality"`|Sample rate 48 kHz, mono, encoding bitrate 128 Kbps|
227
+ * |`"high_quality_stereo"`|Sample rate 48 kHz, stereo, encoding bitrate 192 Kbps| Kbps.
228
+ * @public
229
+ */
230
+ export declare type AudioEncoderConfigurationPreset = keyof typeof AUDIO_ENCODER_CONFIG_SETTINGS;
231
+
232
+ export declare interface AudioPlaybackOptions {
233
+ origin?: boolean;
234
+ mixing?: boolean;
235
+ effect?: boolean;
236
+ }
237
+
133
238
  export declare class AudioProcessorContext extends EventEmitter implements IAudioProcessorContext {
134
239
  private constraintsMap;
135
240
  private statsRegistry;
@@ -217,6 +322,24 @@ export declare enum AudioSourceEvents {
217
322
  UPDATE_SOURCE = "update_source"
218
323
  }
219
324
 
325
+ /**
326
+ * Options for processing the audio buffer. You need to set the options for processing the audio buffer when calling [startProcessAudioBuffer]{@link IBufferSourceAudioTrack.startProcessAudioBuffer}.
327
+ */
328
+ export declare interface AudioSourceOptions {
329
+ /**
330
+ * How many times the audio loops.
331
+ */
332
+ cycle?: number;
333
+ /**
334
+ * Whether to loop the audio infinitely.
335
+ */
336
+ loop?: boolean;
337
+ /**
338
+ * The playback position (seconds).
339
+ */
340
+ startPlayTime?: number;
341
+ }
342
+
220
343
  /**
221
344
  * Processing state of the audio buffer:
222
345
  * - `"stopped"`: The SDK stops processing the audio buffer. Reasons may include:
@@ -234,7 +357,12 @@ declare class AudioState extends EventEmitter {
234
357
  curState: AudioContextState | "interrupted" | undefined;
235
358
  currentTime?: number;
236
359
  currentTimeStuckAt?: number;
360
+ private interruptDetectorTrack?;
237
361
  get duringInterruption(): boolean;
362
+ private onLocalAudioTrackMute;
363
+ private onLocalAudioTrackUnmute;
364
+ bindInterruptDetectorTrack(track: MicrophoneAudioTrack): void;
365
+ unbindInterruptDetectorTrack(track: MicrophoneAudioTrack): void;
238
366
  }
239
367
 
240
368
  export declare function audioTimerLoop(callback: (time: number) => any, frequency: number): () => void;
@@ -264,14 +392,189 @@ declare class AutoPlayGestureEventEmitter extends EventEmitter {
264
392
 
265
393
  export declare const autoPlayGestureEventEmitter: AutoPlayGestureEventEmitter;
266
394
 
395
+ /**
396
+ * @ignore
397
+ *
398
+ * Image enhancement options. You need to set the image enhancement options when calling [setBeautyEffect]{@link ILocalVideoTrack.setBeautyEffect}.
399
+ */
400
+ export declare interface BeautyEffectOptions {
401
+ /**
402
+ *
403
+ * The smoothness level.
404
+ *
405
+ * The value range is [0.0, 1.0]. The original smoothness level is 0.0. The default value is 0.5. This parameter is usually used to remove blemishes.
406
+ */
407
+ smoothnessLevel?: number;
408
+ /**
409
+ * The brightness level.
410
+ *
411
+ * The value range is [0.0, 1.0]. The original brightness level is 0.0. The default value is 0.7.
412
+ */
413
+ lighteningLevel?: number;
414
+ /**
415
+ * The redness level.
416
+ *
417
+ * The value range is [0.0, 1.0]. The original redness level is 0.0. The default value is 0.1. This parameter adjusts the red saturation level.
418
+ */
419
+ rednessLevel?: number;
420
+ /**
421
+ * The contrast level. Use this together with {@link lighteningLevel}.
422
+ * - 0: Low contrast level.
423
+ * - 1: (Default) The original contrast level.
424
+ * - 2: High contrast level.
425
+ */
426
+ lighteningContrastLevel?: 0 | 1 | 2;
427
+ }
428
+
429
+ export declare interface BeautyWebGLParameters {
430
+ denoiseLevel?: number;
431
+ lightLevel?: number;
432
+ rednessLevel?: number;
433
+ lighteningContrastLevel?: number;
434
+ }
435
+
267
436
  export declare const blob2Uint8Array: (blob: Blob) => Promise<Uint8Array>;
268
437
 
438
+ export declare class BufferSourceAudioTrack extends LocalAudioTrack implements IBufferSourceAudioTrack {
439
+ source: string | File | AudioBuffer | null;
440
+ private _bufferSource;
441
+ get __className__(): string;
442
+ constructor(source: string | File | AudioBuffer, bufferSource: AudioBufferSource, encodingConfig?: AudioEncoderConfiguration, trackId?: string);
443
+ get currentState(): AudioSourceState;
444
+ get duration(): number;
445
+ get playbackSpeed(): number;
446
+ getCurrentTime(): number;
447
+ startProcessAudioBuffer(options?: AudioSourceOptions): void;
448
+ pauseProcessAudioBuffer(): void;
449
+ seekAudioBuffer(time: number): void;
450
+ resumeProcessAudioBuffer(): void;
451
+ stopProcessAudioBuffer(): void;
452
+ close(): void;
453
+ setAudioBufferPlaybackSpeed(speed: number): void;
454
+ }
455
+
456
+ /**
457
+ * Configurations for the audio track from an audio file or `AudioBuffer` object. Set these configurations when calling [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack}.
458
+ */
459
+ export declare interface BufferSourceAudioTrackInitConfig {
460
+ /**
461
+ * The type of the audio source:
462
+ * - `File`: An [File](https://developer.mozilla.org/en-US/docs/Web/API/File) object, representing a local audio file.
463
+ * - `string`: The online audio file retrieved from an HTTPS address. Ensure the address supports HTTPS and CORS.
464
+ * - `AudioBuffer`: An [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer) object, representing the raw data in PCM format.
465
+ */
466
+ source: File | string | AudioBuffer;
467
+ /**
468
+ * Whether to cache the online file:
469
+ * - `true`: Cache the online file.
470
+ * - `false`: (default) Do not cache the online file.
471
+ */
472
+ cacheOnlineFile?: boolean;
473
+ /**
474
+ * The audio encoder configurations.
475
+ *
476
+ * You can set the audio encoder configurations in either of the following ways:
477
+ * - Pass the preset audio encoder configurations by using [[AudioEncoderConfigurationPreset]].
478
+ * - Pass your customized audio encoder configurations by using [[AudioEncoderConfiguration]].
479
+ *
480
+ * > Firefox does not support setting the audio encoding rate.
481
+ */
482
+ encoderConfig?: AudioEncoderConfiguration | AudioEncoderConfigurationPreset;
483
+ }
484
+
485
+ export declare class CameraVideoTrack extends LocalVideoTrack implements ICameraVideoTrack {
486
+ private _config;
487
+ private _originalConstraints;
488
+ private _constraints;
489
+ _enabled: boolean;
490
+ _deviceName: string;
491
+ get __className__(): string;
492
+ constructor(track: MediaStreamTrack, config: CameraVideoTrackInitConfig, constraints: MediaTrackConstraints, scalabilityConfig?: SVCConfiguration, optimizationMode?: OptimizationMode | "balanced", trackId?: string);
493
+ setDevice(deviceId: string | RequiredOnlyOneOf<{
494
+ facingMode: VideoFacingModeEnum;
495
+ deviceId: string;
496
+ }>): Promise<void>;
497
+ private _setDeviceById;
498
+ private _setDeviceByFacingModel;
499
+ setEnabled(enabled: boolean, skipChangeState?: boolean): Promise<void>;
500
+ setEncoderConfiguration(config: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, doNotRenegoation?: boolean): Promise<void>;
501
+ protected _getDefaultPlayerConfig(): Partial<PlayerConfig>;
502
+ protected onTrackEnded(): void;
503
+ renewMediaStreamTrack(newConstraints?: MediaTrackConstraints): Promise<void>;
504
+ tryResumeVideoForIOS15_16WeChat: () => Promise<void>;
505
+ close(): void;
506
+ clone(config?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, cloneTrack?: boolean): CameraVideoTrack;
507
+ bindProcessorContextEvents(): void;
508
+ }
509
+
510
+ /**
511
+ * Configurations for the video track from the video captured by a camera. Set these configurations when calling [AgoraRTC.createCameraVideoTrack]{@link IAgoraRTC.createCameraVideoTrack}.
512
+ */
513
+ export declare interface CameraVideoTrackInitConfig {
514
+ /**
515
+ * The video encoder configurations.
516
+ *
517
+ * You can set the video encoder configurations in either of the following ways:
518
+ * - Pass the preset video encoder configurations by using [[VideoEncoderConfigurationPreset]].
519
+ * - Pass your customized video encoder configurations by using [[VideoEncoderConfiguration]].
520
+ * - Leave this property empty to use the SDK's default value, `"480p_1"` (resolution: 640 × 480, frame rate: 15 fps, bitrate: 500 Kbps).
521
+ */
522
+ encoderConfig?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset;
523
+ /**
524
+ * Whether to user the front camera or the rear camera.
525
+ *
526
+ * You can use this parameter to choose between the front camera and the rear camera on a mobile device:
527
+ * - `"user"`: The front camera.
528
+ * - `"environment"`: The rear camera.
529
+ */
530
+ facingMode?: VideoFacingModeEnum;
531
+ /**
532
+ * Specifies the camera ID.
533
+ *
534
+ * You can get a list of the available cameras by calling [AgoraRTC.getCameras]{@link IAgoraRTC.getCameras}.
535
+ */
536
+ cameraId?: string;
537
+ /**
538
+ * @since
539
+ * <br>&emsp;&emsp;&emsp;*4.0.0*
540
+ *
541
+ * Transmission optimization mode. Whether to prioritize video quality or smoothness:
542
+ * - `"detail"`: Prioritizes video quality.
543
+ * - The SDK ensures high-quality images by automatically calculating a minimum bitrate based on the capturing resolution and frame rate. No matter how poor the network condition is, the sending bitrate will never be lower than the minimum value.
544
+ * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
545
+ * - `"motion"`: Prioritizes video smoothness.
546
+ * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
547
+ * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
548
+ * - Empty: Uses the default transmission optimization mode. The SDK may reduce the frame rate or the sending resolution in poor network conditions.
549
+ *
550
+ * > Note: This method is only supported on Chrome.
551
+ */
552
+ optimizationMode?: OptimizationMode;
553
+ /**
554
+ * @ignore
555
+ *
556
+ * @since
557
+ * <br>&emsp;&emsp;&emsp;*4.18.0*
558
+ *
559
+ * Configurations for Scalable Video Coding (SVC).
560
+ *
561
+ * You can set the configurations using one of the following options:
562
+ * - Use the preset SVC configurations provided by the SDK through {@link SVCConfigurationPreset}.
563
+ * - Use your custom SVC configurations through {@link SVCConfiguration}.
564
+ */
565
+ scalabiltyMode?: SVCConfiguration | SVCConfigurationPreset;
566
+ }
567
+
269
568
  export declare function checkMediaStreamTrackResolution(track: MediaStreamTrack): Promise<[number, number]>;
270
569
 
570
+ export declare function checkTrackState(): (target: any, propertyKey: any, descriptor: PropertyDescriptor) => TypedPropertyDescriptor<any> | undefined;
571
+
271
572
  /**
272
573
  * The visibility of the `<video>` tag.
273
574
  *
274
575
  * Get the visibility of the `<video>` tag through the following methods and events:
576
+ * - [localVideoTrack.on("video-element-visible-status")]{@link ILocalVideoTrack.event_video_element_visible_status}
577
+ * - [localVideoTrack.getVideoElementVisibleStatus]{@link ILocalVideoTrack.getVideoElementVisibleStatus}
275
578
  * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status}
276
579
  * - [remoteVideoTrack.getVideoElementVisibleStatus]{@link IRemoteVideoTrack.getVideoElementVisibleStatus}
277
580
  *
@@ -285,8 +588,201 @@ export declare function checkMediaStreamTrackResolution(track: MediaStreamTrack)
285
588
  */
286
589
  export declare type CheckVideoVisibleResult = CheckVisibleResult;
287
590
 
591
+ /**
592
+ * Specifies a constraint for a property, such as the resolution or bitrate for video capture in [[VideoEncoderConfiguration]].
593
+ */
594
+ export declare interface ConstrainLong {
595
+ /**
596
+ * The lower limit of the property.
597
+ */
598
+ min?: number;
599
+ /**
600
+ * The upper limit of the property.
601
+ */
602
+ max?: number;
603
+ /**
604
+ * An ideal value of a property. If the video capture device cannot output this value, it outputs the closest value instead.
605
+ */
606
+ ideal?: number;
607
+ /**
608
+ * A required value of a property. If the video capture device cannot output this value, the video capture fails.
609
+ */
610
+ exact?: number;
611
+ }
612
+
613
+ export declare function createBufferSourceAudioTrack(config: BufferSourceAudioTrackInitConfig): Promise<BufferSourceAudioTrack>;
614
+
615
+ export declare function createCameraVideoTrack(config?: CameraVideoTrackInitConfig): Promise<CameraVideoTrack>;
616
+
617
+ export declare function createCustomAudioTrack(config: CustomAudioTrackInitConfig): LocalAudioTrack;
618
+
619
+ export declare function createCustomVideoTrack(config: CustomVideoTrackInitConfig): LocalVideoTrack;
620
+
621
+ export declare function createMicrophoneAndCameraTracks(audioConfig?: MicrophoneAudioTrackInitConfig, videoConfig?: CameraVideoTrackInitConfig): Promise<[MicrophoneAudioTrack, CameraVideoTrack]>;
622
+
623
+ export declare function createMicrophoneAudioTrack(config?: MicrophoneAudioTrackInitConfig): Promise<MicrophoneAudioTrack>;
624
+
625
+ export declare function createMixingAudioTrack(trackList: LocalAudioTrack[]): MixingAudioTrack;
626
+
627
+ export declare function createScreenVideoTrack(config: ScreenVideoTrackInitConfig, withAudio: "enable"): Promise<[LocalVideoTrack, LocalAudioTrack]>;
628
+
629
+ export declare function createScreenVideoTrack(config?: ScreenVideoTrackInitConfig, withAudio?: "disable"): Promise<LocalVideoTrack>;
630
+
631
+ export declare function createScreenVideoTrack(config: ScreenVideoTrackInitConfig, withAudio: "auto"): Promise<[LocalVideoTrack, LocalAudioTrack] | LocalVideoTrack>;
632
+
633
+ /**
634
+ * Configurations for the custom audio track. Set these configurations when calling [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack}.
635
+ */
636
+ export declare interface CustomAudioTrackInitConfig {
637
+ /**
638
+ * Your [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object.
639
+ */
640
+ mediaStreamTrack: MediaStreamTrack;
641
+ /**
642
+ * The audio encoder configurations.
643
+ *
644
+ * You can set the audio encoder configurations in either of the following ways:
645
+ * - Pass the preset audio encoder configurations by using [[AudioEncoderConfigurationPreset]].
646
+ * - Pass your customized audio encoder configurations by using [[AudioEncoderConfiguration]].
647
+ *
648
+ * > Firefox does not support setting the audio encoding rate.
649
+ */
650
+ encoderConfig?: AudioEncoderConfiguration | AudioEncoderConfigurationPreset;
651
+ }
652
+
653
+ /**
654
+ * Configurations for the custom video track. Set these configurations when calling [AgoraRTC.createCustomVideoTrack]{@link IAgoraRTC.createCustomVideoTrack}.
655
+ */
656
+ export declare interface CustomVideoTrackInitConfig {
657
+ /**
658
+ * Your [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object.
659
+ */
660
+ mediaStreamTrack: MediaStreamTrack;
661
+ /**
662
+ * @since
663
+ * <br>&emsp;&emsp;&emsp;*4.17.1*
664
+ *
665
+ * Width of the video.
666
+ *
667
+ * You can pass a `number`, or a constraint such as `{ max: 1280, min: 720 }`.
668
+ *
669
+ * For more details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
670
+ */
671
+ width?: number | ConstrainLong;
672
+ /**
673
+ * @since
674
+ * <br>&emsp;&emsp;&emsp;*4.17.1*
675
+ *
676
+ * Height of the video.
677
+ *
678
+ * You can pass a `number`, or a constraint such as `{ max: 1280, min: 720 }`.
679
+ *
680
+ * For more details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
681
+ */
682
+ height?: number | ConstrainLong;
683
+ /**
684
+ * @since
685
+ * <br>&emsp;&emsp;&emsp;*4.17.1*
686
+ *
687
+ * Frame rate of the video (fps).
688
+ *
689
+ * You can pass a `number`, or a constraint such as `{ max: 30, min: 5 }`.
690
+ *
691
+ * For details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
692
+ */
693
+ frameRate?: number | ConstrainLong;
694
+ /**
695
+ * The minimum bitrate of sending the video track (Kbps).
696
+ */
697
+ bitrateMin?: number;
698
+ /**
699
+ * The maximum bitrate of sending the video track (Kbps).
700
+ */
701
+ bitrateMax?: number;
702
+ /**
703
+ * @since
704
+ * <br>&emsp;&emsp;&emsp;*4.0.0*
705
+ *
706
+ * Transmission optimization mode. Whether to prioritize video quality or smoothness:
707
+ * - `"detail"`: Prioritizes video quality.
708
+ * - The SDK ensures high-quality images by automatically calculating a minimum bitrate based on the capturing resolution and frame rate. No matter how poor the network condition is, the sending bitrate will never be lower than the minimum value.
709
+ * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
710
+ * - `"motion"`: Prioritizes video smoothness.
711
+ * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
712
+ * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
713
+ * - Empty: Uses the default transmission optimization mode. The SDK may reduce the frame rate or the sending resolution in poor network conditions.
714
+ *
715
+ * > Note: This method is only supported on Chrome.
716
+ */
717
+ optimizationMode?: "motion" | "detail";
718
+ /**
719
+ * @ignore
720
+ *
721
+ * @since
722
+ * <br>&emsp;&emsp;&emsp;*4.18.0*
723
+ *
724
+ * Configurations for Scalable Video Coding (SVC).
725
+ *
726
+ * You can set `scalabiltyMode` using one of the following options:
727
+ * - Use the preset SVC configurations provided by the SDK through {@link SVCConfigurationPreset}.
728
+ * - Use your custom SVC configurations through {@link SVCConfiguration}.
729
+ */
730
+ scalabiltyMode?: SVCConfiguration | SVCConfigurationPreset;
731
+ }
732
+
733
+ export declare abstract class DataChannel extends EventEmitter implements IDataChannel {
734
+ private _version;
735
+ private _type;
736
+ _config: IDataChannelConfig;
737
+ _originDataChannel?: RTCDataChannel;
738
+ protected _dataStreamPacketHeader: ArrayBuffer;
739
+ protected _dataStreamPacketHandler: DataStream;
740
+ private _datachannelEventMap;
741
+ constructor(config: IDataChannelConfig, datachannel?: RTCDataChannel);
742
+ get id(): number;
743
+ get ordered(): boolean;
744
+ get maxRetransmits(): number;
745
+ get metadata(): string;
746
+ get readyState(): RTCDataChannelState;
747
+ get _originDataChannelId(): number | null;
748
+ getChannelId(): number;
749
+ getConfig(): IDataChannelConfig;
750
+ _close(): void;
751
+ _waitTillOpen(): Promise<void>;
752
+ _updateOriginDataChannel(datachannel: RTCDataChannel): void;
753
+ private _initPacketHeader;
754
+ private _bandDataChannelEvents;
755
+ private _unbindDataChannelEvents;
756
+ }
757
+
758
+ export declare enum DataChannelEvents {
759
+ OPEN = "open",
760
+ MESSAGE = "message",
761
+ CLOSE = "close",
762
+ CLOSING = "closing",
763
+ ERROR = "error"
764
+ }
765
+
766
+ declare class DataStream {
767
+ private _sequence;
768
+ private _startTime;
769
+ private isUseOneByte;
770
+ private get startTime();
771
+ private get sequence();
772
+ serialize(payload: ArrayBuffer): ArrayBuffer;
773
+ deserialize(packet: ArrayBuffer): ArrayBuffer;
774
+ private serializeExtension;
775
+ private deserializeExtension;
776
+ private decompress;
777
+ private compress;
778
+ }
779
+
288
780
  export declare function decodeAudioData(buffer: ArrayBuffer): Promise<AudioBuffer>;
289
781
 
782
+ export declare const DEFAULT_LOCAL_AUDIO_TRACK_STATS: LocalAudioTrackStats;
783
+
784
+ export declare const DEFAULT_LOCAL_VIDEO_TRACK_STATS: LocalVideoTrackStats;
785
+
290
786
  export declare const DEFAULT_NETWORK_QUALITY_STATS: NetworkQuality;
291
787
 
292
788
  export declare const DEFAULT_REMOTE_AUDIO_TRACK_STATS: RemoteAudioTrackStats;
@@ -300,6 +796,8 @@ export declare interface DenoiserStats {
300
796
  vl: number;
301
797
  }
302
798
 
799
+ export declare function detectSupportAudioElementSetSinkId(): boolean;
800
+
303
801
  /**
304
802
  * Information of the media input device.
305
803
  *
@@ -376,6 +874,24 @@ export declare type DeviceState = "ACTIVE" | "INACTIVE";
376
874
 
377
875
  export declare const emptyImage2TypedArray: (type: string) => Promise<ImageTypedData>;
378
876
 
877
+ /**
878
+ * @ignore
879
+ *
880
+ * Occurs when the device is overloaded after you call [setBeautyEffect]{@link ILocalVideoTrack.setBeautyEffect} to enable image enhancement.
881
+ *
882
+ * You can listen for this event to notify users of the device overload and disable image enhancement.
883
+ *
884
+ * ```javascript
885
+ * localVideoTrack.on("beauty-effect-overload", () => {
886
+ * console.log("beauty effect overload, disable beauty effect");
887
+ * localVideoTrack.setBeautyEffect(false);
888
+ * });
889
+ * ```
890
+ * @event
891
+ * @asMemberOf ILocalVideoTrack
892
+ */
893
+ declare function event_beauty_effect_overload(): void;
894
+
379
895
  /**
380
896
  * Occurs when the first remote audio or video frame is decoded.
381
897
  *
@@ -396,6 +912,55 @@ declare function event_first_frame_decoded(): void;
396
912
  */
397
913
  declare function event_sei_received(sei: Uint8Array): void;
398
914
 
915
+ /**
916
+ * Occurs when the state of processing the audio buffer in [BufferSourceAudioTrack]{@link IBufferSourceAudioTrack} changes.
917
+ *
918
+ * @param currentState The state of processing the audio buffer:
919
+ * - `"stopped"`: The SDK stops processing the audio buffer. Reasons may include:
920
+ * - The SDK finishes processing the audio buffer.
921
+ * - The user manually stops the processing of the audio buffer.
922
+ * - `"paused"`: The SDK pauses the processing of the audio buffer.
923
+ * - `"playing"`: The SDK is processing the audio buffer.
924
+ *
925
+ * @event
926
+ * @asMemberOf IBufferSourceAudioTrack
927
+ */
928
+ declare function event_source_state_change(currentState: AudioSourceState): void;
929
+
930
+ /**
931
+ * Occurs when a audio or video track ends.
932
+ *
933
+ * Reasons may include:
934
+ * - Camera is unplugged.
935
+ * - Microphone is unplugged.
936
+ * - The local user stops screen sharing.
937
+ * - The local user closes the underlying `MediaStreamTrack`.
938
+ * - A local media device malfunctions.
939
+ * - The device permission is revoked.
940
+ *
941
+ * @event
942
+ * @asMemberOf ILocalTrack
943
+ */
944
+ declare function event_track_ended(): void;
945
+
946
+ /**
947
+ * Triggers when a media track is updated.
948
+ * @param track The media stream track. See [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack).
949
+ * @event
950
+ */
951
+ export declare function event_track_updated(track: MediaStreamTrack): void;
952
+
953
+ /**
954
+ * Occurs when the `RTCRtpTransceiver` instance of the current track is updated.
955
+ *
956
+ * @param transceiver The new `RTCRtpTransceiver` instance.
957
+ * @param type The type of the video stream to which the current track belongs. See {@link StreamType}.
958
+ *
959
+ * @event
960
+ * @asMemberOf ILocalTrack
961
+ */
962
+ declare function event_transceiver_updated(transceiver: RTCRtpTransceiver, type?: StreamType): void;
963
+
399
964
  /**
400
965
  * Occurs when the `RTCRtpTransceiver` instance of the current track is updated.
401
966
  *
@@ -403,7 +968,43 @@ declare function event_sei_received(sei: Uint8Array): void;
403
968
  * @event
404
969
  * @asMemberOf IRemoteTrack
405
970
  */
406
- declare function event_transceiver_updated(transceiver: RTCRtpTransceiver): void;
971
+ declare function event_transceiver_updated_2(transceiver: RTCRtpTransceiver): void;
972
+
973
+ /**
974
+ * @ignore
975
+ */
976
+ declare function event_user_datachannel_close(): void;
977
+
978
+ /**
979
+ * @ignore
980
+ */
981
+ declare function event_user_datachannel_error(ev: Event): void;
982
+
983
+ /**
984
+ * @ignore
985
+ */
986
+ declare function event_user_datachannel_message(data: ArrayBuffer): void;
987
+
988
+ /**
989
+ * @ignore
990
+ */
991
+ declare function event_user_datachannel_open(): void;
992
+
993
+ /**
994
+ * @since
995
+ * <br>&emsp;&emsp;&emsp;*4.8.0*
996
+ *
997
+ * Indicates the visibility of the `<video>` HTML tag.
998
+ *
999
+ * The SDK triggers this event every 30 seconds.
1000
+ *
1001
+ * After you call `localVideoTrack.play`, the SDK creates an [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) tag for playing video tracks. When `localVideoTrack.isPlaying` is `true` but you cannot see any video, this event helps you check whether the `<video>` tag is visible or not and learn the reason when the `<video>` tag is invisible.
1002
+ *
1003
+ * @param data The visibility of the `<video>` tag.
1004
+ * @asMemberOf ILocalVideoTrack
1005
+ * @event
1006
+ */
1007
+ declare function event_video_element_visible_status(data?: CheckVideoVisibleResult): void;
407
1008
 
408
1009
  /**
409
1010
  * @since
@@ -419,7 +1020,7 @@ declare function event_transceiver_updated(transceiver: RTCRtpTransceiver): void
419
1020
  * @asMemberOf IRemoteVideoTrack
420
1021
  * @event
421
1022
  */
422
- declare function event_video_element_visible_status(data?: CheckVideoVisibleResult): void;
1023
+ declare function event_video_element_visible_status_2(data?: CheckVideoVisibleResult): void;
423
1024
 
424
1025
  /**
425
1026
  * Occurs when the video state changes.
@@ -466,60 +1067,264 @@ declare class FakeTrackSource extends EventEmitter {
466
1067
  createMediaStreamSourceNode(): undefined;
467
1068
  }
468
1069
 
1070
+ export declare const frameData2CryptoBuffer: (imageData: ImageTypedData, appid: string, channelName: string) => Promise<Uint8Array>;
1071
+
469
1072
  export declare function getAudioContext(): AudioContext;
470
1073
 
1074
+ export declare function getAudioEncoderConfiguration(profile: AudioEncoderConfigurationPreset | AudioEncoderConfiguration): AudioEncoderConfiguration;
1075
+
1076
+ export declare function getBitrateConstrainRange(width: number, height: number, frameRate: number, bitrateMin?: number, bitrateMax?: number): DoubleRange;
1077
+
1078
+ export declare function getBitrateFromResAndFps(width: number, height: number, fps: number): Required<DoubleRange>;
1079
+
471
1080
  export declare function getCompatibility(): AgoraRTCCompatibility;
472
1081
 
473
- export declare function getSilenceAudioTrack(): MediaStreamTrack;
1082
+ export declare function getConstraintsFromCameraConfig(config: CameraVideoTrackInitConfig): MediaTrackConstraints;
474
1083
 
475
- export declare function getSilenceSamplesDuration(buffer: AudioBuffer): number;
1084
+ export declare function getConstraintsFromMicrophoneConfig(config: MicrophoneAudioTrackInitConfig): MediaTrackConstraints;
476
1085
 
477
- export declare function handleGetUserMediaError(errorName: string, message?: string): AgoraRTCError;
1086
+ export declare function getConstraintsFromScreenConfig(config: ScreenVideoTrackInitConfig): ScreenConstraintsWithElectron;
478
1087
 
479
- export declare const HAS_GUM_AUDIO: boolean;
1088
+ export declare function getElectronScreenSources(type?: ScreenSourceType): Promise<ElectronDesktopCapturerSource[]>;
480
1089
 
481
- export declare const HAS_GUM_VIDEO: boolean;
1090
+ export declare function getElectronScreenStream(sourceId: string, config: ScreenConstraintsWithElectron, captureAudio?: boolean): Promise<MediaStream>;
482
1091
 
483
- export declare function hasAudioContext(): boolean;
1092
+ export declare function getElectronScreenStreamByUserSelect(config: ScreenConstraintsWithElectron, captureAudio?: boolean): Promise<MediaStream>;
484
1093
 
485
- export declare interface ImageTypedData {
486
- buffer: Uint8Array;
487
- width: number;
488
- height: number;
1094
+ export declare function getLocalStream(config: GetUserMediaConfig, id: string): Promise<MediaStream>;
1095
+
1096
+ export declare const getOriginSenderConfig: (track: LocalVideoTrack) => {
1097
+ frameRate: number;
1098
+ bitrateMax: number;
1099
+ bitrateMin: number;
1100
+ scaleResolutionDownBy: number;
1101
+ scale: number;
1102
+ };
1103
+
1104
+ export declare function getScalabilityConfiguration(profile: SVCConfiguration | SVCConfigurationPreset): SVCConfiguration;
1105
+
1106
+ export declare function getScreenEncoderConfiguration(profile: VideoEncoderConfiguration | ScreenEncoderConfigurationPreset | string): VideoEncoderConfiguration;
1107
+
1108
+ export declare function getSilenceAudioTrack(): MediaStreamTrack;
1109
+
1110
+ export declare function getSilenceSamplesDuration(buffer: AudioBuffer): number;
1111
+
1112
+ export declare function getStaticTrackStream(track: MediaStreamTrack, interval?: number): MediaStreamTrack | void;
1113
+
1114
+ export declare interface GetUserMediaConfig {
1115
+ video?: MediaTrackConstraints;
1116
+ audio?: MediaTrackConstraints;
1117
+ screen?: ScreenConstraintsWithElectron;
1118
+ videoSource?: MediaStreamTrack;
1119
+ audioSource?: MediaStreamTrack;
1120
+ screenAudio?: boolean;
489
1121
  }
490
1122
 
1123
+ export declare function getVideoEncoderConfiguration(profile: VideoEncoderConfigurationPreset | VideoEncoderConfiguration | undefined): VideoEncoderConfiguration;
1124
+
1125
+ export declare function handleGetUserMediaError(errorName: string, message?: string): AgoraRTCError;
1126
+
1127
+ export declare let HAS_GUM_AUDIO: boolean;
1128
+
1129
+ export declare let HAS_GUM_VIDEO: boolean;
1130
+
1131
+ export declare function hasAudioContext(): boolean;
1132
+
491
1133
  /**
492
- * `RemoteAudioTrack` is the basic interface for the remote audio track.
1134
+ * Inherited from [LocalAudioTrack]{@link ILocalAudioTrack}, `BufferSourceAudioTrack` is an interface for the audio from a local audio file and adds several functions for controlling the processing of the audio buffer, such as starting processing, stopping processing, and seeking a specified time location.
493
1135
  *
494
- * You can get create a remote audio track by the [AgoraRTCRemoteUser.audioTrack]{@link IAgoraRTCRemoteUser.audioTrack} object after calling [subscribe]{@link IAgoraRTCClient.subscribe}.
1136
+ * You can create an audio track from an audio file by calling [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack}.
495
1137
  */
496
- export declare interface IRemoteAudioTrack extends IRemoteTrack {
1138
+ export declare interface IBufferSourceAudioTrack extends ILocalAudioTrack {
497
1139
  /**
498
- * Gets the statistics of a remote audio track.
1140
+ * The [source]{@link BufferSourceAudioTrackInitConfig.source} specified when creating an audio track.
1141
+ */
1142
+ source: string | File | AudioBuffer | null;
1143
+ /**
1144
+ * The current state of audio processing, such as start, pause, or stop.
1145
+ */
1146
+ currentState: AudioSourceState;
1147
+ /**
1148
+ * The total duration of the audio (seconds).
1149
+ */
1150
+ duration: number;
1151
+ /**
1152
+ * @since
1153
+ * <br>&emsp;&emsp;&emsp;*4.18.0*
499
1154
  *
500
- * @return An [[RemoteAudioTrackStats]] object.
1155
+ * The playback speed of the current audio file. Valid range is [50, 400], where:
1156
+ * - `50`: Half the original speed.
1157
+ * - `100`: (Default) The original speed.
1158
+ * - `400`: Four times the original speed.
501
1159
  */
502
- getStats(): RemoteAudioTrackStats;
1160
+ playbackSpeed: number;
503
1161
  /**
504
- * Plays a remote audio track.
1162
+ * @param event The event name.
1163
+ * @param listener See [source-state-change]{@link event_source_state_change}.
1164
+ */
1165
+ on(event: "source-state-change", listener: typeof event_source_state_change): void;
1166
+ /**
1167
+ * When the specified event happens, the SDK triggers the callback that you pass.
505
1168
  *
506
- * > When playing the audio track, you do not need to pass any DOM element.
1169
+ * @param event The event name.
1170
+ * @param listener The callback function.
507
1171
  */
508
- play(): void;
1172
+ on(event: string, listener: Function): void;
1173
+ /**
1174
+ * Gets the progress (seconds) of the audio buffer processing.
1175
+ *
1176
+ * @returns The progress (seconds) of the audio buffer processing.
1177
+ */
1178
+ getCurrentTime(): number;
1179
+ /**
1180
+ * Starts processing the audio buffer.
1181
+ *
1182
+ * > Starting processing the audio buffer means that the processing unit in the SDK has received the audio data. If the audio track has been published, the remote user can hear the audio.
1183
+ * > Whether the local user can hear the audio depends on whether the SDK calls the [[play]] method and sends the audio data to the sound card.
1184
+ *
1185
+ * @param options Options for processing the audio buffer. See [[AudioSourceOptions]].
1186
+ */
1187
+ startProcessAudioBuffer(options?: AudioSourceOptions): void;
1188
+ /**
1189
+ * Pauses processing the audio buffer.
1190
+ */
1191
+ pauseProcessAudioBuffer(): void;
1192
+ /**
1193
+ * Jumps to a specified time point.
1194
+ *
1195
+ * @param time The specified time point (seconds).
1196
+ */
1197
+ seekAudioBuffer(time: number): void;
1198
+ /**
1199
+ * Resumes processing the audio buffer.
1200
+ */
1201
+ resumeProcessAudioBuffer(): void;
1202
+ /**
1203
+ * Stops processing the audio buffer.
1204
+ */
1205
+ stopProcessAudioBuffer(): void;
509
1206
  /**
510
1207
  * @since
511
- * <br>&emsp;&emsp;&emsp;*4.1.0*
1208
+ * <br>&emsp;&emsp;&emsp;*4.18.0*
512
1209
  *
513
- * Sets the audio playback device, for example, the speaker.
1210
+ * Sets the playback speed for the current audio file.
514
1211
  *
515
- * > This method supports Chrome and Edge on desktop devices only. Other browsers throw a `NOT_SUPPORTED` error when calling this method.
516
- * @param deviceId Device ID, which can be retrieved by calling [[getPlaybackDevices]].
1212
+ * You can call this method before or after joining a channel.
1213
+ *
1214
+ * @param speed The playback speed. Valid range is [50, 400], where:
1215
+ * - `50`: Half the original speed.
1216
+ * - `100`: (Default) The original speed.
1217
+ * - `400`: Four times the original speed.
517
1218
  */
518
- setPlaybackDevice(deviceId: string): Promise<void>;
1219
+ setAudioBufferPlaybackSpeed(speed: number): void;
1220
+ }
1221
+
1222
+ /**
1223
+ *
1224
+ * Inherited from [LocalVideoTrack]{@link ILocalVideoTrack}, `CameraVideoTrack` is an interface for the video captured by a local camera and adds functions such as switching devices and adjusting video encoder configurations.
1225
+ *
1226
+ * You can create a local camera video track by calling [AgoraRTC.createCameraVideoTrack]{@link IAgoraRTC.createCameraVideoTrack}.
1227
+ */
1228
+ export declare interface ICameraVideoTrack extends ILocalVideoTrack {
1229
+ /**
1230
+ * Sets the device for capturing video.
1231
+ *
1232
+ * > You can call this method either before or after publishing the video track.
1233
+ *
1234
+ * @param deviceId Device ID, which can be passed in using the following ways:
1235
+ * - Pass a string: Pass the `deviceId` obtained using [AgoraRTC.getCameras]{@link IAgoraRTC.getCameras}.
1236
+ * - Pass an object: Starting from version 4.19.0, you can pass an object
1237
+ * containing `facingMode` or `deviceId`, but only one of these properties
1238
+ * can be specified. `deviceId` can be obtained through [AgoraRTC.getCameras]{@link IAgoraRTC.getCameras}, and `facingMode` supports the following values:
1239
+ * - `"environment"`: Use the rear camera.
1240
+ * - `"user"`: Use the front camera.
1241
+ */
1242
+ setDevice(deviceId: string | RequiredOnlyOneOf<{
1243
+ facingMode: VideoFacingModeEnum;
1244
+ deviceId: string;
1245
+ }>): Promise<void>;
1246
+ /**
1247
+ * @since
1248
+ * <br>&emsp;&emsp;&emsp;*4.0.0*
1249
+ *
1250
+ * Enables/Disables the track.
1251
+ *
1252
+ * After a track is disabled, the SDK stops playing and publishing the track.
1253
+ *
1254
+ * > - Disabling a track does not trigger the [LocalTrack.on("track-ended")]{@link event_track_ended} event.
1255
+ * > - If a track is published, disabling this track triggers the [user-unpublished]{@link IAgoraRTCClient.event_user_unpublished} event on the remote client, and re-enabling this track triggers the [user-published]{@link IAgoraRTCClient.event_user_published} event.
1256
+ * > - Do not call `setEnabled` and `setMuted` together.
1257
+ *
1258
+ * @param enabled Whether to enable the track:
1259
+ * - `true`: Enable the track.
1260
+ * - `false`: Disable the track.
1261
+ */
1262
+ setEnabled(enabled: boolean): Promise<void>;
1263
+ /**
1264
+ * @since
1265
+ * <br>&emsp;&emsp;&emsp;*4.19.0*
1266
+ *
1267
+ * Clones the current video track to create a new video track.
1268
+ *
1269
+ * In scenarios such as video conferencing and online education, you can use this method to display the same video stream with two sets of display parameters, including resolution, frame rate, and bitrate. For example, you can have one display set to high-definition and the other to low-definition.
1270
+ *
1271
+ * @param config The encoding configuration for the new video track. You can pass in the SDK's built-in encoding configuration through [[VideoEncoderConfiguration]], or customize the video encoding configuration by passing in a [[VideoEncoderConfigurationPreset]].
1272
+ * @param cloneTrack Whether to clone the current track. Default is `true`.
1273
+ * @returns The newly generated video track.
1274
+ */
1275
+ clone(config?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, cloneTrack?: boolean): ICameraVideoTrack;
1276
+ }
1277
+
1278
+ /**
1279
+ * @ignore
1280
+ */
1281
+ export declare interface IDataChannel extends EventEmitter {
1282
+ readonly id: number;
1283
+ readonly maxRetransmits: number | null;
1284
+ readonly ordered: boolean;
1285
+ readonly readyState: RTCDataChannelState;
1286
+ readonly metadata: string;
1287
+ getChannelId(): number;
1288
+ getConfig(): IDataChannelConfig;
1289
+ }
1290
+
1291
+ /**
1292
+ * @ignore
1293
+ */
1294
+ export declare interface IDataChannelConfig {
1295
+ id: number;
1296
+ ordered: boolean;
1297
+ metadata: string;
1298
+ }
1299
+
1300
+ /**
1301
+ * `LocalAudioTrack` is the basic interface for local audio tracks, providing main methods of local audio tracks.
1302
+ *
1303
+ * You can create a local audio track by calling [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack}.
1304
+ *
1305
+ * The following interfaces are inherited from `LocalAudioTrack`:
1306
+ * - [MicrophoneAudioTrack]{@link IMicrophoneAudioTrack}, the interface for the audio sampled by a local microphone, which adds several microphone-related functions.
1307
+ * - [BufferSourceAudioTrack]{@link IBufferSourceAudioTrack}, the interface for the audio from a local audio file, which adds several audio-file-related functions.
1308
+ */
1309
+ export declare interface ILocalAudioTrack extends ILocalTrack {
1310
+ /**
1311
+ * Sets the volume of a local audio track.
1312
+ *
1313
+ * @param volume The volume. The value ranges from 0 (mute) to 1000 (maximum). A value of 100 is the original volume。 The volume change may not be obvious to human ear. If local track has been published, setting volume will affect the volume heard by remote users.
1314
+ */
1315
+ setVolume(volume: number): void;
1316
+ /**
1317
+ * Gets the audio level of a local audio track.
1318
+ *
1319
+ * @returns The audio level. The value range is [0,1]. 1 is the highest audio level.
1320
+ * Usually a user with audio level above 0.6 is a speaking user.
1321
+ *
1322
+ */
1323
+ getVolumeLevel(): number;
519
1324
  /**
520
1325
  * Sets the callback for getting raw audio data in PCM format.
521
1326
  *
522
- * After you successfully set the callback, the SDK constantly returns the audio frames of a remote audio track in this callback by using [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer).
1327
+ * After you successfully set the callback, the SDK constantly returns the audio frames of a local audio track in this callback by using [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer).
523
1328
  *
524
1329
  * > You can set the `frameSize` parameter to determine the frame size in each callback, which affects the interval between the callbacks. The larger the frame size, the longer the interval between them.
525
1330
  *
@@ -542,23 +1347,31 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
542
1347
  */
543
1348
  setAudioFrameCallback(audioFrameCallback: null | ((buffer: AudioBuffer) => void), frameSize?: number): void;
544
1349
  /**
545
- * Sets the volume of a remote audio track.
1350
+ * Plays a local audio track.
546
1351
  *
547
- * @param volume The volume. The value ranges from 0 (mute) to 100 (maximum). A value of 100 is the current volume.
1352
+ * > When playing a audio track, you do not need to pass any DOM element.
548
1353
  */
549
- setVolume(volume: number): void;
1354
+ play(): void;
550
1355
  /**
551
- * Gets the audio level of a remote audio track.
1356
+ * @since
1357
+ * <br>&emsp;&emsp;&emsp;*4.1.0*
552
1358
  *
553
- * @returns The audio level. The value range is [0,1]. 1 is the highest audio level.
554
- * Usually a user with audio level above 0.6 is a speaking user.
1359
+ * > Note:
1360
+ * > - As of v4.7.0, this method no longer takes effect. Use [IRemoteAudioTrack.setPlaybackDevice]{@link IRemoteAudioTrack.setPlaybackDevice} instead.
1361
+ *
1362
+ * Sets the playback device (speaker) for the remote audio stream.
1363
+ *
1364
+ * @param deviceId The device ID, which can be retrieved by calling [[getPlaybackDevices]].
555
1365
  */
556
- getVolumeLevel(): number;
1366
+ setPlaybackDevice(deviceId: string): Promise<void>;
557
1367
  /**
558
- * @since
559
- * <br>&emsp;&emsp;&emsp;*4.13.0*
1368
+ * Gets the statistics of a local audio track.
560
1369
  *
561
- * Inserts a `Processor` to the remote audio track.
1370
+ * @deprecated from v4.1.0. Use [AgoraRTCClient.getLocalVideoStats]{@link IAgoraRTCClient.getLocalVideoStats} and [AgoraRTCClient.getLocalAudioStats]{@link IAgoraRTCClient.getLocalAudioStats} instead.
1371
+ */
1372
+ getStats(): LocalAudioTrackStats;
1373
+ /**
1374
+ * Inserts a `Processor` to the local audio track.
562
1375
  *
563
1376
  * @param processor The `Processor` instance. Each extension has a corresponding type of `Processor`.
564
1377
  *
@@ -567,199 +1380,1014 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
567
1380
  pipe(processor: IAudioProcessor): IAudioProcessor;
568
1381
  /**
569
1382
  * @since
570
- * <br>&emsp;&emsp;&emsp;*4.13.0*
1383
+ * <br>&emsp;&emsp;&emsp;*4.10.0*
571
1384
  *
572
- * Removes the `Processor` inserted to the remote audio track.
1385
+ * Removes the `Processor` inserted to the local audio track.
573
1386
  */
574
1387
  unpipe(): void;
575
1388
  /**
576
1389
  * @since
577
- * <br>&emsp;&emsp;&emsp;*4.13.0*
1390
+ * <br>&emsp;&emsp;&emsp;*4.10.0*
578
1391
  *
579
- * The destination of the current processing pipeline on the remote audio track.
1392
+ * The destination of the current processing pipeline on the local audio track.
580
1393
  */
581
1394
  processorDestination: IAudioProcessor;
582
1395
  }
583
1396
 
584
1397
  /**
585
- * `RemoteTrack` is the basic interface for remote tracks, providing public methods for [RemoteAudioTrack]{@link IRemoteAudioTrack} and [RemoteVideoTrack]{@link IRemoteVideoTrack}.
1398
+ * @ignore
586
1399
  */
587
- export declare interface IRemoteTrack extends ITrack {
1400
+ export declare interface ILocalDataChannel extends IDataChannel {
1401
+ send(data: ArrayBuffer): void;
1402
+ /** @internal */
1403
+ on(event: "open", listener: typeof event_user_datachannel_open): void;
1404
+ /** @internal */
1405
+ on(event: "close", listener: typeof event_user_datachannel_close): void;
1406
+ /** @internal */
1407
+ on(event: "error", listener: typeof event_user_datachannel_error): void;
1408
+ }
1409
+
1410
+ /**
1411
+ * `LocalTrack` is the basic interface for local tracks, providing public methods for [LocalAudioTrack]{@link ILocalAudioTrack} and [LocalVideoTrack]{@link ILocalVideoTrack}.
1412
+ */
1413
+ export declare interface ILocalTrack extends ITrack {
588
1414
  /**
589
1415
  * @param event The event name.
590
- * @param listener See [first-frame-decoded]{@link event_first_frame_decoded}.
1416
+ * @param listener See [track-updated]{@link event_track_updated}.
591
1417
  */
592
- on(event: "first-frame-decoded", listener: typeof event_first_frame_decoded): void;
1418
+ on(event: "track-updated", listener: typeof event_track_updated): void;
1419
+ /**
1420
+ * @param event The event name.
1421
+ * @param listener See [track-ended]{@link event_track_ended}.
1422
+ */
1423
+ on(event: "track-ended", listener: typeof event_track_ended): void;
593
1424
  /**
594
1425
  * Adds an event listener.
595
1426
  * @param event The event name.
596
- * @param listener See [IRemoteTrack.transceiver-updated]{@link event_transceiver_updated_2}.
1427
+ * @param listener See [ILocalTrack.transceiver-updated]{@link event_transceiver_updated}.
597
1428
  */
598
1429
  on(event: "transceiver-updated", listener: typeof event_transceiver_updated): void;
599
1430
  /**
600
- * Gets the `uid` of the remote user who publishes the remote track.
1431
+ * @since
1432
+ * <br>&emsp;&emsp;&emsp;*4.0.0*
601
1433
  *
602
- * @return The `uid` of the remote user.
1434
+ * Enables/Disables the track.
1435
+ *
1436
+ * After a track is disabled, the SDK stops playing and publishing the track.
1437
+ *
1438
+ * > - Disabling a track does not trigger the [LocalTrack.on("track-ended")]{@link event_track_ended} event.
1439
+ * > - If a track is published, disabling this track triggers the [user-unpublished]{@link IAgoraRTCClient.event_user_unpublished} event on the remote client, and re-enabling this track triggers the [user-published]{@link IAgoraRTCClient.event_user_published} event.
1440
+ * > - Do not call `setEnabled` and `setMuted` together.
1441
+ *
1442
+ * @param enabled Whether to enable the track:
1443
+ * - `true`: Enable the track.
1444
+ * - `false`: Disable the track.
603
1445
  */
604
- getUserId(): UID;
1446
+ setEnabled(enabled: boolean): Promise<void>;
605
1447
  /**
606
- * Gets the statistics of a remote track.
1448
+ * @deprecated from v4.1.0. Use [AgoraRTCClient.getLocalVideoStats]{@link IAgoraRTCClient.getLocalVideoStats} and [AgoraRTCClient.getLocalAudioStats]{@link IAgoraRTCClient.getLocalAudioStats} instead.
607
1449
  *
608
- * @deprecated from v4.1.0. Use [AgoraRTCClient.getRemoteVideoStats]{@link IAgoraRTCClient.getRemoteVideoStats} and [AgoraRTCClient.getRemoteAudioStats]{@link IAgoraRTCClient.getRemoteAudioStats} instead.
609
- * @return An [[RemoteAudioTrackStats]] or [[RemoteVideoTrackStats]] object.
1450
+ * Gets the statistics of a local track.
1451
+ *
1452
+ * > Note: When getting the statistics of a local video track, you cannot get the `encodeDelay` property on iOS.
610
1453
  */
611
- getStats(): RemoteAudioTrackStats | RemoteVideoTrackStats;
1454
+ getStats(): LocalVideoTrackStats | LocalAudioTrackStats;
1455
+ /**
1456
+ * Gets the label of a local track.
1457
+ *
1458
+ * @return The label that the SDK returns may include:
1459
+ * - The [MediaDeviceInfo.label](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo/label) property, if the track is created by calling `createMicrophoneAudioTrack` or `createCameraVideoTrack`.
1460
+ * - The `sourceId` property, if the track is created by calling `createScreenVideoTrack`.
1461
+ * - The [MediaStreamTrack.label](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/label) property, if the track is created by calling `createCustomAudioTrack` or `createCustomVideoTrack`.
1462
+ */
1463
+ getTrackLabel(): string;
1464
+ /**
1465
+ * Sends or stops sending the media data of the track.
1466
+ *
1467
+ * @since
1468
+ * <br>&emsp;&emsp;&emsp;*4.6.0*
1469
+ *
1470
+ * If the track is published, a successful call of `setMuted(true)` triggers the [user-unpublished]{@link IAgoraRTCClient.event_user_unpublished} event on the remote client, and a successful call of `setMuted(false)` triggers the [user-published]{@link IAgoraRTCClient.event_user_published} event.
1471
+ *
1472
+ * > - Calling `setMuted(true)` does not stop capturing audio or video and takes shorter time to take effect than [[setEnabled]]. For details, see [What are the differences between setEnabled and setMuted?](https://docs.agora.io/en/interactive-live-streaming/develop/product-workflow?platform=web#setenabled-and-setmuted).
1473
+ * > - Do not call `setEnabled` and `setMuted` together.
1474
+ *
1475
+ * @param muted Whether to stop sending the media data of the track:
1476
+ * - `true`: Stop sending the media data of the track.
1477
+ * - `false`: Resume sending the media data of the track.
1478
+ */
1479
+ setMuted(muted: boolean): Promise<void>;
1480
+ /**
1481
+ * Closes a local track and releases the audio and video resources that it occupies.
1482
+ *
1483
+ * Once you close a local track, you can no longer reuse it.
1484
+ */
1485
+ close(): void;
1486
+ muted: boolean;
1487
+ enabled: boolean;
612
1488
  }
613
1489
 
614
1490
  /**
615
- * `RemoteVideoTrack` is the basic interface for the remote video track.
1491
+ * `LocalVideoTrack` is the basic interface for local video tracks, providing the main methods for local video tracks.
616
1492
  *
617
- * You can get create a remote video track by the [AgoraRTCRemoteUser.videoTrack]{@link IAgoraRTCRemoteUser.videoTrack} object after calling [subscribe]{@link IAgoraRTCClient.subscribe}.
1493
+ * You can get create a local video track by calling [AgoraRTC.createCustomVideoTrack]{@link IAgoraRTC.createCustomVideoTrack} or [AgoraRTC.createScreenVideoTrack]{@link IAgoraRTC.createScreenVideoTrack} method.
1494
+ *
1495
+ * Inherited from `LocalVideoTrack`, [CameraVideoTrack]{@link ICameraVideoTrack} is an interface for the video captured by a local camera and adds several camera-related functions.
618
1496
  */
619
- export declare interface IRemoteVideoTrack extends IRemoteTrack {
1497
+ export declare interface ILocalVideoTrack extends ILocalTrack {
620
1498
  /**
621
1499
  * @param event The event name.
622
- * @param listener See [video-state-changed]{@link event_video_state_changed}.
1500
+ * @param listener See [track-updated]{@link event_track_updated}.
623
1501
  */
624
- on(event: "video-state-changed", listener: typeof event_video_state_changed): void;
1502
+ on(event: "track-updated", listener: typeof event_track_updated): void;
1503
+ /** @internal */
1504
+ on(event: "beauty-effect-overload", listener: typeof event_beauty_effect_overload): void;
625
1505
  /**
626
1506
  * @param event The event name.
627
- * @param listener See [first-frame-decoded]{@link event_first_frame_decoded}.
1507
+ * @param listener See [track-ended]{@link event_track_ended}.
628
1508
  */
629
- on(event: "first-frame-decoded", listener: typeof event_first_frame_decoded): void;
1509
+ on(event: "track-ended", listener: typeof event_track_ended): void;
630
1510
  /**
631
1511
  * @param event The event name.
632
- * @param listener See [video-element-visible-status]{@link event_video_element_visible_status_2}.
1512
+ * @param listener See [video-element-visible-status]{@link event_video_element_visible_status}.
633
1513
  */
634
1514
  on(event: "video-element-visible-status", listener: typeof event_video_element_visible_status): void;
635
1515
  /**
636
1516
  * Adds an event listener.
637
1517
  * @param event The event name.
638
- * @param listener See [IRemoteTrack.transceiver-updated]{@link event_transceiver_updated_2}.
1518
+ * @param listener See [ILocalTrack.transceiver-updated]{@link event_transceiver_updated}.
639
1519
  */
640
1520
  on(event: "transceiver-updated", listener: typeof event_transceiver_updated): void;
641
1521
  /**
642
- * Adds an event listener.
643
- * @param event The event name.
644
- * @param listener See [ILocalTrack.sei-received]{@link event_sei_received}.
1522
+ * Plays a remote video track on the web page.
1523
+ *
1524
+ * @param element Specifies a DOM element. The SDK will create a `<video>` element under the specified DOM element to play the video track. You can specify a DOM element in either of the following ways:
1525
+ * - `string`: Specify the ID of the DOM element.
1526
+ * - `HTMLElement`: Pass a DOM object.
1527
+ * @param config Sets the playback configurations, such as display mode and mirror mode. See [[VideoPlayerConfig]]. By default, the SDK enables mirror mode for a local video track.
1528
+ */
1529
+ play(element: string | HTMLElement, config?: VideoPlayerConfig): void;
1530
+ /**
1531
+ * Gets the statistics of a local video track.
1532
+ *
1533
+ * @deprecated from v4.1.0. Use [AgoraRTCClient.getLocalVideoStats]{@link IAgoraRTCClient.getLocalVideoStats} and [AgoraRTCClient.getLocalAudioStats]{@link IAgoraRTCClient.getLocalAudioStats} instead.
1534
+ */
1535
+ getStats(): LocalVideoTrackStats;
1536
+ /**
1537
+ * @since
1538
+ * <br>&emsp;&emsp;&emsp;*4.19.0*
1539
+ *
1540
+ * Clones the current video track to create a new video track.
1541
+ *
1542
+ * In scenarios such as video conferencing and online education, you can use this method to display the same video stream with two sets of display parameters, including resolution, frame rate, and bitrate. For example, you can have one display set to high-definition and the other to low-definition.
1543
+ *
1544
+ * @param config The encoding configuration for the new video track. You can pass in the SDK's built-in encoding configuration through [[VideoEncoderConfiguration]], or customize the video encoding configuration by passing in a [[VideoEncoderConfigurationPreset]].
1545
+ * @param cloneTrack Whether to clone the current track. Default is `true`.
1546
+ * @returns The newly generated video track.
1547
+ */
1548
+ clone(config?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, cloneTrack?: boolean): ILocalVideoTrack;
1549
+ /**
1550
+ * @ignore
1551
+ *
1552
+ * Enables/Disables image enhancement and sets the options.
1553
+ *
1554
+ * > Notes:
1555
+ * > - Agora is planning to sunset this built-in image enhancement feature.
1556
+ * You can use the upgraded Image Enhancement Extension instead. For details, see
1557
+ * [Use the Image Enhancement Extension](https://docs.agora.io/en/Video/beauty_effect_web_ng?platform=Web).
1558
+ * > - This method supports the following browsers:
1559
+ * > - Safari 12 or later.
1560
+ * > - Chrome 65 or later.
1561
+ * > - Firefox 70.0.1 or later.
1562
+ * > - This function is not supported on mobile devices.
1563
+ * > - If you enable dual-stream mode, the image enhancement options only apply to the high-quality video stream.
1564
+ *
1565
+ * @param enabled Whether to enable image enhancement:
1566
+ * - `true`: Enable image enhancement.
1567
+ * - `false`: Disable image enhancement.
1568
+ * @param options Sets image enhancement options. See [[BeautyEffectOptions]].
1569
+ */
1570
+ setBeautyEffect(enabled: boolean, options?: BeautyEffectOptions): Promise<void>;
1571
+ /**
1572
+ * @since
1573
+ * <br>&emsp;&emsp;&emsp;*4.1.0*
1574
+ *
1575
+ * Gets the data of the video frame being rendered.
1576
+ *
1577
+ * > You should call this method after calling [[play]]. Otherwise, the method call returns null.
1578
+ *
1579
+ * @returns An `ImageData` object that stores RGBA data. `ImageData` is a web API supported by the browser. For details, see [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData).
1580
+ */
1581
+ getCurrentFrameData(): ImageData;
1582
+ /**
1583
+ *
1584
+ * @ignore
1585
+ */
1586
+ getCurrentFrameImage(imageType: string, quality: number): Promise<ImageTypedData>;
1587
+ /**
1588
+ * @since
1589
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
1590
+ *
1591
+ * Sets the video transmission optimization mode.
1592
+ *
1593
+ * You can call this method during a video call, a live streaming or screen sharing to dynamically change the optimization mode. For example, during the screen sharing, before you change the shared content from text to video, you can change the optimization mode from `"detail"` to `"motion"` to ensure smoothness in poor network conditions.
1594
+ *
1595
+ * > Note: This method supports Chrome only.
1596
+ *
1597
+ * @param mode The video transmission optimization mode:
1598
+ * - `"balanced"`: Uses the default optimization mode.
1599
+ * - For a screen-sharing video track, the default transmission optimization strategy is to prioritizes clarity.
1600
+ * - For the other types of video tracks, the SDK may reduce the frame rate or the sending resolution in poor network conditions.
1601
+ * - `"detail"`: Prioritizes video quality.
1602
+ * - The SDK ensures high-quality images by automatically calculating a minimum bitrate based on the capturing resolution and frame rate. No matter how poor the network condition is, the sending bitrate will never be lower than the minimum value.
1603
+ * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
1604
+ * - `"motion"`: Prioritizes video smoothness.
1605
+ * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
1606
+ * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
1607
+ */
1608
+ setOptimizationMode(mode: "balanced" | "motion" | "detail"): Promise<void>;
1609
+ /**
1610
+ * @since
1611
+ * <br>&emsp;&emsp;&emsp;*4.8.0*
1612
+ *
1613
+ * Gets the visibility of the `<video>` HTML tag.
1614
+ *
1615
+ * After you call `localVideoTrack.play`, the SDK creates an [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) tag for playing video tracks. When `localVideoTrack.isPlaying` is `true` but you cannot see any video, call this method to check whether the `<video>` tag is visible or not and learn the reason when the `<video>` tag is invisible.
1616
+ *
1617
+ * @returns The [[CheckVideoVisibleResult]] object. If this method returns `undefined`, it may be due to the following reasons:
1618
+ * - `localVideoTrack.isPlaying` is `false`.
1619
+ * - The `<video>` tag does not exist.
1620
+ * - The `<video>` tag is not created by calling the `play` method.
1621
+ */
1622
+ getVideoElementVisibleStatus(): CheckVideoVisibleResult | undefined;
1623
+ /**
1624
+ * Inserts a `Processor` to the local video track.
1625
+ *
1626
+ * @param processor The `Processor` instance. Each extension has a corresponding type of `Processor`.
1627
+ *
1628
+ * @returns The `Processor` instance.
1629
+ */
1630
+ pipe(processor: IBaseProcessor): IBaseProcessor;
1631
+ /**
1632
+ * @since
1633
+ * <br>&emsp;&emsp;&emsp;*4.10.0*
1634
+ *
1635
+ * Removes the `Processor` inserted to the local video track.
1636
+ */
1637
+ unpipe(): void;
1638
+ /**
1639
+ * @since
1640
+ * <br>&emsp;&emsp;&emsp;*4.10.0*
1641
+ *
1642
+ * The destination of the current processing pipeline on the local video track.
1643
+ */
1644
+ processorDestination: IBaseProcessor;
1645
+ /**
1646
+ * @since
1647
+ * <br>&emsp;&emsp;&emsp;*4.17.0*
1648
+ *
1649
+ * Replaces the local video track.
1650
+ *
1651
+ * You can call this method before or after publishing the local video stream:
1652
+ * - If you call this method before publishing, the new video track is played locally.
1653
+ * - If you call this method after publishing, the new video track is received by the remote user.
1654
+ *
1655
+ * The new video track can be retrieved by the {@link ILocalVideoTrack.getMediaStreamTrack} or `mediaStream.getVideoTracks` method. You can choose to either stop or retain the replaced track.
1656
+ *
1657
+ * > Notes:
1658
+ * > - This method supports Chrome 65+, Safari, and the latest Firefox.
1659
+ * > - This method might not take effect on some mobile devices.
1660
+ * > - Agora recommends switching between video tracks that are of the same type and have the same encoder configurations for the following reasons:
1661
+ * > - If the video track types are different, such as replacing a `CameraVideoTrack` object with a `ScreenVideoTrack` object, the video is flipped horizontally due to the mirror effect enabled by default on `CameraVideoTrack` (see {@link VideoPlayerConfig.mirror} for details).
1662
+ * > - If the encoder configurations (`encoderConfig`) are different, the actual sending resolution or frame rate might be different from what you set.
1663
+ * > - The subscriber will not be notified if the track gets replaced.
1664
+ * > - To switch the media input devices, Agora recommends using {@link ICameraVideoTrack.setDevice}.
1665
+ *
1666
+ * **Example**
1667
+ * ```javascript
1668
+ * // Current video track
1669
+ * const localVideoTrack = await AgoraRTC.createCameraVideoTrack();
1670
+ * // Gets the new video track (option one)
1671
+ * const newTrack = localVideoTrack.getMediaStreamTrack();
1672
+ * // Gets the new video track (option two)
1673
+ * const newTrack = await navigator.mediaDevices.getUserMedia({audio: true, video: true}).then(mediaStream => mediaStream.getVideoTracks()[0]);
1674
+ * // Replaces and stops the current video track
1675
+ * await localVideoTrack.replaceTrack(newTrack, true);
1676
+ * ```
1677
+ * @param track The new video track, which is a [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object.
1678
+ * @param stopOldTrack Whether to stop the old video track:
1679
+ * - true: Stops the old video track.
1680
+ * - false: Retains the old video track.
1681
+ */
1682
+ replaceTrack(track: MediaStreamTrack, stopOldTrack: boolean): Promise<void>;
1683
+ /**
1684
+ * Sets the video encoder configurations, such as resolution, frame rate, and bitrate.
1685
+ *
1686
+ * @param config The video encoder configurations. You can pass either [[VideoEncoderConfigurationPreset]] or a customized [[VideoEncoderConfiguration]] object.
1687
+ */
1688
+ setEncoderConfiguration(config: VideoEncoderConfiguration | VideoEncoderConfigurationPreset): Promise<void>;
1689
+ /**
1690
+ * Add the SEI data to the H.264 video stream.
1691
+ *
1692
+ * @param config SEI data.
1693
+ */
1694
+ sendSeiData(sei: Uint8Array): void;
1695
+ }
1696
+
1697
+ export declare interface ImageTypedData {
1698
+ buffer: Uint8Array;
1699
+ width: number;
1700
+ height: number;
1701
+ }
1702
+
1703
+ /**
1704
+ * Inherited from [LocalAudioTrack]{@link ILocalAudioTrack}, `MicrophoneAudioTrack` is an interface for the audio sampled by a local microphone and adds several functions such as switching devices.
1705
+ *
1706
+ * You can create a local microphone audio track by calling [AgoraRTC.createMicrophoneAudioTrack]{@link IAgoraRTC.createMicrophoneAudioTrack}.
1707
+ */
1708
+ export declare interface IMicrophoneAudioTrack extends ILocalAudioTrack {
1709
+ /**
1710
+ * Sets the device for sampling audio.
1711
+ *
1712
+ * > You can call the method either before or after publishing an audio track.
1713
+ *
1714
+ * @param deviceId The ID of the specified device. You can get the `deviceId` by calling [AgoraRTC.getMicrophones]{@link IAgoraRTC.getMicrophones}.
1715
+ */
1716
+ setDevice(deviceId: string): Promise<void>;
1717
+ /**
1718
+ * @since
1719
+ * <br>&emsp;&emsp;&emsp;*4.0.0*
1720
+ *
1721
+ * Enables/Disables the track.
1722
+ *
1723
+ * After a track is disabled, the SDK stops playing and publishing the track.
1724
+ *
1725
+ * > - Disabling a track does not trigger the [LocalTrack.on("track-ended")]{@link event_track_ended} event.
1726
+ * > - If a track is published, disabling this track triggers the [user-unpublished]{@link IAgoraRTCClient.event_user_unpublished} event on the remote client, and re-enabling this track triggers the [user-published]{@link IAgoraRTCClient.event_user_published} event.
1727
+ * > - Do not call `setEnabled` and `setMuted` together.
1728
+ *
1729
+ * @param enabled Whether to enable the track:
1730
+ * - `true`: Enable the track.
1731
+ * - `false`: Disable the track.
1732
+ */
1733
+ setEnabled(enabled: boolean): Promise<void>;
1734
+ }
1735
+
1736
+ export declare function interceptLocalAudioFrame(sender: RTCRtpSender): Promise<void>;
1737
+
1738
+ export declare function interceptLocalVideoFrame(sender: RTCRtpSender, localVideoTrack: LocalVideoTrack): Promise<void>;
1739
+
1740
+ export declare function interceptRemoteAudioFrame(receiver: RTCRtpReceiver): Promise<void>;
1741
+
1742
+ export declare function interceptRemoteVideoFrame(receiver: RTCRtpReceiver, options?: InterceptVideoFrameOptions): Promise<void>;
1743
+
1744
+ declare interface InterceptVideoFrameOptions {
1745
+ onSei?: (sei: Uint8Array) => void;
1746
+ }
1747
+
1748
+ /**
1749
+ * `RemoteAudioTrack` is the basic interface for the remote audio track.
1750
+ *
1751
+ * You can get create a remote audio track by the [AgoraRTCRemoteUser.audioTrack]{@link IAgoraRTCRemoteUser.audioTrack} object after calling [subscribe]{@link IAgoraRTCClient.subscribe}.
1752
+ */
1753
+ export declare interface IRemoteAudioTrack extends IRemoteTrack {
1754
+ /**
1755
+ * Gets the statistics of a remote audio track.
1756
+ *
1757
+ * @return An [[RemoteAudioTrackStats]] object.
1758
+ */
1759
+ getStats(): RemoteAudioTrackStats;
1760
+ /**
1761
+ * Plays a remote audio track.
1762
+ *
1763
+ * > When playing the audio track, you do not need to pass any DOM element.
1764
+ */
1765
+ play(): void;
1766
+ /**
1767
+ * @since
1768
+ * <br>&emsp;&emsp;&emsp;*4.1.0*
1769
+ *
1770
+ * Sets the audio playback device, for example, the speaker.
1771
+ *
1772
+ * > > This method is only supported on desktop Chrome and Edge browsers. If you call it on other browsers, you need to set `RESTRICTION_SET_PLAYBACK_DEVICE` to `false` first, and calling it directly will throw a `NOT_SUPPORTED` error.
1773
+ * @param deviceId Device ID, which can be retrieved by calling [[getPlaybackDevices]].
1774
+ */
1775
+ setPlaybackDevice(deviceId: string): Promise<void>;
1776
+ /**
1777
+ * Sets the callback for getting raw audio data in PCM format.
1778
+ *
1779
+ * After you successfully set the callback, the SDK constantly returns the audio frames of a remote audio track in this callback by using [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer).
1780
+ *
1781
+ * > You can set the `frameSize` parameter to determine the frame size in each callback, which affects the interval between the callbacks. The larger the frame size, the longer the interval between them.
1782
+ *
1783
+ * ```js
1784
+ * track.setAudioFrameCallback((buffer) => {
1785
+ * for (let channel = 0; channel < buffer.numberOfChannels; channel += 1) {
1786
+ * // Float32Array with PCM data
1787
+ * const currentChannelData = buffer.getChannelData(channel);
1788
+ * console.log("PCM data in channel", channel, currentChannelData);
1789
+ * }
1790
+ * }, 2048);
1791
+ *
1792
+ * // ....
1793
+ * // Stop getting the raw audio data
1794
+ * track.setAudioFrameCallback(null);
1795
+ * ```
1796
+ *
1797
+ * @param audioFrameCallback The callback function for receiving the [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer) object. If you set `audioBufferCallback` as `null`, the SDK stops getting raw audio data.
1798
+ * @param frameSize The number of samples of each audio channel that an `AudioBuffer` object contains. You can set `frameSize` as 256, 512, 1024, 2048, 4096, 8192, or 16384. The default value is 4096.
1799
+ */
1800
+ setAudioFrameCallback(audioFrameCallback: null | ((buffer: AudioBuffer) => void), frameSize?: number): void;
1801
+ /**
1802
+ * Sets the volume of a remote audio track.
1803
+ *
1804
+ * @param volume The volume. The value ranges from 0 (mute) to 100 (maximum). A value of 100 is the current volume.
1805
+ */
1806
+ setVolume(volume: number): void;
1807
+ /**
1808
+ * Gets the audio level of a remote audio track.
1809
+ *
1810
+ * @returns The audio level. The value range is [0,1]. 1 is the highest audio level.
1811
+ * Usually a user with audio level above 0.6 is a speaking user.
1812
+ */
1813
+ getVolumeLevel(): number;
1814
+ /**
1815
+ * @since
1816
+ * <br>&emsp;&emsp;&emsp;*4.13.0*
1817
+ *
1818
+ * Inserts a `Processor` to the remote audio track.
1819
+ *
1820
+ * @param processor The `Processor` instance. Each extension has a corresponding type of `Processor`.
1821
+ *
1822
+ * @returns The `Processor` instance.
1823
+ */
1824
+ pipe(processor: IAudioProcessor): IAudioProcessor;
1825
+ /**
1826
+ * @since
1827
+ * <br>&emsp;&emsp;&emsp;*4.13.0*
1828
+ *
1829
+ * Removes the `Processor` inserted to the remote audio track.
1830
+ */
1831
+ unpipe(): void;
1832
+ /**
1833
+ * @since
1834
+ * <br>&emsp;&emsp;&emsp;*4.13.0*
1835
+ *
1836
+ * The destination of the current processing pipeline on the remote audio track.
1837
+ */
1838
+ processorDestination: IAudioProcessor;
1839
+ }
1840
+
1841
+ /**
1842
+ * @ignore
1843
+ */
1844
+ export declare interface IRemoteDataChannel extends IDataChannel {
1845
+ /** @internal */
1846
+ on(event: "open", listener: typeof event_user_datachannel_open): void;
1847
+ /** @internal */
1848
+ on(event: "close", listener: typeof event_user_datachannel_close): void;
1849
+ /** @internal */
1850
+ on(event: "error", listener: typeof event_user_datachannel_error): void;
1851
+ /** @internal */
1852
+ on(event: "message", listener: typeof event_user_datachannel_message): void;
1853
+ }
1854
+
1855
+ /**
1856
+ * `RemoteTrack` is the basic interface for remote tracks, providing public methods for [RemoteAudioTrack]{@link IRemoteAudioTrack} and [RemoteVideoTrack]{@link IRemoteVideoTrack}.
1857
+ */
1858
+ export declare interface IRemoteTrack extends ITrack {
1859
+ /**
1860
+ * @param event The event name.
1861
+ * @param listener See [track-updated]{@link event_track_updated}.
1862
+ */
1863
+ on(event: "track-updated", listener: typeof event_track_updated): void;
1864
+ /**
1865
+ * @param event The event name.
1866
+ * @param listener See [first-frame-decoded]{@link event_first_frame_decoded}.
1867
+ */
1868
+ on(event: "first-frame-decoded", listener: typeof event_first_frame_decoded): void;
1869
+ /**
1870
+ * Adds an event listener.
1871
+ * @param event The event name.
1872
+ * @param listener See [IRemoteTrack.transceiver-updated]{@link event_transceiver_updated_2}.
1873
+ */
1874
+ on(event: "transceiver-updated", listener: typeof event_transceiver_updated_2): void;
1875
+ /**
1876
+ * Gets the `uid` of the remote user who publishes the remote track.
1877
+ *
1878
+ * @return The `uid` of the remote user.
1879
+ */
1880
+ getUserId(): UID;
1881
+ /**
1882
+ * Gets the statistics of a remote track.
1883
+ *
1884
+ * @deprecated from v4.1.0. Use [AgoraRTCClient.getRemoteVideoStats]{@link IAgoraRTCClient.getRemoteVideoStats} and [AgoraRTCClient.getRemoteAudioStats]{@link IAgoraRTCClient.getRemoteAudioStats} instead.
1885
+ * @return An [[RemoteAudioTrackStats]] or [[RemoteVideoTrackStats]] object.
1886
+ */
1887
+ getStats(): RemoteAudioTrackStats | RemoteVideoTrackStats;
1888
+ }
1889
+
1890
+ /**
1891
+ * `RemoteVideoTrack` is the basic interface for the remote video track.
1892
+ *
1893
+ * You can get create a remote video track by the [AgoraRTCRemoteUser.videoTrack]{@link IAgoraRTCRemoteUser.videoTrack} object after calling [subscribe]{@link IAgoraRTCClient.subscribe}.
1894
+ */
1895
+ export declare interface IRemoteVideoTrack extends IRemoteTrack {
1896
+ /**
1897
+ * @param event The event name.
1898
+ * @param listener See [track-updated]{@link event_track_updated}.
1899
+ */
1900
+ on(event: "track-updated", listener: typeof event_track_updated): void;
1901
+ /**
1902
+ * @param event The event name.
1903
+ * @param listener See [video-state-changed]{@link event_video_state_changed}.
1904
+ */
1905
+ on(event: "video-state-changed", listener: typeof event_video_state_changed): void;
1906
+ /**
1907
+ * @param event The event name.
1908
+ * @param listener See [first-frame-decoded]{@link event_first_frame_decoded}.
1909
+ */
1910
+ on(event: "first-frame-decoded", listener: typeof event_first_frame_decoded): void;
1911
+ /**
1912
+ * @param event The event name.
1913
+ * @param listener See [video-element-visible-status]{@link event_video_element_visible_status_2}.
1914
+ */
1915
+ on(event: "video-element-visible-status", listener: typeof event_video_element_visible_status_2): void;
1916
+ /**
1917
+ * Adds an event listener.
1918
+ * @param event The event name.
1919
+ * @param listener See [IRemoteTrack.transceiver-updated]{@link event_transceiver_updated_2}.
1920
+ */
1921
+ on(event: "transceiver-updated", listener: typeof event_transceiver_updated_2): void;
1922
+ /**
1923
+ * Adds an event listener.
1924
+ * @param event The event name.
1925
+ * @param listener See [ILocalTrack.sei-received]{@link event_sei_received}.
1926
+ */
1927
+ on(event: "sei-received", listener: typeof event_sei_received): void;
1928
+ /**
1929
+ * Gets the statistics of a remote video track.
1930
+ *
1931
+ * @return An [[RemoteVideoTrackStats]] object。
1932
+ */
1933
+ getStats(): RemoteVideoTrackStats;
1934
+ /**
1935
+ * Plays a remote video track on the web page.
1936
+ *
1937
+ * @param element Specifies a DOM element. The SDK will create a `<video>` element under the specified DOM element to play the video track. You can specify a DOM element in either of following ways:
1938
+ * - `string`: Specify the ID of the DOM element.
1939
+ * - `HTMLElement`: Pass a DOM object.
1940
+ * @param config Sets the playback configurations, such as display mode and mirror mode. See [[VideoPlayerConfig]]. By default, the SDK enables mirror mode for a local video track.
1941
+ */
1942
+ play(element: string | HTMLElement, config?: VideoPlayerConfig): void;
1943
+ /**
1944
+ * @since
1945
+ * <br>&emsp;&emsp;&emsp;*4.1.0*
1946
+ *
1947
+ * Gets the data of the video frame being rendered.
1948
+ *
1949
+ * > You should call this method after calling [[play]]. Otherwise, the method call returns null.
1950
+ *
1951
+ * @returns An `ImageData` object that stores RGBA data. `ImageData` is a web API supported by the browser. For details, see [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData).
1952
+ */
1953
+ getCurrentFrameData(): ImageData;
1954
+ /**
1955
+ * @since
1956
+ * <br>&emsp;&emsp;&emsp;*4.8.0*
1957
+ *
1958
+ * Gets the visibility of the `<video>` HTML tag.
1959
+ *
1960
+ * After you call `remoteVideoTrack.play`, the SDK creates an [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) tag for playing video tracks. When `remoteVideoTrack.isPlaying` is `true` but you cannot see any video, call this method to check whether the `<video>` tag is visible or not and learn the reason when the `<video>` tag is invisible.
1961
+ *
1962
+ * @returns The [[CheckVideoVisibleResult]] object. If this method returns `undefined`, it may be due to the following reasons:
1963
+ * - `remoteVideoTrack.isPlaying` is `false`.
1964
+ * - The `<video>` tag does not exist.
1965
+ * - The `<video>` tag is not created by calling the `play` method.
1966
+ */
1967
+ getVideoElementVisibleStatus(): CheckVideoVisibleResult | undefined;
1968
+ /**
1969
+ * @since
1970
+ * <br>&emsp;&emsp;&emsp;*4.13.0*
1971
+ *
1972
+ * Inserts a `Processor` to the remote video track.
1973
+ *
1974
+ * @param processor The `Processor` instance. Each extension has a corresponding type of `Processor`.
1975
+ *
1976
+ * @returns The `Processor` instance.
1977
+ */
1978
+ pipe(processor: IBaseProcessor): IBaseProcessor;
1979
+ /**
1980
+ * @since
1981
+ * <br>&emsp;&emsp;&emsp;*4.13.0*
1982
+ *
1983
+ * Removes the `Processor` inserted to the remote video track.
1984
+ */
1985
+ unpipe(): void;
1986
+ /**
1987
+ * @since
1988
+ * <br>&emsp;&emsp;&emsp;*4.13.0*
1989
+ *
1990
+ * The destination of the current processing pipeline on the remote video track.
1991
+ */
1992
+ processorDestination: IBaseProcessor;
1993
+ }
1994
+
1995
+ export declare function isAudioEncoderConfiguration(config: AudioEncoderConfiguration): config is AudioEncoderConfiguration;
1996
+
1997
+ export declare function isAudioEncoderConfigurationOrPreset(profile: any): profile is AudioEncoderConfigurationPreset | AudioEncoderConfiguration;
1998
+
1999
+ export declare function isBeautyEffectOptions(options: BeautyEffectOptions): options is BeautyEffectOptions;
2000
+
2001
+ export { isElectron }
2002
+
2003
+ export declare function isLowStreamParameter(streamParameter: any): streamParameter is LowStreamParameter;
2004
+
2005
+ export declare function isScreenSourceType(mediaSource: any): mediaSource is ScreenSourceType;
2006
+
2007
+ export declare function isVideoEncoderConfiguration(config: VideoEncoderConfiguration): config is VideoEncoderConfiguration;
2008
+
2009
+ export declare function isVideoEncoderConfigurationOrPreset(profile: any): profile is VideoEncoderConfigurationPreset | VideoEncoderConfiguration;
2010
+
2011
+ export declare interface ITrack extends EventEmitter {
2012
+ /**
2013
+ * The type of a media track:
2014
+ * - `"audio"`: Audio track.
2015
+ * - `"video"`: Video track.
2016
+ */
2017
+ trackMediaType: "audio" | "video";
2018
+ /**
2019
+ * Whether a media track is playing on the webpage:
2020
+ * - `true`: The media track is playing on the webpage.
2021
+ * - `false`: The media track is not playing on the webpage.
2022
+ */
2023
+ isPlaying: boolean;
2024
+ /**
2025
+ * Gets the ID of a media track, a unique identifier generated by the SDK.
2026
+ *
2027
+ * @return The media track ID.
2028
+ */
2029
+ getTrackId(): string;
2030
+ /**
2031
+ * Gets an [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object.
2032
+ *
2033
+ * @return An [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object.
2034
+ */
2035
+ getMediaStreamTrack(): MediaStreamTrack;
2036
+ /**
2037
+ * Gets the [RTCRtpTransceiver](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver) instance of the current track.
2038
+ *
2039
+ * This method is currently mainly used for end-to-end encryption of video streams (Beta).
2040
+ *
2041
+ * > If the SDK experiences a reconnection, the `RTCRtpTransceiver` instance corresponding to the current track might change. You can obtain the new `RTCRtpTransceiver` instance through the following callbacks:
2042
+ * > - For a local track: [ILocalTrack.transceiver-updated]{@link event_transceiver_updated}
2043
+ * > - For a remote track: [IRemoteTrack.transceiver-updated]{@link event_transceiver_updated_2}
2044
+ *
2045
+ * @param type The type of the video stream. See {@link StreamType}.
2046
+ * @returns The [RTCRtpTransceiver](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver) instance of the current track.
2047
+ */
2048
+ getRTCRtpTransceiver(type?: StreamType): RTCRtpTransceiver | undefined;
2049
+ /**
2050
+ * Plays a media track on the webpage.
2051
+ *
2052
+ * @param element Specifies a DOM element. The SDK will create a `<video>` element under the specified DOM element to play the video track. You can specify a DOM element in either of following ways:
2053
+ * - `string`: Specify the ID of the DOM element.
2054
+ * - `HTMLElement`: Pass a DOM object.
2055
+ */
2056
+ play(element?: string | HTMLElement): void;
2057
+ /**
2058
+ * Stops playing the media track.
2059
+ */
2060
+ stop(): void;
2061
+ }
2062
+
2063
+ export declare class LocalAudioTrack extends LocalTrack implements ILocalAudioTrack {
2064
+ readonly trackMediaType: "audio" | "video";
2065
+ _encoderConfig?: AudioEncoderConfiguration;
2066
+ _trackSource: AudioTrackSource | FakeTrackSource;
2067
+ get _source(): AudioTrackSource;
2068
+ set _source(source: AudioTrackSource | FakeTrackSource);
2069
+ _enabled: boolean;
2070
+ private _volume;
2071
+ _useAudioElement: boolean;
2072
+ _bypassWebAudio: boolean;
2073
+ protected processor?: IAudioProcessor;
2074
+ protected _processorContext: AudioProcessorContext | undefined;
2075
+ protected get processorContext(): AudioProcessorContext;
2076
+ _processorDestination: AudioProcessorDestination | undefined;
2077
+ get processorDestination(): AudioProcessorDestination;
2078
+ protected _getOriginVolumeLevel: boolean;
2079
+ get isPlaying(): boolean;
2080
+ get __className__(): string;
2081
+ constructor(track: MediaStreamTrack, encoderConfig?: AudioEncoderConfiguration, trackId?: string, getOriginVolumeLevel?: boolean);
2082
+ setVolume(volume: number): void;
2083
+ getVolumeLevel(): number;
2084
+ setPlaybackDevice(deviceId: string): Promise<void>;
2085
+ setEnabled(enabled: boolean, _?: any, skipChangeState?: boolean): Promise<void>;
2086
+ protected _setEnabled(enabled: boolean, _?: any, skipChangeState?: boolean): Promise<void>;
2087
+ setMuted(muted: boolean): Promise<void>;
2088
+ getStats(): LocalAudioTrackStats;
2089
+ setAudioFrameCallback(callback: null | ((buffer: AudioBuffer) => void), frameSize?: number): void;
2090
+ play(): void;
2091
+ stop(): void;
2092
+ close(): void;
2093
+ protected _updatePlayerSource(updateWebAudioSource?: boolean): void;
2094
+ protected _updateOriginMediaStreamTrack(track: MediaStreamTrack, stopOldTrack: boolean): Promise<void>;
2095
+ renewMediaStreamTrack(newConstraints?: MediaTrackConstraints): Promise<void>;
2096
+ pipe(processor: IAudioProcessor): IAudioProcessor;
2097
+ unpipe(): void;
2098
+ private bindProcessorDestinationEvents;
2099
+ private unbindProcessorDestinationEvents;
2100
+ protected bindProcessorContextEvents(processorContext: AudioProcessorContext): void;
2101
+ protected unbindProcessorContextEvents(processorContext: AudioProcessorContext): void;
2102
+ private initWebAudio;
2103
+ private initProcessor;
2104
+ }
2105
+
2106
+ /**
2107
+ * Information of the local audio track, which can be retrieved by calling [AgoraRTCClient.getLocalAudioStats]{@link IAgoraRTCClient.getLocalAudioStats}.
2108
+ */
2109
+ export declare interface LocalAudioTrackStats {
2110
+ /**
2111
+ * The audio codec.
2112
+ *
2113
+ * - `"opus"`: The audio codec is OPUS。
2114
+ * - `"aac"`: The audio codec is AAC。
2115
+ * - `"pcmu"`: Reserved for future use.
2116
+ * - `"pcma"`: Reserved for future use.
2117
+ * - `"g722"`: Reserved for future use.
2118
+ *
2119
+ * > Firefox does not support this property.
2120
+ */
2121
+ codecType?: "opus" | "aac" | "PCMU" | "PCMA" | "G722";
2122
+ /**
2123
+ * The energy level of the sent audio.
2124
+ *
2125
+ * The value range is [0,32767].
2126
+ *
2127
+ * > This value is retrieved by calling WebRTC-Stats and may not be up-to-date. To get the real-time sound volume, call [LocalAudioTrack.getVolumeLevel]{@link ILocalAudioTrack.getVolumeLevel}.
2128
+ */
2129
+ sendVolumeLevel: number;
2130
+ /**
2131
+ * The bitrate (bps) of the sent audio.
2132
+ */
2133
+ sendBitrate: number;
2134
+ /**
2135
+ * The total bytes of the sent audio.
2136
+ */
2137
+ sendBytes: number;
2138
+ /**
2139
+ * The total packets of the sent audio.
2140
+ */
2141
+ sendPackets: number;
2142
+ /**
2143
+ * The total number of lost audio packets that were sent.
2144
+ *
2145
+ * > You can not get this property on Safari.
2146
+ */
2147
+ sendPacketsLost: number;
2148
+ /**
2149
+ * Jitter (ms) of the audio packets that were sent.
2150
+ */
2151
+ sendJitterMs: number;
2152
+ /**
2153
+ * Round-trip time delay (ms) of the audio packets that were sent.
2154
+ */
2155
+ sendRttMs: number;
2156
+ /**
2157
+ * The packet loss rate of the sent audio in 400ms.
2158
+ */
2159
+ currentPacketLossRate: number;
2160
+ }
2161
+
2162
+ export declare class LocalDataChannel extends DataChannel implements ILocalDataChannel {
2163
+ send(data: ArrayBuffer): void;
2164
+ }
2165
+
2166
+ export declare abstract class LocalTrack extends Track implements ILocalTrack {
2167
+ _enabled: boolean;
2168
+ _muted: boolean;
2169
+ _isExternalTrack: boolean;
2170
+ get isExternalTrack(): boolean;
2171
+ get muted(): boolean;
2172
+ get enabled(): boolean;
2173
+ _isClosed: boolean;
2174
+ protected _enabledMutex: PromiseMutex;
2175
+ protected processor?: IBaseProcessor;
2176
+ protected abstract _processorContext: IProcessorContext | undefined;
2177
+ protected get processorContext(): IProcessorContext | undefined;
2178
+ abstract get processorDestination(): IBaseProcessor;
2179
+ constructor(track: MediaStreamTrack, trackId?: string);
2180
+ abstract getStats(): LocalVideoTrackStats | LocalAudioTrackStats;
2181
+ abstract setMuted(enabled: boolean): Promise<void>;
2182
+ abstract setEnabled(enabled: boolean): Promise<void>;
2183
+ getTrackLabel(): string;
2184
+ close(): void;
2185
+ protected _updateOriginMediaStreamTrack(track: MediaStreamTrack, stopOldTrack: boolean, isExternalTrack?: boolean): Promise<void>;
2186
+ protected abstract _updatePlayerSource(): void;
2187
+ protected _getDefaultPlayerConfig(): Partial<PlayerConfig>;
2188
+ protected _handleTrackEnded: () => void;
2189
+ protected onTrackEnded(): void;
2190
+ protected stateCheck(stateName: "enabled" | "muted", state: boolean): void;
2191
+ abstract renewMediaStreamTrack(): Promise<void>;
2192
+ getProcessorStats(): ProcessorStats[];
2193
+ getProcessorUsage(): Promise<UsageWithDirection[]>;
2194
+ }
2195
+
2196
+ export declare enum LocalTrackEvents {
2197
+ SOURCE_STATE_CHANGE = "source-state-change",
2198
+ TRACK_ENDED = "track-ended",
2199
+ BEAUTY_EFFECT_OVERLOAD = "beauty-effect-overload",
2200
+ VIDEO_ELEMENT_VISIBLE_STATUS = "video-element-visible-status",
2201
+ CLOSED = "closed"
2202
+ }
2203
+
2204
+ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTrack {
2205
+ readonly trackMediaType: "audio" | "video";
2206
+ _player?: AgoraRTCPlayer | VideoPlayer;
2207
+ isUseScaleResolutionDownBy: boolean;
2208
+ private _videoVisibleTimer;
2209
+ protected _statsTimer: number | null;
2210
+ private _previousVideoVisibleStatus;
2211
+ private _clearPreviousVideoVisibleStatus;
2212
+ _encoderConfig?: Partial<VideoEncoderConfiguration>;
2213
+ _scalabilityMode?: SVCConfiguration;
2214
+ _optimizationMode?: OptimizationMode | "balanced";
2215
+ private _videoHeight?;
2216
+ private _videoWidth?;
2217
+ get videoHeight(): number | undefined;
2218
+ get videoWidth(): number | undefined;
2219
+ _forceBitrateLimit?: {
2220
+ max_bitrate: number;
2221
+ min_bitrate: number;
2222
+ };
2223
+ _enabled: boolean;
2224
+ get isPlaying(): boolean;
2225
+ protected _processorDestination: VideoProcessorDestination;
2226
+ get processorDestination(): VideoProcessorDestination;
2227
+ protected _processorContext: VideoProcessorContext;
2228
+ protected get processorContext(): VideoProcessorContext;
2229
+ protected set processorContext(ctx: VideoProcessorContext);
2230
+ get __className__(): string;
2231
+ constructor(track: MediaStreamTrack, encoderConfig?: Partial<VideoEncoderConfiguration>, scalabilityConfig?: SVCConfiguration, optimizationMode?: OptimizationMode | "balanced", trackId?: string, hints?: TrackHint[]);
2232
+ play(element: HTMLElement | HTMLVideoElement | string, config?: VideoPlayerConfig): void;
2233
+ stop(): void;
2234
+ setEnabled(enabled: boolean, skipChangeState?: boolean): Promise<void>;
2235
+ setMuted(muted: boolean): Promise<void>;
2236
+ setEncoderConfiguration(config: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, doNotRenegoation?: boolean): Promise<void>;
2237
+ getStats(): LocalVideoTrackStats;
2238
+ setBeautyEffect(enabled: boolean, options?: BeautyEffectOptions): Promise<void>;
2239
+ getCurrentFrameData(): ImageData;
2240
+ getCurrentFrameImage(imageType: string, quality?: number): Promise<ImageTypedData>;
2241
+ setBitrateLimit(bitrateLimit: {
2242
+ max_bitrate: number;
2243
+ min_bitrate: number;
2244
+ }): Promise<void>;
2245
+ setOptimizationMode(mode: OptimizationMode | "balanced"): Promise<void>;
2246
+ setScalabiltyMode(mode: SVCConfiguration): void;
2247
+ updateMediaStreamTrackResolution(): void;
2248
+ protected _updatePlayerSource(): void;
2249
+ protected _getDefaultPlayerConfig(): Partial<VideoPlayerConfig>;
2250
+ protected setSenderConfiguration(config: VideoEncoderConfiguration | VideoEncoderConfigurationPreset): Promise<void>;
2251
+ updateBitrateFromProfile(): void;
2252
+ getVideoElementVisibleStatus(): CheckVideoVisibleResult | undefined;
2253
+ renewMediaStreamTrack(newConstraints?: MediaTrackConstraints): Promise<void>;
2254
+ pipe(processor: IBaseProcessor): IBaseProcessor;
2255
+ unpipe(): void;
2256
+ close(): void;
2257
+ clone(config?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, cloneTrack?: boolean): LocalVideoTrack;
2258
+ replaceTrack(track: MediaStreamTrack, stopOldTrack: boolean): Promise<void>;
2259
+ startMonitorStats(): void;
2260
+ sendSeiData(sei: Uint8Array): never;
2261
+ private bindProcessorDestinationEvents;
2262
+ private unbindProcessorDestinationEvents;
2263
+ private unbindProcessorContextEvents;
2264
+ }
2265
+
2266
+ /**
2267
+ * Information of the local video track, which can be retrieved by calling [AgoraRTCClient.getLocalVideoStats]{@link IAgoraRTCClient.getLocalVideoStats}.
2268
+ */
2269
+ export declare interface LocalVideoTrackStats {
2270
+ /**
2271
+ * The video codec.
2272
+ *
2273
+ * - `"H264"`: The video codec is H.264.
2274
+ * - `"VP8"`: The video codec is VP8.
2275
+ * - `"VP9"`: The video codec is VP9.
2276
+ * - `"AV1X"`: Reserved for future use.
2277
+ * - `"AV1"`: Reserved for future use.
2278
+ *
2279
+ * > You can not get this property on Firefox.
2280
+ */
2281
+ codecType?: "H264" | "H265" | "VP8" | "VP9" | "AV1X" | "AV1";
2282
+ /**
2283
+ * The total bytes of the sent video.
2284
+ */
2285
+ sendBytes: number;
2286
+ /**
2287
+ * The frame rate (fps) of the sent video.
2288
+ *
2289
+ * > You can not get this property on Firefox.
2290
+ */
2291
+ sendFrameRate?: number;
2292
+ /**
2293
+ * The frame rate (fps) of the captured video.
2294
+ *
2295
+ * > You can not get this property on Safari and Firefox.
2296
+ */
2297
+ captureFrameRate?: number;
2298
+ /**
2299
+ * The total packets of the sent video.
2300
+ */
2301
+ sendPackets: number;
2302
+ /**
2303
+ * The total number of lost video packets that were sent.
2304
+ *
2305
+ * > - You can not get this property on Safari.
2306
+ * > - This property is inaccurate on Firefox.
2307
+ */
2308
+ sendPacketsLost: number;
2309
+ /**
2310
+ * Jitter (ms) of the video packets that were sent.
2311
+ */
2312
+ sendJitterMs: number;
2313
+ /**
2314
+ * Round-trip time delay (ms) of the video packets that were sent.
645
2315
  */
646
- on(event: "sei-received", listener: typeof event_sei_received): void;
2316
+ sendRttMs: number;
647
2317
  /**
648
- * Gets the statistics of a remote video track.
649
- *
650
- * @return An [[RemoteVideoTrackStats]] object。
2318
+ * The resolution height (pixel) of the sent video.
651
2319
  */
652
- getStats(): RemoteVideoTrackStats;
2320
+ sendResolutionHeight: number;
653
2321
  /**
654
- * Plays a remote video track on the web page.
655
- *
656
- * @param element Specifies a DOM element. The SDK will create a `<video>` element under the specified DOM element to play the video track. You can specify a DOM element in either of following ways:
657
- * - `string`: Specify the ID of the DOM element.
658
- * - `HTMLElement`: Pass a DOM object.
659
- * @param config Sets the playback configurations, such as display mode and mirror mode. See [[VideoPlayerConfig]]. By default, the SDK enables mirror mode for a local video track.
2322
+ * The resolution width (pixel) of the sent video.
660
2323
  */
661
- play(element: string | HTMLElement, config?: VideoPlayerConfig): void;
2324
+ sendResolutionWidth: number;
662
2325
  /**
663
- * @since
664
- * <br>&emsp;&emsp;&emsp;*4.1.0*
665
- *
666
- * Gets the data of the video frame being rendered.
667
- *
668
- * > You should call this method after calling [[play]]. Otherwise, the method call returns null.
669
- *
670
- * @returns An `ImageData` object that stores RGBA data. `ImageData` is a web API supported by the browser. For details, see [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData).
2326
+ * The resolution height (pixel) of the captured video.
671
2327
  */
672
- getCurrentFrameData(): ImageData;
2328
+ captureResolutionHeight: number;
673
2329
  /**
674
- * @since
675
- * <br>&emsp;&emsp;&emsp;*4.8.0*
676
- *
677
- * Gets the visibility of the `<video>` HTML tag.
678
- *
679
- * After you call `remoteVideoTrack.play`, the SDK creates an [`<video>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) tag for playing video tracks. When `remoteVideoTrack.isPlaying` is `true` but you cannot see any video, call this method to check whether the `<video>` tag is visible or not and learn the reason when the `<video>` tag is invisible.
680
- *
681
- * @returns The [[CheckVideoVisibleResult]] object. If this method returns `undefined`, it may be due to the following reasons:
682
- * - `localRemoteTrack.isPlaying` is `false`.
683
- * - The `<video>` tag does not exist.
684
- * - The `<video>` tag is not created by calling the `play` method.
2330
+ * The resolution width (pixel) of the captured video.
685
2331
  */
686
- getVideoElementVisibleStatus(): CheckVideoVisibleResult | undefined;
2332
+ captureResolutionWidth: number;
687
2333
  /**
688
- * @since
689
- * <br>&emsp;&emsp;&emsp;*4.13.0*
690
- *
691
- * Inserts a `Processor` to the remote video track.
692
- *
693
- * @param processor The `Processor` instance. Each extension has a corresponding type of `Processor`.
694
- *
695
- * @returns The `Processor` instance.
2334
+ * The time (ms) required for encoding the captured video.
696
2335
  */
697
- pipe(processor: IBaseProcessor): IBaseProcessor;
2336
+ encodeDelay?: number;
698
2337
  /**
699
- * @since
700
- * <br>&emsp;&emsp;&emsp;*4.13.0*
701
- *
702
- * Removes the `Processor` inserted to the remote video track.
2338
+ * The bitrate (bps) of the sent video.
703
2339
  */
704
- unpipe(): void;
2340
+ sendBitrate: number;
705
2341
  /**
706
- * @since
707
- * <br>&emsp;&emsp;&emsp;*4.13.0*
708
- *
709
- * The destination of the current processing pipeline on the remote video track.
2342
+ * The target bitrate (bps) of the sent video, namely the bitrate set in {@link VideoEncoderConfiguration}.
710
2343
  */
711
- processorDestination: IBaseProcessor;
712
- }
713
-
714
- export declare interface ITrack extends EventEmitter {
2344
+ targetSendBitrate: number;
715
2345
  /**
716
- * The type of a media track:
717
- * - `"audio"`: Audio track.
718
- * - `"video"`: Video track.
2346
+ * The total duration of the sent video in seconds.
719
2347
  */
720
- trackMediaType: "audio" | "video";
2348
+ totalDuration: number;
721
2349
  /**
722
- * Whether a media track is playing on the webpage:
723
- * - `true`: The media track is playing on the webpage.
724
- * - `false`: The media track is not playing on the webpage.
2350
+ * The total freeze time of the encoded video in seconds.
725
2351
  */
726
- isPlaying: boolean;
2352
+ totalFreezeTime: number;
727
2353
  /**
728
- * Gets the ID of a media track, a unique identifier generated by the SDK.
729
- *
730
- * @return The media track ID.
2354
+ * The packet loss rate of the sent video in 400ms.
731
2355
  */
732
- getTrackId(): string;
2356
+ currentPacketLossRate: number;
2357
+ }
2358
+
2359
+ /**
2360
+ * The video profile of the low-quality video stream. Set the the video profile of the low-quality video stream when calling [setLowStreamParameter]{@link IAgoraRTCClient.setLowStreamParameter}.
2361
+ */
2362
+ export declare interface LowStreamParameter {
733
2363
  /**
734
- * Gets an [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object.
2364
+ * Width of the video.
735
2365
  *
736
- * @return An [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object.
2366
+ * You can pass a `number`, or a constraint such as `{ max: 1280, min: 720 }`.
2367
+ *
2368
+ * For more details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
737
2369
  */
738
- getMediaStreamTrack(): MediaStreamTrack;
2370
+ width: ConstrainULong;
739
2371
  /**
740
- * Gets the [RTCRtpTransceiver](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver) instance of the current track.
741
- *
742
- * This method is currently mainly used for end-to-end encryption of video streams (Beta).
2372
+ * Height of the video.
743
2373
  *
744
- * > If the SDK experiences a reconnection, the `RTCRtpTransceiver` instance corresponding to the current track might change. You can obtain the new `RTCRtpTransceiver` instance through the following callbacks:
745
- * > - For a remote track: [IRemoteTrack.transceiver-updated]{@link event_transceiver_updated_2}
2374
+ * You can pass a `number`, or a constraint such as `{ max: 1280, min: 720 }`.
746
2375
  *
747
- * @param type The type of the video stream. See {@link StreamType}.
748
- * @returns The [RTCRtpTransceiver](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver) instance of the current track.
2376
+ * For more details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
749
2377
  */
750
- getRTCRtpTransceiver(type?: StreamType): RTCRtpTransceiver | undefined;
2378
+ height: ConstrainULong;
751
2379
  /**
752
- * Plays a media track on the webpage.
2380
+ * Frame rate of the video (fps).
753
2381
  *
754
- * @param element Specifies a DOM element. The SDK will create a `<video>` element under the specified DOM element to play the video track. You can specify a DOM element in either of following ways:
755
- * - `string`: Specify the ID of the DOM element.
756
- * - `HTMLElement`: Pass a DOM object.
2382
+ * You can pass a `number`, or a constraint such as `{ max: 30, min: 5 }`.
2383
+ *
2384
+ * For details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
757
2385
  */
758
- play(element?: string | HTMLElement): void;
2386
+ framerate?: ConstrainULong;
759
2387
  /**
760
- * Stops playing the media track.
2388
+ * Bitrate of the video (Kbps).
761
2389
  */
762
- stop(): void;
2390
+ bitrate?: number;
763
2391
  }
764
2392
 
765
2393
  export declare const MediaElementNumStatus: {
@@ -787,6 +2415,87 @@ export declare interface MediaStats {
787
2415
  resolution: Resolution;
788
2416
  }
789
2417
 
2418
+ export declare class MicrophoneAudioTrack extends LocalAudioTrack implements IMicrophoneAudioTrack {
2419
+ _config: MicrophoneAudioTrackInitConfig;
2420
+ _deviceName: string;
2421
+ private _constraints;
2422
+ private readonly _originalConstraints;
2423
+ _enabled: boolean;
2424
+ get __className__(): string;
2425
+ constructor(track: MediaStreamTrack, config: MicrophoneAudioTrackInitConfig, constraints: MediaTrackConstraints, trackId?: string);
2426
+ setDevice(deviceId: string): Promise<void>;
2427
+ setEnabled(enabled: boolean, notCloseDevice?: boolean, skipChangeState?: boolean): Promise<void>;
2428
+ close(): void;
2429
+ protected onTrackEnded(): void;
2430
+ renewMediaStreamTrack(newConstraints?: MediaTrackConstraints): Promise<void>;
2431
+ protected bindProcessorContextEvents(processorContext: AudioProcessorContext): void;
2432
+ protected unbindProcessorContextEvents(processorContext: AudioProcessorContext): void;
2433
+ }
2434
+
2435
+ /**
2436
+ * Configurations for the audio track from the audio captured by a microphone. Set these configurations when calling [AgoraRTC.createMicrophoneAudioTrack]{@link IAgoraRTC.createMicrophoneAudioTrack}.
2437
+ */
2438
+ export declare interface MicrophoneAudioTrackInitConfig {
2439
+ /**
2440
+ * The audio encoder configurations.
2441
+ *
2442
+ * You can set the audio encoder configurations in either of the following ways:
2443
+ * - Pass the preset audio encoder configurations by using [[AudioEncoderConfigurationPreset]].
2444
+ * - Pass your customized audio encoder configurations by using [[AudioEncoderConfiguration]].
2445
+ *
2446
+ * > Firefox does not support setting the audio encoding rate.
2447
+ */
2448
+ encoderConfig?: AudioEncoderConfiguration | AudioEncoderConfigurationPreset;
2449
+ /**
2450
+ * Whether to enable acoustic echo cancellation:
2451
+ * - `true`: Enable acoustic echo cancellation.
2452
+ * - `false`: Do not enable acoustic echo cancellation.
2453
+ */
2454
+ AEC?: boolean;
2455
+ /**
2456
+ * Whether to enable audio gain control:
2457
+ * - `true`: Enable audio gain control.
2458
+ * - `false`: Do not enable audio gain control.
2459
+ */
2460
+ AGC?: boolean;
2461
+ /**
2462
+ * Whether to enable automatic noise suppression:
2463
+ * - `true`: Enable automatic noise suppression.
2464
+ * - `false`: Do not automatic noise suppression.
2465
+ */
2466
+ ANS?: boolean;
2467
+ /**
2468
+ * @ignore
2469
+ */
2470
+ DTX?: boolean;
2471
+ /**
2472
+ * Specifies the microphone ID.
2473
+ *
2474
+ * You can get a list of the available microphones by calling [AgoraRTC.getMicrophones]{@link IAgoraRTC.getMicrophones}.
2475
+ */
2476
+ microphoneId?: string;
2477
+ /**
2478
+ * @ignore
2479
+ * Specifies whether or not audio track pass through WebAudio.
2480
+ */
2481
+ bypassWebAudio?: boolean;
2482
+ }
2483
+
2484
+ export declare class MixingAudioTrack extends LocalAudioTrack {
2485
+ get __className__(): string;
2486
+ trackList: LocalAudioTrack[];
2487
+ private destNode;
2488
+ get isActive(): boolean;
2489
+ constructor();
2490
+ hasAudioTrack(track: LocalAudioTrack): boolean;
2491
+ addAudioTrack(track: LocalAudioTrack): void;
2492
+ removeAudioTrack(track: LocalAudioTrack): void;
2493
+ private updateEncoderConfig;
2494
+ _updateRtpTransceiver(transceiver: RTCRtpTransceiver): void;
2495
+ }
2496
+
2497
+ export declare type OptimizationMode = "motion" | "detail";
2498
+
790
2499
  export declare interface PlayerConfig extends VideoPlayerConfig {
791
2500
  trackId: string;
792
2501
  element: HTMLElement;
@@ -921,6 +2630,14 @@ export declare interface RemoteAudioTrackStats {
921
2630
  publishDuration: number;
922
2631
  }
923
2632
 
2633
+ export declare class RemoteDataChannel extends DataChannel implements IRemoteDataChannel {
2634
+ private _messageListener;
2635
+ constructor(config: IDataChannelConfig);
2636
+ _updateOriginDataChannel(datachannel: RTCDataChannel): void;
2637
+ _close(): void;
2638
+ private _bandRemoteDataChannelEvents;
2639
+ }
2640
+
924
2641
  /**
925
2642
  * The stream fallback option. Set the stream fallback option when calling [setStreamFallbackOption]{@link IAgoraRTCClient.setStreamFallbackOption}.
926
2643
  *
@@ -1110,6 +2827,172 @@ export declare interface Resolution {
1110
2827
 
1111
2828
  export declare const SAFARI_GLOBAL_GUM_LOCK: PromiseMutex;
1112
2829
 
2830
+ export declare interface ScreenConstraintsWithElectron extends MediaTrackConstraints {
2831
+ sourceId?: string;
2832
+ extensionId?: string;
2833
+ mandatory?: any;
2834
+ mediaSource?: ScreenSourceType;
2835
+ width?: ConstrainULong;
2836
+ height?: ConstrainULong;
2837
+ displaySurface?: "browser" | "window" | "monitor";
2838
+ selfBrowserSurface?: "include" | "exclude";
2839
+ surfaceSwitching?: "include" | "exclude";
2840
+ systemAudio?: "include" | "exclude";
2841
+ }
2842
+
2843
+ /**
2844
+ * The preset video encoder configurations for screen sharing.
2845
+ *
2846
+ * You can pass the preset video encoder configurations when calling [AgoraRTC.createScreenVideoTrack]{@link IAgoraRTC.createScreenVideoTrack}.
2847
+ *
2848
+ * The following table lists all the preset video profiles for screen sharing.
2849
+ *
2850
+ * | Video Profile | Resolution (Width×Height) | Frame Rate (fps) |
2851
+ * | -------- | --------------- | ----------- |
2852
+ * | "480p" | 640 × 480 | 5 |
2853
+ * | "480p_1" | 640 × 480 | 5 |
2854
+ * | "480p_2" | 640 × 480 | 30 |
2855
+ * | "480p_3" | 640 × 480 | 15 |
2856
+ * | "720p" | 1280 × 720 | 5 |
2857
+ * | "720p_1" | 1280 × 720 | 5 |
2858
+ * | "720p_2" | 1280 × 720 | 30 |
2859
+ * | "720p_3" | 1280 × 720 | 15 |
2860
+ * | "720p_auto" <sup>①</sup> | 1280 × 720 | 30 |
2861
+ * | "1080p" | 1920 × 1080 | 5 |
2862
+ * | "1080p_1" | 1920 × 1080 | 5 |
2863
+ * | "1080p_2" | 1920 × 1080 | 30 |
2864
+ * | "1080p_3" | 1920 × 1080 | 15 |
2865
+ *
2866
+ * > <sup>①</sup> `"720p_auto"` is only recommended to be set on Safari to ensure dynamic adjustment of the encoding resolution. For details, see the release notes.
2867
+ */
2868
+ export declare type ScreenEncoderConfigurationPreset = keyof typeof SUPPORT_SCREEN_ENCODER_CONFIG_LIST;
2869
+
2870
+ /**
2871
+ * The type of the source for screen sharing.
2872
+ * - `"screen"`: Sharing the whole screen.
2873
+ * - `"application"`: Sharing all windows of an app.
2874
+ * - `"window"`: Sharing a window of an app.
2875
+ */
2876
+ export declare type ScreenSourceType = "screen" | "window" | "application";
2877
+
2878
+ /**
2879
+ * Configurations for the video track for screen sharing. Set these configurations when calling [AgoraRTC.createScreenVideoTrack]{@link IAgoraRTC.createScreenVideoTrack}.
2880
+ */
2881
+ export declare interface ScreenVideoTrackInitConfig {
2882
+ /**
2883
+ * The video encoder configurations for screen sharing.
2884
+ *
2885
+ * You can set the video encoder configurations in either of the following ways:
2886
+ * - Pass the preset video encoder configurations by using [[ScreenEncoderConfigurationPreset]].
2887
+ * - Pass your customized video encoder configurations by using [[VideoEncoderConfiguration]].
2888
+ * - Leave this property empty to use the SDK's default value, `"1080p_2"` (resolution: 1920 × 1080, frame rate: 30 fps, bitrate: 3000 Kbps).
2889
+ */
2890
+ encoderConfig?: VideoEncoderConfiguration | ScreenEncoderConfigurationPreset;
2891
+ /**
2892
+ * The `sourceId` when you share the screen through Electron.
2893
+ */
2894
+ electronScreenSourceId?: string;
2895
+ /**
2896
+ * The `extensionId` when you share the screen with a Chrome extension.
2897
+ */
2898
+ extensionId?: string;
2899
+ /**
2900
+ *
2901
+ * @deprecated from v4.17.1. Use {@link displaySurface} instead.
2902
+ *
2903
+ * The type of the source for screen sharing.
2904
+ */
2905
+ screenSourceType?: ScreenSourceType;
2906
+ /**
2907
+ * @since
2908
+ * <br>&emsp;&emsp;&emsp;*4.0.0*
2909
+ *
2910
+ * Transmission optimization mode. Whether to prioritize video quality or smoothness:
2911
+ * - `"detail"`: (Default) Prioritizes video quality.
2912
+ * - The SDK ensures high-quality images by automatically calculating a minimum bitrate based on the capturing resolution and frame rate. No matter how poor the network condition is, the sending bitrate will never be lower than the minimum value.
2913
+ * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
2914
+ * - `"motion"`: Prioritizes video smoothness.
2915
+ * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
2916
+ * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
2917
+ *
2918
+ * > Note: This method is only supported on Chrome.
2919
+ */
2920
+ optimizationMode?: "motion" | "detail";
2921
+ /**
2922
+ * @ignore
2923
+ *
2924
+ * @since
2925
+ * <br>&emsp;&emsp;&emsp;*4.18.0*
2926
+ *
2927
+ * Configurations for Scalable Video Coding (SVC).
2928
+ *
2929
+ * You can set the configurations using one of the following options:
2930
+ * - Use the preset SVC configurations provided by the SDK through {@link SVCConfigurationPreset}.
2931
+ * - Use your custom SVC configurations through {@link SVCConfiguration}.
2932
+ */
2933
+ scalabiltyMode?: SVCConfiguration | SVCConfigurationPreset;
2934
+ /**
2935
+ *
2936
+ * @since
2937
+ * <br>&emsp;&emsp;&emsp;*4.17.1*
2938
+ *
2939
+ * The pre-selected pane in the media picker. See [displaySurface](https://developer.chrome.com/docs/web-platform/screen-sharing-controls/#displaySurface) for details.
2940
+ *
2941
+ * > Note: This property is supported on Chrome 107 and later, as well as Edge 107 and later.
2942
+ */
2943
+ displaySurface?: "browser" | "window" | "monitor";
2944
+ /**
2945
+ *
2946
+ * @since
2947
+ * <br>&emsp;&emsp;&emsp;*4.17.1*
2948
+ *
2949
+ * Whether to allow the user to share the current tab:
2950
+ * - `"include"`: (Default) Allows the user to share the current tab.
2951
+ * - `"exclude"`: Prevents the user from sharing the current tab.
2952
+ *
2953
+ * See [displaySurface](https://developer.chrome.com/docs/web-platform/screen-sharing-controls/#displaySurface) for details.
2954
+ *
2955
+ * > Note:
2956
+ * > - This property is defaulted to `"exclude"` on Chrome 107. For better compatibility with earlier versions, the SDK changes the default value to "include", which ensures that users can still share the current tab after upgrading to Chrome 107.
2957
+ * > - This property is supported on Chrome 107 and later, as well as Edge 107 and later.
2958
+ */
2959
+ selfBrowserSurface?: "include" | "exclude";
2960
+ /**
2961
+ *
2962
+ * @since
2963
+ * <br>&emsp;&emsp;&emsp;*4.17.1*
2964
+ *
2965
+ * Whether to allow the user to dynamically switch between shared tabs:
2966
+ * - `"include"`: (Default) The user can dynamically switch between shared tabs.
2967
+ * - `"exclude"`: The user cannot dynamically switch between shared tabs.
2968
+ *
2969
+ * See [surfaceSwitching](https://developer.chrome.com/docs/web-platform/screen-sharing-controls/#surfaceSwitching) for details.
2970
+ *
2971
+ * > Note: This property is supported on Chrome 107 and later, as well as Edge 107 and later.
2972
+ */
2973
+ surfaceSwitching?: "include" | "exclude";
2974
+ /**
2975
+ *
2976
+ * @since
2977
+ * <br>&emsp;&emsp;&emsp;*4.17.1*
2978
+ *
2979
+ * Whether to capture system audio:
2980
+ * - `"include"`: (Default) Captures system audio.
2981
+ * - `"exclude"`: Avoids capturing system audio
2982
+ *
2983
+ * See [systemAudio](https://developer.chrome.com/docs/web-platform/screen-sharing-controls/#systemAudio) for details.
2984
+ *
2985
+ * > Note: This property is supported on Chrome 105 and later (Windows only), as well as Edge 105 and later (Windows only).
2986
+ */
2987
+ systemAudio?: "include" | "exclude";
2988
+ }
2989
+
2990
+ export declare type SenderConfig = {
2991
+ bitrateMax: number;
2992
+ bitrateMin: number;
2993
+ scaleResolutionDownBy: number;
2994
+ };
2995
+
1113
2996
  export declare function silenceScriptProcessHandler(e: AudioProcessingEvent): AudioBuffer;
1114
2997
 
1115
2998
  export declare interface StatsRegistry {
@@ -1130,6 +3013,72 @@ export declare enum StreamType {
1130
3013
  LOW_STREAM = 1
1131
3014
  }
1132
3015
 
3016
+ export declare const SUPPORT_720P_AUTO_CONFIG_LIST: Required<{
3017
+ scaleResolutionDownBy: number;
3018
+ width: number;
3019
+ height: number;
3020
+ frameRate: number;
3021
+ bitrateMin: number;
3022
+ bitrateMax: number;
3023
+ }>[];
3024
+
3025
+ /**
3026
+ * @ignore
3027
+ */
3028
+ export declare const SUPPORT_SCREEN_ENCODER_CONFIG_LIST: Record<string, VideoEncoderConfiguration>;
3029
+
3030
+ /**
3031
+ * @ignore
3032
+ */
3033
+ export declare const SUPPORT_SVC_CONFIG_LIST: Record<string, SVCConfiguration>;
3034
+
3035
+ /**
3036
+ * @ignore
3037
+ */
3038
+ export declare const SUPPORT_VIDEO_ENCODER_CONFIG_LIST: Record<string, VideoEncoderConfiguration>;
3039
+
3040
+ /**
3041
+ * @ignore
3042
+ * @since
3043
+ * <br>&emsp;&emsp;&emsp;*4.18.0*
3044
+ *
3045
+ * Custom SVC encoding configurations.
3046
+ *
3047
+ * You can control the SVC configurations for local video by passing `SVCConfiguration` in the following methods:
3048
+ * - [AgoraRTC.createCameraVideoTrack]{@link IAgoraRTC.createCameraVideoTrack}
3049
+ * - [AgoraRTC.createCustomVideoTrack]{@link IAgoraRTC.createCustomVideoTrack}
3050
+ * - [AgoraRTC.createScreenVideoTrack]{@link IAgoraRTC.createScreenVideoTrack}
3051
+ */
3052
+ export declare interface SVCConfiguration {
3053
+ /**
3054
+ * Specifies the number of spatial layer in SVC.
3055
+ */
3056
+ numSpatialLayers: 1 | 2 | 3;
3057
+ /**
3058
+ * Specifies the number of temporal layer in SVC.
3059
+ */
3060
+ numTemporalLayers: 1 | 3;
3061
+ }
3062
+
3063
+ /**
3064
+ * @ignore
3065
+ *
3066
+ * @since
3067
+ * <br>&emsp;&emsp;&emsp;*4.18.0*
3068
+ *
3069
+ * The preset SVC configurations provided by the SDK.
3070
+ * - `"1SL1TL"`: 1 spatial layer, 1 temporal layer.
3071
+ * - `"3SL3TL"`: 3 spatial layers, 3 temporal layers.
3072
+ * - `"2SL3TL"`: 2 spatial layers, 3 temporal layers.
3073
+ *
3074
+ * You can control the SVC configurations for local video by passing these preset values in the following methods:
3075
+ * - [AgoraRTC.createCameraVideoTrack]{@link IAgoraRTC.createCameraVideoTrack}
3076
+ * - [AgoraRTC.createCustomVideoTrack]{@link IAgoraRTC.createCustomVideoTrack}
3077
+ * - [AgoraRTC.createScreenVideoTrack]{@link IAgoraRTC.createScreenVideoTrack}
3078
+ *
3079
+ */
3080
+ export declare type SVCConfigurationPreset = keyof typeof SUPPORT_SVC_CONFIG_LIST;
3081
+
1133
3082
  export declare abstract class Track extends EventEmitter implements ITrack {
1134
3083
  abstract readonly trackMediaType: "audio" | "video";
1135
3084
  private _ID;
@@ -1139,7 +3088,9 @@ export declare abstract class Track extends EventEmitter implements ITrack {
1139
3088
  _hints: TrackHint[];
1140
3089
  _isClosed: boolean;
1141
3090
  _originMediaStreamTrack: MediaStreamTrack;
1142
- _mediaStreamTrack: MediaStreamTrack;
3091
+ mediaStreamTrack: MediaStreamTrack;
3092
+ set _mediaStreamTrack(track: MediaStreamTrack);
3093
+ get _mediaStreamTrack(): MediaStreamTrack;
1143
3094
  _external: ExternalMethods;
1144
3095
  constructor(track: MediaStreamTrack, trackId?: string);
1145
3096
  toString(): string;
@@ -1157,7 +3108,7 @@ export declare enum TrackEvents {
1157
3108
  TRANSCEIVER_UPDATED = "transceiver-updated",
1158
3109
  SEI_TO_SEND = "sei-to-send",
1159
3110
  SEI_RECEIVED = "sei-received",
1160
- CLOSED = "closed"
3111
+ TRACK_UPDATED = "track-updated"
1161
3112
  }
1162
3113
 
1163
3114
  export declare enum TrackHint {
@@ -1180,6 +3131,7 @@ export declare enum TrackInternalEvent {
1180
3131
  GET_LOW_VIDEO_TRACK = "@get_low_video_track",
1181
3132
  NEED_RESET_REMOTE_SDP = "@need_reset_remote_sdp",
1182
3133
  NEED_UPDATE_VIDEO_ENCODER = "@need_update_video_encoder",
3134
+ NEED_UPDATE_VIDEO_SEND_PARAMETERS = "@need_update_video_send_parameters",
1183
3135
  NEED_MUTE_TRACK = "@need_mute_track",
1184
3136
  NEED_UNMUTE_TRACK = "@need_unmute_track"
1185
3137
  }
@@ -1192,6 +3144,111 @@ export declare interface UsageRegistry {
1192
3144
  cb: () => Usage | Promise<Usage>;
1193
3145
  }
1194
3146
 
3147
+ /**
3148
+ * `VideoEncoderConfiguration` is the interface that defines the video encoder configurations.
3149
+ *
3150
+ * You can customize the video encoder configurations when calling [AgoraRTC.createCameraVideoTrack]{@link IAgoraRTC.createCameraVideoTrack} or [AgoraRTC.createScreenVideoTrack]{@link IAgoraRTC.createScreenVideoTrack}.
3151
+ *
3152
+ * The SDK provides the preset video encoder configurations. For more information, see [[VideoEncoderConfigurationPreset]].
3153
+ *
3154
+ * > The actual bitrate may differ slightly from the value you set due to the limitations of the operation system or the web browser. Agora recommends setting the bitrate between 100 Kbps and 5000 Kbps.
3155
+ */
3156
+ export declare interface VideoEncoderConfiguration {
3157
+ /**
3158
+ * Width of the video.
3159
+ *
3160
+ * You can pass a `number`, or a constraint such as `{ max: 1280, min: 720 }`.
3161
+ *
3162
+ * For more details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
3163
+ */
3164
+ width?: number | ConstrainLong;
3165
+ /**
3166
+ * Height of the video.
3167
+ *
3168
+ * You can pass a `number`, or a constraint such as `{ max: 1280, min: 720 }`.
3169
+ *
3170
+ * For more details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
3171
+ */
3172
+ height?: number | ConstrainLong;
3173
+ /**
3174
+ * Frame rate of the video (fps).
3175
+ *
3176
+ * You can pass a `number`, or a constraint such as `{ max: 30, min: 5 }`.
3177
+ *
3178
+ * For details about the constraint, see [ConstrainLong]{@link ConstrainLong}.
3179
+ */
3180
+ frameRate?: number | ConstrainLong;
3181
+ /**
3182
+ * The minimum bitrate of the video (Kbps).
3183
+ */
3184
+ bitrateMin?: number;
3185
+ /**
3186
+ * The maximum bitrate of the video (Kbps).
3187
+ */
3188
+ bitrateMax?: number;
3189
+ /**
3190
+ * @ignore
3191
+ */
3192
+ scaleResolutionDownBy?: number;
3193
+ }
3194
+
3195
+ /**
3196
+ *
3197
+ * The preset video encoder configurations.
3198
+ *
3199
+ * You can pass the preset video encoder configurations when calling [AgoraRTC.createCameraVideoTrack]{@link IAgoraRTC.createCameraVideoTrack} or [AgoraRTC.createScreenVideoTrack]{@link IAgoraRTC.createScreenVideoTrack}.
3200
+ *
3201
+ * The following table lists all the preset video profiles. The SDK uses `"480p_1"` by default.
3202
+ *
3203
+ * | Video Profile | Resolution (Width×Height) | Frame Rate (fps) | Chrome | Firefox | Safari |
3204
+ * | -------- | --------------- | ----------- | ------ | ------- | ------ |
3205
+ * | 120p | 160 × 120 | 15 | ✓ | | |
3206
+ * | 120p_1 | 160 × 120 | 15 | ✓ | | |
3207
+ * | 120p_3 | 120 × 120 | 15 | ✓ | | |
3208
+ * | 180p | 320 × 180 | 15 | ✓ | | |
3209
+ * | 180p_1 | 320 × 180 | 15 | ✓ | | |
3210
+ * | 180p_3 | 180 × 180 | 15 | ✓ | | |
3211
+ * | 180p_4 | 240 × 180 | 15 | ✓ | | |
3212
+ * | 240p | 320 × 240 | 15 | ✓ | | |
3213
+ * | 240p_1 | 320 × 240 | 15 | ✓ | | |
3214
+ * | 240p_3 | 240 × 240 | 15 | ✓ | | |
3215
+ * | 240p_4 | 424 × 240 | 15 | ✓ | | |
3216
+ * | 360p | 640 × 360 | 15 | ✓ | | |
3217
+ * | 360p_1 | 640 × 360 | 15 | ✓ | | |
3218
+ * | 360p_3 | 360 × 360 | 15 | ✓ | | |
3219
+ * | 360p_4 | 640 × 360 | 30 | ✓ | | |
3220
+ * | 360p_6 | 360 × 360 | 30 | ✓ | | |
3221
+ * | 360p_7 | 480 × 360 | 15 | ✓ | | |
3222
+ * | 360p_8 | 480 × 360 | 30 | ✓ | | |
3223
+ * | 360p_9 | 640 × 360 | 15 | ✓ | | |
3224
+ * | 360p_10 | 640 × 360 | 24 | ✓ | | |
3225
+ * | 360p_11 | 640 × 360 | 24 | ✓ | | |
3226
+ * | 480p | 640 × 480 | 15 | ✓ | ✓ | ✓ |
3227
+ * | 480p_1 | 640 × 480 | 15 | ✓ | ✓ | ✓ |
3228
+ * | 480p_2 | 640 × 480 | 30 | ✓ | ✓ | ✓ |
3229
+ * | 480p_3 | 480 × 480 | 15 | ✓ | ✓ | ✓ |
3230
+ * | 480p_4 | 640 × 480 | 30 | ✓ | ✓ | ✓ |
3231
+ * | 480p_6 | 480 × 480 | 30 | ✓ | ✓ | ✓ |
3232
+ * | 480p_8 | 848 × 480 | 15 | ✓ | ✓ | ✓ |
3233
+ * | 480p_9 | 848 × 480 | 30 | ✓ | ✓ | ✓ |
3234
+ * | 480p_10 | 640 × 480 | 10 | ✓ | ✓ | ✓ |
3235
+ * | 720p | 1280 × 720 | 15 | ✓ | ✓ | ✓ |
3236
+ * | 720p_1 | 1280 × 720 | 15 | ✓ | ✓ | ✓ |
3237
+ * | 720p_2 | 1280 × 720 | 30 | ✓ | ✓ | ✓ |
3238
+ * | 720p_3 | 1280 × 720 | 30 | ✓ | ✓ | ✓ |
3239
+ * | 720p_auto <sup>①</sup> | 1280 × 720 | 30 | ✓ | ✓ | ✓ |
3240
+ * | 720p_5 | 960 × 720 | 15 | ✓ | ✓ | ✓ |
3241
+ * | 720p_6 | 960 × 720 | 30 | ✓ | ✓ | ✓ |
3242
+ * | 1080p | 1920 × 1080 | 15 | ✓ | | ✓ |
3243
+ * | 1080p_1 | 1920 × 1080 | 15 | ✓ | | ✓ |
3244
+ * | 1080p_2 | 1920 × 1080 | 30 | ✓ | | ✓ |
3245
+ * | 1080p_3 | 1920 × 1080 | 30 | ✓ | | ✓ |
3246
+ * | 1080p_5 | 1920 × 1080 | 60 | ✓ | | ✓ |
3247
+ *
3248
+ * > <sup>①</sup> `"720p_auto"` is only recommended to be set on Safari to ensure dynamic adjustment of the encoding resolution. For details, see the release notes.
3249
+ */
3250
+ export declare type VideoEncoderConfigurationPreset = keyof typeof SUPPORT_VIDEO_ENCODER_CONFIG_LIST;
3251
+
1195
3252
  declare class VideoPlayer {
1196
3253
  trackId: string;
1197
3254
  config: PlayerConfig;
@@ -1208,6 +3265,8 @@ declare class VideoPlayer {
1208
3265
  protected videoTrack?: MediaStreamTrack;
1209
3266
  protected videoElement: HTMLVideoElement;
1210
3267
  protected cacheVideoElement?: HTMLVideoElement;
3268
+ private renderStats?;
3269
+ get rendFrameRate(): number;
1211
3270
  get videoElementStatus(): MediaElementStatus;
1212
3271
  set videoElementStatus(status: MediaElementStatus);
1213
3272
  get videoState(): VideoState;