@xmov/avatar 2.0.0-beta.13 → 2.0.0-beta.14
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/capability-checker.ts +90 -16
package/package.json
CHANGED
|
@@ -110,17 +110,27 @@ function checkAudioSystemSync(): ICapabilityCheckItem {
|
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* 同步检查 WebCodecs API 是否存在(不探测具体编解码器)
|
|
113
|
+
*
|
|
114
|
+
* 与 streaming-video.ts 解码策略一致标注平台解码路径:
|
|
115
|
+
* - Android(含 OpenHarmony/ArkWeb):prefer-software 软解码
|
|
116
|
+
* - 其余环境:默认配置(硬解码)
|
|
117
|
+
* 实际解码配置支持度由异步 checkWebCodecsDetailed 探测
|
|
113
118
|
*/
|
|
114
119
|
function checkWebCodecsSync(): ICapabilityCheckItem {
|
|
115
120
|
const hasVideoDecoder = typeof (window as any).VideoDecoder !== 'undefined';
|
|
116
|
-
const
|
|
121
|
+
const userAgent = (navigator.userAgent || '').toLowerCase();
|
|
122
|
+
const isAndroid = /android/.test(userAgent) || /openharmony|arkweb/.test(userAgent);
|
|
117
123
|
|
|
118
124
|
return {
|
|
119
125
|
name: 'webcodecs',
|
|
120
|
-
supported,
|
|
126
|
+
supported: hasVideoDecoder,
|
|
121
127
|
severity: 'fatal',
|
|
122
|
-
reason:
|
|
123
|
-
detail: {
|
|
128
|
+
reason: hasVideoDecoder ? undefined : '浏览器不支持 WebCodecs VideoDecoder API',
|
|
129
|
+
detail: {
|
|
130
|
+
hasVideoDecoder,
|
|
131
|
+
isAndroid,
|
|
132
|
+
hardwareAcceleration: isAndroid ? 'prefer-software' : 'default',
|
|
133
|
+
},
|
|
124
134
|
};
|
|
125
135
|
}
|
|
126
136
|
|
|
@@ -186,13 +196,17 @@ export function checkCapabilitySync(audioOnlyMode = false): ICapabilityCheckRepo
|
|
|
186
196
|
|
|
187
197
|
/**
|
|
188
198
|
* 异步检查 WebCodecs 详细编解码器支持
|
|
199
|
+
*
|
|
200
|
+
* 与 streaming-video.ts 解码策略一致:
|
|
201
|
+
* - Android(含 OpenHarmony/ArkWeb):主路径为 prefer-software 软解码,默认配置兜底
|
|
202
|
+
* - 其余环境:主路径为默认配置(硬解码)
|
|
203
|
+
* 逐 codec 探测两种配置的支持度,并按平台主路径判定 SDK 可用性
|
|
189
204
|
*/
|
|
190
205
|
async function checkWebCodecsDetailed(): Promise<ICapabilityCheckItem> {
|
|
191
206
|
try {
|
|
192
207
|
const hasVideoDecoder = typeof (window as any).VideoDecoder !== 'undefined';
|
|
193
|
-
const supported = hasVideoDecoder;
|
|
194
208
|
|
|
195
|
-
if (!
|
|
209
|
+
if (!hasVideoDecoder) {
|
|
196
210
|
return {
|
|
197
211
|
name: 'webcodecs',
|
|
198
212
|
supported: false,
|
|
@@ -202,29 +216,89 @@ async function checkWebCodecsDetailed(): Promise<ICapabilityCheckItem> {
|
|
|
202
216
|
};
|
|
203
217
|
}
|
|
204
218
|
|
|
219
|
+
// 平台判定与 streaming-video.ts 保持一致
|
|
220
|
+
const userAgent = (navigator.userAgent || '').toLowerCase();
|
|
221
|
+
const isAndroid = /android/.test(userAgent) || /openharmony|arkweb/.test(userAgent);
|
|
222
|
+
|
|
223
|
+
// 探测配置补全尺寸字段:与业务 isConfigSupported(config) 一致(纯 codec 在部分浏览器被拒)
|
|
224
|
+
const probeW = 2160;
|
|
225
|
+
const probeH = 1920;
|
|
226
|
+
|
|
205
227
|
// 探测具体编解码器支持
|
|
206
|
-
|
|
228
|
+
// 注意:WebCodecs 的 codec 字段是纯编解码器字符串(如 avc1.640032),
|
|
229
|
+
// 不能用 video/mp4; codecs="..." 的 MIME 形式(会导致 isConfigSupported 抛异常)
|
|
230
|
+
let codecSupport: Record<string, { default: boolean; software: boolean | null; error?: string }> = {};
|
|
207
231
|
const testCodecs = [
|
|
208
|
-
'
|
|
209
|
-
'
|
|
210
|
-
'
|
|
232
|
+
'avc1.42E01E', // H.264 Baseline
|
|
233
|
+
'avc1.4D001F', // H.264 Main
|
|
234
|
+
'avc1.64001F', // H.264 High
|
|
211
235
|
];
|
|
236
|
+
|
|
237
|
+
// 主路径(平台默认解码配置)与兜底(默认配置)任一支持即判定可用
|
|
238
|
+
let primarySupported = false;
|
|
239
|
+
let fallbackSupported = false;
|
|
240
|
+
// 探测过程是否出现异常(区别于"确实不支持"):异常时降级 warn,避免误杀可用环境
|
|
241
|
+
let probeFailed = false;
|
|
212
242
|
for (const codec of testCodecs) {
|
|
213
243
|
try {
|
|
214
|
-
|
|
244
|
+
// 默认配置(浏览器默认/硬解),业务兜底路径
|
|
245
|
+
const defaultResult = await (window as any).VideoDecoder.isConfigSupported({
|
|
215
246
|
codec,
|
|
247
|
+
codedWidth: probeW,
|
|
248
|
+
codedHeight: probeH,
|
|
216
249
|
});
|
|
217
|
-
|
|
250
|
+
const defaultOk = !!defaultResult?.supported;
|
|
251
|
+
if (defaultOk) {
|
|
252
|
+
fallbackSupported = true;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Android 主路径:prefer-software 软解码(与 streaming-video.ts 一致)
|
|
256
|
+
let softwareOk: boolean | null = null;
|
|
257
|
+
if (isAndroid) {
|
|
258
|
+
try {
|
|
259
|
+
const softwareResult = await (window as any).VideoDecoder.isConfigSupported({
|
|
260
|
+
codec,
|
|
261
|
+
codedWidth: probeW,
|
|
262
|
+
codedHeight: probeH,
|
|
263
|
+
hardwareAcceleration: 'prefer-software',
|
|
264
|
+
});
|
|
265
|
+
softwareOk = !!softwareResult?.supported;
|
|
266
|
+
} catch {
|
|
267
|
+
softwareOk = false;
|
|
268
|
+
}
|
|
269
|
+
if (softwareOk) {
|
|
270
|
+
primarySupported = true;
|
|
271
|
+
}
|
|
272
|
+
} else if (defaultOk) {
|
|
273
|
+
primarySupported = true;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
codecSupport[codec] = { default: defaultOk, software: softwareOk };
|
|
218
277
|
} catch {
|
|
219
|
-
|
|
278
|
+
// isConfigSupported 抛异常:探测方式受限(如浏览器实现差异),非"确实不支持"
|
|
279
|
+
probeFailed = true;
|
|
280
|
+
codecSupport[codec] = { default: false, software: null, error: 'probe-failed' };
|
|
220
281
|
}
|
|
221
282
|
}
|
|
222
283
|
|
|
284
|
+
const supported = primarySupported || fallbackSupported;
|
|
285
|
+
// 探测异常且无任何配置支持:降级 warn(运行时业务用真实 config 的 isConfigSupported 为准)
|
|
286
|
+
const severity = probeFailed && !supported ? 'warn' : 'fatal';
|
|
223
287
|
return {
|
|
224
288
|
name: 'webcodecs',
|
|
225
|
-
supported
|
|
226
|
-
severity
|
|
227
|
-
|
|
289
|
+
supported,
|
|
290
|
+
severity,
|
|
291
|
+
reason: supported
|
|
292
|
+
? undefined
|
|
293
|
+
: severity === 'warn'
|
|
294
|
+
? 'WebCodecs 探测异常(运行时将以实际视频配置二次确认)'
|
|
295
|
+
: '浏览器不支持 H.264 解码(默认/软解配置均不可用)',
|
|
296
|
+
detail: {
|
|
297
|
+
hasVideoDecoder,
|
|
298
|
+
isAndroid,
|
|
299
|
+
hardwareAcceleration: isAndroid ? 'prefer-software' : 'default',
|
|
300
|
+
codecSupport,
|
|
301
|
+
},
|
|
228
302
|
};
|
|
229
303
|
} catch (e) {
|
|
230
304
|
return {
|