@agora-js/media 4.21.0 → 4.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
  */
@@ -2653,7 +2659,13 @@ export declare enum RemoteStreamFallbackType {
2653
2659
  /**
2654
2660
  * 2: Subscribe to the low-quality video stream when the network conditions worsen, and subscribe to audio only when the conditions become too poor to support video transmission.
2655
2661
  */
2656
- AUDIO_ONLY = 2
2662
+ AUDIO_ONLY = 2,
2663
+ HIGH_STREAM_LAYER1 = 3,
2664
+ HIGH_STREAM_LAYER2 = 4,
2665
+ HIGH_STREAM_LAYER3 = 5,
2666
+ HIGH_STREAM_LAYER4 = 6,
2667
+ HIGH_STREAM_LAYER5 = 7,
2668
+ HIGH_STREAM_LAYER6 = 8
2657
2669
  }
2658
2670
 
2659
2671
  /**
@@ -2667,7 +2679,13 @@ export declare enum RemoteStreamType {
2667
2679
  /**
2668
2680
  * 1: Low-quality video stream (low-bitrate, low-resolution).
2669
2681
  */
2670
- LOW_STREAM = 1
2682
+ LOW_STREAM = 1,
2683
+ HIGH_STREAM_LAYER1 = 4,
2684
+ HIGH_STREAM_LAYER2 = 5,
2685
+ HIGH_STREAM_LAYER3 = 6,
2686
+ HIGH_STREAM_LAYER4 = 7,
2687
+ HIGH_STREAM_LAYER5 = 8,
2688
+ HIGH_STREAM_LAYER6 = 9
2671
2689
  }
2672
2690
 
2673
2691
  export declare abstract class RemoteTrack extends Track implements IRemoteTrack {
@@ -2698,7 +2716,7 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
2698
2716
  private _videoVisibleTimer;
2699
2717
  private _previousVideoVisibleStatus;
2700
2718
  private _clearPreviousVideoVisibleStatus;
2701
- readonly trackMediaType: "audio" | "video";
2719
+ readonly trackMediaType: TrackMediaType.VIDEO;
2702
2720
  _videoWidth?: number;
2703
2721
  _videoHeight?: number;
2704
2722
  _player?: AgoraRTCPlayer | VideoPlayer;
@@ -2739,7 +2757,7 @@ export declare interface RemoteVideoTrackStats {
2739
2757
  * - `"VP8"`: The video codec is VP8.
2740
2758
  * - `"VP9"`: The video codec is VP9.
2741
2759
  * - `"AV1X"`: Reserved for future use.
2742
- * - `"AV1"`: Reserved for future use.
2760
+ * - `"AV1"`: The video codec is AV1.
2743
2761
  *
2744
2762
  * > You can not get this property on Firefox.
2745
2763
  */
@@ -2905,17 +2923,21 @@ export declare interface ScreenVideoTrackInitConfig {
2905
2923
  screenSourceType?: ScreenSourceType;
2906
2924
  /**
2907
2925
  * @since
2908
- * <br>&emsp;&emsp;&emsp;*4.0.0*
2926
+ * <br>&emsp;&emsp;&emsp;*4.2.0*
2909
2927
  *
2910
- * Transmission optimization mode. Whether to prioritize video quality or smoothness:
2911
- * - `"detail"`: (Default) Prioritizes video quality.
2928
+ * Sets the video transmission optimization mode.
2929
+ *
2930
+ * 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.
2931
+ *
2932
+ * > Note: This method supports Chrome only.
2933
+ *
2934
+ * @param mode The video transmission optimization mode:
2935
+ * - `"detail"`: Prioritizes video quality.
2912
2936
  * - 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
2937
  * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate.
2914
- * - `"motion"`: Prioritizes video smoothness.
2938
+ * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness.
2915
2939
  * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes.
2916
2940
  * - 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
2941
  */
2920
2942
  optimizationMode?: "motion" | "detail";
2921
2943
  /**
@@ -3114,7 +3136,8 @@ export declare enum TrackEvents {
3114
3136
  export declare enum TrackHint {
3115
3137
  SCREEN_TRACK = "screen_track",
3116
3138
  CUSTOM_TRACK = "custome_track",
3117
- LOW_STREAM = "low_stream"
3139
+ LOW_STREAM = "low_stream",
3140
+ SCREEN_LOW_TRACK = "screen_low_track"
3118
3141
  }
3119
3142
 
3120
3143
  export declare enum TrackInternalEvent {
@@ -3136,6 +3159,12 @@ export declare enum TrackInternalEvent {
3136
3159
  NEED_UNMUTE_TRACK = "@need_unmute_track"
3137
3160
  }
3138
3161
 
3162
+ export declare enum TrackMediaType {
3163
+ AUDIO = "audio",
3164
+ VIDEO = "video",
3165
+ DATA = "data"
3166
+ }
3167
+
3139
3168
  export declare function updateAgoraRTCCompatibility(): void;
3140
3169
 
3141
3170
  export declare interface UsageRegistry {