From 1c95f1b4aa45f5fbe16b3ff2e00c560dd5d84550 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 11 Mar 2022 11:22:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=A4=9A=E4=BD=99=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DOCKERFILE | 2 +- .../iot/vmp/gb28181/bean/SubscribeHolder.java | 12 ++++++ .../iot/vmp/gb28181/bean/SubscribeInfo.java | 33 --------------- .../subscribe/catalog/CatalogEventLister.java | 2 +- .../impl/SubscribeRequestProcessor.java | 17 +------- .../iot/vmp/storager/IRedisCatchStorage.java | 10 ----- .../storager/impl/RedisCatchStorageImpl.java | 41 ------------------- 7 files changed, 16 insertions(+), 101 deletions(-) diff --git a/DOCKERFILE b/DOCKERFILE index 96bc29bf..6c4beb55 100644 --- a/DOCKERFILE +++ b/DOCKERFILE @@ -85,7 +85,7 @@ RUN echo '#!/bin/bash' > run.sh && \ echo 'nohup /opt/media/MediaServer -d -m 3 &' >> run.sh && \ echo 'cd /opt/wvp' >> run.sh && \ echo 'if [${WVP_CONFIG}]; then' >> run.sh && \ - echo ' java -jar *.jar --spring.confi g.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 ${WVP_CONFIG}' >> run.sh && \ + echo ' java -jar *.jar --spring.config.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 ${WVP_CONFIG}' >> run.sh && \ echo 'else' >> run.sh && \ echo ' java -jar *.jar --spring.config.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 --media.ip=127.0.0.1 --media.sdp-ip=${WVP_IP} --sip.ip=${WVP_IP} --media.stream-ip=${WVP_IP}' >> run.sh && \ echo 'fi' >> run.sh diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java index a027486c..287c2a0a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java @@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.gb28181.bean; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; @Component @@ -34,4 +36,14 @@ public class SubscribeHolder { public void removeMobilePositionSubscribe(String platformId) { mobilePositionMap.remove(platformId); } + + public List getAllCatalogSubscribePlatform() { + List platforms = new ArrayList<>(); + if(catalogMap.size() > 0) { + for (String key : catalogMap.keySet()) { + platforms.add(catalogMap.get(key).getId()); + } + } + return platforms; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java index 373533a6..956e93eb 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java @@ -14,17 +14,11 @@ public class SubscribeInfo { public SubscribeInfo(RequestEvent evt, String id) { this.id = id; Request request = evt.getRequest(); - CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME); - this.callId = callIdHeader.getCallId(); - FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME); - this.fromTag = fromHeader.getTag(); ExpiresHeader expiresHeader = (ExpiresHeader)request.getHeader(ExpiresHeader.NAME); this.expires = expiresHeader.getExpires(); EventHeader eventHeader = (EventHeader)request.getHeader(EventHeader.NAME); this.eventId = eventHeader.getEventId(); this.eventType = eventHeader.getEventType(); - ViaHeader viaHeader = (ViaHeader)request.getHeader(ViaHeader.NAME); - this.branch = viaHeader.getBranch(); this.transaction = evt.getServerTransaction(); this.dialog = evt.getDialog(); } @@ -34,9 +28,6 @@ public class SubscribeInfo { private String callId; private String eventId; private String eventType; - private String fromTag; - private String toTag; - private String branch; private ServerTransaction transaction; private Dialog dialog; @@ -52,18 +43,6 @@ public class SubscribeInfo { return callId; } - public String getFromTag() { - return fromTag; - } - - public void setToTag(String toTag) { - this.toTag = toTag; - } - - public String getToTag() { - return toTag; - } - public void setId(String id) { this.id = id; } @@ -76,10 +55,6 @@ public class SubscribeInfo { this.callId = callId; } - public void setFromTag(String fromTag) { - this.fromTag = fromTag; - } - public String getEventId() { return eventId; } @@ -96,14 +71,6 @@ public class SubscribeInfo { this.eventType = eventType; } - public String getBranch() { - return branch; - } - - public void setBranch(String branch) { - this.branch = branch; - } - public ServerTransaction getTransaction() { return transaction; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index 9e3b352a..6af6c661 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -74,7 +74,7 @@ public class CatalogEventLister implements ApplicationListener { } }else { // 获取所用订阅 - List platforms = redisCatchStorage.getAllSubscribePlatform(); + List platforms = subscribeHolder.getAllCatalogSubscribePlatform(); if (event.getDeviceChannels() != null) { if (platforms.size() > 0) { for (DeviceChannel deviceChannel : event.getDeviceChannels()) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index e1e7125e..4acec149 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -158,20 +158,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme String interval = XmlUtil.getText(rootElement, "Interval"); // GPS上报时间间隔 dynamicTask.startCron(key, new GPSSubscribeTask(redisCatchStorage, sipCommanderForPlatform, storager, platformId, sn, key, subscribeHolder), Integer.parseInt(interval)); subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo); -// redisCatchStorage.updateSubscribe(key, subscribeInfo); }else if (subscribeInfo.getExpires() == 0) { dynamicTask.stop(key); -// redisCatchStorage.delSubscribe(key); subscribeHolder.removeMobilePositionSubscribe(platformId); } try { ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); - Response response = responseXmlAck(evt, resultXml.toString(), parentPlatform); - ToHeader toHeader = (ToHeader)response.getHeader(ToHeader.NAME); - subscribeInfo.setToTag(toHeader.getTag()); - redisCatchStorage.updateSubscribe(key, subscribeInfo); - + responseXmlAck(evt, resultXml.toString(), parentPlatform); } catch (SipException e) { e.printStackTrace(); } catch (InvalidArgumentException e) { @@ -211,21 +205,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme .append("\r\n"); if (subscribeInfo.getExpires() > 0) { -// redisCatchStorage.updateSubscribe(key, subscribeInfo); subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); }else if (subscribeInfo.getExpires() == 0) { -// redisCatchStorage.delSubscribe(key); subscribeHolder.removeCatalogSubscribe(platformId); } try { ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); - Response response = responseXmlAck(evt, resultXml.toString(), parentPlatform); - ToHeader toHeader = (ToHeader)response.getHeader(ToHeader.NAME); - subscribeInfo.setToTag(toHeader.getTag()); -// redisCatchStorage.updateSubscribe(key, subscribeInfo); - subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); - + responseXmlAck(evt, resultXml.toString(), parentPlatform); } catch (SipException e) { e.printStackTrace(); } catch (InvalidArgumentException e) { diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java index b0edc063..5829292c 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -204,18 +204,8 @@ public interface IRedisCatchStorage { void resetAllSN(); - void updateSubscribe(String key, SubscribeInfo subscribeInfo); - - SubscribeInfo getSubscribe(String key); - - void delSubscribe(String key); - MediaItem getStreamInfo(String app, String streamId, String mediaServerId); - List getAllSubscribe(); - - List getAllSubscribePlatform(); - void addCpuInfo(double cpuInfo); void addMemInfo(double memInfo); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 0641348a..0541d935 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -490,21 +490,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { return (GPSMsgInfo)redis.get(key); } - @Override - public void updateSubscribe(String key, SubscribeInfo subscribeInfo) { - redis.set(key, subscribeInfo, subscribeInfo.getExpires()); - } - - @Override - public SubscribeInfo getSubscribe(String key) { - return (SubscribeInfo)redis.get(key); - } - - @Override - public void delSubscribe(String key) { - redis.del(key); - } - @Override public List getAllGpsMsgInfo() { String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_*"; @@ -535,32 +520,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { return result; } - @Override - public List getAllSubscribe() { - String scanKey = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_*"; - List result = new ArrayList<>(); - List keys = redis.scan(scanKey); - for (int i = 0; i < keys.size(); i++) { - String key = (String) keys.get(i); - SubscribeInfo subscribeInfo = (SubscribeInfo) redis.get(key); - result.add(subscribeInfo); - } - return result; - } - - @Override - public List getAllSubscribePlatform() { - String scanKey = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_*"; - List result = new ArrayList<>(); - List keys = redis.scan(scanKey); - for (int i = 0; i < keys.size(); i++) { - String key = (String) keys.get(i); - String platformId = key.substring(scanKey.length() - 1); - result.add(platformId); - } - return result; - } - @Override public void addCpuInfo(double cpuInfo) { String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetup.getServerId();