From 03d6ad289baddf8feed64ffca5f1b13828bea710 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 01 九月 2022 14:50:28 +0800
Subject: [PATCH] Merge branch 'wvp-28181-2.0'
---
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java | 7
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java | 10
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java | 3
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java | 2
web_src/src/components/dialog/pushStreamEdit.vue | 2
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java | 35
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java | 1
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java | 11
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java | 4
src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java | 33 -
web_src/src/components/Login.vue | 11
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java | 11
src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java | 45 +
doc/_sidebar.md | 1
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java | 11
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java | 10
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java | 4
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java | 1
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java | 61 +
web_src/src/components/dialog/StreamProxyEdit.vue | 2
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java | 13
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java | 7
web_src/src/components/dialog/platformEdit.vue | 21
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java | 232 ++++++++
src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java | 10
src/main/java/com/genersoft/iot/vmp/conf/security/UrlTokenHandler.java | 24
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 17
src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java | 5
src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java | 74 +-
src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java | 165 +++++
src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java | 32
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java | 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java | 6
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java | 9
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java | 41 -
src/main/java/com/genersoft/iot/vmp/storager/dao/dto/PlatformRegisterInfo.java | 41 +
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java | 8
src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java | 6
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 31
src/main/java/com/genersoft/iot/vmp/gb28181/utils/HeaderUtils.java | 22
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java | 3
src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java | 2
web_src/src/components/CloudRecord.vue | 8
pom.xml | 2
src/main/resources/logback-spring-local.xml | 30
web_src/src/components/dialog/MediaServerEdit.vue | 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java | 9
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java | 7
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java | 11
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java | 40
web_src/src/components/dialog/devicePlayer.vue | 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java | 54 -
web_src/src/components/CloudRecordDetail.vue | 5
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java | 7
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java | 6
src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java | 28
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java | 4
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java | 4
src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java | 55 +
src/main/resources/all-application.yml | 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java | 6
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java | 7
/dev/null | 72 --
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java | 20
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 87 ++-
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java | 25
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 3
src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java | 4
68 files changed, 979 insertions(+), 557 deletions(-)
diff --git a/doc/_content/donation.md b/doc/_content/donation.md
deleted file mode 100644
index 959eee8..0000000
--- a/doc/_content/donation.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# 鎹愯禒
-椤圭洰鐩墠浠嶅湪绉瀬寮�鍙戙�傚ぇ瀹剁殑鎹愯禒浠ュ強start鍙互璁╂垜鐪嬪埌澶у鐨勬敮鎸佷簬鍏虫敞銆傛洿鍔犳湁鍔ㄥ姏鎶婇」鐩淮鎶や笅鍘汇��
-
-<div align="left">
-<img src=_media/weixin.jpg style="height: 500px; border: 1px solid #e2e2e2"/>
-<img src=_media/zhifubao.jpg style="height: 500px; border: 1px solid #e2e2e2; margin-left: 20px"/>
-</div>
\ No newline at end of file
diff --git a/doc/_sidebar.md b/doc/_sidebar.md
index eb0c96c..3b10bae 100644
--- a/doc/_sidebar.md
+++ b/doc/_sidebar.md
@@ -29,5 +29,4 @@
- [璁惧娉ㄥ唽涓嶄笂鏉ョ殑瑙e喅鍔炴硶](_content/qa/regiser_error.md)
- [鐐规挱瓒呮椂/鎶ラ敊鐨勮В鍐冲姙娉昡(_content/qa/play_error.md)
* [**鍏嶈矗澹版槑**](_content/disclaimers.md)
-* [**鎹愯禒**](_content/donation.md)
* [**鍏充簬鏈枃妗�**](_content/about_doc.md)
diff --git a/pom.xml b/pom.xml
index 2b9a838..71dd948 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
<groupId>com.genersoft</groupId>
<artifactId>wvp-pro</artifactId>
- <version>2.3.1</version>
+ <version>2.3.2</version>
<name>web video platform</name>
<description>鍥芥爣28181瑙嗛骞冲彴</description>
diff --git a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
index 4f717f0..41a56cd 100644
--- a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
+++ b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
@@ -31,6 +31,8 @@
private String rtsp;
private String rtsps;
private String rtc;
+
+ private String rtcs;
private String mediaServerId;
private Object tracks;
private String startTime;
@@ -302,4 +304,12 @@
public void setIp(String ip) {
this.ip = ip;
}
+
+ public String getRtcs() {
+ return rtcs;
+ }
+
+ public void setRtcs(String rtcs) {
+ this.rtcs = rtcs;
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
index bbbfce9..7a122c7 100644
--- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
+++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
@@ -14,8 +14,6 @@
public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_";
- public static final String MEDIA_SERVER_KEEPALIVE_PREFIX = "VMP_MEDIA_SERVER_KEEPALIVE_";
-
public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS_";
public static final String MEDIA_STREAM_PREFIX = "VMP_MEDIA_STREAM";
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java b/src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java
deleted file mode 100644
index ef4a617..0000000
--- a/src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.genersoft.iot.vmp.conf;
-
-import org.springframework.data.redis.connection.RedisConnection;
-import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
-import org.springframework.data.redis.listener.RedisMessageListenerContainer;
-
-import java.util.Properties;
-
-public class RedisKeyExpirationEventMessageListener extends KeyExpirationEventMessageListener {
-
- private UserSetting userSetting;
- private RedisMessageListenerContainer listenerContainer;
- private String keyspaceNotificationsConfigParameter = "EA";
-
- public RedisKeyExpirationEventMessageListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
- super(listenerContainer);
- this.listenerContainer = listenerContainer;
- this.userSetting = userSetting;
- }
-
- @Override
- public void init() {
- if (!userSetting.getRedisConfig()) {
- // 閰嶇疆springboot榛樿Config涓虹┖锛屽嵆涓嶈搴旂敤鍘讳慨鏀箁edis鐨勯粯璁ら厤缃紝鍥犱负Redis鏈嶅姟鍑轰簬瀹夊叏浼氱鐢–ONFIG鍛戒护缁欒繙绋嬬敤鎴蜂娇鐢�
- setKeyspaceNotificationsConfigParameter("");
- }else {
-
- RedisConnection connection = this.listenerContainer.getConnectionFactory().getConnection();
- Properties config = connection.getConfig("notify-keyspace-events");
- try {
- if (!keyspaceNotificationsConfigParameter.equals(config.getProperty("notify-keyspace-events"))) {
- connection.setConfig("notify-keyspace-events", keyspaceNotificationsConfigParameter);
- }
- } finally {
- connection.close();
- }
- }
- super.init();
- }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
index cf16f86..93674f6 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
@@ -4,6 +4,7 @@
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
+import com.genersoft.iot.vmp.service.IPlatformService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,6 +16,7 @@
/**
* 绯荤粺鍚姩鏃舵帶鍒朵笂绾у钩鍙伴噸鏂版敞鍐�
+ * @author lin
*/
@Component
@Order(value=3)
@@ -27,7 +29,7 @@
private IRedisCatchStorage redisCatchStorage;
@Autowired
- private EventPublisher publisher;
+ private IPlatformService platformService;
@Autowired
private ISIPCommanderForPlatform sipCommanderForPlatform;
@@ -35,33 +37,26 @@
@Override
public void run(String... args) throws Exception {
- // 璁剧疆鎵�鏈夊钩鍙扮绾�
- storager.outlineForAllParentPlatform();
-
- // 娓呯悊鎵�鏈夊钩鍙版敞鍐岀紦瀛�
- redisCatchStorage.cleanPlatformRegisterInfos();
-
- // 鍋滄鎵�鏈夋帹娴�
-// zlmrtpServerFactory.closeAllSendRtpStream();
-
+ // 鑾峰彇鎵�鏈夊惎鐢ㄧ殑骞冲彴
List<ParentPlatform> parentPlatforms = storager.queryEnableParentPlatformList(true);
for (ParentPlatform parentPlatform : parentPlatforms) {
- redisCatchStorage.updatePlatformRegister(parentPlatform);
-
- redisCatchStorage.updatePlatformKeepalive(parentPlatform);
-
+ // 鏇存柊缂撳瓨
ParentPlatformCatch parentPlatformCatch = new ParentPlatformCatch();
-
parentPlatformCatch.setParentPlatform(parentPlatform);
parentPlatformCatch.setId(parentPlatform.getServerGBId());
redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
+ if (parentPlatform.isStatus()) {
+ // 璁剧疆鎵�鏈夊钩鍙扮绾�
+ platformService.offline(parentPlatform);
+ // 鍙栨秷璁㈤槄
+ sipCommanderForPlatform.unregister(parentPlatform, null, (eventResult)->{
+ platformService.login(parentPlatform);
+ });
+ }else {
+ platformService.login(parentPlatform);
+ }
- // 鍙栨秷璁㈤槄
- sipCommanderForPlatform.unregister(parentPlatform, null, (eventResult)->{
- // 鍙戦�佸钩鍙版湭娉ㄥ唽娑堟伅
- publisher.platformNotRegisterEventPublish(parentPlatform.getServerGBId());
- });
}
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
index d28ddeb..017b39d 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
@@ -31,8 +31,6 @@
private Boolean logInDatebase = Boolean.TRUE;
- private Boolean redisConfig = Boolean.TRUE;
-
private String serverId = "000000";
private String thirdPartyGBIdReg = "[\\s\\S]*";
@@ -121,14 +119,6 @@
public void setThirdPartyGBIdReg(String thirdPartyGBIdReg) {
this.thirdPartyGBIdReg = thirdPartyGBIdReg;
- }
-
- public Boolean getRedisConfig() {
- return redisConfig;
- }
-
- public void setRedisConfig(Boolean redisConfig) {
- this.redisConfig = redisConfig;
}
public Boolean getRecordSip() {
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java b/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
index 95b2262..9cdd2a4 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
@@ -1,6 +1,8 @@
package com.genersoft.iot.vmp.conf.security;
import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
+import org.apache.poi.hssf.eventmodel.ERFListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.AuthenticationException;
@@ -28,8 +30,8 @@
response.setHeader("Access-Control-Allow-Headers", "token, Accept, Origin, X-Requested-With, Content-Type, Last-Modified");
response.setHeader("Content-type", "application/json;charset=UTF-8");
JSONObject jsonObject = new JSONObject();
- jsonObject.put("code", "-1");
- jsonObject.put("msg", "璇风櫥褰曞悗閲嶆柊璇锋眰");
+ jsonObject.put("code", ErrorCode.ERROR401.getCode());
+ jsonObject.put("msg", ErrorCode.ERROR401.getMsg());
String logUri = "api/user/login";
if (request.getRequestURI().contains(logUri)){
jsonObject.put("msg", e.getMessage());
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/UrlTokenHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/security/UrlTokenHandler.java
new file mode 100644
index 0000000..e63aca4
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/conf/security/UrlTokenHandler.java
@@ -0,0 +1,24 @@
+package com.genersoft.iot.vmp.conf.security;
+
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import java.util.Collections;
+
+public class UrlTokenHandler extends SpringBootServletInitializer {
+
+ @Override
+ public void onStartup(ServletContext servletContext) throws ServletException {
+ super.onStartup(servletContext);
+
+ servletContext.setSessionTrackingModes(
+ Collections.singleton(SessionTrackingMode.COOKIE)
+ );
+ SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
+ sessionCookieConfig.setHttpOnly(true);
+
+ }
+}
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 c1811bf..f32bd26 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
@@ -10,14 +10,10 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
-import org.springframework.stereotype.Component;
import javax.sip.*;
import java.util.Properties;
import java.util.TooManyListenersException;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
@Configuration
public class SipLayer{
@@ -52,7 +48,9 @@
* 瀹屾暣閰嶇疆鍙傝�� gov.nist.javax.sip.SipStackImpl锛岄渶瑕佷笅杞芥簮鐮�
* gov/nist/javax/sip/SipStackImpl.class
*/
- properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "true");
+ if (logger.isDebugEnabled()) {
+ properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false");
+ }
// 鎺ユ敹鎵�鏈塶otify璇锋眰锛屽嵆浣挎病鏈夎闃�
properties.setProperty("gov.nist.javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true");
// 涓篲NULL _瀵硅瘽妗嗕紶閫抇缁堟鐨刜浜嬩欢
@@ -63,13 +61,13 @@
properties.setProperty("gov.nist.javax.sip.RELIABLE_CONNECTION_KEEP_ALIVE_TIMEOUT", "60");
/**
- * 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
- * TRACE_EXCEPTION = 17; public static final int TRACE_DEBUG = 32;
+ * sip_server_log.log 鍜� sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE
*/
- properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "0");
- properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "sip_server_log");
- properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "sip_debug_log");
+ properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "ERROR");
+// if (logger.isDebugEnabled()) {
+// properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "DEBUG");
+// }
+
sipStack = (SipStackImpl) sipFactory.createSipStack(properties);
return sipStack;
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 ef2eecd..ade5d0e 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
@@ -84,7 +84,7 @@
* 娉ㄥ唽鍛ㄦ湡 (绉�)
*/
@Schema(description = "娉ㄥ唽鍛ㄦ湡 (绉�)")
- private String expires;
+ private int expires;
/**
* 蹇冭烦鍛ㄦ湡(绉�)
@@ -286,11 +286,11 @@
this.password = password;
}
- public String getExpires() {
+ public int getExpires() {
return expires;
}
- public void setExpires(String expires) {
+ public void setExpires(int expires) {
this.expires = expires;
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java
index 6c429f2..a53d26e 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java
@@ -4,7 +4,9 @@
private String id;
- // 蹇冭烦鏈洖澶嶆鏁�
+ /**
+ * 蹇冭烦鏈洖澶嶆鏁�
+ */
private int keepAliveReply;
// 娉ㄥ唽鏈洖澶嶆鏁�
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 4a900c1..441dff3 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
@@ -14,6 +14,9 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
+/**
+ * @author lin
+ */
@Component
public class SubscribeHolder {
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
index 8a4dd3d..26ababd 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
@@ -2,9 +2,6 @@
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent;
-import com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire.PlatformKeepaliveExpireEvent;
-import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformCycleRegisterEvent;
-import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformNotRegisterEvent;
import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
@@ -31,36 +28,6 @@
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
-
- /**
- * 骞冲彴蹇冭烦鍒版湡浜嬩欢
- * @param platformGbId
- */
- public void platformKeepaliveExpireEventPublish(String platformGbId){
- PlatformKeepaliveExpireEvent platformKeepaliveExpireEvent = new PlatformKeepaliveExpireEvent(this);
- platformKeepaliveExpireEvent.setPlatformGbID(platformGbId);
- applicationEventPublisher.publishEvent(platformKeepaliveExpireEvent);
- }
-
- /**
- * 骞冲彴鏈敞鍐屼簨浠�
- * @param platformGbId
- */
- public void platformNotRegisterEventPublish(String platformGbId){
- PlatformNotRegisterEvent platformNotRegisterEvent = new PlatformNotRegisterEvent(this);
- platformNotRegisterEvent.setPlatformGbID(platformGbId);
- applicationEventPublisher.publishEvent(platformNotRegisterEvent);
- }
-
- /**
- * 骞冲彴鍛ㄦ湡娉ㄥ唽浜嬩欢
- * @param paltformGbId
- */
- public void platformRegisterCycleEventPublish(String paltformGbId) {
- PlatformCycleRegisterEvent platformCycleRegisterEvent = new PlatformCycleRegisterEvent(this);
- platformCycleRegisterEvent.setPlatformGbID(paltformGbId);
- applicationEventPublisher.publishEvent(platformCycleRegisterEvent);
- }
/**
* 璁惧鎶ヨ浜嬩欢
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
index c6cfc7a..b3fd82e 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
@@ -59,9 +59,25 @@
void response(EventResult eventResult);
}
+ /**
+ *
+ */
+ public enum EventResultType{
+ // 瓒呮椂
+ timeout,
+ // 鍥炲
+ response,
+ // 浜嬪姟宸茬粨鏉�
+ transactionTerminated,
+ // 浼氳瘽宸茬粨鏉�
+ dialogTerminated,
+ // 璁惧鏈壘鍒�
+ deviceNotFoundEvent
+ }
+
public static class EventResult<EventObject>{
public int statusCode;
- public String type;
+ public EventResultType type;
public String msg;
public String callId;
public Dialog dialog;
@@ -76,7 +92,7 @@
ResponseEvent responseEvent = (ResponseEvent)event;
Response response = responseEvent.getResponse();
this.dialog = responseEvent.getDialog();
- this.type = "response";
+ this.type = EventResultType.response;
if (response != null) {
this.msg = response.getReasonPhrase();
this.statusCode = response.getStatusCode();
@@ -85,28 +101,28 @@
}else if (event instanceof TimeoutEvent) {
TimeoutEvent timeoutEvent = (TimeoutEvent)event;
- this.type = "timeout";
+ this.type = EventResultType.timeout;
this.msg = "娑堟伅瓒呮椂鏈洖澶�";
this.statusCode = -1024;
this.dialog = timeoutEvent.getClientTransaction().getDialog();
this.callId = this.dialog != null?timeoutEvent.getClientTransaction().getDialog().getCallId().getCallId(): null;
}else if (event instanceof TransactionTerminatedEvent) {
TransactionTerminatedEvent transactionTerminatedEvent = (TransactionTerminatedEvent)event;
- this.type = "transactionTerminated";
+ this.type = EventResultType.transactionTerminated;
this.msg = "浜嬪姟宸茬粨鏉�";
this.statusCode = -1024;
this.callId = transactionTerminatedEvent.getClientTransaction().getDialog().getCallId().getCallId();
this.dialog = transactionTerminatedEvent.getClientTransaction().getDialog();
}else if (event instanceof DialogTerminatedEvent) {
DialogTerminatedEvent dialogTerminatedEvent = (DialogTerminatedEvent)event;
- this.type = "dialogTerminated";
+ this.type = EventResultType.dialogTerminated;
this.msg = "浼氳瘽宸茬粨鏉�";
this.statusCode = -1024;
this.callId = dialogTerminatedEvent.getDialog().getCallId().getCallId();
this.dialog = dialogTerminatedEvent.getDialog();
}else if (event instanceof DeviceNotFoundEvent) {
DeviceNotFoundEvent deviceNotFoundEvent = (DeviceNotFoundEvent)event;
- this.type = "deviceNotFoundEvent";
+ this.type = EventResultType.deviceNotFoundEvent;
this.msg = "璁惧鏈壘鍒�";
this.statusCode = -1024;
this.dialog = deviceNotFoundEvent.getDialog();
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEvent.java
deleted file mode 100644
index 1e9a2c4..0000000
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEvent.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire;
-
-import org.springframework.context.ApplicationEvent;
-
-/**
- * 骞冲彴蹇冭烦瓒呮椂浜嬩欢
- */
-public class PlatformKeepaliveExpireEvent extends ApplicationEvent {
-
- /**
- * Add default serial version ID
- */
- private static final long serialVersionUID = 1L;
-
- private String platformGbID;
-
- public PlatformKeepaliveExpireEvent(Object source) {
- super(source);
- }
-
- public String getPlatformGbID() {
- return platformGbID;
- }
-
- public void setPlatformGbID(String platformGbID) {
- this.platformGbID = platformGbID;
- }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java
deleted file mode 100644
index 67b297c..0000000
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire;
-
-import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
-import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
-import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
-import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
-import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
-import org.jetbrains.annotations.NotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationListener;
-import org.springframework.stereotype.Component;
-
-import javax.sip.message.Response;
-
-/**
- * @description: 骞冲彴蹇冭烦瓒呮椂浜嬩欢
- * @author: panll
- * @date: 2020骞�11鏈�5鏃� 10:00
- */
-@Component
-public class PlatformKeepaliveExpireEventLister implements ApplicationListener<PlatformKeepaliveExpireEvent> {
-
-
- private final static Logger logger = LoggerFactory.getLogger(PlatformKeepaliveExpireEventLister.class);
-
- @Autowired
- private IVideoManagerStorage storager;
-
- @Autowired
- private IRedisCatchStorage redisCatchStorage;
-
- @Autowired
- private ISIPCommanderForPlatform sipCommanderForPlatform;
-
- @Autowired
- private SipSubscribe sipSubscribe;
-
- @Autowired
- private EventPublisher publisher;
-
- @Override
- public void onApplicationEvent(@NotNull PlatformKeepaliveExpireEvent event) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("骞冲彴蹇冭烦鍒版湡浜嬩欢浜嬩欢瑙﹀彂锛屽钩鍙板浗鏍嘔D锛�" + event.getPlatformGbID());
- }
- ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformGbID());
- ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(event.getPlatformGbID());
- if (parentPlatformCatch == null) {
- return;
- }
- if (parentPlatform == null) {
- logger.debug("骞冲彴蹇冭烦鍒版湡浜嬩欢浜嬩欢瑙﹀彂锛屼絾骞冲彴宸茬粡鍒犻櫎!!! 骞冲彴鍥芥爣ID锛�" + event.getPlatformGbID());
- return;
- }
- parentPlatformCatch.setParentPlatform(parentPlatform);
- // 鍙戦�佸績璺�
- if (parentPlatformCatch.getKeepAliveReply() >= 3) {
- // 鏈�3娆℃湭鏀跺埌蹇冭烦鍥炲, 璁剧疆骞冲彴鐘舵�佷负绂荤嚎, 寮�濮嬮噸鏂版敞鍐�
- logger.warn("鏈�3娆℃湭鏀跺埌蹇冭烦鍥炲,鏍囪璁剧疆骞冲彴鐘舵�佷负绂荤嚎, 骞堕噸鏂版敞鍐� 骞冲彴鍥芥爣ID锛�" + event.getPlatformGbID());
- storager.updateParentPlatformStatus(event.getPlatformGbID(), false);
- publisher.platformNotRegisterEventPublish(event.getPlatformGbID());
- parentPlatformCatch.setKeepAliveReply(0);
- redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
- }else {
- // 鍐嶆鍙戦�佸績璺�
- String callId = sipCommanderForPlatform.keepalive(parentPlatform);
-
- parentPlatformCatch.setKeepAliveReply( parentPlatformCatch.getKeepAliveReply() + 1);
- // 瀛樺偍蹇冭烦淇℃伅, 骞惰缃姸鎬佷负鏈洖澶�, 濡傛灉澶氭杩囨湡浠嶆湭鏀跺埌鍥炲,鍒欒涓轰笂绾у钩鍙板凡缁忕绾�
- redisCatchStorage.updatePlatformKeepalive(parentPlatform);
- redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
-
- sipSubscribe.addOkSubscribe(callId, (SipSubscribe.EventResult eventResult) ->{
- if (eventResult.statusCode == Response.OK) {
- // 鏀跺埌蹇冭烦鍝嶅簲淇℃伅,
- parentPlatformCatch.setKeepAliveReply(0);
- redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
- }
- } );
- }
- }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEvent.java
deleted file mode 100644
index c2ff61f..0000000
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEvent.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
-
-import org.springframework.context.ApplicationEvent;
-
-public class PlatformCycleRegisterEvent extends ApplicationEvent {
- /**
- * Add default serial version ID
- */
- private static final long serialVersionUID = 1L;
-
- private String platformGbID;
-
- public String getPlatformGbID() {
- return platformGbID;
- }
-
- public void setPlatformGbID(String platformGbID) {
- this.platformGbID = platformGbID;
- }
-
- public PlatformCycleRegisterEvent(Object source) {
- super(source);
- }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java
deleted file mode 100644
index d2a9246..0000000
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
-
-import com.genersoft.iot.vmp.conf.DynamicTask;
-import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
-import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationListener;
-import org.springframework.stereotype.Component;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-@Component
-public class PlatformCycleRegisterEventLister implements ApplicationListener<PlatformCycleRegisterEvent> {
-
- private final static Logger logger = LoggerFactory.getLogger(PlatformCycleRegisterEventLister.class);
-
- @Autowired
- private IVideoManagerStorage storager;
- @Autowired
- private ISIPCommanderForPlatform sipCommanderFroPlatform;
- @Autowired
- private DynamicTask dynamicTask;
-
- @Override
- public void onApplicationEvent(PlatformCycleRegisterEvent event) {
- logger.info("涓婄骇骞冲彴鍛ㄦ湡娉ㄥ唽浜嬩欢");
- ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformGbID());
- if (parentPlatform == null) {
- logger.info("[ 骞冲彴鏈敞鍐屼簨浠� ] 骞冲彴宸茬粡鍒犻櫎!!! 骞冲彴鍥芥爣ID锛�" + event.getPlatformGbID());
- return;
- }
- String taskKey = "platform-cycle-register" + parentPlatform.getServerGBId();;
- SipSubscribe.Event okEvent = (responseEvent)->{
- dynamicTask.stop(taskKey);
- };
- dynamicTask.startCron(taskKey, ()->{
- logger.info("[骞冲彴娉ㄥ唽]鍐嶆鍚戝钩鍙版敞鍐岋紝骞冲彴鍥芥爣ID锛�" + event.getPlatformGbID());
- sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
- }, Integer.parseInt(parentPlatform.getExpires())* 1000);
- }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEvent.java
deleted file mode 100644
index c936975..0000000
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEvent.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
-
-import org.springframework.context.ApplicationEvent;
-
-public class PlatformNotRegisterEvent extends ApplicationEvent {
-
- /**
- * Add default serial version ID
- */
- private static final long serialVersionUID = 1L;
-
- private String platformGbID;
-
- public PlatformNotRegisterEvent(Object source) {
- super(source);
- }
-
- public String getPlatformGbID() {
- return platformGbID;
- }
-
- public void setPlatformGbID(String platformGbID) {
- this.platformGbID = platformGbID;
- }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java
deleted file mode 100644
index 56bdeb5..0000000
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
-
-import com.genersoft.iot.vmp.conf.DynamicTask;
-import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
-import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
-import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
-import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
-import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
-import com.genersoft.iot.vmp.service.IMediaServerService;
-import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationListener;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-/**
- * @description: 骞冲彴鏈敞鍐屼簨浠�,鏉ユ簮鏈変簩:
- * 1銆佸钩鍙版柊娣诲姞
- * 2銆佸钩鍙板績璺宠秴鏃�
- * @author: panll
- * @date: 2020骞�11鏈�24鏃� 10:00
- */
-@Component
-public class PlatformNotRegisterEventLister implements ApplicationListener<PlatformNotRegisterEvent> {
-
- private final static Logger logger = LoggerFactory.getLogger(PlatformNotRegisterEventLister.class);
-
- @Autowired
- private IVideoManagerStorage storager;
- @Autowired
- private IRedisCatchStorage redisCatchStorage;
- @Autowired
- private IMediaServerService mediaServerService;
-
- @Autowired
- private SIPCommanderFroPlatform sipCommanderFroPlatform;
-
- @Autowired
- private ZLMRTPServerFactory zlmrtpServerFactory;
-
- @Autowired
- private SipConfig config;
-
- @Autowired
- private DynamicTask dynamicTask;
-
- // @Autowired
- // private RedisUtil redis;
-
- @Override
- public void onApplicationEvent(PlatformNotRegisterEvent event) {
-
- logger.info("[ 骞冲彴鏈敞鍐屼簨浠� ]骞冲彴鍥芥爣ID锛�" + event.getPlatformGbID());
-
- ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformGbID());
- if (parentPlatform == null) {
- logger.info("[ 骞冲彴鏈敞鍐屼簨浠� ] 骞冲彴宸茬粡鍒犻櫎!!! 骞冲彴鍥芥爣ID锛�" + event.getPlatformGbID());
- return;
- }
- // 鏌ヨ鏄惁鏈夋帹娴侊紝 濡傛灉鏈夊垯閮藉仠姝�
- List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServer(event.getPlatformGbID());
- if (sendRtpItems != null && sendRtpItems.size() > 0) {
- logger.info("[ 骞冲彴鏈敞鍐屼簨浠� ] 鍋滄[ {} ]鐨勬墍鏈夋帹娴�", event.getPlatformGbID());
- for (SendRtpItem sendRtpItem : sendRtpItems) {
- redisCatchStorage.deleteSendRTPServer(event.getPlatformGbID(), sendRtpItem.getChannelId(), null, null);
- MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
- Map<String, Object> param = new HashMap<>();
- param.put("vhost", "__defaultVhost__");
- param.put("app", sendRtpItem.getApp());
- param.put("stream", sendRtpItem.getStreamId());
- zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
- }
-
- }
- String taskKey = "platform-not-register-" + parentPlatform.getServerGBId();
- SipSubscribe.Event okEvent = (responseEvent)->{
- dynamicTask.stop(taskKey);
- };
- dynamicTask.startCron(taskKey, ()->{
- logger.info("[骞冲彴娉ㄥ唽]鍐嶆鍚戝钩鍙版敞鍐岋紝骞冲彴鍥芥爣ID锛�" + event.getPlatformGbID());
- sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
- }, config.getRegisterTimeInterval()* 1000);
- }
-}
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 79bb4ca..734d600 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
@@ -30,22 +30,9 @@
@Autowired
private IVideoManagerStorage storager;
- @Autowired
- private IRedisCatchStorage redisCatchStorage;
- @Autowired
- private IMediaServerService mediaServerService;
@Autowired
private SIPCommanderFroPlatform sipCommanderFroPlatform;
-
- @Autowired
- private ZLMRTPServerFactory zlmrtpServerFactory;
-
- @Autowired
- private SipConfig config;
-
- @Autowired
- private UserSetting userSetting;
@Autowired
private IGbStreamService gbStreamService;
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 7edee4d..2ee1037 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
@@ -60,7 +60,6 @@
// TODO 鏆傛椂鍙鐞嗚棰戞祦鐨勫洖澶�,鍚庣画澧炲姞瀵瑰浗鏍囪澶囩殑鏀寔
List<DeviceChannel> gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId());
if (gbStreams.size() == 0) {
- logger.info("鍙戦�佽闃呮椂鍙戠幇骞冲彴宸茬粡娌℃湁鍏宠仈鐨勭洿鎾祦锛歿}", platform.getServerGBId());
return;
}
for (DeviceChannel deviceChannel : gbStreams) {
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
index 319016c..13f04b6 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
@@ -71,7 +71,6 @@
@Override
@Async
public void processRequest(RequestEvent requestEvent) {
- logger.debug("\n鏀跺埌璇锋眰锛歕n{}", requestEvent.getRequest());
String method = requestEvent.getRequest().getMethod();
ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method);
if (sipRequestProcessor == null) {
@@ -90,7 +89,6 @@
@Async
public void processResponse(ResponseEvent responseEvent) {
Response response = responseEvent.getResponse();
- logger.debug("\n鏀跺埌鍝嶅簲锛歕n{}", responseEvent.getResponse());
int status = response.getStatusCode();
if (((status >= 200) && (status < 300)) || status == Response.UNAUTHORIZED) { // Success!
@@ -114,7 +112,7 @@
} else if ((status >= 100) && (status < 200)) {
// 澧炲姞鍏跺畠鏃犻渶鍥炲鐨勫搷搴旓紝濡�101銆�180绛�
} else {
- logger.warn("鎺ユ敹鍒板け璐ョ殑response鍝嶅簲锛乻tatus锛�" + status + ",message:" + response.getReasonPhrase()/* .getContent().toString()*/);
+ logger.warn("鎺ユ敹鍒板け璐ョ殑response鍝嶅簲锛乻tatus锛�" + status + ",message:" + response.getReasonPhrase());
if (responseEvent.getResponse() != null && sipSubscribe.getErrorSubscribesSize() > 0 ) {
CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME);
if (callIdHeader != null) {
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 154071e..b5cc514 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
@@ -3,7 +3,7 @@
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
import gov.nist.javax.sip.message.SIPRequest;
@@ -98,7 +98,7 @@
* @param device 瑙嗛璁惧
* @param channelId 棰勮閫氶亾
*/
- void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent);
+ void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent);
/**
* 璇锋眰鍥炴斁瑙嗛娴�
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
index d000f5a..351505f 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
@@ -15,7 +15,7 @@
* @return
*/
boolean register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent);
- boolean register(ParentPlatform parentPlatform, String callId, WWWAuthenticateHeader www, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain);
+ boolean register(ParentPlatform parentPlatform, String callId, WWWAuthenticateHeader www, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister);
/**
* 鍚戜笂绾у钩鍙版敞閿�
@@ -30,7 +30,7 @@
* @param parentPlatform
* @return callId(浣滀负鎺ュ彈鍥炲鐨勫垽瀹�)
*/
- String keepalive(ParentPlatform parentPlatform);
+ String keepalive(ParentPlatform parentPlatform,SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent);
/**
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
index ad8043f..a75e806 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
@@ -3,6 +3,7 @@
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
+import com.genersoft.iot.vmp.gb28181.utils.HeaderUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import gov.nist.javax.sip.message.MessageFactoryImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -75,7 +76,7 @@
}
- public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
+ public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException {
Request request = null;
String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort();
//璇锋眰琛�
@@ -109,18 +110,20 @@
.createSipURI(platform.getDeviceGBId(), sipAddress));
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
- ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(Integer.parseInt(platform.getExpires()));
+ ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0);
request.addHeader(expires);
+ UserAgentHeader userAgentHeader = HeaderUtils.createUserAgentHeader(sipFactory);
+ request.addHeader(userAgentHeader);
return request;
}
public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, String fromTag, String viaTag,
- String callId, WWWAuthenticateHeader www , CallIdHeader callIdHeader) throws ParseException, PeerUnavailableException, InvalidArgumentException {
+ String callId, WWWAuthenticateHeader www , CallIdHeader callIdHeader, boolean isRegister) throws ParseException, PeerUnavailableException, InvalidArgumentException {
- Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, viaTag, callIdHeader);
+ Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, viaTag, callIdHeader, isRegister);
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort());
if (www == null) {
AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader("Digest");
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
index b89fd8e..aee6d4e 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
@@ -12,6 +12,7 @@
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
+import com.genersoft.iot.vmp.gb28181.utils.HeaderUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import gov.nist.javax.sip.SipProviderImpl;
import gov.nist.javax.sip.SipStackImpl;
@@ -266,15 +267,7 @@
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory()
.createSipURI(sipConfig.getId(), sipConfig.getIp() + ":" + sipConfig.getPort()));
infoRequest.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
- List<String> agentParam = new ArrayList<>();
- agentParam.add("wvp-pro");
- // TODO 娣诲姞鐗堟湰淇℃伅浠ュ強鏃ユ湡
- UserAgentHeader userAgentHeader = null;
- try {
- userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
+ UserAgentHeader userAgentHeader = HeaderUtils.createUserAgentHeader(sipFactory);
infoRequest.addHeader(userAgentHeader);
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application",
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 811637a..9c31e2a 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
@@ -10,12 +10,12 @@
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider;
+import com.genersoft.iot.vmp.gb28181.utils.HeaderUtils;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
-import com.genersoft.iot.vmp.media.zlm.dto.HookType;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
@@ -33,19 +33,15 @@
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
import javax.sip.*;
import javax.sip.address.Address;
import javax.sip.address.SipURI;
-import javax.sip.address.URI;
import javax.sip.header.*;
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;
/**
* @description:璁惧鑳藉姏鎺ュ彛锛岀敤浜庡畾涔夎澶囩殑鎺у埗銆佹煡璇㈣兘鍔�
@@ -88,7 +84,7 @@
private UserSetting userSetting;
@Autowired
- private ZLMHttpHookSubscribe subscribe;
+ private ZlmHttpHookSubscribe subscribe;
@Autowired
private SipSubscribe sipSubscribe;
@@ -351,7 +347,7 @@
*/
@Override
public void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
- ZLMHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) {
+ ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) {
String stream = ssrcInfo.getStream();
try {
if (device == null) {
@@ -640,7 +636,7 @@
hookEvent.call(new InviteStreamInfo(mediaServerItem, json, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream()));
subscribe.removeSubscribe(hookSubscribe);
hookSubscribe.getContent().put("regist", false);
- hookSubscribe.getContent().put("schema", "rtmp");
+ hookSubscribe.getContent().put("schema", "rtsp");
// 娣诲姞娴佹敞閿�鐨勮闃咃紝娉ㄩ攢浜嗗悗鍚戣澶囧彂閫乥ye
subscribe.addSubscribe(hookSubscribe,
(MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd)->{
@@ -780,15 +776,7 @@
// 澧炲姞Contact header
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
byeRequest.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
- List<String> agentParam = new ArrayList<>();
- agentParam.add("wvp-pro");
- // TODO 娣诲姞鐗堟湰淇℃伅浠ュ強鏃ユ湡
- UserAgentHeader userAgentHeader = null;
- try {
- userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
+ UserAgentHeader userAgentHeader = HeaderUtils.createUserAgentHeader(sipFactory);
byeRequest.addHeader(userAgentHeader);
ClientTransaction clientTransaction = null;
if("TCP".equals(protocol)) {
@@ -1680,14 +1668,11 @@
clientTransaction = udpSipProvider.getNewClientTransaction(request);
}
if (request.getHeader(UserAgentHeader.NAME) == null) {
- List<String> agentParam = new ArrayList<>();
- agentParam.add("wvp-pro");
- // TODO 娣诲姞鐗堟湰淇℃伅浠ュ強鏃ユ湡
UserAgentHeader userAgentHeader = null;
try {
- userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
+ userAgentHeader = HeaderUtils.createUserAgentHeader(sipFactory);
} catch (ParseException e) {
- throw new RuntimeException(e);
+ logger.error("娣诲姞UserAgentHeader澶辫触", e);
}
request.addHeader(userAgentHeader);
}
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 e767b4f..55a00a8 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
@@ -4,6 +4,8 @@
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
+import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
+import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
@@ -75,28 +77,21 @@
@Override
public boolean register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) {
- return register(parentPlatform, null, null, errorEvent, okEvent, false);
+ return register(parentPlatform, null, null, errorEvent, okEvent, false, true);
}
@Override
public boolean unregister(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) {
- ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
- parentPlatform.setExpires("0");
- if (parentPlatformCatch != null) {
- parentPlatformCatch.setParentPlatform(parentPlatform);
- redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
- }
- return register(parentPlatform, null, null, errorEvent, okEvent, false);
+ return register(parentPlatform, null, null, errorEvent, okEvent, false, false);
}
@Override
public boolean register(ParentPlatform parentPlatform, @Nullable String callId, @Nullable WWWAuthenticateHeader www,
- SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain) {
+ SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister) {
try {
Request request;
String tm = Long.toString(System.currentTimeMillis());
if (!registerAgain ) {
- // //callid
CallIdHeader callIdHeader = null;
if(parentPlatform.getTransport().equals("TCP")) {
callIdHeader = tcpSipProvider.getNewCallId();
@@ -107,10 +102,10 @@
request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform,
redisCatchStorage.getCSEQ(), "FromRegister" + tm,
- "z9hG4bK-" + UUID.randomUUID().toString().replace("-", ""), callIdHeader);
+ "z9hG4bK-" + UUID.randomUUID().toString().replace("-", ""), callIdHeader, isRegister);
// 灏� callid 鍐欏叆缂撳瓨锛� 绛夋敞鍐屾垚鍔熷彲浠ユ洿鏂扮姸鎬�
String callIdFromHeader = callIdHeader.getCallId();
- redisCatchStorage.updatePlatformRegisterInfo(callIdFromHeader, parentPlatform.getServerGBId());
+ redisCatchStorage.updatePlatformRegisterInfo(callIdFromHeader, PlatformRegisterInfo.getInstance(parentPlatform.getServerGBId(), isRegister));
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{
if (event != null) {
@@ -127,7 +122,7 @@
}else {
CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
: udpSipProvider.getNewCallId();
- request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, "FromRegister" + tm, null, callId, www, callIdHeader);
+ request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, "FromRegister" + tm, null, callId, www, callIdHeader, isRegister);
}
transmitRequest(parentPlatform, request, null, okEvent);
@@ -145,7 +140,7 @@
}
@Override
- public String keepalive(ParentPlatform parentPlatform) {
+ public String keepalive(ParentPlatform parentPlatform,SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) {
String callId = null;
try {
String characterSet = parentPlatform.getCharacterSet();
@@ -168,7 +163,7 @@
UUID.randomUUID().toString().replace("-", ""),
null,
callIdHeader);
- transmitRequest(parentPlatform, request);
+ transmitRequest(parentPlatform, request, errorEvent, okEvent);
callId = callIdHeader.getCallId();
} catch (ParseException | InvalidArgumentException | SipException e) {
e.printStackTrace();
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
index 8f3ba0a..8977d8a 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
@@ -59,6 +59,9 @@
public ServerTransaction getServerTransaction(RequestEvent evt) {
Request request = evt.getRequest();
ServerTransaction serverTransaction = evt.getServerTransaction();
+ if (serverTransaction != null) {
+ System.out.println(serverTransaction.getState().toString());
+ }
// 鍒ゆ柇TCP杩樻槸UDP
boolean isTcp = false;
ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
@@ -86,6 +89,8 @@
logger.error(e.getMessage());
} catch (TransactionUnavailableException e) {
logger.error(e.getMessage());
+ }finally {
+
}
}
return serverTransaction;
@@ -182,6 +187,10 @@
sipFactory.createAddressFactory().createSipURI(sipURI.getUser(), sipURI.getHost()+":"+sipURI.getPort()
));
response.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
+ ServerTransaction serverTransaction = getServerTransaction(evt);
+ if (serverTransaction == null) {
+
+ }
getServerTransaction(evt).sendResponse(response);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
index 6eb4bc9..2b7fec2 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
@@ -4,12 +4,14 @@
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
+import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
+import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
@@ -66,7 +68,7 @@
private IMediaServerService mediaServerService;
@Autowired
- private ZLMHttpHookSubscribe subscribe;
+ private ZlmHttpHookSubscribe subscribe;
@Autowired
private DynamicTask dynamicTask;
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 cb7faf2..cf41388 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
@@ -19,7 +19,7 @@
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
@@ -50,7 +50,6 @@
import javax.sdp.*;
import javax.sip.*;
-import javax.sip.address.SipURI;
import javax.sip.header.CallIdHeader;
import javax.sip.message.Request;
import javax.sip.message.Response;
@@ -337,7 +336,7 @@
Long finalStartTime = startTime;
Long finalStopTime = stopTime;
- ZLMHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON) -> {
+ ZlmHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON) -> {
String app = responseJSON.getString("app");
String stream = responseJSON.getString("stream");
logger.info("[涓婄骇鐐规挱]涓嬬骇宸茬粡寮�濮嬫帹娴併�� 鍥炲200OK(SDP)锛� {}/{}", app, stream);
@@ -440,6 +439,7 @@
streamId = String.format("%s_%s", device.getDeviceId(), channelId);
}
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, null, device.isSsrcCheck(), false);
+ logger.info(JSONObject.toJSONString(ssrcInfo));
sendRtpItem.setStreamId(ssrcInfo.getStream());
// 鍐欏叆redis锛� 瓒呮椂鏃跺洖澶�
redisCatchStorage.updateSendRTPSever(sendRtpItem);
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 13cc1b6..6ce2ce0 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
@@ -180,7 +180,6 @@
private void processNotifyCatalogList(RequestEvent evt, Element rootElement) throws SipException {
- System.out.println(evt.getRequest().toString());
String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
String deviceId = XmlUtil.getText(rootElement, "DeviceID");
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
index 4ea5d92..98fd7a7 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
@@ -164,7 +164,7 @@
}
}
- if (channelId.equals(sipConfig.getId())) {
+ if ("7".equals(deviceAlarm.getAlarmMethod()) ) {
// 鍙戦�佺粰骞冲彴鐨勬姤璀︿俊鎭�� 鍙戦�乺edis閫氱煡
AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage();
alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod()));
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java
index 04a11b9..1a39635 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java
@@ -6,6 +6,7 @@
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract;
+import com.genersoft.iot.vmp.gb28181.utils.HeaderUtils;
import gov.nist.javax.sip.ResponseEventExt;
import gov.nist.javax.sip.message.SIPResponse;
import gov.nist.javax.sip.stack.SIPDialog;
@@ -103,15 +104,7 @@
}
requestURI.setPort(event.getRemotePort());
reqAck.setRequestURI(requestURI);
- List<String> agentParam = new ArrayList<>();
- agentParam.add("wvp-pro");
- // TODO 娣诲姞鐗堟湰淇℃伅浠ュ強鏃ユ湡
- UserAgentHeader userAgentHeader = null;
- try {
- userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
+ UserAgentHeader userAgentHeader = HeaderUtils.createUserAgentHeader(sipFactory);
reqAck.addHeader(userAgentHeader);
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
reqAck.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
index a48dd20..a5cddae 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
@@ -6,8 +6,10 @@
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract;
+import com.genersoft.iot.vmp.service.IPlatformService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +46,9 @@
@Autowired
private SubscribeHolder subscribeHolder;
+ @Autowired
+ private IPlatformService platformService;
+
@Override
public void afterPropertiesSet() throws Exception {
// 娣诲姞娑堟伅澶勭悊鐨勮闃�
@@ -60,48 +65,39 @@
Response response = evt.getResponse();
CallIdHeader callIdHeader = (CallIdHeader) response.getHeader(CallIdHeader.NAME);
String callId = callIdHeader.getCallId();
-
- String platformGBId = redisCatchStorage.queryPlatformRegisterInfo(callId);
- if (platformGBId == null) {
- logger.info(String.format("鏈壘鍒癱allId锛� %s 鐨勬敞鍐�/娉ㄩ攢骞冲彴id", callId ));
+ PlatformRegisterInfo platformRegisterInfo = redisCatchStorage.queryPlatformRegisterInfo(callId);
+ if (platformRegisterInfo == null) {
+ logger.info(String.format("[鍥芥爣绾ц仈]鏈壘鍒癱allId锛� %s 鐨勬敞鍐�/娉ㄩ攢骞冲彴id", callId ));
return;
}
- ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformGBId);
+ ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformRegisterInfo.getPlatformId());
if (parentPlatformCatch == null) {
- logger.warn(String.format("[鏀跺埌娉ㄥ唽/娉ㄩ攢%S璇锋眰]骞冲彴锛�%s锛屼絾鏄钩鍙扮紦瀛樹俊鎭湭鏌ヨ鍒�!!!", response.getStatusCode(),platformGBId));
+ logger.warn(String.format("[鍥芥爣绾ц仈]鏀跺埌娉ㄥ唽/娉ㄩ攢%S璇锋眰锛屽钩鍙帮細%s锛屼絾鏄钩鍙扮紦瀛樹俊鎭湭鏌ヨ鍒�!!!", response.getStatusCode(),platformRegisterInfo.getPlatformId()));
return;
}
- String action = parentPlatformCatch.getParentPlatform().getExpires().equals("0") ? "娉ㄩ攢" : "娉ㄥ唽";
- logger.info(String.format("[%s %S鍝嶅簲]%s ", action, response.getStatusCode(), platformGBId ));
+
+ String action = platformRegisterInfo.isRegister() ? "娉ㄥ唽" : "娉ㄩ攢";
+ logger.info(String.format("[鍥芥爣绾ц仈]%s %S鍝嶅簲,%s ", action, response.getStatusCode(), platformRegisterInfo.getPlatformId() ));
ParentPlatform parentPlatform = parentPlatformCatch.getParentPlatform();
if (parentPlatform == null) {
- logger.warn(String.format("鏀跺埌 %s %s鐨�%S璇锋眰, 浣嗘槸骞冲彴淇℃伅鏈煡璇㈠埌!!!", platformGBId, action, response.getStatusCode()));
+ logger.warn(String.format("[鍥芥爣绾ц仈]鏀跺埌 %s %s鐨�%S璇锋眰, 浣嗘槸骞冲彴淇℃伅鏈煡璇㈠埌!!!", platformRegisterInfo.getPlatformId(), action, response.getStatusCode()));
return;
}
- if (response.getStatusCode() == 401) {
+ if (response.getStatusCode() == Response.UNAUTHORIZED) {
WWWAuthenticateHeader www = (WWWAuthenticateHeader)response.getHeader(WWWAuthenticateHeader.NAME);
- sipCommanderForPlatform.register(parentPlatform, callId, www, null, null, true);
- }else if (response.getStatusCode() == 200){
- // 娉ㄥ唽/娉ㄩ攢鎴愬姛
- logger.info(String.format("%s %s鎴愬姛", platformGBId, action));
+ sipCommanderForPlatform.register(parentPlatform, callId, www, null, null, true, platformRegisterInfo.isRegister());
+ }else if (response.getStatusCode() == Response.OK){
+
+ if (platformRegisterInfo.isRegister()) {
+ platformService.online(parentPlatform);
+ }else {
+ platformService.offline(parentPlatform);
+ }
+
+ // 娉ㄥ唽/娉ㄩ攢鎴愬姛绉婚櫎缂撳瓨鐨勪俊鎭�
redisCatchStorage.delPlatformRegisterInfo(callId);
- redisCatchStorage.delPlatformCatchInfo(platformGBId);
- // 鍙栧洖Expires璁剧疆锛岄伩鍏嶆敞閿�杩囩▼涓缃负0
- ParentPlatform parentPlatformTmp = storager.queryParentPlatByServerGBId(platformGBId);
- if (parentPlatformTmp != null) {
- parentPlatformTmp.setStatus("娉ㄥ唽".equals(action));
- redisCatchStorage.updatePlatformRegister(parentPlatformTmp);
- redisCatchStorage.updatePlatformKeepalive(parentPlatformTmp);
- parentPlatformCatch.setParentPlatform(parentPlatformTmp);
- }
- redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
- storager.updateParentPlatformStatus(platformGBId, "娉ㄥ唽".equals(action));
- if ("娉ㄩ攢".equals(action)) {
- subscribeHolder.removeCatalogSubscribe(platformGBId);
- subscribeHolder.removeMobilePositionSubscribe(platformGBId);
- }
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/HeaderUtils.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/HeaderUtils.java
new file mode 100644
index 0000000..8611267
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/HeaderUtils.java
@@ -0,0 +1,22 @@
+package com.genersoft.iot.vmp.gb28181.utils;
+
+import javax.sip.PeerUnavailableException;
+import javax.sip.SipFactory;
+import javax.sip.header.UserAgentHeader;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 鐢熸垚header鐨勫伐鍏风被
+ * @author lin
+ */
+public class HeaderUtils {
+
+ public static UserAgentHeader createUserAgentHeader(SipFactory sipFactory) throws PeerUnavailableException, ParseException {
+ List<String> agentParam = new ArrayList<>();
+ agentParam.add("WVP PRO");
+ // TODO 娣诲姞鐗堟湰淇℃伅浠ュ強鏃ユ湡
+ return sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
index 36ae1b8..2d11754 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
@@ -50,7 +50,7 @@
if (mediaServerItem == null) {
return null;
}
- if (ObjectUtils.isEmpty(mediaServerItem.getRecordAssistPort())) {
+ if (mediaServerItem.getRecordAssistPort() > 0) {
logger.warn("鏈惎鐢ˋssist鏈嶅姟");
return null;
}
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
index e3ad0bd..ac57c33 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -7,12 +7,10 @@
import com.alibaba.fastjson.JSON;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.UserSetting;
-import com.genersoft.iot.vmp.gb28181.bean.Device;
-import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
-import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
+import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.media.zlm.dto.*;
import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
@@ -20,10 +18,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -48,6 +47,9 @@
@Autowired
private SIPCommander cmder;
+
+ @Autowired
+ private SIPCommanderFroPlatform commanderFroPlatform;
@Autowired
private IPlayService playService;
@@ -77,7 +79,7 @@
private ZLMMediaListManager zlmMediaListManager;
@Autowired
- private ZLMHttpHookSubscribe subscribe;
+ private ZlmHttpHookSubscribe subscribe;
@Autowired
private UserSetting userSetting;
@@ -91,6 +93,10 @@
@Autowired
private AssistRESTfulUtils assistRESTfulUtils;
+ @Qualifier("taskExecutor")
+ @Autowired
+ private ThreadPoolTaskExecutor taskExecutor;
+
/**
* 鏈嶅姟鍣ㄥ畾鏃朵笂鎶ユ椂闂达紝涓婃姤闂撮殧鍙厤缃紝榛樿10s涓婃姤涓�娆�
*
@@ -101,9 +107,9 @@
logger.info("[ ZLM HOOK ] on_server_keepalive API璋冪敤锛屽弬鏁帮細" + json.toString());
String mediaServerId = json.getString("mediaServerId");
- List<ZLMHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive);
+ List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive);
if (subscribes != null && subscribes.size() > 0) {
- for (ZLMHttpHookSubscribe.Event subscribe : subscribes) {
+ for (ZlmHttpHookSubscribe.Event subscribe : subscribes) {
subscribe.response(null, json);
}
}
@@ -167,7 +173,7 @@
logger.debug("[ ZLM HOOK ]on_play API璋冪敤锛屽弬鏁帮細" + JSON.toJSONString(param));
}
String mediaServerId = param.getMediaServerId();
- ZLMHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json);
+ ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json);
if (subscribe != null ) {
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
if (mediaInfo != null) {
@@ -237,9 +243,11 @@
// 閴存潈閫氳繃
redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
// 閫氱煡assist鏂扮殑callId
- if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) {
- assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
- }
+ taskExecutor.execute(()->{
+ if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) {
+ assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
+ }
+ });
}else {
zlmMediaListManager.sendStreamEvent(param.getApp(),param.getStream(), param.getMediaServerId());
}
@@ -252,7 +260,7 @@
}
- ZLMHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json);
+ ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json);
if (subscribe != null) {
if (mediaInfo != null) {
subscribe.response(mediaInfo, json);
@@ -376,7 +384,7 @@
logger.debug("[ ZLM HOOK ]on_shell_login API璋冪敤锛屽弬鏁帮細" + json.toString());
}
String mediaServerId = json.getString("mediaServerId");
- ZLMHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_shell_login, json);
+ ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_shell_login, json);
if (subscribe != null ) {
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
if (mediaInfo != null) {
@@ -402,7 +410,7 @@
logger.info("[ ZLM HOOK ]on_stream_changed API璋冪敤锛屽弬鏁帮細" + JSONObject.toJSONString(item));
String mediaServerId = item.getMediaServerId();
JSONObject json = (JSONObject) JSON.toJSON(item);
- ZLMHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json);
+ ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json);
if (subscribe != null ) {
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
if (mediaInfo != null) {
@@ -415,19 +423,24 @@
String schema = item.getSchema();
List<MediaItem.MediaTrack> tracks = item.getTracks();
boolean regist = item.isRegist();
- if (regist) {
- StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
- if (streamAuthorityInfo == null) {
- streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(item);
+ if (item.getOriginType() == OriginType.RTMP_PUSH.ordinal()
+ || item.getOriginType() == OriginType.RTSP_PUSH.ordinal()
+ || item.getOriginType() == OriginType.RTC_PUSH.ordinal()) {
+ if (regist) {
+ StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
+ if (streamAuthorityInfo == null) {
+ streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(item);
+ }else {
+ streamAuthorityInfo.setOriginType(item.getOriginType());
+ streamAuthorityInfo.setOriginTypeStr(item.getOriginTypeStr());
+ }
+ redisCatchStorage.updateStreamAuthorityInfo(app, stream, streamAuthorityInfo);
}else {
- streamAuthorityInfo.setOriginType(item.getOriginType());
- streamAuthorityInfo.setOriginTypeStr(item.getOriginTypeStr());
+ redisCatchStorage.removeStreamAuthorityInfo(app, stream);
}
- redisCatchStorage.updateStreamAuthorityInfo(app, stream, streamAuthorityInfo);
- }else {
- redisCatchStorage.removeStreamAuthorityInfo(app, stream);
}
- if ("rtmp".equals(schema)){
+
+ if ("rtsp".equals(schema)){
logger.info("on_stream_changed锛氭敞鍐�->{}, app->{}, stream->{}", regist, app, stream);
if (regist) {
mediaServerService.addCount(mediaServerId);
@@ -523,17 +536,21 @@
if ("rtp".equals(app)){
ret.put("close", true);
StreamInfo streamInfoForPlayCatch = redisCatchStorage.queryPlayByStreamId(streamId);
- SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, null, streamId);
if (streamInfoForPlayCatch != null) {
- // 濡傛灉鍦ㄧ粰涓婄骇鎺ㄦ祦锛屼篃涓嶅仠姝€��
+ // 鏀跺埌鏃犱汉瑙傜湅璇存槑娴佷篃娌℃湁鍦ㄥ線涓婄骇鎺ㄩ��
if (redisCatchStorage.isChannelSendingRTP(streamInfoForPlayCatch.getChannelId())) {
- ret.put("close", false);
- } else {
- cmder.streamByeCmd(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId(),
- streamInfoForPlayCatch.getStream(), null);
- redisCatchStorage.stopPlay(streamInfoForPlayCatch);
- storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
+ List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByChnnelId(streamInfoForPlayCatch.getChannelId());
+ if (sendRtpItems.size() > 0) {
+ for (SendRtpItem sendRtpItem : sendRtpItems) {
+ ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId());
+ commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId());
+ }
+ }
}
+ cmder.streamByeCmd(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId(),
+ streamInfoForPlayCatch.getStream(), null);
+ redisCatchStorage.stopPlay(streamInfoForPlayCatch);
+ storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
}else{
StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (streamInfoForPlayBackCatch != null) {
@@ -615,9 +632,9 @@
}
String remoteAddr = request.getRemoteAddr();
jsonObject.put("ip", remoteAddr);
- List<ZLMHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started);
+ List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started);
if (subscribes != null && subscribes.size() > 0) {
- for (ZLMHttpHookSubscribe.Event subscribe : subscribes) {
+ for (ZlmHttpHookSubscribe.Event subscribe : subscribes) {
subscribe.response(null, jsonObject);
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
index a8b4a8d..50a1fa5 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
@@ -1,30 +1,24 @@
package com.genersoft.iot.vmp.media.zlm;
-import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.dto.*;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.service.IStreamPushService;
-import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.StreamPushMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
-import org.checkerframework.checker.units.qual.C;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
/**
* @author lin
@@ -59,7 +53,7 @@
private StreamPushMapper streamPushMapper;
@Autowired
- private ZLMHttpHookSubscribe subscribe;
+ private ZlmHttpHookSubscribe subscribe;
@Autowired
private UserSetting userSetting;
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 c9e2b34..65bebc9 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
@@ -92,6 +92,7 @@
int result = -1;
// 鏌ヨ姝tp server 鏄惁宸茬粡瀛樺湪
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId);
+ logger.info(JSONObject.toJSONString(rtpInfo));
if(rtpInfo.getInteger("code") == 0){
if (rtpInfo.getBoolean("exist")) {
result = rtpInfo.getInteger("local_port");
@@ -113,7 +114,7 @@
}
param.put("ssrc", ssrc);
JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param);
-
+ logger.info(JSONObject.toJSONString(openRtpServerResultJson));
if (openRtpServerResultJson != null) {
if (openRtpServerResultJson.getInteger("code") == 0) {
result= openRtpServerResultJson.getInteger("port");
@@ -277,7 +278,7 @@
* 鏌ヨ寰呰浆鎺ㄧ殑娴佹槸鍚﹀氨缁�
*/
public Boolean isRtpReady(MediaServerItem mediaServerItem, String streamId) {
- JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem,"rtp", "rtmp", streamId);
+ JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem,"rtp", "rtsp", streamId);
return (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online"));
}
@@ -297,7 +298,7 @@
* @return
*/
public int totalReaderCount(MediaServerItem mediaServerItem, String app, String streamId) {
- JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtmp", streamId);
+ JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtsp", streamId);
if (mediaInfo == null) {
return 0;
}
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
index b24d0a1..da4bb76 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
@@ -8,7 +8,6 @@
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForServerStarted;
-import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import org.slf4j.Logger;
@@ -19,9 +18,7 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
-import java.time.Instant;
import java.util.*;
-import java.util.concurrent.TimeUnit;
@Component
@Order(value=1)
@@ -35,7 +32,7 @@
private ZLMRESTfulUtils zlmresTfulUtils;
@Autowired
- private ZLMHttpHookSubscribe hookSubscribe;
+ private ZlmHttpHookSubscribe hookSubscribe;
@Autowired
private EventPublisher publisher;
@@ -62,8 +59,6 @@
}
mediaServerService.syncCatchFromDatabase();
HookSubscribeForServerStarted hookSubscribeForServerStarted = HookSubscribeFactory.on_server_started();
-// Instant expiresInstant = Instant.now().plusSeconds(TimeUnit.SECONDS.toSeconds(60));
-// hookSubscribeForStreamChange.setExpires(expiresInstant);
// 璁㈤槄 zlm鍚姩浜嬩欢, 鏂扮殑zlm涔熶細浠庤繖閲岃繘鍏ョ郴缁�
hookSubscribe.addSubscribe(hookSubscribeForServerStarted,
(MediaServerItem mediaServerItem, JSONObject response)->{
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java
similarity index 69%
rename from src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
rename to src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java
index 57b6d81..823bdab 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java
@@ -4,6 +4,9 @@
import com.genersoft.iot.vmp.media.zlm.dto.HookType;
import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@@ -13,21 +16,22 @@
import java.util.concurrent.TimeUnit;
/**
- * @description:閽堝 ZLMediaServer鐨刪ook浜嬩欢璁㈤槄
- * @author: pan
- * @date: 2020骞�12鏈�2鏃� 21:17:32
+ * ZLMediaServer鐨刪ook浜嬩欢璁㈤槄
+ * @author lin
*/
@Component
-public class ZLMHttpHookSubscribe {
+public class ZlmHttpHookSubscribe {
+
+ private final static Logger logger = LoggerFactory.getLogger(ZlmHttpHookSubscribe.class);
@FunctionalInterface
public interface Event{
void response(MediaServerItem mediaServerItem, JSONObject response);
}
- private Map<HookType, Map<IHookSubscribe, ZLMHttpHookSubscribe.Event>> allSubscribes = new ConcurrentHashMap<>();
+ private Map<HookType, Map<IHookSubscribe, ZlmHttpHookSubscribe.Event>> allSubscribes = new ConcurrentHashMap<>();
- public void addSubscribe(IHookSubscribe hookSubscribe, ZLMHttpHookSubscribe.Event event) {
+ public void addSubscribe(IHookSubscribe hookSubscribe, ZlmHttpHookSubscribe.Event event) {
if (hookSubscribe.getExpires() == null) {
// 榛樿5鍒嗛挓杩囨湡
Instant expiresInstant = Instant.now().plusSeconds(TimeUnit.MINUTES.toSeconds(5));
@@ -36,8 +40,8 @@
allSubscribes.computeIfAbsent(hookSubscribe.getHookType(), k -> new ConcurrentHashMap<>()).put(hookSubscribe, event);
}
- public ZLMHttpHookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) {
- ZLMHttpHookSubscribe.Event event= null;
+ public ZlmHttpHookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) {
+ ZlmHttpHookSubscribe.Event event= null;
Map<IHookSubscribe, Event> eventMap = allSubscribes.get(type);
if (eventMap == null) {
return null;
@@ -69,8 +73,8 @@
Set<Map.Entry<IHookSubscribe, Event>> entries = eventMap.entrySet();
if (entries.size() > 0) {
- List<Map.Entry<IHookSubscribe, ZLMHttpHookSubscribe.Event>> entriesToRemove = new ArrayList<>();
- for (Map.Entry<IHookSubscribe, ZLMHttpHookSubscribe.Event> entry : entries) {
+ List<Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event>> entriesToRemove = new ArrayList<>();
+ for (Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event> entry : entries) {
JSONObject content = entry.getKey().getContent();
if (content == null || content.size() == 0) {
entriesToRemove.add(entry);
@@ -87,13 +91,13 @@
result = result && content.getString(s).equals(hookSubscribe.getContent().getString(s));
}
}
- if (null != result && result){
+ if (result){
entriesToRemove.add(entry);
}
}
if (!CollectionUtils.isEmpty(entriesToRemove)) {
- for (Map.Entry<IHookSubscribe, ZLMHttpHookSubscribe.Event> entry : entriesToRemove) {
+ for (Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event> entry : entriesToRemove) {
entries.remove(entry);
}
}
@@ -106,12 +110,12 @@
* @param type
* @return
*/
- public List<ZLMHttpHookSubscribe.Event> getSubscribes(HookType type) {
+ public List<ZlmHttpHookSubscribe.Event> getSubscribes(HookType type) {
Map<IHookSubscribe, Event> eventMap = allSubscribes.get(type);
if (eventMap == null) {
return null;
}
- List<ZLMHttpHookSubscribe.Event> result = new ArrayList<>();
+ List<ZlmHttpHookSubscribe.Event> result = new ArrayList<>();
for (IHookSubscribe key : eventMap.keySet()) {
result.add(eventMap.get(key));
}
@@ -127,5 +131,28 @@
return result;
}
+ /**
+ * 瀵硅闃呮暟鎹繘琛岃繃鏈熸竻鐞�
+ */
+ @Scheduled(cron="0 0/5 * * * ?") //姣�5鍒嗛挓鎵ц涓�娆�
+ public void execute(){
+ logger.info("[hook璁㈤槄] 娓呯悊");
+
+ Instant instant = Instant.now().minusMillis(TimeUnit.MINUTES.toMillis(5));
+ int total = 0;
+ for (HookType hookType : allSubscribes.keySet()) {
+ Map<IHookSubscribe, Event> hookSubscribeEventMap = allSubscribes.get(hookType);
+ if (hookSubscribeEventMap.size() > 0) {
+ for (IHookSubscribe hookSubscribe : hookSubscribeEventMap.keySet()) {
+ if (hookSubscribe.getExpires().isBefore(instant)) {
+ // 杩囨湡鐨�
+ hookSubscribeEventMap.remove(hookSubscribe);
+ total ++;
+ }
+ }
+ }
+ }
+ logger.info("[hook璁㈤槄] 娓呯悊缁撴潫锛屽叡娓呯悊{}鏉¤繃鏈熸暟鎹�", total);
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java
deleted file mode 100644
index d3af23c..0000000
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.genersoft.iot.vmp.media.zlm.event;
-
-import com.alibaba.fastjson.JSONObject;
-import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener;
-import com.genersoft.iot.vmp.conf.UserSetting;
-import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
-import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
-import com.genersoft.iot.vmp.service.IMediaServerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.connection.Message;
-import org.springframework.data.redis.listener.RedisMessageListenerContainer;
-import org.springframework.stereotype.Component;
-
-/**
- * @description:璁惧蹇冭烦瓒呮椂鐩戝惉,鍊熷姪redis杩囨湡鐗规�э紝杩涜鐩戝惉锛岀洃鍚埌璇存槑璁惧蹇冭烦瓒呮椂锛屽彂閫佺绾夸簨浠�
- * @author: swwheihei
- * @date: 2020骞�5鏈�6鏃� 涓婂崍11:35:46
- */
-@Component
-public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageListener {
-
- private Logger logger = LoggerFactory.getLogger(ZLMKeepliveTimeoutListener.class);
-
- @Autowired
- private EventPublisher publisher;
-
- @Autowired
- private ZLMRESTfulUtils zlmresTfulUtils;
-
- @Autowired
- private UserSetting userSetting;
-
- @Autowired
- private IMediaServerService mediaServerService;
-
- public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
- super(listenerContainer, userSetting);
- }
-
-
- /**
- * 鐩戝惉澶辨晥鐨刱ey锛宬ey鏍煎紡涓簁eeplive_deviceId
- * @param message
- * @param pattern
- */
- @Override
- public void onMessage(Message message, byte[] pattern) {
- // 鑾峰彇澶辨晥鐨刱ey
- String expiredKey = message.toString();
- String KEEPLIVEKEY_PREFIX = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetting.getServerId() + "_";
- if(!expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){
- return;
- }
-
- String mediaServerId = expiredKey.substring(KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
- logger.info("[zlm蹇冭烦鍒版湡]锛�" + mediaServerId);
- // 鍙戣捣http璇锋眰楠岃瘉zlm鏄惁纭疄鏃犳硶杩炴帴锛屽鏋滅‘瀹炴棤娉曡繛鎺ュ垯鍙戦�佺绾夸簨浠讹紝鍚﹀垯涓嶄綔澶勭悊
- MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
- JSONObject mediaServerConfig = zlmresTfulUtils.getMediaServerConfig(mediaServerItem);
- if (mediaServerConfig != null && mediaServerConfig.getInteger("code") == 0) {
- logger.info("[zlm蹇冭烦鍒版湡]锛歿}楠岃瘉鍚巣lm浠嶅湪绾匡紝鎭㈠蹇冭烦淇℃伅", mediaServerId);
- // 娣诲姞zlm淇℃伅
- mediaServerService.updateMediaServerKeepalive(mediaServerId, mediaServerConfig);
- }else {
- publisher.zlmOfflineEventPublish(mediaServerId);
- }
- }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java
new file mode 100644
index 0000000..b5f3c5b
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java
@@ -0,0 +1,45 @@
+package com.genersoft.iot.vmp.service;
+
+import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
+import com.github.pagehelper.PageInfo;
+
+/**
+ * 鍥芥爣骞冲彴鐨勪笟鍔$被
+ * @author lin
+ */
+public interface IPlatformService {
+
+ ParentPlatform queryPlatformByServerGBId(String platformGbId);
+
+ /**
+ * 鍒嗛〉鑾峰彇涓婄骇骞冲彴
+ * @param page
+ * @param count
+ * @return
+ */
+ PageInfo<ParentPlatform> queryParentPlatformList(int page, int count);
+
+ /**
+ * 娣诲姞绾ц仈骞冲彴
+ * @param parentPlatform 绾ц仈骞冲彴
+ */
+ boolean add(ParentPlatform parentPlatform);
+
+ /**
+ * 骞冲彴涓婄嚎
+ * @param parentPlatform 骞冲彴淇℃伅
+ */
+ void online(ParentPlatform parentPlatform);
+
+ /**
+ * 骞冲彴绂荤嚎
+ * @param parentPlatform 骞冲彴淇℃伅
+ */
+ void offline(ParentPlatform parentPlatform);
+
+ /**
+ * 鍚戜笂绾у钩鍙板彂璧锋敞鍐�
+ * @param parentPlatform
+ */
+ void login(ParentPlatform parentPlatform);
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
index 027eb97..9a2bb58 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
@@ -6,7 +6,7 @@
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback;
import com.genersoft.iot.vmp.service.bean.PlayBackCallback;
@@ -14,7 +14,6 @@
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
-import org.springframework.http.ResponseEntity;
import org.springframework.web.context.request.async.DeferredResult;
/**
@@ -25,9 +24,9 @@
void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId, String uuid);
void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
- ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
+ ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
InviteTimeOutCallback timeoutCallback, String uuid);
- PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent, Runnable timeoutCallback);
+ PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent, Runnable timeoutCallback);
MediaServerItem getNewMediaServerItem(Device device);
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 867fcab..58f8741 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
@@ -11,6 +11,7 @@
import com.genersoft.iot.vmp.media.zlm.ZLMRunner;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import org.slf4j.Logger;
@@ -22,7 +23,6 @@
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@@ -42,7 +42,6 @@
import com.genersoft.iot.vmp.storager.dao.MediaServerMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import okhttp3.OkHttpClient;
import okhttp3.Request;
@@ -57,6 +56,8 @@
public class MediaServerServiceImpl implements IMediaServerService {
private final static Logger logger = LoggerFactory.getLogger(MediaServerServiceImpl.class);
+
+ private final String zlmKeepaliveKeyPrefix = "zlm-keepalive_";
@Autowired
private SipConfig sipConfig;
@@ -88,9 +89,11 @@
@Autowired
private ZLMRTPServerFactory zlmrtpServerFactory;
-
@Autowired
private EventPublisher publisher;
+
+ @Autowired
+ private DynamicTask dynamicTask;
/**
* 鍒濆鍖�
@@ -135,7 +138,7 @@
logger.info("media server [ {} ] ssrcConfig is null", mediaServerItem.getId());
return null;
}else {
- String ssrc = null;
+ String ssrc;
if (presetSsrc != null) {
ssrc = presetSsrc;
}else {
@@ -404,15 +407,43 @@
if (serverItem.isAutoConfig()) {
setZLMConfig(serverItem, "0".equals(zlmServerConfig.getHookEnable()));
}
+ final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + serverItem.getId();
+ dynamicTask.stop(zlmKeepaliveKey);
+ dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(serverItem), (serverItem.getHookAliveInterval() + 5) * 1000);
publisher.zlmOnlineEventPublish(serverItem.getId());
logger.info("[ZLM] 杩炴帴鎴愬姛 {} - {}:{} ",
zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(), zlmServerConfig.getHttpPort());
+ }
+
+ class KeepAliveTimeoutRunnable implements Runnable{
+
+ private MediaServerItem serverItem;
+
+ public KeepAliveTimeoutRunnable(MediaServerItem serverItem) {
+ this.serverItem = serverItem;
+ }
+
+ @Override
+ public void run() {
+ logger.info("[zlm蹇冭烦鍒版湡]锛�" + serverItem.getId());
+ // 鍙戣捣http璇锋眰楠岃瘉zlm鏄惁纭疄鏃犳硶杩炴帴锛屽鏋滅‘瀹炴棤娉曡繛鎺ュ垯鍙戦�佺绾夸簨浠讹紝鍚﹀垯涓嶄綔澶勭悊
+ JSONObject mediaServerConfig = zlmresTfulUtils.getMediaServerConfig(serverItem);
+ if (mediaServerConfig != null && mediaServerConfig.getInteger("code") == 0) {
+ logger.info("[zlm蹇冭烦鍒版湡]锛歿}楠岃瘉鍚巣lm浠嶅湪绾匡紝鎭㈠蹇冭烦淇℃伅,璇锋鏌lm鏄惁鍙互姝e父鍚憌vp鍙戦�佸績璺�", serverItem.getId());
+ // 娣诲姞zlm淇℃伅
+ updateMediaServerKeepalive(serverItem.getId(), mediaServerConfig);
+ }else {
+ publisher.zlmOfflineEventPublish(serverItem.getId());
+ }
+ }
}
@Override
public void zlmServerOffline(String mediaServerId) {
delete(mediaServerId);
+ final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + mediaServerId;
+ dynamicTask.stop(zlmKeepaliveKey);
}
@Override
@@ -423,7 +454,7 @@
if (RedisUtil.zScore(key, serverItem.getId()) == null) { // 涓嶅瓨鍦ㄥ垯璁剧疆榛樿鍊� 宸插瓨鍦ㄥ垯閲嶇疆
RedisUtil.zAdd(key, serverItem.getId(), 0L);
// 鏌ヨ鏈嶅姟娴佹暟閲�
- zlmresTfulUtils.getMediaList(serverItem, null, null, "rtmp",(mediaList ->{
+ zlmresTfulUtils.getMediaList(serverItem, null, null, "rtsp",(mediaList ->{
Integer code = mediaList.getInteger("code");
if (code == 0) {
JSONArray data = mediaList.getJSONArray("data");
@@ -435,7 +466,6 @@
}else {
clearRTPServer(serverItem);
}
-
}
@@ -471,7 +501,7 @@
}
// 鑾峰彇鍒嗘暟鏈�浣庣殑锛屽強骞跺彂鏈�浣庣殑
- Set<Object> objects = RedisUtil.ZRange(key, 0, -1);
+ Set<Object> objects = RedisUtil.zRange(key, 0, -1);
ArrayList<Object> mediaServerObjectS = new ArrayList<>(objects);
String mediaServerId = (String)mediaServerObjectS.get(0);
@@ -489,10 +519,7 @@
mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort());
String protocol = sslEnabled ? "https" : "http";
String hookPrex = String.format("%s://%s:%s/index/hook", protocol, mediaServerItem.getHookIp(), serverPort);
- String recordHookPrex = null;
- if (mediaServerItem.getRecordAssistPort() != 0) {
- recordHookPrex = String.format("http://127.0.0.1:%s/api/record", mediaServerItem.getRecordAssistPort());
- }
+
Map<String, Object> param = new HashMap<>();
param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline
param.put("ffmpeg.cmd","%s -fflags nobuffer -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s");
@@ -501,7 +528,6 @@
param.put("hook.on_play",String.format("%s/on_play", hookPrex));
param.put("hook.on_http_access",String.format("%s/on_http_access", hookPrex));
param.put("hook.on_publish", String.format("%s/on_publish", hookPrex));
- param.put("hook.on_record_mp4",recordHookPrex != null? String.format("%s/on_record_mp4", recordHookPrex): "");
param.put("hook.on_record_ts",String.format("%s/on_record_ts", hookPrex));
param.put("hook.on_rtsp_auth",String.format("%s/on_rtsp_auth", hookPrex));
param.put("hook.on_rtsp_realm",String.format("%s/on_rtsp_realm", hookPrex));
@@ -511,6 +537,11 @@
param.put("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrex));
param.put("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrex));
param.put("hook.on_server_keepalive",String.format("%s/on_server_keepalive", hookPrex));
+ if (mediaServerItem.getRecordAssistPort() > 0) {
+ param.put("hook.on_record_mp4",String.format("http://127.0.0.1:%s/api/record/on_record_mp4", mediaServerItem.getRecordAssistPort()));
+ }else {
+ param.put("hook.on_record_mp4","");
+ }
param.put("hook.timeoutSec","20");
param.put("general.streamNoneReaderDelayMS",mediaServerItem.getStreamNoneReaderDelayMS()==-1?"3600000":mediaServerItem.getStreamNoneReaderDelayMS() );
// 鎺ㄦ祦鏂紑鍚庡彲浠ュ湪瓒呮椂鏃堕棿鍐呴噸鏂拌繛鎺ヤ笂缁х画鎺ㄦ祦锛岃繖鏍锋挱鏀惧櫒浼氭帴鐫�鎾斁銆�
@@ -631,9 +662,9 @@
return;
}
}
- String key = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + mediaServerId;
- int hookAliveInterval = mediaServerItem.getHookAliveInterval() + 2;
- RedisUtil.set(key, data, hookAliveInterval);
+ final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + mediaServerItem.getId();
+ dynamicTask.stop(zlmKeepaliveKey);
+ dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(mediaServerItem), (mediaServerItem.getHookAliveInterval() + 5) * 1000);
}
private MediaServerItem getOneFromDatabase(String mediaServerId) {
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
index 8beff77..b63747c 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
@@ -108,6 +108,7 @@
streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam));
+ streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId));
if (mediaInfo.getHttpSSlPort() != 0) {
streamInfoResult.setHttps_flv(String.format("https://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_flv(String.format("wss://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
@@ -118,7 +119,7 @@
streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
- streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=%s%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, isPlay?"play":"push", ObjectUtils.isEmpty(callId)?"":"&callId=" + callId));
+ streamInfoResult.setRtcs(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId));
}
streamInfoResult.setTracks(tracks);
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
new file mode 100644
index 0000000..708d693
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
@@ -0,0 +1,232 @@
+package com.genersoft.iot.vmp.service.impl;
+
+import com.genersoft.iot.vmp.conf.DynamicTask;
+import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
+import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
+import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
+import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
+import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
+import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
+import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
+import com.genersoft.iot.vmp.service.IMediaServerService;
+import com.genersoft.iot.vmp.service.IPlatformService;
+import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
+import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.sip.TimeoutEvent;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author lin
+ */
+@Service
+public class PlatformServiceImpl implements IPlatformService {
+
+ private final static String REGISTER_KEY_PREFIX = "platform_register_";
+ private final static String KEEPALIVE_KEY_PREFIX = "platform_keepalive_";
+
+ private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class);
+
+ @Autowired
+ private ParentPlatformMapper platformMapper;
+
+ @Autowired
+ private IRedisCatchStorage redisCatchStorage;
+
+ @Autowired
+ private IMediaServerService mediaServerService;
+
+ @Autowired
+ private SIPCommanderFroPlatform commanderForPlatform;
+
+ @Autowired
+ private DynamicTask dynamicTask;
+
+ @Autowired
+ private ZLMRTPServerFactory zlmrtpServerFactory;
+
+ @Autowired
+ private SubscribeHolder subscribeHolder;
+
+
+
+ @Override
+ public ParentPlatform queryPlatformByServerGBId(String platformGbId) {
+ return platformMapper.getParentPlatByServerGBId(platformGbId);
+ }
+
+ @Override
+ public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count) {
+ PageHelper.startPage(page, count);
+ List<ParentPlatform> all = platformMapper.getParentPlatformList();
+ return new PageInfo<>(all);
+ }
+
+ @Override
+ public boolean add(ParentPlatform parentPlatform) {
+
+ if (parentPlatform.getCatalogGroup() == 0) {
+ // 姣忔鍙戦�佺洰褰曠殑鏁伴噺榛樿涓�1
+ parentPlatform.setCatalogGroup(1);
+ }
+ if (parentPlatform.getAdministrativeDivision() == null) {
+ // 琛屾斂鍖哄垝榛樿鍘荤紪鍙风殑鍓�6浣�
+ parentPlatform.setAdministrativeDivision(parentPlatform.getServerGBId().substring(0,6));
+ }
+ parentPlatform.setCatalogId(parentPlatform.getDeviceGBId());
+ int result = platformMapper.addParentPlatform(parentPlatform);
+ // 娣诲姞缂撳瓨
+ ParentPlatformCatch parentPlatformCatch = new ParentPlatformCatch();
+ parentPlatformCatch.setParentPlatform(parentPlatform);
+ parentPlatformCatch.setId(parentPlatform.getServerGBId());
+ parentPlatformCatch.setParentPlatform(parentPlatform);
+ redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
+ if (parentPlatform.isEnable()) {
+ // 淇濆瓨鏃跺惎鐢ㄥ氨鍙戦�佹敞鍐�
+ // 娉ㄥ唽鎴愬姛鏃剁敱绋嬪簭鐩存帴璋冪敤浜唎nline鏂规硶
+ commanderForPlatform.register(parentPlatform, eventResult -> {
+ logger.info("[鍥芥爣绾ц仈] {},娣诲姞鍚戜笂绾ф敞鍐屽け璐ワ紝璇风‘瀹氫笂绾у钩鍙板彲鐢ㄦ椂閲嶆柊淇濆瓨", parentPlatform.getServerGBId());
+ }, null);
+ }
+ return result > 0;
+ }
+
+ @Override
+ public void online(ParentPlatform parentPlatform) {
+ logger.info("[鍥芥爣绾ц仈]锛歿}, 骞冲彴涓婄嚎/鏇存柊娉ㄥ唽", parentPlatform.getServerGBId());
+ platformMapper.updateParentPlatformStatus(parentPlatform.getServerGBId(), true);
+ ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
+ if (parentPlatformCatch != null) {
+ parentPlatformCatch.getParentPlatform().setStatus(true);
+ redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
+ }else {
+ parentPlatformCatch = new ParentPlatformCatch();
+ parentPlatformCatch.setParentPlatform(parentPlatform);
+ parentPlatformCatch.setId(parentPlatform.getServerGBId());
+ parentPlatform.setStatus(true);
+ parentPlatformCatch.setParentPlatform(parentPlatform);
+ redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
+ }
+
+ final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId();
+ if (dynamicTask.contains(registerTaskKey)) {
+ dynamicTask.stop(registerTaskKey);
+ }
+ // 娣诲姞娉ㄥ唽浠诲姟
+ dynamicTask.startDelay(registerTaskKey,
+ // 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
+ ()->commanderForPlatform.register(parentPlatform, eventResult -> offline(parentPlatform),null),
+ parentPlatform.getExpires()*1000);
+
+ final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId();
+ if (!dynamicTask.contains(keepaliveTaskKey)) {
+ // 娣诲姞蹇冭烦浠诲姟
+ dynamicTask.startCron(keepaliveTaskKey,
+ ()-> commanderForPlatform.keepalive(parentPlatform, eventResult -> {
+ // 蹇冭烦澶辫触
+ if (eventResult.type == SipSubscribe.EventResultType.timeout) {
+ // 蹇冭烦瓒呮椂
+ ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
+ // 姝ゆ椂鏄涓夋蹇冭烦瓒呮椂锛� 骞冲彴绂荤嚎
+ if (platformCatch.getKeepAliveReply() == 2) {
+ // 璁剧疆骞冲彴绂荤嚎锛屽苟閲嶆柊娉ㄥ唽
+ offline(parentPlatform);
+ logger.info("[鍥芥爣绾ц仈] {}锛屼笁娆″績璺宠秴鏃跺悗鍐嶆鍙戣捣娉ㄥ唽", parentPlatform.getServerGBId());
+ commanderForPlatform.register(parentPlatform, eventResult1 -> {
+ logger.info("[鍥芥爣绾ц仈] {}锛屼笁娆″績璺宠秴鏃跺悗鍐嶆鍙戣捣娉ㄥ唽浠嶇劧澶辫触锛屽紑濮嬪畾鏃跺彂璧锋敞鍐岋紝闂撮殧涓�1鍒嗛挓", parentPlatform.getServerGBId());
+ // 娣诲姞娉ㄥ唽浠诲姟
+ dynamicTask.startCron(registerTaskKey,
+ // 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
+ ()->logger.info("[鍥芥爣绾ц仈] {},骞冲彴绂荤嚎鍚庢寔缁彂璧锋敞鍐岋紝澶辫触", parentPlatform.getServerGBId()),
+ 60*1000);
+ }, null);
+ }
+
+ }else {
+ logger.warn("[鍥芥爣绾ц仈]鍙戦�佸績璺虫敹鍒伴敊璇紝code锛� {}, msg: {}", eventResult.statusCode, eventResult.msg);
+ }
+
+ }, eventResult -> {
+ // 蹇冭烦鎴愬姛
+ // 娓呯┖涔嬪墠鐨勫績璺宠秴鏃惰鏁�
+ ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
+ if (platformCatch.getKeepAliveReply() > 0) {
+ platformCatch.setKeepAliveReply(0);
+ redisCatchStorage.updatePlatformCatchInfo(platformCatch);
+ }
+ }),
+ parentPlatform.getExpires()*1000);
+ }
+ }
+
+ @Override
+ public void offline(ParentPlatform parentPlatform) {
+ logger.info("[骞冲彴绂荤嚎]锛歿}", parentPlatform.getServerGBId());
+ ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
+ parentPlatformCatch.setKeepAliveReply(0);
+ parentPlatformCatch.setRegisterAliveReply(0);
+ ParentPlatform parentPlatformInCatch = parentPlatformCatch.getParentPlatform();
+ parentPlatformInCatch.setStatus(false);
+ parentPlatformCatch.setParentPlatform(parentPlatformInCatch);
+ redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
+ platformMapper.updateParentPlatformStatus(parentPlatform.getServerGBId(), false);
+
+ // 鍋滄鎵�鏈夋帹娴�
+ logger.info("[骞冲彴绂荤嚎] {}, 鍋滄鎵�鏈夋帹娴�", parentPlatform.getServerGBId());
+ stopAllPush(parentPlatform.getServerGBId());
+ // 娓呴櫎娉ㄥ唽瀹氭椂
+ logger.info("[骞冲彴绂荤嚎] {}, 鍋滄瀹氭椂娉ㄥ唽浠诲姟", parentPlatform.getServerGBId());
+ final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId();
+ if (dynamicTask.contains(registerTaskKey)) {
+ dynamicTask.stop(registerTaskKey);
+ }
+ // 娓呴櫎蹇冭烦瀹氭椂
+ logger.info("[骞冲彴绂荤嚎] {}, 鍋滄瀹氭椂鍙戦�佸績璺充换鍔�", parentPlatform.getServerGBId());
+ final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId();
+ if (dynamicTask.contains(keepaliveTaskKey)) {
+ // 娣诲姞蹇冭烦浠诲姟
+ dynamicTask.stop(keepaliveTaskKey);
+ }
+ // 鍋滄鐩綍璁㈤槄鍥炲
+ logger.info("[骞冲彴绂荤嚎] {}, 鍋滄璁㈤槄鍥炲", parentPlatform.getServerGBId());
+ subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
+ }
+
+ private void stopAllPush(String platformId) {
+ List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServer(platformId);
+ if (sendRtpItems != null && sendRtpItems.size() > 0) {
+ for (SendRtpItem sendRtpItem : sendRtpItems) {
+ redisCatchStorage.deleteSendRTPServer(platformId, sendRtpItem.getChannelId(), null, null);
+ MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
+ Map<String, Object> param = new HashMap<>(3);
+ param.put("vhost", "__defaultVhost__");
+ param.put("app", sendRtpItem.getApp());
+ param.put("stream", sendRtpItem.getStreamId());
+ zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
+ }
+
+ }
+ }
+
+ @Override
+ public void login(ParentPlatform parentPlatform) {
+ final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId();
+ commanderForPlatform.register(parentPlatform, eventResult1 -> {
+ logger.info("[鍥芥爣绾ц仈] {}锛屽紑濮嬪畾鏃跺彂璧锋敞鍐岋紝闂撮殧涓�1鍒嗛挓", parentPlatform.getServerGBId());
+ // 娣诲姞娉ㄥ唽浠诲姟
+ dynamicTask.startCron(registerTaskKey,
+ // 娉ㄥ唽澶辫触锛堟敞鍐屾垚鍔熸椂鐢辩▼搴忕洿鎺ヨ皟鐢ㄤ簡online鏂规硶锛�
+ ()->logger.info("[鍥芥爣绾ц仈] {},骞冲彴绂荤嚎鍚庢寔缁彂璧锋敞鍐岋紝澶辫触", parentPlatform.getServerGBId()),
+ 60*1000);
+ }, null);
+ }
+}
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 1ced19b..c64511c 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
@@ -37,7 +37,7 @@
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
@@ -128,7 +128,7 @@
private DynamicTask dynamicTask;
@Autowired
- private ZLMHttpHookSubscribe subscribe;
+ private ZlmHttpHookSubscribe subscribe;
@Qualifier("taskExecutor")
@@ -139,7 +139,7 @@
@Override
public PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId,
- ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
+ ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
Runnable timeoutCallback) {
if (mediaServerItem == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏈壘鍒板彲鐢ㄧ殑zlm");
@@ -222,6 +222,7 @@
streamId = String.format("%s_%s", device.getDeviceId(), channelId);
}
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false);
+ logger.info(JSONObject.toJSONString(ssrcInfo));
play(mediaServerItem, ssrcInfo, device, channelId, (mediaServerItemInUse, response)->{
if (hookEvent != null) {
hookEvent.response(mediaServerItem, response);
@@ -257,8 +258,8 @@
@Override
public void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
- ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
- InviteTimeOutCallback timeoutCallback, String uuid) {
+ ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
+ InviteTimeOutCallback timeoutCallback, String uuid) {
String streamId = null;
if (mediaServerItem.isRtpEnable()) {
@@ -333,7 +334,7 @@
// 鍗曠鍙fā寮弒treamId涔熸湁鍙樺寲锛岄渶瑕侀噸鏂拌缃洃鍚�
if (!mediaServerItem.isRtpEnable()) {
// 娣诲姞璁㈤槄
- HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtmp", mediaServerItem.getId());
+ HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId());
subscribe.removeSubscribe(hookSubscribe);
hookSubscribe.getContent().put("stream", String.format("%08x", Integer.parseInt(ssrcInResponse)).toUpperCase());
subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response)->{
@@ -609,7 +610,7 @@
logger.warn("鏌ヨ褰曞儚淇℃伅鏃跺彂鐜拌妭鐐瑰凡绂荤嚎");
return null;
}
- if (mediaServerItem.getRecordAssistPort() != 0) {
+ if (mediaServerItem.getRecordAssistPort() > 0) {
JSONObject jsonObject = assistRESTfulUtils.fileDuration(mediaServerItem, streamInfo.getApp(), streamInfo.getStream(), null);
if (jsonObject != null && jsonObject.getInteger("code") == 0) {
long duration = jsonObject.getLong("data");
@@ -802,7 +803,7 @@
// for (SendRtpItem sendRtpItem : sendRtpItems) {
// if (sendRtpItem.getMediaServerId().equals(mediaServerId)) {
// if (mediaListMap.get(sendRtpItem.getStreamId()) == null) {
-// ParentPlatform platform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId());
+// ParentPlatform platform = storager.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
// sipCommanderFroPlatform.streamByeCmd(platform, sendRtpItem.getCallId());
// }
// }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java
index 4d1948a..1634234 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java
@@ -4,6 +4,8 @@
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
+import com.genersoft.iot.vmp.service.IPlatformChannelService;
+import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.slf4j.Logger;
@@ -12,6 +14,9 @@
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
+
+import java.util.List;
@Component
@@ -37,8 +42,6 @@
return;
}
String gbId = alarmChannelMessage.getGbId();
- Device device = storage.queryVideoDevice(gbId);
- ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId);
DeviceAlarm deviceAlarm = new DeviceAlarm();
deviceAlarm.setCreateTime(DateUtil.getNow());
@@ -46,18 +49,29 @@
deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription());
deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn());
deviceAlarm.setAlarmPriority("1");
- deviceAlarm.setAlarmTime(DateUtil.getNow());
+ deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601());
deviceAlarm.setAlarmType("1");
deviceAlarm.setLongitude(0);
deviceAlarm.setLatitude(0);
-
- if (device != null && platform == null) {
- commander.sendAlarmMessage(device, deviceAlarm);
- }else if (device == null && platform != null){
- commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
+ if (ObjectUtils.isEmpty(gbId)) {
+ // 鍙戦�佺粰鎵�鏈夌殑涓婄骇
+ List<ParentPlatform> parentPlatforms = storage.queryEnableParentPlatformList(true);
+ if (parentPlatforms.size() > 0) {
+ for (ParentPlatform parentPlatform : parentPlatforms) {
+ commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm);
+ }
+ }
}else {
- logger.warn("鏃犳硶纭畾" + gbId + "鏄钩鍙拌繕鏄澶�");
+ Device device = storage.queryVideoDevice(gbId);
+ ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId);
+ if (device != null && platform == null) {
+ commander.sendAlarmMessage(device, deviceAlarm);
+ }else if (device == null && platform != null){
+ commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
+ }else {
+ logger.warn("鏃犳硶纭畾" + gbId + "鏄钩鍙拌繕鏄澶�");
+ }
}
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java
index 0f5f57c..ff82cd7 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java
@@ -5,12 +5,11 @@
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
-import com.genersoft.iot.vmp.media.zlm.dto.HookType;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.bean.*;
@@ -24,9 +23,6 @@
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
-import javax.sip.InvalidArgumentException;
-import javax.sip.SipException;
-import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -86,7 +82,7 @@
private ZLMMediaListManager mediaListManager;
@Autowired
- private ZLMHttpHookSubscribe subscribe;
+ private ZlmHttpHookSubscribe subscribe;
public interface PlayMsgCallback{
@@ -271,7 +267,7 @@
}, userSetting.getPlatformPlayTimeout());
// 娣诲姞璁㈤槄
- HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed(content.getApp(), content.getStream(), true, "rtmp", mediaServerItem.getId());
+ HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed(content.getApp(), content.getStream(), true, "rtsp", mediaServerItem.getId());
subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json)->{
dynamicTask.stop(taskKey);
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
index 8ab2712..0c8992e 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -295,7 +295,6 @@
if (jsonObject == null) {
return false;
}
- System.out.println(jsonObject);
if (jsonObject.getInteger("code") == 0) {
result = true;
streamProxy.setEnable(true);
@@ -421,7 +420,7 @@
if(data != null && data.size() > 0) {
for (int i = 0; i < data.size(); i++) {
JSONObject streamJSONObj = data.getJSONObject(i);
- if ("rtmp".equals(streamJSONObj.getString("schema"))) {
+ if ("rtsp".equals(streamJSONObj.getString("schema"))) {
StreamInfo streamInfo = new StreamInfo();
String app = streamJSONObj.getString("app");
String stream = streamJSONObj.getString("stream");
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 d10de48..1f467e4 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
@@ -8,6 +8,7 @@
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
+import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
import java.util.List;
import java.util.Map;
@@ -61,17 +62,13 @@
void delPlatformCatchInfo(String platformGbId);
- void updatePlatformKeepalive(ParentPlatform parentPlatform);
-
void delPlatformKeepalive(String platformGbId);
-
- void updatePlatformRegister(ParentPlatform parentPlatform);
void delPlatformRegister(String platformGbId);
- void updatePlatformRegisterInfo(String callId, String platformGbId);
+ void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo);
- String queryPlatformRegisterInfo(String callId);
+ PlatformRegisterInfo queryPlatformRegisterInfo(String callId);
void delPlatformRegisterInfo(String callId);
@@ -237,4 +234,6 @@
* 鍙戦�乺edis娑堟伅 鏌ヨ鎵�鏈夋帹娴佽澶囩殑鐘舵��
*/
void sendStreamPushRequestedMsgForStatus();
+
+ List<SendRtpItem> querySendRTPServerByChnnelId(String channelId);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
index b2c1e1b..b65cc68 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
@@ -170,15 +170,6 @@
*/
boolean deleteParentPlatform(ParentPlatform parentPlatform);
-
- /**
- * 鍒嗛〉鑾峰彇涓婄骇骞冲彴
- * @param page
- * @param count
- * @return
- */
- PageInfo<ParentPlatform> queryParentPlatformList(int page, int count);
-
/**
* 鑾峰彇鎵�鏈夊凡鍚敤鐨勫钩鍙�
* @return
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/PlatformRegisterInfo.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/PlatformRegisterInfo.java
new file mode 100644
index 0000000..16f6636
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/PlatformRegisterInfo.java
@@ -0,0 +1,41 @@
+package com.genersoft.iot.vmp.storager.dao.dto;
+
+/**
+ * 骞冲彴鍙戦�佹敞鍐�/娉ㄩ攢娑堟伅鏃剁紦瀛樻娑堟伅
+ * @author lin
+ */
+public class PlatformRegisterInfo {
+
+ /**
+ * 骞冲彴Id
+ */
+ private String platformId;
+
+ /**
+ * 鏄惁鏃舵敞鍐岋紝false涓烘敞閿�
+ */
+ private boolean register;
+
+ public static PlatformRegisterInfo getInstance(String platformId, boolean register) {
+ PlatformRegisterInfo platformRegisterInfo = new PlatformRegisterInfo();
+ platformRegisterInfo.setPlatformId(platformId);
+ platformRegisterInfo.setRegister(register);
+ return platformRegisterInfo;
+ }
+
+ public String getPlatformId() {
+ return platformId;
+ }
+
+ public void setPlatformId(String platformId) {
+ this.platformId = platformId;
+ }
+
+ public boolean isRegister() {
+ return register;
+ }
+
+ public void setRegister(boolean register) {
+ this.register = register;
+ }
+}
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 ff31c11..ecefe73 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
@@ -16,11 +16,13 @@
import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
+import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
import java.util.*;
@@ -290,18 +292,6 @@
}
@Override
- public void updatePlatformKeepalive(ParentPlatform parentPlatform) {
- String key = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + parentPlatform.getServerGBId();
- RedisUtil.set(key, "", Integer.parseInt(parentPlatform.getKeepTimeout()));
- }
-
- @Override
- public void updatePlatformRegister(ParentPlatform parentPlatform) {
- String key = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_" + parentPlatform.getServerGBId();
- RedisUtil.set(key, "", Integer.parseInt(parentPlatform.getExpires()));
- }
-
- @Override
public ParentPlatformCatch queryPlatformCatchInfo(String platformGbId) {
return (ParentPlatformCatch)RedisUtil.get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId);
}
@@ -323,15 +313,15 @@
@Override
- public void updatePlatformRegisterInfo(String callId, String platformGbId) {
+ public void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo) {
String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId;
- RedisUtil.set(key, platformGbId, 30);
+ RedisUtil.set(key, platformRegisterInfo, 30);
}
@Override
- public String queryPlatformRegisterInfo(String callId) {
- return (String)RedisUtil.get(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId);
+ public PlatformRegisterInfo queryPlatformRegisterInfo(String callId) {
+ return (PlatformRegisterInfo)RedisUtil.get(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId);
}
@Override
@@ -380,6 +370,24 @@
}
@Override
+ public List<SendRtpItem> querySendRTPServerByChnnelId(String channelId) {
+ if (channelId == null) {
+ return null;
+ }
+ String platformGbId = "*";
+ String callId = "*";
+ String streamId = "*";
+ String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId
+ + "_" + channelId + "_" + streamId + "_" + callId;
+ List<Object> scan = RedisUtil.scan(key);
+ List<SendRtpItem> result = new ArrayList<>();
+ for (Object o : scan) {
+ result.add((SendRtpItem) RedisUtil.get((String) o));
+ }
+ return result;
+ }
+
+ @Override
public List<SendRtpItem> querySendRTPServer(String platformGbId) {
if (platformGbId == null) {
platformGbId = "*";
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 0ec9dbc..e8e0e02 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
@@ -458,13 +458,6 @@
}
@Override
- public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count) {
- PageHelper.startPage(page, count);
- List<ParentPlatform> all = platformMapper.getParentPlatformList();
- return new PageInfo<>(all);
- }
-
- @Override
public ParentPlatform queryParentPlatByServerGBId(String platformGbId) {
return platformMapper.getParentPlatByServerGBId(platformGbId);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
index 494bcbb..f7e0729 100644
--- a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
+++ b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
@@ -82,4 +82,9 @@
return false;
}
}
+
+ public static String getNowForISO8601() {
+ LocalDateTime nowDateTime = LocalDateTime.now();
+ return formatterISO8601.format(nowDateTime);
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java b/src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java
index b155bcd..5323875 100644
--- a/src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java
+++ b/src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java
@@ -33,11 +33,11 @@
/**
* 鑾峰彇瀵硅薄 杩欓噷閲嶅啓浜哹ean鏂规硶锛岃捣涓昏浣滅敤
*/
- public static Object getBean(String beanId) throws BeansException {
+ public static <T> T getBean(String beanId) throws BeansException {
if (applicationContext == null) {
return null;
}
- return applicationContext.getBean(beanId);
+ return (T) applicationContext.getBean(beanId);
}
/**
diff --git a/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java
index 5ef0b39..749dddd 100644
--- a/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java
+++ b/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java
@@ -5,15 +5,14 @@
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
-import org.springframework.beans.factory.annotation.Autowired;
+import gov.nist.javax.sip.stack.UDPMessageChannel;
import org.springframework.data.redis.core.*;
-import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
/**
- * @description:Redis宸ュ叿绫�
- * @author: swwheihei
- * @date: 2020骞�5鏈�6鏃� 涓嬪崍8:27:29
+ * Redis宸ュ叿绫�
+ * @author swwheihei
+ * @date 2020骞�5鏈�6鏃� 涓嬪崍8:27:29
*/
@SuppressWarnings(value = {"rawtypes", "unchecked"})
public class RedisUtil {
@@ -21,9 +20,9 @@
private static RedisTemplate redisTemplate;
static {
- redisTemplate = (RedisTemplate)SpringBeanFactory.getBean("redisTemplate");
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
}
-
+
/**
* 鎸囧畾缂撳瓨澶辨晥鏃堕棿
* @param key 閿�
@@ -31,6 +30,9 @@
* @return true / false
*/
public static boolean expire(String key, long time) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
if (time > 0) {
redisTemplate.expire(key, time, TimeUnit.SECONDS);
@@ -45,9 +47,11 @@
/**
* 鏍规嵁 key 鑾峰彇杩囨湡鏃堕棿
* @param key 閿�
- * @return
*/
public static long getExpire(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.getExpire(key, TimeUnit.SECONDS);
}
@@ -57,6 +61,9 @@
* @return true / false
*/
public static boolean hasKey(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.hasKey(key);
} catch (Exception e) {
@@ -71,6 +78,9 @@
* @param key 閿紙涓�涓垨鑰呭涓級
*/
public static boolean del(String... key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
if (key != null && key.length > 0) {
if (key.length == 1) {
@@ -95,6 +105,9 @@
* @return 鍊�
*/
public static Object get(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return key == null ? null : redisTemplate.opsForValue().get(key);
}
@@ -105,6 +118,9 @@
* @return true / false
*/
public static boolean set(String key, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForValue().set(key, value);
return true;
@@ -122,6 +138,9 @@
* @return true / false
*/
public static boolean set(String key, Object value, long time) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
if (time > 0) {
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
@@ -142,6 +161,9 @@
* @return
*/
public static long incr(String key, long delta) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
if (delta < 0) {
throw new RuntimeException("閫掑鍥犲瓙蹇呴』澶т簬 0");
}
@@ -155,6 +177,9 @@
* @return
*/
public static long decr(String key, long delta) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
if (delta < 0) {
throw new RuntimeException("閫掑噺鍥犲瓙蹇呴』澶т簬 0");
}
@@ -170,6 +195,9 @@
* @return 鍊�
*/
public static Object hget(String key, String item) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForHash().get(key, item);
}
@@ -179,6 +207,9 @@
* @return 瀵瑰簲鐨勫涓敭鍊�
*/
public static Map<Object, Object> hmget(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForHash().entries(key);
}
@@ -189,6 +220,9 @@
* @return true / false
*/
public static boolean hmset(String key, Map<Object, Object> map) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForHash().putAll(key, map);
return true;
@@ -206,6 +240,9 @@
* @return true / false
*/
public static boolean hmset(String key, Map<Object, Object> map, long time) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForHash().putAll(key, map);
if (time > 0) {
@@ -226,6 +263,9 @@
* @return true / false
*/
public static boolean hset(String key, String item, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForHash().put(key, item, value);
return true;
@@ -244,6 +284,9 @@
* @return true / false
*/
public static boolean hset(String key, String item, Object value, long time) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForHash().put(key, item, value);
if (time > 0) {
@@ -262,6 +305,9 @@
* @param item 椤癸紙鍙互澶氫釜锛宯o null锛�
*/
public static void hdel(String key, Object... item) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
redisTemplate.opsForHash().delete(key, item);
}
@@ -272,6 +318,9 @@
* @return true / false
*/
public static boolean hHasKey(String key, String item) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForHash().hasKey(key, item);
}
@@ -283,6 +332,9 @@
* @return
*/
public static Double hincr(String key, String item, Double by) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForHash().increment(key, item, by);
}
@@ -294,6 +346,9 @@
* @return
*/
public static Double hdecr(String key, String item, Double by) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForHash().increment(key, item, -by);
}
@@ -305,6 +360,9 @@
* @return 鍊�
*/
public static Set<Object> sGet(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForSet().members(key);
} catch (Exception e) {
@@ -320,6 +378,9 @@
* @return true / false
*/
public static boolean sHasKey(String key, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForSet().isMember(key, value);
} catch (Exception e) {
@@ -335,6 +396,9 @@
* @return 鎴愬姛涓暟
*/
public static long sSet(String key, Object... values) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForSet().add(key, values);
} catch (Exception e) {
@@ -351,6 +415,9 @@
* @return 鎴愬姛鏀惧叆涓暟
*/
public static long sSet(String key, long time, Object... values) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
long count = redisTemplate.opsForSet().add(key, values);
if (time > 0) {
@@ -369,6 +436,9 @@
* @return 闀垮害
*/
public static long sGetSetSize(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForSet().size(key);
} catch (Exception e) {
@@ -384,6 +454,9 @@
* @return 鎴愬姛绉婚櫎涓暟
*/
public static long setRemove(String key, Object... values) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForSet().remove(key, values);
} catch (Exception e) {
@@ -401,6 +474,9 @@
* @param score
*/
public static void zAdd(Object key, Object value, double score) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
redisTemplate.opsForZSet().add(key, value, score);
}
@@ -411,6 +487,9 @@
* @param value
*/
public static void zRemove(Object key, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
redisTemplate.opsForZSet().remove(key, value);
}
@@ -422,6 +501,9 @@
* @param delta -1 琛ㄧず鍑� 1 琛ㄧず鍔�1
*/
public static Double zIncrScore(Object key, Object value, double delta) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForZSet().incrementScore(key, value, delta);
}
@@ -433,6 +515,9 @@
* @return
*/
public static Double zScore(Object key, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForZSet().score(key, value);
}
@@ -444,6 +529,9 @@
* @return
*/
public static Long zRank(Object key, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForZSet().rank(key, value);
}
@@ -454,6 +542,9 @@
* @return
*/
public static Long zSize(Object key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForZSet().zCard(key);
}
@@ -467,7 +558,10 @@
* @param end
* @return
*/
- public static Set<Object> ZRange(Object key, int start, int end) {
+ public static Set<Object> zRange(Object key, int start, int end) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForZSet().range(key, start, end);
}
/**
@@ -479,6 +573,9 @@
* @return
*/
public static Set<ZSetOperations.TypedTuple<String>> zRangeWithScore(Object key, int start, int end) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForZSet().rangeWithScores(key, start, end);
}
/**
@@ -492,6 +589,9 @@
* @return
*/
public static Set<String> zRevRange(Object key, int start, int end) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForZSet().reverseRange(key, start, end);
}
/**
@@ -503,6 +603,9 @@
* @return
*/
public static Set<String> zSortRange(Object key, int min, int max) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForZSet().rangeByScore(key, min, max);
}
@@ -517,6 +620,9 @@
* @return
*/
public static List<Object> lGet(String key, long start, long end) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForList().range(key, start, end);
} catch (Exception e) {
@@ -531,6 +637,9 @@
* @return 闀垮害
*/
public static long lGetListSize(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForList().size(key);
} catch (Exception e) {
@@ -548,6 +657,9 @@
* @return 鍊�
*/
public static Object lGetIndex(String key, long index) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForList().index(key, index);
} catch (Exception e) {
@@ -563,6 +675,9 @@
* @return true / false
*/
public static boolean lSet(String key, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForList().rightPush(key, value);
return true;
@@ -580,6 +695,9 @@
* @return true / false
*/
public static boolean lSet(String key, Object value, long time) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForList().rightPush(key, value);
if (time > 0) {
@@ -599,6 +717,9 @@
* @return true / false
*/
public static boolean lSetList(String key, List<Object> values) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForList().rightPushAll(key, values);
return true;
@@ -616,6 +737,9 @@
* @return true / false
*/
public static boolean lSetList(String key, List<Object> values, long time) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForList().rightPushAll(key, values);
if (time > 0) {
@@ -636,6 +760,9 @@
* @return true / false
*/
public static boolean lUpdateIndex(String key, long index, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
redisTemplate.opsForList().set(key, index, value);
return true;
@@ -655,6 +782,9 @@
* @return
*/
public static long lRemove(String key, long count, Object value) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
return redisTemplate.opsForList().remove(key, count, value);
} catch (Exception e) {
@@ -669,6 +799,9 @@
* @return
*/
public static Object lLeftPop(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForList().leftPop(key);
}
@@ -678,6 +811,9 @@
* @return
*/
public static Object lrightPop(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
return redisTemplate.opsForList().rightPop(key);
}
@@ -687,6 +823,9 @@
* @return true / false
*/
public static List<Object> keys(String key) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
try {
Set<String> set = redisTemplate.keys(key);
return new ArrayList<>(set);
@@ -727,6 +866,9 @@
* @return
*/
public static List<Object> scan(String query) {
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
Set<String> resultKeys = (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
ScanOptions scanOptions = ScanOptions.scanOptions().match("*" + query + "*").count(1000).build();
Cursor<byte[]> scan = connection.scan(scanOptions);
@@ -743,9 +885,10 @@
// ============================== 娑堟伅鍙戦�佷笌璁㈤槄 ==============================
public static void convertAndSend(String channel, JSONObject msg) {
-// redisTemplate.convertAndSend(channel, msg);
+ if (redisTemplate == null) {
+ redisTemplate = SpringBeanFactory.getBean("redisTemplate");
+ }
redisTemplate.convertAndSend(channel, msg);
-
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
index 14b7a37..bf42189 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
@@ -9,14 +9,13 @@
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
-import com.genersoft.iot.vmp.gb28181.bean.TreeType;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.service.IPlatformChannelService;
+import com.genersoft.iot.vmp.service.IPlatformService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam;
import com.github.pagehelper.PageInfo;
@@ -26,10 +25,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import com.genersoft.iot.vmp.conf.SipConfig;
@@ -70,6 +66,9 @@
@Autowired
private DynamicTask dynamicTask;
+ @Autowired
+ private IPlatformService platformService;
+
/**
* 鑾峰彇鍥芥爣鏈嶅姟鐨勯厤缃�
*
@@ -95,8 +94,7 @@
@Parameter(name = "id", description = "骞冲彴鍥芥爣缂栧彿", required = true)
@GetMapping("/info/{id}")
public ParentPlatform getPlatform(@PathVariable String id) {
- ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(id);
- WVPResult<ParentPlatform> wvpResult = new WVPResult<>();
+ ParentPlatform parentPlatform = platformService.queryPlatformByServerGBId(id);
if (parentPlatform != null) {
return parentPlatform;
} else {
@@ -117,7 +115,7 @@
@Parameter(name = "count", description = "姣忛〉鏉℃暟", required = true)
public PageInfo<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count) {
- PageInfo<ParentPlatform> parentPlatformPageInfo = storager.queryParentPlatformList(page, count);
+ PageInfo<ParentPlatform> parentPlatformPageInfo = platformService.queryParentPlatformList(page, count);
if (parentPlatformPageInfo.getList().size() > 0) {
for (ParentPlatform platform : parentPlatformPageInfo.getList()) {
platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null);
@@ -136,7 +134,7 @@
@Operation(summary = "娣诲姞涓婄骇骞冲彴淇℃伅")
@PostMapping("/add")
@ResponseBody
- public String addPlatform(@RequestBody ParentPlatform parentPlatform) {
+ public void addPlatform(@RequestBody ParentPlatform parentPlatform) {
if (logger.isDebugEnabled()) {
logger.debug("淇濆瓨涓婄骇骞冲彴淇℃伅API璋冪敤");
@@ -158,32 +156,16 @@
throw new ControllerException(ErrorCode.ERROR400.getCode(), "error severPort");
}
+
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
if (parentPlatformOld != null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "骞冲彴 " + parentPlatform.getServerGBId() + " 宸插瓨鍦�");
}
parentPlatform.setCreateTime(DateUtil.getNow());
parentPlatform.setUpdateTime(DateUtil.getNow());
- boolean updateResult = storager.updateParentPlatform(parentPlatform);
+ boolean updateResult = platformService.add(parentPlatform);
- if (updateResult) {
- // 淇濆瓨鏃跺惎鐢ㄥ氨鍙戦�佹敞鍐�
- if (parentPlatform.isEnable()) {
- if (parentPlatformOld != null && parentPlatformOld.isStatus()) {
- commanderForPlatform.unregister(parentPlatformOld, null, eventResult -> {
- // 鍙淇濆瓨灏卞彂閫佹敞鍐�
- commanderForPlatform.register(parentPlatform, null, null);
- });
- } else {
- // 鍙淇濆瓨灏卞彂閫佹敞鍐�
- commanderForPlatform.register(parentPlatform, null, null);
- }
-
- } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 鍏抽棴鍚敤鏃舵敞閿�
- commanderForPlatform.unregister(parentPlatform, null, null);
- }
- return null;
- } else {
+ if (!updateResult) {
throw new ControllerException(ErrorCode.ERROR100.getCode(),"鍐欏叆鏁版嵁搴撳け璐�");
}
}
@@ -197,7 +179,7 @@
@Operation(summary = "淇濆瓨涓婄骇骞冲彴淇℃伅")
@PostMapping("/save")
@ResponseBody
- public String savePlatform(@RequestBody ParentPlatform parentPlatform) {
+ public void savePlatform(@RequestBody ParentPlatform parentPlatform) {
if (logger.isDebugEnabled()) {
logger.debug("淇濆瓨涓婄骇骞冲彴淇℃伅API璋冪敤");
@@ -247,7 +229,6 @@
// 鍋滄璁㈤槄鐩稿叧鐨勫畾鏃朵换鍔�
subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
}
- return null;
} else {
throw new ControllerException(ErrorCode.ERROR100.getCode(),"鍐欏叆鏁版嵁搴撳け璐�");
}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
index 08b0793..2884734 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
@@ -8,24 +8,21 @@
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.VersionInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import gov.nist.javax.sip.SipStackImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
-import org.ehcache.xml.model.ThreadPoolsType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.sip.ListeningPoint;
@@ -42,7 +39,7 @@
public class ServerController {
@Autowired
- private ZLMHttpHookSubscribe zlmHttpHookSubscribe;
+ private ZlmHttpHookSubscribe zlmHttpHookSubscribe;
@Autowired
private IMediaServerService mediaServerService;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
index d8a87d7..d0aff58 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
@@ -5,6 +5,7 @@
import com.alibaba.excel.read.metadata.ReadSheet;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
@@ -17,6 +18,7 @@
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.impl.StreamPushUploadFileHandler;
import com.genersoft.iot.vmp.vmanager.bean.BatchGBStreamParam;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
@@ -95,11 +97,9 @@
@PostMapping(value = "/save_to_gb")
@ResponseBody
@Operation(summary = "灏嗘帹娴佹坊鍔犲埌鍥芥爣")
- public Object saveToGB(@RequestBody GbStream stream){
- if (streamPushService.saveToGB(stream)){
- return "success";
- }else {
- return "fail";
+ public void saveToGB(@RequestBody GbStream stream){
+ if (!streamPushService.saveToGB(stream)){
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
@@ -107,11 +107,9 @@
@DeleteMapping(value = "/remove_form_gb")
@ResponseBody
@Operation(summary = "灏嗘帹娴佺Щ鍑哄埌鍥芥爣")
- public Object removeFormGB(@RequestBody GbStream stream){
- if (streamPushService.removeFromGB(stream)){
- return "success";
- }else {
- return "fail";
+ public void removeFormGB(@RequestBody GbStream stream){
+ if (!streamPushService.removeFromGB(stream)){
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
@@ -121,25 +119,21 @@
@Operation(summary = "涓涓�涓帹娴�")
@Parameter(name = "app", description = "搴旂敤鍚�", required = true)
@Parameter(name = "stream", description = "娴乮d", required = true)
- public Object stop(String app, String streamId){
- if (streamPushService.stop(app, streamId)){
- return "success";
- }else {
- return "fail";
+ public void stop(String app, String streamId){
+ if (!streamPushService.stop(app, streamId)){
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
@DeleteMapping(value = "/batchStop")
@ResponseBody
@Operation(summary = "涓澶氫釜鎺ㄦ祦")
- public Object batchStop(@RequestBody BatchGBStreamParam batchGBStreamParam){
+ public void batchStop(@RequestBody BatchGBStreamParam batchGBStreamParam){
if (batchGBStreamParam.getGbStreams().size() == 0) {
- return "fail";
+ throw new ControllerException(ErrorCode.ERROR100);
}
- if (streamPushService.batchStop(batchGBStreamParam.getGbStreams())){
- return "success";
- }else {
- return "fail";
+ if (!streamPushService.batchStop(batchGBStreamParam.getGbStreams())){
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
@@ -249,7 +243,7 @@
@Parameter(name = "app", description = "搴旂敤鍚�", required = true)
@Parameter(name = "stream", description = "娴乮d", required = true)
@Parameter(name = "mediaServerId", description = "濯掍綋鏈嶅姟鍣╥d")
- public WVPResult<StreamInfo> getPlayUrl(@RequestParam String app,@RequestParam String stream,
+ public StreamInfo getPlayUrl(@RequestParam String app,@RequestParam String stream,
@RequestParam(required = false) String mediaServerId){
boolean authority = false;
// 鏄惁鐧婚檰鐢ㄦ埛, 鐧婚檰鐢ㄦ埛杩斿洖瀹屾暣淇℃伅
@@ -257,52 +251,38 @@
if (userInfo!= null) {
authority = true;
}
- WVPResult<StreamInfo> result = new WVPResult<>();
StreamPushItem push = streamPushService.getPush(app, stream);
if (push != null && !push.isSelf()) {
- result.setCode(-1);
- result.setMsg("鏉ヨ嚜鍏朵粬骞冲彴鐨勬帹娴佷俊鎭�");
- return result;
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏉ヨ嚜鍏朵粬骞冲彴鐨勬帹娴佷俊鎭�");
}
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
- if (streamInfo != null){
- result.setCode(0);
- result.setMsg("success");
- result.setData(streamInfo);
- }else {
- result.setCode(-1);
- result.setMsg("鑾峰彇鎾斁鍦板潃澶辫触");
+ if (streamInfo == null){
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "鑾峰彇鎾斁鍦板潃澶辫触");
}
-
- return result;
+ return streamInfo;
}
/**
- * 鑾峰彇鎺ㄦ祦鎾斁鍦板潃
+ * 娣诲姞鎺ㄦ祦淇℃伅
* @param stream 鎺ㄦ祦淇℃伅
* @return
*/
@PostMapping(value = "/add")
@ResponseBody
- @Operation(summary = "鍋滄瑙嗛鍥炴斁")
- public WVPResult<StreamInfo> add(@RequestBody StreamPushItem stream){
+ @Operation(summary = "娣诲姞鎺ㄦ祦淇℃伅")
+ public void add(@RequestBody StreamPushItem stream){
if (ObjectUtils.isEmpty(stream.getGbId())) {
-
- return new WVPResult<>(400, "鍥芥爣ID涓嶅彲涓虹┖", null);
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "鍥芥爣ID涓嶅彲涓虹┖");
}
if (ObjectUtils.isEmpty(stream.getApp()) && ObjectUtils.isEmpty(stream.getStream())) {
- return new WVPResult<>(400, "app鎴杝tream涓嶅彲涓虹┖", null);
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "app鎴杝tream涓嶅彲涓虹┖");
}
stream.setStatus(false);
stream.setPushIng(false);
stream.setAliveSecond(0L);
stream.setTotalReaderCount("0");
- boolean result = streamPushService.add(stream);
-
- if (result) {
- return new WVPResult<>(0, "success", null);
- }else {
- return new WVPResult<>(-1, "fail", null);
+ if (!streamPushService.add(stream)) {
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
}
diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml
index 6679c0d..222c076 100644
--- a/src/main/resources/all-application.yml
+++ b/src/main/resources/all-application.yml
@@ -179,8 +179,6 @@
platform-play-timeout: 60000
# 鏄惁寮�鍚帴鍙i壌鏉�
interface-authentication: true
- # 鑷姩閰嶇疆redis 鍙互杩囨湡浜嬩欢
- redis-config: true
# 鎺ュ彛閴存潈渚嬪鐨勬帴鍙�, 鍗充笉杩涜鎺ュ彛閴存潈鐨勬帴鍙�,灏介噺璇︾粏涔﹀啓锛屽敖閲忎笉鐢�/**锛岃嚦灏戜袱绾х洰褰�
interface-authentication-excludes:
- /api/v1/**
diff --git a/src/main/resources/logback-spring-local.xml b/src/main/resources/logback-spring-local.xml
index 9e58355..b9d3b39 100644
--- a/src/main/resources/logback-spring-local.xml
+++ b/src/main/resources/logback-spring-local.xml
@@ -77,25 +77,35 @@
</encoder>
</appender>
+ <!-- 鐢熸垚 SIP鏃ュ織杩藉姞 -->
+ <appender name="sipRollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <!--鍘嗗彶鏃ュ織鏂囦欢杈撳嚭鐨勬枃浠跺悕 -->
+ <FileNamePattern>${LOG_HOME}/sip-%d{yyyy-MM-dd}.%i.log</FileNamePattern>
+ <!--鏃ュ織鏂囦欢淇濈暀澶╂暟 -->
+ <MaxHistory>30</MaxHistory>
+ <maxFileSize>50MB</maxFileSize>
+ </rollingPolicy>
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <!--鏍煎紡鍖栬緭鍑猴細%d琛ㄧず鏃ユ湡锛�%thread琛ㄧず绾跨▼鍚嶏紝%-5level锛氱骇鍒粠宸︽樉绀�5涓瓧绗﹀搴�%msg锛氭棩蹇楁秷鎭紝%n鏄崲琛岀 -->
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
+ </encoder>
+ </appender>
+
<!-- 鏃ュ織杈撳嚭绾у埆 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
- <appender-ref ref="RollingFile" />
- <appender-ref ref="RollingFileError" />
</root>
-<!-- <logger name="com.genersoft.iot.vmp.storager.dao" level="INFO">-->
-<!-- <appender-ref ref="STDOUT"/>-->
-<!-- </logger>-->
-<!-- <logger name="com.genersoft.iot.vmp.gb28181" level="INFO">-->
-<!-- <appender-ref ref="STDOUT"/>-->
-<!-- </logger>-->
+ <logger name="GB28181_SIP" level="debug" additivity="true">
+ <appender-ref ref="RollingFileError"/>
+ <appender-ref ref="sipRollingFile"/>
+ </logger>
<!--璁板綍druid-sql鐨勮褰�-->
- <logger name="druid.sql.Statement" level="debug" additivity="true">
+ <logger name="com.genersoft.iot.vmp.storager.dao" level="info" additivity="true">
<!--AppenderRef ref="Console"/-->
- <!-- <appender-ref ref="RollingFile"/>-->
<appender-ref ref="RollingFileError"/>
<appender-ref ref="druidSqlRollingFile"/>
</logger>
diff --git a/web_src/src/components/CloudRecord.vue b/web_src/src/components/CloudRecord.vue
index 73f20c1..4784e05 100644
--- a/web_src/src/components/CloudRecord.vue
+++ b/web_src/src/components/CloudRecord.vue
@@ -1,7 +1,11 @@
<template>
<div id="app" style="width: 100%">
<div class="page-header">
- <div class="page-title">浜戠褰曞儚</div>
+ <div class="page-title">
+ <el-page-header v-if="recordDetail" @back="backToList" content="浜戠褰曞儚"></el-page-header>
+ <div v-if="!recordDetail">浜戠褰曞儚</div>
+ </div>
+
<div class="page-header-btn">
鑺傜偣閫夋嫨:
<el-select size="mini" @change="chooseMediaChange" style="width: 16rem; margin-right: 1rem;" v-model="mediaServerId" placeholder="璇烽�夋嫨" :disabled="recordDetail">
@@ -183,7 +187,7 @@
}).catch(function (error) {
console.log(error);
});
- }
+ },
}
diff --git a/web_src/src/components/CloudRecordDetail.vue b/web_src/src/components/CloudRecordDetail.vue
index b96b606..143448e 100644
--- a/web_src/src/components/CloudRecordDetail.vue
+++ b/web_src/src/components/CloudRecordDetail.vue
@@ -1,7 +1,9 @@
<template>
<div id="recordDetail">
<el-container>
+
<el-aside width="300px">
+
<div class="record-list-box-box">
<el-date-picker size="mini" v-model="chooseDate" :picker-options="pickerOptions" type="date" value-format="yyyy-MM-dd" placeholder="鏃ユ湡" @change="dateChange()"></el-date-picker>
<div class="record-list-box" :style="recordListStyle">
@@ -423,6 +425,9 @@
}).catch(function (error) {
console.log(error);
});
+ },
+ goBack(){
+ this.$router.push('/cloudRecord');
}
}
};
diff --git a/web_src/src/components/Login.vue b/web_src/src/components/Login.vue
index 4ebc6d1..37c8a83 100644
--- a/web_src/src/components/Login.vue
+++ b/web_src/src/components/Login.vue
@@ -66,10 +66,6 @@
//鐧诲綍璇锋眰
toLogin(){
-
- //涓�鑸璺熷悗绔簡瑙e瘑鐮佺殑鍔犲瘑瑙勫垯
- //杩欓噷渚嬪瓙鐢ㄧ殑鍝堝笇绠楁硶鏉ヨ嚜./js/sha1.min.js
-
//闇�瑕佹兂鍚庣鍙戦�佺殑鐧诲綍鍙傛暟
let loginParam = {
username: this.username,
@@ -78,12 +74,17 @@
var that = this;
//璁剧疆鍦ㄧ櫥褰曠姸鎬�
this.isLoging = true;
+ let timeoutTask = setTimeout(()=>{
+ that.$message.error("鐧诲綍瓒呮椂");
+ that.isLoging = false;
+ }, 1000)
this.$axios({
method: 'get',
url:"/api/user/login",
params: loginParam
}).then(function (res) {
+ window.clearTimeout(timeoutTask)
console.log(JSON.stringify(res));
if (res.data.code === 0 ) {
that.$cookies.set("session", {"username": that.username,"roleId":res.data.data.role.id}) ;
@@ -99,6 +100,8 @@
});
}
}).catch(function (error) {
+ console.log(error)
+ window.clearTimeout(timeoutTask)
that.$message.error(error.response.data.msg);
that.isLoging = false;
});
diff --git a/web_src/src/components/dialog/MediaServerEdit.vue b/web_src/src/components/dialog/MediaServerEdit.vue
index 7206bac..1754461 100644
--- a/web_src/src/components/dialog/MediaServerEdit.vue
+++ b/web_src/src/components/dialog/MediaServerEdit.vue
@@ -357,7 +357,7 @@
var result = false;
var that = this;
await that.$axios({
- method: 'post',
+ method: 'get',
url:`/api/platform/exit/${deviceGbId}`
}).then(function (res) {
result = res.data;
diff --git a/web_src/src/components/dialog/StreamProxyEdit.vue b/web_src/src/components/dialog/StreamProxyEdit.vue
index ac209db..936bc53 100644
--- a/web_src/src/components/dialog/StreamProxyEdit.vue
+++ b/web_src/src/components/dialog/StreamProxyEdit.vue
@@ -263,7 +263,7 @@
var result = false;
var that = this;
await that.$axios({
- method: 'post',
+ method: 'get',
url:`/api/platform/exit/${deviceGbId}`
}).then(function (res) {
result = res.data;
diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue
index 0cba21f..2d3818a 100644
--- a/web_src/src/components/dialog/devicePlayer.vue
+++ b/web_src/src/components/dialog/devicePlayer.vue
@@ -386,7 +386,7 @@
if (tab.name === "codec") {
this.$axios({
method: 'get',
- url: '/zlm/' +this.mediaServerId+ '/index/api/getMediaInfo?vhost=__defaultVhost__&schema=rtmp&app='+ this.app +'&stream='+ this.streamId
+ url: '/zlm/' +this.mediaServerId+ '/index/api/getMediaInfo?vhost=__defaultVhost__&schema=rtsp&app='+ this.app +'&stream='+ this.streamId
}).then(function (res) {
that.tracksLoading = false;
if (res.data.code == 0 && res.data.tracks) {
diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue
index d2ebb84..ef28b4c 100644
--- a/web_src/src/components/dialog/platformEdit.vue
+++ b/web_src/src/components/dialog/platformEdit.vue
@@ -268,30 +268,29 @@
}
},
saveForm: function (){
- var that = this;
- that.$axios({
+ this.$axios({
method: 'post',
url: this.saveUrl,
- data: that.platform
- }).then(function (res) {
+ data: this.platform
+ }).then((res) =>{
if (res.data.code === 0) {
- that.$message({
+ this.$message({
showClose: true,
message: "淇濆瓨鎴愬姛",
type: "success",
});
- that.showDialog = false;
- if (that.listChangeCallback != null) {
- that.listChangeCallback();
+ this.showDialog = false;
+ if (this.listChangeCallback != null) {
+ this.listChangeCallback();
}
}else {
- that.$message({
+ this.$message({
showClose: true,
message: res.data.msg,
type: "error",
});
}
- }).catch(function (error) {
+ }).catch((error)=> {
console.log(error);
});
},
@@ -328,7 +327,7 @@
var result = false;
var that = this;
await that.$axios({
- method: 'post',
+ method: 'get',
url:`/api/platform/exit/${deviceGbId}`})
.then(function (res) {
if (res.data.code === 0) {
diff --git a/web_src/src/components/dialog/pushStreamEdit.vue b/web_src/src/components/dialog/pushStreamEdit.vue
index 8c827a3..de4e7bc 100644
--- a/web_src/src/components/dialog/pushStreamEdit.vue
+++ b/web_src/src/components/dialog/pushStreamEdit.vue
@@ -158,7 +158,7 @@
var result = false;
var that = this;
await that.$axios({
- method:"post",
+ method:"get",
url:`/api/platform/exit/${deviceGbId}`
}).then(function (res) {
result = res.data;
--
Gitblit v1.8.0