@ray-js/ipc-player-integration 0.0.57-beta.0 → 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/README.md +0 -6
- package/lib/ctx/ctx.album.test.d.ts +1 -0
- package/lib/ctx/ctx.album.test.js +197 -0
- package/lib/ctx/ctx.composition.js +19 -4
- package/lib/ctx/ctx.js +106 -55
- 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/i18n/index.d.ts +12 -0
- package/lib/i18n/strings.d.ts +6 -0
- package/lib/i18n/strings.js +6 -0
- package/lib/index.d.ts +0 -4
- package/lib/index.js +1 -3
- package/lib/interface.d.ts +16 -3
- package/lib/ui/absoluteContent.d.ts +2 -0
- package/lib/ui/absoluteContent.js +3 -0
- package/lib/ui/bottomLeftContent.js +17 -60
- package/lib/ui/bottomRightContent.js +3 -6
- package/lib/ui/ui.d.ts +0 -5
- package/lib/ui/ui.js +45 -60
- package/lib/utils/captureResult.d.ts +14 -0
- package/lib/utils/captureResult.js +70 -0
- package/lib/utils/captureResult.test.d.ts +1 -0
- package/lib/utils/captureResult.test.js +117 -0
- 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/battery/battery.js +1 -2
- package/lib/widgets/battery/batteryFull.js +1 -2
- package/lib/widgets/captureResult/captureResult.d.ts +16 -0
- package/lib/widgets/captureResult/captureResult.js +85 -0
- package/lib/widgets/captureResult/captureResult.less +144 -0
- package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
- package/lib/widgets/captureResult/captureResult.test.js +80 -0
- package/lib/widgets/captureResult/index.d.ts +2 -0
- package/lib/widgets/captureResult/index.js +2 -0
- package/lib/widgets/floodlight/floodlight.js +1 -2
- package/lib/widgets/flowLowTip/flowLowTip.js +1 -2
- package/lib/widgets/fullScreen/fullScreen.js +1 -2
- package/lib/widgets/fullScreen/fullTravelRouteControl.d.ts +1 -1
- package/lib/widgets/fullScreen/fullTravelRouteControl.js +1 -1
- package/lib/widgets/fullScreen/verticalScreen.js +1 -2
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/moveInteractiveControl/controlButton.js +1 -2
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.js +3 -12
- package/lib/widgets/moveInteractiveControl/moveInteractiveControlUI.less +4 -24
- package/lib/widgets/multiCamera/landscapeTip.js +1 -2
- package/lib/widgets/multiCamera/moveablePtzControl.js +1 -1
- package/lib/widgets/multiCamera/multiPtz.js +1 -2
- package/lib/widgets/multiCamera/ptzMoveableTip.js +1 -2
- package/lib/widgets/multiCamera/switchLayout.js +1 -2
- package/lib/widgets/multiCamera/tileMultiPtz.js +1 -2
- package/lib/widgets/multiCamera/tileSwitchLayout.js +1 -2
- package/lib/widgets/multiCamera/tileTip.js +1 -2
- package/lib/widgets/muted/muted.js +10 -5
- package/lib/widgets/muted/muted.less +5 -1
- package/lib/widgets/muted/muted.test.d.ts +1 -0
- package/lib/widgets/muted/muted.test.js +81 -0
- package/lib/widgets/ptz/ptz.js +1 -2
- package/lib/widgets/ptz/ptzControl.js +1 -1
- package/lib/widgets/ptzControlTip/ptzControlTip.js +3 -6
- package/lib/widgets/ptzControlTip/ptzControlTip.less +0 -6
- package/lib/widgets/realTimeMagnification/realTimeMagnification.js +1 -2
- package/lib/widgets/recordVideo/recordVideo.js +50 -36
- package/lib/widgets/recordVideo/recordVideo.less +17 -74
- package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
- package/lib/widgets/resolution/fullResolutionControl.js +19 -29
- package/lib/widgets/resolution/resolution.js +2 -3
- package/lib/widgets/screenshot/screenshot.js +66 -45
- package/lib/widgets/screenshot/screenshot.less +1 -40
- package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
- package/lib/widgets/screenshot/screenshot.test.js +120 -0
- package/lib/widgets/signal4G/signal4G.js +1 -4
- package/lib/widgets/siren/siren.js +1 -2
- package/lib/widgets/tempHumidity/tempHumidity.js +1 -2
- package/lib/widgets/toggleVerticalFull/toggleVerticalFull.js +1 -2
- package/lib/widgets/trialBadge/index.js +3 -8
- package/lib/widgets/trialBadge/index.less +0 -24
- package/lib/widgets/tryExperience/tryExperience.js +1 -3
- package/lib/widgets/videoBitKBP/videoBitKBP.js +1 -2
- package/lib/widgets/voiceIntercom/voiceIntercom.js +24 -50
- package/lib/widgets/voiceIntercom/voiceIntercom.less +0 -16
- package/lib/widgets/zoomTurntable/turntable/index.d.ts +7 -5
- package/lib/widgets/zoomTurntable/turntable/index.js +1 -2
- package/lib/widgets/zoomTurntable/zoomTurntableEntry.js +1 -2
- package/lib/widgets/zoomTurntable/zoomTurntableTip.js +1 -2
- package/package.json +8 -15
- package/lib/renderer/capabilities.d.ts +0 -8
- package/lib/renderer/capabilities.js +0 -19
- package/lib/renderer/context.d.ts +0 -5
- package/lib/renderer/context.js +0 -6
- package/lib/renderer/directionControl.d.ts +0 -6
- package/lib/renderer/directionControl.js +0 -3
- package/lib/renderer/font.less +0 -5
- package/lib/renderer/glyphs.d.ts +0 -1
- package/lib/renderer/glyphs.js +0 -256
- package/lib/renderer/index.module.less +0 -48
- package/lib/renderer/ptzZoom.d.ts +0 -6
- package/lib/renderer/ptzZoom.js +0 -3
- package/lib/renderer/text.d.ts +0 -4
- package/lib/renderer/text.js +0 -32
- package/lib/renderer/text.module.less +0 -4
- package/lib/renderer/viewport.d.ts +0 -7
- package/lib/renderer/viewport.js +0 -24
- package/lib/res/lynx-signal/index.d.ts +0 -1
- package/lib/res/lynx-signal/index.js +0 -22
- package/lib/res/lynx-signal/signalFour0.png +0 -0
- package/lib/res/lynx-signal/signalFour1.png +0 -0
- package/lib/res/lynx-signal/signalFour2.png +0 -0
- package/lib/res/lynx-signal/signalFour3.png +0 -0
- package/lib/res/lynx-signal/signalFour4.png +0 -0
- package/lib/res/lynx-signal/signalThree0.png +0 -0
- package/lib/res/lynx-signal/signalThree1.png +0 -0
- package/lib/res/lynx-signal/signalThree2.png +0 -0
- package/lib/res/lynx-signal/signalThree3.png +0 -0
package/README.md
CHANGED
|
@@ -359,9 +359,3 @@ yarn build
|
|
|
359
359
|
```
|
|
360
360
|
|
|
361
361
|
Other available scripts: `start:wechat`, `start:web`, `start:native`, `build:tuya`, `build:wechat`, `build:web`, `build:native`.
|
|
362
|
-
|
|
363
|
-
## Lynx integration
|
|
364
|
-
|
|
365
|
-
This branch includes master `3fadcb8` (`0.0.55`) updates for automatic clarity, offline notifications and album permissions. Set `renderMode="lynx"` explicitly; the default remains `webview`.
|
|
366
|
-
|
|
367
|
-
Use **`@ray-js/ray-ipc-player: 2.1.6-beta.0`** exactly and **`@ray-js/ray-ipc-utils: ^1.1.18`** (currently locked to `1.1.18`). Pin **`@ray-js/direction-control: 0.0.13-beta.0`** and **`@ray-js/ipc-ptz-zoom: 0.0.5-beta.0`** as the published Lynx versions. PTZ, direction and turntable widgets require compatible `lynxAdapters`. See [Lynx integration notes](./README-LYNX.md) for adapter requirements, verification and remaining runtime limitations.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { act, renderHook } from '@testing-library/react-hooks/dom';
|
|
3
|
+
import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
|
|
4
|
+
import { createUseCtx } from './ctx';
|
|
5
|
+
import { useStore } from './store';
|
|
6
|
+
jest.mock('@ray-js/ray', () => ({
|
|
7
|
+
authorize: jest.fn(),
|
|
8
|
+
authorizeStatus: jest.fn(),
|
|
9
|
+
getSystemInfoSync: jest.fn(),
|
|
10
|
+
openAppSystemSettingPage: jest.fn(),
|
|
11
|
+
showModal: jest.fn()
|
|
12
|
+
}));
|
|
13
|
+
jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({
|
|
14
|
+
ClarityType: {
|
|
15
|
+
HD: 'HD',
|
|
16
|
+
SD: 'SD',
|
|
17
|
+
AUTO: 'AUTO'
|
|
18
|
+
},
|
|
19
|
+
IntercomMode: {
|
|
20
|
+
OneWay: 'OneWay',
|
|
21
|
+
TwoWay: 'TwoWay'
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
jest.mock('../i18n', () => ({
|
|
25
|
+
__esModule: true,
|
|
26
|
+
default: {
|
|
27
|
+
getLang: key => key
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
jest.mock('./multiCameraCtx', () => ({
|
|
31
|
+
isMultiCameraTileSupported: () => false,
|
|
32
|
+
useMultiCameraCtx: () => ({})
|
|
33
|
+
}));
|
|
34
|
+
jest.mock('../utils/ttt', () => ({
|
|
35
|
+
getCachedAutoClarity: jest.fn(),
|
|
36
|
+
isClarityChangedSupported: () => false,
|
|
37
|
+
setCachedAutoClarity: jest.fn(),
|
|
38
|
+
subscribeClarityChanged: () => () => undefined
|
|
39
|
+
}));
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
jest.clearAllMocks();
|
|
42
|
+
getSystemInfoSync.mockReturnValue({
|
|
43
|
+
platform: 'android',
|
|
44
|
+
system: 'android 12'
|
|
45
|
+
});
|
|
46
|
+
authorizeStatus.mockImplementation(_ref => {
|
|
47
|
+
let {
|
|
48
|
+
fail
|
|
49
|
+
} = _ref;
|
|
50
|
+
return fail({
|
|
51
|
+
errorCode: 9004
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
authorize.mockImplementation(_ref2 => {
|
|
55
|
+
let {
|
|
56
|
+
fail
|
|
57
|
+
} = _ref2;
|
|
58
|
+
return fail({
|
|
59
|
+
errorCode: 9004
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const mountContext = function () {
|
|
64
|
+
let saveToAlbum = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
65
|
+
const capture = {
|
|
66
|
+
tempImagePath: 'thingfile://capture.jpg',
|
|
67
|
+
filePath: 'thingfile://record.mp4'
|
|
68
|
+
};
|
|
69
|
+
const startRecord = jest.fn(_ref3 => {
|
|
70
|
+
let {
|
|
71
|
+
success
|
|
72
|
+
} = _ref3;
|
|
73
|
+
return success();
|
|
74
|
+
});
|
|
75
|
+
const stopRecord = jest.fn(_ref4 => {
|
|
76
|
+
let {
|
|
77
|
+
success
|
|
78
|
+
} = _ref4;
|
|
79
|
+
return success(capture);
|
|
80
|
+
});
|
|
81
|
+
const useCtx = createUseCtx({
|
|
82
|
+
createPlayContext: () => ({
|
|
83
|
+
startRecord,
|
|
84
|
+
stopRecord
|
|
85
|
+
}),
|
|
86
|
+
getMemoryState: jest.fn().mockResolvedValue({
|
|
87
|
+
resolution: 'HD',
|
|
88
|
+
resolutionList: ['HD', 'SD'],
|
|
89
|
+
mute: true,
|
|
90
|
+
intercomMode: 'TwoWay',
|
|
91
|
+
isIntercomSupported: false
|
|
92
|
+
}),
|
|
93
|
+
setResolutionMemoryState: jest.fn(),
|
|
94
|
+
setMuteMemoryState: jest.fn(),
|
|
95
|
+
authorizeStatus: jest.fn(),
|
|
96
|
+
toast: jest.fn()
|
|
97
|
+
});
|
|
98
|
+
const hook = renderHook(() => {
|
|
99
|
+
const ctx = useCtx({
|
|
100
|
+
devId: 'camera-1',
|
|
101
|
+
multiLens: true,
|
|
102
|
+
saveToAlbum
|
|
103
|
+
});
|
|
104
|
+
const state = useStore({
|
|
105
|
+
recording: ctx.recording
|
|
106
|
+
});
|
|
107
|
+
return _objectSpread(_objectSpread({}, ctx), {}, {
|
|
108
|
+
state
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
return _objectSpread(_objectSpread({}, hook), {}, {
|
|
112
|
+
startRecord,
|
|
113
|
+
stopRecord,
|
|
114
|
+
capture
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
it('starts without legacy authorization and retains the native stop result', async () => {
|
|
118
|
+
const {
|
|
119
|
+
result,
|
|
120
|
+
startRecord,
|
|
121
|
+
stopRecord,
|
|
122
|
+
capture,
|
|
123
|
+
unmount
|
|
124
|
+
} = mountContext();
|
|
125
|
+
await act(async () => {
|
|
126
|
+
expect(await result.current.setRecording(true)).toBe(true);
|
|
127
|
+
});
|
|
128
|
+
expect(startRecord).toHaveBeenCalledWith(expect.objectContaining({
|
|
129
|
+
saveToAlbum: 1
|
|
130
|
+
}));
|
|
131
|
+
expect(result.current.state.recording).toBe(true);
|
|
132
|
+
expect(result.current.multiLens).toBe(true);
|
|
133
|
+
await act(async () => {
|
|
134
|
+
expect(await result.current.setRecording(false)).toEqual(capture);
|
|
135
|
+
});
|
|
136
|
+
expect(stopRecord).toHaveBeenCalledTimes(1);
|
|
137
|
+
expect(result.current.state.recording).toBe(false);
|
|
138
|
+
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
139
|
+
expect(authorize).not.toHaveBeenCalled();
|
|
140
|
+
unmount();
|
|
141
|
+
});
|
|
142
|
+
it('settles a denied start without calling the native recorder', async () => {
|
|
143
|
+
getSystemInfoSync.mockReturnValue({
|
|
144
|
+
platform: 'ios',
|
|
145
|
+
system: 'iOS 18'
|
|
146
|
+
});
|
|
147
|
+
const {
|
|
148
|
+
result,
|
|
149
|
+
startRecord,
|
|
150
|
+
unmount
|
|
151
|
+
} = mountContext();
|
|
152
|
+
await act(async () => {
|
|
153
|
+
expect(await result.current.setRecording(true)).toBe(false);
|
|
154
|
+
});
|
|
155
|
+
expect(startRecord).not.toHaveBeenCalled();
|
|
156
|
+
expect(result.current.state.recording).toBe(false);
|
|
157
|
+
expect(showModal).toHaveBeenCalledTimes(1);
|
|
158
|
+
unmount();
|
|
159
|
+
});
|
|
160
|
+
it('propagates a native start failure without entering recording state', async () => {
|
|
161
|
+
const {
|
|
162
|
+
result,
|
|
163
|
+
startRecord,
|
|
164
|
+
unmount
|
|
165
|
+
} = mountContext();
|
|
166
|
+
const error = {
|
|
167
|
+
errorCode: 1001,
|
|
168
|
+
errorMsg: 'Start failed'
|
|
169
|
+
};
|
|
170
|
+
startRecord.mockImplementationOnce(_ref5 => {
|
|
171
|
+
let {
|
|
172
|
+
fail
|
|
173
|
+
} = _ref5;
|
|
174
|
+
return fail(error);
|
|
175
|
+
});
|
|
176
|
+
await act(async () => {
|
|
177
|
+
await expect(result.current.setRecording(true)).rejects.toEqual(error);
|
|
178
|
+
});
|
|
179
|
+
expect(result.current.state.recording).toBe(false);
|
|
180
|
+
unmount();
|
|
181
|
+
});
|
|
182
|
+
it('keeps the requested album when stopping on page unload', async () => {
|
|
183
|
+
const {
|
|
184
|
+
result,
|
|
185
|
+
stopRecord,
|
|
186
|
+
capture,
|
|
187
|
+
unmount
|
|
188
|
+
} = mountContext(0);
|
|
189
|
+
await act(async () => {
|
|
190
|
+
expect(await result.current.stopRecordingOnUnload()).toEqual(capture);
|
|
191
|
+
});
|
|
192
|
+
expect(stopRecord).toHaveBeenCalledWith(expect.objectContaining({
|
|
193
|
+
saveToAlbum: 0
|
|
194
|
+
}));
|
|
195
|
+
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
196
|
+
unmount();
|
|
197
|
+
});
|
|
@@ -6,6 +6,7 @@ import { IntercomMode, MuteMode, ClarityType } from '@ray-js/ray-ipc-utils/lib/i
|
|
|
6
6
|
import { createUseCtx } from './ctx';
|
|
7
7
|
import { FullSmallIntercom, VerticalSmallIntercom, BatteryFull, Battery, Screenshot, TempHumidity, Signal4G, RecordVideo, FullScreen, VideoBitKBP, Muted, Floodlight, Siren, TryExperience, Resolution, Ptz, MultiPtz, TileTip, PtzMoveableTip, LandscapeTip, TileActions, MoveablePtzControl, SwitchLayout, ToggleVerticalFull, RealTimeMagnification, ZoomTurntableEntry } from '../widgets';
|
|
8
8
|
import { authorizeStatus } from '../utils/authorize';
|
|
9
|
+
import { PlayState } from '../interface';
|
|
9
10
|
import { landscapeTipId, moveablePtzControlId, multiPtzId, ptzMoveableTipId, tileActionsId, tileTipId } from '../ui/constant';
|
|
10
11
|
import { multiPrefix } from '../widgets/multiCamera/constants';
|
|
11
12
|
const createPlayContext = ty.createIpcPlayerContext;
|
|
@@ -87,20 +88,29 @@ export const defaultBottomRightContent = [{
|
|
|
87
88
|
content: FullScreen
|
|
88
89
|
}];
|
|
89
90
|
const absoluteContent = [];
|
|
91
|
+
const renderWhenPlaying = _ref => {
|
|
92
|
+
let {
|
|
93
|
+
playState
|
|
94
|
+
} = _ref;
|
|
95
|
+
return playState === PlayState.PLAYING;
|
|
96
|
+
};
|
|
90
97
|
export const multiCameraAbsoluteContent = [{
|
|
91
98
|
id: tileTipId,
|
|
92
99
|
content: TileTip,
|
|
93
100
|
absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
|
|
101
|
+
renderWhen: renderWhenPlaying,
|
|
94
102
|
hidden: true
|
|
95
103
|
}, {
|
|
96
104
|
id: ptzMoveableTipId,
|
|
97
105
|
content: PtzMoveableTip,
|
|
98
106
|
absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
|
|
107
|
+
renderWhen: renderWhenPlaying,
|
|
99
108
|
hidden: true
|
|
100
109
|
}, {
|
|
101
110
|
id: landscapeTipId,
|
|
102
111
|
content: LandscapeTip,
|
|
103
112
|
absoluteContentClassName: `${multiPrefix}-tile-tip-wrap`,
|
|
113
|
+
renderWhen: renderWhenPlaying,
|
|
104
114
|
hidden: true
|
|
105
115
|
}, {
|
|
106
116
|
id: tileActionsId,
|
|
@@ -112,12 +122,12 @@ export const multiCameraAbsoluteContent = [{
|
|
|
112
122
|
absoluteNoCoverView: true,
|
|
113
123
|
hidden: true
|
|
114
124
|
}];
|
|
115
|
-
const toast =
|
|
125
|
+
const toast = _ref2 => {
|
|
116
126
|
let {
|
|
117
127
|
title,
|
|
118
128
|
duration
|
|
119
|
-
} =
|
|
120
|
-
config = _objectWithoutProperties(
|
|
129
|
+
} = _ref2,
|
|
130
|
+
config = _objectWithoutProperties(_ref2, _excluded);
|
|
121
131
|
ty.showToast(_objectSpread({
|
|
122
132
|
title,
|
|
123
133
|
duration,
|
|
@@ -129,6 +139,7 @@ const getMemoryState = devId => {
|
|
|
129
139
|
mute: true,
|
|
130
140
|
intercomMode: IntercomMode.TwoWay,
|
|
131
141
|
resolution: ClarityType.HD,
|
|
142
|
+
defaultResolution: ClarityType.HD,
|
|
132
143
|
resolutionList: [ClarityType.HD, ClarityType.SD],
|
|
133
144
|
isIntercomSupported: false,
|
|
134
145
|
maxZoomSettings: 6
|
|
@@ -140,12 +151,16 @@ const getMemoryState = devId => {
|
|
|
140
151
|
return resolve(defaultValue);
|
|
141
152
|
}
|
|
142
153
|
const muteValue = res.data.microphoneSettings.cachedMuteMode === MuteMode.OFF;
|
|
154
|
+
const {
|
|
155
|
+
availableResolutions
|
|
156
|
+
} = res.data.videoResolution;
|
|
143
157
|
return resolve({
|
|
144
158
|
mute: muteValue,
|
|
145
159
|
intercomMode: res.data.intercomInfo.cachedIntercomMode,
|
|
146
160
|
isIntercomSupported: res.data.intercomInfo.isIntercomSupported,
|
|
147
161
|
resolution: res.data.videoResolution.cachedResolution,
|
|
148
|
-
|
|
162
|
+
defaultResolution: res.data.videoResolution.defaultResolution,
|
|
163
|
+
resolutionList: Array.isArray(availableResolutions) && availableResolutions.length > 0 ? availableResolutions : defaultValue.resolutionList,
|
|
149
164
|
maxZoomSettings: (_res$data$maxZoomSett = res.data.maxZoomSettings) !== null && _res$data$maxZoomSett !== void 0 ? _res$data$maxZoomSett : 6
|
|
150
165
|
});
|
|
151
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 {
|
|
@@ -38,6 +40,7 @@ export const createUseCtx = _ref => {
|
|
|
38
40
|
initBottomRightContent,
|
|
39
41
|
initAbsoluteContent,
|
|
40
42
|
saveToAlbum = SAVE_TO_ALBUM,
|
|
43
|
+
multiLens = false,
|
|
41
44
|
showPtzControlTip = false,
|
|
42
45
|
videoSplitProtocol
|
|
43
46
|
} = _ref2;
|
|
@@ -57,6 +60,7 @@ export const createUseCtx = _ref => {
|
|
|
57
60
|
|
|
58
61
|
// 录像中
|
|
59
62
|
const [recording] = useAtom(false);
|
|
63
|
+
const recordingMultiLensRef = useRef(false);
|
|
60
64
|
|
|
61
65
|
// 录像是否不可点击
|
|
62
66
|
const [recordingDisabled, setRecordingDisabled] = useAtom(false);
|
|
@@ -74,6 +78,13 @@ export const createUseCtx = _ref => {
|
|
|
74
78
|
const [resolution] = useAtom('HD');
|
|
75
79
|
// resolution 清晰度列表
|
|
76
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);
|
|
77
88
|
// 自动模式下宿主上报的实际清晰度,供横竖屏码率区域共用
|
|
78
89
|
const [autoClarity] = useAtom(null);
|
|
79
90
|
|
|
@@ -124,40 +135,74 @@ export const createUseCtx = _ref => {
|
|
|
124
135
|
if (!eventRef.current) {
|
|
125
136
|
eventRef.current = getEventInstance();
|
|
126
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]);
|
|
127
156
|
useEffect(() => {
|
|
128
157
|
// 初始化获取缓存值
|
|
129
|
-
|
|
158
|
+
let active = true;
|
|
130
159
|
(async () => {
|
|
131
160
|
if (!devId) return;
|
|
132
161
|
try {
|
|
133
|
-
var _res$maxZoomSettings;
|
|
134
162
|
const res = await getMemoryState(devId);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
_setMute(res.mute, true);
|
|
138
|
-
setIntercomMode(res.intercomMode);
|
|
139
|
-
setIntercomSupported(res.isIntercomSupported);
|
|
140
|
-
setMaxZoomSettings((_res$maxZoomSettings = res.maxZoomSettings) !== null && _res$maxZoomSettings !== void 0 ? _res$maxZoomSettings : 6);
|
|
163
|
+
if (!active) return;
|
|
164
|
+
syncMemoryState(res);
|
|
141
165
|
} catch (error) {
|
|
142
166
|
console.error('获取 getMemoryState 失败:', error);
|
|
143
167
|
}
|
|
144
168
|
})();
|
|
169
|
+
return () => {
|
|
170
|
+
active = false;
|
|
171
|
+
};
|
|
145
172
|
}, [devId]);
|
|
146
173
|
useEffect(() => {
|
|
174
|
+
let active = true;
|
|
147
175
|
if (devId && _playState === PlayState.PLAYING) {
|
|
148
176
|
// 获取缓存的值且同步
|
|
149
177
|
getMemoryState(devId).then(res => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// 传true表示值即可,会取播放器的值
|
|
153
|
-
restoreResolution(res.resolution, res.resolutionList, _setResolution);
|
|
154
|
-
_setMute(res.mute, true);
|
|
155
|
-
setIntercomMode(res.intercomMode);
|
|
156
|
-
setIntercomSupported(res.isIntercomSupported);
|
|
157
|
-
setMaxZoomSettings((_res$maxZoomSettings2 = res.maxZoomSettings) !== null && _res$maxZoomSettings2 !== void 0 ? _res$maxZoomSettings2 : 6);
|
|
178
|
+
if (!active) return;
|
|
179
|
+
syncMemoryState(res);
|
|
158
180
|
});
|
|
159
181
|
}
|
|
182
|
+
return () => {
|
|
183
|
+
active = false;
|
|
184
|
+
};
|
|
160
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]);
|
|
161
206
|
useEffect(() => {
|
|
162
207
|
refreshAfterPlayback(_playState, currentResolution);
|
|
163
208
|
}, [devId, _playState, currentResolution]);
|
|
@@ -274,6 +319,30 @@ export const createUseCtx = _ref => {
|
|
|
274
319
|
});
|
|
275
320
|
});
|
|
276
321
|
};
|
|
322
|
+
const stopRecording = showError => {
|
|
323
|
+
return new Promise((resolve, reject) => {
|
|
324
|
+
IPCPlayerInstance.current.stopRecord({
|
|
325
|
+
saveToAlbum,
|
|
326
|
+
success: res => {
|
|
327
|
+
recordingMultiLensRef.current = false;
|
|
328
|
+
updateAtom(recording, false);
|
|
329
|
+
resolve(res);
|
|
330
|
+
},
|
|
331
|
+
fail: err => {
|
|
332
|
+
recordingMultiLensRef.current = false;
|
|
333
|
+
updateAtom(recording, false);
|
|
334
|
+
reject(err);
|
|
335
|
+
if (showError) {
|
|
336
|
+
const errObj = err.innerError || err || {};
|
|
337
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
|
|
338
|
+
toast({
|
|
339
|
+
title: errMsg
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
277
346
|
const multiCameraCtx = useMultiCameraCtx({
|
|
278
347
|
devId,
|
|
279
348
|
IPCPlayerInstance: IPCPlayerInstance.current,
|
|
@@ -284,6 +353,7 @@ export const createUseCtx = _ref => {
|
|
|
284
353
|
brandColor,
|
|
285
354
|
verticalMic,
|
|
286
355
|
saveToAlbum,
|
|
356
|
+
multiLens,
|
|
287
357
|
screenType,
|
|
288
358
|
isVerticalFullLayout,
|
|
289
359
|
setIsVerticalFullLayout,
|
|
@@ -329,7 +399,7 @@ export const createUseCtx = _ref => {
|
|
|
329
399
|
ty.authorizeStatus({
|
|
330
400
|
// 麦克风权限
|
|
331
401
|
scope: 'scope.record',
|
|
332
|
-
success:
|
|
402
|
+
success: success => {
|
|
333
403
|
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
334
404
|
IPCPlayerInstance.current.startTalk({
|
|
335
405
|
success: () => {
|
|
@@ -347,12 +417,12 @@ export const createUseCtx = _ref => {
|
|
|
347
417
|
}
|
|
348
418
|
});
|
|
349
419
|
},
|
|
350
|
-
fail:
|
|
420
|
+
fail: err => {
|
|
351
421
|
console.log('authorizeStatus失败回调');
|
|
352
422
|
ty.authorize({
|
|
353
423
|
// 麦克风权限
|
|
354
424
|
scope: 'scope.record',
|
|
355
|
-
success:
|
|
425
|
+
success: success => {
|
|
356
426
|
console.log('authorize成功回调');
|
|
357
427
|
IPCPlayerInstance.current.startTalk({
|
|
358
428
|
success: () => {
|
|
@@ -428,44 +498,25 @@ export const createUseCtx = _ref => {
|
|
|
428
498
|
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
429
499
|
return false;
|
|
430
500
|
}
|
|
431
|
-
if (target)
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
501
|
+
if (!target) return stopRecording(true);
|
|
502
|
+
const granted = await ensureAlbumPermission();
|
|
503
|
+
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
504
|
+
if (!granted) return false;
|
|
436
505
|
return new Promise((resolve, reject) => {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
});
|
|
449
|
-
} else {
|
|
450
|
-
IPCPlayerInstance.current.stopRecord({
|
|
451
|
-
saveToAlbum,
|
|
452
|
-
success: res => {
|
|
453
|
-
updateAtom(recording, false);
|
|
454
|
-
resolve(res);
|
|
455
|
-
},
|
|
456
|
-
fail: err => {
|
|
457
|
-
updateAtom(recording, false);
|
|
458
|
-
reject(err);
|
|
459
|
-
const errObj = err.innerError || err || {};
|
|
460
|
-
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_stop_recording_err');
|
|
461
|
-
toast({
|
|
462
|
-
title: errMsg
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
}
|
|
506
|
+
IPCPlayerInstance.current.startRecord({
|
|
507
|
+
saveToAlbum,
|
|
508
|
+
success: () => {
|
|
509
|
+
updateAtom(recording, true);
|
|
510
|
+
resolve(true);
|
|
511
|
+
},
|
|
512
|
+
fail: err => {
|
|
513
|
+
eventRef.current.emit(changeIgnoreHideStopPreview, false);
|
|
514
|
+
reject(err);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
467
517
|
});
|
|
468
518
|
},
|
|
519
|
+
stopRecordingOnUnload: () => stopRecording(false),
|
|
469
520
|
setRecordingDisabled,
|
|
470
521
|
setScreenType,
|
|
471
522
|
topLeftContent,
|
|
@@ -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
|
+
};
|