@xmaxai/web-sdk 1.0.3 → 1.0.5
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 +637 -0
- package/dist/{chunk-JWAAS6P4.cjs → chunk-JN6HURTT.cjs} +3581 -605
- package/dist/chunk-JN6HURTT.cjs.map +1 -0
- package/dist/{chunk-YMLRUDAO.js → chunk-VMJXIVUF.js} +3467 -491
- package/dist/chunk-VMJXIVUF.js.map +1 -0
- package/dist/index.cjs +16 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +377 -75
- package/dist/index.d.ts +377 -75
- package/dist/index.js +17 -3
- 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 +11 -7
- package/dist/chunk-JWAAS6P4.cjs.map +0 -1
- package/dist/chunk-YMLRUDAO.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,34 +2,59 @@ import { R as RealtimeVideoFormat, a as RealtimeVideoTrack, C as CameraPosition,
|
|
|
2
2
|
export { b as RealtimeVideoEncoderPreference, c as RealtimeVideoFormatInit } from './VideoContentMode-BM97_H8V.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 实时媒体使用的 RTC 提供方;一个 Manager 生命周期内保持不变。
|
|
6
6
|
*/
|
|
7
|
-
declare enum
|
|
7
|
+
declare enum RtcProvider {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* 腾讯实时音视频。
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
trtc = "trtc",
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* 声网实时音视频。
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
agora = "agora",
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* 火山引擎实时音视频。
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
vertc = "vertc"
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* SDK 当前支持的实时生成模型。
|
|
24
|
+
*/
|
|
25
|
+
declare enum RealtimeModel {
|
|
26
|
+
x2_0 = "x2.0",
|
|
27
|
+
x2_0_trtc = "x2.0-trtc",
|
|
28
|
+
x2_0_agora = "x2.0-agora",
|
|
29
|
+
x2_1_preview = "x2.1-preview"
|
|
30
|
+
}
|
|
31
|
+
/** 内置模型或服务端新增的模型标识;自定义名称原样传给服务端。 */
|
|
32
|
+
type RealtimeModelName = RealtimeModel | (string & {});
|
|
33
|
+
/**
|
|
34
|
+
* 模型输入画面的像素尺寸。
|
|
35
|
+
*/
|
|
21
36
|
interface ModelSize {
|
|
22
37
|
width: number;
|
|
23
38
|
height: number;
|
|
24
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* 获取模型的显示名称。
|
|
42
|
+
*/
|
|
43
|
+
declare function modelDisplayName(model: RealtimeModelName): string;
|
|
25
44
|
/**
|
|
26
45
|
* 未指定视频规格时,各媒体来源使用的默认帧率。
|
|
27
46
|
*/
|
|
28
|
-
declare function defaultFrameRate(_model:
|
|
47
|
+
declare function defaultFrameRate(_model: RealtimeModelName): number;
|
|
29
48
|
/**
|
|
30
49
|
* 摄像头采集使用的默认视频规格。
|
|
31
50
|
*/
|
|
32
|
-
declare function defaultCameraVideoFormat(model:
|
|
51
|
+
declare function defaultCameraVideoFormat(model: RealtimeModelName): RealtimeVideoFormat;
|
|
52
|
+
/**
|
|
53
|
+
* 查询 SDK 允许配置的 RTC 提供方,第一项为默认值。
|
|
54
|
+
* 未知模型默认沿用 x2.1-preview 的 VeRTC,也允许显式选择其他已接入的 RTC;
|
|
55
|
+
* 是否被该模型的服务端支持,由服务端决定。
|
|
56
|
+
*/
|
|
57
|
+
declare function supportedRtcProviders(model: RealtimeModelName): readonly RtcProvider[];
|
|
33
58
|
|
|
34
59
|
/**
|
|
35
60
|
* 定义媒体输入规则与平台媒体能力查询能力。
|
|
@@ -88,11 +113,11 @@ declare class StoredFile {
|
|
|
88
113
|
}
|
|
89
114
|
|
|
90
115
|
/**
|
|
91
|
-
*
|
|
116
|
+
* 上传图片或视频的参数。
|
|
92
117
|
*/
|
|
93
118
|
interface StorageUploadOptions {
|
|
94
119
|
/**
|
|
95
|
-
*
|
|
120
|
+
* 文件数据;File 作为 Blob 的子类可直接传入。
|
|
96
121
|
*/
|
|
97
122
|
data: Blob | ArrayBuffer | Uint8Array;
|
|
98
123
|
/**
|
|
@@ -100,7 +125,7 @@ interface StorageUploadOptions {
|
|
|
100
125
|
*/
|
|
101
126
|
fileName: string;
|
|
102
127
|
/**
|
|
103
|
-
*
|
|
128
|
+
* 文件 MIME 类型;缺省按文件名后缀推断。
|
|
104
129
|
*/
|
|
105
130
|
contentType?: string;
|
|
106
131
|
/**
|
|
@@ -109,83 +134,76 @@ interface StorageUploadOptions {
|
|
|
109
134
|
onProgress?: (transferred: number, total: number) => void;
|
|
110
135
|
}
|
|
111
136
|
/**
|
|
112
|
-
*
|
|
137
|
+
* 定义图片、视频上传和视频下载能力。
|
|
113
138
|
*/
|
|
114
139
|
interface StorageServicing {
|
|
115
140
|
/**
|
|
116
141
|
* 上传图片。
|
|
117
142
|
*
|
|
118
|
-
* 从 Xmax
|
|
119
|
-
* 实时生成的参考图路径。
|
|
143
|
+
* 从 Xmax 服务获取临时凭证后直传对象存储。
|
|
120
144
|
*
|
|
121
145
|
* @returns 已存储文件信息。
|
|
122
146
|
* @throws 参数无效、凭证获取失败或上传失败时抛出错误。
|
|
123
147
|
*/
|
|
124
148
|
uploadImage(options: StorageUploadOptions): Promise<StoredFile>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 远端视频插帧的开关与显示帧率配置。
|
|
129
|
-
*/
|
|
130
|
-
interface FrameInterpolationConfiguration {
|
|
131
149
|
/**
|
|
132
|
-
*
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
interface RealtimeConfigurationInit {
|
|
141
|
-
/**
|
|
142
|
-
* 实时生成业务使用的模型。
|
|
143
|
-
*/
|
|
144
|
-
model: RealtimeModel;
|
|
145
|
-
/**
|
|
146
|
-
* 是否默认开启远端生成画面的插帧,默认 false。
|
|
147
|
-
* frameInterpolation.enabled 显式设置时优先。
|
|
150
|
+
* 上传视频。
|
|
151
|
+
*
|
|
152
|
+
* 从 Xmax 服务获取临时凭证后,通过 COS putObject 普通上传原始文件。
|
|
153
|
+
* 不进行转码、压缩或分片上传;单个文件受 COS 普通上传的 5GB 上限约束。
|
|
154
|
+
*
|
|
155
|
+
* @returns 已存储文件信息。
|
|
156
|
+
* @throws 参数无效、凭证获取失败或上传失败时抛出错误。
|
|
148
157
|
*/
|
|
149
|
-
|
|
158
|
+
uploadVideo(options: StorageUploadOptions): Promise<StoredFile>;
|
|
150
159
|
/**
|
|
151
|
-
*
|
|
160
|
+
* 下载完整视频文件并触发浏览器保存;跨域地址需要允许 CORS。
|
|
161
|
+
*
|
|
162
|
+
* @param options.url 可直接访问的 HTTP(S) 视频地址。
|
|
163
|
+
* @param options.fileName 保存时建议使用的文件名。
|
|
164
|
+
* @param options.signal 用于取消网络下载的信号。
|
|
165
|
+
* @returns 文件读取完成并已触发浏览器保存,不代表文件已写入磁盘。
|
|
166
|
+
* @throws 参数无效、非浏览器环境、下载失败或主动取消时抛出错误。
|
|
152
167
|
*/
|
|
153
|
-
|
|
168
|
+
downloadVideo(options: {
|
|
169
|
+
url: string;
|
|
170
|
+
fileName: string;
|
|
171
|
+
signal?: AbortSignal;
|
|
172
|
+
}): Promise<void>;
|
|
154
173
|
}
|
|
174
|
+
|
|
155
175
|
/**
|
|
156
176
|
* 创建实时 Manager 所需的业务配置。
|
|
157
177
|
*/
|
|
158
178
|
declare class RealtimeConfiguration {
|
|
159
|
-
/**
|
|
160
|
-
* 模型配置
|
|
161
|
-
*/
|
|
162
179
|
/**
|
|
163
180
|
* 实时生成业务使用的模型。
|
|
164
181
|
*/
|
|
165
|
-
readonly model:
|
|
182
|
+
readonly model: RealtimeModelName;
|
|
166
183
|
/**
|
|
167
|
-
*
|
|
184
|
+
* 实时连接使用的 RTC 提供方。
|
|
168
185
|
*/
|
|
186
|
+
readonly provider: RtcProvider;
|
|
169
187
|
/**
|
|
170
188
|
* 是否默认请求开启远端生成画面的插帧。
|
|
171
189
|
*/
|
|
172
190
|
readonly isFrameInterpolationEnabled: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* 已补全默认值的只读插帧配置。
|
|
175
|
-
*/
|
|
176
|
-
readonly frameInterpolation: Readonly<Required<FrameInterpolationConfiguration>>;
|
|
177
191
|
/**
|
|
178
192
|
* 创建实时业务配置。
|
|
179
193
|
*
|
|
180
|
-
* @param init.model
|
|
181
|
-
* @param init.
|
|
182
|
-
* @param init.
|
|
194
|
+
* @param init.model 实时生成业务使用的模型;未知名称原样透传,默认配置同 x2.1-preview。
|
|
195
|
+
* @param init.provider RTC 提供方,默认按模型定义选择;必须受模型支持,创建后不可切换。
|
|
196
|
+
* @param init.isFrameInterpolationEnabled 是否默认开启远端生成画面的插帧,默认 false。
|
|
183
197
|
*/
|
|
184
|
-
constructor(init:
|
|
198
|
+
constructor(init: {
|
|
199
|
+
model: RealtimeModelName;
|
|
200
|
+
provider?: RtcProvider;
|
|
201
|
+
isFrameInterpolationEnabled?: boolean;
|
|
202
|
+
});
|
|
185
203
|
}
|
|
186
204
|
|
|
187
205
|
/**
|
|
188
|
-
*
|
|
206
|
+
* RTC 网络质量等级:未知、极好、良好、一般、差、极差、断网。
|
|
189
207
|
*/
|
|
190
208
|
type NetworkQualityLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
191
209
|
/**
|
|
@@ -198,11 +216,11 @@ interface NetworkStatistics {
|
|
|
198
216
|
*/
|
|
199
217
|
readonly downlinkQuality?: NetworkQualityLevel;
|
|
200
218
|
/**
|
|
201
|
-
* 上行连接到
|
|
219
|
+
* 上行连接到 RTC 云端的往返延迟,单位 ms,不是单程延迟;Agora 未提供时为空。
|
|
202
220
|
*/
|
|
203
221
|
readonly uplinkRttMs?: number;
|
|
204
222
|
/**
|
|
205
|
-
* 所有下行连接到
|
|
223
|
+
* 所有下行连接到 RTC 云端的平均往返延迟,单位 ms;Agora 未提供时为空。
|
|
206
224
|
*/
|
|
207
225
|
readonly downlinkRttMs?: number;
|
|
208
226
|
}
|
|
@@ -211,7 +229,32 @@ interface NetworkStatistics {
|
|
|
211
229
|
*/
|
|
212
230
|
type NetworkStatisticsListener = (statistics: NetworkStatistics | undefined) => void;
|
|
213
231
|
|
|
232
|
+
/**
|
|
233
|
+
* 服务端读取网络视频时使用的采样方式。
|
|
234
|
+
*/
|
|
235
|
+
declare enum RealtimeVideoSampleMethod {
|
|
236
|
+
time = "time",
|
|
237
|
+
fps = "fps"
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* 服务端可直接访问的网络视频及采样配置。
|
|
241
|
+
*/
|
|
242
|
+
interface RealtimeReferenceVideo {
|
|
243
|
+
/**
|
|
244
|
+
* HTTP 或 HTTPS 视频地址。
|
|
245
|
+
*/
|
|
246
|
+
readonly path: string;
|
|
247
|
+
/**
|
|
248
|
+
* 服务端采样方式。
|
|
249
|
+
*/
|
|
250
|
+
readonly sampleMethod: RealtimeVideoSampleMethod;
|
|
251
|
+
}
|
|
252
|
+
|
|
214
253
|
interface RealtimeContextInit {
|
|
254
|
+
/**
|
|
255
|
+
* 服务端直接读取的网络视频。
|
|
256
|
+
*/
|
|
257
|
+
referenceVideo?: RealtimeReferenceVideo;
|
|
215
258
|
/**
|
|
216
259
|
* 实时生成使用的文本条件。
|
|
217
260
|
*/
|
|
@@ -225,6 +268,10 @@ interface RealtimeContextInit {
|
|
|
225
268
|
* 单次实时生成任务的文本和参考资源上下文。
|
|
226
269
|
*/
|
|
227
270
|
declare class RealtimeContext {
|
|
271
|
+
/**
|
|
272
|
+
* 服务端直接读取的网络视频。
|
|
273
|
+
*/
|
|
274
|
+
readonly referenceVideo?: RealtimeReferenceVideo;
|
|
228
275
|
/**
|
|
229
276
|
* 生成条件
|
|
230
277
|
*/
|
|
@@ -534,6 +581,10 @@ type RealtimeLaunchTimingListener = (timing: RealtimeLaunchTiming) => void;
|
|
|
534
581
|
* 视频流实际运行统计;缺失或无效指标为 undefined。
|
|
535
582
|
*/
|
|
536
583
|
interface VideoStatistics {
|
|
584
|
+
/**
|
|
585
|
+
* 本端视频上行丢包率,单位 %;厂商未提供时为空。
|
|
586
|
+
*/
|
|
587
|
+
readonly uplinkLossPercent?: number;
|
|
537
588
|
readonly width?: number;
|
|
538
589
|
readonly height?: number;
|
|
539
590
|
/**
|
|
@@ -555,23 +606,24 @@ type VideoStatisticsListener = (statistics: VideoStatistics | undefined) => void
|
|
|
555
606
|
interface RemoteVideoStatistics extends VideoStatistics {
|
|
556
607
|
readonly userID: string;
|
|
557
608
|
/**
|
|
558
|
-
* 本端 SDK 到
|
|
609
|
+
* 本端 SDK 到 RTC 云端的往返延迟,单位 ms;不是与远端用户之间的 RTT。
|
|
559
610
|
*/
|
|
560
611
|
readonly rttMs?: number;
|
|
561
612
|
/**
|
|
562
|
-
* 本端 SDK 到
|
|
613
|
+
* 本端 SDK 到 RTC 云端的上行丢包率,单位 %,不是结果流的发送端丢包率。
|
|
563
614
|
*/
|
|
564
615
|
readonly uplinkLossPercent?: number;
|
|
565
616
|
/**
|
|
566
|
-
*
|
|
617
|
+
* RTC 云端到本端 SDK 的下行丢包率,单位 %。
|
|
567
618
|
*/
|
|
568
619
|
readonly downlinkLossPercent?: number;
|
|
569
620
|
/**
|
|
570
|
-
* 当前远端视频流的播放缓冲延迟,单位 ms
|
|
621
|
+
* 当前远端视频流的播放缓冲延迟,单位 ms;Agora 未提供时为空。
|
|
571
622
|
*/
|
|
572
623
|
readonly jitterBufferDelayMs?: number;
|
|
573
624
|
/**
|
|
574
|
-
*
|
|
625
|
+
* RTC 媒体端到端延迟估算值,单位 ms;不代表完整 AI 处理链路耗时。
|
|
626
|
+
* 采用各厂商原生口径,Agora end2EndDelay 不包含编码与解码耗时。
|
|
575
627
|
*/
|
|
576
628
|
readonly endToEndDelayMs?: number;
|
|
577
629
|
}
|
|
@@ -665,6 +717,47 @@ interface XmaxRealtimeManaging {
|
|
|
665
717
|
*/
|
|
666
718
|
enableFrameValidation?: boolean;
|
|
667
719
|
}): Promise<RealtimeMediaStream>;
|
|
720
|
+
/**
|
|
721
|
+
* 创建服务端直接读取的 HTTP/HTTPS 网络视频源,不采集或发布本地音视频。
|
|
722
|
+
* 本地预览静音播放一次,独立于服务端进度;创建源不会开始生成。
|
|
723
|
+
* 地址必须可由服务端直接访问,不转发浏览器 Cookie 或自定义鉴权头。
|
|
724
|
+
* @param options.videoFormat 模型输入及生成画面规格,不是上行编码参数。
|
|
725
|
+
* @param options.sampleMethod 服务端采样方式,默认 time。
|
|
726
|
+
* @param options.onFinish 当前任务收到服务端完成消息且生成就绪后调用一次,不代表尾帧已播放完。
|
|
727
|
+
* @throws 地址、格式无效或已有活动媒体源时抛错;close 释放源,disconnect 保留预览。
|
|
728
|
+
*/
|
|
729
|
+
createNetworkVideoStream(options: {
|
|
730
|
+
url: string;
|
|
731
|
+
videoFormat: RealtimeVideoFormat;
|
|
732
|
+
sampleMethod?: RealtimeVideoSampleMethod;
|
|
733
|
+
onFinish?: () => void;
|
|
734
|
+
}): Promise<RealtimeMediaStream>;
|
|
735
|
+
/**
|
|
736
|
+
* 从本地 File/Blob 创建文件视频源,支持 TRTC、Agora 和 VeRTC,不访问摄像头或麦克风。
|
|
737
|
+
* 通过 Canvas 等比缩放补黑边,文件音频独立上行,本地预览始终静音。
|
|
738
|
+
* 应从用户点击事件直接调用以解锁播放;创建后停在首帧,startGeneration 时开始播放。
|
|
739
|
+
* @param options.videoFormat 期望的视频规格;尺寸自动匹配最接近宽高比的模型档位,等距时优先横屏。
|
|
740
|
+
* @param options.loop 是否循环播放文件音视频,默认 true。
|
|
741
|
+
* @param options.includeAudio 是否发送文件音频,默认 true;无音轨文件输出静音,false 不创建音频轨。
|
|
742
|
+
* @throws 提供方不支持、文件/格式无效、浏览器无法解码或播放受限时抛错。
|
|
743
|
+
*/
|
|
744
|
+
createLocalVideoStream(options: {
|
|
745
|
+
file: Blob;
|
|
746
|
+
videoFormat: RealtimeVideoFormat;
|
|
747
|
+
loop?: boolean;
|
|
748
|
+
includeAudio?: boolean;
|
|
749
|
+
}): Promise<RealtimeMediaStream>;
|
|
750
|
+
/**
|
|
751
|
+
* 更新当前本地流的上行视频格式,立即应用于 RTC 编码器,不重连或重启生成。
|
|
752
|
+
* 传入完整格式;未指定的码率和编码偏好按 RealtimeVideoFormat 默认规则解析。
|
|
753
|
+
* 成功后更新本地轨道的 videoFormat,后续重连继续使用该格式。
|
|
754
|
+
* 模型生成及远端插帧仍使用创建本地流时的格式;此接口不改变生成尺寸。
|
|
755
|
+
* 实际发送规格受设备、浏览器和网络影响,应通过统计回调确认。
|
|
756
|
+
*
|
|
757
|
+
* @param videoFormat 本次完整的上行尺寸、帧率和编码配置。
|
|
758
|
+
* @throws 无本地相机或文件视频流、其他操作进行中、参数无效或 RTC 更新失败时抛错。
|
|
759
|
+
*/
|
|
760
|
+
updateVideoFormat(videoFormat: RealtimeVideoFormat): Promise<void>;
|
|
668
761
|
/**
|
|
669
762
|
* 停止本地相机流并释放本地预览与 RTC 资源。
|
|
670
763
|
*/
|
|
@@ -681,11 +774,11 @@ interface XmaxRealtimeManaging {
|
|
|
681
774
|
/**
|
|
682
775
|
* 使用当前 Manager 创建的本地流建立实时连接。
|
|
683
776
|
*
|
|
684
|
-
* 创建实时会话、加入 RTC
|
|
777
|
+
* 创建实时会话、加入 RTC 房间并启动会话心跳;摄像头源发布本地流,网络视频源仅接收。
|
|
685
778
|
* 启用帧检测时,发布前并行等待相机预热(固定 200ms),避免把黑帧推给 RTC。
|
|
686
779
|
* 返回的远端媒体流在生成开始后承载远端生成画面。
|
|
687
780
|
*
|
|
688
|
-
* @param localStream
|
|
781
|
+
* @param localStream 由当前 Manager 创建的摄像头、本地文件或网络视频源。
|
|
689
782
|
* @returns 远端生成结果占位的媒体流。
|
|
690
783
|
* @throws 本地流不属于当前 Manager、已有活动连接、会话创建或进房
|
|
691
784
|
* 发布失败时抛出错误;失败时自动释放连接资源并恢复本地预览。
|
|
@@ -706,7 +799,7 @@ interface XmaxRealtimeManaging {
|
|
|
706
799
|
* 尚未连接时先建立实时连接;已在生成时仅更新生成条件,不重启生成。
|
|
707
800
|
* 首次生成必须提供条件上下文,之后缺省时复用最近一次缓存的上下文。
|
|
708
801
|
*
|
|
709
|
-
* @param options.localStream
|
|
802
|
+
* @param options.localStream 由当前 Manager 创建的摄像头、本地文件或网络视频源。
|
|
710
803
|
* @param options.context 本次生成使用的条件上下文;缺省时复用缓存。
|
|
711
804
|
* @returns 承载远端生成画面的媒体流。
|
|
712
805
|
* @throws 本地流不属于当前 Manager、缺少可用的条件上下文、信令发送
|
|
@@ -870,7 +963,174 @@ declare class XmaxConfiguration {
|
|
|
870
963
|
}
|
|
871
964
|
|
|
872
965
|
/**
|
|
873
|
-
*
|
|
966
|
+
* 非实时视频的输出质量。
|
|
967
|
+
*/
|
|
968
|
+
declare enum NonRealtimeQuality {
|
|
969
|
+
sd = "sd",
|
|
970
|
+
hd = "hd"
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* 服务端任务状态;上传进度不属于任务状态。
|
|
974
|
+
*/
|
|
975
|
+
declare enum NonRealtimeTaskStatus {
|
|
976
|
+
submitted = "submitted",
|
|
977
|
+
processing = "processing",
|
|
978
|
+
completed = "completed",
|
|
979
|
+
error = "error"
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* 提交非实时任务的参数;资源必须来自 Xmax 上传流程,不能使用 blob URL 或本地路径。
|
|
983
|
+
*/
|
|
984
|
+
interface NonRealtimeTaskOptions {
|
|
985
|
+
/**
|
|
986
|
+
* 模型标识。
|
|
987
|
+
*/
|
|
988
|
+
model: string;
|
|
989
|
+
/**
|
|
990
|
+
* 已上传源视频的 URL。
|
|
991
|
+
*/
|
|
992
|
+
videoPath: string;
|
|
993
|
+
/**
|
|
994
|
+
* 生成指令;去除首尾空白后为 1–1024 个字符。
|
|
995
|
+
*/
|
|
996
|
+
prompt: string;
|
|
997
|
+
/**
|
|
998
|
+
* 已上传参考图片的 URL;省略表示不使用参考图。
|
|
999
|
+
*/
|
|
1000
|
+
referencePath?: string;
|
|
1001
|
+
/**
|
|
1002
|
+
* 输出质量。
|
|
1003
|
+
*/
|
|
1004
|
+
quality: NonRealtimeQuality;
|
|
1005
|
+
/**
|
|
1006
|
+
* 可选的处理帧率;仅接受协议支持的整数,省略时沿用源视频帧率(含小数)。
|
|
1007
|
+
*/
|
|
1008
|
+
fps?: number;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* 非实时生成结果;缺失或 null 的服务端字段规范化为 undefined。
|
|
1012
|
+
*/
|
|
1013
|
+
interface NonRealtimeResult {
|
|
1014
|
+
readonly url?: string;
|
|
1015
|
+
readonly uploadError?: string;
|
|
1016
|
+
readonly uploadStatus?: string;
|
|
1017
|
+
readonly finalizeDurationMs?: number;
|
|
1018
|
+
readonly compressionLevel?: string;
|
|
1019
|
+
readonly frameCount?: number;
|
|
1020
|
+
readonly fps?: number;
|
|
1021
|
+
readonly durationMs?: number;
|
|
1022
|
+
readonly fileSizeBytes?: number;
|
|
1023
|
+
readonly droppedFrameCount?: number;
|
|
1024
|
+
readonly originalFileSizeBytes?: number;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* 非实时任务快照;uid 和 status 为 SDK 查询、恢复及轮询所需字段。
|
|
1028
|
+
* 时间戳保持服务端原始字符串,不推断时区。
|
|
1029
|
+
*/
|
|
1030
|
+
interface NonRealtimeTask {
|
|
1031
|
+
readonly uid: string;
|
|
1032
|
+
readonly status: NonRealtimeTaskStatus;
|
|
1033
|
+
readonly userUid?: string;
|
|
1034
|
+
readonly prompt?: string;
|
|
1035
|
+
readonly videoPath?: string;
|
|
1036
|
+
readonly referencePath?: string;
|
|
1037
|
+
readonly processorId?: string;
|
|
1038
|
+
readonly quality?: NonRealtimeQuality;
|
|
1039
|
+
readonly requestedFps?: number;
|
|
1040
|
+
readonly resolvedFps?: number;
|
|
1041
|
+
readonly retryCount?: number;
|
|
1042
|
+
readonly videoDurationSeconds?: number;
|
|
1043
|
+
readonly billableDurationSeconds?: number;
|
|
1044
|
+
readonly chargePoints?: number;
|
|
1045
|
+
readonly result?: NonRealtimeResult;
|
|
1046
|
+
readonly processStartTime?: string;
|
|
1047
|
+
readonly createTimestamp?: string;
|
|
1048
|
+
readonly updateTimestamp?: string;
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* 分页查询选项。
|
|
1052
|
+
*/
|
|
1053
|
+
interface NonRealtimeTaskListOptions {
|
|
1054
|
+
/**
|
|
1055
|
+
* 从 1 开始的页码,默认 1。
|
|
1056
|
+
*/
|
|
1057
|
+
pageNumber?: number;
|
|
1058
|
+
/**
|
|
1059
|
+
* 每页数量,1–100,默认 10。
|
|
1060
|
+
*/
|
|
1061
|
+
pageSize?: number;
|
|
1062
|
+
/**
|
|
1063
|
+
* 可选的任务状态筛选。
|
|
1064
|
+
*/
|
|
1065
|
+
status?: NonRealtimeTaskStatus;
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* 按创建时间从新到旧排列的任务页。
|
|
1069
|
+
*/
|
|
1070
|
+
interface NonRealtimeTaskPage {
|
|
1071
|
+
readonly pageNumber: number;
|
|
1072
|
+
readonly pageSize: number;
|
|
1073
|
+
readonly total: number;
|
|
1074
|
+
readonly list: readonly NonRealtimeTask[];
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* 本地任务等待选项;所有时间单位均为毫秒。
|
|
1079
|
+
*/
|
|
1080
|
+
interface NonRealtimeWaitOptions {
|
|
1081
|
+
/**
|
|
1082
|
+
* 成功查询后等待多久再查询,默认 2000;必须为正数。
|
|
1083
|
+
*/
|
|
1084
|
+
intervalMs?: number;
|
|
1085
|
+
/**
|
|
1086
|
+
* 总等待时限,必须为正数;省略时持续等待直至终态或取消。
|
|
1087
|
+
*/
|
|
1088
|
+
timeoutMs?: number;
|
|
1089
|
+
/**
|
|
1090
|
+
* 连续瞬时查询错误允许重试的次数,默认 3;成功查询后重置,0 表示不重试。
|
|
1091
|
+
*/
|
|
1092
|
+
maxConsecutiveRetries?: number;
|
|
1093
|
+
/**
|
|
1094
|
+
* 停止轮询及正在进行的查询,不取消服务端任务或退款。
|
|
1095
|
+
*/
|
|
1096
|
+
signal?: AbortSignal;
|
|
1097
|
+
/**
|
|
1098
|
+
* 每次成功查询的任务快照(含终态),不是生成百分比;回调异常不影响轮询。
|
|
1099
|
+
*/
|
|
1100
|
+
onTaskUpdated?: (task: NonRealtimeTask) => void;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* 非实时视频任务能力;各任务和等待操作相互独立,不维护唯一的当前任务。
|
|
1104
|
+
*/
|
|
1105
|
+
interface XmaxNonRealtimeManaging {
|
|
1106
|
+
/**
|
|
1107
|
+
* 提交并立即返回任务;不等待生成,不自动上传资源,也不自动重试提交请求。
|
|
1108
|
+
* 超时或响应解析失败不能证明服务端未创建任务,重复提交可能再次扣费。
|
|
1109
|
+
*/
|
|
1110
|
+
submitTask(options: NonRealtimeTaskOptions): Promise<NonRealtimeTask>;
|
|
1111
|
+
/**
|
|
1112
|
+
* 查询单个任务;服务端 error 状态原样返回,不作为 HTTP 查询失败抛出。
|
|
1113
|
+
*/
|
|
1114
|
+
getTask(taskUid: string, options?: {
|
|
1115
|
+
signal?: AbortSignal;
|
|
1116
|
+
}): Promise<NonRealtimeTask>;
|
|
1117
|
+
/**
|
|
1118
|
+
* 批量查询最多 100 个 ID,去重后按请求顺序返回;任一任务无权限或不存在则整体失败。
|
|
1119
|
+
*/
|
|
1120
|
+
getTasks(taskUids: readonly string[]): Promise<readonly NonRealtimeTask[]>;
|
|
1121
|
+
/**
|
|
1122
|
+
* 查询任务列表;默认第一页、每页 10 条,最多 100 条。
|
|
1123
|
+
*/
|
|
1124
|
+
listTasks(options?: NonRealtimeTaskListOptions): Promise<NonRealtimeTaskPage>;
|
|
1125
|
+
/**
|
|
1126
|
+
* 串行轮询直到 completed 且结果 URL 可用;任务 error 时抛出 NonRealtimeTaskError。
|
|
1127
|
+
* 超时、取消只停止本地等待,之后可使用同一任务 ID 继续查询或等待。
|
|
1128
|
+
*/
|
|
1129
|
+
waitForCompletion(taskUid: string, options?: NonRealtimeWaitOptions): Promise<NonRealtimeTask>;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* SDK 的统一入口,负责创建实时、非实时和媒体服务组件。
|
|
874
1134
|
*/
|
|
875
1135
|
declare class XmaxClient {
|
|
876
1136
|
/**
|
|
@@ -893,25 +1153,45 @@ declare class XmaxClient {
|
|
|
893
1153
|
constructor(configuration: XmaxConfiguration);
|
|
894
1154
|
/**
|
|
895
1155
|
* 创建实时媒体 Manager。
|
|
1156
|
+
* 模型专用地址优先于环境默认地址,并用于该 Manager 的整个会话生命周期。
|
|
896
1157
|
*
|
|
897
1158
|
* @param options 实时生成模型等业务配置。
|
|
898
1159
|
* @returns 可用于本地相机预览、实时连接与生成的实时 Manager。
|
|
899
1160
|
*/
|
|
900
1161
|
createRealtimeManager(options: RealtimeConfiguration): XmaxRealtimeManaging;
|
|
1162
|
+
/**
|
|
1163
|
+
* 创建非实时视频任务 Manager,使用全局 API Key 和当前环境的非实时任务服务地址。
|
|
1164
|
+
* 本方法不发起网络请求或加载 RTC,任务由服务端持久化,可按 ID 恢复查询。
|
|
1165
|
+
*/
|
|
1166
|
+
createNonRealtimeManager(): XmaxNonRealtimeManaging;
|
|
901
1167
|
/**
|
|
902
1168
|
* 创建媒体处理与能力查询 Service。
|
|
903
1169
|
*
|
|
904
1170
|
* @param model 媒体输入规则使用的模型,默认为 `x2.0-trtc`。
|
|
905
1171
|
*/
|
|
906
|
-
createMediaService(model?:
|
|
1172
|
+
createMediaService(model?: RealtimeModelName): MediaServicing;
|
|
907
1173
|
/**
|
|
908
1174
|
* 创建文件存储 Service。
|
|
909
1175
|
*
|
|
910
|
-
* @returns
|
|
1176
|
+
* @returns 可上传图片和视频到对象存储的存储 Service。
|
|
911
1177
|
*/
|
|
912
1178
|
createStorageService(): StorageServicing;
|
|
913
1179
|
}
|
|
914
1180
|
|
|
1181
|
+
/**
|
|
1182
|
+
* 服务端任务失败或终态结果不可用;保留最后的任务快照供接入方展示及恢复查询。
|
|
1183
|
+
*/
|
|
1184
|
+
declare class NonRealtimeTaskError extends XmaxError {
|
|
1185
|
+
/**
|
|
1186
|
+
* 失败上下文
|
|
1187
|
+
*/
|
|
1188
|
+
readonly task: NonRealtimeTask;
|
|
1189
|
+
/**
|
|
1190
|
+
* 使用 API 错误分类,不虚构服务端未返回的业务错误码。
|
|
1191
|
+
*/
|
|
1192
|
+
constructor(task: NonRealtimeTask, message: string);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
915
1195
|
/**
|
|
916
1196
|
* 提供模型输入尺寸和平台媒体能力相关的业务规则。
|
|
917
1197
|
* 模型输入尺寸与远端插帧能力。
|
|
@@ -920,13 +1200,13 @@ declare class MediaService implements MediaServicing {
|
|
|
920
1200
|
/**
|
|
921
1201
|
* 模型约束
|
|
922
1202
|
*/
|
|
923
|
-
readonly model:
|
|
1203
|
+
readonly model: RealtimeModelName;
|
|
924
1204
|
/**
|
|
925
1205
|
* 创建媒体服务。
|
|
926
1206
|
*
|
|
927
1207
|
* @param model 媒体输入规则使用的模型,默认为 `x2.0-trtc`。
|
|
928
1208
|
*/
|
|
929
|
-
constructor(model?:
|
|
1209
|
+
constructor(model?: RealtimeModelName);
|
|
930
1210
|
/**
|
|
931
1211
|
* Web 插帧保留原始尺寸;/16 对齐由 GPU 内部补边处理,不缩小回传视频。
|
|
932
1212
|
*/
|
|
@@ -958,6 +1238,13 @@ declare enum ApiMethod {
|
|
|
958
1238
|
put = "PUT",
|
|
959
1239
|
delete = "DELETE"
|
|
960
1240
|
}
|
|
1241
|
+
/**
|
|
1242
|
+
* 请求控制选项;signal 仅取消本地 HTTP 请求,不撤销服务端已执行的操作。
|
|
1243
|
+
*/
|
|
1244
|
+
interface ApiRequestOptions {
|
|
1245
|
+
signal?: AbortSignal;
|
|
1246
|
+
keepalive?: boolean;
|
|
1247
|
+
}
|
|
961
1248
|
/**
|
|
962
1249
|
* 定义 Xmax API 的基础请求能力。
|
|
963
1250
|
*
|
|
@@ -974,11 +1261,11 @@ interface ApiServicing {
|
|
|
974
1261
|
* @returns 统一响应中的 `data` 字段。
|
|
975
1262
|
* @throws 配置无效、网络失败、业务失败或响应无法解析时抛出错误。
|
|
976
1263
|
*/
|
|
977
|
-
request<T>(method: ApiMethod, path: string, body?: unknown): Promise<T>;
|
|
1264
|
+
request<T>(method: ApiMethod, path: string, body?: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
978
1265
|
/**
|
|
979
1266
|
* 发送 GET 请求。
|
|
980
1267
|
*/
|
|
981
|
-
get<T>(path: string): Promise<T>;
|
|
1268
|
+
get<T>(path: string, options?: ApiRequestOptions): Promise<T>;
|
|
982
1269
|
/**
|
|
983
1270
|
* 发送 POST 请求。
|
|
984
1271
|
*/
|
|
@@ -1059,7 +1346,7 @@ interface StorageServiceOptions {
|
|
|
1059
1346
|
identifierGenerator?: () => string;
|
|
1060
1347
|
}
|
|
1061
1348
|
/**
|
|
1062
|
-
*
|
|
1349
|
+
* 管理文件上传和视频下载。
|
|
1063
1350
|
*
|
|
1064
1351
|
* 上传直传不经过 Xmax 服务中转:先通过 `GET /cos/sts` 获取临时凭证,
|
|
1065
1352
|
* 再用临时凭证创建 COS 客户端直传;访问地址按 `Location`、自定义
|
|
@@ -1092,6 +1379,18 @@ declare class StorageService implements StorageServicing {
|
|
|
1092
1379
|
* 上传图片并返回访问地址。
|
|
1093
1380
|
*/
|
|
1094
1381
|
uploadImage(options: StorageUploadOptions): Promise<StoredFile>;
|
|
1382
|
+
/**
|
|
1383
|
+
* 普通上传原始视频并返回访问地址,不进行转码、压缩或分片。
|
|
1384
|
+
*/
|
|
1385
|
+
uploadVideo(options: StorageUploadOptions): Promise<StoredFile>;
|
|
1386
|
+
/**
|
|
1387
|
+
* 下载原始视频文件并交给浏览器保存,支持取消网络下载。
|
|
1388
|
+
*/
|
|
1389
|
+
downloadVideo(options: Parameters<StorageServicing["downloadVideo"]>[0]): Promise<void>;
|
|
1390
|
+
/**
|
|
1391
|
+
* 获取临时凭证并通过 COS putObject 上传文件,统一处理进度、结果和错误。
|
|
1392
|
+
*/
|
|
1393
|
+
private upload;
|
|
1095
1394
|
/**
|
|
1096
1395
|
* 获取临时存储配置;字段不完整时抛出 API 错误。
|
|
1097
1396
|
*/
|
|
@@ -1137,7 +1436,6 @@ declare class StorageService implements StorageServicing {
|
|
|
1137
1436
|
|
|
1138
1437
|
interface RemoteFrameInterpolationOptions {
|
|
1139
1438
|
size: ModelSize;
|
|
1140
|
-
targetFrameRate: number;
|
|
1141
1439
|
onActiveChange?: (active: boolean) => void;
|
|
1142
1440
|
onFailure: (error: unknown) => void;
|
|
1143
1441
|
}
|
|
@@ -1230,6 +1528,10 @@ declare class XmaxVideoView {
|
|
|
1230
1528
|
* 从容器元素移除。
|
|
1231
1529
|
*/
|
|
1232
1530
|
detach(): void;
|
|
1531
|
+
/**
|
|
1532
|
+
* 设置网络视频预览;静音播放一次,不捕获或发布媒体轨道。 @internal
|
|
1533
|
+
*/
|
|
1534
|
+
setVideoURL(url: string | null): void;
|
|
1233
1535
|
/**
|
|
1234
1536
|
* 直接设置渲染用的媒体流(绑定管线和直接渲染共用)。 @internal
|
|
1235
1537
|
*/
|
|
@@ -1356,4 +1658,4 @@ declare class XmaxRealtimeVideoView {
|
|
|
1356
1658
|
private showRemoteVideo;
|
|
1357
1659
|
}
|
|
1358
1660
|
|
|
1359
|
-
export { CameraPosition,
|
|
1661
|
+
export { CameraPosition, MediaService, type MediaServicing, type NetworkQualityLevel, type NetworkStatistics, type NetworkStatisticsListener, NonRealtimeQuality, type NonRealtimeResult, type NonRealtimeTask, NonRealtimeTaskError, type NonRealtimeTaskListOptions, type NonRealtimeTaskOptions, type NonRealtimeTaskPage, NonRealtimeTaskStatus, type NonRealtimeWaitOptions, RealtimeConfiguration, RealtimeConnectionState, RealtimeContext, type RealtimeContextInit, type RealtimeLaunchTiming, type RealtimeLaunchTimingListener, RealtimeMediaStream, RealtimeModel, type RealtimeModelName, RealtimeReason, type RealtimeReferenceVideo, RealtimeState, type RealtimeStateListener, RealtimeVideoFormat, RealtimeVideoSampleMethod, 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 XmaxNonRealtimeManaging, type XmaxRealtimeManaging, XmaxRealtimeVideoView, XmaxVideoView, apiBaseURL, defaultCameraVideoFormat, defaultFrameRate, modelDisplayName, supportedRtcProviders };
|