Commit b5be4211d598ba1e537bfcac828001f062332506
Committed by
xp.Huang
1 parent
b22bbead
perf(src/packages/external/Informations): 修改摄像头支持gbt28181播放
Showing
3 changed files
with
43 additions
and
11 deletions
@@ -2,7 +2,8 @@ import { defHttp } from "@/utils/external/http/axios"; | @@ -2,7 +2,8 @@ import { defHttp } from "@/utils/external/http/axios"; | ||
2 | import { useGlobSetting } from '@/hooks/external/setting'; | 2 | import { useGlobSetting } from '@/hooks/external/setting'; |
3 | enum Api { | 3 | enum Api { |
4 | OPEN_FLV = '/rtsp/openFlv', | 4 | OPEN_FLV = '/rtsp/openFlv', |
5 | - CLOSE_FLV = '/rtsp/closeFlv' | 5 | + CLOSE_FLV = '/rtsp/closeFlv', |
6 | + GET_VIDEO_CONTROL_START = '/video/control/start', | ||
6 | } | 7 | } |
7 | 8 | ||
8 | export const getOpenFlvPlayUrl = (url: string, browserId: string) => { | 9 | export const getOpenFlvPlayUrl = (url: string, browserId: string) => { |
@@ -19,3 +20,17 @@ export const closeFlvPlay = (url: string, browserId: string) => { | @@ -19,3 +20,17 @@ export const closeFlvPlay = (url: string, browserId: string) => { | ||
19 | } | 20 | } |
20 | }); | 21 | }); |
21 | }; | 22 | }; |
23 | + | ||
24 | +//gbt28181,获取flv地址 | ||
25 | +export const getVideoControlStart = ({ | ||
26 | + deviceId, | ||
27 | + channelId, | ||
28 | +}: Record<'deviceId' | 'channelId', string>) => { | ||
29 | + return defHttp.get<Recordable>( | ||
30 | + { | ||
31 | + url: `${Api.GET_VIDEO_CONTROL_START}/${deviceId}/${channelId}`, | ||
32 | + timeout: 30 * 1000, | ||
33 | + }, | ||
34 | + {} | ||
35 | + ); | ||
36 | +}; |
@@ -23,6 +23,14 @@ export interface videoListInterface { | @@ -23,6 +23,14 @@ export interface videoListInterface { | ||
23 | label: string | 23 | label: string |
24 | value: string | 24 | value: string |
25 | sn: string | 25 | sn: string |
26 | + channelId: string | ||
27 | + params: GBT28181Params | ||
28 | +} | ||
29 | + | ||
30 | +export interface GBT28181Params { | ||
31 | + channelNo: string | ||
32 | + deviceId: string | ||
33 | + deviceName: string | ||
26 | } | 34 | } |
27 | 35 | ||
28 | export enum AccessMode { | 36 | export enum AccessMode { |
@@ -37,7 +45,7 @@ export const option = { | @@ -37,7 +45,7 @@ export const option = { | ||
37 | poster: '', | 45 | poster: '', |
38 | sourceType: 'custom', | 46 | sourceType: 'custom', |
39 | organization: '', | 47 | organization: '', |
40 | - videoId : '' | 48 | + videoId: '' |
41 | } | 49 | } |
42 | 50 | ||
43 | export default class Config extends PublicConfigClass implements CreateComponentType { | 51 | export default class Config extends PublicConfigClass implements CreateComponentType { |
@@ -61,6 +61,7 @@ import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/Ch | @@ -61,6 +61,7 @@ import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/Ch | ||
61 | import { NTreeSelect } from 'naive-ui' | 61 | import { NTreeSelect } from 'naive-ui' |
62 | import { getOrganizationList, getVideoList, getVideoUrl } from '@/api/external/common/index' | 62 | import { getOrganizationList, getVideoList, getVideoUrl } from '@/api/external/common/index' |
63 | import { TKUpload } from '@/components/external/Common/TKUpload' | 63 | import { TKUpload } from '@/components/external/Common/TKUpload' |
64 | +import { getVideoControlStart } from '@/api/external/flvPlay' | ||
64 | 65 | ||
65 | const props = defineProps({ | 66 | const props = defineProps({ |
66 | optionData: { | 67 | optionData: { |
@@ -100,14 +101,14 @@ const getVideoLists = async (organizationId: string) => { | @@ -100,14 +101,14 @@ const getVideoLists = async (organizationId: string) => { | ||
100 | const res = await getVideoList({ organizationId }) | 101 | const res = await getVideoList({ organizationId }) |
101 | if (!res) return | 102 | if (!res) return |
102 | videoOptions.value = res?.data?.map((item: videoListInterface) => { | 103 | videoOptions.value = res?.data?.map((item: videoListInterface) => { |
103 | - if(item.accessMode === AccessMode.GBT28181) return 0; | ||
104 | return { | 104 | return { |
105 | label: item.name, | 105 | label: item.name, |
106 | - value: item.accessMode === AccessMode.Streaming ? item.id : item.videoUrl, | 106 | + value: item.accessMode === AccessMode.Streaming ? item.id : item.accessMode === AccessMode.ManuallyEnter ? item.videoUrl : item?.params?.deviceId, |
107 | id: item.id, | 107 | id: item.id, |
108 | - accessMode: item.accessMode | ||
109 | - } | ||
110 | - }).filter(Boolean) | 108 | + accessMode: item.accessMode, |
109 | + channelId: item.accessMode === AccessMode.GBT28181 ? item?.params?.channelNo :'' | ||
110 | + } | ||
111 | + }) | ||
111 | } | 112 | } |
112 | 113 | ||
113 | const getVideoUrlById = async (id: string) => { | 114 | const getVideoUrlById = async (id: string) => { |
@@ -126,19 +127,27 @@ const handleChecked = (value: string) => { | @@ -126,19 +127,27 @@ const handleChecked = (value: string) => { | ||
126 | } | 127 | } |
127 | } | 128 | } |
128 | 129 | ||
129 | -const handleSelect = (_: string, e: videoListInterface) => { | ||
130 | - const { accessMode, id, value } = e | ||
131 | - //1表示,需要从服务端调取接口换取播放的地址,0则不需要 | 130 | +const handleSelect = async (_: string, e: videoListInterface) => { |
131 | + const { accessMode, id, value , channelId } = e | ||
132 | + //流媒体,需要从服务端调取接口换取播放的地址 | ||
132 | if (accessMode === AccessMode.Streaming) { | 133 | if (accessMode === AccessMode.Streaming) { |
133 | getVideoUrlById(id) | 134 | getVideoUrlById(id) |
134 | url.value = id | 135 | url.value = id |
135 | props.optionData.videoId = id | 136 | props.optionData.videoId = id |
137 | + } else if (accessMode === AccessMode.GBT28181) { | ||
138 | + //gbt28181,需要调用接口获取flv播放地址 | ||
139 | + if(!value) return | ||
140 | + const { data: { flv } } = await getVideoControlStart({ | ||
141 | + deviceId: value, | ||
142 | + channelId | ||
143 | + }) | ||
144 | + props.optionData.dataset = flv || '' | ||
136 | } else { | 145 | } else { |
137 | props.optionData.dataset = value as string | 146 | props.optionData.dataset = value as string |
138 | } | 147 | } |
139 | } | 148 | } |
140 | 149 | ||
141 | -onMounted(async() => { | 150 | +onMounted(async () => { |
142 | if (props.optionData.sourceType === sourceTypeEnum.PLATFORM) { | 151 | if (props.optionData.sourceType === sourceTypeEnum.PLATFORM) { |
143 | getOriginationList() | 152 | getOriginationList() |
144 | if (props.optionData.organization) { | 153 | if (props.optionData.organization) { |