@xmaxai/web-sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +430 -0
- package/dist/VideoContentMode-BXkqM4XG.d.cts +118 -0
- package/dist/VideoContentMode-BXkqM4XG.d.ts +118 -0
- package/dist/chunk-JJWUZ3AW.cjs +7779 -0
- package/dist/chunk-JJWUZ3AW.cjs.map +1 -0
- package/dist/chunk-MJ72WWQX.js +7779 -0
- package/dist/chunk-MJ72WWQX.js.map +1 -0
- package/dist/index.cjs +59 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +888 -0
- package/dist/index.d.ts +888 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +116 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +39 -0
- package/dist/react/index.d.ts +39 -0
- package/dist/react/index.js +116 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
import { R as RealtimeVideoFormat, a as RealtimeVideoTrack, C as CameraPosition, V as VideoContentMode } from './VideoContentMode-BXkqM4XG.js';
|
|
2
|
+
export { b as RealtimeVideoEncoderPreference, c as RealtimeVideoFormatInit } from './VideoContentMode-BXkqM4XG.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SDK 当前支持的实时生成模型。
|
|
6
|
+
*/
|
|
7
|
+
declare enum RealtimeModel {
|
|
8
|
+
/** Xmax X2 Fast 1080P 实时生成模型。 */
|
|
9
|
+
x2_fast_1080p = "x2-fast-1080p"
|
|
10
|
+
}
|
|
11
|
+
interface ModelSize {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
/** 未指定视频规格时,各媒体来源使用的默认帧率。 */
|
|
16
|
+
declare function defaultFrameRate(_model: RealtimeModel): number;
|
|
17
|
+
/** 摄像头采集使用的默认视频规格。 */
|
|
18
|
+
declare function defaultCameraVideoFormat(_model: RealtimeModel): RealtimeVideoFormat;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 定义媒体输入规则与平台媒体能力查询能力。
|
|
22
|
+
*/
|
|
23
|
+
interface MediaServicing {
|
|
24
|
+
/** 校验并保留原始尺寸;Web 插帧不降低回传分辨率。 */
|
|
25
|
+
resolveFrameInterpolationSize(size: ModelSize): ModelSize;
|
|
26
|
+
supportsFrameInterpolation(size: ModelSize): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* 按模型输入规则解析目标尺寸。
|
|
29
|
+
*
|
|
30
|
+
* 分辨率桶非空时必须精确匹配;否则按像素面积上下限等比缩放并对齐到
|
|
31
|
+
* 模型要求的像素倍数。
|
|
32
|
+
*
|
|
33
|
+
* @throws 尺寸无效或不满足模型约束时抛出错误。
|
|
34
|
+
*/
|
|
35
|
+
resolveModelInputSize(size: ModelSize): ModelSize;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 上传完成后返回的已存储文件信息。
|
|
40
|
+
*/
|
|
41
|
+
declare class StoredFile {
|
|
42
|
+
/** 文件的访问地址。 */
|
|
43
|
+
readonly url: string;
|
|
44
|
+
/** 对象存储中的对象键。 */
|
|
45
|
+
readonly objectKey: string;
|
|
46
|
+
/** 对象存储返回的 ETag;未返回时为空。 */
|
|
47
|
+
readonly etag?: string;
|
|
48
|
+
/**
|
|
49
|
+
* 创建已存储文件信息。
|
|
50
|
+
*
|
|
51
|
+
* @param init.url 文件访问地址。
|
|
52
|
+
* @param init.objectKey 对象键。
|
|
53
|
+
* @param init.etag 对象存储返回的 ETag。
|
|
54
|
+
*/
|
|
55
|
+
constructor(init: {
|
|
56
|
+
url: string;
|
|
57
|
+
objectKey: string;
|
|
58
|
+
etag?: string;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** 上传图片的参数。 */
|
|
63
|
+
interface StorageUploadOptions {
|
|
64
|
+
/** 图片数据。 */
|
|
65
|
+
data: Blob | ArrayBuffer | Uint8Array;
|
|
66
|
+
/** 文件名;用于对象键后缀和缺省内容类型推断。 */
|
|
67
|
+
fileName: string;
|
|
68
|
+
/** 图片 MIME 类型;缺省按文件名后缀推断。 */
|
|
69
|
+
contentType?: string;
|
|
70
|
+
/** 上传进度回调(已传字节数、总字节数)。 */
|
|
71
|
+
onProgress?: (transferred: number, total: number) => void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 定义文件存储能力:上传图片到对象存储并返回访问地址。
|
|
75
|
+
*/
|
|
76
|
+
interface StorageServicing {
|
|
77
|
+
/**
|
|
78
|
+
* 上传图片。
|
|
79
|
+
*
|
|
80
|
+
* 从 Xmax 服务获取临时凭证后直传对象存储,返回的地址可用作
|
|
81
|
+
* 实时生成的参考图路径。
|
|
82
|
+
*
|
|
83
|
+
* @returns 已存储文件信息。
|
|
84
|
+
* @throws 参数无效、凭证获取失败或上传失败时抛出错误。
|
|
85
|
+
*/
|
|
86
|
+
uploadImage(options: StorageUploadOptions): Promise<StoredFile>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface FrameInterpolationConfiguration {
|
|
90
|
+
/** 是否请求开启远端插帧,默认 true。不支持时自动播放原视频。 */
|
|
91
|
+
enabled?: boolean;
|
|
92
|
+
/** 显示帧率上限,默认 60;每对源帧最多插入一帧。取值 1–60。 */
|
|
93
|
+
targetFrameRate?: number;
|
|
94
|
+
}
|
|
95
|
+
interface RealtimeConfigurationInit {
|
|
96
|
+
/** 实时生成业务使用的模型。 */
|
|
97
|
+
model: RealtimeModel;
|
|
98
|
+
/**
|
|
99
|
+
* 是否默认开启远端生成画面的插帧。
|
|
100
|
+
* frameInterpolation.enabled 显式设置时优先。
|
|
101
|
+
*/
|
|
102
|
+
isFrameInterpolationEnabled?: boolean;
|
|
103
|
+
frameInterpolation?: FrameInterpolationConfiguration;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 创建实时 Manager 所需的业务配置。
|
|
107
|
+
*/
|
|
108
|
+
declare class RealtimeConfiguration {
|
|
109
|
+
/** 实时生成业务使用的模型。 */
|
|
110
|
+
readonly model: RealtimeModel;
|
|
111
|
+
/** 是否默认请求开启远端生成画面的插帧。 */
|
|
112
|
+
readonly isFrameInterpolationEnabled: boolean;
|
|
113
|
+
readonly frameInterpolation: Readonly<Required<FrameInterpolationConfiguration>>;
|
|
114
|
+
/**
|
|
115
|
+
* 创建实时业务配置。
|
|
116
|
+
*
|
|
117
|
+
* @param init.model 实时生成业务使用的模型。
|
|
118
|
+
* @param init.isFrameInterpolationEnabled 是否默认开启远端生成画面的插帧。
|
|
119
|
+
*/
|
|
120
|
+
constructor(init: RealtimeConfigurationInit);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** TRTC 网络质量等级:未知、极好、良好、一般、差、极差、断网。 */
|
|
124
|
+
type NetworkQualityLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
125
|
+
/** 本端 RTC 连接的网络统计,不依赖远端生成流是否已经到达。 */
|
|
126
|
+
interface NetworkStatistics {
|
|
127
|
+
readonly uplinkQuality?: NetworkQualityLevel;
|
|
128
|
+
/** 所有下行连接的平均网络质量。 */
|
|
129
|
+
readonly downlinkQuality?: NetworkQualityLevel;
|
|
130
|
+
/** 上行连接到 TRTC 云端的往返延迟,单位 ms,不是单程延迟。 */
|
|
131
|
+
readonly uplinkRttMs?: number;
|
|
132
|
+
/** 所有下行连接到 TRTC 云端的平均往返延迟,单位 ms。 */
|
|
133
|
+
readonly downlinkRttMs?: number;
|
|
134
|
+
}
|
|
135
|
+
/** undefined 表示尚无采样或连接已清理。 */
|
|
136
|
+
type NetworkStatisticsListener = (statistics: NetworkStatistics | undefined) => void;
|
|
137
|
+
|
|
138
|
+
interface RealtimeContextInit {
|
|
139
|
+
/** 实时生成使用的文本条件。 */
|
|
140
|
+
prompt: string;
|
|
141
|
+
/** 已上传参考图片的可选远端路径。 */
|
|
142
|
+
referencePath?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 单次实时生成任务的文本和参考资源上下文。
|
|
146
|
+
*/
|
|
147
|
+
declare class RealtimeContext {
|
|
148
|
+
/** 实时生成使用的文本条件。 */
|
|
149
|
+
readonly prompt: string;
|
|
150
|
+
/** 已上传参考图片的可选远端路径。 */
|
|
151
|
+
readonly referencePath?: string;
|
|
152
|
+
/** 创建实时生成条件并规范化文本和参考路径。 */
|
|
153
|
+
constructor(init: RealtimeContextInit);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 实时生成输入/输出的媒体流。
|
|
158
|
+
*/
|
|
159
|
+
declare class RealtimeMediaStream {
|
|
160
|
+
/** 媒体流标识。 */
|
|
161
|
+
readonly id: string;
|
|
162
|
+
/** 媒体流包含的视频轨道。 */
|
|
163
|
+
readonly videoTrack?: RealtimeVideoTrack;
|
|
164
|
+
/**
|
|
165
|
+
* 创建实时媒体流。
|
|
166
|
+
*
|
|
167
|
+
* @param init.id 媒体流标识。
|
|
168
|
+
* @param init.videoTrack 媒体流包含的视频轨道。
|
|
169
|
+
*/
|
|
170
|
+
constructor(init: {
|
|
171
|
+
id: string;
|
|
172
|
+
videoTrack?: RealtimeVideoTrack;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* SDK 向接入方暴露的统一错误码。
|
|
178
|
+
*/
|
|
179
|
+
declare enum XmaxErrorCode {
|
|
180
|
+
/** API Key 未配置或为空。 */
|
|
181
|
+
invalidAPIKey = "INVALID_API_KEY",
|
|
182
|
+
/** 调用参数、配置或当前生命周期状态不符合操作要求。 */
|
|
183
|
+
invalidConfiguration = "INVALID_CONFIGURATION",
|
|
184
|
+
/** SDK 内部发生无法归类的非预期错误。 */
|
|
185
|
+
internalError = "INTERNAL_ERROR",
|
|
186
|
+
/** 网络不可用、连接失败或 HTTP 请求无法完成。 */
|
|
187
|
+
networkError = "NETWORK_ERROR",
|
|
188
|
+
/** Xmax API 返回业务失败,或者响应数据无法正确解析。 */
|
|
189
|
+
apiError = "API_ERROR",
|
|
190
|
+
/** 实时生成会话数据缺失、会话关闭或心跳状态异常。 */
|
|
191
|
+
sessionError = "SESSION_ERROR",
|
|
192
|
+
/** RTC Engine、房间、媒体传输或渲染绑定发生错误。 */
|
|
193
|
+
rtcError = "RTC_ERROR",
|
|
194
|
+
/** 本地媒体读取、解码、同步或帧处理发生错误。 */
|
|
195
|
+
mediaError = "MEDIA_ERROR",
|
|
196
|
+
/** 当前系统、设备或视频规格不支持远端视频插帧。 */
|
|
197
|
+
frameInterpolationUnsupported = "FRAME_INTERPOLATION_UNSUPPORTED",
|
|
198
|
+
/** 接入方未授予相机权限。 */
|
|
199
|
+
cameraPermissionDenied = "CAMERA_PERMISSION_DENIED",
|
|
200
|
+
/** 启动相机在限定时间内未获得足够明亮且稳定的画面,未发布视频。 */
|
|
201
|
+
cameraExposureTimeout = "CAMERA_EXPOSURE_TIMEOUT",
|
|
202
|
+
/** 接入方未授予麦克风权限。 */
|
|
203
|
+
microphonePermissionDenied = "MICROPHONE_PERMISSION_DENIED",
|
|
204
|
+
/** 文件或二进制数据上传失败。 */
|
|
205
|
+
uploadError = "UPLOAD_ERROR",
|
|
206
|
+
/** 远端文件下载失败。 */
|
|
207
|
+
downloadError = "DOWNLOAD_ERROR",
|
|
208
|
+
/** 图片未通过内容安全检查。 */
|
|
209
|
+
unsafeImage = "UNSAFE_IMAGE",
|
|
210
|
+
/** 操作因生命周期切换或接入方主动终止而正常取消。 */
|
|
211
|
+
cancelled = "CANCELLED",
|
|
212
|
+
/** 等待连接、房间事件或生成结果超过规定时间。 */
|
|
213
|
+
timeout = "TIMEOUT"
|
|
214
|
+
}
|
|
215
|
+
/** SDK 内部组件上报统一错误时使用的监听器。 */
|
|
216
|
+
type XmaxErrorListener = (error: XmaxError) => void;
|
|
217
|
+
/**
|
|
218
|
+
* 表示 SDK 抛出或回调给接入方的统一错误。
|
|
219
|
+
*/
|
|
220
|
+
declare class XmaxError extends Error {
|
|
221
|
+
/** SDK 统一错误码。 */
|
|
222
|
+
readonly code: XmaxErrorCode;
|
|
223
|
+
/** Xmax API 返回的业务错误码;非 API 业务错误时为空。 */
|
|
224
|
+
readonly apiCode?: number;
|
|
225
|
+
/** HTTP 响应状态码;请求未获得响应时为空。 */
|
|
226
|
+
readonly httpStatus?: number;
|
|
227
|
+
/**
|
|
228
|
+
* 创建 SDK 错误。
|
|
229
|
+
*
|
|
230
|
+
* @param code SDK 统一错误码。
|
|
231
|
+
* @param message 面向接入方的可读错误说明。
|
|
232
|
+
* @param options Xmax API 业务错误码与 HTTP 状态码(可选)。
|
|
233
|
+
*/
|
|
234
|
+
constructor(code: XmaxErrorCode, message: string, options?: {
|
|
235
|
+
apiCode?: number;
|
|
236
|
+
httpStatus?: number;
|
|
237
|
+
});
|
|
238
|
+
/**
|
|
239
|
+
* 将未知错误转换为 SDK 内部错误,已有 `XmaxError` 原样返回。
|
|
240
|
+
*
|
|
241
|
+
* @param error 待转换的错误。
|
|
242
|
+
* @returns 可向接入方抛出或回调的统一错误。
|
|
243
|
+
*/
|
|
244
|
+
static from(error: unknown): XmaxError;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 实时业务连接状态。
|
|
249
|
+
*/
|
|
250
|
+
declare enum RealtimeConnectionState {
|
|
251
|
+
/** 没有可用的本地媒体流。 */
|
|
252
|
+
idle = "Idle",
|
|
253
|
+
/** 正在准备本地媒体流;摄像头还需等待有效帧和预览视图绑定。 */
|
|
254
|
+
preparing = "Preparing",
|
|
255
|
+
/** 本地媒体流已就绪,可以预览、连接和生成。 */
|
|
256
|
+
ready = "Ready",
|
|
257
|
+
/** 正在创建 Session、加入 Room 并发布本地流。 */
|
|
258
|
+
connecting = "Connecting",
|
|
259
|
+
/** 实时连接已建立,当前没有生成任务。 */
|
|
260
|
+
connected = "Connected",
|
|
261
|
+
/** 实时连接已建立且生成任务正在运行。 */
|
|
262
|
+
generating = "Generating",
|
|
263
|
+
/** 正在清理生成、Room 和 Session 资源。 */
|
|
264
|
+
disconnecting = "Disconnecting"
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* 进入当前实时状态的原因。
|
|
268
|
+
*/
|
|
269
|
+
type RealtimeReason = {
|
|
270
|
+
kind: "normal";
|
|
271
|
+
} | {
|
|
272
|
+
kind: "orientationChanged";
|
|
273
|
+
} | {
|
|
274
|
+
kind: "failure";
|
|
275
|
+
error: XmaxError;
|
|
276
|
+
};
|
|
277
|
+
declare const RealtimeReason: {
|
|
278
|
+
normal: RealtimeReason;
|
|
279
|
+
orientationChanged: RealtimeReason;
|
|
280
|
+
failure(error: XmaxError): RealtimeReason;
|
|
281
|
+
};
|
|
282
|
+
interface RealtimeStateInit {
|
|
283
|
+
connectionState: RealtimeConnectionState;
|
|
284
|
+
sessionID?: string;
|
|
285
|
+
taskID?: string;
|
|
286
|
+
reason?: RealtimeReason;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* 实时业务当前状态快照。
|
|
290
|
+
*/
|
|
291
|
+
declare class RealtimeState {
|
|
292
|
+
/** 当前连接生命周期状态。 */
|
|
293
|
+
readonly connectionState: RealtimeConnectionState;
|
|
294
|
+
/** 当前或最近一次实时 Session 标识。 */
|
|
295
|
+
readonly sessionID?: string;
|
|
296
|
+
/** 当前生成任务标识。 */
|
|
297
|
+
readonly taskID?: string;
|
|
298
|
+
/** 进入当前状态的原因;正常开始新的操作时清空。 */
|
|
299
|
+
readonly reason?: RealtimeReason;
|
|
300
|
+
/**
|
|
301
|
+
* 创建实时状态快照。
|
|
302
|
+
*
|
|
303
|
+
* @param init.connectionState 当前连接生命周期状态。
|
|
304
|
+
* @param init.sessionID 当前或最近一次实时 Session 标识。
|
|
305
|
+
* @param init.taskID 当前生成任务标识。
|
|
306
|
+
* @param init.reason 状态变化原因,默认无。
|
|
307
|
+
*/
|
|
308
|
+
constructor(init: RealtimeStateInit);
|
|
309
|
+
/**
|
|
310
|
+
* 判断当前状态与另一状态是否等价:连接状态、会话、任务与原因种类一致。
|
|
311
|
+
*
|
|
312
|
+
* @param other 待比较的状态。
|
|
313
|
+
*/
|
|
314
|
+
equals(other: RealtimeState): boolean;
|
|
315
|
+
}
|
|
316
|
+
/** 实时状态监听器。 */
|
|
317
|
+
type RealtimeStateListener = (state: RealtimeState) => void;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 一次相机启动的耗时快照,单位为毫秒;undefined 表示该阶段尚未完成。
|
|
321
|
+
* 新一轮打开摄像头时重置;失败、关闭或断开后保留已完成的值。
|
|
322
|
+
* 仅预览时不产生首帧和总耗时;预览后手动启动生成的等待计入总耗时。
|
|
323
|
+
*/
|
|
324
|
+
interface RealtimeLaunchTiming {
|
|
325
|
+
/** 开始打开摄像头到相机流创建完成(包含权限等待)。 */
|
|
326
|
+
readonly cameraMs?: number;
|
|
327
|
+
/** 开始创建会话到 RTC 进房并发布本地流完成。 */
|
|
328
|
+
readonly connectionMs?: number;
|
|
329
|
+
/** 开始发送生成信令到 SDK 远端视图首次呈现视频帧。 */
|
|
330
|
+
readonly firstFrameMs?: number;
|
|
331
|
+
/** 开始打开摄像头到 SDK 远端视图首次呈现视频帧。 */
|
|
332
|
+
readonly totalMs?: number;
|
|
333
|
+
}
|
|
334
|
+
/** 阶段完成时提供完整快照;不支持帧回调的浏览器以 playing 近似首帧。 */
|
|
335
|
+
type RealtimeLaunchTimingListener = (timing: RealtimeLaunchTiming) => void;
|
|
336
|
+
|
|
337
|
+
/** 视频流实际运行统计;缺失或无效指标为 undefined。 */
|
|
338
|
+
interface VideoStatistics {
|
|
339
|
+
readonly width?: number;
|
|
340
|
+
readonly height?: number;
|
|
341
|
+
/** 实际帧率,单位 fps。 */
|
|
342
|
+
readonly frameRate?: number;
|
|
343
|
+
/** 实际码率,单位 kbps。 */
|
|
344
|
+
readonly bitrateKbps?: number;
|
|
345
|
+
}
|
|
346
|
+
/** undefined 表示当前没有可用统计(尚未发布、断开或停止)。 */
|
|
347
|
+
type VideoStatisticsListener = (statistics: VideoStatistics | undefined) => void;
|
|
348
|
+
/** 一路远端主视频流的接收统计。 */
|
|
349
|
+
interface RemoteVideoStatistics extends VideoStatistics {
|
|
350
|
+
readonly userID: string;
|
|
351
|
+
/** 本端 SDK 到 TRTC 云端的往返延迟,单位 ms;不是与远端用户之间的 RTT。 */
|
|
352
|
+
readonly rttMs?: number;
|
|
353
|
+
/** 本端 SDK 到 TRTC 云端的上行丢包率,单位 %,不是结果流的发送端丢包率。 */
|
|
354
|
+
readonly uplinkLossPercent?: number;
|
|
355
|
+
/** TRTC 云端到本端 SDK 的下行丢包率,单位 %。 */
|
|
356
|
+
readonly downlinkLossPercent?: number;
|
|
357
|
+
/** 当前远端视频流的播放缓冲延迟,单位 ms。 */
|
|
358
|
+
readonly jitterBufferDelayMs?: number;
|
|
359
|
+
/** TRTC 媒体端到端延迟估算值,单位 ms;不代表完整 AI 处理链路耗时。 */
|
|
360
|
+
readonly endToEndDelayMs?: number;
|
|
361
|
+
}
|
|
362
|
+
/** undefined 表示当前结果流没有统计或已被清理。 */
|
|
363
|
+
type RemoteVideoStatisticsListener = (statistics: RemoteVideoStatistics | undefined) => void;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* 定义 SDK 对接入方提供的实时媒体与生成控制能力。
|
|
367
|
+
*/
|
|
368
|
+
interface XmaxRealtimeManaging {
|
|
369
|
+
/** 实时能力配置。 */
|
|
370
|
+
readonly options: RealtimeConfiguration;
|
|
371
|
+
/** 当前实时连接与生成状态。 */
|
|
372
|
+
readonly currentState: RealtimeState;
|
|
373
|
+
/** 插帧功能开关;不随首帧等待、跳帧或视图挂载变化,不支持或故障降级时关闭。 */
|
|
374
|
+
readonly isFrameInterpolationEnabled: boolean;
|
|
375
|
+
/** 切换客户端插帧,不改变回传分辨率或重启任务。不支持时抛错且保留配置。 */
|
|
376
|
+
setFrameInterpolationEnabled(enabled: boolean): Promise<void>;
|
|
377
|
+
/** 当前本地媒体预览音量,取值范围为 `0...1`。 */
|
|
378
|
+
readonly localAudioVolume: number;
|
|
379
|
+
/** 当前远端生成音频播放音量,取值范围为 `0...1`。 */
|
|
380
|
+
readonly remoteAudioVolume: number;
|
|
381
|
+
/**
|
|
382
|
+
* 设置实时状态监听器。
|
|
383
|
+
* @param listener 实时状态回调;传入 `undefined` 时清除监听器。
|
|
384
|
+
*/
|
|
385
|
+
setStateListener(listener?: RealtimeStateListener): Promise<void>;
|
|
386
|
+
/**
|
|
387
|
+
* 监听 TRTC 上下行网络质量和 RTT;立即回放最新快照,断开后回调 undefined。
|
|
388
|
+
* 独立于日志和远端生成流;传入 undefined 取消监听,监听器异常不影响主流程。
|
|
389
|
+
*/
|
|
390
|
+
setNetworkStatisticsListener(listener?: NetworkStatisticsListener): Promise<void>;
|
|
391
|
+
/**
|
|
392
|
+
* 监听启动耗时;立即回放当前快照,每完成一个阶段再次回调。
|
|
393
|
+
* 新一轮打开摄像头时重置;失败或终止后冻结,更新生成条件不重置。
|
|
394
|
+
* 首帧统计需要将远端轨道绑定到 SDK 视频视图,且不会阻塞 startGeneration。
|
|
395
|
+
* 传入 undefined 清除监听器;监听器异常不影响生成流程。
|
|
396
|
+
*/
|
|
397
|
+
setLaunchTimingListener(listener?: RealtimeLaunchTimingListener): Promise<void>;
|
|
398
|
+
/**
|
|
399
|
+
* 监听本地主视频流实际分辨率、帧率及码率(kbps),独立于日志开关。
|
|
400
|
+
* 设置后立即回放最新快照;未取得数据或停止/断开时回调 undefined。
|
|
401
|
+
* 传入 undefined 取消监听;监听器异常不影响生成流程。
|
|
402
|
+
*/
|
|
403
|
+
setLocalVideoStatisticsListener(listener?: VideoStatisticsListener): Promise<void>;
|
|
404
|
+
/**
|
|
405
|
+
* 监听当前生成结果流的分辨率、帧率、码率、云端 RTT 和媒体 E2E 估算值。
|
|
406
|
+
* 独立于日志开关;立即回放最新快照,流消失或断开时回调 undefined。
|
|
407
|
+
* 传入 undefined 取消监听;监听器异常不影响生成流程。
|
|
408
|
+
*/
|
|
409
|
+
setRemoteVideoStatisticsListener(listener?: RemoteVideoStatisticsListener): Promise<void>;
|
|
410
|
+
/**
|
|
411
|
+
* 设置本地媒体预览音量。
|
|
412
|
+
* @throws 音量超出有效范围时抛出错误。
|
|
413
|
+
*/
|
|
414
|
+
setLocalAudioVolume(volume: number): Promise<void>;
|
|
415
|
+
/**
|
|
416
|
+
* 设置远端生成音频播放音量。
|
|
417
|
+
* 尚未连接或订阅远端流时保存配置,并在远端音频开始播放前应用。
|
|
418
|
+
* @throws 音量超出有效范围或 RTC 音量配置失败时抛出错误。
|
|
419
|
+
*/
|
|
420
|
+
setRemoteAudioVolume(volume: number): Promise<void>;
|
|
421
|
+
/**
|
|
422
|
+
* 创建本地相机流并开始预览。
|
|
423
|
+
*
|
|
424
|
+
* 将返回的轨道绑定到预览视图;收到有效帧且视图已绑定后进入 `ready`。
|
|
425
|
+
*
|
|
426
|
+
* @returns 包含本地相机视频轨道的媒体流。
|
|
427
|
+
* @throws 模型不支持相机输入、配置无效、权限或采集启动失败时抛出错误。
|
|
428
|
+
*/
|
|
429
|
+
createLocalCameraStream(options: {
|
|
430
|
+
videoFormat: RealtimeVideoFormat;
|
|
431
|
+
position: CameraPosition;
|
|
432
|
+
useMicrophone: boolean;
|
|
433
|
+
}): Promise<RealtimeMediaStream>;
|
|
434
|
+
/** 停止本地相机流并释放本地预览与 RTC 资源。 */
|
|
435
|
+
stopLocalCameraStream(): Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* 切换前后置摄像头。
|
|
438
|
+
*
|
|
439
|
+
* 生成过程中调用时,SDK 会停止当前生成、切换摄像头,并使用缓存的生成
|
|
440
|
+
* 条件恢复生成;RTC 连接保持不变。连接或生成正在启动时不可切换。
|
|
441
|
+
*
|
|
442
|
+
* @returns 复用原视频轨道并更新摄像头位置后的本地媒体流。
|
|
443
|
+
*/
|
|
444
|
+
switchCamera(): Promise<RealtimeMediaStream>;
|
|
445
|
+
/**
|
|
446
|
+
* 使用当前 Manager 创建的本地流建立实时连接。
|
|
447
|
+
*
|
|
448
|
+
* 创建实时会话、加入 RTC 房间并发布本地流,成功后启动会话心跳。
|
|
449
|
+
* 发布前并行检查相机亮度稳定性;5 秒内未通过检查时抛出
|
|
450
|
+
* `cameraExposureTimeout`,不发布媒体,接入方可改善光照后重试。
|
|
451
|
+
* 返回的远端媒体流在生成开始后承载远端生成画面。
|
|
452
|
+
*
|
|
453
|
+
* @param localStream 由 `createLocalCameraStream` 创建的本地媒体流。
|
|
454
|
+
* @returns 远端生成结果占位的媒体流。
|
|
455
|
+
* @throws 本地流不属于当前 Manager、已有活动连接、会话创建或进房
|
|
456
|
+
* 发布失败时抛出错误;失败时自动释放连接资源并恢复本地预览。
|
|
457
|
+
*/
|
|
458
|
+
connect(localStream: RealtimeMediaStream): Promise<RealtimeMediaStream>;
|
|
459
|
+
/** 断开实时连接并保留当前本地媒体预览。 */
|
|
460
|
+
disconnect(): Promise<void>;
|
|
461
|
+
/**
|
|
462
|
+
* 关闭当前实时生命周期并释放连接、本地媒体和 RTC Engine。
|
|
463
|
+
* 关闭期间重复调用会等待同一个释放任务;关闭完成后仍可重新创建本地流。
|
|
464
|
+
*/
|
|
465
|
+
close(): Promise<void>;
|
|
466
|
+
/**
|
|
467
|
+
* 按需建立连接并开始生成。
|
|
468
|
+
*
|
|
469
|
+
* 尚未连接时先建立实时连接;已在生成时仅更新生成条件,不重启生成。
|
|
470
|
+
* 首次生成必须提供条件上下文,之后缺省时复用最近一次缓存的上下文。
|
|
471
|
+
*
|
|
472
|
+
* @param options.localStream 由 `createLocalCameraStream` 创建的本地媒体流。
|
|
473
|
+
* @param options.context 本次生成使用的条件上下文;缺省时复用缓存。
|
|
474
|
+
* @returns 承载远端生成画面的媒体流。
|
|
475
|
+
* @throws 本地流不属于当前 Manager、缺少可用的条件上下文、信令发送
|
|
476
|
+
* 或生成确认失败时抛出错误;失败时自动停止生成任务并释放连接资源。
|
|
477
|
+
*/
|
|
478
|
+
startGeneration(options: {
|
|
479
|
+
localStream: RealtimeMediaStream;
|
|
480
|
+
context?: RealtimeContext;
|
|
481
|
+
}): Promise<RealtimeMediaStream>;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Xmax 服务环境。
|
|
486
|
+
*/
|
|
487
|
+
declare enum XmaxEnvironment {
|
|
488
|
+
/** 国内环境。 */
|
|
489
|
+
china = "china",
|
|
490
|
+
/** 海外环境。 */
|
|
491
|
+
global = "global"
|
|
492
|
+
}
|
|
493
|
+
/** 环境对应的 Xmax API Base URL。 */
|
|
494
|
+
declare function apiBaseURL(environment: XmaxEnvironment): string;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* 控制 XmaxSDK 输出的日志类型(位掩码,可组合)。
|
|
498
|
+
*/
|
|
499
|
+
declare enum XmaxLoggerOption {
|
|
500
|
+
none = 0,
|
|
501
|
+
/** Room、API、Realtime、Storage 等业务运行日志。 */
|
|
502
|
+
business = 1,
|
|
503
|
+
/** RTC 网络质量和音视频运行统计,输出到 console.info。 */
|
|
504
|
+
performance = 2,
|
|
505
|
+
/** 输出全部 XmaxSDK 日志。 */
|
|
506
|
+
all = 3
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* 统一输出带 Xmax 前缀和类别的控制台日志。
|
|
510
|
+
*
|
|
511
|
+
* 调用方不得传入 API Key、Token、Secret、Authorization 或完整敏感响应。
|
|
512
|
+
*/
|
|
513
|
+
declare class XmaxLogger {
|
|
514
|
+
static readonly realtime: XmaxLogger;
|
|
515
|
+
static readonly rtc: XmaxLogger;
|
|
516
|
+
static readonly media: XmaxLogger;
|
|
517
|
+
static readonly api: XmaxLogger;
|
|
518
|
+
static readonly storage: XmaxLogger;
|
|
519
|
+
static readonly room: XmaxLogger;
|
|
520
|
+
static readonly stream: XmaxLogger;
|
|
521
|
+
static readonly render: XmaxLogger;
|
|
522
|
+
static readonly interaction: XmaxLogger;
|
|
523
|
+
static readonly permission: XmaxLogger;
|
|
524
|
+
private readonly category;
|
|
525
|
+
private constructor();
|
|
526
|
+
/**
|
|
527
|
+
* 更新 SDK 全局日志选项和细项语言,后一次配置覆盖前一次。
|
|
528
|
+
*
|
|
529
|
+
* @param options 输出的日志类型位掩码。
|
|
530
|
+
* @param environment 服务环境,决定日志细项语言(国内中文,海外英文)。
|
|
531
|
+
*/
|
|
532
|
+
static configure(options: XmaxLoggerOption, environment?: XmaxEnvironment): void;
|
|
533
|
+
/** 选择日志细项文案;日志标题保持原有中英双语。 */
|
|
534
|
+
static localized(chinese: string, english: string): string;
|
|
535
|
+
/** 判断指定日志类型是否已开启。 */
|
|
536
|
+
static isEnabled(option: XmaxLoggerOption): boolean;
|
|
537
|
+
/** 输出调试日志。 */
|
|
538
|
+
debug(message: () => string, option?: XmaxLoggerOption): void;
|
|
539
|
+
/** 输出信息日志。 */
|
|
540
|
+
info(message: () => string, option?: XmaxLoggerOption): void;
|
|
541
|
+
/** 输出警告日志。 */
|
|
542
|
+
warning(message: () => string, option?: XmaxLoggerOption): void;
|
|
543
|
+
/** 输出错误日志。 */
|
|
544
|
+
error(message: () => string, option?: XmaxLoggerOption): void;
|
|
545
|
+
/** 按日志类型开关输出到控制台;未开启时不求值日志内容。 */
|
|
546
|
+
private log;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
interface XmaxConfigurationInit {
|
|
550
|
+
/** 调用 Xmax 服务使用的 API Key。 */
|
|
551
|
+
apiKey: string;
|
|
552
|
+
/** SDK 连接的服务环境;默认为国内环境。 */
|
|
553
|
+
environment?: XmaxEnvironment;
|
|
554
|
+
/** SDK 输出的日志类型;默认为不输出日志。 */
|
|
555
|
+
loggerOptions?: XmaxLoggerOption;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* SDK 全局配置。
|
|
559
|
+
*/
|
|
560
|
+
declare class XmaxConfiguration {
|
|
561
|
+
/** 调用 Xmax 服务使用的 API Key。 */
|
|
562
|
+
readonly apiKey: string;
|
|
563
|
+
/** SDK 连接的服务环境,同时决定日志细项语言:国内为中文,海外为英文。 */
|
|
564
|
+
readonly environment: XmaxEnvironment;
|
|
565
|
+
/** SDK 输出的日志类型;默认为不输出日志。 */
|
|
566
|
+
readonly loggerOptions: XmaxLoggerOption;
|
|
567
|
+
/**
|
|
568
|
+
* 创建 SDK 全局配置。
|
|
569
|
+
*
|
|
570
|
+
* @param init.apiKey 调用 Xmax 服务使用的 API Key。
|
|
571
|
+
* @param init.environment SDK 连接的服务环境;默认为国内环境。
|
|
572
|
+
* @param init.loggerOptions SDK 输出的日志类型;默认为空。
|
|
573
|
+
*/
|
|
574
|
+
constructor(init: XmaxConfigurationInit);
|
|
575
|
+
/**
|
|
576
|
+
* 校验全局配置。
|
|
577
|
+
* @throws API Key 为空时抛出 `XmaxError`。
|
|
578
|
+
*/
|
|
579
|
+
validate(): void;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* SDK 的统一入口,负责创建实时和媒体服务组件。
|
|
584
|
+
*/
|
|
585
|
+
declare class XmaxClient {
|
|
586
|
+
/** 客户端使用的全局配置。 */
|
|
587
|
+
readonly configuration: XmaxConfiguration;
|
|
588
|
+
private readonly apiService;
|
|
589
|
+
/**
|
|
590
|
+
* 创建 SDK 客户端。
|
|
591
|
+
*
|
|
592
|
+
* 本地相机预览不依赖 API Key 校验;连接与生成等涉及服务端的操作
|
|
593
|
+
* 在实际调用时校验 API Key。
|
|
594
|
+
*/
|
|
595
|
+
constructor(configuration: XmaxConfiguration);
|
|
596
|
+
/**
|
|
597
|
+
* 创建实时媒体 Manager。
|
|
598
|
+
*
|
|
599
|
+
* @param options 实时生成模型等业务配置。
|
|
600
|
+
* @returns 可用于本地相机预览、实时连接与生成的实时 Manager。
|
|
601
|
+
*/
|
|
602
|
+
createRealtimeManager(options: RealtimeConfiguration): XmaxRealtimeManaging;
|
|
603
|
+
/**
|
|
604
|
+
* 创建媒体处理与能力查询 Service。
|
|
605
|
+
*
|
|
606
|
+
* @param model 媒体输入规则使用的模型,默认为 `x2-fast-1080p`。
|
|
607
|
+
*/
|
|
608
|
+
createMediaService(model?: RealtimeModel): MediaServicing;
|
|
609
|
+
/**
|
|
610
|
+
* 创建文件存储 Service。
|
|
611
|
+
*
|
|
612
|
+
* @returns 可上传图片到对象存储的存储 Service,返回地址可用作参考图路径。
|
|
613
|
+
*/
|
|
614
|
+
createStorageService(): StorageServicing;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* 提供模型输入尺寸和平台媒体能力相关的业务规则。
|
|
619
|
+
* 模型输入尺寸与远端插帧能力。
|
|
620
|
+
*/
|
|
621
|
+
declare class MediaService implements MediaServicing {
|
|
622
|
+
readonly model: RealtimeModel;
|
|
623
|
+
/**
|
|
624
|
+
* 创建媒体服务。
|
|
625
|
+
*
|
|
626
|
+
* @param model 媒体输入规则使用的模型,默认为 `x2-fast-1080p`。
|
|
627
|
+
*/
|
|
628
|
+
constructor(model?: RealtimeModel);
|
|
629
|
+
/** Web 插帧保留原始尺寸;/16 对齐由 GPU 内部补边处理,不缩小回传视频。 */
|
|
630
|
+
resolveFrameInterpolationSize(size: ModelSize): ModelSize;
|
|
631
|
+
/** WebGPU 适配器探测是异步的;实际性能和运行状态由渲染管线判断。 */
|
|
632
|
+
supportsFrameInterpolation(size: ModelSize): Promise<boolean>;
|
|
633
|
+
resolveModelInputSize(size: ModelSize): ModelSize;
|
|
634
|
+
/** 在对齐网格上选择满足面积限制且最接近目标的尺寸。 */
|
|
635
|
+
private boundedAlignedSize;
|
|
636
|
+
/** 校验尺寸为有限正数,并归一化为不小于 1 的整数。 */
|
|
637
|
+
private validatedSize;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Xmax API 支持的 HTTP 请求方法。
|
|
642
|
+
*/
|
|
643
|
+
declare enum ApiMethod {
|
|
644
|
+
get = "GET",
|
|
645
|
+
post = "POST",
|
|
646
|
+
put = "PUT",
|
|
647
|
+
delete = "DELETE"
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* 定义 Xmax API 的基础请求能力。
|
|
651
|
+
*
|
|
652
|
+
* 响应统一按 `{ success, code, message, data }` 信封解析,
|
|
653
|
+
* 各方法返回信封中的 `data` 字段。
|
|
654
|
+
*/
|
|
655
|
+
interface ApiServicing {
|
|
656
|
+
/**
|
|
657
|
+
* 发送请求并返回统一响应中的数据。
|
|
658
|
+
*
|
|
659
|
+
* @param method HTTP 请求方法。
|
|
660
|
+
* @param path 相对 Base URL 的请求路径。
|
|
661
|
+
* @param body JSON 请求体;无请求体时省略。
|
|
662
|
+
* @returns 统一响应中的 `data` 字段。
|
|
663
|
+
* @throws 配置无效、网络失败、业务失败或响应无法解析时抛出错误。
|
|
664
|
+
*/
|
|
665
|
+
request<T>(method: ApiMethod, path: string, body?: unknown): Promise<T>;
|
|
666
|
+
/** 发送 GET 请求。 */
|
|
667
|
+
get<T>(path: string): Promise<T>;
|
|
668
|
+
/** 发送 POST 请求。 */
|
|
669
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
670
|
+
/** 发送 PUT 请求。 */
|
|
671
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
672
|
+
/** 发送 DELETE 请求。 */
|
|
673
|
+
delete<T>(path: string): Promise<T>;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** 解析后的临时存储配置。 */
|
|
677
|
+
interface TemporaryStorageConfiguration {
|
|
678
|
+
bucket: string;
|
|
679
|
+
region: string;
|
|
680
|
+
endpoint?: string;
|
|
681
|
+
prefix: string;
|
|
682
|
+
credentials: {
|
|
683
|
+
accessKeyID: string;
|
|
684
|
+
secretAccessKey: string;
|
|
685
|
+
sessionToken: string;
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
/** 对象存储直传客户端需要的最小接口。 */
|
|
689
|
+
interface StorageObjectClient {
|
|
690
|
+
putObject(params: {
|
|
691
|
+
Bucket: string;
|
|
692
|
+
Region: string;
|
|
693
|
+
Key: string;
|
|
694
|
+
Body: Blob;
|
|
695
|
+
ContentType: string;
|
|
696
|
+
onProgress?: (info: {
|
|
697
|
+
loaded: number;
|
|
698
|
+
total: number;
|
|
699
|
+
}) => void;
|
|
700
|
+
}, callback: (error: {
|
|
701
|
+
message?: string;
|
|
702
|
+
} | null, data?: {
|
|
703
|
+
Location?: string;
|
|
704
|
+
ETag?: string;
|
|
705
|
+
}) => void): void;
|
|
706
|
+
}
|
|
707
|
+
/** 对象存储客户端工厂;生产实现按临时凭证创建 COS 客户端。 */
|
|
708
|
+
type StorageObjectClientFactory = (configuration: TemporaryStorageConfiguration) => Promise<StorageObjectClient>;
|
|
709
|
+
interface StorageServiceOptions {
|
|
710
|
+
/** Xmax API 请求组件。 */
|
|
711
|
+
apiService: ApiServicing;
|
|
712
|
+
/** 对象存储客户端工厂(可替换,测试用)。 */
|
|
713
|
+
clientFactory?: StorageObjectClientFactory;
|
|
714
|
+
/** 时间来源(可替换,测试用)。 */
|
|
715
|
+
dateGenerator?: () => Date;
|
|
716
|
+
/** 标识来源(可替换,测试用)。 */
|
|
717
|
+
identifierGenerator?: () => string;
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* 管理文件上传到对象存储。
|
|
721
|
+
*
|
|
722
|
+
* 上传直传不经过 Xmax 服务中转:先通过 `GET /cos/sts` 获取临时凭证,
|
|
723
|
+
* 再用临时凭证创建 COS 客户端直传;访问地址按 `Location`、自定义
|
|
724
|
+
* endpoint 或默认 COS 域名依次解析。
|
|
725
|
+
*/
|
|
726
|
+
declare class StorageService implements StorageServicing {
|
|
727
|
+
private readonly apiService;
|
|
728
|
+
private readonly clientFactory;
|
|
729
|
+
private readonly dateGenerator;
|
|
730
|
+
private readonly identifierGenerator;
|
|
731
|
+
/**
|
|
732
|
+
* 创建存储 Service。
|
|
733
|
+
*
|
|
734
|
+
* @param options.apiService Xmax API 请求组件。
|
|
735
|
+
* @param options.clientFactory 对象存储客户端工厂(可替换,测试用)。
|
|
736
|
+
* @param options.dateGenerator 时间来源(可替换,测试用)。
|
|
737
|
+
* @param options.identifierGenerator 标识来源(可替换,测试用)。
|
|
738
|
+
*/
|
|
739
|
+
constructor(options: StorageServiceOptions);
|
|
740
|
+
/** 上传图片并返回访问地址。 */
|
|
741
|
+
uploadImage(options: StorageUploadOptions): Promise<StoredFile>;
|
|
742
|
+
/** 获取临时存储配置;字段不完整时抛出 API 错误。 */
|
|
743
|
+
private fetchStorageConfiguration;
|
|
744
|
+
/** 生成对象键:`${prefix}${毫秒时间戳}_${标识}_${文件名}`。 */
|
|
745
|
+
private makeObjectKey;
|
|
746
|
+
/** 生产环境 COS 客户端工厂:动态加载 cos-js-sdk-v5 并按临时凭证创建客户端。 */
|
|
747
|
+
private static cosClientFactory;
|
|
748
|
+
/** 调用对象存储上传并包装为 Promise。 */
|
|
749
|
+
private static putObject;
|
|
750
|
+
/**
|
|
751
|
+
* 解析对象访问地址:优先使用上传返回的 `Location`(补全协议),
|
|
752
|
+
* 其次拼接自定义 endpoint,最后回退到默认 COS 域名。
|
|
753
|
+
*/
|
|
754
|
+
private static resolveObjectURL;
|
|
755
|
+
/** 统一构造上传体。 */
|
|
756
|
+
private static makeBody;
|
|
757
|
+
/** 校验文件名非空且不包含路径分隔符。 */
|
|
758
|
+
private static validateFileName;
|
|
759
|
+
/** 按文件名后缀推断内容类型。 */
|
|
760
|
+
private static inferContentType;
|
|
761
|
+
/** 格式化字节数用于日志输出。 */
|
|
762
|
+
private static formatByteCount;
|
|
763
|
+
/** 归一化可选字符串:去除首尾空白后为空时返回 `undefined`。 */
|
|
764
|
+
private static nonEmpty;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
interface RemoteFrameInterpolationOptions {
|
|
768
|
+
size: ModelSize;
|
|
769
|
+
targetFrameRate: number;
|
|
770
|
+
onActiveChange?: (active: boolean) => void;
|
|
771
|
+
onFailure: (error: unknown) => void;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* 单轨视频视图(框架无关)。
|
|
776
|
+
*
|
|
777
|
+
* 通过 `attach(to:)` 挂载到任意容器元素;设置 `track` 后自动渲染。
|
|
778
|
+
* 轨道注册了渲染绑定时走绑定管线,否则按 `mediaStreamTrack` 直接渲染。
|
|
779
|
+
*/
|
|
780
|
+
declare class XmaxVideoView {
|
|
781
|
+
/** 视图根元素(div,内含一个 video 元素)。 */
|
|
782
|
+
readonly element: HTMLDivElement;
|
|
783
|
+
/** @internal 渲染视频帧的元素,供绑定管线使用。 */
|
|
784
|
+
readonly videoElement: HTMLVideoElement;
|
|
785
|
+
/** 首帧实际提交显示时调用(一次性;换轨后重新武装)。 */
|
|
786
|
+
frameDisplayHandler?: () => void;
|
|
787
|
+
private currentTrack?;
|
|
788
|
+
private contentMode;
|
|
789
|
+
private mirrored;
|
|
790
|
+
private hasNotifiedFrameDisplay;
|
|
791
|
+
private onPlaying?;
|
|
792
|
+
private videoFrameCallbackID?;
|
|
793
|
+
private frameNotificationSequence;
|
|
794
|
+
private interpolationOptions?;
|
|
795
|
+
private interpolationPipeline?;
|
|
796
|
+
private interpolationCanvas?;
|
|
797
|
+
private detached;
|
|
798
|
+
/**
|
|
799
|
+
* 创建单轨视频视图。
|
|
800
|
+
*
|
|
801
|
+
* @param options.videoContentMode 视频内容显示模式,默认 fill。
|
|
802
|
+
*/
|
|
803
|
+
constructor(options?: {
|
|
804
|
+
videoContentMode?: VideoContentMode;
|
|
805
|
+
});
|
|
806
|
+
/** 当前显示的视频轨道;切换时自动解绑旧轨道。 */
|
|
807
|
+
get track(): RealtimeVideoTrack | undefined;
|
|
808
|
+
set track(track: RealtimeVideoTrack | undefined);
|
|
809
|
+
/** 视频内容在容器中的显示模式。 */
|
|
810
|
+
get videoContentMode(): VideoContentMode;
|
|
811
|
+
set videoContentMode(mode: VideoContentMode);
|
|
812
|
+
/** 本地预览是否镜像显示(仅影响显示,不影响发布流)。 */
|
|
813
|
+
get isMirrored(): boolean;
|
|
814
|
+
set isMirrored(mirrored: boolean);
|
|
815
|
+
/** 挂载到容器元素。 */
|
|
816
|
+
attach(to: HTMLElement): void;
|
|
817
|
+
/** 从容器元素移除。 */
|
|
818
|
+
detach(): void;
|
|
819
|
+
/** 直接设置渲染用的媒体流(绑定管线和直接渲染共用)。 @internal */
|
|
820
|
+
setMediaStream(stream: MediaStream | null): void;
|
|
821
|
+
/** 由远端绑定注入配置;本地预览不走此管线。 @internal */
|
|
822
|
+
setFrameInterpolation(options?: RemoteFrameInterpolationOptions): void;
|
|
823
|
+
private startInterpolation;
|
|
824
|
+
private stopInterpolation;
|
|
825
|
+
/** 接入轨道画面:优先走注册的渲染绑定,否则按媒体轨直接渲染。 */
|
|
826
|
+
private attachTrack;
|
|
827
|
+
/** 解绑当前轨道并清空渲染内容。 */
|
|
828
|
+
private detachCurrentTrack;
|
|
829
|
+
/** 首帧提交合成器时通知;旧浏览器回退到 playing 近似判断。 */
|
|
830
|
+
private armFrameDisplayNotification;
|
|
831
|
+
/** 换流、解绑或卸载时取消观察,防止迟到的首帧归入下一条流。 */
|
|
832
|
+
private cancelFrameDisplayNotification;
|
|
833
|
+
/** 应用显示模式与镜像样式。 */
|
|
834
|
+
private applyContentMode;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* 在本地预览和远端生成画面之间自动切换的视频容器(框架无关)。
|
|
839
|
+
*
|
|
840
|
+
* 设置远端轨道后,容器等待首帧实际提交显示再渐入远端画面;
|
|
841
|
+
* 远端轨道置空时立即恢复本地预览。
|
|
842
|
+
*/
|
|
843
|
+
declare class XmaxRealtimeVideoView {
|
|
844
|
+
/** 视图根元素。 */
|
|
845
|
+
readonly element: HTMLDivElement;
|
|
846
|
+
private readonly localVideoView;
|
|
847
|
+
private readonly remoteVideoView;
|
|
848
|
+
private currentLocalTrack?;
|
|
849
|
+
private currentRemoteTrack?;
|
|
850
|
+
private contentMode;
|
|
851
|
+
/**
|
|
852
|
+
* 创建实时视频容器。
|
|
853
|
+
*
|
|
854
|
+
* @param options.localTrack 需要持续预览的本地视频轨道。
|
|
855
|
+
* @param options.remoteTrack 需要覆盖显示的远端生成视频轨道。
|
|
856
|
+
* @param options.videoContentMode 本地与远端视频的内容显示模式,默认 fill。
|
|
857
|
+
*/
|
|
858
|
+
constructor(options?: {
|
|
859
|
+
localTrack?: RealtimeVideoTrack;
|
|
860
|
+
remoteTrack?: RealtimeVideoTrack;
|
|
861
|
+
videoContentMode?: VideoContentMode;
|
|
862
|
+
});
|
|
863
|
+
/** 当前显示的本地视频轨道。 */
|
|
864
|
+
get localTrack(): RealtimeVideoTrack | undefined;
|
|
865
|
+
set localTrack(track: RealtimeVideoTrack | undefined);
|
|
866
|
+
/**
|
|
867
|
+
* 当前显示的远端生成视频轨道。
|
|
868
|
+
* 设置新轨道后等待首帧提交显示再渐入;置空时立即恢复本地预览。
|
|
869
|
+
*/
|
|
870
|
+
get remoteTrack(): RealtimeVideoTrack | undefined;
|
|
871
|
+
set remoteTrack(track: RealtimeVideoTrack | undefined);
|
|
872
|
+
/** 视频内容在容器中的显示模式。 */
|
|
873
|
+
get videoContentMode(): VideoContentMode;
|
|
874
|
+
set videoContentMode(mode: VideoContentMode);
|
|
875
|
+
/** 本地预览是否镜像显示(前置摄像头)。 */
|
|
876
|
+
get isLocalMirrored(): boolean;
|
|
877
|
+
set isLocalMirrored(mirrored: boolean);
|
|
878
|
+
/** 挂载到容器元素。 */
|
|
879
|
+
attach(to: HTMLElement): void;
|
|
880
|
+
/** 从容器元素移除。 */
|
|
881
|
+
detach(): void;
|
|
882
|
+
/** 更新远端轨道绑定:重置渐入状态,等待首帧提交后再显示远端画面。 */
|
|
883
|
+
private updateRemoteTrack;
|
|
884
|
+
/** 远端首帧已提交:渐入远端画面。 */
|
|
885
|
+
private showRemoteVideo;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
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 };
|