@agora-js/media 4.24.0 → 4.24.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.
@@ -41,6 +41,8 @@ export declare interface AgoraRTCCompatibility {
41
41
  supportWebRTCInsertableStream: boolean;
42
42
  supportRequestVideoFrameCallback: boolean;
43
43
  supportWebCrypto: boolean;
44
+ supportSuppressLocalAudioPlayback: boolean;
45
+ supportRestrictOwnAudio: boolean;
44
46
  }
45
47
 
46
48
  export declare class AgoraRTCPlayer extends VideoPlayer {
@@ -172,11 +174,12 @@ declare class AudioElementPlayCenter {
172
174
  updateTrack(trackId: string, track: MediaStreamTrack): void;
173
175
  isPlaying(trackId: string): boolean;
174
176
  setVolume(trackId: string, volume: number): void;
177
+ getVolume(trackId: string): number;
175
178
  stop(trackId: string): void;
176
179
  private bindAudioElementEvents;
177
180
  getPlayerState(trackId: string): string;
178
181
  private autoResumeAudioElement;
179
- autoResumeAfterInterruption: (force?: boolean) => void;
182
+ autoResumeAfterInterruption: (force?: boolean) => Promise<void[]>;
180
183
  private autoResumeAfterInterruptionOnIOS15_16;
181
184
  }
182
185
 
@@ -840,6 +843,10 @@ export declare function detectSupportPrePc(store?: SDKStore): boolean;
840
843
 
841
844
  export declare function detectSupportPreSub(store?: SDKStore): boolean;
842
845
 
846
+ export declare function detectSupportRestrictOwnAudio(): boolean;
847
+
848
+ export declare function detectSupportSuppressLocalAudioPlayback(): boolean;
849
+
843
850
  /**
844
851
  * Information of the media input device.
845
852
  *
@@ -949,7 +956,7 @@ declare function event_first_frame_decoded(): void;
949
956
  * @since
950
957
  * <br>&emsp;&emsp;&emsp;*4.20.1*
951
958
  *
952
- * Parsing SEI data from the H.264 video stream triggers this event, which returns the SEI data.
959
+ * Parsing SEI data from the H.264 or H.265 video stream triggers this event, which returns the SEI data.
953
960
  *
954
961
  * @param sei SEI data in Uint8Array
955
962
  * @asMemberOf ILocalVideoTrack
@@ -1112,7 +1119,7 @@ declare class FakeTrackSource extends EventEmitter {
1112
1119
  createMediaStreamSourceNode(): undefined;
1113
1120
  }
1114
1121
 
1115
- export declare const frameData2CryptoBuffer: (imageData: ImageTypedData, appid: string, channelName: string) => Promise<Uint8Array<ArrayBufferLike>>;
1122
+ export declare const frameData2CryptoBuffer: (imageData: ImageTypedData, appid: string, channelName: string) => Promise<Uint8Array>;
1116
1123
 
1117
1124
  export declare function getAudioContext(): AudioContext;
1118
1125
 
@@ -1130,7 +1137,10 @@ export declare function getConstraintsFromCameraConfig(config: CameraVideoTrackI
1130
1137
 
1131
1138
  export declare function getConstraintsFromMicrophoneConfig(config: MicrophoneAudioTrackInitConfig): MediaTrackConstraints;
1132
1139
 
1133
- export declare function getConstraintsFromScreenAudioConfig(config: ScreenAudioTrackInitConfig): MediaTrackConstraints;
1140
+ export declare function getConstraintsFromScreenAudioConfig(config: ScreenAudioTrackInitConfig): MediaTrackConstraints & {
1141
+ suppressLocalAudioPlayback?: boolean;
1142
+ restrictOwnAudio?: boolean;
1143
+ };
1134
1144
 
1135
1145
  export declare function getConstraintsFromScreenConfig(config: ScreenVideoTrackInitConfig): ScreenConstraintsWithElectron;
1136
1146
 
@@ -1183,6 +1193,8 @@ export declare let HAS_GUM_VIDEO: boolean;
1183
1193
 
1184
1194
  export declare function hasAudioContext(): boolean;
1185
1195
 
1196
+ export declare function hasMicrophoneTrack(): boolean;
1197
+
1186
1198
  /**
1187
1199
  * 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.
1188
1200
  *
@@ -1355,6 +1367,15 @@ declare interface IDataStream {
1355
1367
  deserialize: (packet: ArrayBuffer) => ArrayBuffer;
1356
1368
  }
1357
1369
 
1370
+ export declare interface IFrameInfo {
1371
+ type: string;
1372
+ rtpTimestamp: number;
1373
+ payloadType: number;
1374
+ ssrc: number;
1375
+ length: number;
1376
+ mimeType?: string;
1377
+ }
1378
+
1358
1379
  /**
1359
1380
  * `LocalAudioTrack` is the basic interface for local audio tracks, providing main methods of local audio tracks.
1360
1381
  *
@@ -1523,11 +1544,11 @@ export declare interface ILocalTrack extends ITrack {
1523
1544
  * Sends or stops sending the media data of the track.
1524
1545
  *
1525
1546
  * @since
1526
- * <br>&emsp;&emsp;&emsp;*4.6.0*
1547
+ * <br>&emsp;&emsp;&emsp;*4.0.0*
1527
1548
  *
1528
1549
  * 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.
1529
1550
  *
1530
- * > - 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).
1551
+ * > - 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/help/integration-issues/set_enabled_set_muted).
1531
1552
  * > - Do not call `setEnabled` and `setMuted` together.
1532
1553
  *
1533
1554
  * @param muted Whether to stop sending the media data of the track:
@@ -1813,6 +1834,7 @@ export declare function interceptRemoteVideoFrame(receiver: RTCRtpReceiver, opti
1813
1834
 
1814
1835
  export declare interface InterceptVideoFrameOptions {
1815
1836
  onSei?: (sei: Uint8Array) => void;
1837
+ onFirstFrame?: (frameInfo: IFrameInfo) => void;
1816
1838
  }
1817
1839
 
1818
1840
  /**
@@ -1874,6 +1896,7 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
1874
1896
  * @param volume The volume. The value ranges from 0 (mute) to 100 (maximum). A value of 100 is the current volume.
1875
1897
  */
1876
1898
  setVolume(volume: number): void;
1899
+ setAmplifiedVolume(volume: number): void;
1877
1900
  /**
1878
1901
  * Gets the audio level of a remote audio track.
1879
1902
  *
@@ -1881,6 +1904,7 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
1881
1904
  * Usually a user with audio level above 0.6 is a speaking user.
1882
1905
  */
1883
1906
  getVolumeLevel(): number;
1907
+ getVolume(): number;
1884
1908
  /**
1885
1909
  * @since
1886
1910
  * <br>&emsp;&emsp;&emsp;*4.13.0*
@@ -2060,6 +2084,12 @@ export declare interface IRemoteVideoTrack extends IRemoteTrack {
2060
2084
  * The destination of the current processing pipeline on the remote video track.
2061
2085
  */
2062
2086
  processorDestination: IBaseProcessor;
2087
+ /**
2088
+ * Stops playing the media track.
2089
+ * @param isKeepLastFrame Whether to keep the last frame.
2090
+ * @internal
2091
+ */
2092
+ stop(isKeepLastFrame?: boolean): void;
2063
2093
  }
2064
2094
 
2065
2095
  export declare function isAudioEncoderConfiguration(config: AudioEncoderConfiguration): config is AudioEncoderConfiguration;
@@ -2603,8 +2633,10 @@ export declare class RemoteAudioTrack extends RemoteTrack implements IRemoteAudi
2603
2633
  constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore);
2604
2634
  setAudioFrameCallback(callback: null | ((buffer: AudioBuffer) => void), frameSize?: number): void;
2605
2635
  setVolume(volume: number): void;
2636
+ setAmplifiedVolume(volume: number): void;
2606
2637
  setPlaybackDevice(deviceId: string): Promise<void>;
2607
2638
  getVolumeLevel(): number;
2639
+ getVolume(): number;
2608
2640
  getStats(): RemoteAudioTrackStats;
2609
2641
  play(): void;
2610
2642
  stop(): void;
@@ -2798,7 +2830,7 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
2798
2830
  constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore, player?: AgoraRTCPlayer);
2799
2831
  getStats(): RemoteVideoTrackStats;
2800
2832
  play(element: string | HTMLElement | HTMLVideoElement, config?: VideoPlayerConfig): void;
2801
- stop(): void;
2833
+ stop(isKeepLastFrame?: boolean): void;
2802
2834
  getCurrentFrameData(): ImageData;
2803
2835
  updateMediaStreamTrackResolution(): void;
2804
2836
  protected _updatePlayerSource(): void;
@@ -2914,12 +2946,59 @@ export declare interface Resolution {
2914
2946
  height: number;
2915
2947
  }
2916
2948
 
2949
+ export declare function restartBackgroundTag(): void;
2950
+
2917
2951
  export declare const SAFARI_GLOBAL_GUM_LOCK: PromiseMutex;
2918
2952
 
2919
2953
  /**
2920
2954
  * Configurations for the audio track of screen sharing. Set these configurations when calling [AgoraRTC.createScreenVideoTrack]{@link IAgoraRTC.createScreenVideoTrack} to enable audio during screen sharing.
2921
2955
  */
2922
- export declare type ScreenAudioTrackInitConfig = AudioTrackInitConfig;
2956
+ export declare type ScreenAudioTrackInitConfig = {
2957
+ /**
2958
+ * Whether to enable acoustic echo cancellation:
2959
+ * - `true`: Enable acoustic echo cancellation.
2960
+ * - `false`: Do not enable acoustic echo cancellation.
2961
+ */
2962
+ AEC?: boolean;
2963
+ /**
2964
+ * Whether to enable audio gain control:
2965
+ * - `true`: Enable audio gain control.
2966
+ * - `false`: Do not enable audio gain control.
2967
+ */
2968
+ AGC?: boolean;
2969
+ /**
2970
+ * Whether to enable automatic noise suppression:
2971
+ * - `true`: Enable automatic noise suppression.
2972
+ * - `false`: Do not enable automatic noise suppression.
2973
+ */
2974
+ ANS?: boolean;
2975
+ /**
2976
+ * @since
2977
+ * <br>&emsp;&emsp;&emsp;*4.24.1*</br>
2978
+ *
2979
+ * Whether to suppress local audio playback.
2980
+ * - `true`: Suppress local audio playback.
2981
+ * - `false`: (Default) Do not suppress local audio playback.
2982
+ *
2983
+ * See [suppressLocalAudioPlayback](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSupportedConstraints/suppressLocalAudioPlayback) for details.
2984
+ *
2985
+ * > This parameter is supported on Chrome 109 and later, Edge 109 and later, and Opera 95 and later.
2986
+ */
2987
+ suppressLocalAudioPlayback?: boolean;
2988
+ /**
2989
+ * @since
2990
+ * <br>&emsp;&emsp;&emsp;*4.24.1*</br>
2991
+ *
2992
+ * Whether to restrict local audio capture.
2993
+ * - `true`: Restrict local audio capture.
2994
+ * - `false`: (Default) Do not restrict local audio capture.
2995
+ *
2996
+ * See [restrictOwnAudio](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSupportedConstraints/restrictOwnAudio) for details.
2997
+ *
2998
+ * > This parameter is supported on Chrome 141 and later, Edge 141 and later, and Opera 125 and later.
2999
+ */
3000
+ restrictOwnAudio?: boolean;
3001
+ };
2923
3002
 
2924
3003
  export declare interface ScreenConstraintsWithElectron extends MediaTrackConstraints {
2925
3004
  sourceId?: string;
@@ -2933,6 +3012,8 @@ export declare interface ScreenConstraintsWithElectron extends MediaTrackConstra
2933
3012
  surfaceSwitching?: "include" | "exclude";
2934
3013
  systemAudio?: "include" | "exclude";
2935
3014
  preferCurrentTab?: boolean;
3015
+ monitorTypeSurfaces?: "exclude" | "include";
3016
+ windowAudio?: "exclude" | "system";
2936
3017
  }
2937
3018
 
2938
3019
  /**
@@ -3096,6 +3177,31 @@ export declare interface ScreenVideoTrackInitConfig {
3096
3177
  * > Note: This property is only supported in Chrome 94 and above, and Opera 80 and above..
3097
3178
  */
3098
3179
  preferCurrentTab?: boolean;
3180
+ /**
3181
+ * @since
3182
+ * <br>&emsp;&emsp;&emsp;*4.24.1*</br>
3183
+ *
3184
+ * Whether to allow sharing window audio.
3185
+ * - `"exclude"`: Do not share any audio.
3186
+ * - `"system"`: (Default) Share system audio.
3187
+ *
3188
+ * See [withAudio](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#windowAudio) for details.
3189
+ */
3190
+ windowAudio?: "exclude" | "system";
3191
+ /**
3192
+ * @since
3193
+ * <br>&emsp;&emsp;&emsp;*4.24.1*</br>
3194
+ *
3195
+ * Whether to allow sharing the entire screen, including the browser tab and window options.
3196
+ * - `"exclude"`: Do not share the entire screen.
3197
+ * - `"include"`: Share the entire screen.
3198
+ *
3199
+ * See [monitorTypeSurfaces](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#monitortypesurfaces) for details.
3200
+ *
3201
+ * > - This parameter is supported on Chrome 119 and later.
3202
+ * > - If you set `monitorTypeSurface` to `exclude`, you cannot set `displaySurface` to `monitor`; otherwise, an error will occur.
3203
+ */
3204
+ monitorTypeSurfaces?: "exclude" | "include";
3099
3205
  }
3100
3206
 
3101
3207
  export declare type SenderConfig = {
@@ -3312,14 +3418,14 @@ export declare interface VideoEncoderConfiguration {
3312
3418
  * | Video Profile | Resolution (Width×Height) | Frame Rate (fps) | Chrome | Firefox | Safari |
3313
3419
  * | -------- | --------------- | ----------- | ------ | ------- | ------ |
3314
3420
  * | 120p | 160 × 120 | 15 | ✓ | | |
3315
- * | 120p_1 | 160 × 120 | 15 | ✓ | | |
3421
+ * | 120p_1 | 160 × 120 | 15 | ✓ | ||
3316
3422
  * | 120p_3 | 120 × 120 | 15 | ✓ | | |
3317
3423
  * | 180p | 320 × 180 | 15 | ✓ | | |
3318
3424
  * | 180p_1 | 320 × 180 | 15 | ✓ | | |
3319
3425
  * | 180p_3 | 180 × 180 | 15 | ✓ | | |
3320
- * | 180p_4 | 240 × 180 | 15 | ✓ | | |
3426
+ * | 180p_4 | 240 × 180 | 15 | ✓ | ||
3321
3427
  * | 240p | 320 × 240 | 15 | ✓ | | |
3322
- * | 240p_1 | 320 × 240 | 15 | ✓ | | |
3428
+ * | 240p_1 | 320 × 240 | 15 | ✓ | ||
3323
3429
  * | 240p_3 | 240 × 240 | 15 | ✓ | | |
3324
3430
  * | 240p_4 | 424 × 240 | 15 | ✓ | | |
3325
3431
  * | 360p | 640 × 360 | 15 | ✓ | | |
@@ -3327,7 +3433,7 @@ export declare interface VideoEncoderConfiguration {
3327
3433
  * | 360p_3 | 360 × 360 | 15 | ✓ | | |
3328
3434
  * | 360p_4 | 640 × 360 | 30 | ✓ | | |
3329
3435
  * | 360p_6 | 360 × 360 | 30 | ✓ | | |
3330
- * | 360p_7 | 480 × 360 | 15 | ✓ | | |
3436
+ * | 360p_7 | 480 × 360 | 15 | ✓ | ||
3331
3437
  * | 360p_8 | 480 × 360 | 30 | ✓ | | |
3332
3438
  * | 360p_9 | 640 × 360 | 15 | ✓ | | |
3333
3439
  * | 360p_10 | 640 × 360 | 24 | ✓ | | |
@@ -3363,6 +3469,7 @@ declare class VideoPlayer {
3363
3469
  config: PlayerConfig;
3364
3470
  onFirstVideoFrameDecoded?: () => void;
3365
3471
  onFirstVideoFrameRender?: () => void;
3472
+ onVideoBufferReady?: () => void;
3366
3473
  onVideoStateChanged?: (state: VideoState) => void;
3367
3474
  freezeTimeCounterList: number[];
3368
3475
  renderFreezeAccTime: number;
@@ -3377,6 +3484,7 @@ declare class VideoPlayer {
3377
3484
  protected videoTrack?: MediaStreamTrack;
3378
3485
  protected videoElement: HTMLVideoElement;
3379
3486
  protected cacheVideoElement?: HTMLVideoElement;
3487
+ protected cancelRVFId?: number;
3380
3488
  protected internal: boolean;
3381
3489
  get rendFrameRate(): number;
3382
3490
  get videoElementStatus(): MediaElementStatus;
@@ -3399,7 +3507,7 @@ declare class VideoPlayer {
3399
3507
  play(sessionId?: string): void;
3400
3508
  getCurrentFrame(): ImageData;
3401
3509
  getCurrentFrameToUint8Array(type: string, quality?: number): Promise<ImageTypedData>;
3402
- destroy(): void;
3510
+ destroy(isKeepLastFrame?: boolean): void;
3403
3511
  protected initVideoElement(): void;
3404
3512
  protected resetVideoElement(): void;
3405
3513
  private startGetVideoDimensions;
@@ -3435,6 +3543,11 @@ export declare interface VideoPlayerConfig {
3435
3543
  * > - When playing the remote video track, the SDK uses cover mode by default.
3436
3544
  */
3437
3545
  fit?: "cover" | "contain" | "fill";
3546
+ /**
3547
+ * Whether to use the style
3548
+ * @ignore
3549
+ */
3550
+ noStyle?: boolean;
3438
3551
  }
3439
3552
 
3440
3553
  export declare class VideoProcessorContext extends EventEmitter implements IProcessorContext {
@@ -3505,10 +3618,14 @@ export declare enum VideoState {
3505
3618
  declare class VisibilityWatcher extends EventEmitter {
3506
3619
  private _lastHiddenTime;
3507
3620
  private _lastVisibleTime;
3621
+ needUploadStats: number[];
3622
+ isCollectingStats: boolean;
3508
3623
  get visibility(): DocumentVisibilityState;
3509
3624
  get lastHiddenTime(): DOMHighResTimeStamp;
3510
3625
  get lastVisibleTime(): DOMHighResTimeStamp;
3511
3626
  constructor();
3627
+ startCollectStats(): void;
3628
+ stopCollectStats(): void;
3512
3629
  }
3513
3630
 
3514
3631
  export declare const visibilityWatcher: VisibilityWatcher;