Commit bfaa519e49c7bc3a09f398bd903275f4d59659db

Authored by hotcoffie
Committed by GitHub
2 parents c592740e c286ecb4

Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0

Showing 61 changed files with 597 additions and 394 deletions
src/main/java/com/genersoft/iot/vmp/common/ApiSaveConstant.java
... ... @@ -38,10 +38,14 @@ public class ApiSaveConstant {
38 38 }
39 39 break;
40 40 case "query":
41   - if (keyItemArray.length <= 5) return null;
  41 + if (keyItemArray.length <= 5) {
  42 + return null;
  43 + }
42 44 switch (keyItemArray[4]) {
43 45 case "devices":
44   - if (keyItemArray.length < 7) return null;
  46 + if (keyItemArray.length < 7) {
  47 + return null;
  48 + }
45 49 switch (keyItemArray[6]) {
46 50 case "sync":
47 51 return "[设备查询] 同步设备通道";
... ...
src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java
... ... @@ -7,6 +7,10 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
7 7  
8 8 import java.util.concurrent.ThreadPoolExecutor;
9 9  
  10 +/**
  11 + * ThreadPoolTask 配置类
  12 + * @author lin
  13 + */
10 14 @Configuration
11 15 @EnableAsync(proxyTargetClass = true)
12 16 public class ThreadPoolTaskConfig {
... ... @@ -40,6 +44,10 @@ public class ThreadPoolTaskConfig {
40 44 */
41 45 private static final String threadNamePrefix = "wvp-";
42 46  
  47 + /**
  48 + *
  49 + * @return
  50 + */
43 51 @Bean("taskExecutor") // bean的名称,默认为首字母小写的方法名
44 52 public ThreadPoolTaskExecutor taskExecutor() {
45 53 ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
... ...
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
1 1 package com.genersoft.iot.vmp.conf;
2 2  
  3 +import io.swagger.models.auth.In;
3 4 import org.springframework.boot.context.properties.ConfigurationProperties;
4 5 import org.springframework.stereotype.Component;
5 6  
... ... @@ -19,7 +20,7 @@ public class UserSetting {
19 20  
20 21 private Boolean seniorSdp = Boolean.FALSE;
21 22  
22   - private Long playTimeout = 18000L;
  23 + private Integer playTimeout = 18000;
23 24  
24 25 private int platformPlayTimeout = 60000;
25 26  
... ... @@ -55,7 +56,7 @@ public class UserSetting {
55 56 return seniorSdp;
56 57 }
57 58  
58   - public Long getPlayTimeout() {
  59 + public Integer getPlayTimeout() {
59 60 return playTimeout;
60 61 }
61 62  
... ... @@ -83,7 +84,7 @@ public class UserSetting {
83 84 this.seniorSdp = seniorSdp;
84 85 }
85 86  
86   - public void setPlayTimeout(Long playTimeout) {
  87 + public void setPlayTimeout(Integer playTimeout) {
87 88 this.playTimeout = playTimeout;
88 89 }
89 90  
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
... ... @@ -8,6 +8,7 @@ import org.slf4j.Logger;
8 8 import org.slf4j.LoggerFactory;
9 9 import org.springframework.beans.factory.annotation.Autowired;
10 10 import org.springframework.context.annotation.Bean;
  11 +import org.springframework.context.annotation.Configuration;
11 12 import org.springframework.context.annotation.DependsOn;
12 13 import org.springframework.stereotype.Component;
13 14  
... ... @@ -18,7 +19,7 @@ import java.util.concurrent.LinkedBlockingQueue;
18 19 import java.util.concurrent.ThreadPoolExecutor;
19 20 import java.util.concurrent.TimeUnit;
20 21  
21   -@Component
  22 +@Configuration
22 23 public class SipLayer{
23 24  
24 25 private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);
... ... @@ -35,7 +36,7 @@ public class SipLayer{
35 36  
36 37  
37 38 @Bean("sipFactory")
38   - private SipFactory createSipFactory() {
  39 + SipFactory createSipFactory() {
39 40 sipFactory = SipFactory.getInstance();
40 41 sipFactory.setPathName("gov.nist");
41 42 return sipFactory;
... ... @@ -43,7 +44,7 @@ public class SipLayer{
43 44  
44 45 @Bean("sipStack")
45 46 @DependsOn({"sipFactory"})
46   - private SipStack createSipStack() throws PeerUnavailableException {
  47 + SipStack createSipStack() throws PeerUnavailableException {
47 48 Properties properties = new Properties();
48 49 properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP");
49 50 properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getMonitorIp());
... ... @@ -64,7 +65,7 @@ public class SipLayer{
64 65  
65 66 @Bean(name = "tcpSipProvider")
66 67 @DependsOn("sipStack")
67   - private SipProviderImpl startTcpListener() {
  68 + SipProviderImpl startTcpListener() {
68 69 ListeningPoint tcpListeningPoint = null;
69 70 SipProviderImpl tcpSipProvider = null;
70 71 try {
... ... @@ -89,7 +90,7 @@ public class SipLayer{
89 90  
90 91 @Bean(name = "udpSipProvider")
91 92 @DependsOn("sipStack")
92   - private SipProviderImpl startUdpListener() {
  93 + SipProviderImpl startUdpListener() {
93 94 ListeningPoint udpListeningPoint = null;
94 95 SipProviderImpl udpSipProvider = null;
95 96 try {
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java
... ... @@ -129,7 +129,9 @@ public class DigestServerAuthenticationHelper {
129 129 */
130 130 public boolean doAuthenticateHashedPassword(Request request, String hashedPassword) {
131 131 AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME);
132   - if ( authHeader == null ) return false;
  132 + if ( authHeader == null ) {
  133 + return false;
  134 + }
133 135 String realm = authHeader.getRealm();
134 136 String username = authHeader.getUsername();
135 137  
... ... @@ -176,7 +178,9 @@ public class DigestServerAuthenticationHelper {
176 178 */
177 179 public boolean doAuthenticatePlainTextPassword(Request request, String pass) {
178 180 AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME);
179   - if ( authHeader == null ) return false;
  181 + if ( authHeader == null ) {
  182 + return false;
  183 + }
180 184 String realm = authHeader.getRealm().trim();
181 185 String username = authHeader.getUsername().trim();
182 186  
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
... ... @@ -25,6 +25,7 @@ public class GbStream extends PlatformGbStream{
25 25 return gbStreamId;
26 26 }
27 27  
  28 + @Override
28 29 public void setGbStreamId(Integer gbStreamId) {
29 30 this.gbStreamId = gbStreamId;
30 31 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
... ... @@ -59,7 +59,9 @@ public class SubscribeHolder {
59 59 mobilePositionMap.put(platformId, subscribeInfo);
60 60 String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId;
61 61 // 添加任务处理GPS定时推送
62   - dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(redisCatchStorage, sipCommanderForPlatform, storager, platformId, subscribeInfo.getSn(), key, this), subscribeInfo.getGpsInterval());
  62 + dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(redisCatchStorage, sipCommanderForPlatform,
  63 + storager, platformId, subscribeInfo.getSn(), key, this, dynamicTask),
  64 + subscribeInfo.getGpsInterval());
63 65 String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId;
64 66 dynamicTask.stop(taskOverdueKey);
65 67 // 添加任务处理订阅过期
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java deleted 100644 → 0
1   -package com.genersoft.iot.vmp.gb28181.event;
2   -
3   -import com.genersoft.iot.vmp.conf.UserSetting;
4   -import org.springframework.beans.factory.annotation.Autowired;
5   -import org.springframework.stereotype.Component;
6   -
7   -import com.genersoft.iot.vmp.common.VideoManagerConstants;
8   -import com.genersoft.iot.vmp.utils.redis.RedisUtil;
9   -
10   -/**
11   - * @description:设备离在线状态检测器,用于检测设备状态
12   - * @author: swwheihei
13   - * @date: 2020年5月13日 下午2:40:29
14   - */
15   -@Component
16   -public class DeviceOffLineDetector {
17   -
18   - @Autowired
19   - private RedisUtil redis;
20   -
21   - @Autowired
22   - private UserSetting userSetting;
23   -
24   - public boolean isOnline(String deviceId) {
25   - String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + deviceId;
26   - return redis.hasKey(key);
27   - }
28   -}
src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
... ... @@ -62,7 +62,9 @@ public class OnlineEventListener implements ApplicationListener&lt;OnlineEvent&gt; {
62 62  
63 63 logger.info("设备上线事件触发,deviceId:" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
64 64 Device device = event.getDevice();
65   - if (device == null) return;
  65 + if (device == null) {
  66 + return;
  67 + }
66 68 String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId();
67 69 Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
68 70 device.setOnline(1);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java
1 1 package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
2 2  
  3 +import com.genersoft.iot.vmp.conf.DynamicTask;
3 4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
4 5 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
5 6 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
... ... @@ -22,6 +23,8 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener&lt;Pla
22 23 private IVideoManagerStorage storager;
23 24 @Autowired
24 25 private ISIPCommanderForPlatform sipCommanderFroPlatform;
  26 + @Autowired
  27 + private DynamicTask dynamicTask;
25 28  
26 29 @Override
27 30 public void onApplicationEvent(PlatformCycleRegisterEvent event) {
... ... @@ -31,17 +34,13 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener&lt;Pla
31 34 logger.info("[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
32 35 return;
33 36 }
34   - Timer timer = new Timer();
  37 + String taskKey = "platform-cycle-register" + parentPlatform.getServerGBId();;
35 38 SipSubscribe.Event okEvent = (responseEvent)->{
36   - timer.cancel();
  39 + dynamicTask.stop(taskKey);
37 40 };
38   - sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
39   - timer.schedule(new TimerTask() {
40   - @Override
41   - public void run() {
42   - logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
43   - sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
44   - }
45   - }, 15*1000 ,Long.parseLong(parentPlatform.getExpires())* 1000);
  41 + dynamicTask.startCron(taskKey, ()->{
  42 + logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
  43 + sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
  44 + }, Integer.parseInt(parentPlatform.getExpires())* 1000);
46 45 }
47 46 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java
1 1 package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
2 2  
  3 +import com.genersoft.iot.vmp.conf.DynamicTask;
3 4 import com.genersoft.iot.vmp.conf.SipConfig;
4 5 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
5 6 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
... ... @@ -46,6 +47,9 @@ public class PlatformNotRegisterEventLister implements ApplicationListener&lt;Platf
46 47 @Autowired
47 48 private SipConfig config;
48 49  
  50 + @Autowired
  51 + private DynamicTask dynamicTask;
  52 +
49 53 // @Autowired
50 54 // private RedisUtil redis;
51 55  
... ... @@ -75,19 +79,13 @@ public class PlatformNotRegisterEventLister implements ApplicationListener&lt;Platf
75 79 }
76 80  
77 81 }
78   - Timer timer = new Timer();
  82 + String taskKey = "platform-not-register-" + parentPlatform.getServerGBId();
79 83 SipSubscribe.Event okEvent = (responseEvent)->{
80   - timer.cancel();
  84 + dynamicTask.stop(taskKey);
81 85 };
82   - logger.info("[平台注册]平台国标ID:" + event.getPlatformGbID());
83   - sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
84   - // 设置注册失败则每隔15秒发起一次注册
85   - timer.schedule(new TimerTask() {
86   - @Override
87   - public void run() {
88   - logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
89   - sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
90   - }
91   - }, config.getRegisterTimeInterval()* 1000, config.getRegisterTimeInterval()* 1000);//十五秒后再次发起注册
  86 + dynamicTask.startCron(taskKey, ()->{
  87 + logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
  88 + sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
  89 + }, config.getRegisterTimeInterval()* 1000);
92 90 }
93 91 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
... ... @@ -60,7 +60,9 @@ public class CatalogEventLister implements ApplicationListener&lt;CatalogEvent&gt; {
60 60 Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
61 61 if (event.getPlatformId() != null) {
62 62 parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
63   - if (parentPlatform != null && !parentPlatform.isStatus())return;
  63 + if (parentPlatform != null && !parentPlatform.isStatus()) {
  64 + return;
  65 + }
64 66 subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
65 67  
66 68 if (subscribe == null) {
... ... @@ -80,7 +82,9 @@ public class CatalogEventLister implements ApplicationListener&lt;CatalogEvent&gt; {
80 82 }else if (event.getGbStreams() != null) {
81 83 if (platforms.size() > 0) {
82 84 for (GbStream gbStream : event.getGbStreams()) {
83   - if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) continue;
  85 + if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) {
  86 + continue;
  87 + }
84 88 List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms);
85 89 parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB);
86 90 }
... ... @@ -113,7 +117,9 @@ public class CatalogEventLister implements ApplicationListener&lt;CatalogEvent&gt; {
113 117 if (parentPlatforms != null && parentPlatforms.size() > 0) {
114 118 for (ParentPlatform platform : parentPlatforms) {
115 119 SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
116   - if (subscribeInfo == null) continue;
  120 + if (subscribeInfo == null) {
  121 + continue;
  122 + }
117 123 logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId);
118 124 List<DeviceChannel> deviceChannelList = new ArrayList<>();
119 125 DeviceChannel deviceChannel = new DeviceChannel();
... ... @@ -155,7 +161,9 @@ public class CatalogEventLister implements ApplicationListener&lt;CatalogEvent&gt; {
155 161 if (parentPlatforms != null && parentPlatforms.size() > 0) {
156 162 for (ParentPlatform platform : parentPlatforms) {
157 163 SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
158   - if (subscribeInfo == null) continue;
  164 + if (subscribeInfo == null) {
  165 + continue;
  166 + }
159 167 logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId);
160 168 List<DeviceChannel> deviceChannelList = new ArrayList<>();
161 169 DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(platform.getServerGBId(), gbId);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
... ... @@ -65,19 +65,25 @@ public class CatalogDataCatch {
65 65  
66 66 public List<DeviceChannel> get(String deviceId) {
67 67 CatalogData catalogData = data.get(deviceId);
68   - if (catalogData == null) return null;
  68 + if (catalogData == null) {
  69 + return null;
  70 + }
69 71 return catalogData.getChannelList();
70 72 }
71 73  
72 74 public int getTotal(String deviceId) {
73 75 CatalogData catalogData = data.get(deviceId);
74   - if (catalogData == null) return 0;
  76 + if (catalogData == null) {
  77 + return 0;
  78 + }
75 79 return catalogData.getTotal();
76 80 }
77 81  
78 82 public SyncStatus getSyncStatus(String deviceId) {
79 83 CatalogData catalogData = data.get(deviceId);
80   - if (catalogData == null) return null;
  84 + if (catalogData == null) {
  85 + return null;
  86 + }
81 87 SyncStatus syncStatus = new SyncStatus();
82 88 syncStatus.setCurrent(catalogData.getChannelList().size());
83 89 syncStatus.setTotal(catalogData.getTotal());
... ... @@ -87,7 +93,9 @@ public class CatalogDataCatch {
87 93  
88 94 public boolean isSyncRunning(String deviceId) {
89 95 CatalogData catalogData = data.get(deviceId);
90   - if (catalogData == null) return false;
  96 + if (catalogData == null) {
  97 + return false;
  98 + }
91 99 return !catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end);
92 100 }
93 101  
... ... @@ -125,7 +133,9 @@ public class CatalogDataCatch {
125 133  
126 134 public void setChannelSyncEnd(String deviceId, String errorMsg) {
127 135 CatalogData catalogData = data.get(deviceId);
128   - if (catalogData == null)return;
  136 + if (catalogData == null) {
  137 + return;
  138 + }
129 139 catalogData.setStatus(CatalogData.CatalogDataStatus.end);
130 140 catalogData.setErrorMsg(errorMsg);
131 141 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
... ... @@ -78,7 +78,9 @@ public class VideoStreamSessionManager {
78 78  
79 79 public ClientTransaction getTransactionByStream(String deviceId, String channelId, String stream){
80 80 SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
81   - if (ssrcTransaction == null) return null;
  81 + if (ssrcTransaction == null) {
  82 + return null;
  83 + }
82 84 byte[] transactionByteArray = ssrcTransaction.getTransaction();
83 85 ClientTransaction clientTransaction = (ClientTransaction)SerializeUtils.deSerialize(transactionByteArray);
84 86 return clientTransaction;
... ... @@ -86,39 +88,63 @@ public class VideoStreamSessionManager {
86 88  
87 89 public SIPDialog getDialogByStream(String deviceId, String channelId, String stream){
88 90 SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
89   - if (ssrcTransaction == null) return null;
  91 + if (ssrcTransaction == null) {
  92 + return null;
  93 + }
90 94 byte[] dialogByteArray = ssrcTransaction.getDialog();
91   - if (dialogByteArray == null) return null;
  95 + if (dialogByteArray == null) {
  96 + return null;
  97 + }
92 98 SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray);
93 99 return dialog;
94 100 }
95 101  
96 102 public SIPDialog getDialogByCallId(String deviceId, String channelId, String callID){
97 103 SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callID, null);
98   - if (ssrcTransaction == null) return null;
  104 + if (ssrcTransaction == null) {
  105 + return null;
  106 + }
99 107 byte[] dialogByteArray = ssrcTransaction.getDialog();
100   - if (dialogByteArray == null) return null;
  108 + if (dialogByteArray == null) {
  109 + return null;
  110 + }
101 111 SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray);
102 112 return dialog;
103 113 }
104 114  
105 115 public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
106   - if (StringUtils.isEmpty(callId)) callId ="*";
107   - if (StringUtils.isEmpty(stream)) stream ="*";
  116 + if (StringUtils.isEmpty(callId)) {
  117 + callId ="*";
  118 + }
  119 + if (StringUtils.isEmpty(stream)) {
  120 + stream ="*";
  121 + }
108 122 String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
109 123 List<Object> scanResult = redisUtil.scan(key);
110   - if (scanResult.size() == 0) return null;
  124 + if (scanResult.size() == 0) {
  125 + return null;
  126 + }
111 127 return (SsrcTransaction)redisUtil.get((String) scanResult.get(0));
112 128 }
113 129  
114 130 public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){
115   - if (StringUtils.isEmpty(deviceId)) deviceId ="*";
116   - if (StringUtils.isEmpty(channelId)) channelId ="*";
117   - if (StringUtils.isEmpty(callId)) callId ="*";
118   - if (StringUtils.isEmpty(stream)) stream ="*";
  131 + if (StringUtils.isEmpty(deviceId)) {
  132 + deviceId ="*";
  133 + }
  134 + if (StringUtils.isEmpty(channelId)) {
  135 + channelId ="*";
  136 + }
  137 + if (StringUtils.isEmpty(callId)) {
  138 + callId ="*";
  139 + }
  140 + if (StringUtils.isEmpty(stream)) {
  141 + stream ="*";
  142 + }
119 143 String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
120 144 List<Object> scanResult = redisUtil.scan(key);
121   - if (scanResult.size() == 0) return null;
  145 + if (scanResult.size() == 0) {
  146 + return null;
  147 + }
122 148 List<SsrcTransaction> result = new ArrayList<>();
123 149 for (Object keyObj : scanResult) {
124 150 result.add((SsrcTransaction)redisUtil.get((String) keyObj));
... ... @@ -128,19 +154,25 @@ public class VideoStreamSessionManager {
128 154  
129 155 public String getMediaServerId(String deviceId, String channelId, String stream){
130 156 SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
131   - if (ssrcTransaction == null) return null;
  157 + if (ssrcTransaction == null) {
  158 + return null;
  159 + }
132 160 return ssrcTransaction.getMediaServerId();
133 161 }
134 162  
135 163 public String getSSRC(String deviceId, String channelId, String stream){
136 164 SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
137   - if (ssrcTransaction == null) return null;
  165 + if (ssrcTransaction == null) {
  166 + return null;
  167 + }
138 168 return ssrcTransaction.getSsrc();
139 169 }
140 170  
141 171 public void remove(String deviceId, String channelId, String stream) {
142 172 SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
143   - if (ssrcTransaction == null) return;
  173 + if (ssrcTransaction == null) {
  174 + return;
  175 + }
144 176 redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_"
145 177 + deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream());
146 178 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java
... ... @@ -2,6 +2,9 @@ package com.genersoft.iot.vmp.gb28181.task;
2 2  
3 3 import javax.sip.DialogState;
4 4  
  5 +/**
  6 + * @author lin
  7 + */
5 8 public interface ISubscribeTask extends Runnable{
6 9 void stop();
7 10  
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
1 1 package com.genersoft.iot.vmp.gb28181.task.impl;
2 2  
  3 +import com.genersoft.iot.vmp.conf.DynamicTask;
3 4 import com.genersoft.iot.vmp.gb28181.bean.Device;
4 5 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
5 6 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
6 7 import org.slf4j.Logger;
7 8 import org.slf4j.LoggerFactory;
8 9 import org.springframework.scheduling.annotation.Async;
  10 +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
9 11  
10 12 import javax.sip.Dialog;
11 13 import javax.sip.DialogState;
... ... @@ -15,6 +17,7 @@ import java.util.TimerTask;
15 17  
16 18 /**
17 19 * 目录订阅任务
  20 + * @author lin
18 21 */
19 22 public class CatalogSubscribeTask implements ISubscribeTask {
20 23 private final Logger logger = LoggerFactory.getLogger(CatalogSubscribeTask.class);
... ... @@ -22,18 +25,21 @@ public class CatalogSubscribeTask implements ISubscribeTask {
22 25 private final ISIPCommander sipCommander;
23 26 private Dialog dialog;
24 27  
25   - private Timer timer ;
  28 + private DynamicTask dynamicTask;
26 29  
27   - public CatalogSubscribeTask(Device device, ISIPCommander sipCommander) {
  30 + private String taskKey = "catalog-subscribe-timeout";
  31 +
  32 +
  33 + public CatalogSubscribeTask(Device device, ISIPCommander sipCommander, DynamicTask dynamicTask) {
28 34 this.device = device;
29 35 this.sipCommander = sipCommander;
  36 + this.dynamicTask = dynamicTask;
30 37 }
31 38  
32 39 @Override
33 40 public void run() {
34   - if (timer != null ) {
35   - timer.cancel();
36   - timer = null;
  41 + if (dynamicTask.get(taskKey) != null) {
  42 + dynamicTask.stop(taskKey);
37 43 }
38 44 sipCommander.catalogSubscribe(device, dialog, eventResult -> {
39 45 if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) {
... ... @@ -51,13 +57,7 @@ public class CatalogSubscribeTask implements ISubscribeTask {
51 57 dialog = null;
52 58 // 失败
53 59 logger.warn("[目录订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg);
54   - timer = new Timer();
55   - timer.schedule(new TimerTask() {
56   - @Override
57   - public void run() {
58   - CatalogSubscribeTask.this.run();
59   - }
60   - }, 2000);
  60 + dynamicTask.startDelay(taskKey, CatalogSubscribeTask.this, 2000);
61 61 });
62 62 }
63 63  
... ... @@ -71,9 +71,8 @@ public class CatalogSubscribeTask implements ISubscribeTask {
71 71 * TERMINATED-> Terminated Dialog状态-终止
72 72 */
73 73 logger.info("取消目录订阅时dialog状态为{}", DialogState.CONFIRMED);
74   - if (timer != null ) {
75   - timer.cancel();
76   - timer = null;
  74 + if (dynamicTask.get(taskKey) != null) {
  75 + dynamicTask.stop(taskKey);
77 76 }
78 77 if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) {
79 78 device.setSubscribeCycleForCatalog(0);
... ... @@ -95,7 +94,9 @@ public class CatalogSubscribeTask implements ISubscribeTask {
95 94  
96 95 @Override
97 96 public DialogState getDialogState() {
98   - if (dialog == null) return null;
  97 + if (dialog == null) {
  98 + return null;
  99 + }
99 100 return dialog.getState();
100 101 }
101 102 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java
1 1 package com.genersoft.iot.vmp.gb28181.task.impl;
2 2  
  3 +import com.genersoft.iot.vmp.conf.DynamicTask;
3 4 import com.genersoft.iot.vmp.gb28181.bean.*;
4 5 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
5 6 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
... ... @@ -15,6 +16,7 @@ import java.util.List;
15 16  
16 17 /**
17 18 * 向已经订阅(移动位置)的上级发送MobilePosition消息
  19 + * @author lin
18 20 */
19 21 public class MobilePositionSubscribeHandlerTask implements ISubscribeTask {
20 22  
... ... @@ -25,10 +27,18 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask {
25 27 private ISIPCommanderForPlatform sipCommanderForPlatform;
26 28 private SubscribeHolder subscribeHolder;
27 29 private ParentPlatform platform;
  30 +
28 31 private String sn;
29 32 private String key;
30 33  
31   - public MobilePositionSubscribeHandlerTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorage storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) {
  34 + public MobilePositionSubscribeHandlerTask(IRedisCatchStorage redisCatchStorage,
  35 + ISIPCommanderForPlatform sipCommanderForPlatform,
  36 + IVideoManagerStorage storager,
  37 + String platformId,
  38 + String sn,
  39 + String key,
  40 + SubscribeHolder subscribeInfo,
  41 + DynamicTask dynamicTask) {
32 42 this.redisCatchStorage = redisCatchStorage;
33 43 this.storager = storager;
34 44 this.platform = storager.queryParentPlatByServerGBId(platformId);
... ... @@ -41,7 +51,9 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask {
41 51 @Override
42 52 public void run() {
43 53  
44   - if (platform == null) return;
  54 + if (platform == null) {
  55 + return;
  56 + }
45 57 SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId());
46 58 if (subscribe != null) {
47 59  
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java
1 1 package com.genersoft.iot.vmp.gb28181.task.impl;
2 2  
  3 +import com.genersoft.iot.vmp.conf.DynamicTask;
3 4 import com.genersoft.iot.vmp.gb28181.bean.Device;
4 5 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
5 6 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
... ... @@ -16,25 +17,26 @@ import java.util.TimerTask;
16 17  
17 18 /**
18 19 * 移动位置订阅的定时更新
  20 + * @author lin
19 21 */
20 22 public class MobilePositionSubscribeTask implements ISubscribeTask {
21 23 private final Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeTask.class);
22 24 private Device device;
23 25 private ISIPCommander sipCommander;
24 26 private Dialog dialog;
  27 + private DynamicTask dynamicTask;
  28 + private String taskKey = "mobile-position-subscribe-timeout";
25 29  
26   - private Timer timer ;
27   -
28   - public MobilePositionSubscribeTask(Device device, ISIPCommander sipCommander) {
  30 + public MobilePositionSubscribeTask(Device device, ISIPCommander sipCommander, DynamicTask dynamicTask) {
29 31 this.device = device;
30 32 this.sipCommander = sipCommander;
  33 + this.dynamicTask = dynamicTask;
31 34 }
32 35  
33 36 @Override
34 37 public void run() {
35   - if (timer != null ) {
36   - timer.cancel();
37   - timer = null;
  38 + if (dynamicTask.get(taskKey) != null) {
  39 + dynamicTask.stop(taskKey);
38 40 }
39 41 sipCommander.mobilePositionSubscribe(device, dialog, eventResult -> {
40 42 // if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) {
... ... @@ -52,13 +54,7 @@ public class MobilePositionSubscribeTask implements ISubscribeTask {
52 54 dialog = null;
53 55 // 失败
54 56 logger.warn("[移动位置订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg);
55   - timer = new Timer();
56   - timer.schedule(new TimerTask() {
57   - @Override
58   - public void run() {
59   - MobilePositionSubscribeTask.this.run();
60   - }
61   - }, 2000);
  57 + dynamicTask.startDelay(taskKey, MobilePositionSubscribeTask.this, 2000);
62 58 });
63 59  
64 60 }
... ... @@ -72,9 +68,8 @@ public class MobilePositionSubscribeTask implements ISubscribeTask {
72 68 * COMPLETED-> Completed Dialog状态-已完成
73 69 * TERMINATED-> Terminated Dialog状态-终止
74 70 */
75   - if (timer != null ) {
76   - timer.cancel();
77   - timer = null;
  71 + if (dynamicTask.get(taskKey) != null) {
  72 + dynamicTask.stop(taskKey);
78 73 }
79 74 if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) {
80 75 logger.info("取消移动订阅时dialog状态为{}", dialog.getState());
... ... @@ -96,7 +91,9 @@ public class MobilePositionSubscribeTask implements ISubscribeTask {
96 91 }
97 92 @Override
98 93 public DialogState getDialogState() {
99   - if (dialog == null) return null;
  94 + if (dialog == null) {
  95 + return null;
  96 + }
100 97 return dialog.getState();
101 98 }
102 99 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
... ... @@ -62,7 +62,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
62 62 * @param processor 处理程序
63 63 */
64 64 public void addTimeoutProcessor(ITimeoutProcessor processor) {
65   - this.timeoutProcessor = processor;
  65 + timeoutProcessor = processor;
66 66 }
67 67  
68 68 /**
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/CheckForAllRecordsThread.java
... ... @@ -29,6 +29,7 @@ public class CheckForAllRecordsThread extends Thread {
29 29 this.recordInfo = recordInfo;
30 30 }
31 31  
  32 + @Override
32 33 public void run() {
33 34  
34 35 String cacheKey = this.key;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
... ... @@ -65,12 +65,16 @@ public class DeferredResultHolder {
65 65  
66 66 public DeferredResult get(String key, String id) {
67 67 Map<String, DeferredResult> deferredResultMap = map.get(key);
68   - if (deferredResultMap == null) return null;
  68 + if (deferredResultMap == null) {
  69 + return null;
  70 + }
69 71 return deferredResultMap.get(id);
70 72 }
71 73  
72 74 public boolean exist(String key, String id){
73   - if (key == null) return false;
  75 + if (key == null) {
  76 + return false;
  77 + }
74 78 Map<String, DeferredResult> deferredResultMap = map.get(key);
75 79 if (id == null) {
76 80 return deferredResultMap != null;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
... ... @@ -228,9 +228,13 @@ public class SIPRequestHeaderProvider {
228 228 public Request createInfoRequest(Device device, StreamInfo streamInfo, String content)
229 229 throws PeerUnavailableException, ParseException, InvalidArgumentException {
230 230 Request request = null;
231   - if (streamInfo == null) return null;
  231 + if (streamInfo == null) {
  232 + return null;
  233 + }
232 234 Dialog dialog = streamSession.getDialogByStream(streamInfo.getDeviceID(), streamInfo.getChannelId(), streamInfo.getStream());
233   - if (dialog == null) return null;
  235 + if (dialog == null) {
  236 + return null;
  237 + }
234 238  
235 239 SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(),
236 240 device.getHostAddress());
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
... ... @@ -340,13 +340,15 @@ public class SIPCommander implements ISIPCommander {
340 340 * @param channelId 预览通道
341 341 * @param event hook订阅
342 342 * @param errorEvent sip错误订阅
343   - */
  343 + */
344 344 @Override
345 345 public void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
346 346 ZLMHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) {
347 347 String streamId = ssrcInfo.getStream();
348 348 try {
349   - if (device == null) return;
  349 + if (device == null) {
  350 + return;
  351 + }
350 352 String streamMode = device.getStreamMode().toUpperCase();
351 353  
352 354 logger.info("{} 分配的ZLM为: {} [{}:{}]", streamId, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort());
... ... @@ -694,7 +696,9 @@ public class SIPCommander implements ISIPCommander {
694 696 if (callId != null) {
695 697 dialog = streamSession.getDialogByCallId(deviceId, channelId, callId);
696 698 }else {
697   - if (stream == null) return;
  699 + if (stream == null) {
  700 + return;
  701 + }
698 702 dialog = streamSession.getDialogByStream(deviceId, channelId, stream);
699 703 }
700 704 if (ssrcTransaction != null) {
... ... @@ -1454,6 +1458,7 @@ public class SIPCommander implements ISIPCommander {
1454 1458 * @param device 视频设备
1455 1459 * @return true = 命令发送成功
1456 1460 */
  1461 + @Override
1457 1462 public boolean mobilePositionSubscribe(Device device, Dialog dialog, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) {
1458 1463 try {
1459 1464 StringBuffer subscribePostitionXml = new StringBuffer(200);
... ... @@ -1505,6 +1510,7 @@ public class SIPCommander implements ISIPCommander {
1505 1510 * @param endTime 报警发生终止时间(可选)
1506 1511 * @return true = 命令发送成功
1507 1512 */
  1513 + @Override
1508 1514 public boolean alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String alarmType, String startTime, String endTime) {
1509 1515 try {
1510 1516 StringBuffer cmdXml = new StringBuffer(200);
... ... @@ -1701,7 +1707,9 @@ public class SIPCommander implements ISIPCommander {
1701 1707 content.append("CSeq: " + cseq + "\r\n");
1702 1708 content.append("Range: npt=now-\r\n");
1703 1709 Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
1704   - if (request == null) return;
  1710 + if (request == null) {
  1711 + return;
  1712 + }
1705 1713 logger.info(request.toString());
1706 1714 ClientTransaction clientTransaction = null;
1707 1715 if ("TCP".equals(device.getTransport())) {
... ... @@ -1730,7 +1738,9 @@ public class SIPCommander implements ISIPCommander {
1730 1738 content.append("Range: npt=" + Math.abs(seekTime) + "-\r\n");
1731 1739  
1732 1740 Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
1733   - if (request == null) return;
  1741 + if (request == null) {
  1742 + return;
  1743 + }
1734 1744 logger.info(request.toString());
1735 1745 ClientTransaction clientTransaction = null;
1736 1746 if ("TCP".equals(device.getTransport())) {
... ... @@ -1758,7 +1768,9 @@ public class SIPCommander implements ISIPCommander {
1758 1768 content.append("CSeq: " + cseq + "\r\n");
1759 1769 content.append("Scale: " + String.format("%.1f",speed) + "\r\n");
1760 1770 Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString());
1761   - if (request == null) return;
  1771 + if (request == null) {
  1772 + return;
  1773 + }
1762 1774 logger.info(request.toString());
1763 1775 ClientTransaction clientTransaction = null;
1764 1776 if ("TCP".equals(device.getTransport())) {
... ... @@ -1824,7 +1836,9 @@ public class SIPCommander implements ISIPCommander {
1824 1836 // 设置编码, 防止中文乱码
1825 1837 messageFactory.setDefaultContentEncodingCharset(characterSet);
1826 1838 Dialog dialog = subscribeInfo.getDialog();
1827   - if (dialog == null || !dialog.getState().equals(DialogState.CONFIRMED)) return;
  1839 + if (dialog == null || !dialog.getState().equals(DialogState.CONFIRMED)) {
  1840 + return;
  1841 + }
1828 1842 SIPRequest notifyRequest = (SIPRequest)dialog.createRequest(Request.NOTIFY);
1829 1843 ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
1830 1844 notifyRequest.setContent(catalogXmlContent, contentTypeHeader);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
... ... @@ -529,7 +529,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
529 529 // 设置编码, 防止中文乱码
530 530 messageFactory.setDefaultContentEncodingCharset(characterSet);
531 531 Dialog dialog = subscribeInfo.getDialog();
532   - if (dialog == null || !dialog.getState().equals(DialogState.CONFIRMED)) return;
  532 + if (dialog == null || !dialog.getState().equals(DialogState.CONFIRMED)) {
  533 + return;
  534 + }
533 535 SIPRequest notifyRequest = (SIPRequest)dialog.createRequest(Request.NOTIFY);
534 536 ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
535 537 notifyRequest.setContent(catalogXmlContent, contentTypeHeader);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
... ... @@ -139,7 +139,9 @@ public abstract class SIPRequestProcessorParent {
139 139 serverTransaction.sendResponse(response);
140 140 if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) {
141 141  
142   - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete();
  142 + if (serverTransaction.getDialog() != null) {
  143 + serverTransaction.getDialog().delete();
  144 + }
143 145 }
144 146 }
145 147  
... ... @@ -149,7 +151,9 @@ public abstract class SIPRequestProcessorParent {
149 151 ServerTransaction serverTransaction = getServerTransaction(evt);
150 152 serverTransaction.sendResponse(response);
151 153 if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) {
152   - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete();
  154 + if (serverTransaction.getDialog() != null) {
  155 + serverTransaction.getDialog().delete();
  156 + }
153 157 }
154 158 }
155 159  
... ... @@ -215,7 +219,9 @@ public abstract class SIPRequestProcessorParent {
215 219 return getRootElement(evt, "gb2312");
216 220 }
217 221 public Element getRootElement(RequestEvent evt, String charset) throws DocumentException {
218   - if (charset == null) charset = "gb2312";
  222 + if (charset == null) {
  223 + charset = "gb2312";
  224 + }
219 225 Request request = evt.getRequest();
220 226 SAXReader reader = new SAXReader();
221 227 reader.setEncoding(charset);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
... ... @@ -72,7 +72,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
72 72 public void process(RequestEvent evt) {
73 73 Dialog dialog = evt.getDialog();
74 74 CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
75   - if (dialog == null) return;
  75 + if (dialog == null) {
  76 + return;
  77 + }
76 78 if (dialog.getState()== DialogState.CONFIRMED) {
77 79 String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser();
78 80 logger.info("ACK请求: platformGbId->{}", platformGbId);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
... ... @@ -81,7 +81,9 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
81 81 responseAck(evt, Response.OK);
82 82 Dialog dialog = evt.getDialog();
83 83 CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
84   - if (dialog == null) return;
  84 + if (dialog == null) {
  85 + return;
  86 + }
85 87 if (dialog.getState().equals(DialogState.TERMINATED)) {
86 88 String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser();
87 89 String channelId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser();
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
... ... @@ -321,7 +321,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
321 321 response = getMessageFactory().createResponse(event.statusCode, evt.getRequest());
322 322 ServerTransaction serverTransaction = getServerTransaction(evt);
323 323 serverTransaction.sendResponse(response);
324   - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete();
  324 + if (serverTransaction.getDialog() != null) {
  325 + serverTransaction.getDialog().delete();
  326 + }
325 327 } catch (ParseException | SipException | InvalidArgumentException e) {
326 328 e.printStackTrace();
327 329 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
... ... @@ -5,7 +5,6 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants;
5 5 import com.genersoft.iot.vmp.conf.SipConfig;
6 6 import com.genersoft.iot.vmp.conf.UserSetting;
7 7 import com.genersoft.iot.vmp.gb28181.bean.*;
8   -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
9 8 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
10 9 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
11 10 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
... ... @@ -19,7 +18,6 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
19 18 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
20 19 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
21 20 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
22   -import com.genersoft.iot.vmp.utils.GpsUtil;
23 21 import com.genersoft.iot.vmp.utils.redis.RedisUtil;
24 22 import org.dom4j.DocumentException;
25 23 import org.dom4j.Element;
... ... @@ -65,10 +63,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
65 63 @Autowired
66 64 private EventPublisher publisher;
67 65  
68   - @Autowired
69   - private DeviceOffLineDetector offLineDetector;
70   -
71   -
72 66 private String method = "NOTIFY";
73 67  
74 68 @Autowired
... ... @@ -240,7 +234,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
240 234  
241 235 // 回复200 OK
242 236 responseAck(evt, Response.OK);
243   - if (offLineDetector.isOnline(deviceId)) {
  237 + if (redisCatchStorage.deviceIsOnline(deviceId)) {
244 238 publisher.deviceAlarmEventPublish(deviceAlarm);
245 239 }
246 240 } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
... ... @@ -331,7 +325,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
331 325  
332 326 }
333 327  
334   - if (!offLineDetector.isOnline(deviceId)) {
  328 + if (!redisCatchStorage.deviceIsOnline(deviceId)) {
335 329 publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE);
336 330 }
337 331 }
... ... @@ -357,10 +351,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
357 351 public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) {
358 352 }
359 353  
360   - public void setOffLineDetector(DeviceOffLineDetector offLineDetector) {
361   - this.offLineDetector = offLineDetector;
362   - }
363   -
364 354 public IRedisCatchStorage getRedisCatchStorage() {
365 355 return redisCatchStorage;
366 356 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
... ... @@ -130,7 +130,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
130 130 response = getMessageFactory().createResponse(Response.BAD_REQUEST, request);
131 131 ServerTransaction serverTransaction = getServerTransaction(evt);
132 132 serverTransaction.sendResponse(response);
133   - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete();
  133 + if (serverTransaction.getDialog() != null) {
  134 + serverTransaction.getDialog().delete();
  135 + }
134 136 return;
135 137 }
136 138 // 添加Contact头
... ... @@ -195,7 +197,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
195 197 return;
196 198 }
197 199 serverTransaction.sendResponse(response);
198   - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete();
  200 + if (serverTransaction.getDialog() != null) {
  201 + serverTransaction.getDialog().delete();
  202 + }
199 203 }
200 204  
201 205 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
... ... @@ -35,23 +35,18 @@ import java.text.ParseException;
35 35  
36 36 /**
37 37 * SIP命令类型: SUBSCRIBE请求
  38 + * @author lin
38 39 */
39 40 @Component
40 41 public class SubscribeRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {
41 42  
42   - private Logger logger = LoggerFactory.getLogger(SubscribeRequestProcessor.class);
43   - private String method = "SUBSCRIBE";
  43 + private final Logger logger = LoggerFactory.getLogger(SubscribeRequestProcessor.class);
  44 + private final String method = "SUBSCRIBE";
44 45  
45 46 @Autowired
46 47 private SIPProcessorObserver sipProcessorObserver;
47 48  
48 49 @Autowired
49   - private IRedisCatchStorage redisCatchStorage;
50   -
51   - @Autowired
52   - private ISIPCommanderForPlatform sipCommanderForPlatform;
53   -
54   - @Autowired
55 50 private IVideoManagerStorage storager;
56 51  
57 52 @Lazy
... ... @@ -82,7 +77,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
82 77 /**
83 78 * 处理SUBSCRIBE请求
84 79 *
85   - * @param evt
  80 + * @param evt 事件
86 81 */
87 82 @Override
88 83 public void process(RequestEvent evt) {
... ... @@ -101,13 +96,12 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
101 96 } else {
102 97 logger.info("接收到消息:" + cmd);
103 98  
104   - Response response = null;
105   - response = getMessageFactory().createResponse(200, request);
  99 + Response response = getMessageFactory().createResponse(200, request);
106 100 if (response != null) {
107 101 ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30);
108 102 response.setExpires(expireHeader);
109 103 }
110   - logger.info("response : " + response.toString());
  104 + logger.info("response : " + response);
111 105 ServerTransaction transaction = getServerTransaction(evt);
112 106 if (transaction != null) {
113 107 transaction.sendResponse(response);
... ... @@ -117,13 +111,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
117 111 logger.info("processRequest serverTransactionId is null.");
118 112 }
119 113 }
120   - } catch (ParseException e) {
121   - e.printStackTrace();
122   - } catch (SipException e) {
123   - e.printStackTrace();
124   - } catch (InvalidArgumentException e) {
125   - e.printStackTrace();
126   - } catch (DocumentException e) {
  114 + } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
127 115 e.printStackTrace();
128 116 }
129 117  
... ... @@ -134,14 +122,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
134 122 */
135 123 private void processNotifyMobilePosition(RequestEvent evt, Element rootElement) throws SipException {
136 124 String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
137   - String deviceID = XmlUtil.getText(rootElement, "DeviceID");
  125 + String deviceId = XmlUtil.getText(rootElement, "DeviceID");
138 126 ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
139 127 SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId);
140 128 if (platform == null) {
141 129 return;
142 130 }
143 131 if (evt.getServerTransaction() == null) {
144   - ServerTransaction serverTransaction = platform.getTransport().equals("TCP") ? tcpSipProvider.getNewServerTransaction(evt.getRequest())
  132 + ServerTransaction serverTransaction = "TCP".equals(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest())
145 133 : udpSipProvider.getNewServerTransaction(evt.getRequest());
146 134 subscribeInfo.setTransaction(serverTransaction);
147 135 Dialog dialog = serverTransaction.getDialog();
... ... @@ -154,13 +142,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
154 142 resultXml.append("<?xml version=\"1.0\" ?>\r\n")
155 143 .append("<Response>\r\n")
156 144 .append("<CmdType>MobilePosition</CmdType>\r\n")
157   - .append("<SN>" + sn + "</SN>\r\n")
158   - .append("<DeviceID>" + deviceID + "</DeviceID>\r\n")
  145 + .append("<SN>").append(sn).append("</SN>\r\n")
  146 + .append("<DeviceID>").append(deviceId).append("</DeviceID>\r\n")
159 147 .append("<Result>OK</Result>\r\n")
160 148 .append("</Response>\r\n");
161 149  
162 150 if (subscribeInfo.getExpires() > 0) {
163   - String interval = XmlUtil.getText(rootElement, "Interval"); // GPS上报时间间隔
  151 + // GPS上报时间间隔
  152 + String interval = XmlUtil.getText(rootElement, "Interval");
164 153 if (interval == null) {
165 154 subscribeInfo.setGpsInterval(5);
166 155 }else {
... ... @@ -169,15 +158,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
169 158  
170 159 subscribeInfo.setSn(sn);
171 160 subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo);
172   -// if (subscribeHolder.getMobilePositionSubscribe(platformId) == null ) {
173   -// subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo);
174   -// }else {
175   -// if (subscribeHolder.getMobilePositionSubscribe(platformId).getDialog() != null
176   -// && subscribeHolder.getMobilePositionSubscribe(platformId).getDialog().getState() != null
177   -// && !subscribeHolder.getMobilePositionSubscribe(platformId).getDialog().getState().equals(DialogState.CONFIRMED)) {
178   -// subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo);
179   -// }
180   -// }
  161 +
181 162 }else if (subscribeInfo.getExpires() == 0) {
182 163 subscribeHolder.removeMobilePositionSubscribe(platformId);
183 164 }
... ... @@ -185,11 +166,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
185 166 try {
186 167 ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
187 168 responseXmlAck(evt, resultXml.toString(), parentPlatform);
188   - } catch (SipException e) {
189   - e.printStackTrace();
190   - } catch (InvalidArgumentException e) {
191   - e.printStackTrace();
192   - } catch (ParseException e) {
  169 + } catch (SipException | InvalidArgumentException | ParseException e) {
193 170 e.printStackTrace();
194 171 }
195 172 }
... ... @@ -200,12 +177,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
200 177  
201 178 private void processNotifyCatalogList(RequestEvent evt, Element rootElement) throws SipException {
202 179 String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
203   - String deviceID = XmlUtil.getText(rootElement, "DeviceID");
  180 + String deviceId = XmlUtil.getText(rootElement, "DeviceID");
204 181 ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
205   - if (platform == null)return;
  182 + if (platform == null){
  183 + return;
  184 + }
206 185 SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId);
207 186 if (evt.getServerTransaction() == null) {
208   - ServerTransaction serverTransaction = platform.getTransport().equals("TCP") ? tcpSipProvider.getNewServerTransaction(evt.getRequest())
  187 + ServerTransaction serverTransaction = "TCP".equals(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest())
209 188 : udpSipProvider.getNewServerTransaction(evt.getRequest());
210 189 subscribeInfo.setTransaction(serverTransaction);
211 190 Dialog dialog = serverTransaction.getDialog();
... ... @@ -213,13 +192,13 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
213 192 subscribeInfo.setDialog(dialog);
214 193 }
215 194 String sn = XmlUtil.getText(rootElement, "SN");
216   - logger.info("[回复 目录订阅]: {}/{}", platformId, deviceID);
  195 + logger.info("[回复 目录订阅]: {}/{}", platformId, deviceId);
217 196 StringBuilder resultXml = new StringBuilder(200);
218 197 resultXml.append("<?xml version=\"1.0\" ?>\r\n")
219 198 .append("<Response>\r\n")
220 199 .append("<CmdType>Catalog</CmdType>\r\n")
221   - .append("<SN>" + sn + "</SN>\r\n")
222   - .append("<DeviceID>" + deviceID + "</DeviceID>\r\n")
  200 + .append("<SN>").append(sn).append("</SN>\r\n")
  201 + .append("<DeviceID>").append(deviceId).append("</DeviceID>\r\n")
223 202 .append("<Result>OK</Result>\r\n")
224 203 .append("</Response>\r\n");
225 204  
... ... @@ -232,11 +211,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
232 211 try {
233 212 ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId);
234 213 responseXmlAck(evt, resultXml.toString(), parentPlatform);
235   - } catch (SipException e) {
236   - e.printStackTrace();
237   - } catch (InvalidArgumentException e) {
238   - e.printStackTrace();
239   - } catch (ParseException e) {
  214 + } catch (SipException | InvalidArgumentException | ParseException e) {
240 215 e.printStackTrace();
241 216 }
242 217 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
2 2  
3   -import com.alibaba.fastjson.JSON;
4 3 import com.genersoft.iot.vmp.conf.SipConfig;
5 4 import com.genersoft.iot.vmp.conf.UserSetting;
6 5 import com.genersoft.iot.vmp.gb28181.bean.*;
7   -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
8 6 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
9 7 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
10 8 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
... ... @@ -14,7 +12,6 @@ import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
14 12 import com.genersoft.iot.vmp.service.IDeviceAlarmService;
15 13 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
16 14 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
17   -import com.genersoft.iot.vmp.utils.GpsUtil;
18 15 import org.dom4j.Element;
19 16 import org.slf4j.Logger;
20 17 import org.slf4j.LoggerFactory;
... ... @@ -59,9 +56,6 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
59 56 @Autowired
60 57 private IDeviceAlarmService deviceAlarmService;
61 58  
62   - @Autowired
63   - private DeviceOffLineDetector offLineDetector;
64   -
65 59 @Override
66 60 public void afterPropertiesSet() throws Exception {
67 61 notifyMessageHandler.addHandler(cmdType, this);
... ... @@ -151,7 +145,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
151 145 }
152 146  
153 147  
154   - if (offLineDetector.isOnline(device.getDeviceId())) {
  148 + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) {
155 149 publisher.deviceAlarmEventPublish(deviceAlarm);
156 150 }
157 151 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
... ... @@ -70,7 +70,9 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
70 70 videoManagerStorager.updateDevice(device);
71 71 redisCatchStorage.updateDevice(device);
72 72 }
73   - publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
  73 + if (!redisCatchStorage.deviceIsOnline(device.getDeviceId())) {
  74 + publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
  75 + }
74 76 }
75 77 } catch (SipException e) {
76 78 e.printStackTrace();
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
2 2  
3   -import com.genersoft.iot.vmp.common.VideoManagerConstants;
4 3 import com.genersoft.iot.vmp.conf.SipConfig;
5 4 import com.genersoft.iot.vmp.conf.UserSetting;
6 5 import com.genersoft.iot.vmp.gb28181.bean.*;
7   -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
8 6 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
9 7 import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch;
10 8 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
11   -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
12 9 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
13 10 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
14 11 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
... ... @@ -17,8 +14,6 @@ import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
17 14 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
18 15 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
19 16 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
20   -import com.genersoft.iot.vmp.utils.GpsUtil;
21   -import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
22 17 import org.dom4j.DocumentException;
23 18 import org.dom4j.Element;
24 19 import org.slf4j.Logger;
... ... @@ -59,9 +54,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
59 54 private CatalogDataCatch catalogDataCatch;
60 55  
61 56 @Autowired
62   - private DeviceOffLineDetector offLineDetector;
63   -
64   - @Autowired
65 57 private SipConfig config;
66 58  
67 59 @Autowired
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java
... ... @@ -4,13 +4,13 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants;
4 4 import com.genersoft.iot.vmp.conf.SipConfig;
5 5 import com.genersoft.iot.vmp.gb28181.bean.Device;
6 6 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
7   -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
8 7 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
9 8 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
10 9 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
11 10 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
12 11 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
13 12 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
  13 +import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
14 14 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
15 15 import org.dom4j.DocumentException;
16 16 import org.dom4j.Element;
... ... @@ -42,10 +42,10 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
42 42 private IVideoManagerStorage storager;
43 43  
44 44 @Autowired
45   - private DeferredResultHolder deferredResultHolder;
  45 + private IRedisCatchStorage redisCatchStorage;
46 46  
47 47 @Autowired
48   - private DeviceOffLineDetector offLineDetector;
  48 + private DeferredResultHolder deferredResultHolder;
49 49  
50 50 @Autowired
51 51 private SipConfig config;
... ... @@ -82,7 +82,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
82 82 deferredResultHolder.invokeAllResult(msg);
83 83 // 回复200 OK
84 84 responseAck(evt, Response.OK);
85   - if (offLineDetector.isOnline(device.getDeviceId())) {
  85 + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) {
86 86 publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE);
87 87 }
88 88 } catch (DocumentException e) {
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java
... ... @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
4 4 import com.genersoft.iot.vmp.common.VideoManagerConstants;
5 5 import com.genersoft.iot.vmp.gb28181.bean.Device;
6 6 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
7   -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
8 7 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
9 8 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
10 9 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
... ... @@ -12,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP
12 11 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
13 12 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
14 13 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
  14 +import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
15 15 import org.dom4j.Element;
16 16 import org.slf4j.Logger;
17 17 import org.slf4j.LoggerFactory;
... ... @@ -34,8 +34,6 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen
34 34 @Autowired
35 35 private ResponseMessageHandler responseMessageHandler;
36 36  
37   - @Autowired
38   - private DeviceOffLineDetector offLineDetector;
39 37  
40 38 @Autowired
41 39 private DeferredResultHolder deferredResultHolder;
... ... @@ -43,6 +41,9 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen
43 41 @Autowired
44 42 private EventPublisher publisher;
45 43  
  44 + @Autowired
  45 + private IRedisCatchStorage redisCatchStorage;
  46 +
46 47 @Override
47 48 public void afterPropertiesSet() throws Exception {
48 49 responseMessageHandler.addHandler(cmdType, this);
... ... @@ -74,10 +75,8 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen
74 75 msg.setData(json);
75 76 deferredResultHolder.invokeAllResult(msg);
76 77  
77   - if (offLineDetector.isOnline(device.getDeviceId())) {
  78 + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) {
78 79 publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE);
79   - } else {
80   -
81 80 }
82 81 }
83 82  
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
... ... @@ -25,7 +25,9 @@ public class SipUtils {
25 25 * */
26 26 public static String getChannelIdFromHeader(Request request) {
27 27 Header subject = request.getHeader("subject");
28   - if (subject == null) return null;
  28 + if (subject == null) {
  29 + return null;
  30 + }
29 31 return ((Subject) subject).getSubject().split(":")[0];
30 32 }
31 33  
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
... ... @@ -85,7 +85,9 @@ public class ZLMHttpHookSubscribe {
85 85 if (result == null) {
86 86 result = key.getString(s).equals(hookResponse.getString(s));
87 87 }else {
88   - if (key.getString(s) == null) continue;
  88 + if (key.getString(s) == null) {
  89 + continue;
  90 + }
89 91 result = result && key.getString(s).equals(hookResponse.getString(s));
90 92 }
91 93 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
... ... @@ -67,7 +67,9 @@ public class ZLMMediaListManager {
67 67  
68 68 // 使用异步的当时更新媒体流列表
69 69 zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{
70   - if (mediaList == null) return;
  70 + if (mediaList == null) {
  71 + return;
  72 + }
71 73 String dataStr = mediaList.getString("data");
72 74  
73 75 Integer code = mediaList.getInteger("code");
... ... @@ -176,7 +178,9 @@ public class ZLMMediaListManager {
176 178 //使用异步更新推流
177 179 zlmresTfulUtils.getMediaList(mediaServerItem, app, streamId, "rtmp", json->{
178 180  
179   - if (json == null) return;
  181 + if (json == null) {
  182 + return;
  183 + }
180 184 String dataStr = json.getString("data");
181 185  
182 186 Integer code = json.getInteger("code");
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
... ... @@ -23,7 +23,9 @@ public class ZLMRTPServerFactory {
23 23 private int[] portRangeArray = new int[2];
24 24  
25 25 public int getFreePort(MediaServerItem mediaServerItem, int startPort, int endPort, List<Integer> usedFreelist) {
26   - if (endPort <= startPort) return -1;
  26 + if (endPort <= startPort) {
  27 + return -1;
  28 + }
27 29 if (usedFreelist == null) {
28 30 usedFreelist = new ArrayList<>();
29 31 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
... ... @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.media.zlm;
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONArray;
5 5 import com.alibaba.fastjson.JSONObject;
  6 +import com.genersoft.iot.vmp.conf.DynamicTask;
6 7 import com.genersoft.iot.vmp.conf.MediaConfig;
7 8 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
8 9 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
... ... @@ -51,6 +52,9 @@ public class ZLMRunner implements CommandLineRunner {
51 52 @Autowired
52 53 private MediaConfig mediaConfig;
53 54  
  55 + @Autowired
  56 + private DynamicTask dynamicTask;
  57 +
54 58 @Qualifier("taskExecutor")
55 59 @Autowired
56 60 private ThreadPoolTaskExecutor taskExecutor;
... ... @@ -97,27 +101,25 @@ public class ZLMRunner implements CommandLineRunner {
97 101 all.add(mediaConfig.getMediaSerItem());
98 102 }
99 103 for (MediaServerItem mediaServerItem : all) {
100   - if (startGetMedia == null) startGetMedia = new HashMap<>();
  104 + if (startGetMedia == null) {
  105 + startGetMedia = new HashMap<>();
  106 + }
101 107 startGetMedia.put(mediaServerItem.getId(), true);
102 108 taskExecutor.execute(()->{
103 109 connectZlmServer(mediaServerItem);
104 110 });
105 111 }
106   - Timer timer = new Timer();
107   - // 10分钟后未连接到则不再去主动连接, TODO 并对重启前使用此在zlm的通道发送bye
108   - timer.schedule(new TimerTask() {
109   - @Override
110   - public void run() {
  112 + String taskKey = "zlm-connect-timeout";
  113 + dynamicTask.startDelay(taskKey, ()->{
111 114 if (startGetMedia != null) {
112 115 Set<String> allZlmId = startGetMedia.keySet();
113 116 for (String id : allZlmId) {
114   - logger.error("[ {} ]]主动连接失败,不再主动连接", id);
  117 + logger.error("[ {} ]]主动连接失败,不再尝试连接", id);
115 118 }
116 119 startGetMedia = null;
117 120 }
118   - // TODO 清理数据库中与redis不匹配的zlm
119   - }
120   - }, 60 * 1000 * 10);
  121 + // TODO 清理数据库中与redis不匹配的zlm
  122 + }, 6 * 1000 );
121 123 }
122 124  
123 125 @Async
... ... @@ -139,12 +141,12 @@ public class ZLMRunner implements CommandLineRunner {
139 141 if ( startGetMedia.get(mediaServerItem.getId()) == null || !startGetMedia.get(mediaServerItem.getId())) {
140 142 return null;
141 143 }
142   - JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem);
143   - ZLMServerConfig ZLMServerConfig = null;
144   - if (responseJSON != null) {
145   - JSONArray data = responseJSON.getJSONArray("data");
  144 + JSONObject responseJson = zlmresTfulUtils.getMediaServerConfig(mediaServerItem);
  145 + ZLMServerConfig zlmServerConfig = null;
  146 + if (responseJson != null) {
  147 + JSONArray data = responseJson.getJSONArray("data");
146 148 if (data != null && data.size() > 0) {
147   - ZLMServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class);
  149 + zlmServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class);
148 150 }
149 151 } else {
150 152 logger.error("[ {} ]-[ {}:{} ]第{}次主动连接失败, 2s后重试",
... ... @@ -159,9 +161,9 @@ public class ZLMRunner implements CommandLineRunner {
159 161 } catch (InterruptedException e) {
160 162 e.printStackTrace();
161 163 }
162   - ZLMServerConfig = getMediaServerConfig(mediaServerItem, index += 1);
  164 + zlmServerConfig = getMediaServerConfig(mediaServerItem, index += 1);
163 165 }
164   - return ZLMServerConfig;
  166 + return zlmServerConfig;
165 167  
166 168 }
167 169  
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java
... ... @@ -29,18 +29,22 @@ public class StreamProxyItem extends GbStream {
29 29 this.type = type;
30 30 }
31 31  
  32 + @Override
32 33 public String getApp() {
33 34 return app;
34 35 }
35 36  
  37 + @Override
36 38 public void setApp(String app) {
37 39 this.app = app;
38 40 }
39 41  
  42 + @Override
40 43 public String getStream() {
41 44 return stream;
42 45 }
43 46  
  47 + @Override
44 48 public void setStream(String stream) {
45 49 this.stream = stream;
46 50 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java
... ... @@ -124,18 +124,22 @@ public class StreamPushItem extends GbStream implements Comparable&lt;StreamPushIte
124 124 this.id = id;
125 125 }
126 126  
  127 + @Override
127 128 public String getApp() {
128 129 return app;
129 130 }
130 131  
  132 + @Override
131 133 public void setApp(String app) {
132 134 this.app = app;
133 135 }
134 136  
  137 + @Override
135 138 public String getStream() {
136 139 return stream;
137 140 }
138 141  
  142 + @Override
139 143 public void setStream(String stream) {
140 144 this.stream = stream;
141 145 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
... ... @@ -12,6 +12,8 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
12 12 import org.slf4j.Logger;
13 13 import org.slf4j.LoggerFactory;
14 14 import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.beans.factory.annotation.Qualifier;
  16 +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
15 17 import org.springframework.stereotype.Service;
16 18  
17 19 import javax.sip.DialogState;
... ... @@ -43,7 +45,7 @@ public class DeviceServiceImpl implements IDeviceService {
43 45 }
44 46 logger.info("[添加目录订阅] 设备{}", device.getDeviceId());
45 47 // 添加目录订阅
46   - CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander);
  48 + CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander, dynamicTask);
47 49 // 提前开始刷新订阅
48 50 int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForCatalog(),30);
49 51 // 设置最小值为30
... ... @@ -68,10 +70,10 @@ public class DeviceServiceImpl implements IDeviceService {
68 70 }
69 71 logger.info("[添加移动位置订阅] 设备{}", device.getDeviceId());
70 72 // 添加目录订阅
71   - MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander);
72   - // 提前开始刷新订阅
  73 + MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander, dynamicTask);
73 74 // 设置最小值为30
74 75 int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForMobilePosition(),30);
  76 + // 提前开始刷新订阅
75 77 dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, subscribeCycleForCatalog -1 );
76 78 return true;
77 79 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
... ... @@ -70,7 +70,9 @@ public class GbStreamServiceImpl implements IGbStreamService {
70 70 boolean result = false;
71 71 TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
72 72 ParentPlatform parentPlatform = platformMapper.getParentPlatByServerGBId(platformId);
73   - if (catalogId == null) catalogId = parentPlatform.getCatalogId();
  73 + if (catalogId == null) {
  74 + catalogId = parentPlatform.getCatalogId();
  75 + }
74 76 try {
75 77 List<DeviceChannel> deviceChannelList = new ArrayList<>();
76 78 for (GbStream gbStream : gbStreams) {
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
... ... @@ -54,7 +54,9 @@ public class MediaServiceImpl implements IMediaService {
54 54 if (mediaList != null) {
55 55 if (mediaList.getInteger("code") == 0) {
56 56 JSONArray data = mediaList.getJSONArray("data");
57   - if (data == null) return null;
  57 + if (data == null) {
  58 + return null;
  59 + }
58 60 JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class);
59 61 JSONArray tracks = mediaJSON.getJSONArray("tracks");
60 62 streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks);
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.JSONArray;
5 5 import com.alibaba.fastjson.JSONObject;
6 6 import com.genersoft.iot.vmp.common.StreamInfo;
  7 +import com.genersoft.iot.vmp.conf.DynamicTask;
7 8 import com.genersoft.iot.vmp.conf.UserSetting;
8 9 import com.genersoft.iot.vmp.gb28181.bean.*;
9 10 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
... ... @@ -83,6 +84,9 @@ public class PlayServiceImpl implements IPlayService {
83 84 @Autowired
84 85 private UserSetting userSetting;
85 86  
  87 + @Autowired
  88 + private DynamicTask dynamicTask;
  89 +
86 90  
87 91  
88 92  
... ... @@ -97,7 +101,7 @@ public class PlayServiceImpl implements IPlayService {
97 101 String uuid = UUID.randomUUID().toString();
98 102 msg.setId(uuid);
99 103 playResult.setUuid(uuid);
100   - DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetting.getPlayTimeout());
  104 + DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
101 105 playResult.setResult(result);
102 106 // 录像查询以channelId作为deviceId查询
103 107 resultHolder.put(key, uuid, result);
... ... @@ -234,30 +238,27 @@ public class PlayServiceImpl implements IPlayService {
234 238 }
235 239  
236 240 // 超时处理
237   - Timer timer = new Timer();
  241 + String timeOutTaskKey = UUID.randomUUID().toString();
238 242 SSRCInfo finalSsrcInfo = ssrcInfo;
239   - timer.schedule(new TimerTask() {
240   - @Override
241   - public void run() {
242   - logger.warn(String.format("设备点播超时,deviceId:%s ,channelId:%s", device.getDeviceId(), channelId));
243   -
244   - SIPDialog dialog = streamSession.getDialogByStream(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
245   - if (dialog != null) {
246   - timeoutCallback.run(1, "收流超时");
247   - // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
248   - cmder.streamByeCmd(device.getDeviceId(), channelId, finalSsrcInfo.getStream(), null);
249   - }else {
250   - timeoutCallback.run(0, "点播超时");
251   - mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
252   - mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
253   - streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
254   - }
  243 + dynamicTask.startDelay( timeOutTaskKey,()->{
  244 + logger.warn(String.format("设备点播超时,deviceId:%s ,channelId:%s", device.getDeviceId(), channelId));
  245 +
  246 + SIPDialog dialog = streamSession.getDialogByStream(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
  247 + if (dialog != null) {
  248 + timeoutCallback.run(1, "收流超时");
  249 + // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
  250 + cmder.streamByeCmd(device.getDeviceId(), channelId, finalSsrcInfo.getStream(), null);
  251 + }else {
  252 + timeoutCallback.run(0, "点播超时");
  253 + mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
  254 + mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
  255 + streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
255 256 }
256   - }, userSetting.getPlayTimeout());
  257 + }, userSetting.getPlayTimeout()*1000);
257 258 final String ssrc = ssrcInfo.getSsrc();
258 259 cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> {
259 260 logger.info("收到订阅消息: " + response.toJSONString());
260   - timer.cancel();
  261 + dynamicTask.stop(timeOutTaskKey);
261 262 // hook响应
262 263 onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid);
263 264 hookEvent.response(mediaServerItemInuse, response);
... ... @@ -289,7 +290,7 @@ public class PlayServiceImpl implements IPlayService {
289 290 }
290 291 }
291 292 }, (event) -> {
292   - timer.cancel();
  293 + dynamicTask.stop(timeOutTaskKey);
293 294 mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
294 295 // 释放ssrc
295 296 mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
... ... @@ -331,7 +332,9 @@ public class PlayServiceImpl implements IPlayService {
331 332  
332 333 @Override
333 334 public MediaServerItem getNewMediaServerItem(Device device) {
334   - if (device == null) return null;
  335 + if (device == null) {
  336 + return null;
  337 + }
335 338 String mediaServerId = device.getMediaServerId();
336 339 MediaServerItem mediaServerItem;
337 340 if (mediaServerId == null) {
... ... @@ -350,7 +353,9 @@ public class PlayServiceImpl implements IPlayService {
350 353 String endTime,InviteStreamCallback inviteStreamCallback,
351 354 PlayBackCallback callback) {
352 355 Device device = storager.queryVideoDevice(deviceId);
353   - if (device == null) return null;
  356 + if (device == null) {
  357 + return null;
  358 + }
354 359 MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
355 360 SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true);
356 361  
... ... @@ -362,7 +367,9 @@ public class PlayServiceImpl implements IPlayService {
362 367 String deviceId, String channelId, String startTime,
363 368 String endTime, InviteStreamCallback infoCallBack,
364 369 PlayBackCallback playBackCallback) {
365   - if (mediaServerItem == null || ssrcInfo == null) return null;
  370 + if (mediaServerItem == null || ssrcInfo == null) {
  371 + return null;
  372 + }
366 373 String uuid = UUID.randomUUID().toString();
367 374 String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId;
368 375 DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(30000L);
... ... @@ -377,34 +384,31 @@ public class PlayServiceImpl implements IPlayService {
377 384 msg.setId(uuid);
378 385 msg.setKey(key);
379 386 PlayBackResult<RequestMessage> playBackResult = new PlayBackResult<>();
380   -
381   - Timer timer = new Timer();
382   - timer.schedule(new TimerTask() {
383   - @Override
384   - public void run() {
385   - logger.warn(String.format("设备回放超时,deviceId:%s ,channelId:%s", deviceId, channelId));
386   - playBackResult.setCode(-1);
387   - playBackResult.setData(msg);
388   - playBackCallback.call(playBackResult);
389   - SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream());
  387 + String playBackTimeOutTaskKey = UUID.randomUUID().toString();
  388 + dynamicTask.startDelay(playBackTimeOutTaskKey, ()->{
  389 + logger.warn(String.format("设备回放超时,deviceId:%s ,channelId:%s", deviceId, channelId));
  390 + playBackResult.setCode(-1);
  391 + playBackResult.setData(msg);
  392 + playBackCallback.call(playBackResult);
  393 + SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream());
  394 + // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
  395 + if (dialog != null) {
390 396 // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
391   - if (dialog != null) {
392   - // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
393   - cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null);
394   - }else {
395   - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
396   - mediaServerService.closeRTPServer(deviceId, channelId, ssrcInfo.getStream());
397   - streamSession.remove(deviceId, channelId, ssrcInfo.getStream());
398   - }
399 397 cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null);
400   - // 回复之前所有的点播请求
401   - playBackCallback.call(playBackResult);
  398 + }else {
  399 + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
  400 + mediaServerService.closeRTPServer(deviceId, channelId, ssrcInfo.getStream());
  401 + streamSession.remove(deviceId, channelId, ssrcInfo.getStream());
402 402 }
403   - }, userSetting.getPlayTimeout());
  403 + cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null);
  404 + // 回复之前所有的点播请求
  405 + playBackCallback.call(playBackResult);
  406 + }, userSetting.getPlayTimeout()*1000);
  407 +
404 408 cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack,
405 409 (InviteStreamInfo inviteStreamInfo) -> {
406 410 logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString());
407   - timer.cancel();
  411 + dynamicTask.stop(playBackTimeOutTaskKey);
408 412 StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId);
409 413 if (streamInfo == null) {
410 414 logger.warn("设备回放API调用失败!");
... ... @@ -422,7 +426,7 @@ public class PlayServiceImpl implements IPlayService {
422 426 playBackResult.setResponse(inviteStreamInfo.getResponse());
423 427 playBackCallback.call(playBackResult);
424 428 }, event -> {
425   - timer.cancel();
  429 + dynamicTask.stop(playBackTimeOutTaskKey);
426 430 msg.setData(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg));
427 431 playBackResult.setCode(-1);
428 432 playBackResult.setData(msg);
... ... @@ -436,7 +440,9 @@ public class PlayServiceImpl implements IPlayService {
436 440 @Override
437 441 public DeferredResult<ResponseEntity<String>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
438 442 Device device = storager.queryVideoDevice(deviceId);
439   - if (device == null) return null;
  443 + if (device == null) {
  444 + return null;
  445 + }
440 446 MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
441 447 SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true);
442 448  
... ... @@ -445,7 +451,9 @@ public class PlayServiceImpl implements IPlayService {
445 451  
446 452 @Override
447 453 public DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
448   - if (mediaServerItem == null || ssrcInfo == null) return null;
  454 + if (mediaServerItem == null || ssrcInfo == null) {
  455 + return null;
  456 + }
449 457 String uuid = UUID.randomUUID().toString();
450 458 String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId;
451 459 DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(30000L);
... ... @@ -464,34 +472,31 @@ public class PlayServiceImpl implements IPlayService {
464 472 PlayBackResult<RequestMessage> downloadResult = new PlayBackResult<>();
465 473 downloadResult.setData(msg);
466 474  
467   - Timer timer = new Timer();
468   - timer.schedule(new TimerTask() {
469   - @Override
470   - public void run() {
471   - logger.warn(String.format("录像下载请求超时,deviceId:%s ,channelId:%s", deviceId, channelId));
472   - wvpResult.setCode(-1);
473   - wvpResult.setMsg("录像下载请求超时");
474   - downloadResult.setCode(-1);
475   - hookCallBack.call(downloadResult);
476   - SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream());
  475 + String downLoadTimeOutTaskKey = UUID.randomUUID().toString();
  476 + dynamicTask.startDelay(downLoadTimeOutTaskKey, ()->{
  477 + logger.warn(String.format("录像下载请求超时,deviceId:%s ,channelId:%s", deviceId, channelId));
  478 + wvpResult.setCode(-1);
  479 + wvpResult.setMsg("录像下载请求超时");
  480 + downloadResult.setCode(-1);
  481 + hookCallBack.call(downloadResult);
  482 + SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream());
  483 + // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
  484 + if (dialog != null) {
477 485 // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
478   - if (dialog != null) {
479   - // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
480   - cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null);
481   - }else {
482   - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
483   - mediaServerService.closeRTPServer(deviceId, channelId, ssrcInfo.getStream());
484   - streamSession.remove(deviceId, channelId, ssrcInfo.getStream());
485   - }
486 486 cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null);
487   - // 回复之前所有的点播请求
488   - hookCallBack.call(downloadResult);
  487 + }else {
  488 + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
  489 + mediaServerService.closeRTPServer(deviceId, channelId, ssrcInfo.getStream());
  490 + streamSession.remove(deviceId, channelId, ssrcInfo.getStream());
489 491 }
490   - }, userSetting.getPlayTimeout());
  492 + cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null);
  493 + // 回复之前所有的点播请求
  494 + hookCallBack.call(downloadResult);
  495 + }, userSetting.getPlayTimeout()*1000);
491 496 cmder.downloadStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, infoCallBack,
492 497 inviteStreamInfo -> {
493 498 logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString());
494   - timer.cancel();
  499 + dynamicTask.stop(downLoadTimeOutTaskKey);
495 500 StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId);
496 501 streamInfo.setStartTime(startTime);
497 502 streamInfo.setEndTime(endTime);
... ... @@ -512,7 +517,7 @@ public class PlayServiceImpl implements IPlayService {
512 517 downloadResult.setResponse(inviteStreamInfo.getResponse());
513 518 hookCallBack.call(downloadResult);
514 519 }, event -> {
515   - timer.cancel();
  520 + dynamicTask.stop(downLoadTimeOutTaskKey);
516 521 downloadResult.setCode(-1);
517 522 wvpResult.setCode(-1);
518 523 wvpResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg));
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
... ... @@ -194,7 +194,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
194 194  
195 195 @Override
196 196 public JSONObject removeStreamProxyFromZlm(StreamProxyItem param) {
197   - if (param ==null) return null;
  197 + if (param ==null) {
  198 + return null;
  199 + }
198 200 MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
199 201 JSONObject result = zlmresTfulUtils.closeStreams(mediaServerItem, param.getApp(), param.getStream());
200 202 return result;
... ... @@ -230,7 +232,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
230 232 StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream);
231 233 if (!streamProxy.isEnable() && streamProxy != null) {
232 234 JSONObject jsonObject = addStreamProxyToZlm(streamProxy);
233   - if (jsonObject == null) return false;
  235 + if (jsonObject == null) {
  236 + return false;
  237 + }
234 238 if (jsonObject.getInteger("code") == 0) {
235 239 result = true;
236 240 streamProxy.setEnable(true);
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
... ... @@ -66,7 +66,9 @@ public class StreamPushServiceImpl implements IStreamPushService {
66 66  
67 67 @Override
68 68 public List<StreamPushItem> handleJSON(String jsonData, MediaServerItem mediaServerItem) {
69   - if (jsonData == null) return null;
  69 + if (jsonData == null) {
  70 + return null;
  71 + }
70 72  
71 73 Map<String, StreamPushItem> result = new HashMap<>();
72 74  
... ... @@ -219,7 +221,9 @@ public class StreamPushServiceImpl implements IStreamPushService {
219 221 }
220 222 }
221 223 zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{
222   - if (mediaList == null) return;
  224 + if (mediaList == null) {
  225 + return;
  226 + }
223 227 String dataStr = mediaList.getString("data");
224 228  
225 229 Integer code = mediaList.getInteger("code");
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java
... ... @@ -34,7 +34,9 @@ public class UserServiceImpl implements IUserService {
34 34 @Override
35 35 public int addUser(User user) {
36 36 User userByUsername = userMapper.getUserByUsername(user.getUsername());
37   - if (userByUsername != null) return 0;
  37 + if (userByUsername != null) {
  38 + return 0;
  39 + }
38 40 return userMapper.add(user);
39 41 }
40 42 @Override
... ...
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
... ... @@ -223,4 +223,11 @@ public interface IRedisCatchStorage {
223 223  
224 224 void sendStreamPushRequestedMsg(MessageForPushChannel messageForPushChannel);
225 225  
  226 + /**
  227 + * 判断设备状态
  228 + * @param deviceId 设备ID
  229 + * @return
  230 + */
  231 + public boolean deviceIsOnline(String deviceId);
  232 +
226 233 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
... ... @@ -103,7 +103,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
103 103 */
104 104 @Override
105 105 public boolean stopPlay(StreamInfo streamInfo) {
106   - if (streamInfo == null) return false;
  106 + if (streamInfo == null) {
  107 + return false;
  108 + }
107 109 return redis.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
108 110 userSetting.getServerId(),
109 111 streamInfo.getStream(),
... ... @@ -127,7 +129,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
127 129 @Override
128 130 public StreamInfo queryPlayByStreamId(String streamId) {
129 131 List<Object> playLeys = redis.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
130   - if (playLeys == null || playLeys.size() == 0) return null;
  132 + if (playLeys == null || playLeys.size() == 0) {
  133 + return null;
  134 + }
131 135 return (StreamInfo)redis.get(playLeys.get(0).toString());
132 136 }
133 137  
... ... @@ -137,7 +141,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
137 141 userSetting.getServerId(),
138 142 deviceId,
139 143 channelId));
140   - if (playLeys == null || playLeys.size() == 0) return null;
  144 + if (playLeys == null || playLeys.size() == 0) {
  145 + return null;
  146 + }
141 147 return (StreamInfo)redis.get(playLeys.get(0).toString());
142 148 }
143 149  
... ... @@ -146,7 +152,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
146 152 Map<String, StreamInfo> streamInfos = new HashMap<>();
147 153 // List<Object> playLeys = redis.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId));
148 154 List<Object> players = redis.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),deviceId));
149   - if (players.size() == 0) return streamInfos;
  155 + if (players.size() == 0) {
  156 + return streamInfos;
  157 + }
150 158 for (Object player : players) {
151 159 String key = (String) player;
152 160 StreamInfo streamInfo = (StreamInfo) redis.get(key);
... ... @@ -182,10 +190,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
182 190 deviceChannel.setDeviceId(deviceId);
183 191 deviceChannelMapper.update(deviceChannel);
184 192 }
185   - if (deviceId == null) deviceId = "*";
186   - if (channelId == null) channelId = "*";
187   - if (stream == null) stream = "*";
188   - if (callId == null) callId = "*";
  193 + if (deviceId == null) {
  194 + deviceId = "*";
  195 + }
  196 + if (channelId == null) {
  197 + channelId = "*";
  198 + }
  199 + if (stream == null) {
  200 + stream = "*";
  201 + }
  202 + if (callId == null) {
  203 + callId = "*";
  204 + }
189 205 String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX,
190 206 userSetting.getServerId(),
191 207 deviceId,
... ... @@ -210,10 +226,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
210 226 deviceChannel.setDeviceId(deviceId);
211 227 deviceChannelMapper.update(deviceChannel);
212 228 }
213   - if (deviceId == null) deviceId = "*";
214   - if (channelId == null) channelId = "*";
215   - if (stream == null) stream = "*";
216   - if (callId == null) callId = "*";
  229 + if (deviceId == null) {
  230 + deviceId = "*";
  231 + }
  232 + if (channelId == null) {
  233 + channelId = "*";
  234 + }
  235 + if (stream == null) {
  236 + stream = "*";
  237 + }
  238 + if (callId == null) {
  239 + callId = "*";
  240 + }
217 241 String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
218 242 userSetting.getServerId(),
219 243 deviceId,
... ... @@ -235,10 +259,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
235 259 if (stream == null && callId == null) {
236 260 return null;
237 261 }
238   - if (deviceId == null) deviceId = "*";
239   - if (channelId == null) channelId = "*";
240   - if (stream == null) stream = "*";
241   - if (callId == null) callId = "*";
  262 + if (deviceId == null) {
  263 + deviceId = "*";
  264 + }
  265 + if (channelId == null) {
  266 + channelId = "*";
  267 + }
  268 + if (stream == null) {
  269 + stream = "*";
  270 + }
  271 + if (callId == null) {
  272 + callId = "*";
  273 + }
242 274 String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
243 275 userSetting.getServerId(),
244 276 deviceId,
... ... @@ -328,10 +360,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
328 360  
329 361 @Override
330 362 public SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId) {
331   - if (platformGbId == null) platformGbId = "*";
332   - if (channelId == null) channelId = "*";
333   - if (streamId == null) streamId = "*";
334   - if (callId == null) callId = "*";
  363 + if (platformGbId == null) {
  364 + platformGbId = "*";
  365 + }
  366 + if (channelId == null) {
  367 + channelId = "*";
  368 + }
  369 + if (streamId == null) {
  370 + streamId = "*";
  371 + }
  372 + if (callId == null) {
  373 + callId = "*";
  374 + }
335 375 String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId
336 376 + "_" + channelId + "_" + streamId + "_" + callId;
337 377 List<Object> scan = redis.scan(key);
... ... @@ -344,7 +384,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
344 384  
345 385 @Override
346 386 public List<SendRtpItem> querySendRTPServer(String platformGbId) {
347   - if (platformGbId == null) platformGbId = "*";
  387 + if (platformGbId == null) {
  388 + platformGbId = "*";
  389 + }
348 390 String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*";
349 391 List<Object> queryResult = redis.scan(key);
350 392 List<SendRtpItem> result= new ArrayList<>();
... ... @@ -364,8 +406,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
364 406 */
365 407 @Override
366 408 public void deleteSendRTPServer(String platformGbId, String channelId, String callId, String streamId) {
367   - if (streamId == null) streamId = "*";
368   - if (callId == null) callId = "*";
  409 + if (streamId == null) {
  410 + streamId = "*";
  411 + }
  412 + if (callId == null) {
  413 + callId = "*";
  414 + }
369 415 String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId
370 416 + "_" + channelId + "_" + streamId + "_" + callId;
371 417 List<Object> scan = redis.scan(key);
... ... @@ -473,10 +519,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
473 519 if (stream == null && callId == null) {
474 520 return null;
475 521 }
476   - if (deviceId == null) deviceId = "*";
477   - if (channelId == null) channelId = "*";
478   - if (stream == null) stream = "*";
479   - if (callId == null) callId = "*";
  522 + if (deviceId == null) {
  523 + deviceId = "*";
  524 + }
  525 + if (channelId == null) {
  526 + channelId = "*";
  527 + }
  528 + if (stream == null) {
  529 + stream = "*";
  530 + }
  531 + if (callId == null) {
  532 + callId = "*";
  533 + }
480 534 String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX,
481 535 userSetting.getServerId(),
482 536 deviceId,
... ... @@ -645,4 +699,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
645 699 logger.info("[redis 报警通知] {}: {}", key, JSON.toJSON(msg));
646 700 redis.convertAndSend(key, (JSONObject)JSON.toJSON(msg));
647 701 }
  702 +
  703 + @Override
  704 + public boolean deviceIsOnline(String deviceId) {
  705 + String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + deviceId;
  706 + return redis.hasKey(key);
  707 + }
648 708 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
... ... @@ -460,7 +460,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
460 460 public synchronized boolean outline(String deviceId) {
461 461 logger.info("更新设备离线: " + deviceId);
462 462 Device device = deviceMapper.getDeviceByDeviceId(deviceId);
463   - if (device == null) return false;
  463 + if (device == null) {
  464 + return false;
  465 + }
464 466 device.setOnline(0);
465 467 redisCatchStorage.updateDevice(device);
466 468 return deviceMapper.update(device) > 0;
... ... @@ -714,6 +716,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
714 716 * 删除指定设备的所有移动位置
715 717 * @param deviceId
716 718 */
  719 + @Override
717 720 public int clearMobilePositionsByDeviceId(String deviceId) {
718 721 return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId);
719 722 }
... ... @@ -859,7 +862,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
859 862  
860 863 @Override
861 864 public void updateMediaList(List<StreamPushItem> streamPushItems) {
862   - if (streamPushItems == null || streamPushItems.size() == 0) return;
  865 + if (streamPushItems == null || streamPushItems.size() == 0) {
  866 + return;
  867 + }
863 868 logger.info("updateMediaList: " + streamPushItems.size());
864 869 streamPushMapper.addAll(streamPushItems);
865 870 // TODO 待优化
... ...
src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java
... ... @@ -34,7 +34,9 @@ public class SpringBeanFactory implements ApplicationContextAware {
34 34 * 获取对象 这里重写了bean方法,起主要作用
35 35 */
36 36 public static Object getBean(String beanId) throws BeansException {
37   - if (applicationContext == null) return null;
  37 + if (applicationContext == null) {
  38 + return null;
  39 + }
38 40 return applicationContext.getBean(beanId);
39 41 }
40 42  
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
... ... @@ -85,16 +85,30 @@ public class AlarmController {
85 85 @RequestParam(required = false) String startTime,
86 86 @RequestParam(required = false) String endTime
87 87 ) {
88   - if (StringUtils.isEmpty(alarmPriority)) alarmPriority = null;
89   - if (StringUtils.isEmpty(alarmMethod)) alarmMethod = null;
90   - if (StringUtils.isEmpty(alarmType)) alarmType = null;
91   - if (StringUtils.isEmpty(startTime)) startTime = null;
92   - if (StringUtils.isEmpty(endTime)) endTime = null;
  88 + if (StringUtils.isEmpty(alarmPriority)) {
  89 + alarmPriority = null;
  90 + }
  91 + if (StringUtils.isEmpty(alarmMethod)) {
  92 + alarmMethod = null;
  93 + }
  94 + if (StringUtils.isEmpty(alarmType)) {
  95 + alarmType = null;
  96 + }
  97 + if (StringUtils.isEmpty(startTime)) {
  98 + startTime = null;
  99 + }
  100 + if (StringUtils.isEmpty(endTime)) {
  101 + endTime = null;
  102 + }
93 103  
94 104  
95 105 try {
96   - if (startTime != null) format.parse(startTime);
97   - if (endTime != null) format.parse(endTime);
  106 + if (startTime != null) {
  107 + format.parse(startTime);
  108 + }
  109 + if (endTime != null) {
  110 + format.parse(endTime);
  111 + }
98 112 } catch (ParseException e) {
99 113 return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
100 114 }
... ... @@ -125,9 +139,15 @@ public class AlarmController {
125 139 @RequestParam(required = false) String deviceIds,
126 140 @RequestParam(required = false) String time
127 141 ) {
128   - if (StringUtils.isEmpty(id)) id = null;
129   - if (StringUtils.isEmpty(deviceIds)) deviceIds = null;
130   - if (StringUtils.isEmpty(time)) time = null;
  142 + if (StringUtils.isEmpty(id)) {
  143 + id = null;
  144 + }
  145 + if (StringUtils.isEmpty(deviceIds)) {
  146 + deviceIds = null;
  147 + }
  148 + if (StringUtils.isEmpty(time)) {
  149 + time = null;
  150 + }
131 151 try {
132 152 if (time != null) {
133 153 format.parse(time);
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
... ... @@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
6 6 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
7 7 import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
8 8 import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
9   -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
10 9 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
11 10 import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
12 11 import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
... ... @@ -54,9 +53,6 @@ public class DeviceQuery {
54 53  
55 54 @Autowired
56 55 private DeferredResultHolder resultHolder;
57   -
58   - @Autowired
59   - private DeviceOffLineDetector offLineDetector;
60 56  
61 57 @Autowired
62 58 private IDeviceService deviceService;
... ... @@ -310,9 +306,15 @@ public class DeviceQuery {
310 306  
311 307 if (device != null && device.getDeviceId() != null) {
312 308 Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
313   - if (!StringUtils.isEmpty(device.getName())) deviceInStore.setName(device.getName());
314   - if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset());
315   - if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId());
  309 + if (!StringUtils.isEmpty(device.getName())) {
  310 + deviceInStore.setName(device.getName());
  311 + }
  312 + if (!StringUtils.isEmpty(device.getCharset())) {
  313 + deviceInStore.setCharset(device.getCharset());
  314 + }
  315 + if (!StringUtils.isEmpty(device.getMediaServerId())) {
  316 + deviceInStore.setMediaServerId(device.getMediaServerId());
  317 + }
316 318  
317 319 // 目录订阅相关的信息
318 320 if (device.getSubscribeCycleForCatalog() > 0) {
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
... ... @@ -286,7 +286,9 @@ public class PlatformController {
286 286 return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
287 287 }
288 288 ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId);
289   - if (parentPlatform == null) return new ResponseEntity<>("fail", HttpStatus.OK);
  289 + if (parentPlatform == null) {
  290 + return new ResponseEntity<>("fail", HttpStatus.OK);
  291 + }
290 292 // 发送离线消息,无论是否成功都删除缓存
291 293 commanderForPlatform.unregister(parentPlatform, (event -> {
292 294 // 清空redis缓存
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
... ... @@ -65,16 +65,26 @@ public class LogController {
65 65 @RequestParam(required = false) String startTime,
66 66 @RequestParam(required = false) String endTime
67 67 ) {
68   - if (StringUtils.isEmpty(query)) query = null;
69   - if (StringUtils.isEmpty(startTime)) startTime = null;
70   - if (StringUtils.isEmpty(endTime)) endTime = null;
  68 + if (StringUtils.isEmpty(query)) {
  69 + query = null;
  70 + }
  71 + if (StringUtils.isEmpty(startTime)) {
  72 + startTime = null;
  73 + }
  74 + if (StringUtils.isEmpty(endTime)) {
  75 + endTime = null;
  76 + }
71 77 if (!userSetting.getLogInDatebase()) {
72 78 logger.warn("自动记录日志功能已关闭,查询结果可能不完整。");
73 79 }
74 80  
75 81 try {
76   - if (startTime != null) format.parse(startTime);
77   - if (endTime != null) format.parse(endTime);
  82 + if (startTime != null) {
  83 + format.parse(startTime);
  84 + }
  85 + if (endTime != null) {
  86 + format.parse(endTime);
  87 + }
78 88 } catch (ParseException e) {
79 89 return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
80 90 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
... ... @@ -69,9 +69,15 @@ public class StreamProxyController {
69 69 @ResponseBody
70 70 public WVPResult save(@RequestBody StreamProxyItem param){
71 71 logger.info("添加代理: " + JSONObject.toJSONString(param));
72   - if (StringUtils.isEmpty(param.getMediaServerId())) param.setMediaServerId("auto");
73   - if (StringUtils.isEmpty(param.getType())) param.setType("default");
74   - if (StringUtils.isEmpty(param.getGbId())) param.setGbId(null);
  72 + if (StringUtils.isEmpty(param.getMediaServerId())) {
  73 + param.setMediaServerId("auto");
  74 + }
  75 + if (StringUtils.isEmpty(param.getType())) {
  76 + param.setType("default");
  77 + }
  78 + if (StringUtils.isEmpty(param.getGbId())) {
  79 + param.setGbId(null);
  80 + }
75 81 WVPResult<StreamInfo> result = streamProxyService.save(param);
76 82 return result;
77 83 }
... ...
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
... ... @@ -68,7 +68,7 @@ public class ApiStreamController {
68 68 @RequestParam(required = false)String timeout
69 69  
70 70 ){
71   - DeferredResult<JSONObject> resultDeferredResult = new DeferredResult<>(userSetting.getPlayTimeout() + 10);
  71 + DeferredResult<JSONObject> resultDeferredResult = new DeferredResult<>(userSetting.getPlayTimeout().longValue() + 10);
72 72 Device device = storager.queryVideoDevice(serial);
73 73 if (device == null ) {
74 74 JSONObject result = new JSONObject();
... ...
web_src/src/components/common/jessibuca.vue
1 1 <template>
2   - <div ref="container" @dblclick="fullscreenSwich" style="width:100%;height:100%;background-color: #eee;margin:0 auto;">
  2 + <div ref="container" @dblclick="fullscreenSwich" style="width:100%;height:100%;background-color: #000000;margin:0 auto;">
3 3 <div class="buttons-box" id="buttonsBox">
4 4 <div class="buttons-box-left">
5 5 <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i>
... ...