@ray-js/ipc-player-integration 0.0.29-beta.1 → 0.0.29-beta.3

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.
@@ -36,6 +36,10 @@ export declare const useMultiCameraCtx: (props: Props) => {
36
36
  * ptz状态
37
37
  */
38
38
  ptzStatus: import("../interface").RetAtom<boolean>;
39
+ /**
40
+ * 多目设备支持的 dp
41
+ */
42
+ dpSupportMap: Record<"ptz_control" | "ipc_multi_locate_coor" | "zoom_control" | "ipc_multi_locate_coors" | "ipc_multi_ptz_control" | "ipc_multi_zoom_control", boolean>;
39
43
  /**
40
44
  * ipcPlayer extendProps
41
45
  */
@@ -2,6 +2,8 @@ import { getDpIdByCode, publishDps } from '@ray-js/ray-ipc-utils';
2
2
  import { useMemoizedFn } from 'ahooks';
3
3
  import { useMemo } from 'react';
4
4
  import { MultiCameraLayoutStyle, MultiCameraScreenMode } from '../interface';
5
+ import { useDpSupport } from '../hooks';
6
+ import { GUN_BALL, MULTI_GUN_BALL, MULTI_PTZ_CONTROL, MULTI_ZOOM_CONTROL, PTZ_CONTROL, ZOOM_CONTROL } from '../utils/content/dpCode';
5
7
  import { useAtom } from './store';
6
8
  const DEFAULT_VIDEO_SPLIT_PROTOCOL = {
7
9
  total_split_num: 1,
@@ -9,6 +11,7 @@ const DEFAULT_VIDEO_SPLIT_PROTOCOL = {
9
11
  align_info: [],
10
12
  p_v: 3
11
13
  };
14
+ const DP_CODES = [PTZ_CONTROL, GUN_BALL, ZOOM_CONTROL, MULTI_GUN_BALL, MULTI_PTZ_CONTROL, MULTI_ZOOM_CONTROL];
12
15
  /**
13
16
  * 多目摄像头相关状态、方法维护
14
17
  */
@@ -21,6 +24,10 @@ export const useMultiCameraCtx = props => {
21
24
  const isSupport = useMemo(() => {
22
25
  return (videoSplitProtocol === null || videoSplitProtocol === void 0 ? void 0 : videoSplitProtocol.total_split_num) > 1 && (videoSplitProtocol === null || videoSplitProtocol === void 0 ? void 0 : videoSplitProtocol.p_v) >= 3 && typeof (IPCPlayerInstance === null || IPCPlayerInstance === void 0 ? void 0 : IPCPlayerInstance.switchLayoutStyle) === 'function';
23
26
  }, [IPCPlayerInstance, videoSplitProtocol]);
27
+ const dpSupportMap = useDpSupport({
28
+ devId,
29
+ dpCodes: DP_CODES
30
+ });
24
31
  const [layoutStyleAtom, setLayoutStyle] = useAtom(isSupport ? MultiCameraLayoutStyle.tile : MultiCameraLayoutStyle.pip);
25
32
  const [screenModeAtom, setScreenMode] = useAtom(isSupport ? MultiCameraScreenMode.full : MultiCameraScreenMode.short);
26
33
  const [selectedLenInfoAtom, setSelectedLenInfo] = useAtom({
@@ -46,19 +53,28 @@ export const useMultiCameraCtx = props => {
46
53
  setScreenMode(screenMode);
47
54
  });
48
55
  const handleLocalizerViewLocated = useMemoizedFn(async event => {
56
+ var _event$detail;
49
57
  console.info('onLocalizerViewLocated', JSON.stringify(event === null || event === void 0 ? void 0 : event.detail));
50
- const dpData = await getDpIdByCode(devId, 'ipc_multi_locate_coors');
58
+ const locateDpConfig = dpSupportMap.ipc_multi_locate_coors ? {
59
+ code: 'ipc_multi_locate_coors',
60
+ value: JSON.stringify(event.detail)
61
+ } : dpSupportMap.ipc_multi_locate_coor ? {
62
+ code: 'ipc_multi_locate_coor',
63
+ value: String((_event$detail = event.detail) === null || _event$detail === void 0 ? void 0 : _event$detail.coor)
64
+ } // 兼容老 dp
65
+ : null;
66
+ if (!locateDpConfig) return;
67
+ const dpData = await getDpIdByCode(devId, locateDpConfig.code);
51
68
  if (dpData.code === 0) {
52
- const dpId = dpData.data;
53
- const sndDpValue = JSON.stringify(event.detail);
54
69
  publishDps(devId, {
55
- [dpId]: sndDpValue
70
+ [dpData.data]: locateDpConfig.value
56
71
  });
57
72
  }
58
73
  });
59
74
  const extendProps = useMemo(() => {
60
75
  return {
61
- type: isSupport ? 3 : undefined,
76
+ // type: 4 表示多目摄像头
77
+ type: isSupport ? 4 : undefined,
62
78
  onSelectVideoIndex: handleSelectVideoIndex,
63
79
  onLayoutStatusChanged: handleLayoutStatusChanged,
64
80
  onLocalizerViewLocated: handleLocalizerViewLocated
@@ -144,6 +160,10 @@ export const useMultiCameraCtx = props => {
144
160
  * ptz状态
145
161
  */
146
162
  ptzStatus: ptzStatusAtom,
163
+ /**
164
+ * 多目设备支持的 dp
165
+ */
166
+ dpSupportMap,
147
167
  /**
148
168
  * ipcPlayer extendProps
149
169
  */
@@ -5,3 +5,4 @@ export * from './useDpState';
5
5
  export * from './useMemoizedFn';
6
6
  export * from './usePtz';
7
7
  export * from './useSchemaInfo.tsx';
8
+ export * from './useDpSupport';
@@ -4,4 +4,5 @@ export * from './useTemperature';
4
4
  export * from './useDpState';
5
5
  export * from './useMemoizedFn';
6
6
  export * from './usePtz';
7
- export * from './useSchemaInfo.tsx';
7
+ export * from './useSchemaInfo.tsx';
8
+ export * from './useDpSupport';
@@ -0,0 +1,6 @@
1
+ interface Options {
2
+ devId?: string;
3
+ dpCodes: string[];
4
+ }
5
+ export declare function useDpSupport(options: Options): Record<string, boolean>;
6
+ export {};
@@ -0,0 +1,47 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.map.js";
3
+ import "core-js/modules/esnext.iterator.reduce.js";
4
+ import { useEffect, useState } from 'react';
5
+ import { getDeviceInfo } from '@ray-js/ray';
6
+ export function useDpSupport(options) {
7
+ const {
8
+ devId,
9
+ dpCodes
10
+ } = options;
11
+ const [supportedMap, setSupportedMap] = useState(() => {
12
+ var _dpCodes$reduce;
13
+ return (_dpCodes$reduce = dpCodes === null || dpCodes === void 0 ? void 0 : dpCodes.reduce((acc, code) => {
14
+ acc[code] = false;
15
+ return acc;
16
+ }, {})) !== null && _dpCodes$reduce !== void 0 ? _dpCodes$reduce : {};
17
+ });
18
+ useEffect(() => {
19
+ if (!devId || !Array.isArray(dpCodes) || dpCodes.length === 0) {
20
+ var _dpCodes$reduce2;
21
+ setSupportedMap((_dpCodes$reduce2 = dpCodes === null || dpCodes === void 0 ? void 0 : dpCodes.reduce((acc, code) => {
22
+ acc[code] = false;
23
+ return acc;
24
+ }, {})) !== null && _dpCodes$reduce2 !== void 0 ? _dpCodes$reduce2 : {});
25
+ return;
26
+ }
27
+ getDeviceInfo({
28
+ deviceId: devId,
29
+ success: res => {
30
+ const schemaList = Array.isArray(res === null || res === void 0 ? void 0 : res.schema) ? res.schema : [];
31
+ const schemaCodes = new Set(schemaList.map(item => item.code));
32
+ const nextMap = dpCodes.reduce((acc, code) => {
33
+ acc[code] = schemaCodes.has(code);
34
+ return acc;
35
+ }, {});
36
+ setSupportedMap(nextMap);
37
+ },
38
+ fail: () => {
39
+ setSupportedMap(dpCodes.reduce((acc, code) => {
40
+ acc[code] = false;
41
+ return acc;
42
+ }, {}));
43
+ }
44
+ });
45
+ }, [devId, dpCodes]);
46
+ return supportedMap;
47
+ }
@@ -3,3 +3,8 @@ export declare const TEMP_REPORT_F = "temp_report_f";
3
3
  export declare const SENSOR_TEMPERATURE = "sensor_temperature";
4
4
  export declare const SENSOR_HUMIDITY = "sensor_humidity";
5
5
  export declare const PTZ_CONTROL = "ptz_control";
6
+ export declare const GUN_BALL = "ipc_multi_locate_coor";
7
+ export declare const ZOOM_CONTROL = "zoom_control";
8
+ export declare const MULTI_GUN_BALL = "ipc_multi_locate_coors";
9
+ export declare const MULTI_PTZ_CONTROL = "ipc_multi_ptz_control";
10
+ export declare const MULTI_ZOOM_CONTROL = "ipc_multi_zoom_control";
@@ -6,4 +6,14 @@ export const SENSOR_TEMPERATURE = 'sensor_temperature'; // 摄氏度
6
6
 
7
7
  export const SENSOR_HUMIDITY = 'sensor_humidity'; // 湿度
8
8
 
9
- export const PTZ_CONTROL = 'ptz_control'; // ptz
9
+ export const PTZ_CONTROL = 'ptz_control'; // ptz
10
+
11
+ export const GUN_BALL = 'ipc_multi_locate_coor'; // 旧枪球联动-定位器
12
+
13
+ export const ZOOM_CONTROL = 'zoom_control'; // 变焦控制
14
+
15
+ export const MULTI_GUN_BALL = 'ipc_multi_locate_coors'; // 多目枪球联动-定位器
16
+
17
+ export const MULTI_PTZ_CONTROL = 'ipc_multi_ptz_control'; // 多目 PTZ 控制
18
+
19
+ export const MULTI_ZOOM_CONTROL = 'ipc_multi_zoom_control'; // 多目 变焦控制
@@ -60,6 +60,7 @@ export declare const Battery: import("react").FunctionComponent<{
60
60
  nextLayoutStyle: import("../..").RetAtom<import("../..").MultiCameraLayoutStyle>;
61
61
  selectedLenInfo: import("../..").RetAtom<import("../..").MultiCameraLenInfo>;
62
62
  ptzStatus: import("../..").RetAtom<boolean>;
63
+ dpSupportMap: Record<"ptz_control" | "ipc_multi_locate_coor" | "zoom_control" | "ipc_multi_locate_coors" | "ipc_multi_ptz_control" | "ipc_multi_zoom_control", boolean>;
63
64
  extendProps: {
64
65
  type: number | undefined;
65
66
  onSelectVideoIndex: (this: any, event: any) => void;
@@ -137,6 +138,7 @@ export declare const BatteryFull: import("react").FunctionComponent<{
137
138
  nextLayoutStyle: import("../..").RetAtom<import("../..").MultiCameraLayoutStyle>;
138
139
  selectedLenInfo: import("../..").RetAtom<import("../..").MultiCameraLenInfo>;
139
140
  ptzStatus: import("../..").RetAtom<boolean>;
141
+ dpSupportMap: Record<"ptz_control" | "ipc_multi_locate_coor" | "zoom_control" | "ipc_multi_locate_coors" | "ipc_multi_ptz_control" | "ipc_multi_zoom_control", boolean>;
140
142
  extendProps: {
141
143
  type: number | undefined;
142
144
  onSelectVideoIndex: (this: any, event: any) => void;
@@ -74,6 +74,9 @@ export const MoveablePtzControlItem = props => {
74
74
  selectedLenInfo: multiCameraCtx.selectedLenInfo,
75
75
  screenMode: multiCameraCtx.screenMode
76
76
  });
77
+ const {
78
+ dpSupportMap
79
+ } = multiCameraCtx;
77
80
  const [style, setStyle] = useState({
78
81
  positionLeft,
79
82
  positionBottom,
@@ -112,22 +115,29 @@ export const MoveablePtzControlItem = props => {
112
115
  event: touchEvent
113
116
  } = data;
114
117
  touchEvent.stopPropagation();
115
- const dpData = await getDpIdByCode(devId, 'ipc_multi_ptz_control');
118
+ const dpValue = _get(_find(ptzData.current, {
119
+ type
120
+ }), 'dpValue', null);
121
+ const ptzConfig = dpSupportMap.ipc_multi_ptz_control ? {
122
+ code: 'ipc_multi_ptz_control',
123
+ value: JSON.stringify({
124
+ index: selectedLenInfo.index,
125
+ direction: dpValue
126
+ })
127
+ } : dpSupportMap.ptz_control ? {
128
+ code: 'ptz_control',
129
+ value: dpValue
130
+ } : null;
131
+ if (!ptzConfig) return;
132
+ const dpData = await getDpIdByCode(devId, ptzConfig.code);
116
133
  if (dpData.code === 0) {
117
134
  const ptzControlId = dpData.data;
118
- const direction = _get(_find(ptzData.current, {
119
- type
120
- }), 'dpValue', null);
121
- const sndDpValue = JSON.stringify({
122
- index: selectedLenInfo.index,
123
- direction
124
- });
125
135
  publishDps(devId, {
126
- [ptzControlId]: sndDpValue
136
+ [ptzControlId]: ptzConfig.value
127
137
  });
128
138
  ptzTimeId.current = setInterval(() => {
129
139
  publishDps(devId, {
130
- [ptzControlId]: sndDpValue
140
+ [ptzControlId]: ptzConfig.value
131
141
  });
132
142
  }, 1000);
133
143
  }
@@ -139,22 +149,29 @@ export const MoveablePtzControlItem = props => {
139
149
  event: touchEvent
140
150
  } = data;
141
151
  touchEvent.stopPropagation();
142
- const dpData = await getDpIdByCode(devId, 'ipc_multi_zoom_control');
143
- if (dpData.code === 0) {
144
- const ptzControlId = dpData.data;
145
- const control = _get(_find(ptzData.current, {
146
- type
147
- }), 'dpValue', null);
148
- const sndDpValue = JSON.stringify({
152
+ const dpValue = _get(_find(zoomData.current, {
153
+ type
154
+ }), 'dpValue', null);
155
+ const zoomConfig = dpSupportMap.ipc_multi_zoom_control ? {
156
+ code: 'ipc_multi_zoom_control',
157
+ value: JSON.stringify({
149
158
  index: selectedLenInfo.index,
150
- control
151
- });
159
+ control: dpValue
160
+ })
161
+ } : dpSupportMap.zoom_control ? {
162
+ code: 'zoom_control',
163
+ value: dpValue
164
+ } : null;
165
+ if (!zoomConfig) return;
166
+ const dpData = await getDpIdByCode(devId, zoomConfig.code);
167
+ if (dpData.code === 0) {
168
+ const zoomControlId = dpData.data;
152
169
  publishDps(devId, {
153
- [ptzControlId]: sndDpValue
170
+ [zoomControlId]: zoomConfig.value
154
171
  });
155
172
  ptzTimeId.current = setInterval(() => {
156
173
  publishDps(devId, {
157
- [ptzControlId]: sndDpValue
174
+ [zoomControlId]: zoomConfig.value
158
175
  });
159
176
  }, 1000);
160
177
  }
@@ -223,15 +240,22 @@ export const MoveablePtzControlItem = props => {
223
240
  onTouchPtzStart: onTouchPtzStart,
224
241
  onTouchPtzEnd: async () => {
225
242
  screenMode === MultiCameraScreenMode.landscape && event.emit(startTimeToHideAllComponent);
226
- const ptzStopData = await getDpIdByCode(devId, 'ipc_multi_ptz_stop');
227
- if (ptzStopData.code === 0) {
228
- const ptzStopId = ptzStopData.data;
229
- const sendDpValue = JSON.stringify({
243
+ const stopConfig = dpSupportMap.ipc_multi_ptz_control ? {
244
+ code: 'ipc_multi_ptz_stop',
245
+ value: JSON.stringify({
230
246
  index: selectedLenInfo.index
231
- });
232
- publishDps(devId, {
233
- [ptzStopId]: sendDpValue
234
- });
247
+ })
248
+ } : dpSupportMap.ptz_control ? {
249
+ code: 'ptz_stop',
250
+ value: true
251
+ } : null;
252
+ if (stopConfig) {
253
+ const ptzStopData = await getDpIdByCode(devId, stopConfig.code);
254
+ if (ptzStopData.code === 0) {
255
+ publishDps(devId, {
256
+ [ptzStopData.data]: stopConfig.value
257
+ });
258
+ }
235
259
  }
236
260
  if (ptzTimeId.current) {
237
261
  clearInterval(ptzTimeId.current);
@@ -241,15 +265,22 @@ export const MoveablePtzControlItem = props => {
241
265
  onTouchZoomStart: onTouchZoomStart,
242
266
  onTouchZoomEnd: async () => {
243
267
  screenMode === MultiCameraScreenMode.landscape && event.emit(startTimeToHideAllComponent);
244
- const ptzStopData = await getDpIdByCode(devId, 'ipc_multi_zoom_stop');
245
- if (ptzStopData.code === 0) {
246
- const ptzStopId = ptzStopData.data;
247
- const sendDpValue = JSON.stringify({
268
+ const stopConfig = dpSupportMap.ipc_multi_zoom_control ? {
269
+ code: 'ipc_multi_zoom_stop',
270
+ value: JSON.stringify({
248
271
  index: selectedLenInfo.index
249
- });
250
- publishDps(devId, {
251
- [ptzStopId]: sendDpValue
252
- });
272
+ })
273
+ } : dpSupportMap.zoom_control ? {
274
+ code: 'zoom_stop',
275
+ value: true
276
+ } : null;
277
+ if (stopConfig) {
278
+ const zoomStopData = await getDpIdByCode(devId, stopConfig.code);
279
+ if (zoomStopData.code === 0) {
280
+ publishDps(devId, {
281
+ [zoomStopData.data]: stopConfig.value
282
+ });
283
+ }
253
284
  }
254
285
  if (ptzTimeId.current) {
255
286
  clearInterval(ptzTimeId.current);
@@ -63,6 +63,7 @@ export declare const VoiceIntercom: React.ForwardRefExoticComponent<{
63
63
  nextLayoutStyle: import("../../interface").RetAtom<import("../../interface").MultiCameraLayoutStyle>;
64
64
  selectedLenInfo: import("../../interface").RetAtom<import("../../interface").MultiCameraLenInfo>;
65
65
  ptzStatus: import("../../interface").RetAtom<boolean>;
66
+ dpSupportMap: Record<"ptz_control" | "ipc_multi_locate_coor" | "zoom_control" | "ipc_multi_locate_coors" | "ipc_multi_ptz_control" | "ipc_multi_zoom_control", boolean>;
66
67
  extendProps: {
67
68
  type: number | undefined;
68
69
  onSelectVideoIndex: (this: any, event: any) => void;
@@ -73,9 +74,6 @@ export declare const VoiceIntercom: React.ForwardRefExoticComponent<{
73
74
  setScreenMode: (mode: import("../../interface").MultiCameraScreenMode) => void;
74
75
  setPtzStatus: (value: boolean | ((prevValue: boolean) => boolean)) => void;
75
76
  showLenNames: (value: boolean) => void;
76
- /**
77
- * 处理对讲中动画
78
- */
79
77
  setNextLayoutStyle: (value: import("../../interface").MultiCameraLayoutStyle | ((prevValue: import("../../interface").MultiCameraLayoutStyle) => import("../../interface").MultiCameraLayoutStyle)) => void;
80
78
  getNextLayoutStyle: () => Promise<import("../../interface").MultiCameraLayoutStyle>;
81
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.29-beta.1",
3
+ "version": "0.0.29-beta.3",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [