@agora-js/media 4.24.4 → 4.24.6

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,12 +1,15 @@
1
1
  import { AgoraRTCError } from '@agora-js/shared';
2
+ import type { AudioExtensionConstructor } from 'agora-rte-extension-ng';
2
3
  import { CheckVisibleResult } from '@agora-js/shared';
3
4
  import { ElectronDesktopCapturerSource } from '@agora-js/shared';
4
5
  import { EventEmitter } from '@agora-js/shared';
6
+ import type { IAudioExtension } from 'agora-rte-extension-ng';
5
7
  import { IAudioProcessor } from 'agora-rte-extension';
6
8
  import type { IAudioProcessorContext } from 'agora-rte-extension';
7
9
  import { IBaseProcessor } from 'agora-rte-extension';
8
10
  import type { IProcessorContext } from 'agora-rte-extension';
9
11
  import { isElectron } from '@agora-js/shared';
12
+ import type { IVideoExtension } from 'agora-rte-extension-ng';
10
13
  import type { Kind } from 'agora-rte-extension';
11
14
  import type { NetworkQuality } from '@agora-js/shared';
12
15
  import type { ProcessorStats } from 'agora-rte-extension';
@@ -16,6 +19,7 @@ import { SDKStore } from '@agora-js/shared';
16
19
  import { UID } from '@agora-js/shared';
17
20
  import { Usage } from 'agora-rte-extension';
18
21
  import type { UsageWithDirection } from 'agora-rte-extension';
22
+ import type { VideoExtensionConstructor } from 'agora-rte-extension-ng';
19
23
 
20
24
  export declare const __TRACK_LIST__: Track[];
21
25
 
@@ -168,6 +172,7 @@ declare class AudioElementPlayCenter {
168
172
  private elementStateMap;
169
173
  private elementsNeedToResume;
170
174
  private sinkIdMap;
175
+ private elementIdMap;
171
176
  constructor();
172
177
  setSinkID(trackId: string, deviceID: string): Promise<void>;
173
178
  play(track: MediaStreamTrack, trackId: string, volume: number, sessionId?: string): void;
@@ -176,6 +181,7 @@ declare class AudioElementPlayCenter {
176
181
  setVolume(trackId: string, volume: number): void;
177
182
  getVolume(trackId: string): number;
178
183
  stop(trackId: string): void;
184
+ reuseTrackId(fromId: string, toId: string): void;
179
185
  private bindAudioElementEvents;
180
186
  getPlayerState(trackId: string): string;
181
187
  private autoResumeAudioElement;
@@ -740,6 +746,18 @@ export declare interface CustomVideoTrackInitConfig {
740
746
  * The maximum bitrate of sending the video track (Kbps).
741
747
  */
742
748
  bitrateMax?: number;
749
+ /**
750
+ * The minimum width allowed during automatic downscaling.
751
+ *
752
+ * When the SDK takes over resolution downscaling, the sending width will not go below this value.
753
+ */
754
+ minDownscaleWidth?: number;
755
+ /**
756
+ * The minimum height allowed during automatic downscaling.
757
+ *
758
+ * When the SDK takes over resolution downscaling, the sending height will not go below this value.
759
+ */
760
+ minDownscaleHeight?: number;
743
761
  /**
744
762
  * @since
745
763
  * <br>&emsp;&emsp;&emsp;*4.2.0*
@@ -1159,11 +1177,15 @@ export declare function getNewNearestVideoProfile(width: number, height: number,
1159
1177
  export declare function getNewVideoBitrate(width: number, height: number, fps: number): [number, number];
1160
1178
 
1161
1179
  export declare const getOriginSenderConfig: (track: LocalVideoTrack) => {
1180
+ width: number;
1181
+ height: number;
1162
1182
  frameRate: number;
1163
1183
  bitrateMax: number;
1164
1184
  bitrateMin: number;
1165
1185
  scaleResolutionDownBy: number;
1166
1186
  scale: number;
1187
+ minDownscaleWidth: number;
1188
+ minDownscaleHeight: number;
1167
1189
  };
1168
1190
 
1169
1191
  export declare function getScalabilityConfiguration(profile: SVCConfiguration | SVCConfigurationPreset): SVCConfiguration;
@@ -1473,6 +1495,33 @@ export declare interface ILocalAudioTrack extends ILocalTrack {
1473
1495
  * The destination of the current processing pipeline on the local audio track.
1474
1496
  */
1475
1497
  processorDestination: IAudioProcessor;
1498
+ /**
1499
+ * Creates or reuses an audio extension instance on the current audio track using a class constructor.
1500
+ *
1501
+ * @param extensionCtor The audio extension class constructor.
1502
+ * @param extensionOptions Optional extension initialization parameters.
1503
+ */
1504
+ useExtension<T extends IAudioExtension>(extensionCtor: AudioExtensionConstructor<T>, extensionOptions?: Record<string, unknown>): T;
1505
+ /**
1506
+ * Removes an audio extension from the local audio track.
1507
+ *
1508
+ * @param extension The audio extension instance.
1509
+ * @returns Whether the removal succeeded.
1510
+ */
1511
+ removeExtension(extension: IAudioExtension): boolean;
1512
+ /**
1513
+ * Adds a reference track to the current audio extension pipeline.
1514
+ *
1515
+ * @param track The local or remote audio track used as the reference input.
1516
+ */
1517
+ addReferenceTrack(track: ILocalAudioTrack | IRemoteAudioTrack): void;
1518
+ /**
1519
+ * Removes a reference track from the current audio extension pipeline.
1520
+ *
1521
+ * @param track The reference input track to remove.
1522
+ * @returns Whether the removal succeeded.
1523
+ */
1524
+ removeReferenceTrack(track: ILocalAudioTrack | IRemoteAudioTrack): boolean;
1476
1525
  }
1477
1526
 
1478
1527
  /**
@@ -1713,6 +1762,8 @@ export declare interface ILocalVideoTrack extends ILocalTrack {
1713
1762
  * @since
1714
1763
  * <br>&emsp;&emsp;&emsp;*4.10.0*
1715
1764
  *
1765
+ * @deprecated Legacy v1 pipe-mode API. For new extensions, use `useExtension` and `removeExtension`.
1766
+ *
1716
1767
  * Removes the `Processor` inserted to the local video track.
1717
1768
  */
1718
1769
  unpipe(): void;
@@ -1720,9 +1771,31 @@ export declare interface ILocalVideoTrack extends ILocalTrack {
1720
1771
  * @since
1721
1772
  * <br>&emsp;&emsp;&emsp;*4.10.0*
1722
1773
  *
1774
+ * @deprecated Legacy v1 pipe-mode API. For new extensions, use `useExtension` and `removeExtension`.
1775
+ *
1723
1776
  * The destination of the current processing pipeline on the local video track.
1724
1777
  */
1725
1778
  processorDestination: IBaseProcessor;
1779
+ /**
1780
+ * Creates or reuses a video extension proxy on the current video track using a class constructor.
1781
+ *
1782
+ * The same extension constructor always returns the same instance proxy until it is destroyed.
1783
+ *
1784
+ * @param extensionCtor The video extension class constructor.
1785
+ * @param options Optional extension initialization parameters.
1786
+ */
1787
+ useExtension<T extends VideoExtensionConstructor>(extensionCtor: T, options?: {
1788
+ extensionOptions?: Record<string, unknown>;
1789
+ moduleURL?: string;
1790
+ registrationName?: string;
1791
+ }): InstanceType<T>;
1792
+ /**
1793
+ * Removes a video extension from the local video track.
1794
+ *
1795
+ * @param extension The video extension instance.
1796
+ * @returns Whether the removal succeeded.
1797
+ */
1798
+ removeExtension(extension: IVideoExtension): boolean;
1726
1799
  /**
1727
1800
  * @since
1728
1801
  * <br>&emsp;&emsp;&emsp;*4.17.0*
@@ -1932,6 +2005,32 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
1932
2005
  * The destination of the current processing pipeline on the remote audio track.
1933
2006
  */
1934
2007
  processorDestination: IAudioProcessor;
2008
+ /**
2009
+ * Creates or reuses an audio extension instance on the current remote audio track using a class constructor.
2010
+ *
2011
+ * @param extensionCtor The audio extension class constructor.
2012
+ */
2013
+ useExtension<T extends IAudioExtension>(extensionCtor: AudioExtensionConstructor<T>): T;
2014
+ /**
2015
+ * Removes an audio extension from the remote audio track.
2016
+ *
2017
+ * @param extension The audio extension instance.
2018
+ * @returns Whether the removal succeeded.
2019
+ */
2020
+ removeExtension(extension: IAudioExtension): boolean;
2021
+ /**
2022
+ * Adds a reference track to the current audio extension pipeline.
2023
+ *
2024
+ * @param track The local or remote audio track used as the reference input.
2025
+ */
2026
+ addReferenceTrack(track: ILocalAudioTrack | IRemoteAudioTrack): void;
2027
+ /**
2028
+ * Removes a reference track from the current audio extension pipeline.
2029
+ *
2030
+ * @param track The reference input track to remove.
2031
+ * @returns Whether the removal succeeded.
2032
+ */
2033
+ removeReferenceTrack(track: ILocalAudioTrack | IRemoteAudioTrack): boolean;
1935
2034
  }
1936
2035
 
1937
2036
  /**
@@ -2086,6 +2185,24 @@ export declare interface IRemoteVideoTrack extends IRemoteTrack {
2086
2185
  * The destination of the current processing pipeline on the remote video track.
2087
2186
  */
2088
2187
  processorDestination: IBaseProcessor;
2188
+ /**
2189
+ * Creates or reuses a video extension proxy on the current video track using a class constructor.
2190
+ *
2191
+ * @param extensionCtor The video extension class constructor.
2192
+ * @param options Optional extension initialization parameters.
2193
+ */
2194
+ useExtension<T extends VideoExtensionConstructor>(extensionCtor: T, options?: {
2195
+ extensionOptions?: Record<string, unknown>;
2196
+ moduleURL?: string;
2197
+ registrationName?: string;
2198
+ }): InstanceType<T>;
2199
+ /**
2200
+ * Removes a video extension from the remote video track.
2201
+ *
2202
+ * @param extension The video extension instance.
2203
+ * @returns Whether the removal succeeded.
2204
+ */
2205
+ removeExtension(extension: IVideoExtension): boolean;
2089
2206
  /**
2090
2207
  * Stops playing the media track.
2091
2208
  * @param isKeepLastFrame Whether to keep the last frame.
@@ -2181,6 +2298,9 @@ export declare class LocalAudioTrack extends LocalTrack implements ILocalAudioTr
2181
2298
  _processorDestination: AudioProcessorDestination | undefined;
2182
2299
  get processorDestination(): AudioProcessorDestination;
2183
2300
  protected _getOriginVolumeLevel: boolean;
2301
+ private _usePipeMode;
2302
+ private _useExtensionMode;
2303
+ private _extensionManager?;
2184
2304
  get isPlaying(): boolean;
2185
2305
  get __className__(): string;
2186
2306
  constructor(track: MediaStreamTrack, encoderConfig?: AudioEncoderConfiguration, trackId?: string, getOriginVolumeLevel?: boolean);
@@ -2198,6 +2318,11 @@ export declare class LocalAudioTrack extends LocalTrack implements ILocalAudioTr
2198
2318
  protected _updatePlayerSource(updateWebAudioSource?: boolean): void;
2199
2319
  protected _updateOriginMediaStreamTrack(track: MediaStreamTrack, stopOldTrack: boolean): Promise<void>;
2200
2320
  renewMediaStreamTrack(newConstraints?: MediaTrackConstraints): Promise<void>;
2321
+ private _ensureExtensionManager;
2322
+ useExtension<T extends IAudioExtension>(ctor: AudioExtensionConstructor<T>, extensionOptions?: Record<string, unknown>): T;
2323
+ removeExtension(extension: IAudioExtension): boolean;
2324
+ addReferenceTrack(track: LocalAudioTrack | RemoteAudioTrack): void;
2325
+ removeReferenceTrack(track: LocalAudioTrack | RemoteAudioTrack): boolean;
2201
2326
  pipe(processor: IAudioProcessor): IAudioProcessor;
2202
2327
  unpipe(): void;
2203
2328
  private bindProcessorDestinationEvents;
@@ -2330,6 +2455,9 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
2330
2455
  protected _processorDestination: VideoProcessorDestination;
2331
2456
  get processorDestination(): VideoProcessorDestination;
2332
2457
  protected _processorContext: VideoProcessorContext;
2458
+ private _usePipeMode;
2459
+ private _useExtensionMode;
2460
+ private _extensionManager?;
2333
2461
  protected get processorContext(): VideoProcessorContext;
2334
2462
  protected set processorContext(ctx: VideoProcessorContext);
2335
2463
  get __className__(): string;
@@ -2358,6 +2486,13 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
2358
2486
  updateBitrateFromProfile(): void;
2359
2487
  getVideoElementVisibleStatus(): CheckVideoVisibleResult | undefined;
2360
2488
  renewMediaStreamTrack(newConstraints?: MediaTrackConstraints): Promise<void>;
2489
+ private _ensureVideoExtensionManager;
2490
+ useExtension<T extends VideoExtensionConstructor>(extensionCtor: T, options?: {
2491
+ extensionOptions?: Record<string, unknown>;
2492
+ moduleURL?: string;
2493
+ registrationName?: string;
2494
+ }): InstanceType<T>;
2495
+ removeExtension(extension: IVideoExtension): boolean;
2361
2496
  pipe(processor: IBaseProcessor): IBaseProcessor;
2362
2497
  unpipe(): void;
2363
2498
  close(): void;
@@ -2628,6 +2763,9 @@ export declare class RemoteAudioTrack extends RemoteTrack implements IRemoteAudi
2628
2763
  private _volume;
2629
2764
  protected processorContext: AudioProcessorContext;
2630
2765
  processorDestination: AudioProcessorDestination;
2766
+ private _usePipeMode;
2767
+ private _useExtensionMode;
2768
+ private _extensionManager?;
2631
2769
  private _played;
2632
2770
  private _bypassWebAudio;
2633
2771
  get isPlaying(): boolean;
@@ -2642,9 +2780,15 @@ export declare class RemoteAudioTrack extends RemoteTrack implements IRemoteAudi
2642
2780
  getStats(): RemoteAudioTrackStats;
2643
2781
  play(): void;
2644
2782
  stop(): void;
2783
+ _reusePreAudioElement(tempId: string, isPlaying: boolean): void;
2645
2784
  _destroy(): void;
2646
2785
  _isFreeze(): boolean;
2647
2786
  protected _updatePlayerSource(updateWebAudioSource?: boolean): void;
2787
+ private _ensureAudioExtensionManager;
2788
+ useExtension<T extends IAudioExtension>(ctor: AudioExtensionConstructor<T>): T;
2789
+ removeExtension(extension: IAudioExtension): boolean;
2790
+ addReferenceTrack(track: LocalAudioTrack | RemoteAudioTrack): void;
2791
+ removeReferenceTrack(track: LocalAudioTrack | RemoteAudioTrack): boolean;
2648
2792
  pipe(processor: IAudioProcessor): IAudioProcessor;
2649
2793
  unpipe(): void;
2650
2794
  private bindProcessorDestinationEvents;
@@ -2828,6 +2972,9 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
2828
2972
  private _prePlayer?;
2829
2973
  processorDestination: VideoProcessorDestination;
2830
2974
  protected processorContext: VideoProcessorContext;
2975
+ private _usePipeMode;
2976
+ private _useExtensionMode;
2977
+ private _extensionManager?;
2831
2978
  get isPlaying(): boolean;
2832
2979
  get __className__(): string;
2833
2980
  constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore, player?: AgoraRTCPlayer | VideoPlayer);
@@ -2838,6 +2985,13 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
2838
2985
  updateMediaStreamTrackResolution(): void;
2839
2986
  protected _updatePlayerSource(): void;
2840
2987
  getVideoElementVisibleStatus(): CheckVideoVisibleResult | undefined;
2988
+ private _ensureVideoExtensionManager;
2989
+ useExtension<T extends VideoExtensionConstructor>(extensionCtor: T, options?: {
2990
+ extensionOptions?: Record<string, unknown>;
2991
+ moduleURL?: string;
2992
+ registrationName?: string;
2993
+ }): InstanceType<T>;
2994
+ removeExtension(extension: IVideoExtension): boolean;
2841
2995
  pipe(processor: IBaseProcessor): IBaseProcessor;
2842
2996
  unpipe(): void;
2843
2997
  private bindProcessorDestinationEvents;
@@ -3408,6 +3562,18 @@ export declare interface VideoEncoderConfiguration {
3408
3562
  * @ignore
3409
3563
  */
3410
3564
  scaleResolutionDownBy?: number;
3565
+ /**
3566
+ * The minimum width allowed during automatic downscaling.
3567
+ *
3568
+ * When the SDK takes over resolution downscaling, the sending width will not go below this value.
3569
+ */
3570
+ minDownscaleWidth?: number;
3571
+ /**
3572
+ * The minimum height allowed during automatic downscaling.
3573
+ *
3574
+ * When the SDK takes over resolution downscaling, the sending height will not go below this value.
3575
+ */
3576
+ minDownscaleHeight?: number;
3411
3577
  }
3412
3578
 
3413
3579
  /**