diff --git a/pom.xml b/pom.xml
index 7a04892b..3336bb37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -204,6 +204,11 @@
1.12
+
+ org.springframework.session
+ spring-session-core
+
+
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 386eb1ca..da58e107 100644
--- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
+++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
@@ -14,7 +14,7 @@ public class VideoManagerConstants {
public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_";
- public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS";
+ public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS_";
public static final String MEDIA_STREAM_PREFIX = "VMP_MEDIA_STREAM";
@@ -22,14 +22,15 @@ public class VideoManagerConstants {
public static final String CACHEKEY_PREFIX = "VMP_CHANNEL_";
- public static final String KEEPLIVEKEY_PREFIX = "VMP_keeplive_";
+ public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_";
+ // 此处多了一个_,暂不修改
public static final String PLAYER_PREFIX = "VMP_PLAYER_";
-
public static final String PLAY_BLACK_PREFIX = "VMP_PLAYBACK_";
+
public static final String DOWNLOAD_PREFIX = "VMP_DOWNLOAD_";
- public static final String PLATFORM_KEEPLIVEKEY_PREFIX = "VMP_PLATFORM_KEEPLIVE_";
+ public static final String PLATFORM_KEEPALIVE_PREFIX = "VMP_PLATFORM_KEEPALIVE_";
public static final String PLATFORM_CATCH_PREFIX = "VMP_PLATFORM_CATCH_";
@@ -39,8 +40,6 @@ public class VideoManagerConstants {
public static final String PLATFORM_SEND_RTP_INFO_PREFIX = "VMP_PLATFORM_SEND_RTP_INFO_";
- public static final String Pattern_Topic = "VMP_KEEPLIVE_PLATFORM_";
-
public static final String EVENT_ONLINE_REGISTER = "1";
public static final String EVENT_ONLINE_KEEPLIVE = "2";
@@ -51,10 +50,10 @@ public class VideoManagerConstants {
public static final String EVENT_OUTLINE_TIMEOUT = "2";
- public static final String MEDIA_SSRC_USED_PREFIX = "VMP_media_used_ssrc_";
+ public static final String MEDIA_SSRC_USED_PREFIX = "VMP_MEDIA_USED_SSRC_";
- public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_media_transaction_";
+ public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_MEDIA_TRANSACTION_";
//************************** redis 消息*********************************
- public static final String WVP_MSG_STREAM_PUSH_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";
+ public static final String WVP_MSG_STREAM_CHANGE__PREFIX = "WVP_MSG_STREAM_CHANGE_";
}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
index 2d307925..4c24d14a 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
@@ -29,6 +29,8 @@ public class SipConfig {
Integer registerTimeInterval = 60;
+ private boolean alarm = false;
+
public void setIp(String ip) {
this.ip = ip;
}
@@ -104,4 +106,12 @@ public class SipConfig {
public Integer getRegisterTimeInterval() {
return registerTimeInterval;
}
+
+ public boolean isAlarm() {
+ return alarm;
+ }
+
+ public void setAlarm(boolean alarm) {
+ this.alarm = alarm;
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java b/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java
index 3e72e29e..93e2b879 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java
@@ -17,9 +17,6 @@ public class WVPTimerTask {
@Autowired
private IMediaServerService mediaServerService;
- @Autowired
- private UserSetup userSetup;
-
@Value("${server.port}")
private int serverPort;
@@ -31,6 +28,6 @@ public class WVPTimerTask {
JSONObject jsonObject = new JSONObject();
jsonObject.put("ip", sipConfig.getIp());
jsonObject.put("port", serverPort);
- redisCatchStorage.updateWVPInfo(userSetup.getServerId(), jsonObject, 3);
+ redisCatchStorage.updateWVPInfo(jsonObject, 3);
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java
index e5b57c8b..ea2fa6c2 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java
@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.event;
+import com.genersoft.iot.vmp.conf.UserSetup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -16,9 +17,12 @@ public class DeviceOffLineDetector {
@Autowired
private RedisUtil redis;
+
+ @Autowired
+ private UserSetup userSetup;
public boolean isOnline(String deviceId) {
- String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + deviceId;
+ String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + deviceId;
return redis.hasKey(key);
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
index 8363e581..d0850a8b 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.event.offline;
+import com.genersoft.iot.vmp.conf.UserSetup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +25,9 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa
@Autowired
private EventPublisher publisher;
+ @Autowired
+ private UserSetup userSetup;
+
public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer);
}
@@ -40,17 +44,20 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa
String expiredKey = message.toString();
logger.debug(expiredKey);
// 平台心跳到期,需要重发, 判断是否已经多次未收到心跳回复, 多次未收到,则重新发起注册, 注册尝试多次未得到回复,则认为平台离线
- if (expiredKey.startsWith(VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX)) {
- String platformGBId = expiredKey.substring(VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
+ String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetup.getServerId() + "_";
+ String PLATFORM_REGISTER_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetup.getServerId() + "_";
+ String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_";
+ if (expiredKey.startsWith(PLATFORM_KEEPLIVEKEY_PREFIX)) {
+ String platformGBId = expiredKey.substring(PLATFORM_KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
publisher.platformKeepaliveExpireEventPublish(platformGBId);
- }else if (expiredKey.startsWith(VideoManagerConstants.PLATFORM_REGISTER_PREFIX)) {
- String platformGBId = expiredKey.substring(VideoManagerConstants.PLATFORM_REGISTER_PREFIX.length(),expiredKey.length());
+ }else if (expiredKey.startsWith(PLATFORM_REGISTER_PREFIX)) {
+ String platformGBId = expiredKey.substring(PLATFORM_REGISTER_PREFIX.length(),expiredKey.length());
publisher.platformNotRegisterEventPublish(platformGBId);
}else{
- String deviceId = expiredKey.substring(VideoManagerConstants.KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
- publisher.outlineEventPublish(deviceId, VideoManagerConstants.EVENT_OUTLINE_TIMEOUT);
+ String deviceId = expiredKey.substring(KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
+ publisher.outlineEventPublish(deviceId, KEEPLIVEKEY_PREFIX);
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java
index db694cc2..de2b8294 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java
@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.event.offline;
+import com.genersoft.iot.vmp.conf.UserSetup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +25,9 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
@Autowired
private EventPublisher publisher;
+ @Autowired
+ private UserSetup userSetup;
+
public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer);
}
@@ -37,12 +41,13 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
public void onMessage(Message message, byte[] pattern) {
// 获取失效的key
String expiredKey = message.toString();
- if(!expiredKey.startsWith(VideoManagerConstants.KEEPLIVEKEY_PREFIX)){
- logger.debug("收到redis过期监听,但开头不是"+VideoManagerConstants.KEEPLIVEKEY_PREFIX+",忽略");
+ String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_";
+ if(!expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){
+ logger.debug("收到redis过期监听,但开头不是"+KEEPLIVEKEY_PREFIX+",忽略");
return;
}
- String deviceId = expiredKey.substring(VideoManagerConstants.KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
+ String deviceId = expiredKey.substring(KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
publisher.outlineEventPublish(deviceId, VideoManagerConstants.EVENT_OUTLINE_TIMEOUT);
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
index 4b401c76..0f5604c0 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.event.offline;
+import com.genersoft.iot.vmp.conf.UserSetup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +29,9 @@ public class OfflineEventListener implements ApplicationListener {
@Autowired
private RedisUtil redis;
+ @Autowired
+ private UserSetup userSetup;
+
@Override
public void onApplicationEvent(OfflineEvent event) {
@@ -35,7 +39,7 @@ public class OfflineEventListener implements ApplicationListener {
logger.debug("设备离线事件触发,deviceId:" + event.getDeviceId() + ",from:" + event.getFrom());
}
- String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + event.getDeviceId();
+ String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDeviceId();
switch (event.getFrom()) {
// 心跳超时触发的离线事件,说明redis中已删除,无需处理
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
index b347891b..a62c76d5 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
@@ -1,7 +1,9 @@
package com.genersoft.iot.vmp.gb28181.event.online;
import com.genersoft.iot.vmp.conf.SipConfig;
+import com.genersoft.iot.vmp.conf.UserSetup;
import com.genersoft.iot.vmp.gb28181.bean.Device;
+import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +37,9 @@ public class OnlineEventListener implements ApplicationListener {
@Autowired
private SipConfig sipConfig;
+ @Autowired
+ private UserSetup userSetup;
+
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
@@ -44,7 +49,7 @@ public class OnlineEventListener implements ApplicationListener {
logger.debug("设备上线事件触发,deviceId:" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
}
Device device = event.getDevice();
- String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + event.getDevice().getDeviceId();
+ String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDevice().getDeviceId();
switch (event.getFrom()) {
// 注册时触发的在线事件,先在redis中增加超时超时监听
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
index 20950ca2..2ab2b239 100644
--- 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
@@ -52,18 +52,18 @@ public class PlatformNotRegisterEventLister implements ApplicationListener sendRtpItems = redisCatchStorage.querySendRTPServer(event.getPlatformGbID());
- logger.info("停止[ {} ]的所有推流size", sendRtpItems.size());
+ logger.info("[ 平台未注册事件 ] 停止[ {} ]的所有推流size", sendRtpItems.size());
if (sendRtpItems != null && sendRtpItems.size() > 0) {
- logger.info("停止[ {} ]的所有推流", event.getPlatformGbID());
+ logger.info("[ 平台未注册事件 ] 停止[ {} ]的所有推流", event.getPlatformGbID());
StringBuilder app = new StringBuilder();
StringBuilder stream = new StringBuilder();
for (SendRtpItem sendRtpItem : sendRtpItems) {
@@ -91,13 +91,13 @@ public class PlatformNotRegisterEventLister implements ApplicationListener{
timer.cancel();
};
- logger.info("向平台注册,平台国标ID:" + event.getPlatformGbID());
+ logger.info("[平台注册]平台国标ID:" + event.getPlatformGbID());
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
// 设置注册失败则每隔15秒发起一次注册
timer.schedule(new TimerTask() {
@Override
public void run() {
- logger.info("再次向平台注册,平台国标ID:" + event.getPlatformGbID());
+ logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
}
}, config.getRegisterTimeInterval()* 1000, config.getRegisterTimeInterval()* 1000);//十五秒后再次发起注册
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
index ea9aa369..d41b04da 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
@@ -7,6 +7,7 @@ import javax.sip.ClientTransaction;
import javax.sip.Dialog;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
+import com.genersoft.iot.vmp.conf.UserSetup;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.utils.SerializeUtils;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
@@ -25,6 +26,9 @@ public class VideoStreamSessionManager {
@Autowired
private RedisUtil redisUtil;
+ @Autowired
+ private UserSetup userSetup;
+
public void put(String deviceId, String channelId ,String ssrc, String streamId, String mediaServerId, ClientTransaction transaction){
SsrcTransaction ssrcTransaction = new SsrcTransaction();
ssrcTransaction.setDeviceId(deviceId);
@@ -35,7 +39,7 @@ public class VideoStreamSessionManager {
ssrcTransaction.setSsrc(ssrc);
ssrcTransaction.setMediaServerId(mediaServerId);
- redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + deviceId + "_" + channelId, ssrcTransaction);
+ redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId, ssrcTransaction);
}
public void put(String deviceId, String channelId , Dialog dialog){
@@ -44,7 +48,7 @@ public class VideoStreamSessionManager {
byte[] dialogByteArray = SerializeUtils.serialize(dialog);
ssrcTransaction.setDialog(dialogByteArray);
}
- redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + deviceId + "_" + channelId, ssrcTransaction);
+ redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId, ssrcTransaction);
}
@@ -66,7 +70,7 @@ public class VideoStreamSessionManager {
}
public SsrcTransaction getSsrcTransaction(String deviceId, String channelId){
- SsrcTransaction ssrcTransaction = (SsrcTransaction)redisUtil.get(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + deviceId + "_" + channelId);
+ SsrcTransaction ssrcTransaction = (SsrcTransaction)redisUtil.get(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId);
return ssrcTransaction;
}
@@ -90,11 +94,11 @@ public class VideoStreamSessionManager {
public void remove(String deviceId, String channelId) {
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId);
if (ssrcTransaction == null) return;
- redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + deviceId + "_" + channelId);
+ redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId);
}
public List getAllSsrc() {
- List