@agora-js/media 4.24.2 → 4.24.3-300

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
@@ -1146,6 +1146,41 @@ export declare interface CustomVideoTrackInitConfig {
1146
1146
  * The maximum bitrate of sending the video track (Kbps).
1147
1147
  */
1148
1148
  bitrateMax?: number;
1149
+ /**
1150
+ * @自从
1151
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
1152
+ *
1153
+ * 本地视频发送镜像模式。默认值为 `VIDEO_MIRROR_MODE_DISABLED`。
1154
+ *
1155
+ * > 该参数只作用于上行:开启后,publish 发送的是 Canvas 生成的镜像轨道。
1156
+ * > {@link ILocalVideoTrack.getMediaStreamTrack} 和本地 `play` 预览仍是你传入的
1157
+ * > `mediaStreamTrack`(或 processor 的输出),不受该参数影响;预览方向完全由 `play` 的
1158
+ * > `mirror` 决定。
1159
+ * >
1160
+ * > 自定义视频轨道没有 `encoderConfig` 嵌套,该参数与 `width`、`bitrateMax` 等一样直接
1161
+ * > 平铺在本配置对象上。创建后如需切换,调用
1162
+ * > {@link ILocalVideoTrack.setEncoderConfiguration}——它是整体替换语义,仅切换镜像时
1163
+ * > 请携带当前完整编码配置一起传入。
1164
+ */
1165
+ /** @en
1166
+ * @since
1167
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
1168
+ *
1169
+ * The uplink mirror mode for the local video track. The default value is
1170
+ * `VIDEO_MIRROR_MODE_DISABLED`.
1171
+ *
1172
+ * > This option affects the sent video only: when enabled, publish sends the
1173
+ * > Canvas-mirrored track. {@link ILocalVideoTrack.getMediaStreamTrack} and local
1174
+ * > `play` stay on the `mediaStreamTrack` you passed in (or the processor output);
1175
+ * > the preview orientation is determined solely by `mirror` in `play`.
1176
+ * >
1177
+ * > A custom video track has no nested `encoderConfig`, so this option sits directly
1178
+ * > on this configuration object alongside `width` and `bitrateMax`. To toggle it
1179
+ * > after creation, call {@link ILocalVideoTrack.setEncoderConfiguration}, which
1180
+ * > replaces the whole configuration: pass your current encoder configuration along
1181
+ * > with it when you only want to switch mirroring.
1182
+ */
1183
+ mirrorMode?: VideoMirrorModeType;
1149
1184
  /**
1150
1185
  * @自从
1151
1186
  * <br>&emsp;&emsp;&emsp;*4.2.0*
@@ -1294,6 +1329,8 @@ export declare function detectSupportPreSub(store?: SDKStore): boolean;
1294
1329
 
1295
1330
  export declare function detectSupportRestrictOwnAudio(): boolean;
1296
1331
 
1332
+ export declare function detectSupportSDPEndpoint(): boolean;
1333
+
1297
1334
  export declare function detectSupportSuppressLocalAudioPlayback(): boolean;
1298
1335
 
1299
1336
  /**
@@ -1758,6 +1795,13 @@ export declare function getElectronScreenStreamByUserSelect(config: ScreenConstr
1758
1795
 
1759
1796
  export declare function getLocalStream(config: GetUserMediaConfig, id: string): Promise<MediaStream>;
1760
1797
 
1798
+ /**
1799
+ * 送流点唯一的分叉:未开 mirror 时原样 `_mediaStreamTrack`;仅开启时返回 publish Canvas 轨。
1800
+ * packages/main 所有把轨道交给 RTCPeerConnection(addTransceiver/addTrack/replaceTrack)、
1801
+ * 按轨道认领 sender、以及派生小流的读取点都必须经由本函数,禁止直读 `_mediaStreamTrack`。
1802
+ */
1803
+ export declare function getMediaStreamTrackForSender(track: LocalTrack): MediaStreamTrack;
1804
+
1761
1805
  /**
1762
1806
  * 获取新的视频码率
1763
1807
  * @param width
@@ -3755,6 +3799,27 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
3755
3799
  private _clearPreviousVideoVisibleStatus;
3756
3800
  _encoderConfig?: Partial<VideoEncoderConfiguration>;
3757
3801
  _scalabilityMode?: SVCConfiguration;
3802
+ /** 发送镜像开关;不碰 `_mediaStreamTrack` 的语义,主工作轨始终是采集/processor 输出。 */
3803
+ protected _videoMirrorMode: VideoMirrorModeType;
3804
+ /** 仅镜像开启时存在的发布腿:输入 = 主工作轨,输出 = publish 专用 Canvas 轨。 */
3805
+ private _uplinkMirror?;
3806
+ /**
3807
+ * 这条 track 建不出发布腿(环境不支持、canvas context 耗尽等),置位后本轨不再重试。
3808
+ * 作用域是 track 生命周期:失败几乎都是环境能力,一次会话内不会自愈,要恢复只能重建 track。
3809
+ */
3810
+ private _uplinkMirrorUnavailable;
3811
+ /** 是否开启发送镜像(main 的送流点仅在 true 时改读 publish 轨)。 */
3812
+ _isUplinkMirrorEnabled(): boolean;
3813
+ /**
3814
+ * 发送用轨。仅当 `_isUplinkMirrorEnabled()` 时由发布路径调用;惰性创建 Canvas 管线。
3815
+ * 管线建不起来时回落成主工作轨:镜像只影响观感,不该让 publish 整个失败。
3816
+ */
3817
+ _getPublishTrack(): MediaStreamTrack;
3818
+ /**
3819
+ * 主工作轨变更(基类 TRACK_UPDATED:切设备 / processor 换轨 / 静态帧)时只更新镜像输入,
3820
+ * 已挂到 sender 上的 publish 轨身份不变。
3821
+ */
3822
+ private _onWorkingTrackUpdated;
3758
3823
  _optimizationMode?: OptimizationMode;
3759
3824
  _saveEncodeBitrateRatio: number;
3760
3825
  private _videoHeight?;
@@ -3774,6 +3839,25 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
3774
3839
  protected set processorContext(ctx: VideoProcessorContext);
3775
3840
  get __className__(): string;
3776
3841
  constructor(track: MediaStreamTrack, encoderConfig?: Partial<VideoEncoderConfiguration>, scalabilityConfig?: SVCConfiguration, optimizationMode?: OptimizationMode, trackId?: string, hints?: TrackHint[]);
3842
+ /**
3843
+ * 惰性创建发布腿;输入永远是当前主工作轨。
3844
+ * 建不起来(UplinkMirror 构造期的能力探测失败、captureStream 异常等)时不抛给上层:
3845
+ * 送流点有二十多处读取,抛出去会让 publish 整体失败,而镜像只影响观感,回落发主工作轨更合理。
3846
+ * 失败后置位不再重试——能力类失败在一次会话里不会自愈,重试只会重复建 DOM 并刷日志。
3847
+ */
3848
+ private _ensureUplinkMirror;
3849
+ /**
3850
+ * 只更新镜像管线状态,不发 NEED_REPLACE(换轨由 setEncoderConfiguration 统一收口发一次)。
3851
+ * @returns 送流轨是否真的换了(而不是 mode 是否变了)
3852
+ */
3853
+ protected _setVideoMirrorMode(mode: VideoMirrorModeType): boolean;
3854
+ /** sender 已切回主工作轨后,拆掉发布腿。 */
3855
+ protected _disposeUplinkMirrorIfDisabled(): void;
3856
+ /**
3857
+ * 送流轨确实换了时才发一次 NEED_REPLACE;成功后再拆 DISABLE 留下的管线。
3858
+ * 失败语义与 replaceTrack()、切设备一致:回退本地模式并抛出,不补偿 sender。
3859
+ */
3860
+ protected _replaceSenderIfMirrorSwitched(switched: boolean, previousMode: VideoMirrorModeType): Promise<void>;
3777
3861
  play(element: HTMLElement | HTMLVideoElement | string, config?: VideoPlayerConfig): void;
3778
3862
  stop(): void;
3779
3863
  setEnabled(enabled: boolean, skipChangeState?: boolean): Promise<void>;
@@ -4395,6 +4479,7 @@ export declare interface RemoteAudioTrackStats {
4395
4479
  export declare class RemoteDataChannel extends DataChannel implements IRemoteDataChannel {
4396
4480
  private _messageListener;
4397
4481
  constructor(config: IDataChannelConfig);
4482
+ _updateDataChannelConfig(config: IDataChannelConfig): void;
4398
4483
  _updateOriginDataChannel(datachannel: RTCDataChannel): void;
4399
4484
  _close(): void;
4400
4485
  private _bandRemoteDataChannelEvents;
@@ -4507,7 +4592,7 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
4507
4592
  protected processorContext: VideoProcessorContext;
4508
4593
  get isPlaying(): boolean;
4509
4594
  get __className__(): string;
4510
- constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore, player?: AgoraRTCPlayer);
4595
+ constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore, player?: AgoraRTCPlayer | VideoPlayer);
4511
4596
  getStats(): RemoteVideoTrackStats;
4512
4597
  play(element: string | HTMLElement | HTMLVideoElement, config?: VideoPlayerConfig): void;
4513
4598
  stop(isKeepLastFrame?: boolean): void;
@@ -5506,6 +5591,36 @@ export declare interface VideoEncoderConfiguration {
5506
5591
  * @ignore
5507
5592
  */
5508
5593
  scaleResolutionDownBy?: number;
5594
+ /**
5595
+ * @自从
5596
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
5597
+ *
5598
+ * 本地视频发送镜像模式。默认值为 `VIDEO_MIRROR_MODE_DISABLED`。
5599
+ *
5600
+ * > 该参数只作用于上行:开启后,publish 发送的是 Canvas 生成的镜像轨道。
5601
+ * > {@link ILocalVideoTrack.getMediaStreamTrack} 和本地 `play` 预览仍是采集或
5602
+ * > processor 的输出,不受该参数影响;预览方向完全由 `play` 的 `mirror` 决定。
5603
+ * >
5604
+ * > `setEncoderConfiguration` 是整体替换语义:只传 `{ mirrorMode }` 会把其余编码
5605
+ * > 字段重置为默认值。仅切换镜像时,请携带当前完整编码配置一起传入。
5606
+ */
5607
+ /** @en
5608
+ * @since
5609
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
5610
+ *
5611
+ * The uplink mirror mode for the local video track. The default value is
5612
+ * `VIDEO_MIRROR_MODE_DISABLED`.
5613
+ *
5614
+ * > This option affects the sent video only: when enabled, publish sends the
5615
+ * > Canvas-mirrored track. {@link ILocalVideoTrack.getMediaStreamTrack} and local
5616
+ * > `play` stay on the capture or processor output; the preview orientation is
5617
+ * > determined solely by `mirror` in `play`.
5618
+ * >
5619
+ * > `setEncoderConfiguration` replaces the whole configuration: passing
5620
+ * > `{ mirrorMode }` alone resets the other encoding fields to their defaults.
5621
+ * > To toggle mirroring only, pass your current encoder configuration along with it.
5622
+ */
5623
+ mirrorMode?: VideoMirrorModeType;
5509
5624
  }
5510
5625
 
5511
5626
  /**
@@ -5574,10 +5689,41 @@ export declare interface VideoEncoderConfiguration {
5574
5689
  */
5575
5690
  export declare type VideoEncoderConfigurationPreset = keyof typeof SUPPORT_VIDEO_ENCODER_CONFIG_LIST;
5576
5691
 
5692
+ /**
5693
+ * @自从
5694
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
5695
+ *
5696
+ * 本地视频轨道发送镜像模式。
5697
+ *
5698
+ * @public
5699
+ */
5700
+ /** @en
5701
+ * @since
5702
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
5703
+ *
5704
+ * The uplink mirror mode for a local video track.
5705
+ */
5706
+ export declare enum VideoMirrorModeType {
5707
+ /**
5708
+ * 开启本地视频轨道镜像。
5709
+ */
5710
+ /** @en
5711
+ * Enables mirroring for the local video track.
5712
+ */
5713
+ VIDEO_MIRROR_MODE_ENABLED = "enabled",
5714
+ /**
5715
+ * 关闭本地视频轨道镜像。
5716
+ */
5717
+ /** @en
5718
+ * Disables mirroring for the local video track.
5719
+ */
5720
+ VIDEO_MIRROR_MODE_DISABLED = "disabled"
5721
+ }
5722
+
5577
5723
  /**
5578
5724
  * @internal
5579
5725
  */
5580
- declare class VideoPlayer {
5726
+ export declare class VideoPlayer {
5581
5727
  trackId: string;
5582
5728
  config: PlayerConfig;
5583
5729
  onFirstVideoFrameDecoded?: () => void;
@@ -5587,6 +5733,7 @@ declare class VideoPlayer {
5587
5733
  freezeTimeCounterList: number[];
5588
5734
  renderFreezeAccTime: number;
5589
5735
  renderFreezeAccTime2: number;
5736
+ totalFreezeTime: number;
5590
5737
  isKeepLastFrame: boolean;
5591
5738
  isDestroyed: boolean;
5592
5739
  /** 计算 500ms 卡顿时间用 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agora-js/media",
3
- "version": "4.24.2",
3
+ "version": "4.24.3-300",
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,9 +23,9 @@
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.24.2",
27
- "@agora-js/report": "4.24.2",
28
- "axios": "^1.13.2",
26
+ "@agora-js/shared": "4.24.3-300",
27
+ "@agora-js/report": "4.24.3-300",
28
+ "axios": "^1.13.6",
29
29
  "agora-rte-extension": "^1.2.4",
30
30
  "webrtc-adapter": "8.2.0"
31
31
  }
@@ -740,6 +740,25 @@ export declare interface CustomVideoTrackInitConfig {
740
740
  * The maximum bitrate of sending the video track (Kbps).
741
741
  */
742
742
  bitrateMax?: number;
743
+ /**
744
+ * @since
745
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
746
+ *
747
+ * The uplink mirror mode for the local video track. The default value is
748
+ * `VIDEO_MIRROR_MODE_DISABLED`.
749
+ *
750
+ * > This option affects the sent video only: when enabled, publish sends the
751
+ * > Canvas-mirrored track. {@link ILocalVideoTrack.getMediaStreamTrack} and local
752
+ * > `play` stay on the `mediaStreamTrack` you passed in (or the processor output);
753
+ * > the preview orientation is determined solely by `mirror` in `play`.
754
+ * >
755
+ * > A custom video track has no nested `encoderConfig`, so this option sits directly
756
+ * > on this configuration object alongside `width` and `bitrateMax`. To toggle it
757
+ * > after creation, call {@link ILocalVideoTrack.setEncoderConfiguration}, which
758
+ * > replaces the whole configuration: pass your current encoder configuration along
759
+ * > with it when you only want to switch mirroring.
760
+ */
761
+ mirrorMode?: VideoMirrorModeType;
743
762
  /**
744
763
  * @since
745
764
  * <br>&emsp;&emsp;&emsp;*4.2.0*
@@ -845,6 +864,8 @@ export declare function detectSupportPreSub(store?: SDKStore): boolean;
845
864
 
846
865
  export declare function detectSupportRestrictOwnAudio(): boolean;
847
866
 
867
+ export declare function detectSupportSDPEndpoint(): boolean;
868
+
848
869
  export declare function detectSupportSuppressLocalAudioPlayback(): boolean;
849
870
 
850
871
  /**
@@ -1152,6 +1173,8 @@ export declare function getElectronScreenStreamByUserSelect(config: ScreenConstr
1152
1173
 
1153
1174
  export declare function getLocalStream(config: GetUserMediaConfig, id: string): Promise<MediaStream>;
1154
1175
 
1176
+ export declare function getMediaStreamTrackForSender(track: LocalTrack): MediaStreamTrack;
1177
+
1155
1178
  export declare function getNewNearestVideoProfile(width: number, height: number, frameRate: number): any;
1156
1179
 
1157
1180
  export declare function getNewVideoBitrate(width: number, height: number, fps: number): [number, number];
@@ -2313,6 +2336,12 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
2313
2336
  private _clearPreviousVideoVisibleStatus;
2314
2337
  _encoderConfig?: Partial<VideoEncoderConfiguration>;
2315
2338
  _scalabilityMode?: SVCConfiguration;
2339
+ protected _videoMirrorMode: VideoMirrorModeType;
2340
+ private _uplinkMirror?;
2341
+ private _uplinkMirrorUnavailable;
2342
+ _isUplinkMirrorEnabled(): boolean;
2343
+ _getPublishTrack(): MediaStreamTrack;
2344
+ private _onWorkingTrackUpdated;
2316
2345
  _optimizationMode?: OptimizationMode;
2317
2346
  _saveEncodeBitrateRatio: number;
2318
2347
  private _videoHeight?;
@@ -2332,6 +2361,10 @@ export declare class LocalVideoTrack extends LocalTrack implements ILocalVideoTr
2332
2361
  protected set processorContext(ctx: VideoProcessorContext);
2333
2362
  get __className__(): string;
2334
2363
  constructor(track: MediaStreamTrack, encoderConfig?: Partial<VideoEncoderConfiguration>, scalabilityConfig?: SVCConfiguration, optimizationMode?: OptimizationMode, trackId?: string, hints?: TrackHint[]);
2364
+ private _ensureUplinkMirror;
2365
+ protected _setVideoMirrorMode(mode: VideoMirrorModeType): boolean;
2366
+ protected _disposeUplinkMirrorIfDisabled(): void;
2367
+ protected _replaceSenderIfMirrorSwitched(switched: boolean, previousMode: VideoMirrorModeType): Promise<void>;
2335
2368
  play(element: HTMLElement | HTMLVideoElement | string, config?: VideoPlayerConfig): void;
2336
2369
  stop(): void;
2337
2370
  setEnabled(enabled: boolean, skipChangeState?: boolean): Promise<void>;
@@ -2738,6 +2771,7 @@ export declare interface RemoteAudioTrackStats {
2738
2771
  export declare class RemoteDataChannel extends DataChannel implements IRemoteDataChannel {
2739
2772
  private _messageListener;
2740
2773
  constructor(config: IDataChannelConfig);
2774
+ _updateDataChannelConfig(config: IDataChannelConfig): void;
2741
2775
  _updateOriginDataChannel(datachannel: RTCDataChannel): void;
2742
2776
  _close(): void;
2743
2777
  private _bandRemoteDataChannelEvents;
@@ -2827,7 +2861,7 @@ export declare class RemoteVideoTrack extends RemoteTrack implements IRemoteVide
2827
2861
  protected processorContext: VideoProcessorContext;
2828
2862
  get isPlaying(): boolean;
2829
2863
  get __className__(): string;
2830
- constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore, player?: AgoraRTCPlayer);
2864
+ constructor(track: MediaStreamTrack, userId: UID, uintId: number, store: SDKStore, player?: AgoraRTCPlayer | VideoPlayer);
2831
2865
  getStats(): RemoteVideoTrackStats;
2832
2866
  play(element: string | HTMLElement | HTMLVideoElement, config?: VideoPlayerConfig): void;
2833
2867
  stop(isKeepLastFrame?: boolean): void;
@@ -3405,6 +3439,23 @@ export declare interface VideoEncoderConfiguration {
3405
3439
  * @ignore
3406
3440
  */
3407
3441
  scaleResolutionDownBy?: number;
3442
+ /**
3443
+ * @since
3444
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
3445
+ *
3446
+ * The uplink mirror mode for the local video track. The default value is
3447
+ * `VIDEO_MIRROR_MODE_DISABLED`.
3448
+ *
3449
+ * > This option affects the sent video only: when enabled, publish sends the
3450
+ * > Canvas-mirrored track. {@link ILocalVideoTrack.getMediaStreamTrack} and local
3451
+ * > `play` stay on the capture or processor output; the preview orientation is
3452
+ * > determined solely by `mirror` in `play`.
3453
+ * >
3454
+ * > `setEncoderConfiguration` replaces the whole configuration: passing
3455
+ * > `{ mirrorMode }` alone resets the other encoding fields to their defaults.
3456
+ * > To toggle mirroring only, pass your current encoder configuration along with it.
3457
+ */
3458
+ mirrorMode?: VideoMirrorModeType;
3408
3459
  }
3409
3460
 
3410
3461
  /**
@@ -3464,7 +3515,24 @@ export declare interface VideoEncoderConfiguration {
3464
3515
  */
3465
3516
  export declare type VideoEncoderConfigurationPreset = keyof typeof SUPPORT_VIDEO_ENCODER_CONFIG_LIST;
3466
3517
 
3467
- declare class VideoPlayer {
3518
+ /**
3519
+ * @since
3520
+ * <br>&emsp;&emsp;&emsp;*4.24.3-300*
3521
+ *
3522
+ * The uplink mirror mode for a local video track.
3523
+ */
3524
+ export declare enum VideoMirrorModeType {
3525
+ /**
3526
+ * Enables mirroring for the local video track.
3527
+ */
3528
+ VIDEO_MIRROR_MODE_ENABLED = "enabled",
3529
+ /**
3530
+ * Disables mirroring for the local video track.
3531
+ */
3532
+ VIDEO_MIRROR_MODE_DISABLED = "disabled"
3533
+ }
3534
+
3535
+ export declare class VideoPlayer {
3468
3536
  trackId: string;
3469
3537
  config: PlayerConfig;
3470
3538
  onFirstVideoFrameDecoded?: () => void;
@@ -3474,6 +3542,7 @@ declare class VideoPlayer {
3474
3542
  freezeTimeCounterList: number[];
3475
3543
  renderFreezeAccTime: number;
3476
3544
  renderFreezeAccTime2: number;
3545
+ totalFreezeTime: number;
3477
3546
  isKeepLastFrame: boolean;
3478
3547
  isDestroyed: boolean;
3479
3548
  private timeUpdatedCount;