From 5f2252187c0d6b70fb4d07256831a27374270477 Mon Sep 17 00:00:00 2001 From: chunquansang <916920620@è¯@qq.com> Date: Tue, 7 Nov 2023 11:13:14 +0800 Subject: [PATCH] =?UTF-8?q?feat=20h264=E7=9B=91=E6=8E=A7=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/zh-CN/common.ts | 4 +- .../DeviceList/components/VideoModal.tsx | 3 +- src/pages/Device/DeviceList/index.tsx | 37 ++++++++++++++++--- src/services/device/Device.ts | 34 +++++++++++++++++ src/services/device/typings.d.ts | 14 +++++++ 5 files changed, 85 insertions(+), 7 deletions(-) diff --git a/src/locales/zh-CN/common.ts b/src/locales/zh-CN/common.ts index a17c10b..1fad7a9 100644 --- a/src/locales/zh-CN/common.ts +++ b/src/locales/zh-CN/common.ts @@ -41,5 +41,7 @@ export default { 'common.confirm_publish': '确认发布', 'common.set_default': '设为默认版本', 'common.bind_device': '绑定设备', - "common.tip.title": '温馨提示' + "common.tip.title": '温馨提示', + 'common.video_opening': '视频打开中', + 'common.open_failure': '打开失败', } diff --git a/src/pages/Device/DeviceList/components/VideoModal.tsx b/src/pages/Device/DeviceList/components/VideoModal.tsx index 3d31527..b1bcd83 100644 --- a/src/pages/Device/DeviceList/components/VideoModal.tsx +++ b/src/pages/Device/DeviceList/components/VideoModal.tsx @@ -16,6 +16,7 @@ export type VideoModalProps = { handleModal: () => void; values: Partial; reload: any; + videoServerParam: API.RtspRes; }; const VideoModal: React.FC = (props) => { @@ -44,7 +45,7 @@ const VideoModal: React.FC = (props) => { width={1280} onOk={props.handleModal} onCancel={props.handleModal} footer={null}> - {videoInit && ()} + {videoInit && ()} ) diff --git a/src/pages/Device/DeviceList/index.tsx b/src/pages/Device/DeviceList/index.tsx index 6e48abc..1461d97 100644 --- a/src/pages/Device/DeviceList/index.tsx +++ b/src/pages/Device/DeviceList/index.tsx @@ -16,7 +16,7 @@ import {ColumnDrawer as DeviceCategoryColumnDrawer} from "@/pages/Device/DeviceC import { deleteDeviceDeleteDevice, postDeviceGetDeviceList, - deleteDeviceDeleteDeviceByIds + deleteDeviceDeleteDeviceByIds, postDeviceOpenRtspCamera, postDeviceCloseRtspCamera } from '@/services/device/Device'; import {PlusOutlined, RedoOutlined} from '@ant-design/icons'; import type {ActionType, ProColumns} from '@ant-design/pro-components'; @@ -73,8 +73,8 @@ const DeviceList: React.FC = () => { const [hasInit, setHasInit] = useState(false) const [nodeTreeData, setNodeTreeData] = React.useState([]); const [selectNodes, setSelectNodes] = React.useState([]); - - + const [videoOpening, setVideoOpening] = useState(false); + const [videoServerParam, setVideoServerParam] = useState({}) useEffect(() => { postDeviceGroupGetDeviceGroupTree().then((resp) => { setNodeTreeData(resp.data.tree) @@ -86,7 +86,13 @@ const DeviceList: React.FC = () => { const handleVideoModal = ()=>{ if (videoModalOpen) { setVideoModalOpen(false) + if (videoServerParam?.pid || 0) { + postDeviceCloseRtspCamera({pid: videoServerParam.pid}).then((resp) => { + console.log(resp) + }) + } setCurrentRow(undefined) + setVideoServerParam({}) } else { setVideoModalOpen(true) } @@ -394,8 +400,24 @@ const DeviceList: React.FC = () => { { - setVideoModalOpen(true); - setCurrentRow(record); + setVideoOpening(true) + if (record.param) { + postDeviceOpenRtspCamera({url: record.param}).then((resp) => { + setVideoServerParam(resp.data) + setVideoOpening(false) + setVideoModalOpen(true); + console.log(resp.data) + setCurrentRow(record); + }).catch(()=>{ + setVideoOpening(false) + message.error(intl.formatMessage({id: 'common.open_failure', defaultMessage: '$$$'})) + }) + } else { + setVideoOpening(false) + message.error(intl.formatMessage({id: 'common.open_failure', defaultMessage: '$$$'})) + } + // setVideoModalOpen(true); + // setCurrentRow(record); }}> @@ -430,6 +452,10 @@ const DeviceList: React.FC = () => { id: 'pages.searchTable.title', defaultMessage: '$$$', })} + loading={{tip: intl.formatMessage({ + id: 'common.video_opening', + defaultMessage: '$$$' + }), spinning: videoOpening}} options={{fullScreen: true, setting: true, density: true, reload: true}} actionRef={actionRef} rowKey="key" @@ -612,6 +638,7 @@ const DeviceList: React.FC = () => { diff --git a/src/services/device/Device.ts b/src/services/device/Device.ts index f073693..28a65e2 100644 --- a/src/services/device/Device.ts +++ b/src/services/device/Device.ts @@ -118,3 +118,37 @@ export async function putDeviceUpdateDevice(body: API.Device, options?: { [key: ...(options || {}), }); } + +/** 关闭rtsp摄像头驱动 POST /device/closeRtspCamera */ +export async function postDeviceCloseRtspCamera( + body: API.KillRtspReq, + options?: { [key: string]: any }, +) { + return request(`/api/v1/device/closeRtspCamera`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} + + +/** 打开rtsp摄像头驱动 POST /device/openRtspCamera */ +export async function postDeviceOpenRtspCamera( + body: API.RtspReq, + options?: { [key: string]: any }, +) { + return request( + `/api/v1/device/openRtspCamera`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }, + ); +} diff --git a/src/services/device/typings.d.ts b/src/services/device/typings.d.ts index c8b81e4..1452e83 100644 --- a/src/services/device/typings.d.ts +++ b/src/services/device/typings.d.ts @@ -23,6 +23,20 @@ declare namespace API { updateTime?: string; }; + type RtspReq = { + /** rtsp地址 */ + url?: string; + }; + type KillRtspReq = { + /** rtsp地址 */ + pid?: number; + }; + + type RtspRes = { + host?: string; + pid?: number; + }; + type DeviceDeviceCategoryResponse = { deviceCategory?: DeviceCategory; };