@xmaxai/web-sdk 1.0.2 → 1.0.4
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/README.md +468 -0
- package/dist/{chunk-5NIEZJP5.cjs → chunk-FEL5MJMJ.cjs} +2060 -430
- package/dist/chunk-FEL5MJMJ.cjs.map +1 -0
- package/dist/{chunk-6RIEDVRQ.js → chunk-FMAQXPTE.js} +1964 -334
- package/dist/chunk-FMAQXPTE.js.map +1 -0
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -21
- package/dist/index.d.ts +74 -21
- package/dist/index.js +3 -1
- package/dist/react/index.cjs +3 -3
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +3 -1
- package/dist/chunk-5NIEZJP5.cjs.map +0 -1
- package/dist/chunk-6RIEDVRQ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var _chunk5NIEZJP5cjs = require('./chunk-5NIEZJP5.cjs');
|
|
30
29
|
|
|
30
|
+
var _chunkFEL5MJMJcjs = require('./chunk-FEL5MJMJ.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -55,5 +55,7 @@ var _chunk5NIEZJP5cjs = require('./chunk-5NIEZJP5.cjs');
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
exports.CameraPosition = _chunkFEL5MJMJcjs.CameraPosition; exports.MediaService = _chunkFEL5MJMJcjs.MediaService; exports.RealtimeConfiguration = _chunkFEL5MJMJcjs.RealtimeConfiguration; exports.RealtimeConnectionState = _chunkFEL5MJMJcjs.RealtimeConnectionState; exports.RealtimeContext = _chunkFEL5MJMJcjs.RealtimeContext; exports.RealtimeMediaStream = _chunkFEL5MJMJcjs.RealtimeMediaStream; exports.RealtimeModel = _chunkFEL5MJMJcjs.RealtimeModel; exports.RealtimeReason = _chunkFEL5MJMJcjs.RealtimeReason; exports.RealtimeState = _chunkFEL5MJMJcjs.RealtimeState; exports.RealtimeVideoEncoderPreference = _chunkFEL5MJMJcjs.RealtimeVideoEncoderPreference; exports.RealtimeVideoFormat = _chunkFEL5MJMJcjs.RealtimeVideoFormat; exports.RealtimeVideoTrack = _chunkFEL5MJMJcjs.RealtimeVideoTrack; exports.RtcProvider = _chunkFEL5MJMJcjs.RtcProvider; exports.StorageService = _chunkFEL5MJMJcjs.StorageService; exports.StoredFile = _chunkFEL5MJMJcjs.StoredFile; exports.VideoContentMode = _chunkFEL5MJMJcjs.VideoContentMode; exports.XmaxClient = _chunkFEL5MJMJcjs.XmaxClient; exports.XmaxConfiguration = _chunkFEL5MJMJcjs.XmaxConfiguration; exports.XmaxEnvironment = _chunkFEL5MJMJcjs.XmaxEnvironment; exports.XmaxError = _chunkFEL5MJMJcjs.XmaxError; exports.XmaxErrorCode = _chunkFEL5MJMJcjs.XmaxErrorCode; exports.XmaxLogger = _chunkFEL5MJMJcjs.XmaxLogger; exports.XmaxLoggerOption = _chunkFEL5MJMJcjs.XmaxLoggerOption; exports.XmaxRealtimeVideoView = _chunkFEL5MJMJcjs.XmaxRealtimeVideoView; exports.XmaxVideoView = _chunkFEL5MJMJcjs.XmaxVideoView; exports.apiBaseURL = _chunkFEL5MJMJcjs.apiBaseURL; exports.defaultCameraVideoFormat = _chunkFEL5MJMJcjs.defaultCameraVideoFormat; exports.defaultFrameRate = _chunkFEL5MJMJcjs.defaultFrameRate;
|
|
59
61
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/private/var/folders/5j/p3g3j18x2w3byrl5wtnk94tc0000gn/T/xmax-web-release-
|
|
1
|
+
{"version":3,"sources":["/private/var/folders/5j/p3g3j18x2w3byrl5wtnk94tc0000gn/T/xmax-web-release-sdawVu/source/packages/xmax-sdk/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2sDAAC","file":"/private/var/folders/5j/p3g3j18x2w3byrl5wtnk94tc0000gn/T/xmax-web-release-sdawVu/source/packages/xmax-sdk/dist/index.cjs"}
|
package/dist/index.d.cts
CHANGED
|
@@ -10,13 +10,15 @@ declare enum RealtimeModel {
|
|
|
10
10
|
*/
|
|
11
11
|
x2_0 = "x2.0",
|
|
12
12
|
/**
|
|
13
|
-
* Xmax X2.0
|
|
13
|
+
* Xmax X2.0 TRTC 实时生成模型。
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
x2_0_trtc = "x2.0-trtc",
|
|
16
16
|
/**
|
|
17
|
-
* Xmax X2.0
|
|
17
|
+
* Xmax X2.0 Agora 实时生成模型。
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
x2_0_agora = "x2.0-agora",
|
|
20
|
+
/** X2.1 预览模型;媒体规格与 x2.0-trtc 相同。 */
|
|
21
|
+
x2_1_preview = "x2.1-preview"
|
|
20
22
|
}
|
|
21
23
|
interface ModelSize {
|
|
22
24
|
width: number;
|
|
@@ -124,6 +126,22 @@ interface StorageServicing {
|
|
|
124
126
|
uploadImage(options: StorageUploadOptions): Promise<StoredFile>;
|
|
125
127
|
}
|
|
126
128
|
|
|
129
|
+
/**
|
|
130
|
+
* 实时媒体使用的 RTC 提供方;一个 Manager 生命周期内保持不变。
|
|
131
|
+
*/
|
|
132
|
+
declare enum RtcProvider {
|
|
133
|
+
/**
|
|
134
|
+
* 腾讯实时音视频。
|
|
135
|
+
*/
|
|
136
|
+
trtc = "trtc",
|
|
137
|
+
/**
|
|
138
|
+
* 声网实时音视频。
|
|
139
|
+
*/
|
|
140
|
+
agora = "agora",
|
|
141
|
+
/** 火山引擎实时音视频。 */
|
|
142
|
+
vertc = "vertc"
|
|
143
|
+
}
|
|
144
|
+
|
|
127
145
|
/**
|
|
128
146
|
* 远端视频插帧的开关与显示帧率配置。
|
|
129
147
|
*/
|
|
@@ -138,6 +156,10 @@ interface FrameInterpolationConfiguration {
|
|
|
138
156
|
targetFrameRate?: number;
|
|
139
157
|
}
|
|
140
158
|
interface RealtimeConfigurationInit {
|
|
159
|
+
/**
|
|
160
|
+
* RTC 提供方,默认 TRTC;不根据模型名称自动推断。
|
|
161
|
+
*/
|
|
162
|
+
provider?: RtcProvider;
|
|
141
163
|
/**
|
|
142
164
|
* 实时生成业务使用的模型。
|
|
143
165
|
*/
|
|
@@ -156,6 +178,10 @@ interface RealtimeConfigurationInit {
|
|
|
156
178
|
* 创建实时 Manager 所需的业务配置。
|
|
157
179
|
*/
|
|
158
180
|
declare class RealtimeConfiguration {
|
|
181
|
+
/**
|
|
182
|
+
* RTC 配置
|
|
183
|
+
*/
|
|
184
|
+
readonly provider: RtcProvider;
|
|
159
185
|
/**
|
|
160
186
|
* 模型配置
|
|
161
187
|
*/
|
|
@@ -178,6 +204,7 @@ declare class RealtimeConfiguration {
|
|
|
178
204
|
* 创建实时业务配置。
|
|
179
205
|
*
|
|
180
206
|
* @param init.model 实时生成业务使用的模型。
|
|
207
|
+
* @param init.provider RTC 提供方,默认 TRTC;创建后不可切换。
|
|
181
208
|
* @param init.isFrameInterpolationEnabled 是否默认开启远端生成画面的插帧。
|
|
182
209
|
* @param init.frameInterpolation 插帧开关和显示帧率上限的详细配置。
|
|
183
210
|
*/
|
|
@@ -185,7 +212,7 @@ declare class RealtimeConfiguration {
|
|
|
185
212
|
}
|
|
186
213
|
|
|
187
214
|
/**
|
|
188
|
-
*
|
|
215
|
+
* RTC 网络质量等级:未知、极好、良好、一般、差、极差、断网。
|
|
189
216
|
*/
|
|
190
217
|
type NetworkQualityLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
191
218
|
/**
|
|
@@ -198,11 +225,11 @@ interface NetworkStatistics {
|
|
|
198
225
|
*/
|
|
199
226
|
readonly downlinkQuality?: NetworkQualityLevel;
|
|
200
227
|
/**
|
|
201
|
-
* 上行连接到
|
|
228
|
+
* 上行连接到 RTC 云端的往返延迟,单位 ms,不是单程延迟;Agora 未提供时为空。
|
|
202
229
|
*/
|
|
203
230
|
readonly uplinkRttMs?: number;
|
|
204
231
|
/**
|
|
205
|
-
* 所有下行连接到
|
|
232
|
+
* 所有下行连接到 RTC 云端的平均往返延迟,单位 ms;Agora 未提供时为空。
|
|
206
233
|
*/
|
|
207
234
|
readonly downlinkRttMs?: number;
|
|
208
235
|
}
|
|
@@ -314,7 +341,7 @@ declare enum XmaxErrorCode {
|
|
|
314
341
|
*/
|
|
315
342
|
cameraPermissionDenied = "CAMERA_PERMISSION_DENIED",
|
|
316
343
|
/**
|
|
317
|
-
* @deprecated
|
|
344
|
+
* @deprecated 为兼容保留;相机预热改为固定等待,不再抛出此错误。
|
|
318
345
|
*/
|
|
319
346
|
cameraExposureTimeout = "CAMERA_EXPOSURE_TIMEOUT",
|
|
320
347
|
/**
|
|
@@ -504,13 +531,18 @@ interface RealtimeLaunchTiming {
|
|
|
504
531
|
*/
|
|
505
532
|
readonly cameraMs?: number;
|
|
506
533
|
/**
|
|
507
|
-
*
|
|
534
|
+
* 确认相机与麦克风权限可用的耗时;系统弹窗时统计到用户完成授权。
|
|
535
|
+
* 权限被拒绝或浏览器不支持观察时不记录。
|
|
536
|
+
*/
|
|
537
|
+
readonly permissionMs?: number;
|
|
538
|
+
/**
|
|
539
|
+
* 开始创建会话到 RTC 进房配置与相机预热等待完成;不含发布本地流。
|
|
508
540
|
*/
|
|
509
541
|
readonly connectionMs?: number;
|
|
510
542
|
/**
|
|
511
|
-
*
|
|
543
|
+
* 发布本地流到 RTC 房间的耗时。
|
|
512
544
|
*/
|
|
513
|
-
readonly
|
|
545
|
+
readonly publishMs?: number;
|
|
514
546
|
/**
|
|
515
547
|
* 开始发送生成信令到 SDK 远端视图首次呈现视频帧。
|
|
516
548
|
*/
|
|
@@ -529,6 +561,10 @@ type RealtimeLaunchTimingListener = (timing: RealtimeLaunchTiming) => void;
|
|
|
529
561
|
* 视频流实际运行统计;缺失或无效指标为 undefined。
|
|
530
562
|
*/
|
|
531
563
|
interface VideoStatistics {
|
|
564
|
+
/**
|
|
565
|
+
* 本端视频上行丢包率,单位 %;厂商未提供时为空。
|
|
566
|
+
*/
|
|
567
|
+
readonly uplinkLossPercent?: number;
|
|
532
568
|
readonly width?: number;
|
|
533
569
|
readonly height?: number;
|
|
534
570
|
/**
|
|
@@ -550,23 +586,24 @@ type VideoStatisticsListener = (statistics: VideoStatistics | undefined) => void
|
|
|
550
586
|
interface RemoteVideoStatistics extends VideoStatistics {
|
|
551
587
|
readonly userID: string;
|
|
552
588
|
/**
|
|
553
|
-
* 本端 SDK 到
|
|
589
|
+
* 本端 SDK 到 RTC 云端的往返延迟,单位 ms;不是与远端用户之间的 RTT。
|
|
554
590
|
*/
|
|
555
591
|
readonly rttMs?: number;
|
|
556
592
|
/**
|
|
557
|
-
* 本端 SDK 到
|
|
593
|
+
* 本端 SDK 到 RTC 云端的上行丢包率,单位 %,不是结果流的发送端丢包率。
|
|
558
594
|
*/
|
|
559
595
|
readonly uplinkLossPercent?: number;
|
|
560
596
|
/**
|
|
561
|
-
*
|
|
597
|
+
* RTC 云端到本端 SDK 的下行丢包率,单位 %。
|
|
562
598
|
*/
|
|
563
599
|
readonly downlinkLossPercent?: number;
|
|
564
600
|
/**
|
|
565
|
-
* 当前远端视频流的播放缓冲延迟,单位 ms
|
|
601
|
+
* 当前远端视频流的播放缓冲延迟,单位 ms;Agora 未提供时为空。
|
|
566
602
|
*/
|
|
567
603
|
readonly jitterBufferDelayMs?: number;
|
|
568
604
|
/**
|
|
569
|
-
*
|
|
605
|
+
* RTC 媒体端到端延迟估算值,单位 ms;不代表完整 AI 处理链路耗时。
|
|
606
|
+
* 采用各厂商原生口径,Agora end2EndDelay 不包含编码与解码耗时。
|
|
570
607
|
*/
|
|
571
608
|
readonly endToEndDelayMs?: number;
|
|
572
609
|
}
|
|
@@ -656,10 +693,21 @@ interface XmaxRealtimeManaging {
|
|
|
656
693
|
position: CameraPosition;
|
|
657
694
|
useMicrophone: boolean;
|
|
658
695
|
/**
|
|
659
|
-
*
|
|
696
|
+
* 是否在发布前等待相机预热(固定 200ms),默认 true;false 跳过等待,不产生预热耗时。
|
|
660
697
|
*/
|
|
661
698
|
enableFrameValidation?: boolean;
|
|
662
699
|
}): Promise<RealtimeMediaStream>;
|
|
700
|
+
/**
|
|
701
|
+
* 更新当前本地流的上行视频格式,立即应用于 RTC 编码器,不重连或重启生成。
|
|
702
|
+
* 传入完整格式;未指定的码率和编码偏好按 RealtimeVideoFormat 默认规则解析。
|
|
703
|
+
* 成功后更新本地轨道的 videoFormat,后续重连继续使用该格式。
|
|
704
|
+
* 模型生成及远端插帧仍使用创建本地流时的格式;此接口不改变生成尺寸。
|
|
705
|
+
* 实际发送规格受设备、浏览器和网络影响,应通过统计回调确认。
|
|
706
|
+
*
|
|
707
|
+
* @param videoFormat 本次完整的上行尺寸、帧率和编码配置。
|
|
708
|
+
* @throws 无本地相机流、其他操作进行中、参数无效或 RTC 更新失败时抛错。
|
|
709
|
+
*/
|
|
710
|
+
updateVideoFormat(videoFormat: RealtimeVideoFormat): Promise<void>;
|
|
663
711
|
/**
|
|
664
712
|
* 停止本地相机流并释放本地预览与 RTC 资源。
|
|
665
713
|
*/
|
|
@@ -677,8 +725,7 @@ interface XmaxRealtimeManaging {
|
|
|
677
725
|
* 使用当前 Manager 创建的本地流建立实时连接。
|
|
678
726
|
*
|
|
679
727
|
* 创建实时会话、加入 RTC 房间并发布本地流,成功后启动会话心跳。
|
|
680
|
-
*
|
|
681
|
-
* 记录警告并按当前画面继续发布,不因环境较暗而阻断连接。
|
|
728
|
+
* 启用帧检测时,发布前并行等待相机预热(固定 200ms),避免把黑帧推给 RTC。
|
|
682
729
|
* 返回的远端媒体流在生成开始后承载远端生成画面。
|
|
683
730
|
*
|
|
684
731
|
* @param localStream 由 `createLocalCameraStream` 创建的本地媒体流。
|
|
@@ -889,6 +936,7 @@ declare class XmaxClient {
|
|
|
889
936
|
constructor(configuration: XmaxConfiguration);
|
|
890
937
|
/**
|
|
891
938
|
* 创建实时媒体 Manager。
|
|
939
|
+
* 模型专用地址优先于环境默认地址,并用于该 Manager 的整个会话生命周期。
|
|
892
940
|
*
|
|
893
941
|
* @param options 实时生成模型等业务配置。
|
|
894
942
|
* @returns 可用于本地相机预览、实时连接与生成的实时 Manager。
|
|
@@ -985,8 +1033,13 @@ interface ApiServicing {
|
|
|
985
1033
|
put<T>(path: string, body?: unknown): Promise<T>;
|
|
986
1034
|
/**
|
|
987
1035
|
* 发送 DELETE 请求。
|
|
1036
|
+
*
|
|
1037
|
+
* @param options.keepalive 为 true 时请求可存活于页面卸载之后,
|
|
1038
|
+
* 用于刷新或关闭页签时的清理请求。
|
|
988
1039
|
*/
|
|
989
|
-
delete<T>(path: string
|
|
1040
|
+
delete<T>(path: string, options?: {
|
|
1041
|
+
keepalive?: boolean;
|
|
1042
|
+
}): Promise<T>;
|
|
990
1043
|
}
|
|
991
1044
|
|
|
992
1045
|
/**
|
|
@@ -1347,4 +1400,4 @@ declare class XmaxRealtimeVideoView {
|
|
|
1347
1400
|
private showRemoteVideo;
|
|
1348
1401
|
}
|
|
1349
1402
|
|
|
1350
|
-
export { CameraPosition, type FrameInterpolationConfiguration, MediaService, type MediaServicing, type NetworkQualityLevel, type NetworkStatistics, type NetworkStatisticsListener, RealtimeConfiguration, type RealtimeConfigurationInit, RealtimeConnectionState, RealtimeContext, type RealtimeContextInit, type RealtimeLaunchTiming, type RealtimeLaunchTimingListener, RealtimeMediaStream, RealtimeModel, RealtimeReason, RealtimeState, type RealtimeStateListener, RealtimeVideoFormat, RealtimeVideoTrack, type RemoteVideoStatistics, type RemoteVideoStatisticsListener, StorageService, type StorageServicing, type StorageUploadOptions, StoredFile, VideoContentMode, type VideoStatistics, type VideoStatisticsListener, XmaxClient, XmaxConfiguration, type XmaxConfigurationInit, XmaxEnvironment, XmaxError, XmaxErrorCode, type XmaxErrorListener, XmaxLogger, XmaxLoggerOption, type XmaxRealtimeManaging, XmaxRealtimeVideoView, XmaxVideoView, apiBaseURL, defaultCameraVideoFormat, defaultFrameRate };
|
|
1403
|
+
export { CameraPosition, type FrameInterpolationConfiguration, MediaService, type MediaServicing, type NetworkQualityLevel, type NetworkStatistics, type NetworkStatisticsListener, RealtimeConfiguration, type RealtimeConfigurationInit, RealtimeConnectionState, RealtimeContext, type RealtimeContextInit, type RealtimeLaunchTiming, type RealtimeLaunchTimingListener, RealtimeMediaStream, RealtimeModel, RealtimeReason, RealtimeState, type RealtimeStateListener, RealtimeVideoFormat, RealtimeVideoTrack, type RemoteVideoStatistics, type RemoteVideoStatisticsListener, RtcProvider, StorageService, type StorageServicing, type StorageUploadOptions, StoredFile, VideoContentMode, type VideoStatistics, type VideoStatisticsListener, XmaxClient, XmaxConfiguration, type XmaxConfigurationInit, XmaxEnvironment, XmaxError, XmaxErrorCode, type XmaxErrorListener, XmaxLogger, XmaxLoggerOption, type XmaxRealtimeManaging, XmaxRealtimeVideoView, XmaxVideoView, apiBaseURL, defaultCameraVideoFormat, defaultFrameRate };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,13 +10,15 @@ declare enum RealtimeModel {
|
|
|
10
10
|
*/
|
|
11
11
|
x2_0 = "x2.0",
|
|
12
12
|
/**
|
|
13
|
-
* Xmax X2.0
|
|
13
|
+
* Xmax X2.0 TRTC 实时生成模型。
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
x2_0_trtc = "x2.0-trtc",
|
|
16
16
|
/**
|
|
17
|
-
* Xmax X2.0
|
|
17
|
+
* Xmax X2.0 Agora 实时生成模型。
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
x2_0_agora = "x2.0-agora",
|
|
20
|
+
/** X2.1 预览模型;媒体规格与 x2.0-trtc 相同。 */
|
|
21
|
+
x2_1_preview = "x2.1-preview"
|
|
20
22
|
}
|
|
21
23
|
interface ModelSize {
|
|
22
24
|
width: number;
|
|
@@ -124,6 +126,22 @@ interface StorageServicing {
|
|
|
124
126
|
uploadImage(options: StorageUploadOptions): Promise<StoredFile>;
|
|
125
127
|
}
|
|
126
128
|
|
|
129
|
+
/**
|
|
130
|
+
* 实时媒体使用的 RTC 提供方;一个 Manager 生命周期内保持不变。
|
|
131
|
+
*/
|
|
132
|
+
declare enum RtcProvider {
|
|
133
|
+
/**
|
|
134
|
+
* 腾讯实时音视频。
|
|
135
|
+
*/
|
|
136
|
+
trtc = "trtc",
|
|
137
|
+
/**
|
|
138
|
+
* 声网实时音视频。
|
|
139
|
+
*/
|
|
140
|
+
agora = "agora",
|
|
141
|
+
/** 火山引擎实时音视频。 */
|
|
142
|
+
vertc = "vertc"
|
|
143
|
+
}
|
|
144
|
+
|
|
127
145
|
/**
|
|
128
146
|
* 远端视频插帧的开关与显示帧率配置。
|
|
129
147
|
*/
|
|
@@ -138,6 +156,10 @@ interface FrameInterpolationConfiguration {
|
|
|
138
156
|
targetFrameRate?: number;
|
|
139
157
|
}
|
|
140
158
|
interface RealtimeConfigurationInit {
|
|
159
|
+
/**
|
|
160
|
+
* RTC 提供方,默认 TRTC;不根据模型名称自动推断。
|
|
161
|
+
*/
|
|
162
|
+
provider?: RtcProvider;
|
|
141
163
|
/**
|
|
142
164
|
* 实时生成业务使用的模型。
|
|
143
165
|
*/
|
|
@@ -156,6 +178,10 @@ interface RealtimeConfigurationInit {
|
|
|
156
178
|
* 创建实时 Manager 所需的业务配置。
|
|
157
179
|
*/
|
|
158
180
|
declare class RealtimeConfiguration {
|
|
181
|
+
/**
|
|
182
|
+
* RTC 配置
|
|
183
|
+
*/
|
|
184
|
+
readonly provider: RtcProvider;
|
|
159
185
|
/**
|
|
160
186
|
* 模型配置
|
|
161
187
|
*/
|
|
@@ -178,6 +204,7 @@ declare class RealtimeConfiguration {
|
|
|
178
204
|
* 创建实时业务配置。
|
|
179
205
|
*
|
|
180
206
|
* @param init.model 实时生成业务使用的模型。
|
|
207
|
+
* @param init.provider RTC 提供方,默认 TRTC;创建后不可切换。
|
|
181
208
|
* @param init.isFrameInterpolationEnabled 是否默认开启远端生成画面的插帧。
|
|
182
209
|
* @param init.frameInterpolation 插帧开关和显示帧率上限的详细配置。
|
|
183
210
|
*/
|
|
@@ -185,7 +212,7 @@ declare class RealtimeConfiguration {
|
|
|
185
212
|
}
|
|
186
213
|
|
|
187
214
|
/**
|
|
188
|
-
*
|
|
215
|
+
* RTC 网络质量等级:未知、极好、良好、一般、差、极差、断网。
|
|
189
216
|
*/
|
|
190
217
|
type NetworkQualityLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
191
218
|
/**
|
|
@@ -198,11 +225,11 @@ interface NetworkStatistics {
|
|
|
198
225
|
*/
|
|
199
226
|
readonly downlinkQuality?: NetworkQualityLevel;
|
|
200
227
|
/**
|
|
201
|
-
* 上行连接到
|
|
228
|
+
* 上行连接到 RTC 云端的往返延迟,单位 ms,不是单程延迟;Agora 未提供时为空。
|
|
202
229
|
*/
|
|
203
230
|
readonly uplinkRttMs?: number;
|
|
204
231
|
/**
|
|
205
|
-
* 所有下行连接到
|
|
232
|
+
* 所有下行连接到 RTC 云端的平均往返延迟,单位 ms;Agora 未提供时为空。
|
|
206
233
|
*/
|
|
207
234
|
readonly downlinkRttMs?: number;
|
|
208
235
|
}
|
|
@@ -314,7 +341,7 @@ declare enum XmaxErrorCode {
|
|
|
314
341
|
*/
|
|
315
342
|
cameraPermissionDenied = "CAMERA_PERMISSION_DENIED",
|
|
316
343
|
/**
|
|
317
|
-
* @deprecated
|
|
344
|
+
* @deprecated 为兼容保留;相机预热改为固定等待,不再抛出此错误。
|
|
318
345
|
*/
|
|
319
346
|
cameraExposureTimeout = "CAMERA_EXPOSURE_TIMEOUT",
|
|
320
347
|
/**
|
|
@@ -504,13 +531,18 @@ interface RealtimeLaunchTiming {
|
|
|
504
531
|
*/
|
|
505
532
|
readonly cameraMs?: number;
|
|
506
533
|
/**
|
|
507
|
-
*
|
|
534
|
+
* 确认相机与麦克风权限可用的耗时;系统弹窗时统计到用户完成授权。
|
|
535
|
+
* 权限被拒绝或浏览器不支持观察时不记录。
|
|
536
|
+
*/
|
|
537
|
+
readonly permissionMs?: number;
|
|
538
|
+
/**
|
|
539
|
+
* 开始创建会话到 RTC 进房配置与相机预热等待完成;不含发布本地流。
|
|
508
540
|
*/
|
|
509
541
|
readonly connectionMs?: number;
|
|
510
542
|
/**
|
|
511
|
-
*
|
|
543
|
+
* 发布本地流到 RTC 房间的耗时。
|
|
512
544
|
*/
|
|
513
|
-
readonly
|
|
545
|
+
readonly publishMs?: number;
|
|
514
546
|
/**
|
|
515
547
|
* 开始发送生成信令到 SDK 远端视图首次呈现视频帧。
|
|
516
548
|
*/
|
|
@@ -529,6 +561,10 @@ type RealtimeLaunchTimingListener = (timing: RealtimeLaunchTiming) => void;
|
|
|
529
561
|
* 视频流实际运行统计;缺失或无效指标为 undefined。
|
|
530
562
|
*/
|
|
531
563
|
interface VideoStatistics {
|
|
564
|
+
/**
|
|
565
|
+
* 本端视频上行丢包率,单位 %;厂商未提供时为空。
|
|
566
|
+
*/
|
|
567
|
+
readonly uplinkLossPercent?: number;
|
|
532
568
|
readonly width?: number;
|
|
533
569
|
readonly height?: number;
|
|
534
570
|
/**
|
|
@@ -550,23 +586,24 @@ type VideoStatisticsListener = (statistics: VideoStatistics | undefined) => void
|
|
|
550
586
|
interface RemoteVideoStatistics extends VideoStatistics {
|
|
551
587
|
readonly userID: string;
|
|
552
588
|
/**
|
|
553
|
-
* 本端 SDK 到
|
|
589
|
+
* 本端 SDK 到 RTC 云端的往返延迟,单位 ms;不是与远端用户之间的 RTT。
|
|
554
590
|
*/
|
|
555
591
|
readonly rttMs?: number;
|
|
556
592
|
/**
|
|
557
|
-
* 本端 SDK 到
|
|
593
|
+
* 本端 SDK 到 RTC 云端的上行丢包率,单位 %,不是结果流的发送端丢包率。
|
|
558
594
|
*/
|
|
559
595
|
readonly uplinkLossPercent?: number;
|
|
560
596
|
/**
|
|
561
|
-
*
|
|
597
|
+
* RTC 云端到本端 SDK 的下行丢包率,单位 %。
|
|
562
598
|
*/
|
|
563
599
|
readonly downlinkLossPercent?: number;
|
|
564
600
|
/**
|
|
565
|
-
* 当前远端视频流的播放缓冲延迟,单位 ms
|
|
601
|
+
* 当前远端视频流的播放缓冲延迟,单位 ms;Agora 未提供时为空。
|
|
566
602
|
*/
|
|
567
603
|
readonly jitterBufferDelayMs?: number;
|
|
568
604
|
/**
|
|
569
|
-
*
|
|
605
|
+
* RTC 媒体端到端延迟估算值,单位 ms;不代表完整 AI 处理链路耗时。
|
|
606
|
+
* 采用各厂商原生口径,Agora end2EndDelay 不包含编码与解码耗时。
|
|
570
607
|
*/
|
|
571
608
|
readonly endToEndDelayMs?: number;
|
|
572
609
|
}
|
|
@@ -656,10 +693,21 @@ interface XmaxRealtimeManaging {
|
|
|
656
693
|
position: CameraPosition;
|
|
657
694
|
useMicrophone: boolean;
|
|
658
695
|
/**
|
|
659
|
-
*
|
|
696
|
+
* 是否在发布前等待相机预热(固定 200ms),默认 true;false 跳过等待,不产生预热耗时。
|
|
660
697
|
*/
|
|
661
698
|
enableFrameValidation?: boolean;
|
|
662
699
|
}): Promise<RealtimeMediaStream>;
|
|
700
|
+
/**
|
|
701
|
+
* 更新当前本地流的上行视频格式,立即应用于 RTC 编码器,不重连或重启生成。
|
|
702
|
+
* 传入完整格式;未指定的码率和编码偏好按 RealtimeVideoFormat 默认规则解析。
|
|
703
|
+
* 成功后更新本地轨道的 videoFormat,后续重连继续使用该格式。
|
|
704
|
+
* 模型生成及远端插帧仍使用创建本地流时的格式;此接口不改变生成尺寸。
|
|
705
|
+
* 实际发送规格受设备、浏览器和网络影响,应通过统计回调确认。
|
|
706
|
+
*
|
|
707
|
+
* @param videoFormat 本次完整的上行尺寸、帧率和编码配置。
|
|
708
|
+
* @throws 无本地相机流、其他操作进行中、参数无效或 RTC 更新失败时抛错。
|
|
709
|
+
*/
|
|
710
|
+
updateVideoFormat(videoFormat: RealtimeVideoFormat): Promise<void>;
|
|
663
711
|
/**
|
|
664
712
|
* 停止本地相机流并释放本地预览与 RTC 资源。
|
|
665
713
|
*/
|
|
@@ -677,8 +725,7 @@ interface XmaxRealtimeManaging {
|
|
|
677
725
|
* 使用当前 Manager 创建的本地流建立实时连接。
|
|
678
726
|
*
|
|
679
727
|
* 创建实时会话、加入 RTC 房间并发布本地流,成功后启动会话心跳。
|
|
680
|
-
*
|
|
681
|
-
* 记录警告并按当前画面继续发布,不因环境较暗而阻断连接。
|
|
728
|
+
* 启用帧检测时,发布前并行等待相机预热(固定 200ms),避免把黑帧推给 RTC。
|
|
682
729
|
* 返回的远端媒体流在生成开始后承载远端生成画面。
|
|
683
730
|
*
|
|
684
731
|
* @param localStream 由 `createLocalCameraStream` 创建的本地媒体流。
|
|
@@ -889,6 +936,7 @@ declare class XmaxClient {
|
|
|
889
936
|
constructor(configuration: XmaxConfiguration);
|
|
890
937
|
/**
|
|
891
938
|
* 创建实时媒体 Manager。
|
|
939
|
+
* 模型专用地址优先于环境默认地址,并用于该 Manager 的整个会话生命周期。
|
|
892
940
|
*
|
|
893
941
|
* @param options 实时生成模型等业务配置。
|
|
894
942
|
* @returns 可用于本地相机预览、实时连接与生成的实时 Manager。
|
|
@@ -985,8 +1033,13 @@ interface ApiServicing {
|
|
|
985
1033
|
put<T>(path: string, body?: unknown): Promise<T>;
|
|
986
1034
|
/**
|
|
987
1035
|
* 发送 DELETE 请求。
|
|
1036
|
+
*
|
|
1037
|
+
* @param options.keepalive 为 true 时请求可存活于页面卸载之后,
|
|
1038
|
+
* 用于刷新或关闭页签时的清理请求。
|
|
988
1039
|
*/
|
|
989
|
-
delete<T>(path: string
|
|
1040
|
+
delete<T>(path: string, options?: {
|
|
1041
|
+
keepalive?: boolean;
|
|
1042
|
+
}): Promise<T>;
|
|
990
1043
|
}
|
|
991
1044
|
|
|
992
1045
|
/**
|
|
@@ -1347,4 +1400,4 @@ declare class XmaxRealtimeVideoView {
|
|
|
1347
1400
|
private showRemoteVideo;
|
|
1348
1401
|
}
|
|
1349
1402
|
|
|
1350
|
-
export { CameraPosition, type FrameInterpolationConfiguration, MediaService, type MediaServicing, type NetworkQualityLevel, type NetworkStatistics, type NetworkStatisticsListener, RealtimeConfiguration, type RealtimeConfigurationInit, RealtimeConnectionState, RealtimeContext, type RealtimeContextInit, type RealtimeLaunchTiming, type RealtimeLaunchTimingListener, RealtimeMediaStream, RealtimeModel, RealtimeReason, RealtimeState, type RealtimeStateListener, RealtimeVideoFormat, RealtimeVideoTrack, type RemoteVideoStatistics, type RemoteVideoStatisticsListener, StorageService, type StorageServicing, type StorageUploadOptions, StoredFile, VideoContentMode, type VideoStatistics, type VideoStatisticsListener, XmaxClient, XmaxConfiguration, type XmaxConfigurationInit, XmaxEnvironment, XmaxError, XmaxErrorCode, type XmaxErrorListener, XmaxLogger, XmaxLoggerOption, type XmaxRealtimeManaging, XmaxRealtimeVideoView, XmaxVideoView, apiBaseURL, defaultCameraVideoFormat, defaultFrameRate };
|
|
1403
|
+
export { CameraPosition, type FrameInterpolationConfiguration, MediaService, type MediaServicing, type NetworkQualityLevel, type NetworkStatistics, type NetworkStatisticsListener, RealtimeConfiguration, type RealtimeConfigurationInit, RealtimeConnectionState, RealtimeContext, type RealtimeContextInit, type RealtimeLaunchTiming, type RealtimeLaunchTimingListener, RealtimeMediaStream, RealtimeModel, RealtimeReason, RealtimeState, type RealtimeStateListener, RealtimeVideoFormat, RealtimeVideoTrack, type RemoteVideoStatistics, type RemoteVideoStatisticsListener, RtcProvider, StorageService, type StorageServicing, type StorageUploadOptions, StoredFile, VideoContentMode, type VideoStatistics, type VideoStatisticsListener, XmaxClient, XmaxConfiguration, type XmaxConfigurationInit, XmaxEnvironment, XmaxError, XmaxErrorCode, type XmaxErrorListener, XmaxLogger, XmaxLoggerOption, type XmaxRealtimeManaging, XmaxRealtimeVideoView, XmaxVideoView, apiBaseURL, defaultCameraVideoFormat, defaultFrameRate };
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
RealtimeVideoEncoderPreference,
|
|
12
12
|
RealtimeVideoFormat,
|
|
13
13
|
RealtimeVideoTrack,
|
|
14
|
+
RtcProvider,
|
|
14
15
|
StorageService,
|
|
15
16
|
StoredFile,
|
|
16
17
|
VideoContentMode,
|
|
@@ -26,7 +27,7 @@ import {
|
|
|
26
27
|
apiBaseURL,
|
|
27
28
|
defaultCameraVideoFormat,
|
|
28
29
|
defaultFrameRate
|
|
29
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-FMAQXPTE.js";
|
|
30
31
|
export {
|
|
31
32
|
CameraPosition,
|
|
32
33
|
MediaService,
|
|
@@ -40,6 +41,7 @@ export {
|
|
|
40
41
|
RealtimeVideoEncoderPreference,
|
|
41
42
|
RealtimeVideoFormat,
|
|
42
43
|
RealtimeVideoTrack,
|
|
44
|
+
RtcProvider,
|
|
43
45
|
StorageService,
|
|
44
46
|
StoredFile,
|
|
45
47
|
VideoContentMode,
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkFEL5MJMJcjs = require('../chunk-FEL5MJMJ.cjs');
|
|
5
5
|
|
|
6
6
|
// src/react/XmaxRealtimeVideo.tsx
|
|
7
7
|
|
|
@@ -17,7 +17,7 @@ function XmaxRealtimeVideo(props) {
|
|
|
17
17
|
if (!container) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
const view = new (0,
|
|
20
|
+
const view = new (0, _chunkFEL5MJMJcjs.XmaxRealtimeVideoView)();
|
|
21
21
|
view.element.style.width = "100%";
|
|
22
22
|
view.element.style.height = "100%";
|
|
23
23
|
view.attach(container);
|
|
@@ -71,7 +71,7 @@ function XmaxVideo(props) {
|
|
|
71
71
|
if (!container) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
const view = new (0,
|
|
74
|
+
const view = new (0, _chunkFEL5MJMJcjs.XmaxVideoView)();
|
|
75
75
|
view.element.style.width = "100%";
|
|
76
76
|
view.element.style.height = "100%";
|
|
77
77
|
view.attach(container);
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/private/var/folders/5j/p3g3j18x2w3byrl5wtnk94tc0000gn/T/xmax-web-release-
|
|
1
|
+
{"version":3,"sources":["/private/var/folders/5j/p3g3j18x2w3byrl5wtnk94tc0000gn/T/xmax-web-release-sdawVu/source/packages/xmax-sdk/dist/react/index.cjs","../../src/react/XmaxRealtimeVideo.tsx","../../src/react/XmaxVideo.tsx"],"names":["useRef","useEffect","jsx"],"mappings":"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","file":"/private/var/folders/5j/p3g3j18x2w3byrl5wtnk94tc0000gn/T/xmax-web-release-sdawVu/source/packages/xmax-sdk/dist/react/index.cjs","sourcesContent":[null,"import {\n VideoContentMode,\n XmaxRealtimeVideoView,\n type RealtimeVideoTrack,\n} from \"../index\";\nimport {\n useEffect,\n useRef,\n type CSSProperties,\n} from \"react\";\n\nexport interface XmaxRealtimeVideoProps {\n /**\n * 当前显示的本地视频轨道。\n */\n localTrack?: RealtimeVideoTrack;\n\n /**\n * 当前显示的远端生成视频轨道;首帧提交后自动渐入。\n */\n remoteTrack?: RealtimeVideoTrack;\n\n /**\n * 视频内容在容器中的显示模式,默认 fill。\n */\n videoContentMode?: VideoContentMode;\n\n /**\n * 容器类名。\n */\n className?: string;\n\n /**\n * 容器样式。\n */\n style?: CSSProperties;\n}\n\n/**\n * 本地预览和远端生成画面自动切换的 React 组件。\n */\nexport function XmaxRealtimeVideo(props: XmaxRealtimeVideoProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const viewRef = useRef<XmaxRealtimeVideoView | undefined>(undefined);\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n const view = new XmaxRealtimeVideoView();\n view.element.style.width = \"100%\";\n view.element.style.height = \"100%\";\n view.attach(container);\n viewRef.current = view;\n return () => {\n viewRef.current = undefined;\n view.localTrack = undefined;\n view.remoteTrack = undefined;\n view.detach();\n };\n }, []);\n\n useEffect(() => {\n const view = viewRef.current;\n if (view) {\n view.localTrack = props.localTrack;\n }\n }, [props.localTrack]);\n\n useEffect(() => {\n const view = viewRef.current;\n if (view) {\n view.remoteTrack = props.remoteTrack;\n }\n }, [props.remoteTrack]);\n\n useEffect(() => {\n const view = viewRef.current;\n if (view && props.videoContentMode) {\n view.videoContentMode = props.videoContentMode;\n }\n }, [props.videoContentMode]);\n\n return (\n <div\n ref={containerRef}\n className={props.className}\n style={{ position: \"relative\", overflow: \"hidden\", ...props.style }}\n />\n );\n}\n","import {\n VideoContentMode,\n XmaxVideoView,\n type RealtimeVideoTrack,\n} from \"../index\";\nimport {\n useEffect,\n useRef,\n type CSSProperties,\n} from \"react\";\n\nexport interface XmaxVideoProps {\n /**\n * 当前显示的视频轨道;置空时清空画面。\n */\n track?: RealtimeVideoTrack;\n\n /**\n * 视频内容在容器中的显示模式,默认 fill。\n */\n videoContentMode?: VideoContentMode;\n\n /**\n * 是否镜像显示(仅影响显示,不影响发布流)。\n */\n mirrored?: boolean;\n\n /**\n * 容器类名。\n */\n className?: string;\n\n /**\n * 容器样式。\n */\n style?: CSSProperties;\n}\n\n/**\n * 单轨视频 React 组件:把一路视频轨渲染到容器。\n */\nexport function XmaxVideo(props: XmaxVideoProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const viewRef = useRef<XmaxVideoView | undefined>(undefined);\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n const view = new XmaxVideoView();\n view.element.style.width = \"100%\";\n view.element.style.height = \"100%\";\n view.attach(container);\n viewRef.current = view;\n return () => {\n viewRef.current = undefined;\n view.track = undefined;\n view.detach();\n };\n }, []);\n\n useEffect(() => {\n const view = viewRef.current;\n if (view) {\n view.track = props.track;\n }\n }, [props.track]);\n\n useEffect(() => {\n const view = viewRef.current;\n if (view && props.videoContentMode) {\n view.videoContentMode = props.videoContentMode;\n }\n }, [props.videoContentMode]);\n\n useEffect(() => {\n const view = viewRef.current;\n if (view && props.mirrored !== undefined) {\n view.isMirrored = props.mirrored;\n }\n }, [props.mirrored]);\n\n return (\n <div\n ref={containerRef}\n className={props.className}\n style={{ position: \"relative\", overflow: \"hidden\", ...props.style }}\n />\n );\n}\n"]}
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmaxai/web-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "XmaxSDK for Web — Realtime Interactive Video Generation",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@volcengine/rtc": "4.69.3",
|
|
44
|
+
"agora-rtc-sdk-ng": "4.24.8",
|
|
43
45
|
"framegen": "1.4.0",
|
|
44
46
|
"cos-js-sdk-v5": "^1.10.1",
|
|
45
47
|
"trtc-sdk-v5": "^5.6.0"
|