config.data.ts
17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
import { BasicColumn, FormSchema } from '/@/components/Table';
import { FormSchema as QFormSchema, useComponentRegister } from '/@/components/Form/index';
import { CameraVideoUrl, CameraMaxLength } from '/@/utils/rules';
import { h } from 'vue';
import SnHelpMessage from './SnHelpMessage.vue';
import SnHelpMessage1 from './SnHelpMessage1.vue';
import { OrgTreeSelect } from '../../common/OrgTreeSelect';
import { createImgPreview } from '/@/components/Preview';
import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter';
import { findDictItemByCode } from '/@/api/system/dict';
import { DictEnum } from '/@/enums/dictEnum';
import { DataSourceField } from '../../visual/packages/config/common.config';
import { getMeetTheConditionsDevice } from '/@/api/dataBoard';
import { useMessage } from '/@/hooks/web/useMessage';
import { TransportTypeEnum } from '../../device/profiles/components/TransportDescript/const';
import {
getDeviceChannelList,
getFlvPlayUrl,
getStreamingPlayUrl,
} from '/@/api/camera/cameraManager';
import { CameraRecord } from '/@/api/camera/model/cameraModel';
import { isRtspProtocol } from '/@/components/Video/src/utils';
import { useFingerprint } from '/@/utils/useFingerprint';
import { getVideoControlStart } from '/@/api/device/videoChannel';
import { StreamType as PlayerStreamType } from '/@/components/Video/src/types';
import { useGlobSetting } from '/@/hooks/setting';
interface FileItem {
uid: string;
name: string;
status?: string;
response?: string;
url?: string;
}
useComponentRegister('OrgTreeSelect', OrgTreeSelect);
export interface StreamInterface {
label: string;
value: string;
type?: string;
}
//设备通道接口
export interface DeviceChannelInterface {
[x: string]: string | string[];
}
export enum CameraPermission {
PREVIEW = 'api:yt:video:get',
CREATE = 'api:yt:video:post',
UPDATE = 'api:yt:video:update',
DELETE = 'api:yt:video:delete',
}
// GBT28181设备选择全选或者部分
export enum GBT28181DeviceSelectMethod {
ALL = 1, //全部
PARTIAL = 0, //部分
}
export enum AccessMode {
ManuallyEnter = 0,
Streaming = 1,
GBT28181 = 2,
}
export enum PlayProtocol {
HTTP = 0,
HTTPS = 1,
}
export enum StreamType {
MASTER = 0,
CHILD = 1,
THIRD = 2,
}
export enum PageMode {
SPLIT_SCREEN_MODE = 'splitScreen',
LIST_MODE = 'listMode',
FULL_SCREEN_MODE = 'fullScreenMode',
}
export enum MediaType {
MP4 = 'mp4',
M3U8 = 'm3u8',
}
export enum FluoriteMideaProtocolEnum {
HLS = 2,
FLV = 4,
}
export enum ArticulationEnumType {
HIGH_DEFINITION = 1,
SMOOTH = 2,
}
export enum ArticulationEnumNameType {
HIGH_DEFINITION = '高清',
SMOOTH = '流畅',
}
//获取方式文字和Tag颜色配置
export const accessModeConfig = [
{
key: AccessMode.ManuallyEnter,
text: '手动输入',
color: 'cyan',
},
{
key: AccessMode.Streaming,
text: '流媒体获取',
color: 'blue',
},
{
key: AccessMode.GBT28181,
text: 'GBT28181',
color: 'orange',
},
];
// 表格列数据
export const columns: BasicColumn[] = [
{
title: '封面',
dataIndex: 'avatar',
width: 80,
slots: { customRender: 'img' },
},
{
title: '名字',
dataIndex: 'name',
width: 120,
},
{
title: '摄像头编号/监控点编号',
dataIndex: 'sn',
width: 220,
},
{
title: '视频流',
dataIndex: 'videoUrl',
width: 120,
},
{
title: '所属组织',
dataIndex: 'organizationName',
width: 160,
},
{
title: '获取方式',
dataIndex: 'accessMode',
width: 100,
slots: { customRender: 'accessMode' },
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 140,
},
];
// 查询字段
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '摄像头名字',
component: 'Input',
colProps: { span: 8 },
componentProps: {
maxLength: 36,
placeholder: '请输入摄像头名字',
},
},
];
export enum VideoPlatformEnum {
// 海康
ISC = 0,
// 萤石云
FLUORITE = 1,
}
// 弹框配置项
export const formSchema: QFormSchema[] = [
{
field: 'avatar',
label: '视频封面',
component: 'ApiUpload',
changeEvent: 'update:fileList',
valueField: 'fileList',
componentProps: ({ formModel }) => {
return {
listType: 'picture-card',
maxFileLimit: 1,
accept: '.png,.jpg,.jpeg,.gif',
api: async (file: File) => {
try {
const formData = new FormData();
formData.set('file', file);
const { fileStaticUri, fileName } = await uploadThumbnail(formData);
return {
uid: fileStaticUri,
name: fileName,
url: fileStaticUri,
} as FileItem;
} catch (error) {
return {};
}
},
onPreview: (fileList: FileItem) => {
createImgPreview({ imageList: [fileList.url!] });
},
onDelete(url: string) {
formModel.deleteUrl = url!;
},
};
},
},
{
field: 'deleteUrl',
label: '',
component: 'Input',
show: false,
},
{
field: 'name',
label: '视频名字',
required: true,
component: 'Input',
componentProps: {
placeholder: '请输入视频名字',
maxLength: 30,
},
rules: [...CameraMaxLength, { required: true, message: '视频名是必填项' }],
},
{
field: 'organizationId',
label: '所属组织',
required: true,
component: 'OrgTreeSelect',
componentProps({ formActionType }) {
return {
onChange() {
formActionType.setFieldsValue({
deviceId: null,
channelNo: null,
});
},
};
},
},
{
label: '视频流获取方式',
field: 'accessMode',
component: 'RadioGroup',
rules: [{ required: true, message: '视频流获取方式为必选项', type: 'number' }],
defaultValue: AccessMode.ManuallyEnter,
componentProps({ formActionType }) {
return {
defaultValue: AccessMode.ManuallyEnter,
placeholder: '请选择视频流获取方式',
options: [
{ label: '手动输入', value: AccessMode.ManuallyEnter },
{ label: '流媒体获取', value: AccessMode.Streaming },
{ label: 'GBT28181', value: AccessMode.GBT28181 },
],
onChange() {
formActionType.setFieldsValue({
brand: null,
sn: null,
videoUrl: null,
videoPlatformId: null,
});
},
};
},
},
{
field: 'deviceName',
label: '设备名称',
component: 'Input',
show: false,
},
{
field: 'deviceId',
label: '设备',
required: true,
component: 'ApiSelect',
componentProps({ formModel, formActionType }) {
const { setFieldsValue } = formActionType;
const organizationId = formModel[DataSourceField.ORIGINATION_ID];
return {
api: async () => {
if (organizationId) {
try {
const data = await getMeetTheConditionsDevice({
organizationId,
transportType: TransportTypeEnum.GBT28181,
});
if (data)
return data.map((item) => ({
...item,
label: item.alias || item.name,
value: item.tbDeviceId,
deviceType: item.deviceType,
}));
} catch (error) {}
}
return [];
},
placeholder: '请选择设备',
onChange(_, options) {
const { name, alias } = options;
setFieldsValue({
channelNo: [],
deviceName: alias || name,
});
},
onFocus() {
const { createMessage } = useMessage();
if (!organizationId) return createMessage.error('请先选择组织');
},
};
},
ifShow({ values }) {
return values.accessMode === AccessMode.GBT28181;
},
},
{
field: 'channelNo',
label: '通道号',
required: true,
component: 'ApiSelect',
ifShow({ values }) {
return values.accessMode === AccessMode.GBT28181;
},
componentProps({ formModel }) {
const deviceId = formModel[DataSourceField.DEVICE_ID];
return {
api: async () => {
if (deviceId) {
try {
const data = await getDeviceChannelList(deviceId);
if (data)
return data.map((item) => ({
...item,
label: item.name || item.channelId,
value: item.channelId,
}));
} catch (error) {}
}
return [];
},
placeholder: '请选择通道号',
};
},
},
{
field: 'brand',
label: '视频厂家',
component: 'Input',
ifShow({ values }) {
return values.accessMode === AccessMode.ManuallyEnter;
},
componentProps: {
maxLength: 36,
placeholder: '请输入视频厂家',
},
},
{
field: 'sn',
label: '摄像头编号',
required: true,
component: 'Input',
rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],
ifShow({ values }) {
return values.accessMode === AccessMode.ManuallyEnter;
},
componentProps: {
maxLength: 36,
placeholder: '请输入摄像头编号',
},
},
{
field: 'videoUrl',
label: '视频流',
component: 'Input',
required: true,
ifShow({ values }) {
return values.accessMode === AccessMode.ManuallyEnter;
},
componentProps: {
placeholder: '请输入视频流',
maxLength: 255,
},
rules: [{ required: true, message: '视频流是必填项' }, ...CameraVideoUrl],
},
{
field: 'videoType',
label: '流媒体平台',
component: 'ApiRadioGroup',
required: true,
defaultValue: VideoPlatformEnum.ISC,
ifShow: ({ values }) => values.accessMode === AccessMode.Streaming,
componentProps: ({ formActionType }) => {
return {
api: async (params) => {
const values = await findDictItemByCode(params);
return values.map((item) => ({ label: item.itemText, value: Number(item.itemValue) }));
},
params: {
dictCode: DictEnum.STREAMING_MEDIA_TYPE,
},
getPopupContainer: () => document.body,
placeholder: `请选择平台类型`,
onChange() {
const { setFieldsValue } = formActionType;
setFieldsValue({
articulation: ArticulationEnumType.HIGH_DEFINITION,
playProtocol: PlayProtocol.HTTP,
sn: null,
channelNo: null,
videoPlatformId: null,
});
},
};
},
},
{
field: 'videoPlatformId',
label: '流媒体配置',
component: 'Select',
ifShow({ values }) {
return values.accessMode === AccessMode.Streaming;
},
slot: 'videoPlatformIdSlot',
componentProps: {
placeholder: '请选择流媒体配置',
},
},
{
field: 'streamType',
label: '码流',
component: 'RadioGroup',
defaultValue: StreamType.MASTER,
ifShow({ values }) {
return (
values.accessMode === AccessMode.Streaming &&
values.videoType !== VideoPlatformEnum.FLUORITE
);
},
componentProps: {
placeholder: '请选择码流',
defaultValue: StreamType.MASTER,
options: [
{ label: '主码流', value: StreamType.MASTER },
{ label: '子码流', value: StreamType.CHILD },
{ label: '第三码流', value: StreamType.THIRD },
],
},
},
{
field: 'articulation',
label: '清晰度',
component: 'RadioGroup',
defaultValue: ArticulationEnumType.HIGH_DEFINITION,
ifShow: ({ model }) =>
model.accessMode === AccessMode.Streaming && model.videoType === VideoPlatformEnum.FLUORITE,
componentProps: () => {
return {
options: [
{
label: ArticulationEnumNameType.HIGH_DEFINITION,
value: ArticulationEnumType.HIGH_DEFINITION,
},
{
label: ArticulationEnumNameType.SMOOTH,
value: ArticulationEnumType.SMOOTH,
},
],
};
},
},
{
field: 'videoFormat',
label: '视频格式',
component: 'Select',
ifShow: ({ model }) =>
model.accessMode === AccessMode.Streaming && model.videoType === VideoPlatformEnum.FLUORITE,
defaultValue: FluoriteMideaProtocolEnum.FLV,
required: true,
componentProps: {
options: [
{ label: 'FLV', value: FluoriteMideaProtocolEnum.FLV },
{ label: 'HLS', value: FluoriteMideaProtocolEnum.HLS },
],
allowClear: false,
},
},
{
field: 'playProtocol',
label: '播放协议',
component: 'RadioGroup',
defaultValue: PlayProtocol.HTTP,
ifShow({ values }) {
return (
values.accessMode === AccessMode.Streaming &&
values.videoType !== VideoPlatformEnum.FLUORITE
);
},
helpMessage: ['平台使用https的hls协议,需联系海康开放平台专家支持。'],
componentProps: {
placeholder: '请选择播放协议',
defaultValue: PlayProtocol.HTTP,
options: [
{ label: 'http', value: PlayProtocol.HTTP },
{ label: 'https', value: PlayProtocol.HTTPS },
],
},
},
{
field: 'sn',
label: h(SnHelpMessage) as any,
component: 'Input',
rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],
ifShow({ values }) {
return (
values.accessMode === AccessMode.Streaming &&
values.videoType !== VideoPlatformEnum.FLUORITE
);
},
componentProps: {
placeholder: '请输入监控点编号',
},
},
{
field: 'sn',
label: h(SnHelpMessage1) as any,
component: 'Input',
rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],
ifShow({ values }) {
return (
values.accessMode === AccessMode.Streaming &&
values.videoType === VideoPlatformEnum.FLUORITE
);
},
componentProps: {
placeholder: '请输入监控点编号',
},
},
{
field: 'channelNo',
label: '通道号',
component: 'InputNumber',
ifShow({ values }) {
return (
values.accessMode === AccessMode.Streaming &&
values.videoType === VideoPlatformEnum.FLUORITE
);
},
componentProps: {
min: 1,
max: 10000,
step: 1,
placeholder: '请输入通道号',
precision: 0,
},
},
];
// GBT28181表单配置项
export const formGBTSchema: QFormSchema[] = [
{
label: '视频流获取方式',
field: 'accessMode',
component: 'RadioGroup',
rules: [{ required: true, message: '视频流获取方式为必选项', type: 'number' }],
defaultValue: AccessMode.GBT28181,
componentProps({ formActionType }) {
return {
defaultValue: AccessMode.ManuallyEnter,
placeholder: '请选择视频流获取方式',
options: [{ label: 'GBT28181', value: AccessMode.GBT28181 }],
onChange() {
formActionType.setFieldsValue({
brand: null,
sn: null,
videoUrl: null,
videoPlatformId: null,
});
},
};
},
},
{
field: 'organizationId',
label: '所属组织',
required: true,
component: 'OrgTreeSelect',
ifShow: ({ values }) => values.accessMode === AccessMode.GBT28181,
},
{
label: '设备选择方式',
field: 'allDevice',
component: 'RadioGroup',
rules: [{ required: true, message: '设备选择方式为必选项', type: 'number' }],
defaultValue: GBT28181DeviceSelectMethod.ALL,
componentProps() {
return {
defaultValue: GBT28181DeviceSelectMethod.ALL,
placeholder: '请选择设备选择方式',
options: [
{ label: '全部', value: GBT28181DeviceSelectMethod.ALL },
{ label: '部分', value: GBT28181DeviceSelectMethod.PARTIAL },
],
};
},
ifShow: ({ values }) => !!values.organizationId,
},
{
field: 'deviceChannels',
label: '设备和通道号',
component: 'Input',
slot: 'deviceChannelsSlot',
ifShow: ({ values }) =>
values.accessMode === AccessMode.GBT28181 &&
values.allDevice === GBT28181DeviceSelectMethod.PARTIAL,
},
];
export async function getPlayUrl(
params: CameraRecord
): Promise<{ url: string; type: PlayerStreamType }> {
const { accessMode } = params;
if (accessMode === AccessMode.ManuallyEnter) {
const { videoUrl } = params;
if (params.videoUrl) {
const isRTSPPlay = isRtspProtocol(videoUrl);
if (isRTSPPlay) {
const { getResult } = useFingerprint();
const fingerprint = await getResult();
return { url: getFlvPlayUrl(videoUrl, fingerprint.visitorId), type: 'flv' };
} else {
return { url: videoUrl, type: 'auto' };
}
}
} else if (accessMode === AccessMode.GBT28181) {
const { deviceId, channelNo } = params?.params || {};
const result = await getVideoControlStart({ channelId: channelNo!, deviceId: deviceId! });
const { streamMediaContentSecurityProtocol } = useGlobSetting();
return {
url: !!streamMediaContentSecurityProtocol ? result.data.https_flv : result.data.flv,
type: 'flv',
};
} else {
const { id, playProtocol } = params;
const result = await getStreamingPlayUrl(id);
const type: PlayerStreamType =
playProtocol === FluoriteMideaProtocolEnum.FLV
? 'flv'
: playProtocol === FluoriteMideaProtocolEnum.HLS
? 'hls'
: 'auto';
return { url: result.data.url, type };
}
}