From 088419b4d8965e37774a217c5a8135e95fc82c5a Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: 星期三, 20 四月 2022 09:38:09 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/wvp-28181-2.0' into map --- src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java | 3 src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java | 3 src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java | 13 src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java | 21 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 4 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java | 3 web_src/src/components/dialog/catalogEdit.vue | 15 bootstrap.sh | 91 +++ src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java | 15 pom.xml | 2 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java | 4 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java | 2 src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java | 10 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java | 3 src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java | 22 web_src/src/components/dialog/SyncChannelProgress.vue | 45 + web_src/src/components/dialog/deviceEdit.vue | 3 src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java | 13 sql/mysql.sql | 426 ++++++++-------- src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java | 3 src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java | 8 sql/clean.sql | 13 src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java | 2 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java | 15 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 25 web_src/src/components/dialog/platformEdit.vue | 30 + src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java | 64 + src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java | 39 + src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 4 src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java | 4 src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java | 7 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java | 282 +++++----- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java | 59 +- README.md | 4 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java | 4 src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java | 12 src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java | 1 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java | 173 ++++-- sql/update.sql | 14 39 files changed, 891 insertions(+), 570 deletions(-) diff --git a/README.md b/README.md index 69645b0..aec9555 100644 --- a/README.md +++ b/README.md @@ -134,10 +134,10 @@ 鎰熻阿浣滆�匸dexter langhuihui](https://github.com/langhuihui) 寮�婧愯繖涔堝ソ鐢ㄧ殑WEB鎾斁鍣ㄣ�� 鎰熻阿浣滆�匸Kyle](https://gitee.com/kkkkk5G) 寮�婧愪簡濂界敤鐨勫墠绔〉闈� 鎰熻阿鍚勪綅澶т浆鐨勮禐鍔╀互鍙婂椤圭洰鐨勬寚姝d笌甯姪銆傚寘鎷絾涓嶉檺浜庝唬鐮佽础鐚�侀棶棰樺弽棣堛�佽祫閲戞崘璧犵瓑鍚勭鏂瑰紡鐨勬敮鎸侊紒浠ヤ笅鎺掑悕涓嶅垎鍏堝悗锛� -[lawrencehj](https://github.com/lawrencehj) @闄嗕赴-鍒涘绉戞妧 [swwhaha](https://github.com/swwheihei) +[lawrencehj](https://github.com/lawrencehj) [Smallwhitepig](https://github.com/Smallwhitepig) [swwhaha](https://github.com/swwheihei) [hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen) [chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb) -[ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) +[ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666) ps: 鍒氬鍔犱簡杩欎釜鍚嶅崟锛岃偗瀹氶仐婕忎簡涓�浜涘ぇ浣紝娆㈣繋澶т浆鑱旂郴鎴戞坊鍔犮�� diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..0f3c4c9 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +###################################################### +# Copyright 2019 Pham Ngoc Hoai +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Repo: https://github.com/tyrion9/spring-boot-startup-script +# +######### PARAM ###################################### + +JAVA_OPT=-Xmx1024m +JARFILE=`ls -1r *.jar 2>/dev/null | head -n 1` +PID_FILE=pid.file +RUNNING=N +PWD=`pwd` + +######### DO NOT MODIFY ######## + +if [ -f $PID_FILE ]; then + PID=`cat $PID_FILE` + if [ ! -z "$PID" ] && kill -0 $PID 2>/dev/null; then + RUNNING=Y + fi +fi + +start() +{ + if [ $RUNNING == "Y" ]; then + echo "Application already started" + else + if [ -z "$JARFILE" ] + then + echo "ERROR: jar file not found" + else + nohup java $JAVA_OPT -Djava.security.egd=file:/dev/./urandom -jar $PWD/$JARFILE > nohup.out 2>&1 & + echo $! > $PID_FILE + echo "Application $JARFILE starting..." + tail -f nohup.out + fi + fi +} + +stop() +{ + if [ $RUNNING == "Y" ]; then + kill -9 $PID + rm -f $PID_FILE + echo "Application stopped" + else + echo "Application not running" + fi +} + +restart() +{ + stop + start +} + +case "$1" in + + 'start') + start + ;; + + 'stop') + stop + ;; + + 'restart') + restart + ;; + + *) + echo "Usage: $0 { start | stop | restart }" + exit 1 + ;; +esac +exit 0 + diff --git a/pom.xml b/pom.xml index 7ad53db..befb74f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ <groupId>com.genersoft</groupId> <artifactId>wvp-pro</artifactId> - <version>2.0.2</version> + <version>2.1.1</version> <name>web video platform</name> <description>鍥芥爣28181瑙嗛骞冲彴</description> diff --git a/sql/clean.sql b/sql/clean.sql new file mode 100644 index 0000000..b834391 --- /dev/null +++ b/sql/clean.sql @@ -0,0 +1,13 @@ +delete from device; +delete from device_alarm; +delete from device_channel; +delete from device_mobile_position; +delete from gb_stream; +delete from log; +delete from media_server; +delete from parent_platform; +delete from platform_catalog; +delete from platform_gb_channel; +delete from platform_gb_stream; +delete from stream_proxy; +delete from stream_push; \ No newline at end of file diff --git a/sql/mysql.sql b/sql/mysql.sql index d1706b3..cffaa69 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -1,13 +1,13 @@ --- MySQL dump 10.13 Distrib 8.0.28, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.7.3-MariaDB, for Linux (x86_64) -- --- Host: 127.0.0.1 Database: wvp +-- Host: 127.0.0.1 Database: wvp3 -- ------------------------------------------------------ --- Server version 8.0.28-0ubuntu0.20.04.3 +-- Server version 8.0.0-dmr /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!50503 SET NAMES utf8mb4 */; +/*!40101 SET NAMES utf8mb4 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -21,33 +21,34 @@ DROP TABLE IF EXISTS `device`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `device` ( - `id` int NOT NULL AUTO_INCREMENT, - `deviceId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `manufacturer` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `model` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `firmware` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `transport` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `streamMode` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `online` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `registerTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `keepaliveTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `ip` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `createTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `updateTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `port` int NOT NULL, - `expires` int NOT NULL, - `subscribeCycleForCatalog` int NOT NULL, - `subscribeCycleForMobilePosition` int NOT NULL, - `mobilePositionSubmissionInterval` int DEFAULT 5 NOT NULL, - `subscribeCycleForAlarm` int NOT NULL, - `hostAddress` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `charset` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `deviceId` varchar(50) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `manufacturer` varchar(255) DEFAULT NULL, + `model` varchar(255) DEFAULT NULL, + `firmware` varchar(255) DEFAULT NULL, + `transport` varchar(50) DEFAULT NULL, + `streamMode` varchar(50) DEFAULT NULL, + `online` varchar(50) DEFAULT NULL, + `registerTime` varchar(50) DEFAULT NULL, + `keepaliveTime` varchar(50) DEFAULT NULL, + `ip` varchar(50) NOT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, + `port` int(11) NOT NULL, + `expires` int(11) NOT NULL, + `subscribeCycleForCatalog` int(11) NOT NULL, + `subscribeCycleForMobilePosition` int(11) NOT NULL, + `mobilePositionSubmissionInterval` int(11) NOT NULL DEFAULT '5', + `subscribeCycleForAlarm` int(11) NOT NULL, + `hostAddress` varchar(50) NOT NULL, + `charset` varchar(50) NOT NULL, + `ssrcCheck` int(11) DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `device_deviceId_uindex` (`deviceId`) -) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -65,20 +66,20 @@ DROP TABLE IF EXISTS `device_alarm`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `device_alarm` ( - `id` int NOT NULL AUTO_INCREMENT, - `deviceId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `channelId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `alarmPriority` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `alarmMethod` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `alarmTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `alarmDescription` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `deviceId` varchar(50) NOT NULL, + `channelId` varchar(50) NOT NULL, + `alarmPriority` varchar(50) NOT NULL, + `alarmMethod` varchar(50) DEFAULT NULL, + `alarmTime` varchar(50) NOT NULL, + `alarmDescription` varchar(255) DEFAULT NULL, `longitude` double DEFAULT NULL, `latitude` double DEFAULT NULL, - `alarmType` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `alarmType` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -96,43 +97,43 @@ DROP TABLE IF EXISTS `device_channel`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `device_channel` ( - `id` int NOT NULL AUTO_INCREMENT, - `channelId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `manufacture` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `model` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `owner` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `civilCode` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `block` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `address` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `parentId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `safetyWay` int DEFAULT NULL, - `registerWay` int DEFAULT NULL, - `certNum` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `certifiable` int DEFAULT NULL, - `errCode` int DEFAULT NULL, - `endTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `secrecy` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `ipAddress` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `port` int DEFAULT NULL, - `password` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `PTZType` int DEFAULT NULL, - `status` int DEFAULT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `channelId` varchar(50) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `manufacture` varchar(50) DEFAULT NULL, + `model` varchar(50) DEFAULT NULL, + `owner` varchar(50) DEFAULT NULL, + `civilCode` varchar(50) DEFAULT NULL, + `block` varchar(50) DEFAULT NULL, + `address` varchar(50) DEFAULT NULL, + `parentId` varchar(50) DEFAULT NULL, + `safetyWay` int(11) DEFAULT NULL, + `registerWay` int(11) DEFAULT NULL, + `certNum` varchar(50) DEFAULT NULL, + `certifiable` int(11) DEFAULT NULL, + `errCode` int(11) DEFAULT NULL, + `endTime` varchar(50) DEFAULT NULL, + `secrecy` varchar(50) DEFAULT NULL, + `ipAddress` varchar(50) DEFAULT NULL, + `port` int(11) DEFAULT NULL, + `password` varchar(255) DEFAULT NULL, + `PTZType` int(11) DEFAULT NULL, + `status` int(11) DEFAULT NULL, `longitude` double DEFAULT NULL, `latitude` double DEFAULT NULL, - `streamId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `deviceId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `parental` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, + `streamId` varchar(50) DEFAULT NULL, + `deviceId` varchar(50) NOT NULL, + `parental` varchar(50) DEFAULT NULL, `hasAudio` bit(1) DEFAULT NULL, - `createTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `updateTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `subCount` int DEFAULT '0', + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, + `subCount` int(11) DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `device_channel_id_uindex` (`id`), UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) -) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=81657 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -150,24 +151,24 @@ DROP TABLE IF EXISTS `device_mobile_position`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `device_mobile_position` ( - `id` int NOT NULL AUTO_INCREMENT, - `deviceId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `channelId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `deviceName` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `time` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `deviceId` varchar(50) NOT NULL, + `channelId` varchar(50) NOT NULL, + `deviceName` varchar(255) DEFAULT NULL, + `time` varchar(50) NOT NULL, `longitude` double NOT NULL, `latitude` double NOT NULL, `altitude` double DEFAULT NULL, `speed` double DEFAULT NULL, `direction` double DEFAULT NULL, - `reportSource` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `geodeticSystem` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `cnLng` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `cnLat` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, + `reportSource` varchar(50) DEFAULT NULL, + `geodeticSystem` varchar(50) DEFAULT NULL, + `cnLng` varchar(50) DEFAULT NULL, + `cnLat` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6108 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -185,23 +186,23 @@ DROP TABLE IF EXISTS `gb_stream`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `gb_stream` ( - `gbStreamId` int NOT NULL AUTO_INCREMENT, - `app` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `stream` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `gbId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `gbStreamId` int(11) NOT NULL AUTO_INCREMENT, + `app` varchar(255) NOT NULL, + `stream` varchar(255) NOT NULL, + `gbId` varchar(50) NOT NULL, + `name` varchar(255) DEFAULT NULL, `longitude` double DEFAULT NULL, `latitude` double DEFAULT NULL, - `streamType` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `status` int DEFAULT NULL, - `createStamp` bigint DEFAULT NULL, + `streamType` varchar(50) DEFAULT NULL, + `mediaServerId` varchar(50) DEFAULT NULL, + `status` int(11) DEFAULT NULL, + `createStamp` bigint(20) DEFAULT NULL, PRIMARY KEY (`gbStreamId`) USING BTREE, UNIQUE KEY `app` (`app`,`stream`) USING BTREE, UNIQUE KEY `gbId` (`gbId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=300766 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=300769 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -219,19 +220,19 @@ DROP TABLE IF EXISTS `log`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `log` ( - `id` int NOT NULL AUTO_INCREMENT, - `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `uri` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `result` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `timing` bigint NOT NULL, - `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `type` varchar(50) NOT NULL, + `uri` varchar(200) NOT NULL, + `address` varchar(50) NOT NULL, + `result` varchar(50) NOT NULL, + `timing` bigint(20) NOT NULL, + `username` varchar(50) NOT NULL, + `createTime` varchar(50) NOT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=962 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=1552 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -249,34 +250,34 @@ DROP TABLE IF EXISTS `media_server`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `media_server` ( - `id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `hookIp` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `sdpIp` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `streamIp` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `httpPort` int NOT NULL, - `httpSSlPort` int NOT NULL, - `rtmpPort` int NOT NULL, - `rtmpSSlPort` int NOT NULL, - `rtpProxyPort` int NOT NULL, - `rtspPort` int NOT NULL, - `rtspSSLPort` int NOT NULL, - `autoConfig` int NOT NULL, - `secret` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `streamNoneReaderDelayMS` int NOT NULL, - `rtpEnable` int NOT NULL, - `rtpPortRange` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `sendRtpPortRange` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `recordAssistPort` int NOT NULL, - `defaultServer` int NOT NULL, - `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `hookAliveInterval` int NOT NULL, + `id` varchar(255) NOT NULL, + `ip` varchar(50) NOT NULL, + `hookIp` varchar(50) NOT NULL, + `sdpIp` varchar(50) NOT NULL, + `streamIp` varchar(50) NOT NULL, + `httpPort` int(11) NOT NULL, + `httpSSlPort` int(11) NOT NULL, + `rtmpPort` int(11) NOT NULL, + `rtmpSSlPort` int(11) NOT NULL, + `rtpProxyPort` int(11) NOT NULL, + `rtspPort` int(11) NOT NULL, + `rtspSSLPort` int(11) NOT NULL, + `autoConfig` int(11) NOT NULL, + `secret` varchar(50) NOT NULL, + `streamNoneReaderDelayMS` int(11) NOT NULL, + `rtpEnable` int(11) NOT NULL, + `rtpPortRange` varchar(50) NOT NULL, + `sendRtpPortRange` varchar(50) NOT NULL, + `recordAssistPort` int(11) NOT NULL, + `defaultServer` int(11) NOT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, + `hookAliveInterval` int(11) NOT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `media_server_i` (`ip`,`httpPort`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -294,33 +295,36 @@ DROP TABLE IF EXISTS `parent_platform`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `parent_platform` ( - `id` int NOT NULL AUTO_INCREMENT, - `enable` int DEFAULT NULL, - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `serverGBId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `serverGBDomain` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `serverIP` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `serverPort` int DEFAULT NULL, - `deviceGBId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `deviceIp` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `devicePort` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `password` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `expires` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `keepTimeout` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `transport` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `characterSet` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `ptz` int DEFAULT NULL, - `rtcp` int DEFAULT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `enable` int(11) DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `serverGBId` varchar(50) NOT NULL, + `serverGBDomain` varchar(50) DEFAULT NULL, + `serverIP` varchar(50) DEFAULT NULL, + `serverPort` int(11) DEFAULT NULL, + `deviceGBId` varchar(50) NOT NULL, + `deviceIp` varchar(50) DEFAULT NULL, + `devicePort` varchar(50) DEFAULT NULL, + `username` varchar(255) DEFAULT NULL, + `password` varchar(50) DEFAULT NULL, + `expires` varchar(50) DEFAULT NULL, + `keepTimeout` varchar(50) DEFAULT NULL, + `transport` varchar(50) DEFAULT NULL, + `characterSet` varchar(50) DEFAULT NULL, + `catalogId` varchar(50) NOT NULL, + `ptz` int(11) DEFAULT NULL, + `rtcp` int(11) DEFAULT NULL, `status` bit(1) DEFAULT NULL, - `shareAllLiveStream` int DEFAULT NULL, + `shareAllLiveStream` int(11) DEFAULT NULL, + `startOfflinePush` int(11) DEFAULT '0', + `administrativeDivision` varchar(50) NOT NULL, + `catalogGroup` int(11) DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `parent_platform_id_uindex` (`id`), UNIQUE KEY `parent_platform_pk` (`serverGBId`) -) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -338,14 +342,14 @@ DROP TABLE IF EXISTS `platform_catalog`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `platform_catalog` ( - `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `parentId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `id` varchar(50) NOT NULL, + `platformId` varchar(50) NOT NULL, + `name` varchar(255) NOT NULL, + `parentId` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -363,14 +367,14 @@ DROP TABLE IF EXISTS `platform_gb_channel`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `platform_gb_channel` ( - `id` int NOT NULL AUTO_INCREMENT, - `platformId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `catalogId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `deviceChannelId` int NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `platformId` varchar(50) NOT NULL, + `catalogId` varchar(50) NOT NULL, + `deviceChannelId` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -388,15 +392,15 @@ DROP TABLE IF EXISTS `platform_gb_stream`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `platform_gb_stream` ( - `platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `gbStreamId` int NOT NULL, - `id` int NOT NULL AUTO_INCREMENT, + `platformId` varchar(50) NOT NULL, + `catalogId` varchar(50) NOT NULL, + `gbStreamId` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) -) ENGINE=InnoDB AUTO_INCREMENT=301207 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=301210 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -414,29 +418,29 @@ DROP TABLE IF EXISTS `stream_proxy`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `stream_proxy` ( - `id` int NOT NULL AUTO_INCREMENT, - `type` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `app` varchar(255) COLLATE utf8mb4_general_ci NOT NULL, - `stream` varchar(255) COLLATE utf8mb4_general_ci NOT NULL, - `url` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `src_url` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `dst_url` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `timeout_ms` int DEFAULT NULL, - `ffmpeg_cmd_key` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, - `rtp_type` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `mediaServerId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `type` varchar(50) NOT NULL, + `app` varchar(255) NOT NULL, + `stream` varchar(255) NOT NULL, + `url` varchar(255) DEFAULT NULL, + `src_url` varchar(255) DEFAULT NULL, + `dst_url` varchar(255) DEFAULT NULL, + `timeout_ms` int(11) DEFAULT NULL, + `ffmpeg_cmd_key` varchar(255) DEFAULT NULL, + `rtp_type` varchar(50) DEFAULT NULL, + `mediaServerId` varchar(50) DEFAULT NULL, `enable_hls` bit(1) DEFAULT NULL, `enable_mp4` bit(1) DEFAULT NULL, `enable` bit(1) NOT NULL, `status` bit(1) NOT NULL, `enable_remove_none_reader` bit(1) NOT NULL, - `createTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, - `name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, + `createTime` varchar(50) NOT NULL, + `name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `stream_proxy_pk` (`app`,`stream`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -454,20 +458,20 @@ DROP TABLE IF EXISTS `stream_push`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `stream_push` ( - `id` int NOT NULL AUTO_INCREMENT, - `app` varchar(255) COLLATE utf8mb4_general_ci NOT NULL, - `stream` varchar(255) COLLATE utf8mb4_general_ci NOT NULL, - `totalReaderCount` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `originType` int DEFAULT NULL, - `originTypeStr` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, - `createStamp` bigint DEFAULT NULL, - `aliveSecond` int DEFAULT NULL, - `mediaServerId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `app` varchar(255) NOT NULL, + `stream` varchar(255) NOT NULL, + `totalReaderCount` varchar(50) DEFAULT NULL, + `originType` int(11) DEFAULT NULL, + `originTypeStr` varchar(50) DEFAULT NULL, + `createStamp` bigint(20) DEFAULT NULL, + `aliveSecond` int(11) DEFAULT NULL, + `mediaServerId` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `stream_push_pk` (`app`,`stream`) -) ENGINE=InnoDB AUTO_INCREMENT=300799 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB AUTO_INCREMENT=300838 DEFAULT CHARSET=utf8mb4; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -485,17 +489,17 @@ DROP TABLE IF EXISTS `user`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `user` ( - `id` int NOT NULL AUTO_INCREMENT, - `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `roleId` int NOT NULL, - `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `roleId` int(11) NOT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `user_username_uindex` (`username`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -504,7 +508,8 @@ LOCK TABLES `user` WRITE; /*!40000 ALTER TABLE `user` DISABLE KEYS */; -INSERT INTO `user` VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',1,'2021 - 04 - 13 14:14:57','2021 - 04 - 13 14:14:57'); +INSERT INTO `user` VALUES + (1,'admin','21232f297a57a5a743894a0e4a801fc3',1,'2021 - 04 - 13 14:14:57','2021 - 04 - 13 14:14:57'); /*!40000 ALTER TABLE `user` ENABLE KEYS */; UNLOCK TABLES; @@ -514,15 +519,15 @@ DROP TABLE IF EXISTS `user_role`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `user_role` ( - `id` int NOT NULL AUTO_INCREMENT, - `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `authority` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, - `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `authority` varchar(50) NOT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -531,7 +536,8 @@ LOCK TABLES `user_role` WRITE; /*!40000 ALTER TABLE `user_role` DISABLE KEYS */; -INSERT INTO `user_role` VALUES (1,'admin','0','2021-04-13 14:14:57','2021-04-13 14:14:57'); +INSERT INTO `user_role` VALUES + (1,'admin','0','2021-04-13 14:14:57','2021-04-13 14:14:57'); /*!40000 ALTER TABLE `user_role` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -544,4 +550,4 @@ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-03-07 8:26:30 +-- Dump completed on 2022-04-18 10:50:27 diff --git a/sql/update.sql b/sql/update.sql index 5804518..9c18c26 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -1,8 +1,12 @@ -alter table device - add subscribeCycleForMobilePosition int null; +alter table parent_platform + add startOfflinePush int default 0 null; + +alter table parent_platform + add administrativeDivision varchar(50) not null; + +alter table parent_platform + add catalogGroup int default 1 null; alter table device - add mobilePositionSubmissionInterval int default 5 null; + add ssrcCheck int default 0 null; -alter table device - add subscribeCycleForAlarm int null; \ No newline at end of file diff --git a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java index bd10317..052f533 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java @@ -76,7 +76,6 @@ */ public void startDelay(String key, Runnable task, int delay) { stop(key); - System.out.println("瀹氭椂浠诲姟寮�濮嬩簡"); Date starTime = new Date(System.currentTimeMillis() + delay); ScheduledFuture future = futureMap.get(key); @@ -100,7 +99,6 @@ } public void stop(String key) { - System.out.println("瀹氭椂浠诲姟缁撴潫浜�"); if (futureMap.get(key) != null && !futureMap.get(key).isCancelled()) { futureMap.get(key).cancel(true); Runnable runnable = runnableMap.get(key); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java index 1a5cce5..7b7291c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java @@ -48,6 +48,7 @@ properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP"); properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getMonitorIp()); properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "true"); + properties.setProperty("gov.nist.javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true"); // 鎺ユ敹鎵�鏈塶otify璇锋眰锛屽嵆浣挎病鏈夎闃� /** * sip_server_log.log 鍜� sip_debug_log.log public static final int TRACE_NONE = * 0; public static final int TRACE_MESSAGES = 16; public static final int diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java index 40f676e..338f8ad 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java @@ -4,6 +4,7 @@ import java.util.List; public class CatalogData { + private int sn; // 鍛戒护搴忓垪鍙� private int total; private List<DeviceChannel> channelList; private Date lastTime; @@ -15,6 +16,15 @@ } private CatalogDataStatus status; + + public int getSn() { + return sn; + } + + public void setSn(int sn) { + this.sn = sn; + } + public int getTotal() { return total; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java index d50ffb7..81b9666 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java @@ -129,6 +129,11 @@ */ private int subscribeCycleForAlarm; + /** + * 鏄惁寮�鍚痵src鏍¢獙锛岄粯璁ゅ叧闂紝寮�鍚彲浠ラ槻姝覆娴� + */ + private boolean ssrcCheck; + public String getDeviceId() { return deviceId; @@ -321,4 +326,12 @@ public void setSubscribeCycleForAlarm(int subscribeCycleForAlarm) { this.subscribeCycleForAlarm = subscribeCycleForAlarm; } + + public boolean isSsrcCheck() { + return ssrcCheck; + } + + public void setSsrcCheck(boolean ssrcCheck) { + this.ssrcCheck = ssrcCheck; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java index 3633789..1e6ef77 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java @@ -169,6 +169,11 @@ */ private boolean hasAudio; + /** + * 鏍囪閫氶亾鐨勭被鍨嬶紝0->鍥芥爣閫氶亾 1->鐩存挱娴侀�氶亾 2->涓氬姟鍒嗙粍/铏氭嫙缁勭粐/琛屾斂鍖哄垝 + */ + private int channelType; + public int getId() { return id; } @@ -441,4 +446,12 @@ public void setUpdateTime(String updateTime) { this.updateTime = updateTime; } + + public int getChannelType() { + return channelType; + } + + public void setChannelType(int channelType) { + this.channelType = channelType; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java index 8aa7b37..7c23a2f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java @@ -129,6 +129,21 @@ */ private boolean mobilePositionSubscribe; + /** + * 鐐规挱鏈帹娴佺殑璁惧鏃舵槸鍚︿娇鐢╮edis閫氱煡鎷夎捣 + */ + private boolean startOfflinePush; + + /** + * 鐩綍鍒嗙粍-姣忔鍚戜笂绾у彂閫侀�氶亾淇℃伅鏃跺崟涓寘鎼哄甫鐨勯�氶亾鏁伴噺锛屽彇鍊�1,2,4,8 + */ + private int catalogGroup; + + /** + * 琛屾斂鍖哄垝 + */ + private String administrativeDivision; + public Integer getId() { return id; } @@ -329,4 +344,28 @@ public void setMobilePositionSubscribe(boolean mobilePositionSubscribe) { this.mobilePositionSubscribe = mobilePositionSubscribe; } + + public boolean isStartOfflinePush() { + return startOfflinePush; + } + + public void setStartOfflinePush(boolean startOfflinePush) { + this.startOfflinePush = startOfflinePush; + } + + public int getCatalogGroup() { + return catalogGroup; + } + + public void setCatalogGroup(int catalogGroup) { + this.catalogGroup = catalogGroup; + } + + public String getAdministrativeDivision() { + return administrativeDivision; + } + + public void setAdministrativeDivision(String administrativeDivision) { + this.administrativeDivision = administrativeDivision; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java index b5c6bba..1fc1e46 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java @@ -54,6 +54,7 @@ @Autowired private SIPCommander cmder; + private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Override @@ -74,7 +75,7 @@ if (deviceInStore == null) { //绗竴娆′笂绾� logger.info("[{}] 棣栨娉ㄥ唽锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId()); cmder.deviceInfoQuery(device); - cmder.catalogQuery(device, null); + deviceService.sync(device); } break; // 璁惧涓诲姩鍙戦�佸績璺宠Е鍙戠殑鍦ㄧ嚎浜嬩欢 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java index fbc2a32..97360d2 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java @@ -26,28 +26,35 @@ @Autowired private IVideoManagerStorage storager; - public void addReady(String key) { - CatalogData catalogData = data.get(key); + public void addReady(Device device, int sn ) { + CatalogData catalogData = data.get(device.getDeviceId()); if (catalogData == null || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) { catalogData = new CatalogData(); catalogData.setChannelList(new ArrayList<>()); + catalogData.setDevice(device); + catalogData.setSn(sn); catalogData.setStatus(CatalogData.CatalogDataStatus.ready); catalogData.setLastTime(new Date(System.currentTimeMillis())); - data.put(key, catalogData); + data.put(device.getDeviceId(), catalogData); } } - public void put(String key, int total, Device device, List<DeviceChannel> deviceChannelList) { - CatalogData catalogData = data.get(key); + public void put(String deviceId, int sn, int total, Device device, List<DeviceChannel> deviceChannelList) { + CatalogData catalogData = data.get(deviceId); if (catalogData == null) { catalogData = new CatalogData(); + catalogData.setSn(sn); catalogData.setTotal(total); catalogData.setDevice(device); catalogData.setChannelList(new ArrayList<>()); catalogData.setStatus(CatalogData.CatalogDataStatus.runIng); catalogData.setLastTime(new Date(System.currentTimeMillis())); - data.put(key, catalogData); + data.put(deviceId, catalogData); }else { + // 鍚屼竴涓澶囩殑閫氶亾鍚屾璇锋眰鍙�冭檻涓�涓紝鍏朵粬鐨勭洿鎺ュ拷鐣� + if (catalogData.getSn() != sn) { + return; + } catalogData.setTotal(total); catalogData.setDevice(device); catalogData.setStatus(CatalogData.CatalogDataStatus.runIng); @@ -56,20 +63,20 @@ } } - public List<DeviceChannel> get(String key) { - CatalogData catalogData = data.get(key); + public List<DeviceChannel> get(String deviceId) { + CatalogData catalogData = data.get(deviceId); if (catalogData == null) return null; return catalogData.getChannelList(); } - public int getTotal(String key) { - CatalogData catalogData = data.get(key); + public int getTotal(String deviceId) { + CatalogData catalogData = data.get(deviceId); if (catalogData == null) return 0; return catalogData.getTotal(); } - public SyncStatus getSyncStatus(String key) { - CatalogData catalogData = data.get(key); + public SyncStatus getSyncStatus(String deviceId) { + CatalogData catalogData = data.get(deviceId); if (catalogData == null) return null; SyncStatus syncStatus = new SyncStatus(); syncStatus.setCurrent(catalogData.getChannelList().size()); @@ -78,8 +85,10 @@ return syncStatus; } - public void del(String key) { - data.remove(key); + public boolean isSyncRunning(String deviceId) { + CatalogData catalogData = data.get(deviceId); + if (catalogData == null) return false; + return !catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end); } @Scheduled(fixedRate = 5 * 1000) //姣�5绉掓墽琛屼竴娆�, 鍙戠幇鏁版嵁5绉掓湭鏇存柊鍒欑Щ闄ゆ暟鎹苟璁や负鏁版嵁鎺ユ敹瓒呮椂 @@ -92,23 +101,30 @@ Calendar calendarBefore30S = Calendar.getInstance(); calendarBefore30S.setTime(new Date()); calendarBefore30S.set(Calendar.SECOND, calendarBefore30S.get(Calendar.SECOND) - 30); - for (String key : keys) { - CatalogData catalogData = data.get(key); - if (catalogData.getLastTime().before(calendarBefore5S.getTime())) { // 瓒呰繃浜旂鏀朵笉鍒版秷鎭换鍔¤秴鏃讹紝 鍙洿鏂拌繖涓�閮ㄥ垎鏁版嵁 - storager.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); - String errorMsg = "鏇存柊鎴愬姛锛屽叡" + catalogData.getTotal() + "鏉★紝宸叉洿鏂�" + catalogData.getChannelList().size() + "鏉�"; + for (String deviceId : keys) { + CatalogData catalogData = data.get(deviceId); + if ( catalogData.getLastTime().before(calendarBefore5S.getTime())) { // 瓒呰繃浜旂鏀朵笉鍒版秷鎭换鍔¤秴鏃讹紝 鍙洿鏂拌繖涓�閮ㄥ垎鏁版嵁 + if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.runIng)) { + storager.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); + if (catalogData.getTotal() != catalogData.getChannelList().size()) { + String errorMsg = "鏇存柊鎴愬姛锛屽叡" + catalogData.getTotal() + "鏉★紝宸叉洿鏂�" + catalogData.getChannelList().size() + "鏉�"; + catalogData.setErrorMsg(errorMsg); + } + }else if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready)) { + String errorMsg = "鍚屾澶辫触锛岀瓑寰呭洖澶嶈秴鏃�"; + catalogData.setErrorMsg(errorMsg); + } catalogData.setStatus(CatalogData.CatalogDataStatus.end); - catalogData.setErrorMsg(errorMsg); } - if (catalogData.getLastTime().before(calendarBefore30S.getTime())) { // 瓒呰繃涓夊崄绉掞紝濡傛灉鏍囪涓篹nd鍒欏垹闄� - data.remove(key); + if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end) && catalogData.getLastTime().before(calendarBefore30S.getTime())) { // 瓒呰繃涓夊崄绉掞紝濡傛灉鏍囪涓篹nd鍒欏垹闄� + data.remove(deviceId); } } } - public void setChannelSyncEnd(String key, String errorMsg) { - CatalogData catalogData = data.get(key); + public void setChannelSyncEnd(String deviceId, String errorMsg) { + CatalogData catalogData = data.get(deviceId); if (catalogData == null)return; catalogData.setStatus(CatalogData.CatalogDataStatus.end); catalogData.setErrorMsg(errorMsg); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java index bee5fba..59b927f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java @@ -10,6 +10,8 @@ import javax.sip.Dialog; import javax.sip.DialogState; import javax.sip.ResponseEvent; +import java.util.Timer; +import java.util.TimerTask; /** * 鐩綍璁㈤槄浠诲姟 @@ -20,6 +22,8 @@ private final ISIPCommander sipCommander; private Dialog dialog; + private Timer timer ; + public CatalogSubscribeTask(Device device, ISIPCommander sipCommander) { this.device = device; this.sipCommander = sipCommander; @@ -27,6 +31,10 @@ @Override public void run() { + if (timer != null ) { + timer.cancel(); + timer = null; + } sipCommander.catalogSubscribe(device, dialog, eventResult -> { if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) { dialog = eventResult.dialog; @@ -43,6 +51,13 @@ dialog = null; // 澶辫触 logger.warn("[鐩綍璁㈤槄]澶辫触锛屼俊浠ゅ彂閫佸け璐ワ細 {}-{} ", device.getDeviceId(), eventResult.msg); + timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + CatalogSubscribeTask.this.run(); + } + }, 2000); }); } @@ -56,9 +71,13 @@ * TERMINATED-> Terminated Dialog鐘舵��-缁堟 */ logger.info("鍙栨秷鐩綍璁㈤槄鏃禿ialog鐘舵�佷负{}", DialogState.CONFIRMED); + if (timer != null ) { + timer.cancel(); + timer = null; + } if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) { device.setSubscribeCycleForCatalog(0); - sipCommander.mobilePositionSubscribe(device, dialog, eventResult -> { + sipCommander.catalogSubscribe(device, dialog, eventResult -> { ResponseEvent event = (ResponseEvent) eventResult.event; if (event.getResponse().getRawContent() != null) { // 鎴愬姛 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java index f20baf9..c495403 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java @@ -29,7 +29,6 @@ private String key; public MobilePositionSubscribeHandlerTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorage storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) { - System.out.println("MobilePositionSubscribeHandlerTask 鍒濆鍖�"); this.redisCatchStorage = redisCatchStorage; this.storager = storager; this.platform = storager.queryParentPlatByServerGBId(platformId); @@ -42,7 +41,6 @@ @Override public void run() { - logger.info("鎵цMobilePositionSubscribeHandlerTask"); if (platform == null) return; SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()); if (subscribe != null) { @@ -71,7 +69,6 @@ } } } - logger.info("缁撴潫鎵цMobilePositionSubscribeHandlerTask"); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 1de03bd..aea37b6 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -250,7 +250,7 @@ * * @param device 瑙嗛璁惧 */ - boolean catalogQuery(Device device, SipSubscribe.Event errorEvent); + boolean catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent); /** * 鏌ヨ褰曞儚淇℃伅 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 027238b..89e70d0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -1208,14 +1208,14 @@ * @param device 瑙嗛璁惧 */ @Override - public boolean catalogQuery(Device device, SipSubscribe.Event errorEvent) { + public boolean catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) { try { StringBuffer catalogXml = new StringBuffer(200); String charset = device.getCharset(); catalogXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n"); catalogXml.append("<Query>\r\n"); catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); - catalogXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); + catalogXml.append("<SN>" + sn + "</SN>\r\n"); catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); catalogXml.append("</Query>\r\n"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index c5cdae0..0fd8cc5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -32,6 +32,7 @@ import javax.sip.message.Request; import java.lang.reflect.Field; import java.text.ParseException; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.UUID; @@ -215,7 +216,11 @@ return false; } try { - String catalogXml = getCatalogXml(channel, sn, parentPlatform, size); + List<DeviceChannel> channels = new ArrayList<>(); + if (channel != null) { + channels.add(channel); + } + String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); // callid CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() @@ -239,7 +244,7 @@ sendCatalogResponse(channels, parentPlatform, sn, fromTag, 0); return true; } - private String getCatalogXml(DeviceChannel channel, String sn, ParentPlatform parentPlatform, int size) { + private String getCatalogXml(List<DeviceChannel> channels, String sn, ParentPlatform parentPlatform, int size) { String characterSet = parentPlatform.getCharacterSet(); StringBuffer catalogXml = new StringBuffer(600); catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet +"\"?>\r\n"); @@ -248,34 +253,38 @@ catalogXml.append("<SN>" +sn + "</SN>\r\n"); catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); catalogXml.append("<SumNum>" + size + "</SumNum>\r\n"); - catalogXml.append("<DeviceList Num=\"1\">\r\n"); - catalogXml.append("<Item>\r\n"); - if (channel != null) { - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); - catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n"); - catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n"); - catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n"); - catalogXml.append("<Owner>" + channel.getOwner() + "</Owner>\r\n"); - catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n"); - catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); - catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); - if (channel.getParentId() != null) { - catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); + catalogXml.append("<DeviceList Num=\"" + channels.size() +"\">\r\n"); + if (channels.size() > 0) { + for (DeviceChannel channel : channels) { + catalogXml.append("<Item>\r\n"); + catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); + catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n"); + catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n"); + catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); + if (channel.getParentId() != null) { + catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); + } + catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); + catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\r\n"); + catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); + if (channel.getChannelType() != 2) { // 涓氬姟鍒嗙粍/铏氭嫙缁勭粐/琛屾斂鍖哄垝 涓嶈缃互涓嬪瓧娈� + catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n"); + catalogXml.append("<Owner>" + channel.getOwner() + "</Owner>\r\n"); + catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n"); + catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); + catalogXml.append("<Longitude>" + channel.getLongitude() + "</Longitude>\r\n"); + catalogXml.append("<Latitude>" + channel.getLatitude() + "</Latitude>\r\n"); + catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n"); + catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n"); + catalogXml.append("<Info>\r\n"); + catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n"); + catalogXml.append("</Info>\r\n"); + } + + catalogXml.append("</Item>\r\n"); } - catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); - catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); - catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\r\n"); - catalogXml.append("<Longitude>" + channel.getLongitude() + "</Longitude>\r\n"); - catalogXml.append("<Latitude>" + channel.getLatitude() + "</Latitude>\r\n"); - catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n"); - catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n"); - catalogXml.append("<Info>\r\n"); - catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n"); - catalogXml.append("</Info>\r\n"); } - - catalogXml.append("</Item>\r\n"); catalogXml.append("</DeviceList>\r\n"); catalogXml.append("</Response>\r\n"); return catalogXml.toString(); @@ -286,15 +295,20 @@ return; } try { - DeviceChannel deviceChannel = channels.get(index); - String catalogXml = getCatalogXml(deviceChannel, sn, parentPlatform, channels.size()); + List<DeviceChannel> deviceChannels; + if (index + parentPlatform.getCatalogGroup() < channels.size()) { + deviceChannels = channels.subList(index, index + parentPlatform.getCatalogGroup()); + }else { + deviceChannels = channels.subList(index, channels.size()); + } + String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); // callid CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, callIdHeader); transmitRequest(parentPlatform, request, null, eventResult -> { - int indexNext = index + 1; + int indexNext = index + parentPlatform.getCatalogGroup(); sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext); }); } catch (SipException | ParseException | InvalidArgumentException e) { @@ -432,13 +446,21 @@ if (index >= deviceChannels.size()) { return true; } + List<DeviceChannel> channels; + if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) { + channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup()); + }else { + channels = deviceChannels.subList(index, deviceChannels.size()); + } try { Integer finalIndex = index; - String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, deviceChannels.get(index ), deviceChannels.size(), type, subscribeInfo); + String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channels, + deviceChannels.size(), type, subscribeInfo); sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { logger.error("鍙戦�丯OTIFY閫氱煡娑堟伅澶辫触銆傞敊璇細{} {}", eventResult.statusCode, eventResult.msg); }, (eventResult -> { - sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo, finalIndex + 1); + sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo, + finalIndex + parentPlatform.getCatalogGroup()); })); } catch (SipException | ParseException e) { e.printStackTrace(); @@ -500,11 +522,9 @@ } - private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, DeviceChannel channel, int sumNum, String type, SubscribeInfo subscribeInfo) { + private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) { StringBuffer catalogXml = new StringBuffer(600); - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } + String characterSet = parentPlatform.getCharacterSet(); catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); catalogXml.append("<Notify>\r\n"); @@ -512,26 +532,35 @@ catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); catalogXml.append("<SumNum>1</SumNum>\r\n"); - catalogXml.append("<DeviceList Num=\"1\">\r\n"); - catalogXml.append("<Item>\r\n"); - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); - catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n"); - catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n"); - catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n"); - catalogXml.append("<Owner>0</Owner>\r\n"); - catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n"); - catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); - catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); - if (channel.getParentId() != null) { - catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); + catalogXml.append("<DeviceList Num=\"" + channels.size() + "\">\r\n"); + if (channels.size() > 0) { + for (DeviceChannel channel : channels) { + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { + channel.setParentId(parentPlatform.getDeviceGBId()); + } + catalogXml.append("<Item>\r\n"); + catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); + catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n"); + catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n"); + catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); + if (channel.getParentId() != null) { + catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); + } + catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); + catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); + catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); + if (channel.getChannelType() == 2) { // 涓氬姟鍒嗙粍/铏氭嫙缁勭粐/琛屾斂鍖哄垝 涓嶈缃互涓嬪睘鎬� + catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n"); + catalogXml.append("<Owner>0</Owner>\r\n"); + catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n"); + catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); + } + if (!"presence".equals(subscribeInfo.getEventType())) { + catalogXml.append("<Event>" + type + "</Event>\r\n"); + } + catalogXml.append("</Item>\r\n"); + } } - catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); - catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); - catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); - if (!"presence".equals(subscribeInfo.getEventType())) { - catalogXml.append("<Event>" + type + "</Event>\r\n"); - } - catalogXml.append("</Item>\r\n"); catalogXml.append("</DeviceList>\r\n"); catalogXml.append("</Notify>\r\n"); return catalogXml.toString(); @@ -553,13 +582,20 @@ if (index >= deviceChannels.size()) { return true; } + List<DeviceChannel> channels; + if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) { + channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup()); + }else { + channels = deviceChannels.subList(index, deviceChannels.size()); + } try { Integer finalIndex = index; - String catalogXmlContent = getCatalogXmlContentForCatalogOther(parentPlatform, deviceChannels.get(index), type); + String catalogXmlContent = getCatalogXmlContentForCatalogOther(parentPlatform, channels, type); sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { logger.error("鍙戦�丯OTIFY閫氱煡娑堟伅澶辫触銆傞敊璇細{} {}", eventResult.statusCode, eventResult.msg); }, (eventResult -> { - sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo, finalIndex + 1); + sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo, + finalIndex + parentPlatform.getCatalogGroup()); })); } catch (SipException e) { e.printStackTrace(); @@ -574,10 +610,8 @@ return true; } - private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, DeviceChannel channel, String type) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } + private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, List<DeviceChannel> channels, String type) { + String characterSet = parentPlatform.getCharacterSet(); StringBuffer catalogXml = new StringBuffer(600); catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); @@ -586,11 +620,18 @@ catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); catalogXml.append("<SumNum>1</SumNum>\r\n"); - catalogXml.append("<DeviceList Num=\"1\">\r\n"); - catalogXml.append("<Item>\r\n"); - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); - catalogXml.append("<Event>" + type + "</Event>\r\n"); - catalogXml.append("</Item>\r\n"); + catalogXml.append("<DeviceList Num=\" " + channels.size() + " \">\r\n"); + if (channels.size() > 0) { + for (DeviceChannel channel : channels) { + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { + channel.setParentId(parentPlatform.getDeviceGBId()); + } + catalogXml.append("<Item>\r\n"); + catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); + catalogXml.append("<Event>" + type + "</Event>\r\n"); + catalogXml.append("</Item>\r\n"); + } + } catalogXml.append("</DeviceList>\r\n"); catalogXml.append("</Notify>\r\n"); return catalogXml.toString(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 6b6e377..5d02bda 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -397,6 +397,10 @@ logger.info("[ app={}, stream={} ]閫氶亾绂荤嚎锛屽惎鐢ㄦ祦鍚庡紑濮嬫帹娴�",gbStream.getApp(), gbStream.getStream()); responseAck(evt, Response.BAD_REQUEST, "channel [" + gbStream.getGbId() + "] offline"); }else if ("push".equals(gbStream.getStreamType())) { + if (!platform.isStartOfflinePush()) { + responseAck(evt, Response.TEMPORARILY_UNAVAILABLE, "channel unavailable"); + return; + } // 鍙戦�乺edis娑堟伅浠ヤ娇璁惧涓婄嚎 logger.info("[ app={}, stream={} ]閫氶亾绂荤嚎锛屽彂閫乺edis淇℃伅鎺у埗璁惧寮�濮嬫帹娴�",gbStream.getApp(), gbStream.getStream()); MessageForPushChannel messageForPushChannel = new MessageForPushChannel(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index 54a5204..f6a3af9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -3,7 +3,6 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; -import com.genersoft.iot.vmp.gb28181.auth.RegisterLogicHandler; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; @@ -42,166 +41,157 @@ @Component public class RegisterRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - private Logger logger = LoggerFactory.getLogger(RegisterRequestProcessor.class); + private final Logger logger = LoggerFactory.getLogger(RegisterRequestProcessor.class); - public String method = "REGISTER"; + public String method = "REGISTER"; - @Autowired - private SipConfig sipConfig; + @Autowired + private SipConfig sipConfig; - @Autowired - private RegisterLogicHandler handler; + @Autowired + private IRedisCatchStorage redisCatchStorage; - @Autowired - private IRedisCatchStorage redisCatchStorage; + @Autowired + private IVideoManagerStorage storager; - @Autowired - private IVideoManagerStorage storager; + @Autowired + private EventPublisher publisher; - @Autowired - private EventPublisher publisher; + @Autowired + private SIPProcessorObserver sipProcessorObserver; - @Autowired - private SIPProcessorObserver sipProcessorObserver; + @Override + public void afterPropertiesSet() throws Exception { + // 娣诲姞娑堟伅澶勭悊鐨勮闃� + sipProcessorObserver.addRequestProcessor(method, this); + } - @Override - public void afterPropertiesSet() throws Exception { - // 娣诲姞娑堟伅澶勭悊鐨勮闃� - sipProcessorObserver.addRequestProcessor(method, this); - } + /** + * 鏀跺埌娉ㄥ唽璇锋眰 澶勭悊 + * + * @param evt + */ + @Override + public void process(RequestEvent evt) { + try { + RequestEventExt evtExt = (RequestEventExt) evt; + String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort(); + logger.info("[{}] 鏀跺埌娉ㄥ唽璇锋眰锛屽紑濮嬪鐞�", requestAddress); + Request request = evt.getRequest(); + ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME); + Response response = null; + boolean passwordCorrect = false; + // 娉ㄥ唽鏍囧織 0锛氭湭鎼哄甫鎺堟潈澶存垨鑰呭瘑鐮侀敊璇� 1锛氭敞鍐屾垚鍔� 2锛氭敞閿�鎴愬姛 + int registerFlag = 0; + FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME); + AddressImpl address = (AddressImpl) fromHeader.getAddress(); + SipUri uri = (SipUri) address.getURI(); + String deviceId = uri.getUser(); - /** - * 鏀跺埌娉ㄥ唽璇锋眰 澶勭悊 - * @param evt - */ - @Override - public void process(RequestEvent evt) { - try { - RequestEventExt evtExt = (RequestEventExt)evt; - String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort(); - logger.info("[{}] 鏀跺埌娉ㄥ唽璇锋眰锛屽紑濮嬪鐞�", requestAddress); - Request request = evt.getRequest(); - ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME); - Response response = null; - boolean passwordCorrect = false; - // 娉ㄥ唽鏍囧織 0锛氭湭鎼哄甫鎺堟潈澶存垨鑰呭瘑鐮侀敊璇� 1锛氭敞鍐屾垚鍔� 2锛氭敞閿�鎴愬姛 - int registerFlag = 0; - FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME); - AddressImpl address = (AddressImpl) fromHeader.getAddress(); - SipUri uri = (SipUri) address.getURI(); - String deviceId = uri.getUser(); - Device deviceInRedis = redisCatchStorage.getDevice(deviceId); - Device device = storager.queryVideoDevice(deviceId); - if (deviceInRedis != null && device == null) { - // redis 瀛樺湪鑴忔暟鎹� - redisCatchStorage.clearCatchByDeviceId(deviceId); - } - AuthorizationHeader authorhead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); - // 鏍¢獙瀵嗙爜鏄惁姝g‘ - if (authorhead != null) { - passwordCorrect = new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, - sipConfig.getPassword()); - } - if (StringUtils.isEmpty(sipConfig.getPassword())){ - passwordCorrect = true; - } + AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); + if (authHead == null) { + logger.info("[{}] 鏈惡甯︽巿鏉冨ご 鍥炲401", requestAddress); + response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); + new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); + sendResponse(evt, response); + return; + } - // 鏈惡甯︽巿鏉冨ご鎴栬�呭瘑鐮侀敊璇� 鍥炲401 - if (authorhead == null ) { + // 鏍¢獙瀵嗙爜鏄惁姝g‘ + passwordCorrect = StringUtils.isEmpty(sipConfig.getPassword()) || + new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, sipConfig.getPassword()); + // 鏈惡甯︽巿鏉冨ご鎴栬�呭瘑鐮侀敊璇� 鍥炲401 - logger.info("[{}] 鏈惡甯︽巿鏉冨ご 鍥炲401", requestAddress); - response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); - new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); - }else { - if (!passwordCorrect){ - // 娉ㄥ唽澶辫触 - response = getMessageFactory().createResponse(Response.FORBIDDEN, request); - response.setReasonPhrase("wrong password"); - logger.info("[{}] 瀵嗙爜/SIP鏈嶅姟鍣↖D閿欒, 鍥炲403", requestAddress); - }else { - // 鎼哄甫鎺堟潈澶村苟涓斿瘑鐮佹纭� - response = getMessageFactory().createResponse(Response.OK, request); - // 娣诲姞date澶� - SIPDateHeader dateHeader = new SIPDateHeader(); - // 浣跨敤鑷繁淇敼鐨� - WvpSipDate wvpSipDate = new WvpSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis()); - dateHeader.setDate(wvpSipDate); - response.addHeader(dateHeader); + if (!passwordCorrect) { + // 娉ㄥ唽澶辫触 + response = getMessageFactory().createResponse(Response.FORBIDDEN, request); + response.setReasonPhrase("wrong password"); + logger.info("[{}] 瀵嗙爜/SIP鏈嶅姟鍣↖D閿欒, 鍥炲403", requestAddress); + sendResponse(evt, response); + return; + } + Device deviceInRedis = redisCatchStorage.getDevice(deviceId); + Device device = storager.queryVideoDevice(deviceId); + if (deviceInRedis != null && device == null) { + // redis 瀛樺湪鑴忔暟鎹� + redisCatchStorage.clearCatchByDeviceId(deviceId); + } + // 鎼哄甫鎺堟潈澶村苟涓斿瘑鐮佹纭� + response = getMessageFactory().createResponse(Response.OK, request); + // 娣诲姞date澶� + SIPDateHeader dateHeader = new SIPDateHeader(); + // 浣跨敤鑷繁淇敼鐨� + WvpSipDate wvpSipDate = new WvpSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis()); + dateHeader.setDate(wvpSipDate); + response.addHeader(dateHeader); - if (expiresHeader == null) { - response = getMessageFactory().createResponse(Response.BAD_REQUEST, request); - ServerTransaction serverTransaction = getServerTransaction(evt); - serverTransaction.sendResponse(response); - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); - return; - } - // 娣诲姞Contact澶� - response.addHeader(request.getHeader(ContactHeader.NAME)); - // 娣诲姞Expires澶� - response.addHeader(request.getExpires()); + if (expiresHeader == null) { + response = getMessageFactory().createResponse(Response.BAD_REQUEST, request); + ServerTransaction serverTransaction = getServerTransaction(evt); + serverTransaction.sendResponse(response); + if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); + return; + } + // 娣诲姞Contact澶� + response.addHeader(request.getHeader(ContactHeader.NAME)); + // 娣诲姞Expires澶� + response.addHeader(request.getExpires()); - // 鑾峰彇鍒伴�氫俊鍦板潃绛変俊鎭� - ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); - String received = viaHeader.getReceived(); - int rPort = viaHeader.getRPort(); - // 瑙f瀽鏈湴鍦板潃鏇夸唬 - if (StringUtils.isEmpty(received) || rPort == -1) { - received = viaHeader.getHost(); - rPort = viaHeader.getPort(); - } - // + // 鑾峰彇鍒伴�氫俊鍦板潃绛変俊鎭� + ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); + String received = viaHeader.getReceived(); + int rPort = viaHeader.getRPort(); + // 瑙f瀽鏈湴鍦板潃鏇夸唬 + if (StringUtils.isEmpty(received) || rPort == -1) { + received = viaHeader.getHost(); + rPort = viaHeader.getPort(); + } + if (device == null) { + device = new Device(); + device.setStreamMode("UDP"); + device.setCharset("GB2312"); + device.setDeviceId(deviceId); + device.setFirsRegister(true); + } else { + device.setFirsRegister(device.getOnline() == 0); + } + device.setIp(received); + device.setPort(rPort); + device.setHostAddress(received.concat(":").concat(String.valueOf(rPort))); + if (expiresHeader.getExpires() == 0) { + // 娉ㄩ攢鎴愬姛 + registerFlag = 2; + } else { + // 娉ㄥ唽鎴愬姛 + device.setExpires(expiresHeader.getExpires()); + registerFlag = 1; + // 鍒ゆ柇TCP杩樻槸UDP + ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); + String transport = reqViaHeader.getTransport(); + device.setTransport("TCP".equals(transport) ? "TCP" : "UDP"); + } - if (device == null) { - device = new Device(); - device.setStreamMode("UDP"); - device.setCharset("GB2312"); - device.setDeviceId(deviceId); - device.setFirsRegister(true); - }else { - if (device.getOnline() == 0) { - device.setFirsRegister(true); - } - } - device.setIp(received); - device.setPort(rPort); - device.setHostAddress(received.concat(":").concat(String.valueOf(rPort))); - // 娉ㄩ攢鎴愬姛 - if (expiresHeader.getExpires() == 0) { - registerFlag = 2; - } - // 娉ㄥ唽鎴愬姛 - else { - device.setExpires(expiresHeader.getExpires()); - registerFlag = 1; - // 鍒ゆ柇TCP杩樻槸UDP - boolean isTcp = false; - ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); - String transport = reqViaHeader.getTransport(); - if (transport.equals("TCP")) { - isTcp = true; - } - device.setTransport(isTcp ? "TCP" : "UDP"); - } - } - } + sendResponse(evt, response); + // 娉ㄥ唽鎴愬姛 + // 淇濆瓨鍒皉edis + if (registerFlag == 1) { + logger.info("[{}] 娉ㄥ唽鎴愬姛! deviceId:" + deviceId, requestAddress); + publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_REGISTER, expiresHeader.getExpires()); + } else if (registerFlag == 2) { + logger.info("[{}] 娉ㄩ攢鎴愬姛! deviceId:" + deviceId, requestAddress); + publisher.outlineEventPublish(deviceId, VideoManagerConstants.EVENT_OUTLINE_UNREGISTER); + } + } catch (SipException | InvalidArgumentException | NoSuchAlgorithmException | ParseException e) { + e.printStackTrace(); + } - ServerTransaction serverTransaction = getServerTransaction(evt); - serverTransaction.sendResponse(response); - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); - // 娉ㄥ唽鎴愬姛 - // 淇濆瓨鍒皉edis - if (registerFlag == 1 ) { - logger.info("[{}] 娉ㄥ唽鎴愬姛! deviceId:" + device.getDeviceId(), requestAddress); - publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_REGISTER, expiresHeader.getExpires()); - } else if (registerFlag == 2) { - logger.info("[{}] 娉ㄩ攢鎴愬姛! deviceId:" + device.getDeviceId(), requestAddress); - publisher.outlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_OUTLINE_UNREGISTER); - } - } catch (SipException | InvalidArgumentException | NoSuchAlgorithmException | ParseException e) { - e.printStackTrace(); - } - - } + } + + private void sendResponse(RequestEvent evt, Response response) throws InvalidArgumentException, SipException { + ServerTransaction serverTransaction = getServerTransaction(evt); + serverTransaction.sendResponse(response); + if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java index 419a5c2..d17920d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java @@ -79,7 +79,7 @@ deviceChannel.setParental(1); deviceChannel.setParentId(catalog.getParentId()); deviceChannel.setRegisterWay(1); - deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0,6)); + deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setSecrecy("0"); @@ -116,7 +116,7 @@ deviceChannel.setStatus(1); deviceChannel.setParentId(gbStream.getCatalogId()); deviceChannel.setRegisterWay(1); - deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0,6)); + deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setParental(0); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java index 6a33da4..cefee3f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java @@ -83,20 +83,17 @@ catalog.setParentId(parentPlatform.getDeviceGBId()); } DeviceChannel deviceChannel = new DeviceChannel(); + // 閫氶亾鐨勭被鍨嬶紝0->鍥芥爣閫氶亾 1->鐩存挱娴侀�氶亾 2->涓氬姟鍒嗙粍/铏氭嫙缁勭粐/琛屾斂鍖哄垝 + deviceChannel.setChannelType(2); deviceChannel.setChannelId(catalog.getId()); deviceChannel.setName(catalog.getName()); - deviceChannel.setLongitude(0.0); - deviceChannel.setLatitude(0.0); deviceChannel.setDeviceId(parentPlatform.getDeviceGBId()); deviceChannel.setManufacture("wvp-pro"); deviceChannel.setStatus(1); deviceChannel.setParental(1); deviceChannel.setParentId(catalog.getParentId()); deviceChannel.setRegisterWay(1); - deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0,6)); - deviceChannel.setModel("live"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setSecrecy("0"); + deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); allChannels.add(deviceChannel); } } @@ -107,6 +104,8 @@ channel.setCatalogId(parentPlatform.getDeviceGBId()); } DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId()); + // 閫氶亾鐨勭被鍨嬶紝0->鍥芥爣閫氶亾 1->鐩存挱娴侀�氶亾 2->涓氬姟鍒嗙粍/铏氭嫙缁勭粐/琛屾斂鍖哄垝 + deviceChannel.setChannelType(0); deviceChannel.setParental(0); deviceChannel.setParentId(channel.getCatalogId()); deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0, 6)); @@ -120,6 +119,8 @@ gbStream.setCatalogId(null); } DeviceChannel deviceChannel = new DeviceChannel(); + // 閫氶亾鐨勭被鍨嬶紝0->鍥芥爣閫氶亾 1->鐩存挱娴侀�氶亾 2->涓氬姟鍒嗙粍/铏氭嫙缁勭粐/琛屾斂鍖哄垝 + deviceChannel.setChannelType(1); deviceChannel.setChannelId(gbStream.getGbId()); deviceChannel.setName(gbStream.getName()); deviceChannel.setLongitude(gbStream.getLongitude()); @@ -130,7 +131,7 @@ deviceChannel.setStatus(1); deviceChannel.setParentId(gbStream.getCatalogId()); deviceChannel.setRegisterWay(1); - deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0,6)); + deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setParental(0); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index aae3515..910524d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -87,23 +87,17 @@ rootElement = getRootElement(evt, device.getCharset()); Element deviceListElement = rootElement.element("DeviceList"); Element sumNumElement = rootElement.element("SumNum"); - if (sumNumElement == null || deviceListElement == null) { + Element snElement = rootElement.element("SN"); + if (snElement == null || sumNumElement == null || deviceListElement == null) { responseAck(evt, Response.BAD_REQUEST, "xml error"); return; } int sumNum = Integer.parseInt(sumNumElement.getText()); + if (sumNum == 0) { // 鏁版嵁宸茬粡瀹屾暣鎺ユ敹 storager.cleanChannelsForDevice(device.getDeviceId()); - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - WVPResult<Object> result = new WVPResult<>(); - result.setCode(0); - result.setData(device); - msg.setData(result); - result.setMsg("鏇存柊鎴愬姛锛屽叡0鏉�"); - deferredResultHolder.invokeAllResult(msg); - catalogDataCatch.del(key); + catalogDataCatch.setChannelSyncEnd(device.getDeviceId(), null); }else { Iterator<Element> deviceListIterator = deviceListElement.elementIterator(); if (deviceListIterator != null) { @@ -124,24 +118,18 @@ channelList.add(deviceChannel); } - logger.info("鏀跺埌鏉ヨ嚜璁惧銆恵}銆戠殑閫氶亾: {}涓紝{}/{}", device.getDeviceId(), channelList.size(), catalogDataCatch.get(key) == null ? 0 :catalogDataCatch.get(key).size(), sumNum); - catalogDataCatch.put(key, sumNum, device, channelList); - if (catalogDataCatch.get(key).size() == sumNum) { + int sn = Integer.parseInt(snElement.getText()); + catalogDataCatch.put(device.getDeviceId(), sn, sumNum, device, channelList); + logger.info("鏀跺埌鏉ヨ嚜璁惧銆恵}銆戠殑閫氶亾: {}涓紝{}/{}", device.getDeviceId(), channelList.size(), catalogDataCatch.get(device.getDeviceId()) == null ? 0 :catalogDataCatch.get(device.getDeviceId()).size(), sumNum); + if (catalogDataCatch.get(device.getDeviceId()).size() == sumNum) { // 鏁版嵁宸茬粡瀹屾暣鎺ユ敹 - boolean resetChannelsResult = storager.resetChannels(device.getDeviceId(), catalogDataCatch.get(key)); - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - WVPResult<Object> result = new WVPResult<>(); - result.setCode(0); - result.setData(device); - if (resetChannelsResult || sumNum ==0) { - result.setMsg("鏇存柊鎴愬姛锛屽叡" + sumNum + "鏉★紝宸叉洿鏂�" + catalogDataCatch.get(key).size() + "鏉�"); + boolean resetChannelsResult = storager.resetChannels(device.getDeviceId(), catalogDataCatch.get(device.getDeviceId())); + if (!resetChannelsResult) { + String errorMsg = "鎺ユ敹鎴愬姛锛屽啓鍏ュけ璐ワ紝鍏�" + sumNum + "鏉★紝宸叉帴鏀�" + catalogDataCatch.get(device.getDeviceId()).size() + "鏉�"; + catalogDataCatch.setChannelSyncEnd(device.getDeviceId(), errorMsg); }else { - result.setMsg("鎺ユ敹鎴愬姛锛屽啓鍏ュけ璐ワ紝鍏�" + sumNum + "鏉★紝宸叉帴鏀�" + catalogDataCatch.get(key).size() + "鏉�"); + catalogDataCatch.setChannelSyncEnd(device.getDeviceId(), null); } - msg.setData(result); - deferredResultHolder.invokeAllResult(msg); - catalogDataCatch.del(key); } } // 鍥炲200 OK @@ -229,21 +217,26 @@ } public SyncStatus getChannelSyncProgress(String deviceId) { - String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId; - if (catalogDataCatch.get(key) == null) { + if (catalogDataCatch.get(deviceId) == null) { return null; }else { - return catalogDataCatch.getSyncStatus(key); + return catalogDataCatch.getSyncStatus(deviceId); } } - public void setChannelSyncReady(String deviceId) { - String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId; - catalogDataCatch.addReady(key); + public boolean isSyncRunning(String deviceId) { + if (catalogDataCatch.get(deviceId) == null) { + return false; + }else { + return catalogDataCatch.isSyncRunning(deviceId); + } + } + + public void setChannelSyncReady(Device device, int sn) { + catalogDataCatch.addReady(device, sn); } public void setChannelSyncEnd(String deviceId, String errorMsg) { - String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId; - catalogDataCatch.setChannelSyncEnd(key, errorMsg); + catalogDataCatch.setChannelSyncEnd(deviceId, errorMsg); } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java index a36593e..cf8e006 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java @@ -81,7 +81,7 @@ return result; } - public int createRTPServer(MediaServerItem mediaServerItem, String streamId) { + public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc) { int result = -1; // 鏌ヨ姝tp server 鏄惁宸茬粡瀛樺湪 JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId); @@ -94,6 +94,7 @@ param.put("enable_tcp", 1); param.put("stream_id", streamId); param.put("port", 0); + param.put("ssrc", ssrc); JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param); if (openRtpServerResultJson != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java index 17cf7f4..5621d2a 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java @@ -44,15 +44,15 @@ SyncStatus getChannelSyncStatus(String deviceId); /** - * 璁剧疆閫氶亾鍚屾鐘舵�� + * 鏌ョ湅鏄惁浠嶅湪鍚屾 * @param deviceId 璁惧ID + * @return */ - void setChannelSyncReady(String deviceId); + Boolean isSyncRunning(String deviceId); /** - * 璁剧疆鍚屾缁撴潫 - * @param deviceId 璁惧ID - * @param errorMsg 閿欒淇℃伅 + * 閫氶亾鍚屾 + * @param device */ - void setChannelSyncEnd(String deviceId, String errorMsg); + void sync(Device device); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java index 00ec0dd..2a99754 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java @@ -44,9 +44,9 @@ void updateVmServer(List<MediaServerItem> mediaServerItemList); - SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId); + SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean ssrcCheck); - SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback); + SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean ssrcCheck, boolean isPlayback); void closeRTPServer(String deviceId, String channelId, String ssrc); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index d343286..f287c5e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -41,10 +41,6 @@ if (device == null || device.getSubscribeCycleForCatalog() < 0) { return false; } - CatalogSubscribeTask task = (CatalogSubscribeTask)dynamicTask.get(device.getDeviceId() + "catalog"); - if (task != null && task.getDialogState() != null && task.getDialogState().equals(DialogState.CONFIRMED)) { // 宸插瓨鍦ㄤ笉闇�瑕佸啀娆℃坊鍔� - return true; - } logger.info("[娣诲姞鐩綍璁㈤槄] 璁惧{}", device.getDeviceId()); // 娣诲姞鐩綍璁㈤槄 CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander); @@ -71,10 +67,6 @@ return false; } logger.info("[娣诲姞绉诲姩浣嶇疆璁㈤槄] 璁惧{}", device.getDeviceId()); - MobilePositionSubscribeTask task = (MobilePositionSubscribeTask)dynamicTask.get(device.getDeviceId() + "mobile_position"); - if (task != null && task.getDialogState() != null && task.getDialogState().equals(DialogState.CONFIRMED)) { // 宸插瓨鍦ㄤ笉闇�瑕佸啀娆℃坊鍔� - return true; - } // 娣诲姞鐩綍璁㈤槄 MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander); // 鎻愬墠寮�濮嬪埛鏂拌闃� @@ -100,12 +92,21 @@ } @Override - public void setChannelSyncReady(String deviceId) { - catalogResponseMessageHandler.setChannelSyncReady(deviceId); + public Boolean isSyncRunning(String deviceId) { + return catalogResponseMessageHandler.isSyncRunning(deviceId); } @Override - public void setChannelSyncEnd(String deviceId, String errorMsg) { - catalogResponseMessageHandler.setChannelSyncEnd(deviceId, errorMsg); + public void sync(Device device) { + if (catalogResponseMessageHandler.isSyncRunning(device.getDeviceId())) { + logger.info("寮�鍚悓姝ユ椂鍙戠幇鍚屾宸茬粡瀛樺湪"); + return; + } + int sn = (int)((Math.random()*9+1)*100000); + catalogResponseMessageHandler.setChannelSyncReady(device, sn); + sipCommander.catalogQuery(device, sn, event -> { + String errorMsg = String.format("鍚屾閫氶亾澶辫触锛岄敊璇爜锛� %s, %s", event.statusCode, event.msg); + catalogResponseMessageHandler.setChannelSyncEnd(device.getDeviceId(), errorMsg); + }); } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index a667bab..e7b9e51 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -117,12 +117,12 @@ } @Override - public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId) { - return openRTPServer(mediaServerItem, streamId, false); + public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean ssrcCheck) { + return openRTPServer(mediaServerItem, streamId, ssrcCheck,false); } @Override - public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback) { + public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean ssrcCheck, boolean isPlayback) { if (mediaServerItem == null || mediaServerItem.getId() == null) { return null; } @@ -146,7 +146,7 @@ } int rtpServerPort = mediaServerItem.getRtpProxyPort(); if (mediaServerItem.isRtpEnable()) { - rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId); + rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0); } redisUtil.set(key, mediaServerItem); return new SSRCInfo(rtpServerPort, ssrc, streamId); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 61c37a8..518b9d4 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -188,7 +188,7 @@ if (mediaServerItem.isRtpEnable()) { streamId = String.format("%s_%s", device.getDeviceId(), channelId); } - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId); + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck()); play(mediaServerItem, ssrcInfo, device, channelId, (mediaServerItemInUse, response)->{ if (hookEvent != null) { hookEvent.response(mediaServerItem, response); @@ -232,7 +232,7 @@ streamId = String.format("%s_%s", device.getDeviceId(), channelId); } if (ssrcInfo == null) { - ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId); + ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck()); } // 瓒呮椂澶勭悊 diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java index 3aaa735..79b9b29 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -420,9 +420,6 @@ continue; } streamPushItemForPlatform.setPlatformId(platFormInfoArray[0]); - if (platFormInfoArray[0].equals("34020000002110000001")) { - System.out.println(111); - } List<GbStream> gbStreamList = platformForEvent.get(platFormInfoArray[0]); if (gbStreamList == null) { gbStreamList = new ArrayList<>(); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java index aab8d77..97cf2cc 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java @@ -37,6 +37,7 @@ "subscribeCycleForMobilePosition," + "mobilePositionSubmissionInterval," + "subscribeCycleForAlarm," + + "ssrcCheck," + "online" + ") VALUES (" + "#{deviceId}," + @@ -59,6 +60,7 @@ "#{subscribeCycleForMobilePosition}," + "#{mobilePositionSubmissionInterval}," + "#{subscribeCycleForAlarm}," + + "#{ssrcCheck}," + "#{online}" + ")") int add(Device device); @@ -84,6 +86,7 @@ "<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}</if>" + "<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=${mobilePositionSubmissionInterval}</if>" + "<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=${subscribeCycleForAlarm}</if>" + + "<if test=\"ssrcCheck != null\">, ssrcCheck=${ssrcCheck}</if>" + "WHERE deviceId='${deviceId}'"+ " </script>"}) int update(Device device); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java index f74b6d4..2cbb426 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java @@ -16,10 +16,10 @@ @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + - " status, shareAllLiveStream, catalogId) " + + " status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup) " + " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + - " ${status}, ${shareAllLiveStream}, #{catalogId})") + " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup})") int addParentPlatform(ParentPlatform parentPlatform); @Update("UPDATE parent_platform " + @@ -42,6 +42,9 @@ "rtcp=#{rtcp}, " + "status=#{status}, " + "shareAllLiveStream=#{shareAllLiveStream}, " + + "startOfflinePush=${startOfflinePush}, " + + "catalogGroup=#{catalogGroup}, " + + "administrativeDivision=#{administrativeDivision}, " + "catalogId=#{catalogId} " + "WHERE id=#{id}") int updateParentPlatform(ParentPlatform parentPlatform); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 20e56d9..fbb6e38 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -238,12 +238,15 @@ @Override public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) { + if (deviceChannelList == null) { + return false; + } TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); // 鏁版嵁鍘婚噸 List<DeviceChannel> channels = new ArrayList<>(); StringBuilder stringBuilder = new StringBuilder(); Map<String, Integer> subContMap = new HashMap<>(); - if (deviceChannelList.size() > 1) { + if (deviceChannelList != null && deviceChannelList.size() > 1) { // 鏁版嵁鍘婚噸 Set<String> gbIdSet = new HashSet<>(); for (DeviceChannel deviceChannel : deviceChannelList) { @@ -300,6 +303,7 @@ dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦 return true; }catch (Exception e) { + e.printStackTrace(); dataSourceTransactionManager.rollback(transactionStatus); return false; } @@ -415,10 +419,9 @@ TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); boolean result = false; try { - if (platformChannelMapper.delChannelForDeviceId(deviceId) <0 // 鍒犻櫎涓庡浗鏍囧钩鍙扮殑鍏宠仈 - || deviceChannelMapper.cleanChannelsByDeviceId(deviceId) < 0 // 鍒犻櫎浠栫殑閫氶亾 - || deviceMapper.del(deviceId) < 0 // 绉婚櫎璁惧淇℃伅 - ) { + platformChannelMapper.delChannelForDeviceId(deviceId); + deviceChannelMapper.cleanChannelsByDeviceId(deviceId); + if ( deviceMapper.del(deviceId) < 0 ) { //浜嬪姟鍥炴粴 dataSourceTransactionManager.rollback(transactionStatus); } @@ -517,6 +520,12 @@ @Override public boolean updateParentPlatform(ParentPlatform parentPlatform) { int result = 0; + if (parentPlatform.getCatalogGroup() == 0) { + parentPlatform.setCatalogGroup(1); + } + if (parentPlatform.getAdministrativeDivision() == null) { + parentPlatform.setAdministrativeDivision(parentPlatform.getAdministrativeDivision()); + } ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId()); if (parentPlatform.getId() == null ) { if (parentPlatform.getCatalogId() == null) { @@ -536,6 +545,7 @@ parentPlatformCatch.setId(parentPlatform.getServerGBId()); redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId()); } + result = platformMapper.updateParentPlatform(parentPlatform); } // 鏇存柊缂撳瓨 @@ -1071,7 +1081,7 @@ deviceChannel.setParentId(catalog.getParentId()); deviceChannel.setRegisterWay(1); // 琛屾斂鍖哄垝搴旇鏄疍omain鐨勫墠鍏綅 - deviceChannel.setCivilCode(parentPlatByServerGBId.getDeviceGBId().substring(0,6)); + deviceChannel.setCivilCode(parentPlatByServerGBId.getAdministrativeDivision()); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setSecrecy("0"); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index 12136f4..95d2843 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -164,20 +164,17 @@ logger.debug("璁惧閫氶亾淇℃伅鍚屾API璋冪敤锛宒eviceId锛�" + deviceId); } Device device = storager.queryVideoDevice(deviceId); - SyncStatus syncStatus = deviceService.getChannelSyncStatus(deviceId); + boolean status = deviceService.isSyncRunning(deviceId); // 宸插瓨鍦ㄥ垯杩斿洖杩涘害 - if (syncStatus != null && syncStatus.getErrorMsg() == null) { + if (status) { WVPResult<SyncStatus> wvpResult = new WVPResult<>(); wvpResult.setCode(0); - wvpResult.setData(syncStatus); + SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId); + wvpResult.setData(channelSyncStatus); return wvpResult; } - SyncStatus syncStatusReady = new SyncStatus(); - deviceService.setChannelSyncReady(deviceId); - cmder.catalogQuery(device, event -> { - String errorMsg = String.format("鍚屾閫氶亾澶辫触锛岄敊璇爜锛� %s, %s", event.statusCode, event.msg); - deviceService.setChannelSyncEnd(deviceId, errorMsg); - }); + deviceService.sync(device); + WVPResult<SyncStatus> wvpResult = new WVPResult<>(); wvpResult.setCode(0); wvpResult.setMsg("寮�濮嬪悓姝�"); diff --git a/web_src/src/components/dialog/SyncChannelProgress.vue b/web_src/src/components/dialog/SyncChannelProgress.vue index 1ec16f4..246f1ae 100644 --- a/web_src/src/components/dialog/SyncChannelProgress.vue +++ b/web_src/src/components/dialog/SyncChannelProgress.vue @@ -61,23 +61,36 @@ if (!this.syncFlag) { this.syncFlag = true; } - if (res.data.data == null) { - this.syncStatus = "success" - this.percentage = 100; - this.msg = '鍚屾鎴愬姛'; - }else if (res.data.data.total == 0){ - this.msg = `绛夊緟鍚屾涓璥; - this.timmer = setTimeout(this.getProgress, 300) - }else if (res.data.data.errorMsg !== null ){ - this.msg = res.data.data.errorMsg; - this.syncStatus = "exception" - }else { - this.total = res.data.data.total; - this.current = res.data.data.current; - this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100; - this.msg = `鍚屾涓�...[${res.data.data.current}/${res.data.data.total}]`; - this.timmer = setTimeout(this.getProgress, 300) + + if (res.data.data != null) { + if (res.data.data.total == 0) { + if (res.data.data.errorMsg !== null ){ + this.msg = res.data.data.errorMsg; + this.syncStatus = "exception" + }else { + this.msg = `绛夊緟鍚屾涓璥; + this.timmer = setTimeout(this.getProgress, 300) + } + }else { + if (res.data.data.total == res.data.data.current) { + this.syncStatus = "success" + this.percentage = 100; + this.msg = '鍚屾鎴愬姛'; + }else { + if (res.data.data.errorMsg !== null ){ + this.msg = res.data.data.errorMsg; + this.syncStatus = "exception" + }else { + this.total = res.data.data.total; + this.current = res.data.data.current; + this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100; + this.msg = `鍚屾涓�...[${res.data.data.current}/${res.data.data.total}]`; + this.timmer = setTimeout(this.getProgress, 300) + } + } + } } + }else { if (this.syncFlag) { this.syncStatus = "success" diff --git a/web_src/src/components/dialog/catalogEdit.vue b/web_src/src/components/dialog/catalogEdit.vue index 20b2168..93d8f8d 100644 --- a/web_src/src/components/dialog/catalogEdit.vue +++ b/web_src/src/components/dialog/catalogEdit.vue @@ -13,11 +13,24 @@ <div id="shared" style="margin-top: 1rem;margin-right: 100px;"> <el-form ref="form" :rules="rules" :model="form" label-width="140px" > <el-form-item label="鑺傜偣缂栧彿" prop="id" > - <el-input v-model="form.id" :disabled="isEdit"></el-input> + <el-tooltip class="item" effect="dark" content="" placement="top-start"> + <div slot="content"> + 寤鸿鐨勭被鍨嬶細 + <br/> +   琛屾斂鍖哄垝锛堝彲閫�2浣�/4浣�/6浣�/8浣�/10浣嶆暟瀛楋紝渚嬪锛�130432锛岃〃绀烘渤鍖楃渷閭兏甯傚箍骞冲幙锛� + <br/> +   涓氬姟鍒嗙粍锛堢11銆�12銆�13浣�215锛屼緥濡傦細34020000002150000001锛� + <br/> +   铏氭嫙缁勭粐锛堢11銆�12銆�13浣�216锛屼緥濡傦細34020000002160000001锛� + </div> + <el-input v-model="form.id" :disabled="isEdit"></el-input> + </el-tooltip> </el-form-item> <el-form-item label="鑺傜偣鍚嶇О" prop="name"> <el-input v-model="form.name" clearable></el-input> </el-form-item> + + <el-form-item> <div style="float: right;"> <el-button type="primary" @click="onSubmit" >纭</el-button> diff --git a/web_src/src/components/dialog/deviceEdit.vue b/web_src/src/components/dialog/deviceEdit.vue index 1b1aba0..b4dd285 100644 --- a/web_src/src/components/dialog/deviceEdit.vue +++ b/web_src/src/components/dialog/deviceEdit.vue @@ -45,6 +45,9 @@ <el-form-item v-if="form.subscribeCycleForMobilePosition > 0" label="绉诲姩浣嶇疆鎶ラ�侀棿闅�" prop="subscribeCycleForCatalog" > <el-input v-model="form.mobilePositionSubmissionInterval" clearable ></el-input> </el-form-item> + <el-form-item label="鍏朵粬閫夐」"> + <el-checkbox label="SSRC鏍¢獙" v-model="form.ssrcCheck" style="float: left"></el-checkbox> + </el-form-item> <el-form-item> <div style="float: right;"> <el-button type="primary" @click="onSubmit" >纭</el-button> diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index 38a2aef..0caec32 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -44,6 +44,9 @@ <el-form-item label="SIP璁よ瘉鐢ㄦ埛鍚�" prop="username"> <el-input v-model="platform.username"></el-input> </el-form-item> + <el-form-item label="琛屾斂鍖哄垝" prop="administrativeDivision"> + <el-input v-model="platform.administrativeDivision" clearable></el-input> + </el-form-item> <el-form-item label="SIP璁よ瘉瀵嗙爜" prop="password"> <el-input v-model="platform.password" ></el-input> </el-form-item> @@ -63,6 +66,18 @@ <el-option label="TCP" value="TCP"></el-option> </el-select> </el-form-item> + <el-form-item label="鐩綍鍒嗙粍" prop="catalogGroup"> + <el-select + v-model="platform.catalogGroup" + style="width: 100%" + placeholder="璇烽�夋嫨鐩綍鍒嗙粍" + > + <el-option label="1" value="1"></el-option> + <el-option label="2" value="2"></el-option> + <el-option label="4" value="4"></el-option> + <el-option label="8" value="8"></el-option> + </el-select> + </el-form-item> <el-form-item label="瀛楃闆�" prop="characterSet"> <el-select v-model="platform.characterSet" @@ -77,6 +92,7 @@ <el-checkbox label="鍚敤" v-model="platform.enable" @change="checkExpires"></el-checkbox> <el-checkbox label="浜戝彴鎺у埗" v-model="platform.ptz"></el-checkbox> <el-checkbox label="鍏变韩鎵�鏈夌洿鎾祦" v-model="platform.shareAllLiveStream"></el-checkbox> + <el-checkbox label="鎷夎捣绂荤嚎鎺ㄦ祦" v-model="platform.startOfflinePush"></el-checkbox> </el-form-item> <el-form-item> <el-button type="primary" @click="onSubmit">{{ @@ -138,6 +154,9 @@ transport: "UDP", characterSet: "GB2312", shareAllLiveStream: false, + startOfflinePush: false, + catalogGroup: 1, + administrativeDivision: null, }, rules: { name: [{ required: true, message: "璇疯緭鍏ュ钩鍙板悕绉�", trigger: "blur" }], @@ -175,6 +194,7 @@ that.platform.devicePort = res.data.devicePort; that.platform.username = res.data.username; that.platform.password = res.data.password; + that.platform.administrativeDivision = res.data.username.substr(0, 6); }).catch(function (error) { console.log(error); }); @@ -199,6 +219,9 @@ this.platform.characterSet = platform.characterSet; this.platform.shareAllLiveStream = platform.shareAllLiveStream; this.platform.catalogId = platform.catalogId; + this.platform.startOfflinePush = platform.startOfflinePush; + this.platform.catalogGroup = platform.catalogGroup; + this.platform.administrativeDivision = platform.administrativeDivision; this.onSubmit_text = "淇濆瓨"; this.saveUrl = "/api/platform/save"; } @@ -213,6 +236,10 @@ deviceGBIdChange: function () { this.platform.username = this.platform.deviceGBId ; + if (this.platform.administrativeDivision == null) { + this.platform.administrativeDivision = this.platform.deviceGBId.substr(0, 6); + } + }, onSubmit: function () { var that = this; @@ -253,6 +280,7 @@ rtcp: false, name: null, serverGBId: null, + administrativeDivision: null, serverGBDomain: null, serverIP: null, serverPort: null, @@ -266,6 +294,8 @@ transport: "UDP", characterSet: "GB2312", shareAllLiveStream: false, + startOfflinePush: false, + catalogGroup: 1, } }, deviceGBIdExit: async function (deviceGbId) { -- Gitblit v1.8.0