@agora-js/media 4.21.0 → 4.22.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.
package/media.d.ts CHANGED
@@ -808,33 +808,39 @@ export declare interface CameraVideoTrackInitConfig {
808
808
  cameraId?: string;
809
809
  /**
810
810
  * @自从
811
- * <br>&emsp;&emsp;&emsp;*4.0.0*
811
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
812
+ *
813
+ * 设置视频传输优化模式。
814
+ *
815
+ * 你可以在视频通话、视频直播或屏幕共享过程中调用此方法动态调整视频的传输优化模式。例如你想要把屏幕共享内容从演示文稿切换为视频时,你可以将传输优化模式从 `"detail"` 切换为 `"motion"`,确保视频画面在网络波动时不会出现卡顿。
812
816
  *
813
- * 传输优化模式。设置该值后,SDK 会自动调整码率配置以及使用不同的回退策略。
817
+ * > 注意事项:该方法只支持 Chrome 浏览器。
818
+ *
819
+ * @param mode 视频传输优化模式:
814
820
  * - `"detail"`: 清晰优先。
815
821
  * - SDK 会自动根据你的采集分辨率和帧率设定一个最小码率。即使遭遇网络波动,发送码率也不会低于这个值,从而确保清晰的视频画面。
816
822
  * - 大部分情况下,SDK 不会降低发送分辨率,但是可能会降低帧率。
817
- * - `"motion"`: 流畅优先。
823
+ * - `"motion"`: 自 4.21.0 开始,SDK 默认开启流畅优先模式。
818
824
  * - SDK 不会启用最小码率策略。遭遇网络波动时,发送端会降低码率来确保接收端的视频画面不会出现中断和卡顿。
819
825
  * - 大部分情况下,SDK 不会降低帧率,但是可能会降低发送分辨率。
820
- * - 留空: 默认优化策略,兼顾清晰和流畅,也就是说弱网条件下,帧率和分辨率都会被调整。
821
- *
822
- * > 注意事项:该方法只支持 Chrome 浏览器。
823
826
  */
824
827
  /** @en
825
828
  * @since
826
- * <br>&emsp;&emsp;&emsp;*4.0.0*
829
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
830
+ *
831
+ * Sets the video transmission optimization mode.
827
832
  *
828
- * Transmission optimization mode. Whether to prioritize video quality or smoothness:
833
+ * 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.
834
+ *
835
+ * > Note: This method supports Chrome only.
836
+ *
837
+ * @param mode The video transmission optimization mode:
829
838
  * - `"detail"`: Prioritizes video quality.
830
839
  * - 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.
831
840
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
832
- * - `"motion"`: Prioritizes video smoothness.
841
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
833
842
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
834
843
  * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
835
- * - Empty: Uses the default transmission optimization mode. The SDK may reduce the frame rate or the sending resolution in poor network conditions.
836
- *
837
- * > Note: This method is only supported on Chrome.
838
844
  */
839
845
  optimizationMode?: OptimizationMode;
840
846
  /**
@@ -871,7 +877,7 @@ export declare function checkTrackState(): (target: any, propertyKey: any, descr
871
877
  * 可通过以下方法或事件获取:
872
878
  * - [localVideoTrack.on("video-element-visible-status")]{@link ILocalVideoTrack.event_video_element_visible_status}
873
879
  * - [localVideoTrack.getVideoElementVisibleStatus]{@link ILocalVideoTrack.getVideoElementVisibleStatus}
874
- * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status}
880
+ * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status_2}
875
881
  * - [remoteVideoTrack.getVideoElementVisibleStatus]{@link IRemoteVideoTrack.getVideoElementVisibleStatus}
876
882
  *
877
883
  * 包含以下字段:
@@ -888,7 +894,7 @@ export declare function checkTrackState(): (target: any, propertyKey: any, descr
888
894
  * Get the visibility of the `<video>` tag through the following methods and events:
889
895
  * - [localVideoTrack.on("video-element-visible-status")]{@link ILocalVideoTrack.event_video_element_visible_status}
890
896
  * - [localVideoTrack.getVideoElementVisibleStatus]{@link ILocalVideoTrack.getVideoElementVisibleStatus}
891
- * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status}
897
+ * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status_2}
892
898
  * - [remoteVideoTrack.getVideoElementVisibleStatus]{@link IRemoteVideoTrack.getVideoElementVisibleStatus}
893
899
  *
894
900
  * This object contains the following parameters:
@@ -1084,33 +1090,45 @@ export declare interface CustomVideoTrackInitConfig {
1084
1090
  bitrateMax?: number;
1085
1091
  /**
1086
1092
  * @自从
1087
- * <br>&emsp;&emsp;&emsp;*4.0.0*
1093
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
1088
1094
  *
1089
- * 传输优化模式。设置该值后,SDK 会自动调整码率配置以及使用不同的回退策略。
1095
+ * 设置视频传输优化模式。
1096
+ *
1097
+ * 你可以在视频通话、视频直播或屏幕共享过程中调用此方法动态调整视频的传输优化模式。例如你想要把屏幕共享内容从演示文稿切换为视频时,你可以将传输优化模式从 `"detail"` 切换为 `"motion"`,确保视频画面在网络波动时不会出现卡顿。
1098
+ *
1099
+ * > 注意事项:该方法只支持 Chrome 浏览器。
1100
+ *
1101
+ * @param mode 视频传输优化模式:
1102
+ * - `"balanced"`: 使用默认的传输优化模式:
1103
+ * - 对于屏幕共享视频流,SDK 默认的优化策略为清晰优先。
1104
+ * - 对于其他视频流,SDK 默认的优化策略为兼顾清晰和流畅,弱网条件下,帧率和分辨率都会被调整。
1090
1105
  * - `"detail"`: 清晰优先。
1091
1106
  * - SDK 会自动根据你的采集分辨率和帧率设定一个最小码率。即使遭遇网络波动,发送码率也不会低于这个值,从而确保清晰的视频画面。
1092
1107
  * - 大部分情况下,SDK 不会降低发送分辨率,但是可能会降低帧率。
1093
- * - `"motion"`: 流畅优先。
1108
+ * - `"motion"`: 自 4.21.0开始,SDK 默认开启流畅优先模式
1094
1109
  * - SDK 不会启用最小码率策略。遭遇网络波动时,发送端会降低码率来确保接收端的视频画面不会出现中断和卡顿。
1095
1110
  * - 大部分情况下,SDK 不会降低帧率,但是可能会降低发送分辨率。
1096
- * - 留空: 默认优化策略,兼顾清晰和流畅,也就是说弱网条件下,帧率和分辨率都会被调整。
1097
- *
1098
- * > 注意事项:该方法只支持 Chrome 浏览器。
1099
1111
  */
1100
1112
  /** @en
1101
1113
  * @since
1102
- * <br>&emsp;&emsp;&emsp;*4.0.0*
1114
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
1115
+ *
1116
+ * Sets the video transmission optimization mode.
1117
+ *
1118
+ * 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.
1103
1119
  *
1104
- * Transmission optimization mode. Whether to prioritize video quality or smoothness:
1120
+ * > Note: This method supports Chrome only.
1121
+ *
1122
+ * @param mode The video transmission optimization mode:
1123
+ * - `"balanced"`: Uses the default optimization mode.
1124
+ * - For a screen-sharing video track, the default transmission optimization strategy is to prioritizes clarity.
1125
+ * - For the other types of video tracks, the SDK may reduce the frame rate or the sending resolution in poor network conditions.
1105
1126
  * - `"detail"`: Prioritizes video quality.
1106
1127
  * - 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.
1107
1128
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
1108
- * - `"motion"`: Prioritizes video smoothness.
1129
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
1109
1130
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
1110
1131
  * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
1111
- * - Empty: Uses the default transmission optimization mode. The SDK may reduce the frame rate or the sending resolution in poor network conditions.
1112
- *
1113
- * > Note: This method is only supported on Chrome.
1114
1132
  */
1115
1133
  optimizationMode?: "motion" | "detail";
1116
1134
  /**
@@ -1138,15 +1156,17 @@ export declare interface CustomVideoTrackInitConfig {
1138
1156
  }
1139
1157
 
1140
1158
  export declare abstract class DataChannel extends EventEmitter implements IDataChannel {
1159
+ readonly trackMediaType: TrackMediaType.DATA;
1141
1160
  private _version;
1142
1161
  private _type;
1143
1162
  _config: IDataChannelConfig;
1144
1163
  /** 原始的 DataChannel 对象 */
1145
1164
  _originDataChannel?: RTCDataChannel;
1146
1165
  protected _dataStreamPacketHeader: ArrayBuffer;
1147
- protected _dataStreamPacketHandler: DataStream;
1166
+ protected _dataStreamPacketHandler: IDataStream;
1148
1167
  private _datachannelEventMap;
1149
1168
  constructor(config: IDataChannelConfig, datachannel?: RTCDataChannel);
1169
+ useDataStream(dataStream: IDataStream): void;
1150
1170
  get id(): number;
1151
1171
  get ordered(): boolean;
1152
1172
  get maxRetransmits(): number;
@@ -1171,20 +1191,6 @@ export declare enum DataChannelEvents {
1171
1191
  ERROR = "error"
1172
1192
  }
1173
1193
 
1174
- declare class DataStream {
1175
- private _sequence;
1176
- private _startTime;
1177
- private isUseOneByte;
1178
- private get startTime();
1179
- private get sequence();
1180
- serialize(payload: ArrayBuffer): ArrayBuffer;
1181
- deserialize(packet: ArrayBuffer): ArrayBuffer;
1182
- private serializeExtension;
1183
- private deserializeExtension;
1184
- private decompress;
1185
- private compress;
1186
- }
1187
-
1188
1194
  export declare function decodeAudioData(buffer: ArrayBuffer): Promise<AudioBuffer>;
1189
1195
 
1190
1196
  export declare const DEFAULT_LOCAL_AUDIO_TRACK_STATS: LocalAudioTrackStats;
@@ -2010,6 +2016,11 @@ export declare interface IDataChannelConfig {
2010
2016
  metadata: string;
2011
2017
  }
2012
2018
 
2019
+ declare interface IDataStream {
2020
+ serialize: (payload: ArrayBuffer) => ArrayBuffer;
2021
+ deserialize: (packet: ArrayBuffer) => ArrayBuffer;
2022
+ }
2023
+
2013
2024
  /**
2014
2025
  * 基础本地音频轨道,提供了本地音频轨道的主要功能。
2015
2026
  *
@@ -2557,7 +2568,7 @@ export declare interface ILocalVideoTrack extends ILocalTrack {
2557
2568
  * - `"detail"`: 清晰优先。
2558
2569
  * - SDK 会自动根据你的采集分辨率和帧率设定一个最小码率。即使遭遇网络波动,发送码率也不会低于这个值,从而确保清晰的视频画面。
2559
2570
  * - 大部分情况下,SDK 不会降低发送分辨率,但是可能会降低帧率。
2560
- * - `"motion"`: 流畅优先。
2571
+ * - `"motion"`: 自 4.21.0 开始,SDK 默认开启流畅优先模式。
2561
2572
  * - SDK 不会启用最小码率策略。遭遇网络波动时,发送端会降低码率来确保接收端的视频画面不会出现中断和卡顿。
2562
2573
  * - 大部分情况下,SDK 不会降低帧率,但是可能会降低发送分辨率。
2563
2574
  */
@@ -2578,7 +2589,7 @@ export declare interface ILocalVideoTrack extends ILocalTrack {
2578
2589
  * - `"detail"`: Prioritizes video quality.
2579
2590
  * - 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.
2580
2591
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
2581
- * - `"motion"`: Prioritizes video smoothness.
2592
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
2582
2593
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
2583
2594
  * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
2584
2595
  */
@@ -2871,7 +2882,7 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
2871
2882
  *
2872
2883
  * 设置音频播放设备,比如扬声器。
2873
2884
  *
2874
- * > 该方法只支持桌面端的 Chrome 和 Edge 浏览器。如果在其他浏览器上需要先设置`RESTRICTION_SET_PLAYBACK_DEVICE`为`false`,直接调用将会抛出 `NOT_SUPPORTED` 错误。
2885
+ * > 该方法只支持桌面端的 Chrome 和 Edge 浏览器,其他浏览器调用将会抛出 `NOT_SUPPORTED` 错误。
2875
2886
  * @param deviceId 设备 ID,可以通过 [[getPlaybackDevices]] 方法获取。
2876
2887
  */
2877
2888
  /** @en
@@ -2880,7 +2891,7 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
2880
2891
  *
2881
2892
  * Sets the audio playback device, for example, the speaker.
2882
2893
  *
2883
- * > > 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.
2894
+ * > This method supports Chrome and Edge on desktop devices only. Other browsers throw a `NOT_SUPPORTED` error when calling this method.
2884
2895
  * @param deviceId Device ID, which can be retrieved by calling [[getPlaybackDevices]].
2885
2896
  */
2886
2897
  setPlaybackDevice(deviceId: string): Promise<void>;
@@ -3291,6 +3302,8 @@ export { isElectron }
3291
3302
 
3292
3303
  export declare function isLowStreamParameter(streamParameter: any): streamParameter is LowStreamParameter;
3293
3304
 
3305
+ export declare function isPlanB(): boolean;
3306
+
3294
3307
  export declare function isScreenSourceType(mediaSource: any): mediaSource is ScreenSourceType;
3295
3308
 
3296
3309
  export declare function isVideoEncoderConfiguration(config: VideoEncoderConfiguration): config is VideoEncoderConfiguration;
@@ -3593,10 +3606,6 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
3593
3606
  _player?: AgoraRTCPlayer | VideoPlayer;
3594
3607
  isUseScaleResolutionDownBy: boolean;
3595
3608
  private _videoVisibleTimer;
3596
- /**
3597
- * 轮询监听stats
3598
- */
3599
- protected _statsTimer: number | null;
3600
3609
  private _previousVideoVisibleStatus;
3601
3610
  private _clearPreviousVideoVisibleStatus;
3602
3611
  _encoderConfig?: Partial<VideoEncoderConfiguration>;
@@ -3646,7 +3655,6 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
3646
3655
  close(): void;
3647
3656
  clone(config?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, cloneTrack?: boolean): LocalVideoTrack;
3648
3657
  replaceTrack(track: MediaStreamTrack, stopOldTrack: boolean): Promise<void>;
3649
- startMonitorStats(): void;
3650
3658
  sendSeiData(sei: Uint8Array): never;
3651
3659
  private bindProcessorDestinationEvents;
3652
3660
  private unbindProcessorDestinationEvents;
@@ -3668,7 +3676,7 @@ export declare interface LocalVideoTrackStats {
3668
3676
  * - `"VP8"`: 视频编码格式为 VP8。
3669
3677
  * - `"VP9"`: 视频编码格式为 VP9。
3670
3678
  * - `"AV1X"`: 预留参数,暂不支持。
3671
- * - `"AV1"`: 预留参数,暂不支持。
3679
+ * - `"AV1"`: 视频编码格式为 AV1。
3672
3680
  *
3673
3681
  * > Firefox 上无法获取该值。
3674
3682
  */
@@ -3679,7 +3687,7 @@ export declare interface LocalVideoTrackStats {
3679
3687
  * - `"VP8"`: The video codec is VP8.
3680
3688
  * - `"VP9"`: The video codec is VP9.
3681
3689
  * - `"AV1X"`: Reserved for future use.
3682
- * - `"AV1"`: Reserved for future use.
3690
+ * - `"AV1"`: The video codec is AV1.
3683
3691
  *
3684
3692
  * > You can not get this property on Firefox.
3685
3693
  */
@@ -4057,7 +4065,7 @@ export declare interface ProcessorUsageStats {
4057
4065
  }
4058
4066
 
4059
4067
  export declare class RemoteAudioTrack extends RemoteTrack implements IRemoteAudioTrack {
4060
- readonly trackMediaType: "audio" | "video";
4068
+ readonly trackMediaType: TrackMediaType.AUDIO;
4061
4069
  _source: AudioTrackSource | FakeTrackSource;
4062
4070
  _useAudioElement: boolean;
4063
4071
  private _volume;
@@ -4192,6 +4200,13 @@ export declare interface RemoteAudioTrackStats {
4192
4200
  * The total number of lost audio packets that should be received.
4193
4201
  */
4194
4202
  receivePacketsLost: number;
4203
+ /**
4204
+ * 因过早或过晚到达抖动缓冲器而被丢弃的数据包数量。
4205
+ */
4206
+ /** @en
4207
+ * The number of packets discarded by the jitter buffer due to early or late arrival.
4208
+ */
4209
+ receivePacketsDiscarded: number;
4195
4210
  /**
4196
4211
  * 接收的音频总丢包率。
4197
4212
  */
@@ -4315,7 +4330,7 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
4315
4330
  private _videoVisibleTimer;
4316
4331
  private _previousVideoVisibleStatus;
4317
4332
  private _clearPreviousVideoVisibleStatus;
4318
- readonly trackMediaType: "audio" | "video";
4333
+ readonly trackMediaType: TrackMediaType.VIDEO;
4319
4334
  _videoWidth?: number;
4320
4335
  _videoHeight?: number;
4321
4336
  _player?: AgoraRTCPlayer | VideoPlayer;
@@ -4376,7 +4391,7 @@ export declare interface RemoteVideoTrackStats {
4376
4391
  * - `"VP8"`: The video codec is VP8.
4377
4392
  * - `"VP9"`: The video codec is VP9.
4378
4393
  * - `"AV1X"`: Reserved for future use.
4379
- * - `"AV1"`: Reserved for future use.
4394
+ * - `"AV1"`: The video codec is AV1.
4380
4395
  *
4381
4396
  * > You can not get this property on Firefox.
4382
4397
  */
@@ -4684,31 +4699,39 @@ export declare interface ScreenVideoTrackInitConfig {
4684
4699
  screenSourceType?: ScreenSourceType;
4685
4700
  /**
4686
4701
  * @自从
4687
- * <br>&emsp;&emsp;&emsp;*4.0.0*
4702
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
4688
4703
  *
4689
- * 传输优化模式。设置该值后,SDK 会自动调整码率配置以及使用不同的回退策略。
4690
- * - `"motion"`: 流畅优先。
4691
- * - SDK 不会启用最小码率策略。遭遇网络波动时,发送端会降低码率来确保接收端的视频画面不会出现中断和卡顿。
4692
- * - 大部分情况下,SDK 不会降低帧率,但是可能会降低发送分辨率。
4693
- * - `"detail"`: (默认)清晰优先。
4694
- * - SDK 会自动根据你的采集分辨率和帧率设定一个最小码率。即使遭遇网络波动,发送码率也不会低于这个值,从而确保清晰的视频画面。
4695
- * - 大部分情况下,SDK 不会降低发送分辨率,但是可能会降低帧率。
4704
+ * 设置视频传输优化模式。
4705
+ *
4706
+ * 你可以在视频通话、视频直播或屏幕共享过程中调用此方法动态调整视频的传输优化模式。例如你想要把屏幕共享内容从演示文稿切换为视频时,你可以将传输优化模式从 `"detail"` 切换为 `"motion"`,确保视频画面在网络波动时不会出现卡顿。
4696
4707
  *
4697
4708
  * > 注意事项:该方法只支持 Chrome 浏览器。
4709
+ *
4710
+ * @param mode 视频传输优化模式:
4711
+ * - `"detail"`: 清晰优先。
4712
+ * - SDK 会自动根据你的采集分辨率和帧率设定一个最小码率。即使遭遇网络波动,发送码率也不会低于这个值,从而确保清晰的视频画面。
4713
+ * - 大部分情况下,SDK 不会降低发送分辨率,但是可能会降低帧率。
4714
+ * - `"motion"`: 自 4.21.0 开始,SDK 默认开启流畅优先模式。
4715
+ * - SDK 不会启用最小码率策略。遭遇网络波动时,发送端会降低码率来确保接收端的视频画面不会出现中断和卡顿。
4716
+ * - 大部分情况下,SDK 不会降低帧率,但是可能会降低发送分辨率。
4698
4717
  */
4699
4718
  /** @en
4700
4719
  * @since
4701
- * <br>&emsp;&emsp;&emsp;*4.0.0*
4720
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
4702
4721
  *
4703
- * Transmission optimization mode. Whether to prioritize video quality or smoothness:
4704
- * - `"detail"`: (Default) Prioritizes video quality.
4722
+ * Sets the video transmission optimization mode.
4723
+ *
4724
+ * 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.
4725
+ *
4726
+ * > Note: This method supports Chrome only.
4727
+ *
4728
+ * @param mode The video transmission optimization mode:
4729
+ * - `"detail"`: Prioritizes video quality.
4705
4730
  * - 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.
4706
4731
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
4707
- * - `"motion"`: Prioritizes video smoothness.
4732
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
4708
4733
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
4709
4734
  * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
4710
- *
4711
- * > Note: This method is only supported on Chrome.
4712
4735
  */
4713
4736
  optimizationMode?: "motion" | "detail";
4714
4737
  /**
@@ -5038,6 +5061,12 @@ export declare enum TrackInternalEvent {
5038
5061
  NEED_UNMUTE_TRACK = "@need_unmute_track"
5039
5062
  }
5040
5063
 
5064
+ export declare enum TrackMediaType {
5065
+ AUDIO = "audio",
5066
+ VIDEO = "video",
5067
+ DATA = "data"
5068
+ }
5069
+
5041
5070
  export declare function updateAgoraRTCCompatibility(): void;
5042
5071
 
5043
5072
  export declare interface UsageRegistry {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agora-js/media",
3
- "version": "4.21.0",
3
+ "version": "4.22.0",
4
4
  "description": "media module across @agora-js packages",
5
5
  "main": "AgoraRTC_N-media.js",
6
6
  "module": "AgoraRTC_N-media.esm.mjs",
@@ -23,11 +23,10 @@
23
23
  "homepage": "https://api-ref.agora.io/en/voice-sdk/web/4.x/index.html",
24
24
  "peerDependencies": {},
25
25
  "dependencies": {
26
- "@agora-js/shared": "4.21.0",
27
- "@agora-js/report": "4.21.0",
26
+ "@agora-js/shared": "4.22.0",
27
+ "@agora-js/report": "4.22.0",
28
28
  "axios": "^1.6.8",
29
29
  "agora-rte-extension": "^1.2.4",
30
- "webrtc-adapter": "8.2.0",
31
- "pako": "^2.1.0"
30
+ "webrtc-adapter": "8.2.0"
32
31
  }
33
32
  }
@@ -536,18 +536,21 @@ export declare interface CameraVideoTrackInitConfig {
536
536
  cameraId?: string;
537
537
  /**
538
538
  * @since
539
- * <br>&emsp;&emsp;&emsp;*4.0.0*
539
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
540
+ *
541
+ * Sets the video transmission optimization mode.
542
+ *
543
+ * 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.
540
544
  *
541
- * Transmission optimization mode. Whether to prioritize video quality or smoothness:
545
+ * > Note: This method supports Chrome only.
546
+ *
547
+ * @param mode The video transmission optimization mode:
542
548
  * - `"detail"`: Prioritizes video quality.
543
549
  * - 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
550
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
545
- * - `"motion"`: Prioritizes video smoothness.
551
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
546
552
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
547
553
  * - 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
554
  */
552
555
  optimizationMode?: OptimizationMode;
553
556
  /**
@@ -575,7 +578,7 @@ export declare function checkTrackState(): (target: any, propertyKey: any, descr
575
578
  * Get the visibility of the `<video>` tag through the following methods and events:
576
579
  * - [localVideoTrack.on("video-element-visible-status")]{@link ILocalVideoTrack.event_video_element_visible_status}
577
580
  * - [localVideoTrack.getVideoElementVisibleStatus]{@link ILocalVideoTrack.getVideoElementVisibleStatus}
578
- * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status}
581
+ * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status_2}
579
582
  * - [remoteVideoTrack.getVideoElementVisibleStatus]{@link IRemoteVideoTrack.getVideoElementVisibleStatus}
580
583
  *
581
584
  * This object contains the following parameters:
@@ -701,18 +704,24 @@ export declare interface CustomVideoTrackInitConfig {
701
704
  bitrateMax?: number;
702
705
  /**
703
706
  * @since
704
- * <br>&emsp;&emsp;&emsp;*4.0.0*
707
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
705
708
  *
706
- * Transmission optimization mode. Whether to prioritize video quality or smoothness:
709
+ * Sets the video transmission optimization mode.
710
+ *
711
+ * 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.
712
+ *
713
+ * > Note: This method supports Chrome only.
714
+ *
715
+ * @param mode The video transmission optimization mode:
716
+ * - `"balanced"`: Uses the default optimization mode.
717
+ * - For a screen-sharing video track, the default transmission optimization strategy is to prioritizes clarity.
718
+ * - For the other types of video tracks, the SDK may reduce the frame rate or the sending resolution in poor network conditions.
707
719
  * - `"detail"`: Prioritizes video quality.
708
720
  * - 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
721
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
710
- * - `"motion"`: Prioritizes video smoothness.
722
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
711
723
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
712
724
  * - 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
725
  */
717
726
  optimizationMode?: "motion" | "detail";
718
727
  /**
@@ -731,14 +740,16 @@ export declare interface CustomVideoTrackInitConfig {
731
740
  }
732
741
 
733
742
  export declare abstract class DataChannel extends EventEmitter implements IDataChannel {
743
+ readonly trackMediaType: TrackMediaType.DATA;
734
744
  private _version;
735
745
  private _type;
736
746
  _config: IDataChannelConfig;
737
747
  _originDataChannel?: RTCDataChannel;
738
748
  protected _dataStreamPacketHeader: ArrayBuffer;
739
- protected _dataStreamPacketHandler: DataStream;
749
+ protected _dataStreamPacketHandler: IDataStream;
740
750
  private _datachannelEventMap;
741
751
  constructor(config: IDataChannelConfig, datachannel?: RTCDataChannel);
752
+ useDataStream(dataStream: IDataStream): void;
742
753
  get id(): number;
743
754
  get ordered(): boolean;
744
755
  get maxRetransmits(): number;
@@ -763,20 +774,6 @@ export declare enum DataChannelEvents {
763
774
  ERROR = "error"
764
775
  }
765
776
 
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
-
780
777
  export declare function decodeAudioData(buffer: ArrayBuffer): Promise<AudioBuffer>;
781
778
 
782
779
  export declare const DEFAULT_LOCAL_AUDIO_TRACK_STATS: LocalAudioTrackStats;
@@ -1297,6 +1294,11 @@ export declare interface IDataChannelConfig {
1297
1294
  metadata: string;
1298
1295
  }
1299
1296
 
1297
+ declare interface IDataStream {
1298
+ serialize: (payload: ArrayBuffer) => ArrayBuffer;
1299
+ deserialize: (packet: ArrayBuffer) => ArrayBuffer;
1300
+ }
1301
+
1300
1302
  /**
1301
1303
  * `LocalAudioTrack` is the basic interface for local audio tracks, providing main methods of local audio tracks.
1302
1304
  *
@@ -1601,7 +1603,7 @@ export declare interface ILocalVideoTrack extends ILocalTrack {
1601
1603
  * - `"detail"`: Prioritizes video quality.
1602
1604
  * - 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
1605
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
1604
- * - `"motion"`: Prioritizes video smoothness.
1606
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
1605
1607
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
1606
1608
  * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution.
1607
1609
  */
@@ -1769,7 +1771,7 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
1769
1771
  *
1770
1772
  * Sets the audio playback device, for example, the speaker.
1771
1773
  *
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.
1774
+ * > This method supports Chrome and Edge on desktop devices only. Other browsers throw a `NOT_SUPPORTED` error when calling this method.
1773
1775
  * @param deviceId Device ID, which can be retrieved by calling [[getPlaybackDevices]].
1774
1776
  */
1775
1777
  setPlaybackDevice(deviceId: string): Promise<void>;
@@ -2002,6 +2004,8 @@ export { isElectron }
2002
2004
 
2003
2005
  export declare function isLowStreamParameter(streamParameter: any): streamParameter is LowStreamParameter;
2004
2006
 
2007
+ export declare function isPlanB(): boolean;
2008
+
2005
2009
  export declare function isScreenSourceType(mediaSource: any): mediaSource is ScreenSourceType;
2006
2010
 
2007
2011
  export declare function isVideoEncoderConfiguration(config: VideoEncoderConfiguration): config is VideoEncoderConfiguration;
@@ -2206,7 +2210,6 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
2206
2210
  _player?: AgoraRTCPlayer | VideoPlayer;
2207
2211
  isUseScaleResolutionDownBy: boolean;
2208
2212
  private _videoVisibleTimer;
2209
- protected _statsTimer: number | null;
2210
2213
  private _previousVideoVisibleStatus;
2211
2214
  private _clearPreviousVideoVisibleStatus;
2212
2215
  _encoderConfig?: Partial<VideoEncoderConfiguration>;
@@ -2256,7 +2259,6 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
2256
2259
  close(): void;
2257
2260
  clone(config?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, cloneTrack?: boolean): LocalVideoTrack;
2258
2261
  replaceTrack(track: MediaStreamTrack, stopOldTrack: boolean): Promise<void>;
2259
- startMonitorStats(): void;
2260
2262
  sendSeiData(sei: Uint8Array): never;
2261
2263
  private bindProcessorDestinationEvents;
2262
2264
  private unbindProcessorDestinationEvents;
@@ -2274,7 +2276,7 @@ export declare interface LocalVideoTrackStats {
2274
2276
  * - `"VP8"`: The video codec is VP8.
2275
2277
  * - `"VP9"`: The video codec is VP9.
2276
2278
  * - `"AV1X"`: Reserved for future use.
2277
- * - `"AV1"`: Reserved for future use.
2279
+ * - `"AV1"`: The video codec is AV1.
2278
2280
  *
2279
2281
  * > You can not get this property on Firefox.
2280
2282
  */
@@ -2521,7 +2523,7 @@ export declare interface ProcessorUsageStats {
2521
2523
  }
2522
2524
 
2523
2525
  export declare class RemoteAudioTrack extends RemoteTrack implements IRemoteAudioTrack {
2524
- readonly trackMediaType: "audio" | "video";
2526
+ readonly trackMediaType: TrackMediaType.AUDIO;
2525
2527
  _source: AudioTrackSource | FakeTrackSource;
2526
2528
  _useAudioElement: boolean;
2527
2529
  private _volume;
@@ -2607,6 +2609,10 @@ export declare interface RemoteAudioTrackStats {
2607
2609
  * The total number of lost audio packets that should be received.
2608
2610
  */
2609
2611
  receivePacketsLost: number;
2612
+ /**
2613
+ * The number of packets discarded by the jitter buffer due to early or late arrival.
2614
+ */
2615
+ receivePacketsDiscarded: number;
2610
2616
  /**
2611
2617
  * The packet loss rate of the received audio.
2612
2618
  */
@@ -2698,7 +2704,7 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
2698
2704
  private _videoVisibleTimer;
2699
2705
  private _previousVideoVisibleStatus;
2700
2706
  private _clearPreviousVideoVisibleStatus;
2701
- readonly trackMediaType: "audio" | "video";
2707
+ readonly trackMediaType: TrackMediaType.VIDEO;
2702
2708
  _videoWidth?: number;
2703
2709
  _videoHeight?: number;
2704
2710
  _player?: AgoraRTCPlayer | VideoPlayer;
@@ -2739,7 +2745,7 @@ export declare interface RemoteVideoTrackStats {
2739
2745
  * - `"VP8"`: The video codec is VP8.
2740
2746
  * - `"VP9"`: The video codec is VP9.
2741
2747
  * - `"AV1X"`: Reserved for future use.
2742
- * - `"AV1"`: Reserved for future use.
2748
+ * - `"AV1"`: The video codec is AV1.
2743
2749
  *
2744
2750
  * > You can not get this property on Firefox.
2745
2751
  */
@@ -2905,17 +2911,21 @@ export declare interface ScreenVideoTrackInitConfig {
2905
2911
  screenSourceType?: ScreenSourceType;
2906
2912
  /**
2907
2913
  * @since
2908
- * <br>&emsp;&emsp;&emsp;*4.0.0*
2914
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
2909
2915
  *
2910
- * Transmission optimization mode. Whether to prioritize video quality or smoothness:
2911
- * - `"detail"`: (Default) Prioritizes video quality.
2916
+ * Sets the video transmission optimization mode.
2917
+ *
2918
+ * 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.
2919
+ *
2920
+ * > Note: This method supports Chrome only.
2921
+ *
2922
+ * @param mode The video transmission optimization mode:
2923
+ * - `"detail"`: Prioritizes video quality.
2912
2924
  * - 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
2925
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
2914
- * - `"motion"`: Prioritizes video smoothness.
2926
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
2915
2927
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
2916
2928
  * - 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
2929
  */
2920
2930
  optimizationMode?: "motion" | "detail";
2921
2931
  /**
@@ -3136,6 +3146,12 @@ export declare enum TrackInternalEvent {
3136
3146
  NEED_UNMUTE_TRACK = "@need_unmute_track"
3137
3147
  }
3138
3148
 
3149
+ export declare enum TrackMediaType {
3150
+ AUDIO = "audio",
3151
+ VIDEO = "video",
3152
+ DATA = "data"
3153
+ }
3154
+
3139
3155
  export declare function updateAgoraRTCCompatibility(): void;
3140
3156
 
3141
3157
  export declare interface UsageRegistry {