Explorar o código

支持国标移动位置订阅,收到新位置发送redis消息;支持通道redis消息拉起第三方推流;云台控制添加ControlPriority字段;处理sql的bug

648540858 %!s(int64=3) %!d(string=hai) anos
pai
achega
7e755f405d
Modificáronse 92 ficheiros con 1460 adicións e 1068 borrados
  1. 8 0
      sql/update.sql
  2. 17 1
      src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
  3. 2 2
      src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java
  4. 7 2
      src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
  5. 1 1
      src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
  6. 4 5
      src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java
  7. 2 3
      src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
  8. 14 2
      src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java
  9. 5 4
      src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java
  10. 4 4
      src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
  11. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java
  12. 39 1
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
  13. 8 0
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java
  14. 6 6
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java
  15. 6 6
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java
  16. 3 3
      src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java
  17. 18 23
      src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
  18. 6 9
      src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java
  19. 5 8
      src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
  20. 6 6
      src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
  21. 2 3
      src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java
  22. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java
  23. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java
  24. 5 5
      src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java
  25. 5 8
      src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
  26. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
  27. 9 9
      src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
  28. 15 17
      src/main/java/com/genersoft/iot/vmp/gb28181/task/GPSSubscribeTask.java
  29. 1 3
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
  30. 15 14
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  31. 0 1
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
  32. 16 5
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
  33. 145 74
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
  34. 29 11
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
  35. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
  36. 16 9
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
  37. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java
  38. 2 3
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java
  39. 5 5
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
  40. 7 22
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java
  41. 2 4
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
  42. 5 5
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java
  43. 2 8
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java
  44. 2 3
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java
  45. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java
  46. 2 4
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java
  47. 5 8
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
  48. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java
  49. 5 5
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java
  50. 2 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java
  51. 14 11
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
  52. 26 9
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
  53. 6 0
      src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java
  54. 5 6
      src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java
  55. 13 0
      src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
  56. 2 2
      src/main/java/com/genersoft/iot/vmp/service/StreamGPSSubscribeTask.java
  57. 3 1
      src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java
  58. 112 0
      src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java
  59. 38 0
      src/main/java/com/genersoft/iot/vmp/service/bean/MobilePositionSubscribeTask.java
  60. 38 5
      src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
  61. 27 32
      src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
  62. 2 3
      src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
  63. 8 8
      src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
  64. 1 1
      src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java
  65. 6 9
      src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
  66. 4 8
      src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
  67. 4 0
      src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
  68. 482 481
      src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
  69. 4 1
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
  70. 9 0
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
  71. 83 71
      src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
  72. 10 15
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  73. 6 6
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
  74. 2 4
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java
  75. 2 4
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java
  76. 29 3
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
  77. 2 2
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java
  78. 2 3
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java
  79. 6 7
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
  80. 2 4
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
  81. 2 7
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java
  82. 2 4
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java
  83. 2 5
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java
  84. 3 4
      src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
  85. 4 4
      src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
  86. 2 2
      src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
  87. 2 2
      src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
  88. 5 6
      src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
  89. 2 0
      src/main/resources/all-application.yml
  90. 6 6
      src/main/resources/logback-spring-local.xml
  91. 2 2
      web_src/src/components/ParentPlatformList.vue
  92. 6 0
      web_src/src/components/dialog/deviceEdit.vue

+ 8 - 0
sql/update.sql

@@ -0,0 +1,8 @@
+alter table device
+    add subscribeCycleForMobilePosition int null;
+
+alter table device
+    add mobilePositionSubmissionInterval int default 5 null;
+
+alter table device
+    add subscribeCycleForAlarm int null;

+ 17 - 1
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java

@@ -70,8 +70,24 @@ public class VideoManagerConstants {
 	public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_";
 
 	//************************** redis 消息*********************************
+
+	// 流变化的通知
 	public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";
-	public static final String WVP_MSG_GPS_PREFIX = "VM_MSG_GPS";
+
+	// 接收推流设备的GPS变化通知
+	public static final String VM_MSG_GPS = "VM_MSG_GPS";
+
+	// redis 消息通知设备推流到平台
+	public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED";
+
+	// 移动位置订阅通知
+	public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition";
+
+	// 报警订阅的通知
+	public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm";
+
+	// 设备状态订阅的通知
+	public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device";
 
 	//**************************    第三方  ****************************************
 	public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java

@@ -29,7 +29,7 @@ public class ApiAccessFilter extends OncePerRequestFilter {
     private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private ILogService logService;
@@ -48,7 +48,7 @@ public class ApiAccessFilter extends OncePerRequestFilter {
 
         filterChain.doFilter(servletRequest, servletResponse);
 
-        if (uriName != null && userSetup.getLogInDatebase()) {
+        if (uriName != null && userSetting.getLogInDatebase()) {
 
             LogDto logDto = new LogDto();
             logDto.setName(uriName);

+ 7 - 2
src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java

@@ -7,6 +7,7 @@ import org.springframework.stereotype.Component;
 
 import java.util.Date;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledFuture;
 
@@ -45,12 +46,12 @@ public class DynamicTask {
      * 延时任务
      * @param key 任务ID
      * @param task 任务
-     * @param delay 延时 /秒
+     * @param delay 延时 /
      * @return
      */
     public String startDelay(String key, Runnable task, int delay) {
         stop(key);
-        Date starTime = new Date(System.currentTimeMillis() + delay * 1000);
+        Date starTime = new Date(System.currentTimeMillis() + delay);
         // scheduleWithFixedDelay 必须等待上一个任务结束才开始计时period, cycleForCatalog表示执行的间隔
         ScheduledFuture future = threadPoolTaskScheduler.schedule(task, starTime);
         futureMap.put(key, future);
@@ -67,4 +68,8 @@ public class DynamicTask {
         return futureMap.get(key) != null;
     }
 
+    public Set<String> getAllKeys() {
+        return futureMap.keySet();
+    }
+
 }

+ 1 - 1
src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java

@@ -92,7 +92,7 @@ public class RedisConfig extends CachingConfigurerSupport {
 
         RedisMessageListenerContainer container = new RedisMessageListenerContainer();
         container.setConnectionFactory(connectionFactory);
-		container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.WVP_MSG_GPS_PREFIX));
+		container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_GPS));
         return container;
     }
 

+ 4 - 5
src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java

@@ -3,25 +3,24 @@ 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 org.springframework.util.StringUtils;
 
 import java.util.Properties;
 
 public class RedisKeyExpirationEventMessageListener extends KeyExpirationEventMessageListener {
 
-    private UserSetup userSetup;
+    private UserSetting userSetting;
     private RedisMessageListenerContainer listenerContainer;
     private String keyspaceNotificationsConfigParameter = "EA";
 
-    public RedisKeyExpirationEventMessageListener(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) {
+    public RedisKeyExpirationEventMessageListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
         super(listenerContainer);
         this.listenerContainer = listenerContainer;
-        this.userSetup = userSetup;
+        this.userSetting = userSetting;
     }
 
     @Override
     public void init() {
-        if (!userSetup.getRedisConfig()) {
+        if (!userSetting.getRedisConfig()) {
             // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用
             setKeyspaceNotificationsConfigParameter("");
         }else {

+ 2 - 3
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java

@@ -4,9 +4,8 @@ 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.transmit.cmd.ISIPCommanderForPlatform;
-import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.core.annotation.Order;
@@ -22,7 +21,7 @@ import java.util.List;
 public class SipPlatformRunner implements CommandLineRunner {
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;

+ 14 - 2
src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java

@@ -6,10 +6,12 @@ import org.springframework.stereotype.Component;
 import java.util.ArrayList;
 import java.util.List;
 
-
+/**
+ * 配置文件 user-settings 映射的配置信息
+ */
 @Component
 @ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true)
-public class UserSetup {
+public class UserSetting {
 
     private Boolean savePositionHistory = Boolean.FALSE;
 
@@ -19,6 +21,8 @@ public class UserSetup {
 
     private Long playTimeout = 18000L;
 
+    private int platformPlayTimeout = 60000;
+
     private Boolean interfaceAuthentication = Boolean.TRUE;
 
     private Boolean recordPushLive = Boolean.TRUE;
@@ -134,4 +138,12 @@ public class UserSetup {
     public void setRecordSip(Boolean recordSip) {
         this.recordSip = recordSip;
     }
+
+    public int getPlatformPlayTimeout() {
+        return platformPlayTimeout;
+    }
+
+    public void setPlatformPlayTimeout(int platformPlayTimeout) {
+        this.platformPlayTimeout = platformPlayTimeout;
+    }
 }

+ 5 - 4
src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java

@@ -1,10 +1,10 @@
 package com.genersoft.iot.vmp.conf.runner;
 
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.service.IDeviceService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.core.annotation.Order;
@@ -21,13 +21,13 @@ import java.util.List;
 public class SipDeviceRunner implements CommandLineRunner {
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private IDeviceService deviceService;
@@ -44,6 +44,7 @@ public class SipDeviceRunner implements CommandLineRunner {
             if (device != null && device.getSubscribeCycleForCatalog() > 0) {
                 // 查询在线设备那些开启了订阅,为设备开启定时的目录订阅
                 deviceService.addCatalogSubscribe(device);
+                deviceService.addMobilePositionSubscribe(device);
             }
         }
         // 重置cseq计数

+ 4 - 4
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java

@@ -1,6 +1,6 @@
 package com.genersoft.iot.vmp.conf.security;
 
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +29,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     private final static Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class);
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private DefaultUserDetailsServiceImpl userDetailsService;
@@ -77,7 +77,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
     @Override
     public void configure(WebSecurity web) {
 
-        if (!userSetup.isInterfaceAuthentication()) {
+        if (!userSetting.isInterfaceAuthentication()) {
             web.ignoring().antMatchers("**");
         }else {
             // 可以直接访问的静态数据
@@ -91,7 +91,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                     .antMatchers("/swagger-resources/**")
                     .antMatchers("/v3/api-docs/**")
                     .antMatchers("/js/**");
-            List<String> interfaceAuthenticationExcludes = userSetup.getInterfaceAuthenticationExcludes();
+            List<String> interfaceAuthenticationExcludes = userSetting.getInterfaceAuthenticationExcludes();
             for (String interfaceAuthenticationExclude : interfaceAuthenticationExcludes) {
                 if (interfaceAuthenticationExclude.split("/").length < 4 ) {
                     logger.warn("{}不满足两级目录,已忽略", interfaceAuthenticationExclude);

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java

@@ -1,6 +1,6 @@
 package com.genersoft.iot.vmp.gb28181.auth;
 
-import com.genersoft.iot.vmp.storager.impl.VideoManagerStoragerImpl;
+import com.genersoft.iot.vmp.storager.impl.VideoManagerStorageImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,7 +23,7 @@ public class RegisterLogicHandler {
 	private SIPCommander cmder;
 
 	@Autowired
-	private VideoManagerStoragerImpl storager;
+	private VideoManagerStorageImpl storager;
 	
 	public void onRegister(Device device) {
 		// 只有第一次注册时调用查询设备信息,如需更新调用更新API接口

+ 39 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java

@@ -112,8 +112,22 @@ public class Device {
 	/**
 	 * 目录订阅周期,0为不订阅
 	 */
-	private int subscribeCycleForCatalog ;
+	private int subscribeCycleForCatalog;
 
+	/**
+	 * 移动设备位置订阅周期,0为不订阅
+	 */
+	private int subscribeCycleForMobilePosition;
+
+	/**
+	 * 移动设备位置信息上报时间间隔,单位:秒,默认值5
+	 */
+	private int mobilePositionSubmissionInterval = 5;
+
+	/**
+	 * 报警订阅周期,0为不订阅
+	 */
+	private int subscribeCycleForAlarm;
 
 
 	public String getDeviceId() {
@@ -283,4 +297,28 @@ public class Device {
 	public void setSubscribeCycleForCatalog(int subscribeCycleForCatalog) {
 		this.subscribeCycleForCatalog = subscribeCycleForCatalog;
 	}
+
+	public int getSubscribeCycleForMobilePosition() {
+		return subscribeCycleForMobilePosition;
+	}
+
+	public void setSubscribeCycleForMobilePosition(int subscribeCycleForMobilePosition) {
+		this.subscribeCycleForMobilePosition = subscribeCycleForMobilePosition;
+	}
+
+	public int getMobilePositionSubmissionInterval() {
+		return mobilePositionSubmissionInterval;
+	}
+
+	public void setMobilePositionSubmissionInterval(int mobilePositionSubmissionInterval) {
+		this.mobilePositionSubmissionInterval = mobilePositionSubmissionInterval;
+	}
+
+	public int getSubscribeCycleForAlarm() {
+		return subscribeCycleForAlarm;
+	}
+
+	public void setSubscribeCycleForAlarm(int subscribeCycleForAlarm) {
+		this.subscribeCycleForAlarm = subscribeCycleForAlarm;
+	}
 }

+ 8 - 0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java

@@ -0,0 +1,8 @@
+package com.genersoft.iot.vmp.gb28181.bean;
+
+public enum InviteStreamType {
+
+    PLAY,PLAYBACK,PUSH,PROXY,CLOUD_RECORD_PUSH,CLOUD_RECORD_PROXY
+
+
+}

+ 6 - 6
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java

@@ -125,9 +125,9 @@ public class ParentPlatform {
     private boolean alarmSubscribe;
 
     /**
-     * 已被订阅GPS信息
+     * 已被订阅移动位置信息
      */
-    private boolean gpsSubscribe;
+    private boolean mobilePositionSubscribe;
 
     public Integer getId() {
         return id;
@@ -322,11 +322,11 @@ public class ParentPlatform {
         this.alarmSubscribe = alarmSubscribe;
     }
 
-    public boolean isGpsSubscribe() {
-        return gpsSubscribe;
+    public boolean isMobilePositionSubscribe() {
+        return mobilePositionSubscribe;
     }
 
-    public void setGpsSubscribe(boolean gpsSubscribe) {
-        this.gpsSubscribe = gpsSubscribe;
+    public void setMobilePositionSubscribe(boolean mobilePositionSubscribe) {
+        this.mobilePositionSubscribe = mobilePositionSubscribe;
     }
 }

+ 6 - 6
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java

@@ -77,9 +77,9 @@ public class SendRtpItem {
     private String CallId;
 
     /**
-     * 是否是play, false是playback
+     * 播放类型
      */
-    private boolean isPlay;
+    private InviteStreamType playType;
 
     private byte[] transaction;
 
@@ -197,12 +197,12 @@ public class SendRtpItem {
         CallId = callId;
     }
 
-    public boolean isPlay() {
-        return isPlay;
+    public InviteStreamType getPlayType() {
+        return playType;
     }
 
-    public void setPlay(boolean play) {
-        isPlay = play;
+    public void setPlayType(InviteStreamType playType) {
+        this.playType = playType;
     }
 
     public byte[] getTransaction() {

+ 3 - 3
src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java

@@ -1,6 +1,6 @@
 package com.genersoft.iot.vmp.gb28181.event;
 
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -19,10 +19,10 @@ public class DeviceOffLineDetector {
     private RedisUtil redis;
 
 	@Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 	
 	public boolean isOnline(String deviceId) {
-		String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + deviceId;
+		String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + deviceId;
 		return redis.hasKey(key);
 	}
 }

+ 18 - 23
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java

@@ -1,27 +1,20 @@
 package com.genersoft.iot.vmp.gb28181.event.offline;
 
 import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.DependsOn;
 import org.springframework.data.redis.connection.Message;
-import org.springframework.data.redis.connection.RedisConnection;
-import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
 import org.springframework.stereotype.Component;
 
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
-import org.springframework.util.StringUtils;
-
-import java.util.Properties;
 
 /**    
  * @description:设备心跳超时监听,借助redis过期特性,进行监听,监听到说明设备心跳超时,发送离线事件
@@ -37,16 +30,16 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent
 	private EventPublisher publisher;
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
 	@Autowired
 	private SipSubscribe sipSubscribe;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
-    public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) {
-        super(listenerContainer, userSetup);
+    public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
+        super(listenerContainer, userSetting);
     }
 
 
@@ -61,10 +54,10 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent
         String expiredKey = message.toString();
         logger.debug(expiredKey);
         // 平台心跳到期,需要重发, 判断是否已经多次未收到心跳回复, 多次未收到,则重新发起注册, 注册尝试多次未得到回复,则认为平台离线
-        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() + "_";
-        String REGISTER_INFO_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_";
+        String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_";
+        String PLATFORM_REGISTER_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_";
+        String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_";
+        String REGISTER_INFO_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_";
         if (expiredKey.startsWith(PLATFORM_KEEPLIVEKEY_PREFIX)) {
             String platformGBId = expiredKey.substring(PLATFORM_KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
             ParentPlatform platform = storager.queryParentPlatByServerGBId(platformGBId);
@@ -84,12 +77,14 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent
                 publisher.outlineEventPublish(deviceId, KEEPLIVEKEY_PREFIX);
             }
         }else if (expiredKey.startsWith(REGISTER_INFO_PREFIX)) {
-            String callid = expiredKey.substring(REGISTER_INFO_PREFIX.length());
-            SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult();
-            eventResult.callId = callid;
-            eventResult.msg = "注册超时";
-            eventResult.type = "register timeout";
-            sipSubscribe.getErrorSubscribe(callid).response(eventResult);
+            String callId = expiredKey.substring(REGISTER_INFO_PREFIX.length());
+            if (sipSubscribe.getErrorSubscribe(callId) != null) {
+                SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult();
+                eventResult.callId = callId;
+                eventResult.msg = "注册超时";
+                eventResult.type = "register timeout";
+                sipSubscribe.getErrorSubscribe(callId).response(eventResult);
+            }
         }
 
     }

+ 6 - 9
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java

@@ -1,14 +1,11 @@
 package com.genersoft.iot.vmp.gb28181.event.offline;
 
 import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.DependsOn;
-import org.springframework.context.annotation.Lazy;
 import org.springframework.data.redis.connection.Message;
-import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
 import org.springframework.stereotype.Component;
 
@@ -29,15 +26,15 @@ public class KeepliveTimeoutListener extends RedisKeyExpirationEventMessageListe
 	private EventPublisher publisher;
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
-    public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) {
-        super(listenerContainer, userSetup);
+    public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
+        super(listenerContainer, userSetting);
     }
 
     @Override
     public void init() {
-        if (!userSetup.getRedisConfig()) {
+        if (!userSetting.getRedisConfig()) {
             // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用
             setKeyspaceNotificationsConfigParameter("");
         }
@@ -54,7 +51,7 @@ public class KeepliveTimeoutListener extends RedisKeyExpirationEventMessageListe
     public void onMessage(Message message, byte[] pattern) {
         //  获取失效的key
         String expiredKey = message.toString();
-        String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_";
+        String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_";
         if(!expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){
         	logger.debug("收到redis过期监听,但开头不是"+KEEPLIVEKEY_PREFIX+",忽略");
         	return;

+ 5 - 8
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java

@@ -1,24 +1,21 @@
 package com.genersoft.iot.vmp.gb28181.event.offline;
 
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
 import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
 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 org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationListener;
-import org.springframework.context.annotation.DependsOn;
-import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Component;
 
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.redis.RedisUtil;
 
 import java.util.List;
@@ -36,7 +33,7 @@ public class OfflineEventListener implements ApplicationListener<OfflineEvent> {
 	private final static Logger logger = LoggerFactory.getLogger(OfflineEventListener.class);
 	
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private VideoStreamSessionManager streamSession;
@@ -45,7 +42,7 @@ public class OfflineEventListener implements ApplicationListener<OfflineEvent> {
     private RedisUtil redis;
 
 	@Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
 	@Autowired
     private EventPublisher eventPublisher;
@@ -65,7 +62,7 @@ public class OfflineEventListener implements ApplicationListener<OfflineEvent> {
 			logger.debug("设备离线事件触发,deviceId:" + event.getDeviceId() + ",from:" + event.getFrom());
 		}
 
-		String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDeviceId();
+		String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDeviceId();
 
 		switch (event.getFrom()) {
 			// 心跳超时触发的离线事件,说明redis中已删除,无需处理

+ 6 - 6
src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java

@@ -1,14 +1,13 @@
 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.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.service.IDeviceService;
-import com.genersoft.iot.vmp.storager.dao.dto.User;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,7 +15,7 @@ import org.springframework.context.ApplicationListener;
 import org.springframework.stereotype.Component;
 
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.redis.RedisUtil;
 
 import java.text.SimpleDateFormat;
@@ -35,7 +34,7 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
 	private final static Logger logger = LoggerFactory.getLogger(OnlineEventListener.class);
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private IDeviceService deviceService;
@@ -47,7 +46,7 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
     private SipConfig sipConfig;
 
 	@Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
 	@Autowired
     private EventPublisher eventPublisher;
@@ -65,7 +64,7 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
 		}
 		Device device = event.getDevice();
 		if (device == null) return;
-		String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDevice().getDeviceId();
+		String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId();
 		Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
 		device.setOnline(1);
 		switch (event.getFrom()) {
@@ -103,6 +102,7 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
 		// 上线添加订阅
 		if (device.getSubscribeCycleForCatalog() > 0) {
 			deviceService.addCatalogSubscribe(device);
+			deviceService.addMobilePositionSubscribe(device);
 		}
 	}
 }

+ 2 - 3
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java

@@ -6,7 +6,7 @@ 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.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationListener;
 import org.springframework.stereotype.Component;
 
-import javax.sip.ResponseEvent;
 import javax.sip.message.Response;
 
 /**
@@ -29,7 +28,7 @@ public class PlatformKeepaliveExpireEventLister implements ApplicationListener<P
     private final static Logger logger = LoggerFactory.getLogger(PlatformKeepaliveExpireEventLister.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java

@@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
 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.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,7 +19,7 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla
     private final static Logger logger = LoggerFactory.getLogger(PlatformCycleRegisterEventLister.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
     @Autowired
     private ISIPCommanderForPlatform sipCommanderFroPlatform;
 

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java

@@ -9,7 +9,7 @@ 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.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,7 +31,7 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf
     private final static Logger logger = LoggerFactory.getLogger(PlatformNotRegisterEventLister.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
     @Autowired
     private IRedisCatchStorage redisCatchStorage;
     @Autowired

+ 5 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java

@@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.gb28181.event.subscribe;
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,13 +20,13 @@ public class SubscribeListenerForPlatform extends RedisKeyExpirationEventMessage
     private Logger logger = LoggerFactory.getLogger(SubscribeListenerForPlatform.class);
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
     @Autowired
     private DynamicTask dynamicTask;
 
-    public SubscribeListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) {
-        super(listenerContainer, userSetup);
+    public SubscribeListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
+        super(listenerContainer, userSetting);
     }
 
 
@@ -41,7 +41,7 @@ public class SubscribeListenerForPlatform extends RedisKeyExpirationEventMessage
         String expiredKey = message.toString();
         logger.debug(expiredKey);
         // 订阅到期
-        String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_";
+        String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_";
         if (expiredKey.startsWith(PLATFORM_KEEPLIVEKEY_PREFIX)) {
             // 取消定时任务
             dynamicTask.stop(expiredKey);

+ 5 - 8
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java

@@ -2,17 +2,14 @@ package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog;
 
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
-import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
-import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformNotRegisterEvent;
 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.IGbStreamService;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,7 +28,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
     private final static Logger logger = LoggerFactory.getLogger(CatalogEventLister.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
     @Autowired
     private IRedisCatchStorage redisCatchStorage;
     @Autowired
@@ -47,7 +44,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
     private SipConfig config;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private IGbStreamService gbStreamService;
@@ -64,7 +61,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
         if (event.getPlatformId() != null) {
             parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
             if (parentPlatform != null && !parentPlatform.isStatus())return;
-            String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() +  "_Catalog_" + event.getPlatformId();
+            String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() +  "_Catalog_" + event.getPlatformId();
 //            subscribe = redisCatchStorage.getSubscribe(key);
             subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
 

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java

@@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -23,7 +23,7 @@ public class CatalogDataCatch {
     private DeferredResultHolder deferredResultHolder;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     public void put(String key, int total, Device device, List<DeviceChannel> deviceChannelList) {
         CatalogData catalogData = data.get(key);

+ 9 - 9
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java

@@ -7,7 +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.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
 import com.genersoft.iot.vmp.utils.SerializeUtils;
 import com.genersoft.iot.vmp.utils.redis.RedisUtil;
@@ -28,7 +28,7 @@ public class VideoStreamSessionManager {
 	private RedisUtil redisUtil;
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
 	public enum SessionType {
 		play,
@@ -58,9 +58,9 @@ public class VideoStreamSessionManager {
 		ssrcTransaction.setMediaServerId(mediaServerId);
 		ssrcTransaction.setType(type);
 
-		redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId()
+		redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
 				+ "_" +  deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction);
-		redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId()
+		redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
 				+ "_" +  deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction);
 	}
 
@@ -70,7 +70,7 @@ public class VideoStreamSessionManager {
 			byte[] dialogByteArray = SerializeUtils.serialize(dialog);
 			ssrcTransaction.setDialog(dialogByteArray);
 		}
-		redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId()
+		redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
 				+ "_" +  deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_"
 				+ ssrcTransaction.getStream(), ssrcTransaction);
 	}
@@ -105,7 +105,7 @@ public class VideoStreamSessionManager {
 	public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
 		if (StringUtils.isEmpty(callId)) callId ="*";
 		if (StringUtils.isEmpty(stream)) stream ="*";
-		String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
+		String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
 		List<Object> scanResult = redisUtil.scan(key);
 		if (scanResult.size() == 0) return null;
 		return (SsrcTransaction)redisUtil.get((String) scanResult.get(0));
@@ -116,7 +116,7 @@ public class VideoStreamSessionManager {
 		if (StringUtils.isEmpty(channelId)) channelId ="*";
 		if (StringUtils.isEmpty(callId)) callId ="*";
 		if (StringUtils.isEmpty(stream)) stream ="*";
-		String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
+		String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
 		List<Object> scanResult = redisUtil.scan(key);
 		if (scanResult.size() == 0) return null;
 		List<SsrcTransaction> result = new ArrayList<>();
@@ -141,13 +141,13 @@ public class VideoStreamSessionManager {
 	public void remove(String deviceId, String channelId, String stream) {
 		SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
 		if (ssrcTransaction == null) return;
-		redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_"
+		redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_"
 				+  deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream());
 	}
 
 
 	public List<SsrcTransaction> getAllSsrc() {
-		List<Object> ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetup.getServerId() + "_" ));
+		List<Object> ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId() + "_" ));
 		List<SsrcTransaction> result= new ArrayList<>();
 		for (int i = 0; i < ssrcTransactionKeys.size(); i++) {
 			String key = (String)ssrcTransactionKeys.get(i);

+ 15 - 17
src/main/java/com/genersoft/iot/vmp/gb28181/task/GPSSubscribeTask.java

@@ -1,5 +1,6 @@
 package com.genersoft.iot.vmp.gb28181.task;
 
+import com.alibaba.fastjson.JSON;
 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
@@ -7,7 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 
 import java.text.SimpleDateFormat;
 import java.util.List;
@@ -15,7 +16,7 @@ import java.util.List;
 public class GPSSubscribeTask implements Runnable{
 
     private IRedisCatchStorage redisCatchStorage;
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
     private ISIPCommanderForPlatform sipCommanderForPlatform;
     private SubscribeHolder subscribeHolder;
     private String platformId;
@@ -24,7 +25,7 @@ public class GPSSubscribeTask implements Runnable{
 
     private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
-    public GPSSubscribeTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorager storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) {
+    public GPSSubscribeTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorage storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) {
         this.redisCatchStorage = redisCatchStorage;
         this.storager = storager;
         this.platformId = platformId;
@@ -48,21 +49,18 @@ public class GPSSubscribeTask implements Runnable{
                     for (GbStream gbStream : gbStreams) {
                         String gbId = gbStream.getGbId();
                         GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
-                        if (gbStream.isStatus()) {
-                            if (gpsMsgInfo != null) {
-                                // 发送GPS消息
-                                sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe);
-                            }else {
-                                // 没有在redis找到新的消息就使用数据库的消息
-                                gpsMsgInfo = new GPSMsgInfo();
-                                gpsMsgInfo.setId(gbId);
-                                gpsMsgInfo.setLat(gbStream.getLongitude());
-                                gpsMsgInfo.setLng(gbStream.getLongitude());
-                                // 发送GPS消息
-                                sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe);
-                            }
+                        if (gpsMsgInfo != null) {
+                            // 发送GPS消息
+                            sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe);
+                        }else {
+                            // 没有在redis找到新的消息就使用数据库的消息
+                            gpsMsgInfo = new GPSMsgInfo();
+                            gpsMsgInfo.setId(gbId);
+                            gpsMsgInfo.setLat(gbStream.getLongitude());
+                            gpsMsgInfo.setLng(gbStream.getLongitude());
+                            // 发送GPS消息
+                            sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe);
                         }
-
                     }
                 }
             }

+ 1 - 3
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java

@@ -305,11 +305,9 @@ public interface ISIPCommander {
 	 * 订阅、取消订阅移动位置
 	 * 
 	 * @param device	视频设备
-	 * @param expires	订阅超时时间(值=0时为取消订阅)
-	 * @param interval	上报时间间隔
 	 * @return			true = 命令发送成功
 	 */
-	boolean mobilePositionSubscribe(Device device, int expires, int interval);
+	boolean mobilePositionSubscribe(Device device, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent);
 
 	/**
 	 * 订阅、取消订阅报警信息

+ 15 - 14
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.conf.DynamicTask;
 import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
 import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
@@ -20,7 +20,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import gov.nist.javax.sip.SipProviderImpl;
 import gov.nist.javax.sip.SipStackImpl;
 import gov.nist.javax.sip.message.SIPRequest;
@@ -71,13 +71,13 @@ public class SIPCommander implements ISIPCommander {
 	private VideoStreamSessionManager streamSession;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private IRedisCatchStorage redisCatchStorage;
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
 	@Autowired
 	private ZLMHttpHookSubscribe subscribe;
@@ -236,6 +236,7 @@ public class SIPCommander implements ISIPCommander {
 			ptzXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
 			ptzXml.append("<PTZCmd>" + cmdStr + "</PTZCmd>\r\n");
 			ptzXml.append("<Info>\r\n");
+			ptzXml.append("<ControlPriority>5</ControlPriority>\r\n");
 			ptzXml.append("</Info>\r\n");
 			ptzXml.append("</Control>\r\n");
 			
@@ -277,6 +278,7 @@ public class SIPCommander implements ISIPCommander {
 			ptzXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
 			ptzXml.append("<PTZCmd>" + cmdStr + "</PTZCmd>\r\n");
 			ptzXml.append("<Info>\r\n");
+			ptzXml.append("<ControlPriority>5</ControlPriority>\r\n");
 			ptzXml.append("</Info>\r\n");
 			ptzXml.append("</Control>\r\n");
 			
@@ -311,6 +313,7 @@ public class SIPCommander implements ISIPCommander {
 			ptzXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
 			ptzXml.append("<PTZCmd>" + cmdString + "</PTZCmd>\r\n");
 			ptzXml.append("<Info>\r\n");
+			ptzXml.append("<ControlPriority>5</ControlPriority>\r\n");
 			ptzXml.append("</Info>\r\n");
 			ptzXml.append("</Control>\r\n");
 			
@@ -365,7 +368,7 @@ public class SIPCommander implements ISIPCommander {
 			content.append("c=IN IP4 "+ mediaServerItem.getSdpIp() +"\r\n");
 			content.append("t=0 0\r\n");
 
-			if (userSetup.isSeniorSdp()) {
+			if (userSetting.isSeniorSdp()) {
 				if("TCP-PASSIVE".equals(streamMode)) {
 					content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n");
 				}else if ("TCP-ACTIVE".equals(streamMode)) {
@@ -465,7 +468,7 @@ public class SIPCommander implements ISIPCommander {
 
 			String streamMode = device.getStreamMode().toUpperCase();
 
-			if (userSetup.isSeniorSdp()) {
+			if (userSetting.isSeniorSdp()) {
 				if("TCP-PASSIVE".equals(streamMode)) {
 					content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n");
 				}else if ("TCP-ACTIVE".equals(streamMode)) {
@@ -575,7 +578,7 @@ public class SIPCommander implements ISIPCommander {
 
 			String streamMode = device.getStreamMode().toUpperCase();
 
-			if (userSetup.isSeniorSdp()) {
+			if (userSetting.isSeniorSdp()) {
 				if("TCP-PASSIVE".equals(streamMode)) {
 					content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n");
 				}else if ("TCP-ACTIVE".equals(streamMode)) {
@@ -1433,11 +1436,9 @@ public class SIPCommander implements ISIPCommander {
 	 * 订阅、取消订阅移动位置
 	 * 
 	 * @param device	视频设备
-	 * @param expires	订阅超时时间
-	 * @param interval	上报时间间隔
 	 * @return			true = 命令发送成功
 	 */
-	public boolean mobilePositionSubscribe(Device device, int expires, int interval) {
+	public boolean mobilePositionSubscribe(Device device, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) {
 		try {
 			StringBuffer subscribePostitionXml = new StringBuffer(200);
 			String charset = device.getCharset();
@@ -1446,8 +1447,8 @@ public class SIPCommander implements ISIPCommander {
 			subscribePostitionXml.append("<CmdType>MobilePosition</CmdType>\r\n");
 			subscribePostitionXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
 			subscribePostitionXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
-			if (expires > 0) {
-				subscribePostitionXml.append("<Interval>" + String.valueOf(interval) + "</Interval>\r\n");
+			if (device.getSubscribeCycleForMobilePosition() > 0) {
+				subscribePostitionXml.append("<Interval>" + String.valueOf(device.getMobilePositionSubmissionInterval()) + "</Interval>\r\n");
 			}
 			subscribePostitionXml.append("</Query>\r\n");
 
@@ -1456,8 +1457,8 @@ public class SIPCommander implements ISIPCommander {
 			CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
 					: udpSipProvider.getNewCallId();
 
-			Request request = headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), "z9hG4bK-viaPos-" + tm, "fromTagPos" + tm, null, expires, "presence" ,callIdHeader); //Position;id=" + tm.substring(tm.length() - 4));
-			transmitRequest(device, request);
+			Request request = headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), "z9hG4bK-viaPos-" + tm, "fromTagPos" + tm, null, device.getSubscribeCycleForMobilePosition(), "presence" ,callIdHeader); //Position;id=" + tm.substring(tm.length() - 4));
+			transmitRequest(device, request, errorEvent, okEvent);
 
 			return true;
 

+ 0 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java

@@ -372,7 +372,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
                     : udpSipProvider.getNewCallId();
             callIdHeader.setCallId(subscribeInfo.getCallId());
 
-//
             sendNotify(parentPlatform, deviceStatusXml.toString(), subscribeInfo, eventResult -> {
                 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg);
             }, null);

+ 16 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java

@@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
 
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
-import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
+import com.genersoft.iot.vmp.gb28181.bean.InviteStreamType;
 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
 import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
@@ -13,8 +13,9 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP
 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.bean.MessageForPushChannel;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.SerializeUtils;
 import gov.nist.javax.sip.stack.SIPDialog;
 import org.slf4j.Logger;
@@ -50,7 +51,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
 	private IRedisCatchStorage redisCatchStorage;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private ZLMRTPServerFactory zlmrtpServerFactory;
@@ -99,10 +100,20 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
 					redisCatchStorage.deleteSendRTPServer(platformGbId, channelId, callIdHeader.getCallId(), null);
 					int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
 					if (totalReaderCount <= 0) {
-						logger.info("收到bye: {}无其它观看者,通知设备停止推流", streamId);
-						if (sendRtpItem.isPlay()) {
+						logger.info("收到bye: {} 无其它观看者,通知设备停止推流", streamId);
+						if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) {
 							cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId, streamId, null);
 						}
+						if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) {
+							MessageForPushChannel messageForPushChannel = new MessageForPushChannel();
+							messageForPushChannel.setType(0);
+							messageForPushChannel.setGbId(sendRtpItem.getChannelId());
+							messageForPushChannel.setApp(sendRtpItem.getApp());
+							messageForPushChannel.setStream(sendRtpItem.getStreamId());
+							messageForPushChannel.setMediaServerId(sendRtpItem.getMediaServerId());
+							messageForPushChannel.setPlatFormId(sendRtpItem.getPlatformId());
+							redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel);
+						}
 					}
 				}
 				// 可能是设备主动停止

+ 145 - 74
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java

@@ -1,14 +1,12 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.conf.DynamicTask;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
-import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
@@ -16,20 +14,19 @@ 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.ZLMMediaListManager;
 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.IPlayService;
+import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.SerializeUtils;
-import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
 import gov.nist.javax.sdp.TimeDescriptionImpl;
 import gov.nist.javax.sdp.fields.TimeField;
-import gov.nist.javax.sip.address.AddressImpl;
-import gov.nist.javax.sip.address.SipUri;
-import gov.nist.javax.sip.header.Subject;
+import javafx.application.Platform;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.InitializingBean;
@@ -37,20 +34,14 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import javax.sdp.*;
-import javax.sip.InvalidArgumentException;
-import javax.sip.RequestEvent;
-import javax.sip.ServerTransaction;
-import javax.sip.SipException;
+import javax.sip.*;
 import javax.sip.address.SipURI;
 import javax.sip.header.CallIdHeader;
-import javax.sip.header.FromHeader;
-import javax.sip.header.Header;
 import javax.sip.message.Request;
 import javax.sip.message.Response;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.List;
 import java.util.Vector;
 
 /**
@@ -68,7 +59,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 	private SIPCommanderFroPlatform cmderFroPlatform;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private IRedisCatchStorage  redisCatchStorage;
@@ -97,6 +88,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 	@Autowired
 	private VideoStreamSessionManager sessionManager;
 
+	@Autowired
+	private UserSetting userSetting;
+
+	@Autowired
+	private ZLMMediaListManager mediaListManager;
+
 
 	@Override
 	public void afterPropertiesSet() throws Exception {
@@ -153,12 +150,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 						responseAck(evt, Response.GONE);
 						return;
 					}
-					Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, gbStream.getApp(), gbStream.getStream());
-					if (!streamReady ) {
-						logger.info("[ app={}, stream={} ]通道离线,返回400",gbStream.getApp(), gbStream.getStream());
-						responseAck(evt, Response.BAD_REQUEST, "channel [" + gbStream.getGbId() + "] offline");
-						return;
-					}
 					responseAck(evt, Response.CALL_IS_BEING_FORWARDED); // 通道存在,发181,呼叫转接中
 				}else if (catalog != null) {
 					responseAck(evt, Response.BAD_REQUEST, "catalog channel can not play"); // 目录不支持点播
@@ -273,13 +264,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 						return;
 					}
 					sendRtpItem.setCallId(callIdHeader.getCallId());
-					sendRtpItem.setPlay("Play".equals(sessionName));
+					sendRtpItem.setPlayType("Play".equals(sessionName)?InviteStreamType.PLAY:InviteStreamType.PLAYBACK);
 					byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog());
 					sendRtpItem.setDialog(dialogByteArray);
 					byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction());
 					sendRtpItem.setTransaction(transactionByteArray);
-
-
 					Long finalStartTime = startTime;
 					Long finalStopTime = stopTime;
 					ZLMHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON)->{
@@ -315,7 +304,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 								mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), ssrc);
 								// 回复bye
 								cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId());
-							}, 60);
+							}, 60*1000);
 							responseSdpAck(evt, content.toString(), platform);
 
 						} catch (SipException e) {
@@ -340,7 +329,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 					});
 					sendRtpItem.setApp("rtp");
 					if ("Playback".equals(sessionName)) {
-						sendRtpItem.setPlay(false);
+						sendRtpItem.setPlayType(InviteStreamType.PLAYBACK);
 						SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, true);
 						sendRtpItem.setStreamId(ssrcInfo.getStream());
 						// 写入redis, 超时时回复
@@ -370,7 +359,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 								}
 							});
 					}else {
-						sendRtpItem.setPlay(true);
+						sendRtpItem.setPlayType(InviteStreamType.PLAY);
 						SsrcTransaction playTransaction = sessionManager.getSsrcTransaction(device.getDeviceId(), channelId, "play", null);
 						if (playTransaction != null) {
 							Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, "rtp", playTransaction.getStream());
@@ -401,56 +390,105 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 						}
 					}
 				}else if (gbStream != null) {
-					SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
-							gbStream.getApp(), gbStream.getStream(), channelId,
-							mediaTransmissionTCP);
 
-					if (tcpActive != null) {
-						sendRtpItem.setTcpActive(tcpActive);
-					}
-					if (sendRtpItem == null) {
-						logger.warn("服务器端口资源不足");
-						responseAck(evt, Response.BUSY_HERE);
-						return;
-					}
+					Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, gbStream.getApp(), gbStream.getStream());
+					if (!streamReady ) {
+						if ("proxy".equals(gbStream.getStreamType())) {
+							// TODO 控制启用以使设备上线
+							logger.info("[ app={}, stream={} ]通道离线,启用流后开始推流",gbStream.getApp(), gbStream.getStream());
+							responseAck(evt, Response.BAD_REQUEST, "channel [" + gbStream.getGbId() + "] offline");
+						}else if ("push".equals(gbStream.getStreamType())) {
+							// 发送redis消息以使设备上线
+							logger.info("[ app={}, stream={} ]通道离线,发送redis信息控制设备开始推流",gbStream.getApp(), gbStream.getStream());
+							MessageForPushChannel messageForPushChannel = new MessageForPushChannel();
+							messageForPushChannel.setType(1);
+							messageForPushChannel.setGbId(gbStream.getGbId());
+							messageForPushChannel.setApp(gbStream.getApp());
+							messageForPushChannel.setStream(gbStream.getStream());
+							// TODO 获取低负载的节点
+							messageForPushChannel.setMediaServerId(gbStream.getMediaServerId());
+							messageForPushChannel.setPlatFormId(platform.getServerGBId());
+							messageForPushChannel.setPlatFormName(platform.getName());
+							redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel);
+							// 设置超时
+							dynamicTask.startDelay(callIdHeader.getCallId(), ()->{
+								logger.info("[ app={}, stream={} ] 等待设备开始推流超时", gbStream.getApp(), gbStream.getStream());
+								try {
+									mediaListManager.removedChannelOnlineEventLister(gbStream.getGbId());
+									responseAck(evt, Response.REQUEST_TIMEOUT); // 超时
+								} catch (SipException e) {
+									e.printStackTrace();
+								} catch (InvalidArgumentException e) {
+									e.printStackTrace();
+								} catch (ParseException e) {
+									e.printStackTrace();
+								}
+							}, userSetting.getPlatformPlayTimeout());
+							// 添加监听
+							MediaServerItem finalMediaServerItem = mediaServerItem;
+							int finalPort = port;
+							boolean finalMediaTransmissionTCP = mediaTransmissionTCP;
+							Boolean finalTcpActive = tcpActive;
+							mediaListManager.addChannelOnlineEventLister(gbStream.getGbId(), (app, stream)->{
+								SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(finalMediaServerItem, addressStr, finalPort, ssrc, requesterId,
+										app, stream, channelId, finalMediaTransmissionTCP);
+
+								if (sendRtpItem == null) {
+									logger.warn("服务器端口资源不足");
+									try {
+										responseAck(evt, Response.BUSY_HERE);
+									} catch (SipException e) {
+										e.printStackTrace();
+									} catch (InvalidArgumentException e) {
+										e.printStackTrace();
+									} catch (ParseException e) {
+										e.printStackTrace();
+									}
+									return;
+								}
+								if (finalTcpActive != null) {
+									sendRtpItem.setTcpActive(finalTcpActive);
+								}
+								sendRtpItem.setPlayType(InviteStreamType.PUSH);
+								// 写入redis, 超时时回复
+								sendRtpItem.setStatus(1);
+								sendRtpItem.setCallId(callIdHeader.getCallId());
+								byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog());
+								sendRtpItem.setDialog(dialogByteArray);
+								byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction());
+								sendRtpItem.setTransaction(transactionByteArray);
+								redisCatchStorage.updateSendRTPSever(sendRtpItem);
+								sendStreamAck(finalMediaServerItem, sendRtpItem, platform, evt);
 
-					// 写入redis, 超时时回复
-					sendRtpItem.setStatus(1);
-					sendRtpItem.setCallId(callIdHeader.getCallId());
-					byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog());
-					sendRtpItem.setDialog(dialogByteArray);
-					byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction());
-					sendRtpItem.setTransaction(transactionByteArray);
-					redisCatchStorage.updateSendRTPSever(sendRtpItem);
-					StringBuffer content = new StringBuffer(200);
-					content.append("v=0\r\n");
-					content.append("o="+ channelId +" 0 0 IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
-					content.append("s=Play\r\n");
-					content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
-					content.append("t=0 0\r\n");
-					content.append("m=video "+ sendRtpItem.getLocalPort()+" RTP/AVP 96\r\n");
-					content.append("a=sendonly\r\n");
-					content.append("a=rtpmap:96 PS/90000\r\n");
-					if (sendRtpItem.isTcp()) {
-						content.append("a=connection:new\r\n");
-						if (!sendRtpItem.isTcpActive()) {
-							content.append("a=setup:active\r\n");
-						}else {
-							content.append("a=setup:passive\r\n");
+							});
 						}
+					}else {
+						SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
+								gbStream.getApp(), gbStream.getStream(), channelId,
+								mediaTransmissionTCP);
+
+
+						if (sendRtpItem == null) {
+							logger.warn("服务器端口资源不足");
+							responseAck(evt, Response.BUSY_HERE);
+							return;
+						}
+						if (tcpActive != null) {
+							sendRtpItem.setTcpActive(tcpActive);
+						}
+						sendRtpItem.setPlayType(InviteStreamType.PUSH);
+						// 写入redis, 超时时回复
+						sendRtpItem.setStatus(1);
+						sendRtpItem.setCallId(callIdHeader.getCallId());
+						byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog());
+						sendRtpItem.setDialog(dialogByteArray);
+						byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction());
+						sendRtpItem.setTransaction(transactionByteArray);
+						redisCatchStorage.updateSendRTPSever(sendRtpItem);
+						sendStreamAck(mediaServerItem, sendRtpItem, platform, evt);
 					}
-					content.append("y="+ ssrc + "\r\n");
-					content.append("f=\r\n");
-
-					try {
-						responseSdpAck(evt, content.toString(), platform);
-					} catch (SipException e) {
-						e.printStackTrace();
-					} catch (InvalidArgumentException e) {
-						e.printStackTrace();
-					} catch (ParseException e) {
-						e.printStackTrace();
-					}
+
+
 				}
 
 			}
@@ -466,6 +504,39 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
 		}
 	}
 
+	public void sendStreamAck(MediaServerItem mediaServerItem, SendRtpItem sendRtpItem, ParentPlatform platform, RequestEvent evt){
+
+		StringBuffer content = new StringBuffer(200);
+		content.append("v=0\r\n");
+		content.append("o="+ sendRtpItem.getChannelId() +" 0 0 IN IP4 "+ mediaServerItem.getSdpIp()+"\r\n");
+		content.append("s=Play\r\n");
+		content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
+		content.append("t=0 0\r\n");
+		content.append("m=video "+ sendRtpItem.getLocalPort()+" RTP/AVP 96\r\n");
+		content.append("a=sendonly\r\n");
+		content.append("a=rtpmap:96 PS/90000\r\n");
+		if (sendRtpItem.isTcp()) {
+			content.append("a=connection:new\r\n");
+			if (!sendRtpItem.isTcpActive()) {
+				content.append("a=setup:active\r\n");
+			}else {
+				content.append("a=setup:passive\r\n");
+			}
+		}
+		content.append("y="+ sendRtpItem.getSsrc() + "\r\n");
+		content.append("f=\r\n");
+
+		try {
+			responseSdpAck(evt, content.toString(), platform);
+		} catch (SipException e) {
+			e.printStackTrace();
+		} catch (InvalidArgumentException e) {
+			e.printStackTrace();
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+	}
+
 	public void inviteFromDeviceHandle(RequestEvent evt, String requesterId) throws InvalidArgumentException, ParseException, SipException, SdpException {
 
 		// 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备)

+ 29 - 11
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java

@@ -1,8 +1,9 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
@@ -16,7 +17,7 @@ import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.GpsUtil;
 import com.genersoft.iot.vmp.utils.redis.RedisUtil;
 import org.dom4j.DocumentException;
@@ -46,10 +47,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
     private final static Logger logger = LoggerFactory.getLogger(NotifyRequestProcessor.class);
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private EventPublisher eventPublisher;
@@ -109,11 +110,15 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
 	 */
 	private void processNotifyMobilePosition(RequestEvent evt) {
 		try {
+			FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
+			String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
+
 			// 回复 200 OK
 			Element rootElement = getRootElement(evt);
+
 			MobilePosition mobilePosition = new MobilePosition();
 			Element deviceIdElement = rootElement.element("DeviceID");
-			String deviceId = deviceIdElement.getTextTrim().toString();
+			String channelId = deviceIdElement.getTextTrim().toString();
 			Device device = redisCatchStorage.getDevice(deviceId);
 			if (device != null) {
 				if (!StringUtils.isEmpty(device.getName())) {
@@ -121,7 +126,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
 				}
 			}
 			mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID"));
-			mobilePosition.setTime(XmlUtil.getText(rootElement, "Time"));
+			mobilePosition.setChannelId(channelId);
+			String time = XmlUtil.getText(rootElement, "Time");
+			mobilePosition.setTime(time);
 			mobilePosition.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude")));
 			mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude")));
 			if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) {
@@ -140,16 +147,27 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
 				mobilePosition.setAltitude(0.0);
 			}
 			mobilePosition.setReportSource("Mobile Position");
-			BaiduPoint bp = new BaiduPoint();
-			bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
+			BaiduPoint bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
 			logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat());
 			mobilePosition.setGeodeticSystem("BD-09");
 			mobilePosition.setCnLng(bp.getBdLng());
 			mobilePosition.setCnLat(bp.getBdLat());
-			if (!userSetup.getSavePositionHistory()) {
+			if (!userSetting.getSavePositionHistory()) {
 				storager.clearMobilePositionsByDeviceId(deviceId);
 			}
 			storager.insertMobilePosition(mobilePosition);
+			storager.updateChannelPotion(deviceId, channelId, mobilePosition.getLongitude(), mobilePosition.getLatitude() );
+			// 发送redis消息。 通知位置信息的变化
+			JSONObject jsonObject = new JSONObject();
+			jsonObject.put("time", time);
+			jsonObject.put("serial", deviceId);
+			jsonObject.put("code", channelId);
+			jsonObject.put("longitude", mobilePosition.getLongitude());
+			jsonObject.put("latitude", mobilePosition.getLatitude());
+			jsonObject.put("altitude", mobilePosition.getAltitude());
+			jsonObject.put("direction", mobilePosition.getDirection());
+			jsonObject.put("speed", mobilePosition.getSpeed());
+			redisCatchStorage.sendMobilePositionMsg(jsonObject);
 			responseAck(evt, Response.OK);
 		} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
 			e.printStackTrace();
@@ -209,7 +227,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
 				mobilePosition.setGeodeticSystem("BD-09");
 				mobilePosition.setCnLng(bp.getBdLng());
 				mobilePosition.setCnLat(bp.getBdLat());
-				if (!userSetup.getSavePositionHistory()) {
+				if (!userSetting.getSavePositionHistory()) {
 					storager.clearMobilePositionsByDeviceId(deviceId);
 				}
 				storager.insertMobilePosition(mobilePosition);
@@ -321,7 +339,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
 	public void setCmder(SIPCommander cmder) {
 	}
 
-	public void setStorager(IVideoManagerStorager storager) {
+	public void setStorager(IVideoManagerStorage storager) {
 		this.storager = storager;
 	}
 

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java

@@ -11,7 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
 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.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import gov.nist.javax.sip.RequestEventExt;
 import gov.nist.javax.sip.address.AddressImpl;
 import gov.nist.javax.sip.address.SipUri;
@@ -56,7 +56,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
 	private IRedisCatchStorage redisCatchStorage;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private EventPublisher publisher;

+ 16 - 9
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java

@@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
 
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.DynamicTask;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.CmdType;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
@@ -15,8 +15,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP
 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.utils.SerializeUtils;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import gov.nist.javax.sip.SipProviderImpl;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
@@ -30,7 +29,6 @@ import org.springframework.stereotype.Component;
 
 import javax.sip.*;
 import javax.sip.header.ExpiresHeader;
-import javax.sip.header.ToHeader;
 import javax.sip.message.Request;
 import javax.sip.message.Response;
 import java.text.ParseException;
@@ -54,7 +52,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
 	private ISIPCommanderForPlatform sipCommanderForPlatform;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Lazy
 	@Autowired
@@ -70,7 +68,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
 	private DynamicTask dynamicTask;
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
 
 	@Autowired
@@ -135,12 +133,21 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
 	/**
 	 * 处理移动位置订阅消息
 	 */
-	private void processNotifyMobilePosition(RequestEvent evt, Element rootElement) {
+	private void processNotifyMobilePosition(RequestEvent evt, Element rootElement) throws SipException {
 		String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
 		String deviceID = XmlUtil.getText(rootElement, "DeviceID");
+		ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
 		SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId);
+		if (evt.getServerTransaction() == null) {
+			ServerTransaction serverTransaction = platform.getTransport().equals("TCP") ? tcpSipProvider.getNewServerTransaction(evt.getRequest())
+					: udpSipProvider.getNewServerTransaction(evt.getRequest());
+			subscribeInfo.setTransaction(serverTransaction);
+			Dialog dialog = serverTransaction.getDialog();
+			dialog.terminateOnBye(false);
+			subscribeInfo.setDialog(dialog);
+		}
 		String sn = XmlUtil.getText(rootElement, "SN");
-		String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() +  "_MobilePosition_" + platformId;
+		String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() +  "_MobilePosition_" + platformId;
 		logger.info("接收到{}的MobilePosition订阅", platformId);
 		StringBuilder resultXml = new StringBuilder(200);
 		resultXml.append("<?xml version=\"1.0\" ?>\r\n")
@@ -193,7 +200,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
 			subscribeInfo.setDialog(dialog);
 		}
 		String sn = XmlUtil.getText(rootElement, "SN");
-		String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() +  "_Catalog_" + platformId;
+		String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() +  "_Catalog_" + platformId;
 		logger.info("接收到{}的Catalog订阅", platformId);
 		StringBuilder resultXml = new StringBuilder(200);
 		resultXml.append("<?xml version=\"1.0\" ?>\r\n")

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java

@@ -11,7 +11,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.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
 import org.slf4j.Logger;
@@ -43,7 +43,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
     private SIPProcessorObserver sipProcessorObserver;
 
     @Autowired
-    private IVideoManagerStorager storage;
+    private IVideoManagerStorage storage;
 
     @Autowired
     private SipSubscribe sipSubscribe;

+ 2 - 3
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java

@@ -8,8 +8,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler;
-import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.SpringBeanFactory;
 import gov.nist.javax.sip.SipStackImpl;
 import org.dom4j.Element;
@@ -41,7 +40,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
     private ControlMessageHandler controlMessageHandler;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private SIPCommander cmder;

+ 5 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java

@@ -1,7 +1,7 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
 
 import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
@@ -10,7 +10,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
 import com.genersoft.iot.vmp.service.IDeviceAlarmService;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.GpsUtil;
 import org.dom4j.Element;
 import org.slf4j.Logger;
@@ -37,13 +37,13 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
     private EventPublisher publisher;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private SipConfig sipConfig;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private IDeviceAlarmService deviceAlarmService;
@@ -99,7 +99,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
                 mobilePosition.setGeodeticSystem("BD-09");
                 mobilePosition.setCnLng(bp.getBdLng());
                 mobilePosition.setCnLat(bp.getBdLat());
-                if (!userSetup.getSavePositionHistory()) {
+                if (!userSetting.getSavePositionHistory()) {
                     storager.clearMobilePositionsByDeviceId(device.getDeviceId());
                 }
                 storager.insertMobilePosition(mobilePosition);

+ 7 - 22
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java

@@ -1,18 +1,13 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
 
-import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.gb28181.bean.*;
-import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.dom4j.Element;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -28,21 +23,17 @@ import java.util.List;
 @Component
 public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
 
-    private Logger logger = LoggerFactory.getLogger(CatalogNotifyMessageHandler.class);
     private final String cmdType = "Catalog";
 
     @Autowired
     private NotifyMessageHandler notifyMessageHandler;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storage;
 
     @Autowired
     private SIPCommanderFroPlatform cmderFroPlatform;
 
-    @Autowired
-    private SipConfig config;
-
     @Override
     public void afterPropertiesSet() throws Exception {
         notifyMessageHandler.addHandler(cmdType, this);
@@ -64,12 +55,12 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
             Element snElement = rootElement.element("SN");
             String sn = snElement.getText();
             // 准备回复通道信息
-            List<DeviceChannelInPlatform> deviceChannels = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId());
+            List<DeviceChannelInPlatform> deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId());
             // 查询关联的直播通道
-            List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
+            List<GbStream> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
             int size = deviceChannels.size() + gbStreams.size();
             // 回复目录信息
-            List<PlatformCatalog> catalogs =  storager.queryCatalogInPlatform(parentPlatform.getServerGBId());
+            List<PlatformCatalog> catalogs =  storage.queryCatalogInPlatform(parentPlatform.getServerGBId());
             if (catalogs.size() > 0) {
                 for (PlatformCatalog catalog : catalogs) {
                     if (catalog.getParentId().equals(catalog.getPlatformId())) {
@@ -101,7 +92,7 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
                     if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) {
                         channel.setCatalogId(parentPlatform.getDeviceGBId());
                     }
-                    DeviceChannel deviceChannel = storager.queryChannel(channel.getDeviceId(), channel.getChannelId());
+                    DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId());
                     deviceChannel.setParental(0);
                     deviceChannel.setParentId(channel.getCatalogId());
                     deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0, 6));
@@ -140,13 +131,7 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
                 // 回复无通道
                 cmderFroPlatform.catalogQuery(null, parentPlatform, sn, fromHeader.getTag(), size);
             }
-        } catch (SipException e) {
-            e.printStackTrace();
-        } catch (InvalidArgumentException e) {
-            e.printStackTrace();
-        } catch (ParseException e) {
-            e.printStackTrace();
-        } catch (InterruptedException e) {
+        } catch (SipException | InvalidArgumentException | ParseException | InterruptedException e) {
             e.printStackTrace();
         }
 

+ 2 - 4
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java

@@ -7,9 +7,8 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
-import com.genersoft.iot.vmp.service.IDeviceService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.dom4j.Element;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -17,7 +16,6 @@ import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.StringUtils;
-import springfox.documentation.service.Header;
 
 import javax.sip.InvalidArgumentException;
 import javax.sip.RequestEvent;
@@ -39,7 +37,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
     private EventPublisher publisher;
 
     @Autowired
-    private IVideoManagerStorager videoManagerStorager;
+    private IVideoManagerStorage videoManagerStorager;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;

+ 5 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java

@@ -1,6 +1,6 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
 
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
@@ -9,7 +9,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.GpsUtil;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
@@ -38,10 +38,10 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
     private NotifyMessageHandler notifyMessageHandler;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Override
     public void afterPropertiesSet() throws Exception {
@@ -85,7 +85,7 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
             mobilePosition.setGeodeticSystem("BD-09");
             mobilePosition.setCnLng(bp.getBdLng());
             mobilePosition.setCnLat(bp.getBdLat());
-            if (!userSetup.getSavePositionHistory()) {
+            if (!userSetting.getSavePositionHistory()) {
                 storager.clearMobilePositionsByDeviceId(device.getDeviceId());
             }
             storager.insertMobilePosition(mobilePosition);

+ 2 - 8
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java

@@ -2,17 +2,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.
 
 import com.genersoft.iot.vmp.conf.SipConfig;
 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.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
-import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.dom4j.Element;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -23,10 +19,8 @@ import org.springframework.stereotype.Component;
 import javax.sip.InvalidArgumentException;
 import javax.sip.RequestEvent;
 import javax.sip.SipException;
-import javax.sip.header.FromHeader;
 import javax.sip.message.Response;
 import java.text.ParseException;
-import java.util.List;
 
 @Component
 public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
@@ -38,7 +32,7 @@ public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implemen
     private QueryMessageHandler queryMessageHandler;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private SIPCommanderFroPlatform cmderFroPlatform;

+ 2 - 3
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java

@@ -8,8 +8,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.dom4j.Element;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,7 +34,7 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
     private QueryMessageHandler queryMessageHandler;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private SIPCommanderFroPlatform cmderFroPlatform;

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java

@@ -8,7 +8,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.dom4j.Element;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,7 +33,7 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i
     private QueryMessageHandler queryMessageHandler;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private SIPCommanderFroPlatform cmderFroPlatform;

+ 2 - 4
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java

@@ -4,16 +4,14 @@ import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener;
-import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
 import com.genersoft.iot.vmp.gb28181.utils.DateUtil;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
-import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
 import org.dom4j.Element;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,7 +37,7 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
     private QueryMessageHandler queryMessageHandler;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private SIPCommanderFroPlatform cmderFroPlatform;

+ 5 - 8
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java

@@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respon
 
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
@@ -15,7 +15,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respons
 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.GpsUtil;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import org.dom4j.DocumentException;
@@ -34,12 +34,9 @@ import javax.sip.message.Response;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 
-import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText;
-
 @Component
 public class CatalogResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
 
@@ -52,7 +49,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
     private ResponseMessageHandler responseMessageHandler;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private DeferredResultHolder deferredResultHolder;
@@ -71,7 +68,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
 
     //by brewswang
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;
@@ -224,7 +221,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
             mobilePosition.setGeodeticSystem("BD-09");
             mobilePosition.setCnLng(bp.getBdLng());
             mobilePosition.setCnLat(bp.getBdLat());
-            if (!userSetup.getSavePositionHistory()) {
+            if (!userSetting.getSavePositionHistory()) {
                 storager.clearMobilePositionsByDeviceId(deviceId);
             }
             storager.insertMobilePosition(mobilePosition);

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java

@@ -11,7 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
 import org.slf4j.Logger;
@@ -39,7 +39,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
     private ResponseMessageHandler responseMessageHandler;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private DeferredResultHolder deferredResultHolder;

+ 5 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java

@@ -1,6 +1,6 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
 
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
@@ -9,7 +9,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.GpsUtil;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
@@ -38,10 +38,10 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
     private ResponseMessageHandler responseMessageHandler;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Override
     public void afterPropertiesSet() throws Exception {
@@ -85,7 +85,7 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
             mobilePosition.setGeodeticSystem("BD-09");
             mobilePosition.setCnLng(bp.getBdLng());
             mobilePosition.setCnLat(bp.getBdLat());
-            if (!userSetup.getSavePositionHistory()) {
+            if (!userSetting.getSavePositionHistory()) {
                 storager.clearMobilePositionsByDeviceId(device.getDeviceId());
             }
             storager.insertMobilePosition(mobilePosition);

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java

@@ -7,7 +7,7 @@ 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.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,7 +33,7 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract {
 	private ISIPCommanderForPlatform sipCommanderForPlatform;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private IRedisCatchStorage redisCatchStorage;

+ 14 - 11
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java

@@ -2,12 +2,10 @@ package com.genersoft.iot.vmp.media.zlm;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.UUID;
 
 import com.alibaba.fastjson.JSON;
 import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.conf.MediaConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
+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;
@@ -17,9 +15,8 @@ import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
 import com.genersoft.iot.vmp.media.zlm.dto.*;
 import com.genersoft.iot.vmp.service.*;
-import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -54,7 +51,7 @@ public class ZLMHttpHookListener {
 	private IPlayService playService;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private IRedisCatchStorage redisCatchStorage;
@@ -81,7 +78,7 @@ public class ZLMHttpHookListener {
 	private ZLMHttpHookSubscribe subscribe;
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
 	@Autowired
 	private VideoStreamSessionManager sessionManager;
@@ -189,6 +186,12 @@ public class ZLMHttpHookListener {
 		ret.put("code", 0);
 		ret.put("msg", "success");
 		ret.put("enable_hls", true);
+		if (json.getInteger("originType") == 1
+				|| json.getInteger("originType") == 2
+				|| json.getInteger("originType") == 3) {
+			ret.put("enable_audio", true);
+		}
+
 		String mediaServerId = json.getString("mediaServerId");
 		ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
 		if (subscribe != null) {
@@ -203,9 +206,9 @@ public class ZLMHttpHookListener {
 	 	String app = json.getString("app");
 	 	String stream = json.getString("stream");
 		if ("rtp".equals(app)) {
-			ret.put("enable_mp4", userSetup.getRecordSip());
+			ret.put("enable_mp4", userSetting.getRecordSip());
 		}else {
-			ret.put("enable_mp4", userSetup.isRecordPushLive());
+			ret.put("enable_mp4", userSetting.isRecordPushLive());
 		}
 		List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, stream);
 		if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
@@ -412,7 +415,7 @@ public class ZLMHttpHookListener {
 						if (type != null) {
 							// 发送流变化redis消息
 							JSONObject jsonObject = new JSONObject();
-							jsonObject.put("serverId", userSetup.getServerId());
+							jsonObject.put("serverId", userSetting.getServerId());
 							jsonObject.put("app", app);
 							jsonObject.put("stream", streamId);
 							jsonObject.put("register", regist);
@@ -506,7 +509,7 @@ public class ZLMHttpHookListener {
 		}
 		String mediaServerId = json.getString("mediaServerId");
 		MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
-		if (userSetup.isAutoApplyPlay() && mediaInfo != null && mediaInfo.isRtpEnable()) {
+		if (userSetting.isAutoApplyPlay() && mediaInfo != null && mediaInfo.isRtpEnable()) {
 			String app = json.getString("app");
 			String streamId = json.getString("stream");
 			if ("rtp".equals(app)) {

+ 26 - 9
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java

@@ -1,20 +1,18 @@
 package com.genersoft.iot.vmp.media.zlm;
 
 import com.alibaba.fastjson.JSONObject;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
-import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
-import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import com.genersoft.iot.vmp.media.zlm.dto.*;
 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.IVideoManagerStorager;
+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 org.checkerframework.checker.units.qual.C;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,6 +20,7 @@ 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;
 
@@ -37,7 +36,7 @@ public class ZLMMediaListManager {
     private IRedisCatchStorage redisCatchStorage;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private GbStreamMapper gbStreamMapper;
@@ -58,7 +57,9 @@ public class ZLMMediaListManager {
     private ZLMHttpHookSubscribe subscribe;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
+
+    private Map<String, ChannelOnlineEvent> channelOnlineEvents = new ConcurrentHashMap<>();
 
 
     public void updateMediaList(MediaServerItem mediaServerItem) {
@@ -109,7 +110,7 @@ public class ZLMMediaListManager {
         // 查找此直播流是否存在redis预设gbId
         StreamPushItem transform = streamPushService.transform(mediaItem);
         // 从streamId取出查询关键值
-        Pattern pattern = Pattern.compile(userSetup.getThirdPartyGBIdReg());
+        Pattern pattern = Pattern.compile(userSetting.getThirdPartyGBIdReg());
         Matcher matcher = pattern.matcher(mediaItem.getStream());// 指定要匹配的字符串
         String queryKey = null;
         if (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
@@ -157,7 +158,15 @@ public class ZLMMediaListManager {
                 transform.setCreateStamp(System.currentTimeMillis());
                 gbStreamMapper.add(transform);
             }
+            if (transform != null) {
+                if (channelOnlineEvents.get(transform.getGbId()) != null)  {
+                    channelOnlineEvents.get(transform.getGbId()).run(transform.getApp(), transform.getStream());
+                    channelOnlineEvents.remove(transform.getGbId());
+                }
+            }
         }
+
+
         storager.updateMedia(transform);
         return transform;
     }
@@ -200,6 +209,14 @@ public class ZLMMediaListManager {
         return result;
     }
 
+    public void addChannelOnlineEventLister(String key, ChannelOnlineEvent callback) {
+        this.channelOnlineEvents.put(key,callback);
+    }
+
+    public void removedChannelOnlineEventLister(String key) {
+        this.channelOnlineEvents.remove(key);
+    }
+
 
 
 //    public void clearAllSessions() {

+ 6 - 0
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java

@@ -0,0 +1,6 @@
+package com.genersoft.iot.vmp.media.zlm.dto;
+
+public interface ChannelOnlineEvent {
+
+    void run(String app, String stream);
+}

+ 5 - 6
src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java

@@ -3,7 +3,7 @@ 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.UserSetup;
+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;
@@ -12,7 +12,6 @@ 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.KeyExpirationEventMessageListener;
 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
 import org.springframework.stereotype.Component;
 
@@ -33,13 +32,13 @@ public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi
 	private ZLMRESTfulUtils zlmresTfulUtils;
 
 	@Autowired
-	private UserSetup userSetup;
+	private UserSetting userSetting;
 
 	@Autowired
 	private IMediaServerService mediaServerService;
 
-    public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) {
-        super(listenerContainer, userSetup);
+    public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
+        super(listenerContainer, userSetting);
     }
 
 
@@ -52,7 +51,7 @@ public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi
     public void onMessage(Message message, byte[] pattern) {
         //  获取失效的key
         String expiredKey = message.toString();
-        String KEEPLIVEKEY_PREFIX = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetup.getServerId() + "_";
+        String KEEPLIVEKEY_PREFIX = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetting.getServerId() + "_";
         if(!expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){
         	return;
         }

+ 13 - 0
src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java

@@ -21,4 +21,17 @@ public interface IDeviceService {
      */
     boolean removeCatalogSubscribe(Device device);
 
+    /**
+     * 添加移动位置订阅
+     * @param device 设备信息
+     * @return
+     */
+    boolean addMobilePositionSubscribe(Device device);
+
+    /**
+     * 移除移动位置订阅
+     * @param device 设备信息
+     * @return
+     */
+    boolean removeMobilePositionSubscribe(Device device);
 }

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/service/StreamGPSSubscribeTask.java

@@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.service;
 
 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -20,7 +20,7 @@ public class StreamGPSSubscribeTask {
     private IRedisCatchStorage redisCatchStorage;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
 
 

+ 3 - 1
src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java

@@ -10,6 +10,9 @@ import org.slf4j.LoggerFactory;
 
 import javax.sip.ResponseEvent;
 
+/**
+ * 目录订阅任务
+ */
 public class CatalogSubscribeTask implements Runnable{
     private final Logger logger = LoggerFactory.getLogger(CatalogSubscribeTask.class);
     private  Device device;
@@ -24,7 +27,6 @@ public class CatalogSubscribeTask implements Runnable{
     public void run() {
         sipCommander.catalogSubscribe(device, eventResult -> {
             ResponseEvent event = (ResponseEvent) eventResult.event;
-            Element rootElement = null;
             if (event.getResponse().getRawContent() != null) {
                 // 成功
                 logger.info("[目录订阅]成功: {}", device.getDeviceId());

+ 112 - 0
src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java

@@ -0,0 +1,112 @@
+package com.genersoft.iot.vmp.service.bean;
+
+/**
+ * 当上级平台
+ */
+public class MessageForPushChannel {
+    /**
+     * 消息类型
+     * 0 流注销 1 流注册
+     */
+    private int type;
+
+    /**
+     * 流应用名
+     */
+    private String app;
+
+    /**
+     * 流Id
+     */
+    private String stream;
+
+    /**
+     * 国标ID
+     */
+    private String gbId;
+
+    /**
+     * 请求的平台ID
+     */
+    private String platFormId;
+
+    /**
+     * 请求平台名称
+     */
+    private String platFormName;
+
+    /**
+     * WVP服务ID
+     */
+    private String serverId;
+
+    /**
+     * 目标流媒体节点ID
+     */
+    private String mediaServerId;
+
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+
+    public String getApp() {
+        return app;
+    }
+
+    public void setApp(String app) {
+        this.app = app;
+    }
+
+    public String getStream() {
+        return stream;
+    }
+
+    public void setStream(String stream) {
+        this.stream = stream;
+    }
+
+    public String getGbId() {
+        return gbId;
+    }
+
+    public void setGbId(String gbId) {
+        this.gbId = gbId;
+    }
+
+    public String getPlatFormId() {
+        return platFormId;
+    }
+
+    public void setPlatFormId(String platFormId) {
+        this.platFormId = platFormId;
+    }
+
+    public String getPlatFormName() {
+        return platFormName;
+    }
+
+    public void setPlatFormName(String platFormName) {
+        this.platFormName = platFormName;
+    }
+
+    public String getServerId() {
+        return serverId;
+    }
+
+    public void setServerId(String serverId) {
+        this.serverId = serverId;
+    }
+
+    public String getMediaServerId() {
+        return mediaServerId;
+    }
+
+    public void setMediaServerId(String mediaServerId) {
+        this.mediaServerId = mediaServerId;
+    }
+}

+ 38 - 0
src/main/java/com/genersoft/iot/vmp/service/bean/MobilePositionSubscribeTask.java

@@ -0,0 +1,38 @@
+package com.genersoft.iot.vmp.service.bean;
+
+import com.genersoft.iot.vmp.gb28181.bean.Device;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
+import org.dom4j.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sip.ResponseEvent;
+
+public class MobilePositionSubscribeTask implements Runnable{
+    private final Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeTask.class);
+    private  Device device;
+    private  ISIPCommander sipCommander;
+
+    public MobilePositionSubscribeTask(Device device, ISIPCommander sipCommander) {
+        this.device = device;
+        this.sipCommander = sipCommander;
+    }
+
+    @Override
+    public void run() {
+        sipCommander.mobilePositionSubscribe(device, eventResult -> {
+            ResponseEvent event = (ResponseEvent) eventResult.event;
+            Element rootElement = null;
+            if (event.getResponse().getRawContent() != null) {
+                // 成功
+                logger.info("[移动位置订阅]成功: {}", device.getDeviceId());
+            }else {
+                // 成功
+                logger.info("[移动位置订阅]成功: {}", device.getDeviceId());
+            }
+        },eventResult -> {
+            // 失败
+            logger.warn("[移动位置订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg);
+        });
+    }
+}

+ 38 - 5
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java

@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
 import com.genersoft.iot.vmp.service.IDeviceService;
 import com.genersoft.iot.vmp.service.bean.CatalogSubscribeTask;
+import com.genersoft.iot.vmp.service.bean.MobilePositionSubscribeTask;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,7 +21,6 @@ public class DeviceServiceImpl implements IDeviceService {
 
     @Autowired
     private DynamicTask dynamicTask;
-;
 
     @Autowired
     private ISIPCommander sipCommander;
@@ -30,9 +30,9 @@ public class DeviceServiceImpl implements IDeviceService {
         if (device == null || device.getSubscribeCycleForCatalog() < 0) {
             return false;
         }
-        if (dynamicTask.contains(device.getDeviceId())) {
+        if (dynamicTask.contains(device.getDeviceId() + "catalog")) {
             // 存在则停止现有的,开启新的
-            dynamicTask.stop(device.getDeviceId());
+            dynamicTask.stop(device.getDeviceId() + "catalog");
         }
         logger.info("[添加目录订阅] 设备{}", device.getDeviceId());
         // 添加目录订阅
@@ -42,7 +42,7 @@ public class DeviceServiceImpl implements IDeviceService {
         int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog();
         // 设置最小值为30
         subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30);
-        dynamicTask.startCron(device.getDeviceId(), catalogSubscribeTask, subscribeCycleForCatalog - 5);
+        dynamicTask.startCron(device.getDeviceId() + "catalog", catalogSubscribeTask, subscribeCycleForCatalog - 5);
         return true;
     }
 
@@ -52,9 +52,42 @@ public class DeviceServiceImpl implements IDeviceService {
             return false;
         }
         logger.info("移除目录订阅: {}", device.getDeviceId());
-        dynamicTask.stop(device.getDeviceId());
+        dynamicTask.stop(device.getDeviceId() + "catalog");
         device.setSubscribeCycleForCatalog(0);
         sipCommander.catalogSubscribe(device, null, null);
         return true;
     }
+
+    @Override
+    public boolean addMobilePositionSubscribe(Device device) {
+        if (device == null || device.getSubscribeCycleForMobilePosition() < 0) {
+            return false;
+        }
+        if (dynamicTask.contains(device.getDeviceId() + "mobile_position")) {
+            // 存在则停止现有的,开启新的
+            dynamicTask.stop(device.getDeviceId() + "mobile_position");
+        }
+        logger.info("[添加移动位置订阅] 设备{}", device.getDeviceId());
+        // 添加目录订阅
+        MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander);
+        mobilePositionSubscribeTask.run();
+        // 提前开始刷新订阅
+        int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog();
+        // 设置最小值为30
+        subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30);
+        dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, subscribeCycleForCatalog - 5);
+        return true;
+    }
+
+    @Override
+    public boolean removeMobilePositionSubscribe(Device device) {
+        if (device == null || device.getSubscribeCycleForCatalog() < 0) {
+            return false;
+        }
+        logger.info("移除移动位置订阅: {}", device.getDeviceId());
+        dynamicTask.stop(device.getDeviceId() + "mobile_position");
+        device.setSubscribeCycleForCatalog(0);
+        sipCommander.mobilePositionSubscribe(device, null, null);
+        return true;
+    }
 }

+ 27 - 32
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java

@@ -4,10 +4,8 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.conf.MediaConfig;
 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.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
@@ -15,11 +13,10 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
 import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
-import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.service.IStreamProxyService;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.storager.dao.MediaServerMapper;
 import com.genersoft.iot.vmp.utils.redis.JedisUtil;
 import com.genersoft.iot.vmp.utils.redis.RedisUtil;
@@ -29,10 +26,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.core.annotation.Order;
 import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.security.core.parameters.P;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.TransactionStatus;
@@ -60,7 +54,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
     private Integer serverPort;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private ZLMRESTfulUtils zlmresTfulUtils;
@@ -84,7 +78,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
     private RedisUtil redisUtil;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private IStreamProxyService streamProxyService;
@@ -111,10 +105,10 @@ public class MediaServerServiceImpl implements IMediaServerService {
             if (mediaServerItem.getSsrcConfig() == null) {
                 SsrcConfig ssrcConfig = new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain());
                 mediaServerItem.setSsrcConfig(ssrcConfig);
-                redisUtil.set(VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItem.getId(), mediaServerItem);
+                redisUtil.set(VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId(), mediaServerItem);
             }
             // 查询redis是否存在此mediaServer
-            String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItem.getId();
+            String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId();
             if (!redisUtil.hasKey(key)) {
                 redisUtil.set(key, mediaServerItem);
             }
@@ -133,7 +127,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
             return null;
         }
         // 获取mediaServer可用的ssrc
-        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItem.getId();
+        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId();
 
         SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig();
         if (ssrcConfig == null) {
@@ -181,7 +175,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
         SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig();
         ssrcConfig.releaseSsrc(ssrc);
         mediaServerItem.setSsrcConfig(ssrcConfig);
-        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItem.getId();
+        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId();
         redisUtil.set(key, mediaServerItem);
     }
 
@@ -191,7 +185,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
     @Override
     public void clearRTPServer(MediaServerItem mediaServerItem) {
         mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain()));
-        redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(), mediaServerItem.getId(), 0);
+        redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), mediaServerItem.getId(), 0);
     }
 
 
@@ -211,15 +205,15 @@ public class MediaServerServiceImpl implements IMediaServerService {
                     )
             );
         }
-        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItemInDataBase.getId();
+        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItemInDataBase.getId();
         redisUtil.set(key, mediaServerItemInDataBase);
     }
 
     @Override
     public List<MediaServerItem> getAll() {
         List<MediaServerItem> result = new ArrayList<>();
-        List<Object> mediaServerKeys = redisUtil.scan(String.format("%S*", VideoManagerConstants.MEDIA_SERVER_PREFIX+ userSetup.getServerId() + "_" ));
-        String onlineKey = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId();
+        List<Object> mediaServerKeys = redisUtil.scan(String.format("%S*", VideoManagerConstants.MEDIA_SERVER_PREFIX+ userSetting.getServerId() + "_" ));
+        String onlineKey = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
         for (Object mediaServerKey : mediaServerKeys) {
             String key = (String) mediaServerKey;
             MediaServerItem mediaServerItem = (MediaServerItem) redisUtil.get(key);
@@ -250,13 +244,13 @@ public class MediaServerServiceImpl implements IMediaServerService {
 
     @Override
     public List<MediaServerItem> getAllOnline() {
-        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
         Set<String> mediaServerIdSet = redisUtil.zRevRange(key, 0, -1);
 
         List<MediaServerItem> result = new ArrayList<>();
         if (mediaServerIdSet != null && mediaServerIdSet.size() > 0) {
             for (String mediaServerId : mediaServerIdSet) {
-                String serverKey = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerId;
+                String serverKey = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerId;
                 result.add((MediaServerItem) redisUtil.get(serverKey));
             }
         }
@@ -274,7 +268,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
         if (mediaServerId == null) {
             return null;
         }
-        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerId;
+        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerId;
         return (MediaServerItem)redisUtil.get(key);
     }
 
@@ -286,7 +280,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
 
     @Override
     public void clearMediaServerForOnline() {
-        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
         redisUtil.del(key);
     }
 
@@ -393,7 +387,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
             return;
         }
         mediaServerMapper.update(serverItem);
-        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + zlmServerConfig.getGeneralMediaServerId();
+        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + zlmServerConfig.getGeneralMediaServerId();
         if (redisUtil.get(key) == null) {
             SsrcConfig ssrcConfig = new SsrcConfig(zlmServerConfig.getGeneralMediaServerId(), null, sipConfig.getDomain());
             serverItem.setSsrcConfig(ssrcConfig);
@@ -404,8 +398,9 @@ public class MediaServerServiceImpl implements IMediaServerService {
         redisUtil.set(key, serverItem);
         resetOnlineServerItem(serverItem);
         updateMediaServerKeepalive(serverItem.getId(), null);
-        setZLMConfig(serverItem, "0".equals(zlmServerConfig.getHookEnable()));
-
+        if (serverItem.isAutoConfig()) {
+            setZLMConfig(serverItem, "0".equals(zlmServerConfig.getHookEnable()));
+        }
         publisher.zlmOnlineEventPublish(serverItem.getId());
         logger.info("[ ZLM:{} ]-[ {}:{} ]连接成功",
                 zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(), zlmServerConfig.getHttpPort());
@@ -420,7 +415,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
     @Override
     public void resetOnlineServerItem(MediaServerItem serverItem) {
         // 更新缓存
-        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
         // 使用zset的分数作为当前并发量, 默认值设置为0
         if (redisUtil.zScore(key, serverItem.getId()) == null) {  // 不存在则设置默认值 已存在则重置
             redisUtil.zAdd(key, serverItem.getId(), 0L);
@@ -446,14 +441,14 @@ public class MediaServerServiceImpl implements IMediaServerService {
         if (mediaServerId == null) {
             return;
         }
-        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
         redisUtil.zIncrScore(key, mediaServerId, 1);
 
     }
 
     @Override
     public void removeCount(String mediaServerId) {
-        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
         redisUtil.zIncrScore(key, mediaServerId, - 1);
     }
 
@@ -463,7 +458,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
      */
     @Override
     public MediaServerItem getMediaServerForMinimumLoad() {
-        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
 
         if (redisUtil.zSize(key)  == null || redisUtil.zSize(key) == 0) {
             logger.info("获取负载最低的节点时无在线节点");
@@ -617,8 +612,8 @@ public class MediaServerServiceImpl implements IMediaServerService {
 
     @Override
     public void delete(String id) {
-        redisUtil.zRemove(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(), id);
-        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + id;
+        redisUtil.zRemove(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), id);
+        String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + id;
         redisUtil.del(key);
     }
     @Override
@@ -636,7 +631,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
             logger.warn("[更新ZLM 保活信息]失败,未找到流媒体信息");
             return;
         }
-        String key = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetup.getServerId() + "_" + mediaServerId;
+        String key = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + mediaServerId;
         int hookAliveInterval = mediaServerItem.getHookAliveInterval() + 2;
         redisUtil.set(key, data, hookAliveInterval);
     }

+ 2 - 3
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java

@@ -6,11 +6,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.conf.MediaConfig;
 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
 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.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.service.IMediaService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -22,7 +21,7 @@ public class MediaServiceImpl implements IMediaService {
     private IRedisCatchStorage redisCatchStorage;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private IMediaServerService mediaServerService;

+ 8 - 8
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
@@ -23,7 +23,7 @@ import com.genersoft.iot.vmp.service.bean.PlayBackCallback;
 import com.genersoft.iot.vmp.service.bean.PlayBackResult;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.redis.RedisUtil;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
@@ -50,7 +50,7 @@ public class PlayServiceImpl implements IPlayService {
     private final static Logger logger = LoggerFactory.getLogger(PlayServiceImpl.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private SIPCommander cmder;
@@ -83,7 +83,7 @@ public class PlayServiceImpl implements IPlayService {
     private VideoStreamSessionManager streamSession;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
 
 
@@ -99,7 +99,7 @@ public class PlayServiceImpl implements IPlayService {
         String uuid = UUID.randomUUID().toString();
         msg.setId(uuid);
         playResult.setUuid(uuid);
-        DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetup.getPlayTimeout());
+        DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetting.getPlayTimeout());
         playResult.setResult(result);
         // 录像查询以channelId作为deviceId查询
         resultHolder.put(key, uuid, result);
@@ -255,7 +255,7 @@ public class PlayServiceImpl implements IPlayService {
                     streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
                 }
             }
-        }, userSetup.getPlayTimeout());
+        }, userSetting.getPlayTimeout());
 
         cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> {
             logger.info("收到订阅消息: " + response.toJSONString());
@@ -374,7 +374,7 @@ public class PlayServiceImpl implements IPlayService {
                 // 回复之前所有的点播请求
                 playBackCallback.call(playBackResult);
             }
-        }, userSetup.getPlayTimeout());
+        }, userSetting.getPlayTimeout());
         cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack,
                 (InviteStreamInfo inviteStreamInfo) -> {
                     logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString());
@@ -461,7 +461,7 @@ public class PlayServiceImpl implements IPlayService {
                 // 回复之前所有的点播请求
                 hookCallBack.call(downloadResult);
             }
-        }, userSetup.getPlayTimeout());
+        }, userSetting.getPlayTimeout());
         cmder.downloadStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, infoCallBack,
                 inviteStreamInfo -> {
                     logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString());

+ 1 - 1
src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java

@@ -20,7 +20,7 @@ public class RedisGPSMsgListener implements MessageListener {
 
     @Override
     public void onMessage(Message message, byte[] bytes) {
-        logger.debug("收到来自REDIS的GPS通知: {}", new String(message.getBody()));
+        logger.info("收到来自REDIS的GPS通知: {}", new String(message.getBody()));
         GPSMsgInfo gpsMsgInfo = JSON.parseObject(message.getBody(), GPSMsgInfo.class);
         redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo);
     }

+ 6 - 9
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java

@@ -3,23 +3,20 @@ package com.genersoft.iot.vmp.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
-import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
-import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
-import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
 import com.genersoft.iot.vmp.service.IGbStreamService;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.service.IMediaService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
 import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
 import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
@@ -44,7 +41,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
     private final static Logger logger = LoggerFactory.getLogger(StreamProxyServiceImpl.class);
 
     @Autowired
-    private IVideoManagerStorager videoManagerStorager;
+    private IVideoManagerStorage videoManagerStorager;
 
     @Autowired
     private IMediaService mediaService;
@@ -59,10 +56,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
     private IRedisCatchStorage redisCatchStorage;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private SipConfig sipConfig;
@@ -321,7 +318,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
         if (mediaItems.size() > 0) {
             for (MediaItem mediaItem : mediaItems) {
                 JSONObject jsonObject = new JSONObject();
-                jsonObject.put("serverId", userSetup.getServerId());
+                jsonObject.put("serverId", userSetting.getServerId());
                 jsonObject.put("app", mediaItem.getApp());
                 jsonObject.put("stream", mediaItem.getStream());
                 jsonObject.put("register", false);

+ 4 - 8
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java

@@ -4,21 +4,17 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
-import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
-import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
-import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
 import com.genersoft.iot.vmp.media.zlm.dto.*;
 import com.genersoft.iot.vmp.service.IGbStreamService;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.service.IStreamPushService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.dao.*;
-import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import org.slf4j.Logger;
@@ -63,7 +59,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
     private IRedisCatchStorage redisCatchStorage;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private IMediaServerService mediaServerService;
@@ -263,7 +259,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
                 String type = "PUSH";
                 for (MediaItem offlineMediaItem : offlineMediaItemList) {
                     JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("serverId", userSetup.getServerId());
+                    jsonObject.put("serverId", userSetting.getServerId());
                     jsonObject.put("app", offlineMediaItem.getApp());
                     jsonObject.put("stream", offlineMediaItem.getStream());
                     jsonObject.put("register", false);
@@ -293,7 +289,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
                 // 移除redis内流的信息
                 redisCatchStorage.removeStream(mediaServerId, type, mediaItem.getApp(), mediaItem.getStream());
                 JSONObject jsonObject = new JSONObject();
-                jsonObject.put("serverId", userSetup.getServerId());
+                jsonObject.put("serverId", userSetting.getServerId());
                 jsonObject.put("app", mediaItem.getApp());
                 jsonObject.put("stream", mediaItem.getStream());
                 jsonObject.put("register", false);

+ 4 - 0
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java

@@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
+import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
 
@@ -212,4 +213,7 @@ public interface IRedisCatchStorage {
 
     void addNetInfo(Map<String, String> networkInterfaces);
 
+    void sendMobilePositionMsg(JSONObject jsonObject);
+
+    void sendStreamPushRequestedMsg(MessageForPushChannel messageForPushChannel);
 }

+ 482 - 481
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java

@@ -1,481 +1,482 @@
-package com.genersoft.iot.vmp.storager;
-
-import com.genersoft.iot.vmp.gb28181.bean.*;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
-import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
-import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
-import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
-import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
-import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
-import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
-import com.github.pagehelper.PageInfo;
-
-import java.util.List;
-
-/**    
- * @description:视频设备数据存储接口
- * @author: swwheihei
- * @date:   2020年5月6日 下午2:14:31     
- */
-@SuppressWarnings("rawtypes")
-public interface IVideoManagerStorager {
-
-	/**   
-	 * 根据设备ID判断设备是否存在
-	 * 
-	 * @param deviceId 设备ID
-	 * @return true:存在  false:不存在
-	 */
-	public boolean exists(String deviceId);
-	
-	/**   
-	 * 视频设备创建
-	 * 
-	 * @param device 设备对象
-	 * @return true:创建成功  false:创建失败
-	 */
-	public boolean create(Device device);
-	
-	/**   
-	 * 视频设备更新
-	 * 
-	 * @param device 设备对象
-	 * @return true:创建成功  false:创建失败
-	 */
-	public boolean updateDevice(Device device);
-
-	/**
-	 * 添加设备通道
-	 *
-	 * @param deviceId 设备id
-	 * @param channel 通道
-	 */
-	public void updateChannel(String deviceId, DeviceChannel channel);
-
-	/**
-	 * 批量添加设备通道
-	 *
-	 * @param deviceId 设备id
-	 * @param channels 多个通道
-	 */
-	public int updateChannels(String deviceId, List<DeviceChannel> channels);
-
-	/**
-	 * 开始播放
-	 * @param deviceId 设备id
-	 * @param channelId 通道ID
-	 * @param streamId 流地址
-	 */
-	public void startPlay(String deviceId, String channelId, String streamId);
-
-	/**
-	 * 停止播放
-	 * @param deviceId 设备id
-	 * @param channelId 通道ID
-	 */
-	public void stopPlay(String deviceId, String channelId);
-	
-	/**   
-	 * 获取设备
-	 * 
-	 * @param deviceId 设备ID
-	 * @return DShadow 设备对象
-	 */
-	public Device queryVideoDevice(String deviceId);
-
-	/**
-	 * 获取某个设备的通道列表
-	 *
-	 * @param deviceId 设备ID
-	 * @param page 分页 当前页
-	 * @param count 每页数量
-	 * @return
-	 */
-	public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
-	
-	public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
-
-	/**
-	 *  获取某个设备的通道树
-	 * @param deviceId 设备ID
-	 * @return
-	 */
-	List<DeviceChannelTree> tree(String deviceId);
-
-	/**
-	 * 获取某个设备的通道列表
-	 *
-	 * @param deviceId 设备ID
-	 * @return
-	 */
-	public List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
-	public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
-
-	/**
-	 * 获取某个设备的通道
-	 * @param deviceId 设备ID
-	 * @param channelId 通道ID
-	 */
-	public DeviceChannel queryChannel(String deviceId, String channelId);
-
-	/**
-	 * 删除通道
-	 * @param deviceId 设备ID
-	 * @param channelId 通道ID
-	 */
-	public int delChannel(String deviceId, String channelId);
-
-	/**
-	 * 获取多个设备
-	 * @param page 当前页数
-	 * @param count 每页数量
-	 * @return List<Device> 设备对象数组
-	 */
-	public PageInfo<Device> queryVideoDeviceList(int page, int count);
-
-	/**
-	 * 获取多个设备
-	 *
-	 * @return List<Device> 设备对象数组
-	 */
-	public List<Device> queryVideoDeviceList();
-
-	/**   
-	 * 删除设备
-	 * 
-	 * @param deviceId 设备ID
-	 * @return true:删除成功  false:删除失败
-	 */
-	public boolean delete(String deviceId);
-	
-	/**   
-	 * 更新设备在线
-	 * 
-	 * @param deviceId 设备ID
-	 * @return true:更新成功  false:更新失败
-	 */
-	public boolean online(String deviceId);
-	
-	/**   
-	 * 更新设备离线
-	 * 
-	 * @param deviceId 设备ID
-	 * @return true:更新成功  false:更新失败
-	 */
-	public boolean outline(String deviceId);
-
-	/**
-	 * 更新所有设备离线
-	 *
-	 * @return true:更新成功  false:更新失败
-	 */
-	public boolean outlineForAll();
-
-
-	/**
-	 * 查询子设备
-	 *
-	 * @param deviceId
-	 * @param channelId
-	 * @param page
-	 * @param count
-	 * @return
-	 */
-	PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
-
-
-	/**
-	 * 清空通道
-	 * @param deviceId
-	 */
-	void cleanChannelsForDevice(String deviceId);
-
-
-	/**
-	 * 更新上级平台
-	 * @param parentPlatform
-	 */
-	boolean updateParentPlatform(ParentPlatform parentPlatform);
-
-
-	/**
-	 * 添加上级平台
-	 * @param parentPlatform
-	 */
-	boolean addParentPlatform(ParentPlatform parentPlatform);
-
-	/**
-	 * 删除上级平台
-	 * @param parentPlatform
-	 */
-	boolean deleteParentPlatform(ParentPlatform parentPlatform);
-
-
-	/**
-	 * 分页获取上级平台
-	 * @param page
-	 * @param count
-	 * @return
-	 */
-	PageInfo<ParentPlatform> queryParentPlatformList(int page, int count);
-
-	/**
-	 * 获取所有已启用的平台
-	 * @return
-	 */
-	List<ParentPlatform> queryEnableParentPlatformList(boolean enable);
-
-	/**
-	 * 获取上级平台
-	 * @param platformGbId
-	 * @return
-	 */
-	ParentPlatform queryParentPlatByServerGBId(String platformGbId);
-
-	/**
-	 * 所有平台离线
-	 */
-	void outlineForAllParentPlatform();
-
-	/**
-	 * 查询通道信息,不区分设备(已关联平台或全部)
-	 */
-	PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId);
-
-	/**
-	 * 查询设备的通道信息
-	 */
-	List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId);
-
-
-	/**
-	 * 更新上级平台的通道信息
-	 * @param platformId
-	 * @param channelReduces
-	 * @return
-	 */
-	int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId);
-
-	/**
-	 *  移除上级平台的通道信息
-	 * @param platformId
-	 * @param channelReduces
-	 * @return
-	 */
-	int delChannelForGB(String platformId, List<ChannelReduce> channelReduces);
-
-
-    DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
-
-    List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId);
-    List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId);
-
-    Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
-
-
-	/**
-	 * 添加Mobile Position设备移动位置
-	 * @param mobilePosition
-	 * @return
-	 */
-	public boolean insertMobilePosition(MobilePosition mobilePosition);
-
-	/**
-	 * 查询移动位置轨迹
-	 * @param deviceId
-	 * @param startTime
-	 * @param endTime
-	 */
-	public List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime);
-
-	/**
-	 * 查询最新移动位置
-	 * @param deviceId
-	 */
-	public MobilePosition queryLatestPosition(String deviceId);
-
-	/**
-	 * 删除指定设备的所有移动位置
-	 * @param deviceId
-	 */
-	public int clearMobilePositionsByDeviceId(String deviceId);
-
-	/**
-	 * 新增代理流
-	 * @param streamProxyDto
-	 * @return
-	 */
-	public boolean addStreamProxy(StreamProxyItem streamProxyDto);
-
-	/**
-	 * 更新代理流
-	 * @param streamProxyDto
-	 * @return
-	 */
-	public boolean updateStreamProxy(StreamProxyItem streamProxyDto);
-
-	/**
-	 * 移除代理流
-	 * @param app
-	 * @param stream
-	 * @return
-	 */
-	public int deleteStreamProxy(String app, String stream);
-
-	/**
-	 * 按照是否启用获取代理流
-	 * @param enable
-	 * @return
-	 */
-	public List<StreamProxyItem> getStreamProxyListForEnable(boolean enable);
-
-	/**
-	 * 按照是app和stream获取代理流
-	 * @param app
-	 * @param stream
-	 * @return
-	 */
-	public StreamProxyItem queryStreamProxy(String app, String stream);
-
-	/**
-	 * 获取代理流
-	 * @param page
-	 * @param count
-	 * @return
-	 */
-	PageInfo<StreamProxyItem> queryStreamProxyList(Integer page, Integer count);
-
-	/**
-	 * 根据国标ID获取平台关联的直播流
-	 * @param platformId
-	 * @param channelId
-	 * @return
-	 */
-	GbStream queryStreamInParentPlatform(String platformId, String channelId);
-
-	/**
-	 * 获取平台关联的直播流
-	 * @param platformId
-	 * @return
-	 */
-	List<GbStream> queryGbStreamListInPlatform(String platformId);
-
-	/**
-	 * 批量更新推流列表
-	 * @param streamPushItems
-	 */
-	void updateMediaList(List<StreamPushItem> streamPushItems);
-
-	/**
-	 * 更新单个推流
-	 * @param streamPushItem
-	 */
-	void updateMedia(StreamPushItem streamPushItem);
-
-	/**
-	 * 移除单个推流
-	 * @param app
-	 * @param stream
-	 */
-	int removeMedia(String app, String stream);
-
-
-	/**
-	 * 清空推流列表
-	 */
-	void clearMediaList();
-
-	/**
-	 * 设置流离线
-	 * @param app
-	 * @param streamId
-	 */
-	int mediaOutline(String app, String streamId);
-
-	/**
-	 * 设置平台在线/离线
-	 * @param online
-	 */
-	void updateParentPlatformStatus(String platformGbID, boolean online);
-
-	/**
-	 * 根据媒体ID获取启用/不启用的代理列表
-	 * @param id 媒体ID
-	 * @param enable 启用/不启用
-	 * @param status 状态
-	 * @return
-	 */
-	List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id,  boolean enable, boolean status);
-
-	/**
-	 * 根据通道ID获取其所在设备
-	 * @param channelId  通道ID
-	 * @return
-	 */
-    Device queryVideoDeviceByChannelId(String channelId);
-
-	/**
-	 * 通道上线
-	 * @param channelId 通道ID
-	 */
-	void deviceChannelOnline(String deviceId, String channelId);
-
-	/**
-	 * 通道离线
-	 * @param channelId 通道ID
-	 */
-	void deviceChannelOffline(String deviceId, String channelId);
-
-	/**
-	 * 通过app与stream获取StreamProxy
-	 * @param app
-	 * @param streamId
-	 * @return
-	 */
-    StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId);
-
-	/**
-	 * catlog查询结束后完全重写通道信息
-	 * @param deviceId
-	 * @param deviceChannelList
-	 */
-	boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList);
-
-	/**
-	 * 获取目录信息
-	 * @param platformId
-	 * @param parentId
-	 * @return
-	 */
-    List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId);
-
-	int addCatalog(PlatformCatalog platformCatalog);
-
-	PlatformCatalog getCatalog(String id);
-
-	int delCatalog(String id);
-
-	int updateCatalog(PlatformCatalog platformCatalog);
-
-	int setDefaultCatalog(String platformId, String catalogId);
-
-	List<PlatformCatalog> queryCatalogInPlatform(String serverGBId);
-
-    int delRelation(PlatformCatalog platformCatalog);
-
-	int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfo);
-
-	List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms);
-
-	List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms);
-
-	GbStream getGbStream(String app, String streamId);
-
-	void delCatalogByPlatformId(String serverGBId);
-
-	void delRelationByPlatformId(String serverGBId);
-
-    PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
-
-	List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
-}
+package com.genersoft.iot.vmp.storager;
+
+import com.genersoft.iot.vmp.gb28181.bean.*;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
+import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
+import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
+import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
+import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+
+/**    
+ * @description:视频设备数据存储接口
+ * @author: swwheihei
+ * @date:   2020年5月6日 下午2:14:31     
+ */
+@SuppressWarnings("rawtypes")
+public interface IVideoManagerStorage {
+
+	/**   
+	 * 根据设备ID判断设备是否存在
+	 * 
+	 * @param deviceId 设备ID
+	 * @return true:存在  false:不存在
+	 */
+	public boolean exists(String deviceId);
+	
+	/**   
+	 * 视频设备创建
+	 * 
+	 * @param device 设备对象
+	 * @return true:创建成功  false:创建失败
+	 */
+	public boolean create(Device device);
+	
+	/**   
+	 * 视频设备更新
+	 * 
+	 * @param device 设备对象
+	 * @return true:创建成功  false:创建失败
+	 */
+	public boolean updateDevice(Device device);
+
+	/**
+	 * 添加设备通道
+	 *
+	 * @param deviceId 设备id
+	 * @param channel 通道
+	 */
+	public void updateChannel(String deviceId, DeviceChannel channel);
+
+	/**
+	 * 批量添加设备通道
+	 *
+	 * @param deviceId 设备id
+	 * @param channels 多个通道
+	 */
+	public int updateChannels(String deviceId, List<DeviceChannel> channels);
+
+	/**
+	 * 开始播放
+	 * @param deviceId 设备id
+	 * @param channelId 通道ID
+	 * @param streamId 流地址
+	 */
+	public void startPlay(String deviceId, String channelId, String streamId);
+
+	/**
+	 * 停止播放
+	 * @param deviceId 设备id
+	 * @param channelId 通道ID
+	 */
+	public void stopPlay(String deviceId, String channelId);
+	
+	/**   
+	 * 获取设备
+	 * 
+	 * @param deviceId 设备ID
+	 * @return DShadow 设备对象
+	 */
+	public Device queryVideoDevice(String deviceId);
+
+	/**
+	 * 获取某个设备的通道列表
+	 *
+	 * @param deviceId 设备ID
+	 * @param page 分页 当前页
+	 * @param count 每页数量
+	 * @return
+	 */
+	public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
+	
+	public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
+
+	/**
+	 *  获取某个设备的通道树
+	 * @param deviceId 设备ID
+	 * @return
+	 */
+	List<DeviceChannelTree> tree(String deviceId);
+
+	/**
+	 * 获取某个设备的通道列表
+	 *
+	 * @param deviceId 设备ID
+	 * @return
+	 */
+	public List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
+	public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
+
+	/**
+	 * 获取某个设备的通道
+	 * @param deviceId 设备ID
+	 * @param channelId 通道ID
+	 */
+	public DeviceChannel queryChannel(String deviceId, String channelId);
+
+	/**
+	 * 删除通道
+	 * @param deviceId 设备ID
+	 * @param channelId 通道ID
+	 */
+	public int delChannel(String deviceId, String channelId);
+
+	/**
+	 * 获取多个设备
+	 * @param page 当前页数
+	 * @param count 每页数量
+	 * @return List<Device> 设备对象数组
+	 */
+	public PageInfo<Device> queryVideoDeviceList(int page, int count);
+
+	/**
+	 * 获取多个设备
+	 *
+	 * @return List<Device> 设备对象数组
+	 */
+	public List<Device> queryVideoDeviceList();
+
+	/**   
+	 * 删除设备
+	 * 
+	 * @param deviceId 设备ID
+	 * @return true:删除成功  false:删除失败
+	 */
+	public boolean delete(String deviceId);
+	
+	/**   
+	 * 更新设备在线
+	 * 
+	 * @param deviceId 设备ID
+	 * @return true:更新成功  false:更新失败
+	 */
+	public boolean online(String deviceId);
+	
+	/**   
+	 * 更新设备离线
+	 * 
+	 * @param deviceId 设备ID
+	 * @return true:更新成功  false:更新失败
+	 */
+	public boolean outline(String deviceId);
+
+	/**
+	 * 更新所有设备离线
+	 *
+	 * @return true:更新成功  false:更新失败
+	 */
+	public boolean outlineForAll();
+
+
+	/**
+	 * 查询子设备
+	 *
+	 * @param deviceId
+	 * @param channelId
+	 * @param page
+	 * @param count
+	 * @return
+	 */
+	PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
+
+
+	/**
+	 * 清空通道
+	 * @param deviceId
+	 */
+	void cleanChannelsForDevice(String deviceId);
+
+
+	/**
+	 * 更新上级平台
+	 * @param parentPlatform
+	 */
+	boolean updateParentPlatform(ParentPlatform parentPlatform);
+
+
+	/**
+	 * 添加上级平台
+	 * @param parentPlatform
+	 */
+	boolean addParentPlatform(ParentPlatform parentPlatform);
+
+	/**
+	 * 删除上级平台
+	 * @param parentPlatform
+	 */
+	boolean deleteParentPlatform(ParentPlatform parentPlatform);
+
+
+	/**
+	 * 分页获取上级平台
+	 * @param page
+	 * @param count
+	 * @return
+	 */
+	PageInfo<ParentPlatform> queryParentPlatformList(int page, int count);
+
+	/**
+	 * 获取所有已启用的平台
+	 * @return
+	 */
+	List<ParentPlatform> queryEnableParentPlatformList(boolean enable);
+
+	/**
+	 * 获取上级平台
+	 * @param platformGbId
+	 * @return
+	 */
+	ParentPlatform queryParentPlatByServerGBId(String platformGbId);
+
+	/**
+	 * 所有平台离线
+	 */
+	void outlineForAllParentPlatform();
+
+	/**
+	 * 查询通道信息,不区分设备(已关联平台或全部)
+	 */
+	PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId);
+
+	/**
+	 * 查询设备的通道信息
+	 */
+	List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId);
+
+
+	/**
+	 * 更新上级平台的通道信息
+	 * @param platformId
+	 * @param channelReduces
+	 * @return
+	 */
+	int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId);
+
+	/**
+	 *  移除上级平台的通道信息
+	 * @param platformId
+	 * @param channelReduces
+	 * @return
+	 */
+	int delChannelForGB(String platformId, List<ChannelReduce> channelReduces);
+
+
+    DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
+
+    List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId);
+    List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId);
+
+    Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
+
+
+	/**
+	 * 添加Mobile Position设备移动位置
+	 * @param mobilePosition
+	 * @return
+	 */
+	public boolean insertMobilePosition(MobilePosition mobilePosition);
+
+	/**
+	 * 查询移动位置轨迹
+	 * @param deviceId
+	 * @param startTime
+	 * @param endTime
+	 */
+	public List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime);
+
+	/**
+	 * 查询最新移动位置
+	 * @param deviceId
+	 */
+	public MobilePosition queryLatestPosition(String deviceId);
+
+	/**
+	 * 删除指定设备的所有移动位置
+	 * @param deviceId
+	 */
+	public int clearMobilePositionsByDeviceId(String deviceId);
+
+	/**
+	 * 新增代理流
+	 * @param streamProxyDto
+	 * @return
+	 */
+	public boolean addStreamProxy(StreamProxyItem streamProxyDto);
+
+	/**
+	 * 更新代理流
+	 * @param streamProxyDto
+	 * @return
+	 */
+	public boolean updateStreamProxy(StreamProxyItem streamProxyDto);
+
+	/**
+	 * 移除代理流
+	 * @param app
+	 * @param stream
+	 * @return
+	 */
+	public int deleteStreamProxy(String app, String stream);
+
+	/**
+	 * 按照是否启用获取代理流
+	 * @param enable
+	 * @return
+	 */
+	public List<StreamProxyItem> getStreamProxyListForEnable(boolean enable);
+
+	/**
+	 * 按照是app和stream获取代理流
+	 * @param app
+	 * @param stream
+	 * @return
+	 */
+	public StreamProxyItem queryStreamProxy(String app, String stream);
+
+	/**
+	 * 获取代理流
+	 * @param page
+	 * @param count
+	 * @return
+	 */
+	PageInfo<StreamProxyItem> queryStreamProxyList(Integer page, Integer count);
+
+	/**
+	 * 根据国标ID获取平台关联的直播流
+	 * @param platformId
+	 * @param channelId
+	 * @return
+	 */
+	GbStream queryStreamInParentPlatform(String platformId, String channelId);
+
+	/**
+	 * 获取平台关联的直播流
+	 * @param platformId
+	 * @return
+	 */
+	List<GbStream> queryGbStreamListInPlatform(String platformId);
+
+	/**
+	 * 批量更新推流列表
+	 * @param streamPushItems
+	 */
+	void updateMediaList(List<StreamPushItem> streamPushItems);
+
+	/**
+	 * 更新单个推流
+	 * @param streamPushItem
+	 */
+	void updateMedia(StreamPushItem streamPushItem);
+
+	/**
+	 * 移除单个推流
+	 * @param app
+	 * @param stream
+	 */
+	int removeMedia(String app, String stream);
+
+
+	/**
+	 * 清空推流列表
+	 */
+	void clearMediaList();
+
+	/**
+	 * 设置流离线
+	 * @param app
+	 * @param streamId
+	 */
+	int mediaOutline(String app, String streamId);
+
+	/**
+	 * 设置平台在线/离线
+	 * @param online
+	 */
+	void updateParentPlatformStatus(String platformGbID, boolean online);
+
+	/**
+	 * 根据媒体ID获取启用/不启用的代理列表
+	 * @param id 媒体ID
+	 * @param enable 启用/不启用
+	 * @param status 状态
+	 * @return
+	 */
+	List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id,  boolean enable, boolean status);
+
+	/**
+	 * 根据通道ID获取其所在设备
+	 * @param channelId  通道ID
+	 * @return
+	 */
+    Device queryVideoDeviceByChannelId(String channelId);
+
+	/**
+	 * 通道上线
+	 * @param channelId 通道ID
+	 */
+	void deviceChannelOnline(String deviceId, String channelId);
+
+	/**
+	 * 通道离线
+	 * @param channelId 通道ID
+	 */
+	void deviceChannelOffline(String deviceId, String channelId);
+
+	/**
+	 * 通过app与stream获取StreamProxy
+	 * @param app
+	 * @param streamId
+	 * @return
+	 */
+    StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId);
+
+	/**
+	 * catlog查询结束后完全重写通道信息
+	 * @param deviceId
+	 * @param deviceChannelList
+	 */
+	boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList);
+
+	/**
+	 * 获取目录信息
+	 * @param platformId
+	 * @param parentId
+	 * @return
+	 */
+    List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId);
+
+	int addCatalog(PlatformCatalog platformCatalog);
+
+	PlatformCatalog getCatalog(String id);
+
+	int delCatalog(String id);
+
+	int updateCatalog(PlatformCatalog platformCatalog);
+
+	int setDefaultCatalog(String platformId, String catalogId);
+
+	List<PlatformCatalog> queryCatalogInPlatform(String serverGBId);
+
+    int delRelation(PlatformCatalog platformCatalog);
+
+	int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfo);
+
+	List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms);
+
+	List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms);
+
+	GbStream getGbStream(String app, String streamId);
+
+	void delCatalogByPlatformId(String serverGBId);
+
+	void delRelationByPlatformId(String serverGBId);
+
+    PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
+
+	List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
+
+    void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude);
+}

+ 4 - 1
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java

@@ -106,7 +106,7 @@ public interface DeviceChannelMapper {
             " <if test='online == true' > AND dc.status=1</if> " +
             " <if test='online == false' > AND dc.status=0</if> " +
             " <if test='hasSubChannel!= null and hasSubChannel == true' >  AND dc.subCount > 0</if> " +
-            " <if test='hasSubChannel!= null and hasSubChannel == false' >  AND dc.subCount == 0</if> " +
+            " <if test='hasSubChannel!= null and hasSubChannel == false' >  AND dc.subCount = 0</if> " +
             " <if test='catalogId == null ' >  AND dc.id not in (select deviceChannelId from platform_gb_channel where platformId=#{platformId} ) </if> " +
             " <if test='catalogId != null ' >  AND pgc.platformId = #{platformId} and pgc.catalogId=#{catalogId} </if> " +
             " ORDER BY dc.deviceId, dc.channelId ASC" +
@@ -270,4 +270,7 @@ public interface DeviceChannelMapper {
             " where deviceId = #{deviceId} " +
             " and channelId = #{channelId}")
     int updateChannelSubCount(String deviceId, String channelId);
+
+    @Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
+    void updatePotion(String deviceId, String channelId, double longitude, double latitude);
 }

+ 9 - 0
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java

@@ -34,6 +34,9 @@ public interface DeviceMapper {
                 "updateTime," +
                 "charset," +
                 "subscribeCycleForCatalog," +
+                "subscribeCycleForMobilePosition," +
+                "mobilePositionSubmissionInterval," +
+                "subscribeCycleForAlarm," +
                 "online" +
             ") VALUES (" +
                 "#{deviceId}," +
@@ -53,6 +56,9 @@ public interface DeviceMapper {
                 "#{updateTime}," +
                 "#{charset}," +
                 "#{subscribeCycleForCatalog}," +
+                "#{subscribeCycleForMobilePosition}," +
+                "#{mobilePositionSubmissionInterval}," +
+                "#{subscribeCycleForAlarm}," +
                 "#{online}" +
             ")")
     int add(Device device);
@@ -75,6 +81,9 @@ public interface DeviceMapper {
                 "<if test=\"expires != null\">, expires=${expires}</if>" +
                 "<if test=\"charset != null\">, charset='${charset}'</if>" +
                 "<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=${subscribeCycleForCatalog}</if>" +
+                "<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}</if>" +
+                "<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=${mobilePositionSubmissionInterval}</if>" +
+                "<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=${subscribeCycleForAlarm}</if>" +
                 "WHERE deviceId='${deviceId}'"+
             " </script>"})
     int update(Device device);

+ 83 - 71
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java

@@ -1,16 +1,16 @@
 package com.genersoft.iot.vmp.storager.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.common.SystemInfoDto;
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
-import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
-import com.genersoft.iot.vmp.service.bean.SSRCInfo;
+import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
 import com.genersoft.iot.vmp.service.bean.ThirdPartyGB;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
@@ -18,9 +18,7 @@ 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.security.core.parameters.P;
 import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
 
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -29,7 +27,7 @@ import java.util.*;
 @Component
 public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
-    private Logger logger = LoggerFactory.getLogger(RedisCatchStorageImpl.class);
+    private final Logger logger = LoggerFactory.getLogger(RedisCatchStorageImpl.class);
 
     @Autowired
 	private RedisUtil redis;
@@ -38,13 +36,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     private DeviceChannelMapper deviceChannelMapper;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
-    private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
     @Override
     public Long getCSEQ(String method) {
-        String key = VideoManagerConstants.SIP_CSEQ_PREFIX  + userSetup.getServerId() + "_" +  method;
+        String key = VideoManagerConstants.SIP_CSEQ_PREFIX  + userSetting.getServerId() + "_" +  method;
 
         long result =  redis.incr(key, 1L);
         if (result > Integer.MAX_VALUE) {
@@ -56,7 +54,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public Long getSN(String method) {
-        String key = VideoManagerConstants.SIP_SN_PREFIX  + userSetup.getServerId() + "_" +  method;
+        String key = VideoManagerConstants.SIP_SN_PREFIX  + userSetting.getServerId() + "_" +  method;
 
         long result =  redis.incr(key, 1L);
         if (result > Integer.MAX_VALUE) {
@@ -68,20 +66,20 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void resetAllCSEQ() {
-        String scanKey = VideoManagerConstants.SIP_CSEQ_PREFIX  + userSetup.getServerId() + "_*";
+        String scanKey = VideoManagerConstants.SIP_CSEQ_PREFIX  + userSetting.getServerId() + "_*";
         List<Object> keys = redis.scan(scanKey);
-        for (int i = 0; i < keys.size(); i++) {
-            String key = (String) keys.get(i);
+        for (Object o : keys) {
+            String key = (String) o;
             redis.set(key, 1);
         }
     }
 
     @Override
     public void resetAllSN() {
-        String scanKey = VideoManagerConstants.SIP_SN_PREFIX  + userSetup.getServerId() + "_*";
+        String scanKey = VideoManagerConstants.SIP_SN_PREFIX  + userSetting.getServerId() + "_*";
         List<Object> keys = redis.scan(scanKey);
-        for (int i = 0; i < keys.size(); i++) {
-            String key = (String) keys.get(i);
+        for (Object o : keys) {
+            String key = (String) o;
             redis.set(key, 1);
         }
     }
@@ -93,7 +91,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
      */
     @Override
     public boolean startPlay(StreamInfo stream) {
-        return redis.set(String.format("%S_%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(),
+        return redis.set(String.format("%S_%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),
                         stream.getStream(), stream.getDeviceID(), stream.getChannelId()),
                 stream);
     }
@@ -107,7 +105,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     public boolean stopPlay(StreamInfo streamInfo) {
         if (streamInfo == null) return false;
         return redis.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 streamInfo.getStream(),
                 streamInfo.getDeviceID(),
                 streamInfo.getChannelId()));
@@ -121,14 +119,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     public StreamInfo queryPlay(StreamInfo streamInfo) {
         return (StreamInfo)redis.get(String.format("%S_%s_%s_%s_%s",
                 VideoManagerConstants.PLAYER_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 streamInfo.getStream(),
                 streamInfo.getDeviceID(),
                 streamInfo.getChannelId()));
     }
     @Override
     public StreamInfo queryPlayByStreamId(String streamId) {
-        List<Object> playLeys = redis.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(), streamId));
+        List<Object> playLeys = redis.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
         if (playLeys == null || playLeys.size() == 0) return null;
         return (StreamInfo)redis.get(playLeys.get(0).toString());
     }
@@ -136,7 +134,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     @Override
     public StreamInfo queryPlayByDevice(String deviceId, String channelId) {
         List<Object> playLeys = redis.scan(String.format("%S_%s_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 deviceId,
                 channelId));
         if (playLeys == null || playLeys.size() == 0) return null;
@@ -147,11 +145,11 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     public Map<String, StreamInfo> queryPlayByDeviceId(String deviceId) {
         Map<String, StreamInfo> streamInfos = new HashMap<>();
 //		List<Object> playLeys = redis.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId));
-        List<Object> players = redis.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(),deviceId));
+        List<Object> players = redis.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),deviceId));
         if (players.size() == 0) return streamInfos;
-        for (int i = 0; i < players.size(); i++) {
-            String key = (String) players.get(i);
-            StreamInfo streamInfo = (StreamInfo)redis.get(key);
+        for (Object player : players) {
+            String key = (String) player;
+            StreamInfo streamInfo = (StreamInfo) redis.get(key);
             streamInfos.put(streamInfo.getDeviceID() + "_" + streamInfo.getChannelId(), streamInfo);
         }
         return streamInfos;
@@ -161,7 +159,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     @Override
     public boolean startPlayback(StreamInfo stream, String callId) {
         return redis.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
-                userSetup.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream);
+                userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream);
     }
 
     @Override
@@ -169,10 +167,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
         boolean result;
         if (stream.getProgress() == 1) {
             result = redis.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX,
-                    userSetup.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream);
+                    userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream);
         }else {
             result = redis.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX,
-                    userSetup.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream, 60*60);
+                    userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream, 60*60);
         }
         return result;
     }
@@ -189,7 +187,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
         if (stream == null) stream = "*";
         if (callId == null) callId = "*";
         String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 deviceId,
                 channelId,
                 stream,
@@ -217,7 +215,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
         if (stream == null) stream = "*";
         if (callId == null) callId = "*";
         String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 deviceId,
                 channelId,
                 stream,
@@ -242,7 +240,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
         if (stream == null) stream = "*";
         if (callId == null) callId = "*";
         String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 deviceId,
                 channelId,
                 stream,
@@ -258,63 +256,63 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) {
-        String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX  + userSetup.getServerId() + "_" +  parentPlatformCatch.getId();
+        String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX  + userSetting.getServerId() + "_" +  parentPlatformCatch.getId();
         redis.set(key, parentPlatformCatch);
     }
 
     @Override
     public void updatePlatformKeepalive(ParentPlatform parentPlatform) {
-        String key = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX  + userSetup.getServerId() + "_" + parentPlatform.getServerGBId();
+        String key = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX  + userSetting.getServerId() + "_" + parentPlatform.getServerGBId();
         redis.set(key, "", Integer.parseInt(parentPlatform.getKeepTimeout()));
     }
 
     @Override
     public void updatePlatformRegister(ParentPlatform parentPlatform) {
-        String key = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetup.getServerId() + "_" + parentPlatform.getServerGBId();
+        String key = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_" + parentPlatform.getServerGBId();
         redis.set(key, "", Integer.parseInt(parentPlatform.getExpires()));
     }
 
     @Override
     public ParentPlatformCatch queryPlatformCatchInfo(String platformGbId) {
-        return (ParentPlatformCatch)redis.get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetup.getServerId() + "_" + platformGbId);
+        return (ParentPlatformCatch)redis.get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId);
     }
 
     @Override
     public void delPlatformCatchInfo(String platformGbId) {
-        redis.del(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetup.getServerId() + "_" + platformGbId);
+        redis.del(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId);
     }
 
     @Override
     public void delPlatformKeepalive(String platformGbId) {
-        redis.del(VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetup.getServerId() + "_" + platformGbId);
+        redis.del(VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + platformGbId);
     }
 
     @Override
     public void delPlatformRegister(String platformGbId) {
-        redis.del(VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetup.getServerId() + "_" + platformGbId);
+        redis.del(VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_" + platformGbId);
     }
 
 
     @Override
     public void updatePlatformRegisterInfo(String callId, String platformGbId) {
-        String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + callId;
+        String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId;
         redis.set(key, platformGbId, 30);
     }
 
 
     @Override
     public String queryPlatformRegisterInfo(String callId) {
-        return (String)redis.get(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + callId);
+        return (String)redis.get(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId);
     }
 
     @Override
     public void delPlatformRegisterInfo(String callId) {
-        redis.del(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + callId);
+        redis.del(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId);
     }
 
     @Override
     public void cleanPlatformRegisterInfos() {
-        List regInfos = redis.scan(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + "*");
+        List regInfos = redis.scan(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + "*");
         for (Object key : regInfos) {
             redis.del(key.toString());
         }
@@ -322,7 +320,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void updateSendRTPSever(SendRtpItem sendRtpItem) {
-        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_"
+        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_"
                 + sendRtpItem.getPlatformId() + "_" + sendRtpItem.getChannelId() + "_"
                 + sendRtpItem.getStreamId() + "_" + sendRtpItem.getCallId();
         redis.set(key, sendRtpItem);
@@ -334,7 +332,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
         if (channelId == null) channelId = "*";
         if (streamId == null) streamId = "*";
         if (callId == null) callId = "*";
-        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_" + platformGbId
+        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId
                 + "_" + channelId + "_" + streamId + "_" + callId;
         List<Object> scan = redis.scan(key);
         if (scan.size() > 0) {
@@ -347,13 +345,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     @Override
     public List<SendRtpItem> querySendRTPServer(String platformGbId) {
         if (platformGbId == null) platformGbId = "*";
-        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*";
+        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*";
         List<Object> queryResult = redis.scan(key);
         List<SendRtpItem> result= new ArrayList<>();
 
-        for (int i = 0; i < queryResult.size(); i++) {
-            String keyItem = (String) queryResult.get(i);
-            result.add((SendRtpItem)redis.get(keyItem));
+        for (Object o : queryResult) {
+            String keyItem = (String) o;
+            result.add((SendRtpItem) redis.get(keyItem));
         }
 
         return result;
@@ -368,7 +366,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     public void deleteSendRTPServer(String platformGbId, String channelId, String callId, String streamId) {
         if (streamId == null) streamId = "*";
         if (callId == null) callId = "*";
-        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_" + platformGbId
+        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId
                 + "_" + channelId + "_" + streamId + "_" + callId;
         List<Object> scan = redis.scan(key);
         if (scan.size() > 0) {
@@ -386,7 +384,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
      */
     @Override
     public boolean isChannelSendingRTP(String channelId) {
-        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_" + "*_" + channelId + "*_" + "*_";
+        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + "*_" + channelId + "*_" + "*_";
         List<Object> RtpStreams = redis.scan(key);
         if (RtpStreams.size() > 0) {
             return true;
@@ -398,7 +396,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     @Override
     public void clearCatchByDeviceId(String deviceId) {
         List<Object> playLeys = redis.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 deviceId));
         if (playLeys.size() > 0) {
             for (Object key : playLeys) {
@@ -407,7 +405,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
         }
 
         List<Object> playBackers = redis.scan(String.format("%S_%s_%s_*_*_*", VideoManagerConstants.PLAY_BLACK_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 deviceId));
         if (playBackers.size() > 0) {
             for (Object key : playBackers) {
@@ -416,7 +414,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
         }
 
         List<Object> deviceCache = redis.scan(String.format("%S%s_%s", VideoManagerConstants.DEVICE_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 deviceId));
         if (deviceCache.size() > 0) {
             for (Object key : deviceCache) {
@@ -427,7 +425,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void outlineForAll() {
-        List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + "*" );
+        List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + "*" );
         for (int i = 0; i < onlineDevices.size(); i++) {
             String key = (String) onlineDevices.get(i);
             redis.del(key);
@@ -437,7 +435,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     @Override
     public List<String> getOnlineForAll() {
         List<String> result = new ArrayList<>();
-        List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_"  + "*" );
+        List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_"  + "*" );
         for (int i = 0; i < onlineDevices.size(); i++) {
             String key = (String) onlineDevices.get(i);
             result.add((String) redis.get(key));
@@ -447,7 +445,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void updateWVPInfo(JSONObject jsonObject, int time) {
-        String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId();
         redis.set(key, jsonObject, time);
     }
 
@@ -460,13 +458,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, MediaItem mediaItem) {
-        String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX  + userSetup.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId();
+        String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX  + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId();
         redis.set(key, mediaItem);
     }
 
     @Override
     public void removeStream(String mediaServerId, String type, String app, String streamId) {
-        String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetup.getServerId() + "_" + type + "_"  + app + "_" + streamId + "_" + mediaServerId;
+        String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_"  + app + "_" + streamId + "_" + mediaServerId;
         redis.del(key);
     }
 
@@ -480,7 +478,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
         if (stream == null) stream = "*";
         if (callId == null) callId = "*";
         String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX,
-                userSetup.getServerId(),
+                userSetting.getServerId(),
                 deviceId,
                 channelId,
                 stream,
@@ -503,7 +501,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void removeStream(String mediaServerId, String type) {
-        String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetup.getServerId() + "_" + type + "_*_*_" + mediaServerId;
+        String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId;
         List<Object> streams = redis.scan(key);
         for (Object stream : streams) {
             redis.del((String) stream);
@@ -513,7 +511,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
     @Override
     public List<MediaItem> getStreams(String mediaServerId, String type) {
         List<MediaItem> result = new ArrayList<>();
-        String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetup.getServerId() + "_" + type + "_*_*_" + mediaServerId;
+        String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId;
         List<Object> streams = redis.scan(key);
         for (Object stream : streams) {
             MediaItem mediaItem = (MediaItem)redis.get((String) stream);
@@ -524,37 +522,37 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void updateDevice(Device device) {
-        String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + device.getDeviceId();
+        String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + device.getDeviceId();
         redis.set(key, device);
     }
 
     @Override
     public void removeDevice(String deviceId) {
-        String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId;
+        String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId;
         redis.del(key);
     }
 
     @Override
     public Device getDevice(String deviceId) {
-        String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId;
+        String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId;
         return (Device)redis.get(key);
     }
 
     @Override
     public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) {
-        String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_" + gpsMsgInfo.getId();
+        String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gpsMsgInfo.getId();
         redis.set(key, gpsMsgInfo, 60); // 默认GPS消息保存1分钟
     }
 
     @Override
     public GPSMsgInfo getGpsMsgInfo(String gbId) {
-        String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_" + gbId;
+        String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gbId;
         return (GPSMsgInfo)redis.get(key);
     }
 
     @Override
     public List<GPSMsgInfo> getAllGpsMsgInfo() {
-        String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_*";
+        String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_*";
         List<GPSMsgInfo> result = new ArrayList<>();
         List<Object> keys = redis.scan(scanKey);
         for (int i = 0; i < keys.size(); i++) {
@@ -570,7 +568,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public MediaItem getStreamInfo(String app, String streamId, String mediaServerId) {
-        String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX  + userSetup.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId;
+        String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX  + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId;
 
         MediaItem result = null;
         List<Object> keys = redis.scan(scanKey);
@@ -584,7 +582,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void addCpuInfo(double cpuInfo) {
-        String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetting.getServerId();
         SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>();
         systemInfoDto.setTime(format.format(System.currentTimeMillis()));
         systemInfoDto.setData(cpuInfo);
@@ -599,7 +597,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void addMemInfo(double memInfo) {
-        String key = VideoManagerConstants.SYSTEM_INFO_MEM_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.SYSTEM_INFO_MEM_PREFIX + userSetting.getServerId();
         SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>();
         systemInfoDto.setTime(format.format(System.currentTimeMillis()));
         systemInfoDto.setData(memInfo);
@@ -614,7 +612,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
     @Override
     public void addNetInfo(Map<String, String> networkInterfaces) {
-        String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetup.getServerId();
+        String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetting.getServerId();
         SystemInfoDto<Map<String, String>> systemInfoDto = new SystemInfoDto<>();
         systemInfoDto.setTime(format.format(System.currentTimeMillis()));
         systemInfoDto.setData(networkInterfaces);
@@ -626,4 +624,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
             }
         }
     }
+
+    @Override
+    public void sendMobilePositionMsg(JSONObject jsonObject) {
+        String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_MOBILE_POSITION;
+        logger.debug("[redis 移动位置订阅通知] {}: {}", key, jsonObject.toString());
+        redis.convertAndSend(key, jsonObject);
+    }
+
+    @Override
+    public void sendStreamPushRequestedMsg(MessageForPushChannel msg) {
+        String key = VideoManagerConstants.VM_MSG_STREAM_PUSH_REQUESTED;
+        logger.debug("[redis 推流被请求通知] {}: {}-{}", key, msg.getApp(), msg.getStream());
+        redis.convertAndSend(key, (JSONObject)JSON.toJSON(msg));
+    }
 }

+ 10 - 15
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@@ -5,14 +5,12 @@ import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
-import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
 import com.genersoft.iot.vmp.service.IGbStreamService;
 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.storager.dao.*;
 import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
 import com.genersoft.iot.vmp.utils.node.ForestNodeMerger;
@@ -40,9 +38,9 @@ import java.util.*;
  */
 @SuppressWarnings("rawtypes")
 @Component
-public class VideoManagerStoragerImpl implements IVideoManagerStorager {
+public class VideoManagerStorageImpl implements IVideoManagerStorage {
 
-	private final Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class);
+	private final Logger logger = LoggerFactory.getLogger(VideoManagerStorageImpl.class);
 
 	@Autowired
 	EventPublisher eventPublisher;
@@ -85,7 +83,6 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
 
 	@Autowired
     private PlatformCatalogMapper catalogMapper;
-;
 
 	@Autowired
     private PlatformGbStreamMapper platformGbStreamMapper;
@@ -96,13 +93,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
 	@Autowired
     private ParentPlatformMapper parentPlatformMapper;
 
-	@Autowired
-    private VideoStreamSessionManager streamSession;
-
-	@Autowired
-    private MediaServerMapper mediaServerMapper;
-
-	private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
 
 	/**
@@ -268,7 +259,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
 						}
 					}
 				}else {
-					stringBuilder.append(deviceChannel.getChannelId() + ",");
+					stringBuilder.append(deviceChannel.getChannelId()).append(",");
 				}
 			}
 			if (channels.size() > 0) {
@@ -286,7 +277,6 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
 			logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder);
 		}
 		try {
-//			int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
 			int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);
 			int limitCount = 300;
 			boolean result = cleanChannelsResult < 0;
@@ -1133,4 +1123,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
 	public List<ChannelSourceInfo> getChannelSource(String platformId, String gbId) {
 		return platformMapper.getChannelSource(platformId, gbId);
 	}
+
+	@Override
+	public void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude) {
+		deviceChannelMapper.updatePotion(deviceId, channelId, longitude, latitude);
+	}
 }

+ 6 - 6
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java

@@ -3,14 +3,12 @@ package com.genersoft.iot.vmp.vmanager.gb28181.MobilePosition;
 import java.util.List;
 import java.util.UUID;
 
-import javax.sip.message.Response;
-
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.github.pagehelper.util.StringUtil;
 
 import io.swagger.annotations.Api;
@@ -42,7 +40,7 @@ public class MobilePositionController {
     private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
     
 	@Autowired
 	private SIPCommander cmder;
@@ -161,9 +159,11 @@ public class MobilePositionController {
             interval = "5";
         }
         Device device = storager.queryVideoDevice(deviceId);
-
+        device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires));
+        device.setMobilePositionSubmissionInterval(Integer.parseInt(interval));
+        storager.updateDevice(device);
         String result = msg;
-        if (cmder.mobilePositionSubscribe(device, Integer.parseInt(expires), Integer.parseInt(interval))) {
+        if (cmder.mobilePositionSubscribe(device, null, null)) {
             result += ",成功";
         } else {
             result += ",失败";

+ 2 - 4
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java

@@ -7,14 +7,12 @@
 
 package com.genersoft.iot.vmp.vmanager.gb28181.device;
 
-import javax.sip.message.Response;
-
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -39,7 +37,7 @@ public class DeviceConfig {
     private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private SIPCommander cmder;

+ 2 - 4
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java

@@ -7,14 +7,12 @@
 
 package com.genersoft.iot.vmp.vmanager.gb28181.device;
 
-import javax.sip.message.Response;
-
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -40,7 +38,7 @@ public class DeviceControl {
     private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private SIPCommander cmder;

+ 29 - 3
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java

@@ -10,7 +10,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.service.IDeviceService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import com.github.pagehelper.PageInfo;
@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.context.request.async.DeferredResult;
 
 import java.util.List;
+import java.util.Set;
 import java.util.UUID;
 
 @Api(tags = "国标设备查询", value = "国标设备查询")
@@ -40,7 +41,7 @@ public class DeviceQuery {
 	private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
 	
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private IRedisCatchStorage redisCatchStorage;
@@ -213,7 +214,12 @@ public class DeviceQuery {
 		if (isSuccess) {
 			redisCatchStorage.clearCatchByDeviceId(deviceId);
 			// 停止此设备的订阅更新
-			dynamicTask.stop(deviceId);
+			Set<String> allKeys = dynamicTask.getAllKeys();
+			for (String key : allKeys) {
+				if (key.startsWith(deviceId)) {
+					dynamicTask.stop(key);
+				}
+			}
 			JSONObject json = new JSONObject();
 			json.put("deviceId", deviceId);
 			return new ResponseEntity<>(json.toString(),HttpStatus.OK);
@@ -321,18 +327,38 @@ public class DeviceQuery {
 			if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset());
 			if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId());
 
+			//  目录订阅相关的信息
 			if (device.getSubscribeCycleForCatalog() > 0) {
 				if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
+					deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
 					// 开启订阅
 					deviceService.addCatalogSubscribe(deviceInStore);
 				}
 			}else if (device.getSubscribeCycleForCatalog() == 0) {
 				if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
+					deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
 					// 取消订阅
 					deviceService.removeCatalogSubscribe(deviceInStore);
 				}
 			}
 
+			// 移动位置订阅相关的信息
+			if (device.getSubscribeCycleForMobilePosition() > 0) {
+				if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) {
+					deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval());
+					deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition());
+					// 开启订阅
+					deviceService.addMobilePositionSubscribe(deviceInStore);
+				}
+			}else if (device.getSubscribeCycleForMobilePosition() == 0) {
+				if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) {
+					// 取消订阅
+					deviceService.removeMobilePositionSubscribe(deviceInStore);
+				}
+			}
+
+			// TODO 报警订阅相关的信息
+
 			storager.updateDevice(device);
 			cmder.deviceInfoQuery(device);
 		}

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java

@@ -1,7 +1,7 @@
 package com.genersoft.iot.vmp.vmanager.gb28181.gbStream;
 
 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean.GbStreamParam;
 import com.genersoft.iot.vmp.service.IGbStreamService;
 import com.github.pagehelper.PageInfo;
@@ -27,7 +27,7 @@ public class GbStreamController {
     private IGbStreamService gbStreamService;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
 
     /**

+ 2 - 3
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java

@@ -4,13 +4,12 @@ import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.service.IStreamPushService;
 import com.genersoft.iot.vmp.service.IMediaService;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +26,7 @@ public class MediaController {
     private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private IStreamPushService streamPushService;

+ 6 - 7
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java

@@ -4,13 +4,13 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.DynamicTask;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 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.transmit.cmd.ISIPCommanderForPlatform;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 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;
@@ -29,7 +29,6 @@ import org.springframework.web.bind.annotation.*;
 import com.genersoft.iot.vmp.conf.SipConfig;
 
 import java.util.List;
-import java.util.Locale;
 
 /**
  * 级联平台管理
@@ -43,10 +42,10 @@ public class PlatformController {
     private final static Logger logger = LoggerFactory.getLogger(PlatformController.class);
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;
@@ -118,7 +117,7 @@ public class PlatformController {
         PageInfo<ParentPlatform> parentPlatformPageInfo = storager.queryParentPlatformList(page, count);
         if (parentPlatformPageInfo.getList().size() > 0) {
             for (ParentPlatform platform : parentPlatformPageInfo.getList()) {
-                platform.setGpsSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null);
+                platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null);
                 platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) != null);
             }
         }
@@ -305,7 +304,7 @@ public class PlatformController {
         storager.delCatalogByPlatformId(parentPlatform.getServerGBId());
         storager.delRelationByPlatformId(parentPlatform.getServerGBId());
         // 停止发送位置订阅定时任务
-        String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() +  "_MobilePosition_" + parentPlatform.getServerGBId();
+        String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() +  "_MobilePosition_" + parentPlatform.getServerGBId();
         dynamicTask.stop(key);
         // 删除缓存的订阅信息
         subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());

+ 2 - 4
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java

@@ -33,14 +33,12 @@ import org.springframework.web.bind.annotation.RestController;
 
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.springframework.web.context.request.async.DeferredResult;
 
 import java.util.List;
 import java.util.UUID;
 
-import javax.sip.message.Response;
-
 @Api(tags = "国标设备点播")
 @CrossOrigin
 @RestController
@@ -56,7 +54,7 @@ public class PlayController {
 	private VideoStreamSessionManager streamSession;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private IRedisCatchStorage redisCatchStorage;

+ 2 - 7
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java

@@ -2,11 +2,8 @@ package com.genersoft.iot.vmp.vmanager.gb28181.playback;
 
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
-import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 //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 com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.service.IPlayService;
 import io.swagger.annotations.Api;
@@ -28,11 +25,9 @@ import org.springframework.web.bind.annotation.RestController;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.springframework.web.context.request.async.DeferredResult;
 
-import java.util.UUID;
-
 @Api(tags = "视频回放")
 @CrossOrigin
 @RestController
@@ -45,7 +40,7 @@ public class PlaybackController {
 	private SIPCommander cmder;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private IRedisCatchStorage redisCatchStorage;

+ 2 - 4
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java

@@ -13,13 +13,11 @@ import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.context.request.async.DeferredResult;
 
-import javax.sip.message.Response;
-
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 
 import java.util.UUID;
 
@@ -35,7 +33,7 @@ public class PtzController {
 	private SIPCommander cmder;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private DeferredResultHolder resultHolder;

+ 2 - 5
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java

@@ -2,12 +2,9 @@ package com.genersoft.iot.vmp.vmanager.gb28181.record;
 
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
-import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.service.IPlayService;
-import com.genersoft.iot.vmp.service.bean.SSRCInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -28,7 +25,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 
 import java.util.UUID;
 
@@ -44,7 +41,7 @@ public class GBRecordController {
 	private SIPCommander cmder;
 
 	@Autowired
-	private IVideoManagerStorager storager;
+	private IVideoManagerStorage storager;
 
 	@Autowired
 	private DeferredResultHolder resultHolder;

+ 3 - 4
src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java

@@ -1,7 +1,6 @@
 package com.genersoft.iot.vmp.vmanager.log;
 
-import com.genersoft.iot.vmp.conf.UserSetup;
-import com.genersoft.iot.vmp.media.zlm.ZLMRunner;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.service.ILogService;
 import com.genersoft.iot.vmp.storager.dao.dto.LogDto;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
@@ -33,7 +32,7 @@ public class LogController {
     private ILogService logService;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
@@ -69,7 +68,7 @@ public class LogController {
         if (StringUtils.isEmpty(query)) query = null;
         if (StringUtils.isEmpty(startTime)) startTime = null;
         if (StringUtils.isEmpty(endTime)) endTime = null;
-        if (!userSetup.getLogInDatebase()) {
+        if (!userSetting.getLogInDatebase()) {
             logger.warn("自动记录日志功能已关闭,查询结果可能不完整。");
         }
 

+ 4 - 4
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java

@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.VManageBootstrap;
 import com.genersoft.iot.vmp.common.VersionPo;
 import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.conf.VersionInfo;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.service.IMediaServerService;
@@ -48,7 +48,7 @@ public class ServerController {
     SipConfig sipConfig;
 
     @Autowired
-    UserSetup userSetup;
+    UserSetting userSetting;
 
     @Value("${server.port}")
     private int serverPort;
@@ -232,14 +232,14 @@ public class ServerController {
         jsonObject.put("server.port", serverPort);
         if (StringUtils.isEmpty(type)) {
             jsonObject.put("sip", JSON.toJSON(sipConfig));
-            jsonObject.put("base", JSON.toJSON(userSetup));
+            jsonObject.put("base", JSON.toJSON(userSetting));
         }else {
             switch (type){
                 case "sip":
                     jsonObject.put("sip", sipConfig);
                     break;
                 case "base":
-                    jsonObject.put("base", userSetup);
+                    jsonObject.put("base", userSetting);
                     break;
                 default:
                     break;

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java

@@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.web.gb28181;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,7 +23,7 @@ public class ApiControlController {
     private SIPCommander cmder;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     /**
      * 设备控制 - 云台控制

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.github.pagehelper.PageInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -25,7 +25,7 @@ public class ApiDeviceController {
     private final static Logger logger = LoggerFactory.getLogger(ApiDeviceController.class);
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     // @Autowired
     // private SIPCommander cmder;

+ 5 - 6
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java

@@ -2,15 +2,14 @@ package com.genersoft.iot.vmp.web.gb28181;
 
 import com.alibaba.fastjson.JSONObject;
 import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.conf.UserSetup;
+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.transmit.callback.DeferredResultHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import com.genersoft.iot.vmp.service.IPlayService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,10 +32,10 @@ public class ApiStreamController {
     private SIPCommander cmder;
 
     @Autowired
-    private IVideoManagerStorager storager;
+    private IVideoManagerStorage storager;
 
     @Autowired
-    private UserSetup userSetup;
+    private UserSetting userSetting;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;
@@ -69,7 +68,7 @@ public class ApiStreamController {
                                              @RequestParam(required = false)String timeout
 
     ){
-        DeferredResult<JSONObject> resultDeferredResult = new DeferredResult<>(userSetup.getPlayTimeout() + 10);
+        DeferredResult<JSONObject> resultDeferredResult = new DeferredResult<>(userSetting.getPlayTimeout() + 10);
         Device device = storager.queryVideoDevice(serial);
         if (device == null ) {
             JSONObject result = new JSONObject();

+ 2 - 0
src/main/resources/all-application.yml

@@ -170,6 +170,8 @@ user-settings:
     save-position-history: false
     # 点播等待超时时间,单位:毫秒
     play-timeout: 3000
+    # 上级点播等待超时时间,单位:毫秒
+    platform-play-timeout: 60000
     # 是否开启接口鉴权
     interface-authentication: true
     # 自动配置redis 可以过期事件

+ 6 - 6
src/main/resources/logback-spring-local.xml

@@ -80,12 +80,12 @@
 		<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="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>-->
 
 	<!--记录druid-sql的记录-->
 	<logger name="druid.sql.Statement" level="debug" additivity="true">

+ 2 - 2
web_src/src/components/ParentPlatformList.vue

@@ -47,8 +47,8 @@
               <i v-if="!scope.row.alarmSubscribe" style="font-size: 20px" title="报警订阅" class="iconfont icon-gbaojings subscribe-off " ></i>
               <i v-if="scope.row.catalogSubscribe" title="目录订阅"  class="iconfont icon-gjichus subscribe-on" ></i>
               <i v-if="!scope.row.catalogSubscribe" title="目录订阅" class="iconfont icon-gjichus subscribe-off" ></i>
-              <i v-if="scope.row.gpsSubscribe" title="位置订阅" class="iconfont icon-gxunjians subscribe-on" ></i>
-              <i v-if="!scope.row.gpsSubscribe" title="位置订阅" class="iconfont icon-gxunjians subscribe-off" ></i>
+              <i v-if="scope.row.mobilePositionSubscribe" title="位置订阅" class="iconfont icon-gxunjians subscribe-on" ></i>
+              <i v-if="!scope.row.mobilePositionSubscribe" title="位置订阅" class="iconfont icon-gxunjians subscribe-off" ></i>
             </template>
           </el-table-column>
 

+ 6 - 0
web_src/src/components/dialog/deviceEdit.vue

@@ -39,6 +39,12 @@
           <el-form-item label="目录订阅周期(0为停用订阅)" prop="subscribeCycleForCatalog" >
             <el-input v-model="form.subscribeCycleForCatalog" clearable ></el-input>
           </el-form-item>
+          <el-form-item label="移动位置订阅周期(0为停用订阅)" prop="subscribeCycleForCatalog" >
+            <el-input v-model="form.subscribeCycleForMobilePosition" clearable ></el-input>
+          </el-form-item>
+          <el-form-item label="移动位置报送间隔" prop="subscribeCycleForCatalog" >
+            <el-input v-model="form.mobilePositionSubmissionInterval" clearable ></el-input>
+          </el-form-item>
           <el-form-item>
             <div style="float: right;">
               <el-button type="primary" @click="onSubmit" >确认</el-button>