Browse Source

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

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

8
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;

18
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_"; public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_";
//************************** redis 消息********************************* //************************** redis 消息*********************************
// 流变化的通知
public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_"; 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_"; public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";

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

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

2
src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java

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

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

5
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.bean.ParentPlatformCatch;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; 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.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.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
@ -22,7 +21,7 @@ import java.util.List;
public class SipPlatformRunner implements CommandLineRunner { public class SipPlatformRunner implements CommandLineRunner {
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;

16
src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java → src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java

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

9
src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java

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

8
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java

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

4
src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java

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

40
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java

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

12
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java

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

12
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java

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

6
src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java

@ -1,6 +1,6 @@
package com.genersoft.iot.vmp.gb28181.event; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -19,10 +19,10 @@ public class DeviceOffLineDetector {
private RedisUtil redis; private RedisUtil redis;
@Autowired @Autowired
private UserSetup userSetup; private UserSetting userSetting;
public boolean isOnline(String deviceId) { 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); return redis.hasKey(key);
} }
} }

35
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java

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

15
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java

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

13
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java

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

12
src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java

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

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

4
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.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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); private final static Logger logger = LoggerFactory.getLogger(PlatformCycleRegisterEventLister.class);
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private ISIPCommanderForPlatform sipCommanderFroPlatform; private ISIPCommanderForPlatform sipCommanderFroPlatform;

4
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.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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); private final static Logger logger = LoggerFactory.getLogger(PlatformNotRegisterEventLister.class);
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@Autowired @Autowired

10
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.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -20,13 +20,13 @@ public class SubscribeListenerForPlatform extends RedisKeyExpirationEventMessage
private Logger logger = LoggerFactory.getLogger(SubscribeListenerForPlatform.class); private Logger logger = LoggerFactory.getLogger(SubscribeListenerForPlatform.class);
@Autowired @Autowired
private UserSetup userSetup; private UserSetting userSetting;
@Autowired @Autowired
private DynamicTask dynamicTask; private DynamicTask dynamicTask;
public SubscribeListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) { public SubscribeListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
super(listenerContainer, userSetup); super(listenerContainer, userSetting);
} }
@ -41,7 +41,7 @@ public class SubscribeListenerForPlatform extends RedisKeyExpirationEventMessage
String expiredKey = message.toString(); String expiredKey = message.toString();
logger.debug(expiredKey); 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)) { if (expiredKey.startsWith(PLATFORM_KEEPLIVEKEY_PREFIX)) {
// 取消定时任务 // 取消定时任务
dynamicTask.stop(expiredKey); dynamicTask.stop(expiredKey);

13
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.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.SipConfig; 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.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.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; 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.IGbStreamService;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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); private final static Logger logger = LoggerFactory.getLogger(CatalogEventLister.class);
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@Autowired @Autowired
@ -47,7 +44,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
private SipConfig config; private SipConfig config;
@Autowired @Autowired
private UserSetup userSetup; private UserSetting userSetting;
@Autowired @Autowired
private IGbStreamService gbStreamService; private IGbStreamService gbStreamService;
@ -64,7 +61,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
if (event.getPlatformId() != null) { if (event.getPlatformId() != null) {
parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
if (parentPlatform != null && !parentPlatform.isStatus())return; 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 = redisCatchStorage.getSubscribe(key);
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());

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

18
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java

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

10
src/main/java/com/genersoft/iot/vmp/gb28181/task/GPSSubscribeTask.java

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.task; 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.GbStream;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; 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.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.text.SimpleDateFormat;
import java.util.List; import java.util.List;
@ -15,7 +16,7 @@ import java.util.List;
public class GPSSubscribeTask implements Runnable{ public class GPSSubscribeTask implements Runnable{
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
private ISIPCommanderForPlatform sipCommanderForPlatform; private ISIPCommanderForPlatform sipCommanderForPlatform;
private SubscribeHolder subscribeHolder; private SubscribeHolder subscribeHolder;
private String platformId; private String platformId;
@ -24,7 +25,7 @@ public class GPSSubscribeTask implements Runnable{
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 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.redisCatchStorage = redisCatchStorage;
this.storager = storager; this.storager = storager;
this.platformId = platformId; this.platformId = platformId;
@ -48,7 +49,6 @@ public class GPSSubscribeTask implements Runnable{
for (GbStream gbStream : gbStreams) { for (GbStream gbStream : gbStreams) {
String gbId = gbStream.getGbId(); String gbId = gbStream.getGbId();
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
if (gbStream.isStatus()) {
if (gpsMsgInfo != null) { if (gpsMsgInfo != null) {
// 发送GPS消息 // 发送GPS消息
sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe);
@ -62,8 +62,6 @@ public class GPSSubscribeTask implements Runnable{
sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe);
} }
} }
}
} }
} }
} }

4
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java

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

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

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(); : udpSipProvider.getNewCallId();
callIdHeader.setCallId(subscribeInfo.getCallId()); callIdHeader.setCallId(subscribeInfo.getCallId());
//
sendNotify(parentPlatform, deviceStatusXml.toString(), subscribeInfo, eventResult -> { sendNotify(parentPlatform, deviceStatusXml.toString(), subscribeInfo, eventResult -> {
logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg);
}, null); }, null);

21
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.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.Device; 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.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; 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.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService; 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.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.utils.SerializeUtils;
import gov.nist.javax.sip.stack.SIPDialog; import gov.nist.javax.sip.stack.SIPDialog;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -50,7 +51,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private ZLMRTPServerFactory zlmrtpServerFactory; private ZLMRTPServerFactory zlmrtpServerFactory;
@ -99,10 +100,20 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
redisCatchStorage.deleteSendRTPServer(platformGbId, channelId, callIdHeader.getCallId(), null); redisCatchStorage.deleteSendRTPServer(platformGbId, channelId, callIdHeader.getCallId(), null);
int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId); int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
if (totalReaderCount <= 0) { if (totalReaderCount <= 0) {
logger.info("收到bye: {}无其它观看者,通知设备停止推流", streamId); logger.info("收到bye: {} 无其它观看者,通知设备停止推流", streamId);
if (sendRtpItem.isPlay()) { if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) {
cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId, streamId, null); 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);
}
} }
} }
// 可能是设备主动停止 // 可能是设备主动停止

165
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; package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; 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.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; 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.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.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IPlayService; 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.service.bean.SSRCInfo;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.utils.SerializeUtils;
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
import gov.nist.javax.sdp.TimeDescriptionImpl; import gov.nist.javax.sdp.TimeDescriptionImpl;
import gov.nist.javax.sdp.fields.TimeField; import gov.nist.javax.sdp.fields.TimeField;
import gov.nist.javax.sip.address.AddressImpl; import javafx.application.Platform;
import gov.nist.javax.sip.address.SipUri;
import gov.nist.javax.sip.header.Subject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
@ -37,20 +34,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.sdp.*; import javax.sdp.*;
import javax.sip.InvalidArgumentException; import javax.sip.*;
import javax.sip.RequestEvent;
import javax.sip.ServerTransaction;
import javax.sip.SipException;
import javax.sip.address.SipURI; import javax.sip.address.SipURI;
import javax.sip.header.CallIdHeader; import javax.sip.header.CallIdHeader;
import javax.sip.header.FromHeader;
import javax.sip.header.Header;
import javax.sip.message.Request; import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Vector; import java.util.Vector;
/** /**
@ -68,7 +59,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
private SIPCommanderFroPlatform cmderFroPlatform; private SIPCommanderFroPlatform cmderFroPlatform;
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@ -97,6 +88,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
@Autowired @Autowired
private VideoStreamSessionManager sessionManager; private VideoStreamSessionManager sessionManager;
@Autowired
private UserSetting userSetting;
@Autowired
private ZLMMediaListManager mediaListManager;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
@ -153,12 +150,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
responseAck(evt, Response.GONE); responseAck(evt, Response.GONE);
return; 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,呼叫转接中 responseAck(evt, Response.CALL_IS_BEING_FORWARDED); // 通道存在,发181,呼叫转接中
}else if (catalog != null) { }else if (catalog != null) {
responseAck(evt, Response.BAD_REQUEST, "catalog channel can not play"); // 目录不支持点播 responseAck(evt, Response.BAD_REQUEST, "catalog channel can not play"); // 目录不支持点播
@ -273,13 +264,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
return; return;
} }
sendRtpItem.setCallId(callIdHeader.getCallId()); sendRtpItem.setCallId(callIdHeader.getCallId());
sendRtpItem.setPlay("Play".equals(sessionName)); sendRtpItem.setPlayType("Play".equals(sessionName)?InviteStreamType.PLAY:InviteStreamType.PLAYBACK);
byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog()); byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog());
sendRtpItem.setDialog(dialogByteArray); sendRtpItem.setDialog(dialogByteArray);
byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction()); byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction());
sendRtpItem.setTransaction(transactionByteArray); sendRtpItem.setTransaction(transactionByteArray);
Long finalStartTime = startTime; Long finalStartTime = startTime;
Long finalStopTime = stopTime; Long finalStopTime = stopTime;
ZLMHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON)->{ ZLMHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON)->{
@ -315,7 +304,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), ssrc); mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), ssrc);
// 回复bye // 回复bye
cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId()); cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId());
}, 60); }, 60*1000);
responseSdpAck(evt, content.toString(), platform); responseSdpAck(evt, content.toString(), platform);
} catch (SipException e) { } catch (SipException e) {
@ -340,7 +329,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
}); });
sendRtpItem.setApp("rtp"); sendRtpItem.setApp("rtp");
if ("Playback".equals(sessionName)) { if ("Playback".equals(sessionName)) {
sendRtpItem.setPlay(false); sendRtpItem.setPlayType(InviteStreamType.PLAYBACK);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, true); SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, true);
sendRtpItem.setStreamId(ssrcInfo.getStream()); sendRtpItem.setStreamId(ssrcInfo.getStream());
// 写入redis, 超时时回复 // 写入redis, 超时时回复
@ -370,7 +359,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
} }
}); });
}else { }else {
sendRtpItem.setPlay(true); sendRtpItem.setPlayType(InviteStreamType.PLAY);
SsrcTransaction playTransaction = sessionManager.getSsrcTransaction(device.getDeviceId(), channelId, "play", null); SsrcTransaction playTransaction = sessionManager.getSsrcTransaction(device.getDeviceId(), channelId, "play", null);
if (playTransaction != null) { if (playTransaction != null) {
Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, "rtp", playTransaction.getStream()); Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, "rtp", playTransaction.getStream());
@ -401,19 +390,93 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
} }
} }
}else if (gbStream != null) { }else if (gbStream != null) {
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);
});
}
}else {
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
gbStream.getApp(), gbStream.getStream(), channelId, gbStream.getApp(), gbStream.getStream(), channelId,
mediaTransmissionTCP); mediaTransmissionTCP);
if (tcpActive != null) {
sendRtpItem.setTcpActive(tcpActive);
}
if (sendRtpItem == null) { if (sendRtpItem == null) {
logger.warn("服务器端口资源不足"); logger.warn("服务器端口资源不足");
responseAck(evt, Response.BUSY_HERE); responseAck(evt, Response.BUSY_HERE);
return; return;
} }
if (tcpActive != null) {
sendRtpItem.setTcpActive(tcpActive);
}
sendRtpItem.setPlayType(InviteStreamType.PUSH);
// 写入redis, 超时时回复 // 写入redis, 超时时回复
sendRtpItem.setStatus(1); sendRtpItem.setStatus(1);
sendRtpItem.setCallId(callIdHeader.getCallId()); sendRtpItem.setCallId(callIdHeader.getCallId());
@ -422,9 +485,30 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction()); byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction());
sendRtpItem.setTransaction(transactionByteArray); sendRtpItem.setTransaction(transactionByteArray);
redisCatchStorage.updateSendRTPSever(sendRtpItem); redisCatchStorage.updateSendRTPSever(sendRtpItem);
sendStreamAck(mediaServerItem, sendRtpItem, platform, evt);
}
}
}
} catch (SipException | InvalidArgumentException | ParseException e) {
e.printStackTrace();
logger.warn("sdp解析错误");
e.printStackTrace();
} catch (SdpParseException e) {
e.printStackTrace();
} catch (SdpException e) {
e.printStackTrace();
}
}
public void sendStreamAck(MediaServerItem mediaServerItem, SendRtpItem sendRtpItem, ParentPlatform platform, RequestEvent evt){
StringBuffer content = new StringBuffer(200); StringBuffer content = new StringBuffer(200);
content.append("v=0\r\n"); content.append("v=0\r\n");
content.append("o="+ channelId +" 0 0 IN IP4 "+mediaServerItem.getSdpIp()+"\r\n"); content.append("o="+ sendRtpItem.getChannelId() +" 0 0 IN IP4 "+ mediaServerItem.getSdpIp()+"\r\n");
content.append("s=Play\r\n"); content.append("s=Play\r\n");
content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n"); content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
content.append("t=0 0\r\n"); content.append("t=0 0\r\n");
@ -439,7 +523,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
content.append("a=setup:passive\r\n"); content.append("a=setup:passive\r\n");
} }
} }
content.append("y="+ ssrc + "\r\n"); content.append("y="+ sendRtpItem.getSsrc() + "\r\n");
content.append("f=\r\n"); content.append("f=\r\n");
try { try {
@ -453,19 +537,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
} }
} }
}
} catch (SipException | InvalidArgumentException | ParseException e) {
e.printStackTrace();
logger.warn("sdp解析错误");
e.printStackTrace();
} catch (SdpParseException e) {
e.printStackTrace();
} catch (SdpException e) {
e.printStackTrace();
}
}
public void inviteFromDeviceHandle(RequestEvent evt, String requesterId) throws InvalidArgumentException, ParseException, SipException, SdpException { public void inviteFromDeviceHandle(RequestEvent evt, String requesterId) throws InvalidArgumentException, ParseException, SipException, SdpException {
// 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备) // 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备)

40
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; 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.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.SipConfig; 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.bean.*;
import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; 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.SipUtils;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.GpsUtil;
import com.genersoft.iot.vmp.utils.redis.RedisUtil; import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
@ -46,10 +47,10 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
private final static Logger logger = LoggerFactory.getLogger(NotifyRequestProcessor.class); private final static Logger logger = LoggerFactory.getLogger(NotifyRequestProcessor.class);
@Autowired @Autowired
private UserSetup userSetup; private UserSetting userSetting;
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private EventPublisher eventPublisher; private EventPublisher eventPublisher;
@ -109,11 +110,15 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
*/ */
private void processNotifyMobilePosition(RequestEvent evt) { private void processNotifyMobilePosition(RequestEvent evt) {
try { try {
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
// 回复 200 OK // 回复 200 OK
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
MobilePosition mobilePosition = new MobilePosition(); MobilePosition mobilePosition = new MobilePosition();
Element deviceIdElement = rootElement.element("DeviceID"); Element deviceIdElement = rootElement.element("DeviceID");
String deviceId = deviceIdElement.getTextTrim().toString(); String channelId = deviceIdElement.getTextTrim().toString();
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(deviceId);
if (device != null) { if (device != null) {
if (!StringUtils.isEmpty(device.getName())) { if (!StringUtils.isEmpty(device.getName())) {
@ -121,7 +126,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
} }
} }
mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID")); 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.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude")));
mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude"))); mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude")));
if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) { if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) {
@ -140,16 +147,27 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
mobilePosition.setAltitude(0.0); mobilePosition.setAltitude(0.0);
} }
mobilePosition.setReportSource("Mobile Position"); mobilePosition.setReportSource("Mobile Position");
BaiduPoint bp = new BaiduPoint(); BaiduPoint bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat()); logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat());
mobilePosition.setGeodeticSystem("BD-09"); mobilePosition.setGeodeticSystem("BD-09");
mobilePosition.setCnLng(bp.getBdLng()); mobilePosition.setCnLng(bp.getBdLng());
mobilePosition.setCnLat(bp.getBdLat()); mobilePosition.setCnLat(bp.getBdLat());
if (!userSetup.getSavePositionHistory()) { if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(deviceId); storager.clearMobilePositionsByDeviceId(deviceId);
} }
storager.insertMobilePosition(mobilePosition); 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); responseAck(evt, Response.OK);
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
e.printStackTrace(); e.printStackTrace();
@ -209,7 +227,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
mobilePosition.setGeodeticSystem("BD-09"); mobilePosition.setGeodeticSystem("BD-09");
mobilePosition.setCnLng(bp.getBdLng()); mobilePosition.setCnLng(bp.getBdLng());
mobilePosition.setCnLat(bp.getBdLat()); mobilePosition.setCnLat(bp.getBdLat());
if (!userSetup.getSavePositionHistory()) { if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(deviceId); storager.clearMobilePositionsByDeviceId(deviceId);
} }
storager.insertMobilePosition(mobilePosition); storager.insertMobilePosition(mobilePosition);
@ -321,7 +339,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
public void setCmder(SIPCommander cmder) { public void setCmder(SIPCommander cmder) {
} }
public void setStorager(IVideoManagerStorager storager) { public void setStorager(IVideoManagerStorage storager) {
this.storager = storager; this.storager = storager;
} }

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

25
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.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask; 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.CmdType;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; 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.SipUtils;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.SipProviderImpl; import gov.nist.javax.sip.SipProviderImpl;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.Element; import org.dom4j.Element;
@ -30,7 +29,6 @@ import org.springframework.stereotype.Component;
import javax.sip.*; import javax.sip.*;
import javax.sip.header.ExpiresHeader; import javax.sip.header.ExpiresHeader;
import javax.sip.header.ToHeader;
import javax.sip.message.Request; import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import java.text.ParseException; import java.text.ParseException;
@ -54,7 +52,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
private ISIPCommanderForPlatform sipCommanderForPlatform; private ISIPCommanderForPlatform sipCommanderForPlatform;
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Lazy @Lazy
@Autowired @Autowired
@ -70,7 +68,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
private DynamicTask dynamicTask; private DynamicTask dynamicTask;
@Autowired @Autowired
private UserSetup userSetup; private UserSetting userSetting;
@Autowired @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 platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
String deviceID = XmlUtil.getText(rootElement, "DeviceID"); String deviceID = XmlUtil.getText(rootElement, "DeviceID");
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
SubscribeInfo subscribeInfo = new SubscribeInfo(evt, 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 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); logger.info("接收到{}的MobilePosition订阅", platformId);
StringBuilder resultXml = new StringBuilder(200); StringBuilder resultXml = new StringBuilder(200);
resultXml.append("<?xml version=\"1.0\" ?>\r\n") resultXml.append("<?xml version=\"1.0\" ?>\r\n")
@ -193,7 +200,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
subscribeInfo.setDialog(dialog); subscribeInfo.setDialog(dialog);
} }
String sn = XmlUtil.getText(rootElement, "SN"); 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); logger.info("接收到{}的Catalog订阅", platformId);
StringBuilder resultXml = new StringBuilder(200); StringBuilder resultXml = new StringBuilder(200);
resultXml.append("<?xml version=\"1.0\" ?>\r\n") resultXml.append("<?xml version=\"1.0\" ?>\r\n")

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

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

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

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

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

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

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

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

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

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

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

4
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.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; 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.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.DocumentException;
import org.dom4j.Element; import org.dom4j.Element;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -39,7 +39,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
private ResponseMessageHandler responseMessageHandler; private ResponseMessageHandler responseMessageHandler;
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private DeferredResultHolder deferredResultHolder; private DeferredResultHolder deferredResultHolder;

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

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

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

35
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java

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

6
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);
}

11
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.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener; 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.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
@ -12,7 +12,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -33,13 +32,13 @@ public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi
private ZLMRESTfulUtils zlmresTfulUtils; private ZLMRESTfulUtils zlmresTfulUtils;
@Autowired @Autowired
private UserSetup userSetup; private UserSetting userSetting;
@Autowired @Autowired
private IMediaServerService mediaServerService; private IMediaServerService mediaServerService;
public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) { public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) {
super(listenerContainer, userSetup); super(listenerContainer, userSetting);
} }
@ -52,7 +51,7 @@ public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi
public void onMessage(Message message, byte[] pattern) { public void onMessage(Message message, byte[] pattern) {
// 获取失效的key // 获取失效的key
String expiredKey = message.toString(); 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)){ if(!expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){
return; return;
} }

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

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

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

4
src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java

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

112
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
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);
});
}
}

43
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.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.bean.CatalogSubscribeTask; import com.genersoft.iot.vmp.service.bean.CatalogSubscribeTask;
import com.genersoft.iot.vmp.service.bean.MobilePositionSubscribeTask;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -20,7 +21,6 @@ public class DeviceServiceImpl implements IDeviceService {
@Autowired @Autowired
private DynamicTask dynamicTask; private DynamicTask dynamicTask;
;
@Autowired @Autowired
private ISIPCommander sipCommander; private ISIPCommander sipCommander;
@ -30,9 +30,9 @@ public class DeviceServiceImpl implements IDeviceService {
if (device == null || device.getSubscribeCycleForCatalog() < 0) { if (device == null || device.getSubscribeCycleForCatalog() < 0) {
return false; 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()); logger.info("[添加目录订阅] 设备{}", device.getDeviceId());
// 添加目录订阅 // 添加目录订阅
@ -42,7 +42,7 @@ public class DeviceServiceImpl implements IDeviceService {
int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog(); int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog();
// 设置最小值为30 // 设置最小值为30
subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30); subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30);
dynamicTask.startCron(device.getDeviceId(), catalogSubscribeTask, subscribeCycleForCatalog - 5); dynamicTask.startCron(device.getDeviceId() + "catalog", catalogSubscribeTask, subscribeCycleForCatalog - 5);
return true; return true;
} }
@ -52,9 +52,42 @@ public class DeviceServiceImpl implements IDeviceService {
return false; return false;
} }
logger.info("移除目录订阅: {}", device.getDeviceId()); logger.info("移除目录订阅: {}", device.getDeviceId());
dynamicTask.stop(device.getDeviceId()); dynamicTask.stop(device.getDeviceId() + "catalog");
device.setSubscribeCycleForCatalog(0); device.setSubscribeCycleForCatalog(0);
sipCommander.catalogSubscribe(device, null, null); sipCommander.catalogSubscribe(device, null, null);
return true; 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;
}
} }

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

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

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

2
src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java

@ -20,7 +20,7 @@ public class RedisGPSMsgListener implements MessageListener {
@Override @Override
public void onMessage(Message message, byte[] bytes) { 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); GPSMsgInfo gpsMsgInfo = JSON.parseObject(message.getBody(), GPSMsgInfo.class);
redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo);
} }

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

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

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

5
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java → src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java

@ -1,7 +1,6 @@
package com.genersoft.iot.vmp.storager; package com.genersoft.iot.vmp.storager;
import com.genersoft.iot.vmp.gb28181.bean.*; 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.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
@ -18,7 +17,7 @@ import java.util.List;
* @date: 2020年5月6日 下午2:14:31 * @date: 2020年5月6日 下午2:14:31
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public interface IVideoManagerStorager { public interface IVideoManagerStorage {
/** /**
* 根据设备ID判断设备是否存在 * 根据设备ID判断设备是否存在
@ -478,4 +477,6 @@ public interface IVideoManagerStorager {
PlatformCatalog queryDefaultCatalogInPlatform(String platformId); PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId); List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude);
} }

5
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 == true' > AND dc.status=1</if> " +
" <if test='online == false' > AND dc.status=0</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 == 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 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> " + " <if test='catalogId != null ' > AND pgc.platformId = #{platformId} and pgc.catalogId=#{catalogId} </if> " +
" ORDER BY dc.deviceId, dc.channelId ASC" + " ORDER BY dc.deviceId, dc.channelId ASC" +
@ -270,4 +270,7 @@ public interface DeviceChannelMapper {
" where deviceId = #{deviceId} " + " where deviceId = #{deviceId} " +
" and channelId = #{channelId}") " and channelId = #{channelId}")
int updateChannelSubCount(String deviceId, String 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
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java

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

154
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java

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

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

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

6
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java

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

6
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java

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

32
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.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.DeviceChannelTree;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
@Api(tags = "国标设备查询", value = "国标设备查询") @Api(tags = "国标设备查询", value = "国标设备查询")
@ -40,7 +41,7 @@ public class DeviceQuery {
private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class); private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@ -213,7 +214,12 @@ public class DeviceQuery {
if (isSuccess) { if (isSuccess) {
redisCatchStorage.clearCatchByDeviceId(deviceId); 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(); JSONObject json = new JSONObject();
json.put("deviceId", deviceId); json.put("deviceId", deviceId);
return new ResponseEntity<>(json.toString(),HttpStatus.OK); 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.getCharset())) deviceInStore.setCharset(device.getCharset());
if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId()); if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId());
// 目录订阅相关的信息
if (device.getSubscribeCycleForCatalog() > 0) { if (device.getSubscribeCycleForCatalog() > 0) {
if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) { if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 开启订阅 // 开启订阅
deviceService.addCatalogSubscribe(deviceInStore); deviceService.addCatalogSubscribe(deviceInStore);
} }
}else if (device.getSubscribeCycleForCatalog() == 0) { }else if (device.getSubscribeCycleForCatalog() == 0) {
if (deviceInStore.getSubscribeCycleForCatalog() != 0) { if (deviceInStore.getSubscribeCycleForCatalog() != 0) {
deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
// 取消订阅 // 取消订阅
deviceService.removeCatalogSubscribe(deviceInStore); 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); storager.updateDevice(device);
cmder.deviceInfoQuery(device); cmder.deviceInfoQuery(device);
} }

4
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java

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

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

13
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.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask; 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.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 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.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam; 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 com.genersoft.iot.vmp.conf.SipConfig;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* 级联平台管理 * 级联平台管理
@ -43,10 +42,10 @@ public class PlatformController {
private final static Logger logger = LoggerFactory.getLogger(PlatformController.class); private final static Logger logger = LoggerFactory.getLogger(PlatformController.class);
@Autowired @Autowired
private UserSetup userSetup; private UserSetting userSetting;
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@ -118,7 +117,7 @@ public class PlatformController {
PageInfo<ParentPlatform> parentPlatformPageInfo = storager.queryParentPlatformList(page, count); PageInfo<ParentPlatform> parentPlatformPageInfo = storager.queryParentPlatformList(page, count);
if (parentPlatformPageInfo.getList().size() > 0) { if (parentPlatformPageInfo.getList().size() > 0) {
for (ParentPlatform platform : parentPlatformPageInfo.getList()) { 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); platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) != null);
} }
} }
@ -305,7 +304,7 @@ public class PlatformController {
storager.delCatalogByPlatformId(parentPlatform.getServerGBId()); storager.delCatalogByPlatformId(parentPlatform.getServerGBId());
storager.delRelationByPlatformId(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); dynamicTask.stop(key);
// 删除缓存的订阅信息 // 删除缓存的订阅信息
subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());

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

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

6
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.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; 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.bean.Device;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; 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.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; 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; import java.util.UUID;
@ -35,7 +33,7 @@ public class PtzController {
private SIPCommander cmder; private SIPCommander cmder;
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private DeferredResultHolder resultHolder; private DeferredResultHolder resultHolder;

7
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.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo; 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.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.IMediaServerService;
import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; 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.bean.RecordInfo;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; 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.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import java.util.UUID; import java.util.UUID;
@ -44,7 +41,7 @@ public class GBRecordController {
private SIPCommander cmder; private SIPCommander cmder;
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorage storager;
@Autowired @Autowired
private DeferredResultHolder resultHolder; private DeferredResultHolder resultHolder;

7
src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java

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

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

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

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

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

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

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

12
src/main/resources/logback-spring-local.xml

@ -80,12 +80,12 @@
<appender-ref ref="RollingFileError" /> <appender-ref ref="RollingFileError" />
</root> </root>
<logger name="com.genersoft.iot.vmp.storager.dao" level="INFO"> <!-- <logger name="com.genersoft.iot.vmp.storager.dao" level="INFO">-->
<appender-ref ref="STDOUT"/> <!-- <appender-ref ref="STDOUT"/>-->
</logger> <!-- </logger>-->
<logger name="com.genersoft.iot.vmp.gb28181" level="INFO"> <!-- <logger name="com.genersoft.iot.vmp.gb28181" level="INFO">-->
<appender-ref ref="STDOUT"/> <!-- <appender-ref ref="STDOUT"/>-->
</logger> <!-- </logger>-->
<!--记录druid-sql的记录--> <!--记录druid-sql的记录-->
<logger name="druid.sql.Statement" level="debug" additivity="true"> <logger name="druid.sql.Statement" level="debug" additivity="true">

4
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.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-on" ></i>
<i v-if="!scope.row.catalogSubscribe" title="目录订阅" class="iconfont icon-gjichus subscribe-off" ></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.mobilePositionSubscribe" 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-off" ></i>
</template> </template>
</el-table-column> </el-table-column>

6
web_src/src/components/dialog/deviceEdit.vue

@ -39,6 +39,12 @@
<el-form-item label="目录订阅周期(0为停用订阅)" prop="subscribeCycleForCatalog" > <el-form-item label="目录订阅周期(0为停用订阅)" prop="subscribeCycleForCatalog" >
<el-input v-model="form.subscribeCycleForCatalog" clearable ></el-input> <el-input v-model="form.subscribeCycleForCatalog" clearable ></el-input>
</el-form-item> </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> <el-form-item>
<div style="float: right;"> <div style="float: right;">
<el-button type="primary" @click="onSubmit" >确认</el-button> <el-button type="primary" @click="onSubmit" >确认</el-button>

Loading…
Cancel
Save