@agora-js/media 4.20.0 → 4.20.1-100

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.
@@ -279,6 +279,8 @@ export declare class AudioProcessorDestination extends EventEmitter implements I
279
279
  }): void;
280
280
  }
281
281
 
282
+ declare type AudioRenderMode = "stereo" | "mono" | "surround";
283
+
282
284
  declare abstract class AudioSource extends EventEmitter {
283
285
  outputNode: GainNode;
284
286
  outputTrack?: MediaStreamTrack;
@@ -646,6 +648,7 @@ export declare interface CustomAudioTrackInitConfig {
646
648
  * > Firefox does not support setting the audio encoding rate.
647
649
  */
648
650
  encoderConfig?: AudioEncoderConfiguration | AudioEncoderConfigurationPreset;
651
+ channelCount?: number;
649
652
  }
650
653
 
651
654
  /**
@@ -896,6 +899,18 @@ declare function event_beauty_effect_overload(): void;
896
899
  */
897
900
  declare function event_first_frame_decoded(): void;
898
901
 
902
+ /**
903
+ * **Since**
904
+ * <br>&emsp;&emsp;&emsp;*4.20.1*
905
+ *
906
+ * Parsing SEI data from the H.264 video stream triggers this event, which returns the SEI data.
907
+ *
908
+ * @param sei SEI data in Uint8Array
909
+ * @asMemberOf ILocalVideoTrack
910
+ * @event
911
+ */
912
+ declare function event_sei_received(sei: Uint8Array): void;
913
+
899
914
  /**
900
915
  * Occurs when the state of processing the audio buffer in [BufferSourceAudioTrack]{@link IBufferSourceAudioTrack} changes.
901
916
  *
@@ -999,6 +1014,14 @@ declare function event_video_element_visible_status(data?: CheckVideoVisibleResu
999
1014
  */
1000
1015
  declare function event_video_element_visible_status_2(data?: CheckVideoVisibleResult): void;
1001
1016
 
1017
+ /**
1018
+ * Occurs when the video state changes.
1019
+ *
1020
+ * @event
1021
+ * @asMemberOf IRemoteTrack
1022
+ */
1023
+ declare function event_video_state_changed(videoState: VideoState): void;
1024
+
1002
1025
  export declare interface ExtendedVideoFrameCallbackMetadata extends VideoFrameCallbackMetadata {
1003
1026
  timestamp: DOMHighResTimeStamp;
1004
1027
  }
@@ -1042,7 +1065,7 @@ export declare function getAudioContext(): AudioContext;
1042
1065
 
1043
1066
  export declare function getAudioEncoderConfiguration(profile: AudioEncoderConfigurationPreset | AudioEncoderConfiguration): AudioEncoderConfiguration;
1044
1067
 
1045
- export declare function getBitrateFromResAndFps(width: number, height: number, fps: number, bitrateAdapterType: "STANDARD_BITRATE" | "COMPATIABLE_BITRATE"): [number, number] | void;
1068
+ export declare function getBitrateConstrainRange(width: number, height: number, frameRate: number, bitrateMin?: number, bitrateMax?: number): DoubleRange;
1046
1069
 
1047
1070
  export declare function getCompatibility(): AgoraRTCCompatibility;
1048
1071
 
@@ -1317,7 +1340,6 @@ export declare interface ILocalAudioTrack extends ILocalTrack {
1317
1340
  *
1318
1341
  * > Note:
1319
1342
  * > - As of v4.7.0, this method no longer takes effect. Use [IRemoteAudioTrack.setPlaybackDevice]{@link IRemoteAudioTrack.setPlaybackDevice} instead.
1320
- * > - This method supports Chrome on desktop devices only. Other browsers throw a '`NOT_SUPPORTED` error when calling this method.
1321
1343
  *
1322
1344
  * Sets the playback device (speaker) for the remote audio stream.
1323
1345
  *
@@ -1330,6 +1352,8 @@ export declare interface ILocalAudioTrack extends ILocalTrack {
1330
1352
  * **DEPRECATED** from v4.1.0. Use [AgoraRTCClient.getLocalVideoStats]{@link IAgoraRTCClient.getLocalVideoStats} and [AgoraRTCClient.getLocalAudioStats]{@link IAgoraRTCClient.getLocalAudioStats} instead.
1331
1353
  */
1332
1354
  getStats(): LocalAudioTrackStats;
1355
+ selectChannels(channels: number[], mode: AudioRenderMode): void;
1356
+ getVolumeLevels(channels?: number[]): number[];
1333
1357
  /**
1334
1358
  * Inserts a `Processor` to the local audio track.
1335
1359
  *
@@ -1424,7 +1448,7 @@ export declare interface ILocalTrack extends ITrack {
1424
1448
  *
1425
1449
  * 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.
1426
1450
  *
1427
- * > - 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%20Broadcast/faq/differences_between_setenabled_and_setmuted).
1451
+ * > - 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).
1428
1452
  * > - Do not call `setEnabled` and `setMuted` together.
1429
1453
  *
1430
1454
  * @param muted Whether to stop sending the media data of the track:
@@ -1469,7 +1493,7 @@ export declare interface ILocalVideoTrack extends ILocalTrack {
1469
1493
  */
1470
1494
  on(event: "transceiver-updated", listener: typeof event_transceiver_updated): void;
1471
1495
  /**
1472
- * Plays a local video track on the web page.
1496
+ * Plays a remote video track on the web page.
1473
1497
  *
1474
1498
  * @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:
1475
1499
  * - `string`: Specify the ID of the DOM element.
@@ -1636,6 +1660,12 @@ export declare interface ILocalVideoTrack extends ILocalTrack {
1636
1660
  * @param config The video encoder configurations. You can pass either [[VideoEncoderConfigurationPreset]] or a customized [[VideoEncoderConfiguration]] object.
1637
1661
  */
1638
1662
  setEncoderConfiguration(config: VideoEncoderConfiguration | VideoEncoderConfigurationPreset): Promise<void>;
1663
+ /**
1664
+ * Add the SEI data to the H.264 video stream.
1665
+ *
1666
+ * @param config SEI data.
1667
+ */
1668
+ sendSeiData(sei: Uint8Array): void;
1639
1669
  }
1640
1670
 
1641
1671
  export declare interface ImageTypedData {
@@ -1677,6 +1707,18 @@ export declare interface IMicrophoneAudioTrack extends ILocalAudioTrack {
1677
1707
  setEnabled(enabled: boolean): Promise<void>;
1678
1708
  }
1679
1709
 
1710
+ export declare function interceptLocalAudioFrame(sender: RTCRtpSender): Promise<void>;
1711
+
1712
+ export declare function interceptLocalVideoFrame(sender: RTCRtpSender, localVideoTrack: LocalVideoTrack): Promise<void>;
1713
+
1714
+ export declare function interceptRemoteAudioFrame(receiver: RTCRtpReceiver): Promise<void>;
1715
+
1716
+ export declare function interceptRemoteVideoFrame(receiver: RTCRtpReceiver, options?: InterceptVideoFrameOptions): Promise<void>;
1717
+
1718
+ declare interface InterceptVideoFrameOptions {
1719
+ onSei?: (sei: Uint8Array) => void;
1720
+ }
1721
+
1680
1722
  /**
1681
1723
  * `RemoteAudioTrack` is the basic interface for the remote audio track.
1682
1724
  *
@@ -1701,7 +1743,7 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
1701
1743
  *
1702
1744
  * Sets the audio playback device, for example, the speaker.
1703
1745
  *
1704
- * > This method supports Chrome on desktop devices only. Other browsers throw a `NOT_SUPPORTED` error when calling this method.
1746
+ * > This method supports Chrome and Edge on desktop devices only. Other browsers throw a `NOT_SUPPORTED` error when calling this method.
1705
1747
  * @param deviceId Device ID, which can be retrieved by calling [[getPlaybackDevices]].
1706
1748
  */
1707
1749
  setPlaybackDevice(deviceId: string): Promise<void>;
@@ -1743,6 +1785,8 @@ export declare interface IRemoteAudioTrack extends IRemoteTrack {
1743
1785
  * Usually a user with audio level above 0.6 is a speaking user.
1744
1786
  */
1745
1787
  getVolumeLevel(): number;
1788
+ selectChannels(channels: number[], mode: AudioRenderMode): void;
1789
+ getVolumeLevels(channels?: number[]): number[];
1746
1790
  /**
1747
1791
  * **Since**
1748
1792
  * <br>&emsp;&emsp;&emsp;*4.13.0*
@@ -1820,6 +1864,11 @@ export declare interface IRemoteTrack extends ITrack {
1820
1864
  * You can get create a remote video track by the [AgoraRTCRemoteUser.videoTrack]{@link IAgoraRTCRemoteUser.videoTrack} object after calling [subscribe]{@link IAgoraRTCClient.subscribe}.
1821
1865
  */
1822
1866
  export declare interface IRemoteVideoTrack extends IRemoteTrack {
1867
+ /**
1868
+ * @param event The event name.
1869
+ * @param listener See [video-state-changed]{@link event_video_state_changed}.
1870
+ */
1871
+ on(event: "video-state-changed", listener: typeof event_video_state_changed): void;
1823
1872
  /**
1824
1873
  * @param event The event name.
1825
1874
  * @param listener See [first-frame-decoded]{@link event_first_frame_decoded}.
@@ -1836,6 +1885,12 @@ export declare interface IRemoteVideoTrack extends IRemoteTrack {
1836
1885
  * @param listener See [IRemoteTrack.transceiver-updated]{@link event_transceiver_updated_2}.
1837
1886
  */
1838
1887
  on(event: "transceiver-updated", listener: typeof event_transceiver_updated_2): void;
1888
+ /**
1889
+ * Adds an event listener.
1890
+ * @param event The event name.
1891
+ * @param listener See [ILocalTrack.sei-received]{@link event_sei_received}.
1892
+ */
1893
+ on(event: "sei-received", listener: typeof event_sei_received): void;
1839
1894
  /**
1840
1895
  * Gets the statistics of a remote video track.
1841
1896
  *
@@ -1975,23 +2030,25 @@ export declare class LocalAudioTrack extends LocalTrack implements ILocalAudioTr
1975
2030
  readonly trackMediaType: "audio" | "video";
1976
2031
  _encoderConfig?: AudioEncoderConfiguration;
1977
2032
  _trackSource: AudioTrackSource | FakeTrackSource;
1978
- get _source(): AudioTrackSource | FakeTrackSource;
2033
+ channelCount?: number;
2034
+ private transformer?;
2035
+ get _source(): AudioTrackSource;
1979
2036
  set _source(source: AudioTrackSource | FakeTrackSource);
1980
2037
  _enabled: boolean;
1981
2038
  private _volume;
1982
2039
  _useAudioElement: boolean;
1983
2040
  _bypassWebAudio: boolean;
1984
2041
  protected processor?: IAudioProcessor;
1985
- protected _processorContext: AudioProcessorContext;
2042
+ protected _processorContext: AudioProcessorContext | undefined;
1986
2043
  protected get processorContext(): AudioProcessorContext;
1987
- protected set processorContext(ctx: AudioProcessorContext);
1988
- _processorDestination: AudioProcessorDestination;
2044
+ _processorDestination: AudioProcessorDestination | undefined;
1989
2045
  get processorDestination(): AudioProcessorDestination;
1990
- set processorDestination(des: AudioProcessorDestination);
1991
2046
  protected _getOriginVolumeLevel: boolean;
1992
2047
  get isPlaying(): boolean;
1993
2048
  get __className__(): string;
1994
- constructor(track: MediaStreamTrack, encoderConfig?: AudioEncoderConfiguration, trackId?: string, getOriginVolumeLevel?: boolean, deferWebAudio?: boolean);
2049
+ constructor(track: MediaStreamTrack, encoderConfig?: AudioEncoderConfiguration, trackId?: string, getOriginVolumeLevel?: boolean, channelCount?: number);
2050
+ selectChannels(channels: number[], mode?: AudioRenderMode): void;
2051
+ getVolumeLevels(channels?: number[]): number[];
1995
2052
  setVolume(volume: number): void;
1996
2053
  getVolumeLevel(): number;
1997
2054
  setPlaybackDevice(deviceId: string): Promise<void>;
@@ -2010,7 +2067,10 @@ export declare class LocalAudioTrack extends LocalTrack implements ILocalAudioTr
2010
2067
  unpipe(): void;
2011
2068
  private bindProcessorDestinationEvents;
2012
2069
  private unbindProcessorDestinationEvents;
2013
- private unbindProcessorContextEvents;
2070
+ protected bindProcessorContextEvents(processorContext: AudioProcessorContext): void;
2071
+ protected unbindProcessorContextEvents(processorContext: AudioProcessorContext): void;
2072
+ private initWebAudio;
2073
+ private initProcessor;
2014
2074
  }
2015
2075
 
2016
2076
  /**
@@ -2083,9 +2143,9 @@ export declare abstract class LocalTrack extends Track implements ILocalTrack {
2083
2143
  _isClosed: boolean;
2084
2144
  protected _enabledMutex: PromiseMutex;
2085
2145
  protected processor?: IBaseProcessor;
2086
- protected abstract _processorContext: IProcessorContext;
2087
- protected get processorContext(): IProcessorContext;
2088
- protected set processorContext(ctx: IProcessorContext);
2146
+ protected abstract _processorContext: IProcessorContext | undefined;
2147
+ protected get processorContext(): IProcessorContext | undefined;
2148
+ abstract processorDestination: IBaseProcessor;
2089
2149
  constructor(track: MediaStreamTrack, trackId?: string);
2090
2150
  abstract getStats(): LocalVideoTrackStats | LocalAudioTrackStats;
2091
2151
  abstract setMuted(enabled: boolean): Promise<void>;
@@ -2164,6 +2224,7 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
2164
2224
  clone(config?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, cloneTrack?: boolean): LocalVideoTrack;
2165
2225
  replaceTrack(track: MediaStreamTrack, stopOldTrack: boolean): Promise<void>;
2166
2226
  startMonitorStats(): void;
2227
+ sendSeiData(sei: Uint8Array): never;
2167
2228
  private bindProcessorDestinationEvents;
2168
2229
  private unbindProcessorDestinationEvents;
2169
2230
  private unbindProcessorContextEvents;
@@ -2334,7 +2395,8 @@ export declare class MicrophoneAudioTrack extends LocalAudioTrack implements IMi
2334
2395
  close(): void;
2335
2396
  protected onTrackEnded(): void;
2336
2397
  renewMediaStreamTrack(newConstraints?: MediaTrackConstraints): Promise<void>;
2337
- private bindProcessorContextEvents;
2398
+ protected bindProcessorContextEvents(processorContext: AudioProcessorContext): void;
2399
+ protected unbindProcessorContextEvents(processorContext: AudioProcessorContext): void;
2338
2400
  }
2339
2401
 
2340
2402
  /**
@@ -2427,15 +2489,19 @@ export declare class RemoteAudioTrack extends RemoteTrack implements IRemoteAudi
2427
2489
  readonly trackMediaType: "audio" | "video";
2428
2490
  _source: AudioTrackSource | FakeTrackSource;
2429
2491
  _useAudioElement: boolean;
2492
+ channelCount?: number;
2430
2493
  private _volume;
2431
2494
  protected processorContext: AudioProcessorContext;
2432
2495
  processorDestination: AudioProcessorDestination;
2433
2496
  private _played;
2434
2497
  private _bypassWebAudio;
2498
+ private transformer?;
2435
2499
  get isPlaying(): boolean;
2436
2500
  get __className__(): string;
2437
- constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore);
2501
+ constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore, channelCount?: number);
2438
2502
  setAudioFrameCallback(callback: null | ((buffer: AudioBuffer) => void), frameSize?: number): void;
2503
+ selectChannels(channels: number[], mode?: AudioRenderMode): void;
2504
+ getVolumeLevels(channels?: number[]): number[];
2439
2505
  setVolume(volume: number): void;
2440
2506
  setPlaybackDevice(deviceId: string): Promise<void>;
2441
2507
  getVolumeLevel(): number;
@@ -2593,7 +2659,8 @@ export declare abstract class RemoteTrack extends Track implements IRemoteTrack
2593
2659
 
2594
2660
  export declare enum RemoteTrackEvents {
2595
2661
  FIRST_FRAME_DECODED = "first-frame-decoded",
2596
- VIDEO_ELEMENT_VISIBLE_STATUS = "video-element-visible-status"
2662
+ VIDEO_ELEMENT_VISIBLE_STATUS = "video-element-visible-status",
2663
+ VIDEO_STATE_CHANGED = "video-state-changed"
2597
2664
  }
2598
2665
 
2599
2666
  export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVideoTrack {
@@ -2621,6 +2688,7 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
2621
2688
  private bindProcessorDestinationEvents;
2622
2689
  private unbindProcessorDestinationEvents;
2623
2690
  _destroy(): void;
2691
+ _onSei(sei: Uint8Array): void;
2624
2692
  }
2625
2693
 
2626
2694
  /**
@@ -2998,7 +3066,9 @@ export declare abstract class Track extends EventEmitter implements ITrack {
2998
3066
  }
2999
3067
 
3000
3068
  export declare enum TrackEvents {
3001
- TRANSCEIVER_UPDATED = "transceiver-updated"
3069
+ TRANSCEIVER_UPDATED = "transceiver-updated",
3070
+ SEI_TO_SEND = "sei-to-send",
3071
+ SEI_RECEIVED = "sei-received"
3002
3072
  }
3003
3073
 
3004
3074
  export declare enum TrackHint {
@@ -3010,6 +3080,7 @@ export declare enum TrackHint {
3010
3080
  export declare enum TrackInternalEvent {
3011
3081
  NEED_RENEGOTIATE = "@need_renegotiate",
3012
3082
  NEED_REPLACE_TRACK = "@need_replace_track",
3083
+ NEED_REPLACE_MIXING_TRACK = "@need_replace_mixing_track",
3013
3084
  NEED_CLOSE = "@need_close",
3014
3085
  NEED_ENABLE_TRACK = "@need_enable_track",
3015
3086
  NEED_DISABLE_TRACK = "@need_disable_track",
@@ -3141,6 +3212,7 @@ declare class VideoPlayer {
3141
3212
  trackId: string;
3142
3213
  config: PlayerConfig;
3143
3214
  onFirstVideoFrameDecoded?: () => void;
3215
+ onVideoStateChanged?: (state: VideoState) => void;
3144
3216
  freezeTimeCounterList: number[];
3145
3217
  renderFreezeAccTime: number;
3146
3218
  isKeepLastFrame: boolean;
@@ -3154,7 +3226,11 @@ declare class VideoPlayer {
3154
3226
  protected cacheVideoElement?: HTMLVideoElement;
3155
3227
  get videoElementStatus(): MediaElementStatus;
3156
3228
  set videoElementStatus(status: MediaElementStatus);
3229
+ get videoState(): VideoState;
3230
+ set videoState(state: VideoState);
3231
+ private _videoState;
3157
3232
  private videoElementCheckInterval?;
3233
+ private videoElementFreezeTimeout?;
3158
3234
  private _videoElementStatus;
3159
3235
  private isGettingVideoDimensions;
3160
3236
  constructor(config: PlayerConfig);
@@ -3245,6 +3321,28 @@ export declare class VideoProcessorDestination extends EventEmitter implements I
3245
3321
  reset(): void;
3246
3322
  }
3247
3323
 
3324
+ /**
3325
+ * The state of the video stream.
3326
+ */
3327
+ export declare enum VideoState {
3328
+ /**
3329
+ * 0: The initial state of the video.
3330
+ */
3331
+ VideoStateStopped = 0,
3332
+ /**
3333
+ * 1: The local user has received the first video packet.
3334
+ */
3335
+ VideoStateStarting = 1,
3336
+ /**
3337
+ * 2: The video stream is being decoded and played normally.
3338
+ */
3339
+ VideoStateDecoding = 2,
3340
+ /**
3341
+ * 3: The video stream is frozen.
3342
+ */
3343
+ VideoStateFrozen = 3
3344
+ }
3345
+
3248
3346
  declare class VisibilityWatcher extends EventEmitter {
3249
3347
  private _lastHiddenTime;
3250
3348
  private _lastVisibleTime;