@ray-js/ipc-player-integration 0.0.56-beta.1 → 0.0.58-beta.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/lib/ctx/ctx.composition.js +6 -1
- package/lib/ctx/ctx.js +63 -20
- package/lib/ctx/ports.output.d.ts +1 -0
- package/lib/ctx/resolution.d.ts +1 -1
- package/lib/ctx/resolution.js +9 -1
- package/lib/ctx/useAutoClarityConfig.d.ts +8 -0
- package/lib/ctx/useAutoClarityConfig.js +40 -0
- package/lib/ui/ui.js +0 -1
- package/lib/utils/productAbility.d.ts +6 -0
- package/lib/utils/productAbility.js +20 -0
- package/lib/utils/ttt.js +2 -8
- package/lib/widgets/tryExperience/tryExperience.js +0 -1
- package/package.json +2 -1
|
@@ -139,6 +139,7 @@ const getMemoryState = devId => {
|
|
|
139
139
|
mute: true,
|
|
140
140
|
intercomMode: IntercomMode.TwoWay,
|
|
141
141
|
resolution: ClarityType.HD,
|
|
142
|
+
defaultResolution: ClarityType.HD,
|
|
142
143
|
resolutionList: [ClarityType.HD, ClarityType.SD],
|
|
143
144
|
isIntercomSupported: false,
|
|
144
145
|
maxZoomSettings: 6
|
|
@@ -150,12 +151,16 @@ const getMemoryState = devId => {
|
|
|
150
151
|
return resolve(defaultValue);
|
|
151
152
|
}
|
|
152
153
|
const muteValue = res.data.microphoneSettings.cachedMuteMode === MuteMode.OFF;
|
|
154
|
+
const {
|
|
155
|
+
availableResolutions
|
|
156
|
+
} = res.data.videoResolution;
|
|
153
157
|
return resolve({
|
|
154
158
|
mute: muteValue,
|
|
155
159
|
intercomMode: res.data.intercomInfo.cachedIntercomMode,
|
|
156
160
|
isIntercomSupported: res.data.intercomInfo.isIntercomSupported,
|
|
157
161
|
resolution: res.data.videoResolution.cachedResolution,
|
|
158
|
-
|
|
162
|
+
defaultResolution: res.data.videoResolution.defaultResolution,
|
|
163
|
+
resolutionList: Array.isArray(availableResolutions) && availableResolutions.length > 0 ? availableResolutions : defaultValue.resolutionList,
|
|
159
164
|
maxZoomSettings: (_res$data$maxZoomSett = res.data.maxZoomSettings) !== null && _res$data$maxZoomSett !== void 0 ? _res$data$maxZoomSett : 6
|
|
160
165
|
});
|
|
161
166
|
}).catch(err => {
|
package/lib/ctx/ctx.js
CHANGED
|
@@ -3,17 +3,19 @@ import "core-js/modules/esnext.iterator.constructor.js";
|
|
|
3
3
|
import "core-js/modules/esnext.iterator.filter.js";
|
|
4
4
|
import "core-js/modules/esnext.iterator.find.js";
|
|
5
5
|
import "core-js/modules/esnext.iterator.map.js";
|
|
6
|
-
import { useRef, useCallback, useEffect } from 'react';
|
|
6
|
+
import { useRef, useCallback, useEffect, useState } from 'react';
|
|
7
7
|
import { getSystemInfoSync, showModal, openAppSystemSettingPage } from '@ray-js/ray';
|
|
8
8
|
import Strings from '../i18n';
|
|
9
9
|
import { ensureAlbumPermission } from '../utils/authorize/album';
|
|
10
10
|
import { useAtom, updateAtom, getDefaultStore, useStore } from './store';
|
|
11
11
|
import { PlayState, IntercomMode } from '../interface';
|
|
12
12
|
import { changeIgnoreHideStopPreview } from '../ui/constant';
|
|
13
|
+
import { ClarityType } from '@ray-js/ray-ipc-utils/lib/interface';
|
|
13
14
|
import { getEventInstance } from './event';
|
|
14
15
|
import { isMultiCameraTileSupported, useMultiCameraCtx } from './multiCameraCtx';
|
|
15
16
|
import { toNativeClarity, withAutoClarity } from './resolution';
|
|
16
17
|
import { useAutoClarity } from './useAutoClarity';
|
|
18
|
+
import { useAutoClarityConfig } from './useAutoClarityConfig';
|
|
17
19
|
const SAVE_TO_ALBUM = 1;
|
|
18
20
|
export const createUseCtx = _ref => {
|
|
19
21
|
let {
|
|
@@ -76,6 +78,13 @@ export const createUseCtx = _ref => {
|
|
|
76
78
|
const [resolution] = useAtom('HD');
|
|
77
79
|
// resolution 清晰度列表
|
|
78
80
|
const [resolutionList, setResolutionList] = useAtom([]);
|
|
81
|
+
const [memoryState, setMemoryState] = useState(null);
|
|
82
|
+
const autoFallbackPendingRef = useRef(null);
|
|
83
|
+
const {
|
|
84
|
+
is4G,
|
|
85
|
+
enableAutoClarity,
|
|
86
|
+
ready: autoConfigReady
|
|
87
|
+
} = useAutoClarityConfig(devId);
|
|
79
88
|
// 自动模式下宿主上报的实际清晰度,供横竖屏码率区域共用
|
|
80
89
|
const [autoClarity] = useAtom(null);
|
|
81
90
|
|
|
@@ -126,40 +135,74 @@ export const createUseCtx = _ref => {
|
|
|
126
135
|
if (!eventRef.current) {
|
|
127
136
|
eventRef.current = getEventInstance();
|
|
128
137
|
}
|
|
138
|
+
const syncMemoryState = res => {
|
|
139
|
+
var _res$maxZoomSettings;
|
|
140
|
+
setMemoryState({
|
|
141
|
+
devId,
|
|
142
|
+
data: res
|
|
143
|
+
});
|
|
144
|
+
// 历史 Auto 等 4G 和面板云配置确定后再恢复,避免先显示 Auto 再回退。
|
|
145
|
+
if (res.resolution !== ClarityType.AUTO) {
|
|
146
|
+
restoreResolution(res.resolution, res.resolutionList, _setResolution);
|
|
147
|
+
}
|
|
148
|
+
_setMute(res.mute, true);
|
|
149
|
+
setIntercomMode(res.intercomMode);
|
|
150
|
+
setIntercomSupported(res.isIntercomSupported);
|
|
151
|
+
setMaxZoomSettings((_res$maxZoomSettings = res.maxZoomSettings) !== null && _res$maxZoomSettings !== void 0 ? _res$maxZoomSettings : 6);
|
|
152
|
+
};
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
autoFallbackPendingRef.current = null;
|
|
155
|
+
}, [devId]);
|
|
129
156
|
useEffect(() => {
|
|
130
157
|
// 初始化获取缓存值
|
|
131
|
-
|
|
158
|
+
let active = true;
|
|
132
159
|
(async () => {
|
|
133
160
|
if (!devId) return;
|
|
134
161
|
try {
|
|
135
|
-
var _res$maxZoomSettings;
|
|
136
162
|
const res = await getMemoryState(devId);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
_setMute(res.mute, true);
|
|
140
|
-
setIntercomMode(res.intercomMode);
|
|
141
|
-
setIntercomSupported(res.isIntercomSupported);
|
|
142
|
-
setMaxZoomSettings((_res$maxZoomSettings = res.maxZoomSettings) !== null && _res$maxZoomSettings !== void 0 ? _res$maxZoomSettings : 6);
|
|
163
|
+
if (!active) return;
|
|
164
|
+
syncMemoryState(res);
|
|
143
165
|
} catch (error) {
|
|
144
166
|
console.error('获取 getMemoryState 失败:', error);
|
|
145
167
|
}
|
|
146
168
|
})();
|
|
169
|
+
return () => {
|
|
170
|
+
active = false;
|
|
171
|
+
};
|
|
147
172
|
}, [devId]);
|
|
148
173
|
useEffect(() => {
|
|
174
|
+
let active = true;
|
|
149
175
|
if (devId && _playState === PlayState.PLAYING) {
|
|
150
176
|
// 获取缓存的值且同步
|
|
151
177
|
getMemoryState(devId).then(res => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// 传true表示值即可,会取播放器的值
|
|
155
|
-
restoreResolution(res.resolution, res.resolutionList, _setResolution);
|
|
156
|
-
_setMute(res.mute, true);
|
|
157
|
-
setIntercomMode(res.intercomMode);
|
|
158
|
-
setIntercomSupported(res.isIntercomSupported);
|
|
159
|
-
setMaxZoomSettings((_res$maxZoomSettings2 = res.maxZoomSettings) !== null && _res$maxZoomSettings2 !== void 0 ? _res$maxZoomSettings2 : 6);
|
|
178
|
+
if (!active) return;
|
|
179
|
+
syncMemoryState(res);
|
|
160
180
|
});
|
|
161
181
|
}
|
|
182
|
+
return () => {
|
|
183
|
+
active = false;
|
|
184
|
+
};
|
|
162
185
|
}, [devId, _playState]);
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
// 普通档位或配置变化时,按 432 面板相同的条件决定是否追加 Auto。
|
|
188
|
+
const list = (memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) === devId ? memoryState.data.resolutionList : [];
|
|
189
|
+
if (!autoConfigReady) {
|
|
190
|
+
setResolutionList(list.filter(clarity => clarity !== ClarityType.AUTO));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
setResolutionList(withAutoClarity(list, is4G, enableAutoClarity));
|
|
194
|
+
const autoDisabled = is4G && enableAutoClarity === false;
|
|
195
|
+
if ((memoryState === null || memoryState === void 0 ? void 0 : memoryState.devId) !== devId || memoryState.data.resolution !== ClarityType.AUTO) return;
|
|
196
|
+
if (autoDisabled && autoFallbackPendingRef.current !== devId) {
|
|
197
|
+
autoFallbackPendingRef.current = devId;
|
|
198
|
+
_setResolution(memoryState.data.defaultResolution).catch(error => {
|
|
199
|
+
autoFallbackPendingRef.current = null;
|
|
200
|
+
console.warn('恢复默认清晰度失败:', error);
|
|
201
|
+
});
|
|
202
|
+
} else if (!autoDisabled) {
|
|
203
|
+
restoreResolution(memoryState.data.resolution, list, _setResolution);
|
|
204
|
+
}
|
|
205
|
+
}, [devId, memoryState, currentResolution, is4G, enableAutoClarity, autoConfigReady]);
|
|
163
206
|
useEffect(() => {
|
|
164
207
|
refreshAfterPlayback(_playState, currentResolution);
|
|
165
208
|
}, [devId, _playState, currentResolution]);
|
|
@@ -356,7 +399,7 @@ export const createUseCtx = _ref => {
|
|
|
356
399
|
ty.authorizeStatus({
|
|
357
400
|
// 麦克风权限
|
|
358
401
|
scope: 'scope.record',
|
|
359
|
-
success:
|
|
402
|
+
success: success => {
|
|
360
403
|
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
361
404
|
IPCPlayerInstance.current.startTalk({
|
|
362
405
|
success: () => {
|
|
@@ -374,12 +417,12 @@ export const createUseCtx = _ref => {
|
|
|
374
417
|
}
|
|
375
418
|
});
|
|
376
419
|
},
|
|
377
|
-
fail:
|
|
420
|
+
fail: err => {
|
|
378
421
|
console.log('authorizeStatus失败回调');
|
|
379
422
|
ty.authorize({
|
|
380
423
|
// 麦克风权限
|
|
381
424
|
scope: 'scope.record',
|
|
382
|
-
success:
|
|
425
|
+
success: success => {
|
|
383
426
|
console.log('authorize成功回调');
|
|
384
427
|
IPCPlayerInstance.current.startTalk({
|
|
385
428
|
success: () => {
|
|
@@ -8,6 +8,7 @@ export type GetMemoryState = (devId: string) => Promise<{
|
|
|
8
8
|
intercomMode: IntercomMode;
|
|
9
9
|
isIntercomSupported: boolean;
|
|
10
10
|
resolution: ClarityType;
|
|
11
|
+
defaultResolution: ClarityType;
|
|
11
12
|
resolutionList: [ClarityType.HD, ClarityType.SD];
|
|
12
13
|
maxZoomSettings?: number;
|
|
13
14
|
}>;
|
package/lib/ctx/resolution.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ type NativeClarity = Parameters<IpcContext['setClarity']>[0]['clarity'];
|
|
|
3
3
|
export declare const toNativeClarity: (clarity: ClarityType) => NativeClarity;
|
|
4
4
|
/** 宿主支持自动清晰度,且返回至少两个档位时才展示 AUTO。 */
|
|
5
5
|
export declare const canShowAutoClarity: (list?: ClarityType[]) => boolean;
|
|
6
|
-
export declare const withAutoClarity: (list?: ClarityType[]) => ClarityType[];
|
|
6
|
+
export declare const withAutoClarity: (list?: ClarityType[], is4G?: boolean, enableAutoClarity?: boolean) => ClarityType[];
|
|
7
7
|
export declare const normalizeResolution: (resolution: ClarityType, list: ClarityType[]) => ClarityType;
|
|
8
8
|
export {};
|
package/lib/ctx/resolution.js
CHANGED
|
@@ -21,8 +21,16 @@ export const canShowAutoClarity = function () {
|
|
|
21
21
|
};
|
|
22
22
|
export const withAutoClarity = function () {
|
|
23
23
|
let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
24
|
+
let is4G = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
25
|
+
let enableAutoClarity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
24
26
|
const withoutAuto = list.filter(clarity => clarity !== ClarityType.AUTO);
|
|
25
|
-
|
|
27
|
+
let showAuto = canShowAutoClarity(withoutAuto);
|
|
28
|
+
// 仅 4G 能力开启且面板云配置明确关闭时隐藏 Auto。
|
|
29
|
+
if (is4G && enableAutoClarity === false) {
|
|
30
|
+
showAuto = false;
|
|
31
|
+
}
|
|
32
|
+
console.log('res===showAuto', is4G, enableAutoClarity, showAuto);
|
|
33
|
+
return showAuto ? [...withoutAuto, ClarityType.AUTO] : withoutAuto;
|
|
26
34
|
};
|
|
27
35
|
export const normalizeResolution = (resolution, list) => {
|
|
28
36
|
if (resolution !== ClarityType.AUTO || canShowAutoClarity(list)) return resolution;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { usePanelConfig } from '@ray-js/panel-sdk';
|
|
3
|
+
import { getAbilityCodeIsOpened } from '../utils/productAbility';
|
|
4
|
+
const TRAFFIC_CAMERA_ABILITY = 'tyabips49q';
|
|
5
|
+
const AUTO_CLARITY_CONFIG = 'tyabij5ce4';
|
|
6
|
+
/** 与 432 面板一致:先取得 4G 能力和面板云开关,再由清晰度列表决定是否加入 Auto。 */
|
|
7
|
+
export const useAutoClarityConfig = devId => {
|
|
8
|
+
var _panelConfig$fun;
|
|
9
|
+
const panelConfig = usePanelConfig();
|
|
10
|
+
const [trafficAbility, setTrafficAbility] = useState(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!devId) return undefined;
|
|
13
|
+
let active = true;
|
|
14
|
+
getAbilityCodeIsOpened(TRAFFIC_CAMERA_ABILITY, devId).then(data => {
|
|
15
|
+
if (!active) return;
|
|
16
|
+
setTrafficAbility({
|
|
17
|
+
devId,
|
|
18
|
+
is4G: (data === null || data === void 0 ? void 0 : data.isOpen) === true
|
|
19
|
+
});
|
|
20
|
+
}).catch(error => {
|
|
21
|
+
console.warn('获取 4G 能力失败:', error);
|
|
22
|
+
if (active) setTrafficAbility({
|
|
23
|
+
devId,
|
|
24
|
+
is4G: false
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return () => {
|
|
28
|
+
active = false;
|
|
29
|
+
};
|
|
30
|
+
}, [devId]);
|
|
31
|
+
const configValue = (_panelConfig$fun = panelConfig.fun) === null || _panelConfig$fun === void 0 ? void 0 : _panelConfig$fun[AUTO_CLARITY_CONFIG];
|
|
32
|
+
const abilityReady = (trafficAbility === null || trafficAbility === void 0 ? void 0 : trafficAbility.devId) === devId;
|
|
33
|
+
const is4G = abilityReady && trafficAbility.is4G;
|
|
34
|
+
// 非 4G 设备只需等待能力查询;4G 设备还需等待面板云配置初始化。
|
|
35
|
+
return {
|
|
36
|
+
is4G,
|
|
37
|
+
enableAutoClarity: configValue !== false && configValue !== 'false',
|
|
38
|
+
ready: abilityReady && (!is4G || panelConfig.initialized)
|
|
39
|
+
};
|
|
40
|
+
};
|
package/lib/ui/ui.js
CHANGED
|
@@ -565,7 +565,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
565
565
|
// canOpenSettings: true,
|
|
566
566
|
// };
|
|
567
567
|
const getNgRes = await getNgRawData();
|
|
568
|
-
console.log('res===getSmartImageQualityState', res);
|
|
569
568
|
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
570
569
|
isPurchase: res.isPurchase,
|
|
571
570
|
buttonState: res.buttonState,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { apiRequestByAtop } from '@ray-js/ray';
|
|
2
|
+
/** 按 PID 维度查询设备的高级能力。 */
|
|
3
|
+
export const getAbilityCodeIsOpened = (abilityCode, deviceId) => new Promise((resolve, reject) => {
|
|
4
|
+
apiRequestByAtop({
|
|
5
|
+
api: 'm.life.app.device.product.ability',
|
|
6
|
+
postData: {
|
|
7
|
+
abilityCode,
|
|
8
|
+
deviceId
|
|
9
|
+
},
|
|
10
|
+
version: '1.0',
|
|
11
|
+
success: result => {
|
|
12
|
+
try {
|
|
13
|
+
resolve(typeof result === 'string' ? JSON.parse(result) : result);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
fail: reject
|
|
19
|
+
});
|
|
20
|
+
});
|
package/lib/utils/ttt.js
CHANGED
|
@@ -37,11 +37,9 @@ export function getAIFrameFeature(devId) {
|
|
|
37
37
|
ty.ipc.getAIFrameFeature({
|
|
38
38
|
devId,
|
|
39
39
|
success: data => {
|
|
40
|
-
console.log('res===getAIFrameFeature data', data);
|
|
41
40
|
resolve(data);
|
|
42
41
|
},
|
|
43
|
-
fail:
|
|
44
|
-
console.warn('res===getAIFrameFeature fail', e);
|
|
42
|
+
fail: () => {
|
|
45
43
|
resolve(null);
|
|
46
44
|
}
|
|
47
45
|
});
|
|
@@ -61,11 +59,9 @@ export function setAIFrameFeature(params) {
|
|
|
61
59
|
try {
|
|
62
60
|
ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
|
|
63
61
|
success: data => {
|
|
64
|
-
console.log('res===setAIFrameFeature data', data);
|
|
65
62
|
resolve(data);
|
|
66
63
|
},
|
|
67
|
-
fail:
|
|
68
|
-
console.warn('res===setAIFrameFeature fail', e);
|
|
64
|
+
fail: () => {
|
|
69
65
|
resolve(null);
|
|
70
66
|
}
|
|
71
67
|
}));
|
|
@@ -135,7 +131,6 @@ export function notifyOfflineShown(deviceId) {
|
|
|
135
131
|
return false;
|
|
136
132
|
}
|
|
137
133
|
try {
|
|
138
|
-
console.warn('res===notifyOfflineShown', deviceId);
|
|
139
134
|
method({
|
|
140
135
|
deviceId,
|
|
141
136
|
scene: 'preview_mini'
|
|
@@ -246,7 +241,6 @@ export function subscribeClarityChanged(devId, handler) {
|
|
|
246
241
|
try {
|
|
247
242
|
ipc.onClarityChanged(listener);
|
|
248
243
|
} catch (error) {
|
|
249
|
-
console.warn('res===onClarityChanged fail', error);
|
|
250
244
|
return () => undefined;
|
|
251
245
|
}
|
|
252
246
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ipc-player-integration",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58-beta.0",
|
|
4
4
|
"description": "IPC 融合播放器",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ray-js/direction-control": "^0.0.8",
|
|
39
39
|
"@ray-js/ipc-ptz-zoom": "^0.0.3",
|
|
40
|
+
"@ray-js/panel-sdk": "^1.13.1",
|
|
40
41
|
"@ray-js/ray-ipc-player": "2.1.5-beta.0",
|
|
41
42
|
"@ray-js/ray-ipc-utils": "^1.1.16",
|
|
42
43
|
"@ray-js/svg": "0.2.0",
|