Commit a2182b5a7ba0ffbba960e774e019a707b5bf26bb
Committed by
GitHub
Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0
Showing
68 changed files
with
733 additions
and
459 deletions
src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
| @@ -7,7 +7,6 @@ import org.springframework.boot.SpringApplication; | @@ -7,7 +7,6 @@ import org.springframework.boot.SpringApplication; | ||
| 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 8 | import org.springframework.boot.web.servlet.ServletComponentScan; | 8 | import org.springframework.boot.web.servlet.ServletComponentScan; |
| 9 | import org.springframework.context.ConfigurableApplicationContext; | 9 | import org.springframework.context.ConfigurableApplicationContext; |
| 10 | -import org.springframework.scheduling.annotation.EnableAsync; | ||
| 11 | import org.springframework.scheduling.annotation.EnableScheduling; | 10 | import org.springframework.scheduling.annotation.EnableScheduling; |
| 12 | import springfox.documentation.oas.annotations.EnableOpenApi; | 11 | import springfox.documentation.oas.annotations.EnableOpenApi; |
| 13 | 12 |
src/main/java/com/genersoft/iot/vmp/common/ApiSaveConstant.java
| 1 | package com.genersoft.iot.vmp.common; | 1 | package com.genersoft.iot.vmp.common; |
| 2 | 2 | ||
| 3 | +/** | ||
| 4 | + * 为API重命名, 方便向数据库记录数据的时候展示 | ||
| 5 | + * @author lin | ||
| 6 | + */ | ||
| 3 | public class ApiSaveConstant { | 7 | public class ApiSaveConstant { |
| 4 | 8 | ||
| 5 | public static String getVal(String key) { | 9 | public static String getVal(String key) { |
| @@ -35,35 +39,47 @@ public class ApiSaveConstant { | @@ -35,35 +39,47 @@ public class ApiSaveConstant { | ||
| 35 | return "[设备控制] 强制关键帧"; | 39 | return "[设备控制] 强制关键帧"; |
| 36 | case "home_position": | 40 | case "home_position": |
| 37 | return "[设备控制] 看守位控制"; | 41 | return "[设备控制] 看守位控制"; |
| 42 | + default: | ||
| 43 | + return ""; | ||
| 38 | } | 44 | } |
| 39 | - break; | ||
| 40 | case "query": | 45 | case "query": |
| 41 | - if (keyItemArray.length <= 5) return null; | 46 | + if (keyItemArray.length <= 5) { |
| 47 | + return null; | ||
| 48 | + } | ||
| 42 | switch (keyItemArray[4]) { | 49 | switch (keyItemArray[4]) { |
| 43 | case "devices": | 50 | case "devices": |
| 44 | - if (keyItemArray.length < 7) return null; | 51 | + if (keyItemArray.length < 7) { |
| 52 | + return null; | ||
| 53 | + } | ||
| 45 | switch (keyItemArray[6]) { | 54 | switch (keyItemArray[6]) { |
| 46 | case "sync": | 55 | case "sync": |
| 47 | return "[设备查询] 同步设备通道"; | 56 | return "[设备查询] 同步设备通道"; |
| 48 | case "delete": | 57 | case "delete": |
| 49 | return "[设备查询] 移除设备"; | 58 | return "[设备查询] 移除设备"; |
| 59 | + default: | ||
| 60 | + return ""; | ||
| 50 | } | 61 | } |
| 51 | - break; | ||
| 52 | case "channel": | 62 | case "channel": |
| 53 | return "[设备查询] 更新通道信息"; | 63 | return "[设备查询] 更新通道信息"; |
| 54 | case "transport": | 64 | case "transport": |
| 55 | return "[设备查询] 修改数据流传输模式"; | 65 | return "[设备查询] 修改数据流传输模式"; |
| 66 | + default: | ||
| 67 | + return ""; | ||
| 56 | } | 68 | } |
| 57 | - break; | 69 | + default: |
| 70 | + return ""; | ||
| 58 | } | 71 | } |
| 72 | + | ||
| 73 | + break; | ||
| 59 | case "gbStream": | 74 | case "gbStream": |
| 60 | switch (keyItemArray[3]) { | 75 | switch (keyItemArray[3]) { |
| 61 | case "del": | 76 | case "del": |
| 62 | return "移除通道与国标的关联"; | 77 | return "移除通道与国标的关联"; |
| 63 | case "add": | 78 | case "add": |
| 64 | return "添加通道与国标的关联"; | 79 | return "添加通道与国标的关联"; |
| 80 | + default: | ||
| 81 | + return ""; | ||
| 65 | } | 82 | } |
| 66 | - break; | ||
| 67 | case "media": | 83 | case "media": |
| 68 | break; | 84 | break; |
| 69 | case "position": | 85 | case "position": |
| @@ -81,8 +97,9 @@ public class ApiSaveConstant { | @@ -81,8 +97,9 @@ public class ApiSaveConstant { | ||
| 81 | return "向上级平台添加国标通道"; | 97 | return "向上级平台添加国标通道"; |
| 82 | case "del_channel_for_gb": | 98 | case "del_channel_for_gb": |
| 83 | return "从上级平台移除国标通道"; | 99 | return "从上级平台移除国标通道"; |
| 100 | + default: | ||
| 101 | + return ""; | ||
| 84 | } | 102 | } |
| 85 | - break; | ||
| 86 | case "platform_gb_stream": | 103 | case "platform_gb_stream": |
| 87 | break; | 104 | break; |
| 88 | case "play": | 105 | case "play": |
| @@ -97,32 +114,36 @@ public class ApiSaveConstant { | @@ -97,32 +114,36 @@ public class ApiSaveConstant { | ||
| 97 | return "结束转码"; | 114 | return "结束转码"; |
| 98 | case "broadcast": | 115 | case "broadcast": |
| 99 | return "语音广播"; | 116 | return "语音广播"; |
| 117 | + default: | ||
| 118 | + return ""; | ||
| 100 | } | 119 | } |
| 101 | - break; | ||
| 102 | case "download": | 120 | case "download": |
| 103 | switch (keyItemArray[3]) { | 121 | switch (keyItemArray[3]) { |
| 104 | case "start": | 122 | case "start": |
| 105 | return "开始历史媒体下载"; | 123 | return "开始历史媒体下载"; |
| 106 | case "stop": | 124 | case "stop": |
| 107 | return "停止历史媒体下载"; | 125 | return "停止历史媒体下载"; |
| 126 | + default: | ||
| 127 | + return ""; | ||
| 108 | } | 128 | } |
| 109 | - break; | ||
| 110 | case "playback": | 129 | case "playback": |
| 111 | switch (keyItemArray[3]) { | 130 | switch (keyItemArray[3]) { |
| 112 | case "start": | 131 | case "start": |
| 113 | return "开始视频回放"; | 132 | return "开始视频回放"; |
| 114 | case "stop": | 133 | case "stop": |
| 115 | return "停止视频回放"; | 134 | return "停止视频回放"; |
| 135 | + default: | ||
| 136 | + return ""; | ||
| 116 | } | 137 | } |
| 117 | - break; | ||
| 118 | case "ptz": | 138 | case "ptz": |
| 119 | switch (keyItemArray[3]) { | 139 | switch (keyItemArray[3]) { |
| 120 | case "control": | 140 | case "control": |
| 121 | return "云台控制"; | 141 | return "云台控制"; |
| 122 | case "front_end_command": | 142 | case "front_end_command": |
| 123 | return "通用前端控制命令"; | 143 | return "通用前端控制命令"; |
| 144 | + default: | ||
| 145 | + return ""; | ||
| 124 | } | 146 | } |
| 125 | - break; | ||
| 126 | case "gb_record": | 147 | case "gb_record": |
| 127 | break; | 148 | break; |
| 128 | case "onvif": | 149 | case "onvif": |
| @@ -142,16 +163,18 @@ public class ApiSaveConstant { | @@ -142,16 +163,18 @@ public class ApiSaveConstant { | ||
| 142 | return "启用代理"; | 163 | return "启用代理"; |
| 143 | case "stop": | 164 | case "stop": |
| 144 | return "停用代理"; | 165 | return "停用代理"; |
| 166 | + default: | ||
| 167 | + return ""; | ||
| 145 | } | 168 | } |
| 146 | - break; | ||
| 147 | case "push": | 169 | case "push": |
| 148 | switch (keyItemArray[3]) { | 170 | switch (keyItemArray[3]) { |
| 149 | case "save_to_gb": | 171 | case "save_to_gb": |
| 150 | return "将推流添加到国标"; | 172 | return "将推流添加到国标"; |
| 151 | case "remove_form_gb": | 173 | case "remove_form_gb": |
| 152 | return "将推流移出到国标"; | 174 | return "将推流移出到国标"; |
| 175 | + default: | ||
| 176 | + return ""; | ||
| 153 | } | 177 | } |
| 154 | - break; | ||
| 155 | case "user": | 178 | case "user": |
| 156 | switch (keyItemArray[3]) { | 179 | switch (keyItemArray[3]) { |
| 157 | case "login": | 180 | case "login": |
| @@ -162,8 +185,11 @@ public class ApiSaveConstant { | @@ -162,8 +185,11 @@ public class ApiSaveConstant { | ||
| 162 | return "添加用户"; | 185 | return "添加用户"; |
| 163 | case "delete": | 186 | case "delete": |
| 164 | return "删除用户"; | 187 | return "删除用户"; |
| 188 | + default: | ||
| 189 | + return ""; | ||
| 165 | } | 190 | } |
| 166 | - break; | 191 | + default: |
| 192 | + return ""; | ||
| 167 | } | 193 | } |
| 168 | } | 194 | } |
| 169 | return null; | 195 | return null; |
src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java
| @@ -7,6 +7,10 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | @@ -7,6 +7,10 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
| 7 | 7 | ||
| 8 | import java.util.concurrent.ThreadPoolExecutor; | 8 | import java.util.concurrent.ThreadPoolExecutor; |
| 9 | 9 | ||
| 10 | +/** | ||
| 11 | + * ThreadPoolTask 配置类 | ||
| 12 | + * @author lin | ||
| 13 | + */ | ||
| 10 | @Configuration | 14 | @Configuration |
| 11 | @EnableAsync(proxyTargetClass = true) | 15 | @EnableAsync(proxyTargetClass = true) |
| 12 | public class ThreadPoolTaskConfig { | 16 | public class ThreadPoolTaskConfig { |
| @@ -40,6 +44,10 @@ public class ThreadPoolTaskConfig { | @@ -40,6 +44,10 @@ public class ThreadPoolTaskConfig { | ||
| 40 | */ | 44 | */ |
| 41 | private static final String threadNamePrefix = "wvp-"; | 45 | private static final String threadNamePrefix = "wvp-"; |
| 42 | 46 | ||
| 47 | + /** | ||
| 48 | + * | ||
| 49 | + * @return | ||
| 50 | + */ | ||
| 43 | @Bean("taskExecutor") // bean的名称,默认为首字母小写的方法名 | 51 | @Bean("taskExecutor") // bean的名称,默认为首字母小写的方法名 |
| 44 | public ThreadPoolTaskExecutor taskExecutor() { | 52 | public ThreadPoolTaskExecutor taskExecutor() { |
| 45 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | 53 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
| 1 | package com.genersoft.iot.vmp.conf; | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | ||
| 3 | +import io.swagger.models.auth.In; | ||
| 3 | import org.springframework.boot.context.properties.ConfigurationProperties; | 4 | import org.springframework.boot.context.properties.ConfigurationProperties; |
| 4 | import org.springframework.stereotype.Component; | 5 | import org.springframework.stereotype.Component; |
| 5 | 6 | ||
| @@ -19,7 +20,7 @@ public class UserSetting { | @@ -19,7 +20,7 @@ public class UserSetting { | ||
| 19 | 20 | ||
| 20 | private Boolean seniorSdp = Boolean.FALSE; | 21 | private Boolean seniorSdp = Boolean.FALSE; |
| 21 | 22 | ||
| 22 | - private Long playTimeout = 18000L; | 23 | + private Integer playTimeout = 18000; |
| 23 | 24 | ||
| 24 | private int platformPlayTimeout = 60000; | 25 | private int platformPlayTimeout = 60000; |
| 25 | 26 | ||
| @@ -55,7 +56,7 @@ public class UserSetting { | @@ -55,7 +56,7 @@ public class UserSetting { | ||
| 55 | return seniorSdp; | 56 | return seniorSdp; |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | - public Long getPlayTimeout() { | 59 | + public Integer getPlayTimeout() { |
| 59 | return playTimeout; | 60 | return playTimeout; |
| 60 | } | 61 | } |
| 61 | 62 | ||
| @@ -83,7 +84,7 @@ public class UserSetting { | @@ -83,7 +84,7 @@ public class UserSetting { | ||
| 83 | this.seniorSdp = seniorSdp; | 84 | this.seniorSdp = seniorSdp; |
| 84 | } | 85 | } |
| 85 | 86 | ||
| 86 | - public void setPlayTimeout(Long playTimeout) { | 87 | + public void setPlayTimeout(Integer playTimeout) { |
| 87 | this.playTimeout = playTimeout; | 88 | this.playTimeout = playTimeout; |
| 88 | } | 89 | } |
| 89 | 90 |
src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
| @@ -13,6 +13,7 @@ import java.io.IOException; | @@ -13,6 +13,7 @@ import java.io.IOException; | ||
| 13 | 13 | ||
| 14 | /** | 14 | /** |
| 15 | * 处理匿名用户访问逻辑 | 15 | * 处理匿名用户访问逻辑 |
| 16 | + * @author lin | ||
| 16 | */ | 17 | */ |
| 17 | @Component | 18 | @Component |
| 18 | public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoint { | 19 | public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoint { |
| @@ -21,7 +22,6 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi | @@ -21,7 +22,6 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi | ||
| 21 | 22 | ||
| 22 | @Override | 23 | @Override |
| 23 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { | 24 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { |
| 24 | -// logger.debug("用户需要登录,访问[{}]失败,AuthenticationException=[{}]", request.getRequestURI(), e.getMessage()); | ||
| 25 | // 允许跨域 | 25 | // 允许跨域 |
| 26 | response.setHeader("Access-Control-Allow-Origin", "*"); | 26 | response.setHeader("Access-Control-Allow-Origin", "*"); |
| 27 | // 允许自定义请求头token(允许head跨域) | 27 | // 允许自定义请求头token(允许head跨域) |
| @@ -30,7 +30,8 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi | @@ -30,7 +30,8 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi | ||
| 30 | JSONObject jsonObject = new JSONObject(); | 30 | JSONObject jsonObject = new JSONObject(); |
| 31 | jsonObject.put("code", "-1"); | 31 | jsonObject.put("code", "-1"); |
| 32 | jsonObject.put("msg", "请登录后重新请求"); | 32 | jsonObject.put("msg", "请登录后重新请求"); |
| 33 | - if (request.getRequestURI().contains("api/user/login")){ | 33 | + String logUri = "api/user/login"; |
| 34 | + if (request.getRequestURI().contains(logUri)){ | ||
| 34 | jsonObject.put("msg", e.getMessage()); | 35 | jsonObject.put("msg", e.getMessage()); |
| 35 | } | 36 | } |
| 36 | response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); | 37 | response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); |
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
| @@ -8,6 +8,7 @@ import org.slf4j.Logger; | @@ -8,6 +8,7 @@ import org.slf4j.Logger; | ||
| 8 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.context.annotation.Bean; | 10 | import org.springframework.context.annotation.Bean; |
| 11 | +import org.springframework.context.annotation.Configuration; | ||
| 11 | import org.springframework.context.annotation.DependsOn; | 12 | import org.springframework.context.annotation.DependsOn; |
| 12 | import org.springframework.stereotype.Component; | 13 | import org.springframework.stereotype.Component; |
| 13 | 14 | ||
| @@ -18,7 +19,7 @@ import java.util.concurrent.LinkedBlockingQueue; | @@ -18,7 +19,7 @@ import java.util.concurrent.LinkedBlockingQueue; | ||
| 18 | import java.util.concurrent.ThreadPoolExecutor; | 19 | import java.util.concurrent.ThreadPoolExecutor; |
| 19 | import java.util.concurrent.TimeUnit; | 20 | import java.util.concurrent.TimeUnit; |
| 20 | 21 | ||
| 21 | -@Component | 22 | +@Configuration |
| 22 | public class SipLayer{ | 23 | public class SipLayer{ |
| 23 | 24 | ||
| 24 | private final static Logger logger = LoggerFactory.getLogger(SipLayer.class); | 25 | private final static Logger logger = LoggerFactory.getLogger(SipLayer.class); |
| @@ -35,7 +36,7 @@ public class SipLayer{ | @@ -35,7 +36,7 @@ public class SipLayer{ | ||
| 35 | 36 | ||
| 36 | 37 | ||
| 37 | @Bean("sipFactory") | 38 | @Bean("sipFactory") |
| 38 | - private SipFactory createSipFactory() { | 39 | + SipFactory createSipFactory() { |
| 39 | sipFactory = SipFactory.getInstance(); | 40 | sipFactory = SipFactory.getInstance(); |
| 40 | sipFactory.setPathName("gov.nist"); | 41 | sipFactory.setPathName("gov.nist"); |
| 41 | return sipFactory; | 42 | return sipFactory; |
| @@ -43,7 +44,7 @@ public class SipLayer{ | @@ -43,7 +44,7 @@ public class SipLayer{ | ||
| 43 | 44 | ||
| 44 | @Bean("sipStack") | 45 | @Bean("sipStack") |
| 45 | @DependsOn({"sipFactory"}) | 46 | @DependsOn({"sipFactory"}) |
| 46 | - private SipStack createSipStack() throws PeerUnavailableException { | 47 | + SipStack createSipStack() throws PeerUnavailableException { |
| 47 | Properties properties = new Properties(); | 48 | Properties properties = new Properties(); |
| 48 | properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP"); | 49 | properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP"); |
| 49 | properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getMonitorIp()); | 50 | properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getMonitorIp()); |
| @@ -64,7 +65,7 @@ public class SipLayer{ | @@ -64,7 +65,7 @@ public class SipLayer{ | ||
| 64 | 65 | ||
| 65 | @Bean(name = "tcpSipProvider") | 66 | @Bean(name = "tcpSipProvider") |
| 66 | @DependsOn("sipStack") | 67 | @DependsOn("sipStack") |
| 67 | - private SipProviderImpl startTcpListener() { | 68 | + SipProviderImpl startTcpListener() { |
| 68 | ListeningPoint tcpListeningPoint = null; | 69 | ListeningPoint tcpListeningPoint = null; |
| 69 | SipProviderImpl tcpSipProvider = null; | 70 | SipProviderImpl tcpSipProvider = null; |
| 70 | try { | 71 | try { |
| @@ -89,7 +90,7 @@ public class SipLayer{ | @@ -89,7 +90,7 @@ public class SipLayer{ | ||
| 89 | 90 | ||
| 90 | @Bean(name = "udpSipProvider") | 91 | @Bean(name = "udpSipProvider") |
| 91 | @DependsOn("sipStack") | 92 | @DependsOn("sipStack") |
| 92 | - private SipProviderImpl startUdpListener() { | 93 | + SipProviderImpl startUdpListener() { |
| 93 | ListeningPoint udpListeningPoint = null; | 94 | ListeningPoint udpListeningPoint = null; |
| 94 | SipProviderImpl udpSipProvider = null; | 95 | SipProviderImpl udpSipProvider = null; |
| 95 | try { | 96 | try { |
src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java
| @@ -129,7 +129,9 @@ public class DigestServerAuthenticationHelper { | @@ -129,7 +129,9 @@ public class DigestServerAuthenticationHelper { | ||
| 129 | */ | 129 | */ |
| 130 | public boolean doAuthenticateHashedPassword(Request request, String hashedPassword) { | 130 | public boolean doAuthenticateHashedPassword(Request request, String hashedPassword) { |
| 131 | AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); | 131 | AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); |
| 132 | - if ( authHeader == null ) return false; | 132 | + if ( authHeader == null ) { |
| 133 | + return false; | ||
| 134 | + } | ||
| 133 | String realm = authHeader.getRealm(); | 135 | String realm = authHeader.getRealm(); |
| 134 | String username = authHeader.getUsername(); | 136 | String username = authHeader.getUsername(); |
| 135 | 137 | ||
| @@ -176,7 +178,9 @@ public class DigestServerAuthenticationHelper { | @@ -176,7 +178,9 @@ public class DigestServerAuthenticationHelper { | ||
| 176 | */ | 178 | */ |
| 177 | public boolean doAuthenticatePlainTextPassword(Request request, String pass) { | 179 | public boolean doAuthenticatePlainTextPassword(Request request, String pass) { |
| 178 | AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); | 180 | AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); |
| 179 | - if ( authHeader == null ) return false; | 181 | + if ( authHeader == null ) { |
| 182 | + return false; | ||
| 183 | + } | ||
| 180 | String realm = authHeader.getRealm().trim(); | 184 | String realm = authHeader.getRealm().trim(); |
| 181 | String username = authHeader.getUsername().trim(); | 185 | String username = authHeader.getUsername().trim(); |
| 182 | 186 |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.gb28181.bean; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 报警方式 | ||
| 5 | + * @author lin | ||
| 6 | + * 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警, | ||
| 7 | + * 7其他报警;可以为直接组合如12为电话报警或 设备报警- | ||
| 8 | + */ | ||
| 9 | +public enum DeviceAlarmMethod { | ||
| 10 | + // 1为电话报警 | ||
| 11 | + Telephone(1), | ||
| 12 | + | ||
| 13 | + // 2为设备报警 | ||
| 14 | + Device(2), | ||
| 15 | + | ||
| 16 | + // 3为短信报警 | ||
| 17 | + SMS(3), | ||
| 18 | + | ||
| 19 | + // 4为 GPS报警 | ||
| 20 | + GPS(4), | ||
| 21 | + | ||
| 22 | + // 5为视频报警 | ||
| 23 | + Video(5), | ||
| 24 | + | ||
| 25 | + // 6为设备故障报警 | ||
| 26 | + DeviceFailure(6), | ||
| 27 | + | ||
| 28 | + // 7其他报警 | ||
| 29 | + Other(7); | ||
| 30 | + | ||
| 31 | + private final int val; | ||
| 32 | + | ||
| 33 | + DeviceAlarmMethod(int val) { | ||
| 34 | + this.val=val; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public int getVal() { | ||
| 38 | + return val; | ||
| 39 | + } | ||
| 40 | +} |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
| @@ -25,6 +25,7 @@ public class GbStream extends PlatformGbStream{ | @@ -25,6 +25,7 @@ public class GbStream extends PlatformGbStream{ | ||
| 25 | return gbStreamId; | 25 | return gbStreamId; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | + @Override | ||
| 28 | public void setGbStreamId(Integer gbStreamId) { | 29 | public void setGbStreamId(Integer gbStreamId) { |
| 29 | this.gbStreamId = gbStreamId; | 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,7 +59,9 @@ public class SubscribeHolder { | ||
| 59 | mobilePositionMap.put(platformId, subscribeInfo); | 59 | mobilePositionMap.put(platformId, subscribeInfo); |
| 60 | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId; | 60 | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId; |
| 61 | // 添加任务处理GPS定时推送 | 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 | String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; | 65 | String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; |
| 64 | dynamicTask.stop(taskOverdueKey); | 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<OnlineEvent> { | @@ -62,7 +62,9 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> { | ||
| 62 | 62 | ||
| 63 | logger.info("设备上线事件触发,deviceId:" + event.getDevice().getDeviceId() + ",from:" + event.getFrom()); | 63 | logger.info("设备上线事件触发,deviceId:" + event.getDevice().getDeviceId() + ",from:" + event.getFrom()); |
| 64 | Device device = event.getDevice(); | 64 | Device device = event.getDevice(); |
| 65 | - if (device == null) return; | 65 | + if (device == null) { |
| 66 | + return; | ||
| 67 | + } | ||
| 66 | String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId(); | 68 | String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId(); |
| 67 | Device deviceInStore = storager.queryVideoDevice(device.getDeviceId()); | 69 | Device deviceInStore = storager.queryVideoDevice(device.getDeviceId()); |
| 68 | device.setOnline(1); | 70 | device.setOnline(1); |
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java
| 1 | package com.genersoft.iot.vmp.gb28181.event.platformNotRegister; | 1 | package com.genersoft.iot.vmp.gb28181.event.platformNotRegister; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.conf.DynamicTask; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 4 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 5 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 6 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| @@ -22,6 +23,8 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla | @@ -22,6 +23,8 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla | ||
| 22 | private IVideoManagerStorage storager; | 23 | private IVideoManagerStorage storager; |
| 23 | @Autowired | 24 | @Autowired |
| 24 | private ISIPCommanderForPlatform sipCommanderFroPlatform; | 25 | private ISIPCommanderForPlatform sipCommanderFroPlatform; |
| 26 | + @Autowired | ||
| 27 | + private DynamicTask dynamicTask; | ||
| 25 | 28 | ||
| 26 | @Override | 29 | @Override |
| 27 | public void onApplicationEvent(PlatformCycleRegisterEvent event) { | 30 | public void onApplicationEvent(PlatformCycleRegisterEvent event) { |
| @@ -31,17 +34,13 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla | @@ -31,17 +34,13 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla | ||
| 31 | logger.info("[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event.getPlatformGbID()); | 34 | logger.info("[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event.getPlatformGbID()); |
| 32 | return; | 35 | return; |
| 33 | } | 36 | } |
| 34 | - Timer timer = new Timer(); | 37 | + String taskKey = "platform-cycle-register" + parentPlatform.getServerGBId();; |
| 35 | SipSubscribe.Event okEvent = (responseEvent)->{ | 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 | package com.genersoft.iot.vmp.gb28181.event.platformNotRegister; | 1 | package com.genersoft.iot.vmp.gb28181.event.platformNotRegister; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.conf.DynamicTask; | ||
| 3 | import com.genersoft.iot.vmp.conf.SipConfig; | 4 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | 6 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| @@ -46,6 +47,9 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf | @@ -46,6 +47,9 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf | ||
| 46 | @Autowired | 47 | @Autowired |
| 47 | private SipConfig config; | 48 | private SipConfig config; |
| 48 | 49 | ||
| 50 | + @Autowired | ||
| 51 | + private DynamicTask dynamicTask; | ||
| 52 | + | ||
| 49 | // @Autowired | 53 | // @Autowired |
| 50 | // private RedisUtil redis; | 54 | // private RedisUtil redis; |
| 51 | 55 | ||
| @@ -75,19 +79,13 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf | @@ -75,19 +79,13 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf | ||
| 75 | } | 79 | } |
| 76 | 80 | ||
| 77 | } | 81 | } |
| 78 | - Timer timer = new Timer(); | 82 | + String taskKey = "platform-not-register-" + parentPlatform.getServerGBId(); |
| 79 | SipSubscribe.Event okEvent = (responseEvent)->{ | 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<CatalogEvent> { | @@ -60,7 +60,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | ||
| 60 | Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); | 60 | Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); |
| 61 | if (event.getPlatformId() != null) { | 61 | if (event.getPlatformId() != null) { |
| 62 | parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); | 62 | parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); |
| 63 | - if (parentPlatform != null && !parentPlatform.isStatus())return; | 63 | + if (parentPlatform != null && !parentPlatform.isStatus()) { |
| 64 | + return; | ||
| 65 | + } | ||
| 64 | subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); | 66 | subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); |
| 65 | 67 | ||
| 66 | if (subscribe == null) { | 68 | if (subscribe == null) { |
| @@ -80,7 +82,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | @@ -80,7 +82,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | ||
| 80 | }else if (event.getGbStreams() != null) { | 82 | }else if (event.getGbStreams() != null) { |
| 81 | if (platforms.size() > 0) { | 83 | if (platforms.size() > 0) { |
| 82 | for (GbStream gbStream : event.getGbStreams()) { | 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 | List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms); | 88 | List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms); |
| 85 | parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB); | 89 | parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB); |
| 86 | } | 90 | } |
| @@ -113,7 +117,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | @@ -113,7 +117,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | ||
| 113 | if (parentPlatforms != null && parentPlatforms.size() > 0) { | 117 | if (parentPlatforms != null && parentPlatforms.size() > 0) { |
| 114 | for (ParentPlatform platform : parentPlatforms) { | 118 | for (ParentPlatform platform : parentPlatforms) { |
| 115 | SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); | 119 | SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); |
| 116 | - if (subscribeInfo == null) continue; | 120 | + if (subscribeInfo == null) { |
| 121 | + continue; | ||
| 122 | + } | ||
| 117 | logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); | 123 | logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); |
| 118 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); | 124 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); |
| 119 | DeviceChannel deviceChannel = new DeviceChannel(); | 125 | DeviceChannel deviceChannel = new DeviceChannel(); |
| @@ -155,7 +161,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | @@ -155,7 +161,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | ||
| 155 | if (parentPlatforms != null && parentPlatforms.size() > 0) { | 161 | if (parentPlatforms != null && parentPlatforms.size() > 0) { |
| 156 | for (ParentPlatform platform : parentPlatforms) { | 162 | for (ParentPlatform platform : parentPlatforms) { |
| 157 | SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); | 163 | SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); |
| 158 | - if (subscribeInfo == null) continue; | 164 | + if (subscribeInfo == null) { |
| 165 | + continue; | ||
| 166 | + } | ||
| 159 | logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); | 167 | logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); |
| 160 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); | 168 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); |
| 161 | DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(platform.getServerGBId(), gbId); | 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,19 +65,25 @@ public class CatalogDataCatch { | ||
| 65 | 65 | ||
| 66 | public List<DeviceChannel> get(String deviceId) { | 66 | public List<DeviceChannel> get(String deviceId) { |
| 67 | CatalogData catalogData = data.get(deviceId); | 67 | CatalogData catalogData = data.get(deviceId); |
| 68 | - if (catalogData == null) return null; | 68 | + if (catalogData == null) { |
| 69 | + return null; | ||
| 70 | + } | ||
| 69 | return catalogData.getChannelList(); | 71 | return catalogData.getChannelList(); |
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | public int getTotal(String deviceId) { | 74 | public int getTotal(String deviceId) { |
| 73 | CatalogData catalogData = data.get(deviceId); | 75 | CatalogData catalogData = data.get(deviceId); |
| 74 | - if (catalogData == null) return 0; | 76 | + if (catalogData == null) { |
| 77 | + return 0; | ||
| 78 | + } | ||
| 75 | return catalogData.getTotal(); | 79 | return catalogData.getTotal(); |
| 76 | } | 80 | } |
| 77 | 81 | ||
| 78 | public SyncStatus getSyncStatus(String deviceId) { | 82 | public SyncStatus getSyncStatus(String deviceId) { |
| 79 | CatalogData catalogData = data.get(deviceId); | 83 | CatalogData catalogData = data.get(deviceId); |
| 80 | - if (catalogData == null) return null; | 84 | + if (catalogData == null) { |
| 85 | + return null; | ||
| 86 | + } | ||
| 81 | SyncStatus syncStatus = new SyncStatus(); | 87 | SyncStatus syncStatus = new SyncStatus(); |
| 82 | syncStatus.setCurrent(catalogData.getChannelList().size()); | 88 | syncStatus.setCurrent(catalogData.getChannelList().size()); |
| 83 | syncStatus.setTotal(catalogData.getTotal()); | 89 | syncStatus.setTotal(catalogData.getTotal()); |
| @@ -87,7 +93,9 @@ public class CatalogDataCatch { | @@ -87,7 +93,9 @@ public class CatalogDataCatch { | ||
| 87 | 93 | ||
| 88 | public boolean isSyncRunning(String deviceId) { | 94 | public boolean isSyncRunning(String deviceId) { |
| 89 | CatalogData catalogData = data.get(deviceId); | 95 | CatalogData catalogData = data.get(deviceId); |
| 90 | - if (catalogData == null) return false; | 96 | + if (catalogData == null) { |
| 97 | + return false; | ||
| 98 | + } | ||
| 91 | return !catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end); | 99 | return !catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end); |
| 92 | } | 100 | } |
| 93 | 101 | ||
| @@ -125,7 +133,9 @@ public class CatalogDataCatch { | @@ -125,7 +133,9 @@ public class CatalogDataCatch { | ||
| 125 | 133 | ||
| 126 | public void setChannelSyncEnd(String deviceId, String errorMsg) { | 134 | public void setChannelSyncEnd(String deviceId, String errorMsg) { |
| 127 | CatalogData catalogData = data.get(deviceId); | 135 | CatalogData catalogData = data.get(deviceId); |
| 128 | - if (catalogData == null)return; | 136 | + if (catalogData == null) { |
| 137 | + return; | ||
| 138 | + } | ||
| 129 | catalogData.setStatus(CatalogData.CatalogDataStatus.end); | 139 | catalogData.setStatus(CatalogData.CatalogDataStatus.end); |
| 130 | catalogData.setErrorMsg(errorMsg); | 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,7 +78,9 @@ public class VideoStreamSessionManager { | ||
| 78 | 78 | ||
| 79 | public ClientTransaction getTransactionByStream(String deviceId, String channelId, String stream){ | 79 | public ClientTransaction getTransactionByStream(String deviceId, String channelId, String stream){ |
| 80 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); | 80 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); |
| 81 | - if (ssrcTransaction == null) return null; | 81 | + if (ssrcTransaction == null) { |
| 82 | + return null; | ||
| 83 | + } | ||
| 82 | byte[] transactionByteArray = ssrcTransaction.getTransaction(); | 84 | byte[] transactionByteArray = ssrcTransaction.getTransaction(); |
| 83 | ClientTransaction clientTransaction = (ClientTransaction)SerializeUtils.deSerialize(transactionByteArray); | 85 | ClientTransaction clientTransaction = (ClientTransaction)SerializeUtils.deSerialize(transactionByteArray); |
| 84 | return clientTransaction; | 86 | return clientTransaction; |
| @@ -86,39 +88,63 @@ public class VideoStreamSessionManager { | @@ -86,39 +88,63 @@ public class VideoStreamSessionManager { | ||
| 86 | 88 | ||
| 87 | public SIPDialog getDialogByStream(String deviceId, String channelId, String stream){ | 89 | public SIPDialog getDialogByStream(String deviceId, String channelId, String stream){ |
| 88 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); | 90 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); |
| 89 | - if (ssrcTransaction == null) return null; | 91 | + if (ssrcTransaction == null) { |
| 92 | + return null; | ||
| 93 | + } | ||
| 90 | byte[] dialogByteArray = ssrcTransaction.getDialog(); | 94 | byte[] dialogByteArray = ssrcTransaction.getDialog(); |
| 91 | - if (dialogByteArray == null) return null; | 95 | + if (dialogByteArray == null) { |
| 96 | + return null; | ||
| 97 | + } | ||
| 92 | SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray); | 98 | SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray); |
| 93 | return dialog; | 99 | return dialog; |
| 94 | } | 100 | } |
| 95 | 101 | ||
| 96 | public SIPDialog getDialogByCallId(String deviceId, String channelId, String callID){ | 102 | public SIPDialog getDialogByCallId(String deviceId, String channelId, String callID){ |
| 97 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callID, null); | 103 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callID, null); |
| 98 | - if (ssrcTransaction == null) return null; | 104 | + if (ssrcTransaction == null) { |
| 105 | + return null; | ||
| 106 | + } | ||
| 99 | byte[] dialogByteArray = ssrcTransaction.getDialog(); | 107 | byte[] dialogByteArray = ssrcTransaction.getDialog(); |
| 100 | - if (dialogByteArray == null) return null; | 108 | + if (dialogByteArray == null) { |
| 109 | + return null; | ||
| 110 | + } | ||
| 101 | SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray); | 111 | SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray); |
| 102 | return dialog; | 112 | return dialog; |
| 103 | } | 113 | } |
| 104 | 114 | ||
| 105 | public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){ | 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 | String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; | 122 | String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; |
| 109 | List<Object> scanResult = redisUtil.scan(key); | 123 | List<Object> scanResult = redisUtil.scan(key); |
| 110 | - if (scanResult.size() == 0) return null; | 124 | + if (scanResult.size() == 0) { |
| 125 | + return null; | ||
| 126 | + } | ||
| 111 | return (SsrcTransaction)redisUtil.get((String) scanResult.get(0)); | 127 | return (SsrcTransaction)redisUtil.get((String) scanResult.get(0)); |
| 112 | } | 128 | } |
| 113 | 129 | ||
| 114 | public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){ | 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 | String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; | 143 | String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; |
| 120 | List<Object> scanResult = redisUtil.scan(key); | 144 | List<Object> scanResult = redisUtil.scan(key); |
| 121 | - if (scanResult.size() == 0) return null; | 145 | + if (scanResult.size() == 0) { |
| 146 | + return null; | ||
| 147 | + } | ||
| 122 | List<SsrcTransaction> result = new ArrayList<>(); | 148 | List<SsrcTransaction> result = new ArrayList<>(); |
| 123 | for (Object keyObj : scanResult) { | 149 | for (Object keyObj : scanResult) { |
| 124 | result.add((SsrcTransaction)redisUtil.get((String) keyObj)); | 150 | result.add((SsrcTransaction)redisUtil.get((String) keyObj)); |
| @@ -128,19 +154,25 @@ public class VideoStreamSessionManager { | @@ -128,19 +154,25 @@ public class VideoStreamSessionManager { | ||
| 128 | 154 | ||
| 129 | public String getMediaServerId(String deviceId, String channelId, String stream){ | 155 | public String getMediaServerId(String deviceId, String channelId, String stream){ |
| 130 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); | 156 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); |
| 131 | - if (ssrcTransaction == null) return null; | 157 | + if (ssrcTransaction == null) { |
| 158 | + return null; | ||
| 159 | + } | ||
| 132 | return ssrcTransaction.getMediaServerId(); | 160 | return ssrcTransaction.getMediaServerId(); |
| 133 | } | 161 | } |
| 134 | 162 | ||
| 135 | public String getSSRC(String deviceId, String channelId, String stream){ | 163 | public String getSSRC(String deviceId, String channelId, String stream){ |
| 136 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); | 164 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); |
| 137 | - if (ssrcTransaction == null) return null; | 165 | + if (ssrcTransaction == null) { |
| 166 | + return null; | ||
| 167 | + } | ||
| 138 | return ssrcTransaction.getSsrc(); | 168 | return ssrcTransaction.getSsrc(); |
| 139 | } | 169 | } |
| 140 | 170 | ||
| 141 | public void remove(String deviceId, String channelId, String stream) { | 171 | public void remove(String deviceId, String channelId, String stream) { |
| 142 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); | 172 | SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); |
| 143 | - if (ssrcTransaction == null) return; | 173 | + if (ssrcTransaction == null) { |
| 174 | + return; | ||
| 175 | + } | ||
| 144 | redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" | 176 | redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" |
| 145 | + deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream()); | 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,6 +2,9 @@ package com.genersoft.iot.vmp.gb28181.task; | ||
| 2 | 2 | ||
| 3 | import javax.sip.DialogState; | 3 | import javax.sip.DialogState; |
| 4 | 4 | ||
| 5 | +/** | ||
| 6 | + * @author lin | ||
| 7 | + */ | ||
| 5 | public interface ISubscribeTask extends Runnable{ | 8 | public interface ISubscribeTask extends Runnable{ |
| 6 | void stop(); | 9 | void stop(); |
| 7 | 10 |
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
| 1 | package com.genersoft.iot.vmp.gb28181.task.impl; | 1 | package com.genersoft.iot.vmp.gb28181.task.impl; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.conf.DynamicTask; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 4 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; | 5 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; |
| 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | 6 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; |
| 6 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
| 7 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
| 8 | import org.springframework.scheduling.annotation.Async; | 9 | import org.springframework.scheduling.annotation.Async; |
| 10 | +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
| 9 | 11 | ||
| 10 | import javax.sip.Dialog; | 12 | import javax.sip.Dialog; |
| 11 | import javax.sip.DialogState; | 13 | import javax.sip.DialogState; |
| @@ -15,6 +17,7 @@ import java.util.TimerTask; | @@ -15,6 +17,7 @@ import java.util.TimerTask; | ||
| 15 | 17 | ||
| 16 | /** | 18 | /** |
| 17 | * 目录订阅任务 | 19 | * 目录订阅任务 |
| 20 | + * @author lin | ||
| 18 | */ | 21 | */ |
| 19 | public class CatalogSubscribeTask implements ISubscribeTask { | 22 | public class CatalogSubscribeTask implements ISubscribeTask { |
| 20 | private final Logger logger = LoggerFactory.getLogger(CatalogSubscribeTask.class); | 23 | private final Logger logger = LoggerFactory.getLogger(CatalogSubscribeTask.class); |
| @@ -22,18 +25,21 @@ public class CatalogSubscribeTask implements ISubscribeTask { | @@ -22,18 +25,21 @@ public class CatalogSubscribeTask implements ISubscribeTask { | ||
| 22 | private final ISIPCommander sipCommander; | 25 | private final ISIPCommander sipCommander; |
| 23 | private Dialog dialog; | 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 | this.device = device; | 34 | this.device = device; |
| 29 | this.sipCommander = sipCommander; | 35 | this.sipCommander = sipCommander; |
| 36 | + this.dynamicTask = dynamicTask; | ||
| 30 | } | 37 | } |
| 31 | 38 | ||
| 32 | @Override | 39 | @Override |
| 33 | public void run() { | 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 | sipCommander.catalogSubscribe(device, dialog, eventResult -> { | 44 | sipCommander.catalogSubscribe(device, dialog, eventResult -> { |
| 39 | if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) { | 45 | if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) { |
| @@ -51,13 +57,7 @@ public class CatalogSubscribeTask implements ISubscribeTask { | @@ -51,13 +57,7 @@ public class CatalogSubscribeTask implements ISubscribeTask { | ||
| 51 | dialog = null; | 57 | dialog = null; |
| 52 | // 失败 | 58 | // 失败 |
| 53 | logger.warn("[目录订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg); | 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,9 +71,8 @@ public class CatalogSubscribeTask implements ISubscribeTask { | ||
| 71 | * TERMINATED-> Terminated Dialog状态-终止 | 71 | * TERMINATED-> Terminated Dialog状态-终止 |
| 72 | */ | 72 | */ |
| 73 | logger.info("取消目录订阅时dialog状态为{}", DialogState.CONFIRMED); | 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 | if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) { | 77 | if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) { |
| 79 | device.setSubscribeCycleForCatalog(0); | 78 | device.setSubscribeCycleForCatalog(0); |
| @@ -95,7 +94,9 @@ public class CatalogSubscribeTask implements ISubscribeTask { | @@ -95,7 +94,9 @@ public class CatalogSubscribeTask implements ISubscribeTask { | ||
| 95 | 94 | ||
| 96 | @Override | 95 | @Override |
| 97 | public DialogState getDialogState() { | 96 | public DialogState getDialogState() { |
| 98 | - if (dialog == null) return null; | 97 | + if (dialog == null) { |
| 98 | + return null; | ||
| 99 | + } | ||
| 99 | return dialog.getState(); | 100 | return dialog.getState(); |
| 100 | } | 101 | } |
| 101 | } | 102 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java
| 1 | package com.genersoft.iot.vmp.gb28181.task.impl; | 1 | package com.genersoft.iot.vmp.gb28181.task.impl; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.conf.DynamicTask; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.*; | 4 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 4 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; | 5 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; |
| 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 6 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| @@ -15,6 +16,7 @@ import java.util.List; | @@ -15,6 +16,7 @@ import java.util.List; | ||
| 15 | 16 | ||
| 16 | /** | 17 | /** |
| 17 | * 向已经订阅(移动位置)的上级发送MobilePosition消息 | 18 | * 向已经订阅(移动位置)的上级发送MobilePosition消息 |
| 19 | + * @author lin | ||
| 18 | */ | 20 | */ |
| 19 | public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { | 21 | public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { |
| 20 | 22 | ||
| @@ -25,10 +27,18 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { | @@ -25,10 +27,18 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { | ||
| 25 | private ISIPCommanderForPlatform sipCommanderForPlatform; | 27 | private ISIPCommanderForPlatform sipCommanderForPlatform; |
| 26 | private SubscribeHolder subscribeHolder; | 28 | private SubscribeHolder subscribeHolder; |
| 27 | private ParentPlatform platform; | 29 | private ParentPlatform platform; |
| 30 | + | ||
| 28 | private String sn; | 31 | private String sn; |
| 29 | private String key; | 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 | this.redisCatchStorage = redisCatchStorage; | 42 | this.redisCatchStorage = redisCatchStorage; |
| 33 | this.storager = storager; | 43 | this.storager = storager; |
| 34 | this.platform = storager.queryParentPlatByServerGBId(platformId); | 44 | this.platform = storager.queryParentPlatByServerGBId(platformId); |
| @@ -41,7 +51,9 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { | @@ -41,7 +51,9 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { | ||
| 41 | @Override | 51 | @Override |
| 42 | public void run() { | 52 | public void run() { |
| 43 | 53 | ||
| 44 | - if (platform == null) return; | 54 | + if (platform == null) { |
| 55 | + return; | ||
| 56 | + } | ||
| 45 | SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()); | 57 | SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()); |
| 46 | if (subscribe != null) { | 58 | if (subscribe != null) { |
| 47 | 59 |
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java
| 1 | package com.genersoft.iot.vmp.gb28181.task.impl; | 1 | package com.genersoft.iot.vmp.gb28181.task.impl; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.conf.DynamicTask; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 4 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; | 5 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; |
| 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | 6 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; |
| @@ -16,25 +17,26 @@ import java.util.TimerTask; | @@ -16,25 +17,26 @@ import java.util.TimerTask; | ||
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| 18 | * 移动位置订阅的定时更新 | 19 | * 移动位置订阅的定时更新 |
| 20 | + * @author lin | ||
| 19 | */ | 21 | */ |
| 20 | public class MobilePositionSubscribeTask implements ISubscribeTask { | 22 | public class MobilePositionSubscribeTask implements ISubscribeTask { |
| 21 | private final Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeTask.class); | 23 | private final Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeTask.class); |
| 22 | private Device device; | 24 | private Device device; |
| 23 | private ISIPCommander sipCommander; | 25 | private ISIPCommander sipCommander; |
| 24 | private Dialog dialog; | 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 | this.device = device; | 31 | this.device = device; |
| 30 | this.sipCommander = sipCommander; | 32 | this.sipCommander = sipCommander; |
| 33 | + this.dynamicTask = dynamicTask; | ||
| 31 | } | 34 | } |
| 32 | 35 | ||
| 33 | @Override | 36 | @Override |
| 34 | public void run() { | 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 | sipCommander.mobilePositionSubscribe(device, dialog, eventResult -> { | 41 | sipCommander.mobilePositionSubscribe(device, dialog, eventResult -> { |
| 40 | // if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) { | 42 | // if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) { |
| @@ -52,13 +54,7 @@ public class MobilePositionSubscribeTask implements ISubscribeTask { | @@ -52,13 +54,7 @@ public class MobilePositionSubscribeTask implements ISubscribeTask { | ||
| 52 | dialog = null; | 54 | dialog = null; |
| 53 | // 失败 | 55 | // 失败 |
| 54 | logger.warn("[移动位置订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg); | 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,9 +68,8 @@ public class MobilePositionSubscribeTask implements ISubscribeTask { | ||
| 72 | * COMPLETED-> Completed Dialog状态-已完成 | 68 | * COMPLETED-> Completed Dialog状态-已完成 |
| 73 | * TERMINATED-> Terminated Dialog状态-终止 | 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 | if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) { | 74 | if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) { |
| 80 | logger.info("取消移动订阅时dialog状态为{}", dialog.getState()); | 75 | logger.info("取消移动订阅时dialog状态为{}", dialog.getState()); |
| @@ -96,7 +91,9 @@ public class MobilePositionSubscribeTask implements ISubscribeTask { | @@ -96,7 +91,9 @@ public class MobilePositionSubscribeTask implements ISubscribeTask { | ||
| 96 | } | 91 | } |
| 97 | @Override | 92 | @Override |
| 98 | public DialogState getDialogState() { | 93 | public DialogState getDialogState() { |
| 99 | - if (dialog == null) return null; | 94 | + if (dialog == null) { |
| 95 | + return null; | ||
| 96 | + } | ||
| 100 | return dialog.getState(); | 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,7 +62,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | ||
| 62 | * @param processor 处理程序 | 62 | * @param processor 处理程序 |
| 63 | */ | 63 | */ |
| 64 | public void addTimeoutProcessor(ITimeoutProcessor processor) { | 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,6 +29,7 @@ public class CheckForAllRecordsThread extends Thread { | ||
| 29 | this.recordInfo = recordInfo; | 29 | this.recordInfo = recordInfo; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | + @Override | ||
| 32 | public void run() { | 33 | public void run() { |
| 33 | 34 | ||
| 34 | String cacheKey = this.key; | 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,12 +65,16 @@ public class DeferredResultHolder { | ||
| 65 | 65 | ||
| 66 | public DeferredResult get(String key, String id) { | 66 | public DeferredResult get(String key, String id) { |
| 67 | Map<String, DeferredResult> deferredResultMap = map.get(key); | 67 | Map<String, DeferredResult> deferredResultMap = map.get(key); |
| 68 | - if (deferredResultMap == null) return null; | 68 | + if (deferredResultMap == null) { |
| 69 | + return null; | ||
| 70 | + } | ||
| 69 | return deferredResultMap.get(id); | 71 | return deferredResultMap.get(id); |
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | public boolean exist(String key, String id){ | 74 | public boolean exist(String key, String id){ |
| 73 | - if (key == null) return false; | 75 | + if (key == null) { |
| 76 | + return false; | ||
| 77 | + } | ||
| 74 | Map<String, DeferredResult> deferredResultMap = map.get(key); | 78 | Map<String, DeferredResult> deferredResultMap = map.get(key); |
| 75 | if (id == null) { | 79 | if (id == null) { |
| 76 | return deferredResultMap != null; | 80 | return deferredResultMap != null; |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| @@ -68,9 +68,6 @@ public class SIPRequestHeaderPlarformProvider { | @@ -68,9 +68,6 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 68 | toHeader, viaHeaders, maxForwards); | 68 | toHeader, viaHeaders, maxForwards); |
| 69 | 69 | ||
| 70 | List<String> agentParam = new ArrayList<>(); | 70 | List<String> agentParam = new ArrayList<>(); |
| 71 | - agentParam.add("wvp-pro"); | ||
| 72 | - UserAgentHeader userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam); | ||
| 73 | - request.addHeader(userAgentHeader); | ||
| 74 | 71 | ||
| 75 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | 72 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| 76 | request.setContent(content, contentTypeHeader); | 73 | request.setContent(content, contentTypeHeader); |
| @@ -115,10 +112,6 @@ public class SIPRequestHeaderPlarformProvider { | @@ -115,10 +112,6 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 115 | ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(Integer.parseInt(platform.getExpires())); | 112 | ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(Integer.parseInt(platform.getExpires())); |
| 116 | request.addHeader(expires); | 113 | request.addHeader(expires); |
| 117 | 114 | ||
| 118 | - List<String> agentParam = new ArrayList<>(); | ||
| 119 | - agentParam.add("wvp-pro"); | ||
| 120 | - UserAgentHeader userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam); | ||
| 121 | - request.addHeader(userAgentHeader); | ||
| 122 | 115 | ||
| 123 | return request; | 116 | return request; |
| 124 | } | 117 | } |
| @@ -226,10 +219,6 @@ public class SIPRequestHeaderPlarformProvider { | @@ -226,10 +219,6 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 226 | messageFactory.setDefaultContentEncodingCharset(parentPlatform.getCharacterSet()); | 219 | messageFactory.setDefaultContentEncodingCharset(parentPlatform.getCharacterSet()); |
| 227 | request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, | 220 | request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, |
| 228 | toHeader, viaHeaders, maxForwards); | 221 | toHeader, viaHeaders, maxForwards); |
| 229 | - List<String> agentParam = new ArrayList<>(); | ||
| 230 | - agentParam.add("wvp-pro"); | ||
| 231 | - UserAgentHeader userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam); | ||
| 232 | - request.addHeader(userAgentHeader); | ||
| 233 | 222 | ||
| 234 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | 223 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| 235 | request.setContent(content, contentTypeHeader); | 224 | request.setContent(content, contentTypeHeader); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| @@ -228,9 +228,13 @@ public class SIPRequestHeaderProvider { | @@ -228,9 +228,13 @@ public class SIPRequestHeaderProvider { | ||
| 228 | public Request createInfoRequest(Device device, StreamInfo streamInfo, String content) | 228 | public Request createInfoRequest(Device device, StreamInfo streamInfo, String content) |
| 229 | throws PeerUnavailableException, ParseException, InvalidArgumentException { | 229 | throws PeerUnavailableException, ParseException, InvalidArgumentException { |
| 230 | Request request = null; | 230 | Request request = null; |
| 231 | - if (streamInfo == null) return null; | 231 | + if (streamInfo == null) { |
| 232 | + return null; | ||
| 233 | + } | ||
| 232 | Dialog dialog = streamSession.getDialogByStream(streamInfo.getDeviceID(), streamInfo.getChannelId(), streamInfo.getStream()); | 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 | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), | 239 | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), |
| 236 | device.getHostAddress()); | 240 | device.getHostAddress()); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -27,6 +27,7 @@ import org.slf4j.Logger; | @@ -27,6 +27,7 @@ import org.slf4j.Logger; | ||
| 27 | import org.slf4j.LoggerFactory; | 27 | import org.slf4j.LoggerFactory; |
| 28 | import org.springframework.beans.factory.annotation.Autowired; | 28 | import org.springframework.beans.factory.annotation.Autowired; |
| 29 | import org.springframework.beans.factory.annotation.Qualifier; | 29 | import org.springframework.beans.factory.annotation.Qualifier; |
| 30 | +import org.springframework.boot.SpringBootVersion; | ||
| 30 | import org.springframework.context.annotation.DependsOn; | 31 | import org.springframework.context.annotation.DependsOn; |
| 31 | import org.springframework.stereotype.Component; | 32 | import org.springframework.stereotype.Component; |
| 32 | import org.springframework.util.StringUtils; | 33 | import org.springframework.util.StringUtils; |
| @@ -37,7 +38,9 @@ import javax.sip.header.*; | @@ -37,7 +38,9 @@ import javax.sip.header.*; | ||
| 37 | import javax.sip.message.Request; | 38 | import javax.sip.message.Request; |
| 38 | import java.lang.reflect.Field; | 39 | import java.lang.reflect.Field; |
| 39 | import java.text.ParseException; | 40 | import java.text.ParseException; |
| 41 | +import java.util.ArrayList; | ||
| 40 | import java.util.HashSet; | 42 | import java.util.HashSet; |
| 43 | +import java.util.List; | ||
| 41 | 44 | ||
| 42 | /** | 45 | /** |
| 43 | * @description:设备能力接口,用于定义设备的控制、查询能力 | 46 | * @description:设备能力接口,用于定义设备的控制、查询能力 |
| @@ -49,7 +52,7 @@ import java.util.HashSet; | @@ -49,7 +52,7 @@ import java.util.HashSet; | ||
| 49 | public class SIPCommander implements ISIPCommander { | 52 | public class SIPCommander implements ISIPCommander { |
| 50 | 53 | ||
| 51 | private final Logger logger = LoggerFactory.getLogger(SIPCommander.class); | 54 | private final Logger logger = LoggerFactory.getLogger(SIPCommander.class); |
| 52 | - | 55 | + |
| 53 | @Autowired | 56 | @Autowired |
| 54 | private SipConfig sipConfig; | 57 | private SipConfig sipConfig; |
| 55 | 58 | ||
| @@ -340,13 +343,15 @@ public class SIPCommander implements ISIPCommander { | @@ -340,13 +343,15 @@ public class SIPCommander implements ISIPCommander { | ||
| 340 | * @param channelId 预览通道 | 343 | * @param channelId 预览通道 |
| 341 | * @param event hook订阅 | 344 | * @param event hook订阅 |
| 342 | * @param errorEvent sip错误订阅 | 345 | * @param errorEvent sip错误订阅 |
| 343 | - */ | 346 | + */ |
| 344 | @Override | 347 | @Override |
| 345 | public void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, | 348 | public void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| 346 | ZLMHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) { | 349 | ZLMHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) { |
| 347 | String streamId = ssrcInfo.getStream(); | 350 | String streamId = ssrcInfo.getStream(); |
| 348 | try { | 351 | try { |
| 349 | - if (device == null) return; | 352 | + if (device == null) { |
| 353 | + return; | ||
| 354 | + } | ||
| 350 | String streamMode = device.getStreamMode().toUpperCase(); | 355 | String streamMode = device.getStreamMode().toUpperCase(); |
| 351 | 356 | ||
| 352 | logger.info("{} 分配的ZLM为: {} [{}:{}]", streamId, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); | 357 | logger.info("{} 分配的ZLM为: {} [{}:{}]", streamId, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); |
| @@ -694,7 +699,9 @@ public class SIPCommander implements ISIPCommander { | @@ -694,7 +699,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 694 | if (callId != null) { | 699 | if (callId != null) { |
| 695 | dialog = streamSession.getDialogByCallId(deviceId, channelId, callId); | 700 | dialog = streamSession.getDialogByCallId(deviceId, channelId, callId); |
| 696 | }else { | 701 | }else { |
| 697 | - if (stream == null) return; | 702 | + if (stream == null) { |
| 703 | + return; | ||
| 704 | + } | ||
| 698 | dialog = streamSession.getDialogByStream(deviceId, channelId, stream); | 705 | dialog = streamSession.getDialogByStream(deviceId, channelId, stream); |
| 699 | } | 706 | } |
| 700 | if (ssrcTransaction != null) { | 707 | if (ssrcTransaction != null) { |
| @@ -1454,6 +1461,7 @@ public class SIPCommander implements ISIPCommander { | @@ -1454,6 +1461,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 1454 | * @param device 视频设备 | 1461 | * @param device 视频设备 |
| 1455 | * @return true = 命令发送成功 | 1462 | * @return true = 命令发送成功 |
| 1456 | */ | 1463 | */ |
| 1464 | + @Override | ||
| 1457 | public boolean mobilePositionSubscribe(Device device, Dialog dialog, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) { | 1465 | public boolean mobilePositionSubscribe(Device device, Dialog dialog, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) { |
| 1458 | try { | 1466 | try { |
| 1459 | StringBuffer subscribePostitionXml = new StringBuffer(200); | 1467 | StringBuffer subscribePostitionXml = new StringBuffer(200); |
| @@ -1505,6 +1513,7 @@ public class SIPCommander implements ISIPCommander { | @@ -1505,6 +1513,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 1505 | * @param endTime 报警发生终止时间(可选) | 1513 | * @param endTime 报警发生终止时间(可选) |
| 1506 | * @return true = 命令发送成功 | 1514 | * @return true = 命令发送成功 |
| 1507 | */ | 1515 | */ |
| 1516 | + @Override | ||
| 1508 | public boolean alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String alarmType, String startTime, String endTime) { | 1517 | public boolean alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String alarmType, String startTime, String endTime) { |
| 1509 | try { | 1518 | try { |
| 1510 | StringBuffer cmdXml = new StringBuffer(200); | 1519 | StringBuffer cmdXml = new StringBuffer(200); |
| @@ -1637,7 +1646,18 @@ public class SIPCommander implements ISIPCommander { | @@ -1637,7 +1646,18 @@ public class SIPCommander implements ISIPCommander { | ||
| 1637 | } else if("UDP".equals(device.getTransport())) { | 1646 | } else if("UDP".equals(device.getTransport())) { |
| 1638 | clientTransaction = udpSipProvider.getNewClientTransaction(request); | 1647 | clientTransaction = udpSipProvider.getNewClientTransaction(request); |
| 1639 | } | 1648 | } |
| 1640 | - | 1649 | + if (request.getHeader(UserAgentHeader.NAME) == null) { |
| 1650 | + List<String> agentParam = new ArrayList<>(); | ||
| 1651 | + agentParam.add("wvp-pro"); | ||
| 1652 | + // TODO 添加版本信息以及日期 | ||
| 1653 | + UserAgentHeader userAgentHeader = null; | ||
| 1654 | + try { | ||
| 1655 | + userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam); | ||
| 1656 | + } catch (ParseException e) { | ||
| 1657 | + throw new RuntimeException(e); | ||
| 1658 | + } | ||
| 1659 | + request.addHeader(userAgentHeader); | ||
| 1660 | + } | ||
| 1641 | CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME); | 1661 | CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME); |
| 1642 | // 添加错误订阅 | 1662 | // 添加错误订阅 |
| 1643 | if (errorEvent != null) { | 1663 | if (errorEvent != null) { |
| @@ -1701,7 +1721,9 @@ public class SIPCommander implements ISIPCommander { | @@ -1701,7 +1721,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 1701 | content.append("CSeq: " + cseq + "\r\n"); | 1721 | content.append("CSeq: " + cseq + "\r\n"); |
| 1702 | content.append("Range: npt=now-\r\n"); | 1722 | content.append("Range: npt=now-\r\n"); |
| 1703 | Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); | 1723 | Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); |
| 1704 | - if (request == null) return; | 1724 | + if (request == null) { |
| 1725 | + return; | ||
| 1726 | + } | ||
| 1705 | logger.info(request.toString()); | 1727 | logger.info(request.toString()); |
| 1706 | ClientTransaction clientTransaction = null; | 1728 | ClientTransaction clientTransaction = null; |
| 1707 | if ("TCP".equals(device.getTransport())) { | 1729 | if ("TCP".equals(device.getTransport())) { |
| @@ -1730,7 +1752,9 @@ public class SIPCommander implements ISIPCommander { | @@ -1730,7 +1752,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 1730 | content.append("Range: npt=" + Math.abs(seekTime) + "-\r\n"); | 1752 | content.append("Range: npt=" + Math.abs(seekTime) + "-\r\n"); |
| 1731 | 1753 | ||
| 1732 | Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); | 1754 | Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); |
| 1733 | - if (request == null) return; | 1755 | + if (request == null) { |
| 1756 | + return; | ||
| 1757 | + } | ||
| 1734 | logger.info(request.toString()); | 1758 | logger.info(request.toString()); |
| 1735 | ClientTransaction clientTransaction = null; | 1759 | ClientTransaction clientTransaction = null; |
| 1736 | if ("TCP".equals(device.getTransport())) { | 1760 | if ("TCP".equals(device.getTransport())) { |
| @@ -1758,7 +1782,9 @@ public class SIPCommander implements ISIPCommander { | @@ -1758,7 +1782,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 1758 | content.append("CSeq: " + cseq + "\r\n"); | 1782 | content.append("CSeq: " + cseq + "\r\n"); |
| 1759 | content.append("Scale: " + String.format("%.1f",speed) + "\r\n"); | 1783 | content.append("Scale: " + String.format("%.1f",speed) + "\r\n"); |
| 1760 | Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); | 1784 | Request request = headerProvider.createInfoRequest(device, streamInfo, content.toString()); |
| 1761 | - if (request == null) return; | 1785 | + if (request == null) { |
| 1786 | + return; | ||
| 1787 | + } | ||
| 1762 | logger.info(request.toString()); | 1788 | logger.info(request.toString()); |
| 1763 | ClientTransaction clientTransaction = null; | 1789 | ClientTransaction clientTransaction = null; |
| 1764 | if ("TCP".equals(device.getTransport())) { | 1790 | if ("TCP".equals(device.getTransport())) { |
| @@ -1824,7 +1850,9 @@ public class SIPCommander implements ISIPCommander { | @@ -1824,7 +1850,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 1824 | // 设置编码, 防止中文乱码 | 1850 | // 设置编码, 防止中文乱码 |
| 1825 | messageFactory.setDefaultContentEncodingCharset(characterSet); | 1851 | messageFactory.setDefaultContentEncodingCharset(characterSet); |
| 1826 | Dialog dialog = subscribeInfo.getDialog(); | 1852 | Dialog dialog = subscribeInfo.getDialog(); |
| 1827 | - if (dialog == null || !dialog.getState().equals(DialogState.CONFIRMED)) return; | 1853 | + if (dialog == null || !dialog.getState().equals(DialogState.CONFIRMED)) { |
| 1854 | + return; | ||
| 1855 | + } | ||
| 1828 | SIPRequest notifyRequest = (SIPRequest)dialog.createRequest(Request.NOTIFY); | 1856 | SIPRequest notifyRequest = (SIPRequest)dialog.createRequest(Request.NOTIFY); |
| 1829 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | 1857 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| 1830 | notifyRequest.setContent(catalogXmlContent, contentTypeHeader); | 1858 | 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,7 +529,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 529 | // 设置编码, 防止中文乱码 | 529 | // 设置编码, 防止中文乱码 |
| 530 | messageFactory.setDefaultContentEncodingCharset(characterSet); | 530 | messageFactory.setDefaultContentEncodingCharset(characterSet); |
| 531 | Dialog dialog = subscribeInfo.getDialog(); | 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 | SIPRequest notifyRequest = (SIPRequest)dialog.createRequest(Request.NOTIFY); | 535 | SIPRequest notifyRequest = (SIPRequest)dialog.createRequest(Request.NOTIFY); |
| 534 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | 536 | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| 535 | notifyRequest.setContent(catalogXmlContent, contentTypeHeader); | 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,7 +139,9 @@ public abstract class SIPRequestProcessorParent { | ||
| 139 | serverTransaction.sendResponse(response); | 139 | serverTransaction.sendResponse(response); |
| 140 | if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) { | 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,7 +151,9 @@ public abstract class SIPRequestProcessorParent { | ||
| 149 | ServerTransaction serverTransaction = getServerTransaction(evt); | 151 | ServerTransaction serverTransaction = getServerTransaction(evt); |
| 150 | serverTransaction.sendResponse(response); | 152 | serverTransaction.sendResponse(response); |
| 151 | if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) { | 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,7 +219,9 @@ public abstract class SIPRequestProcessorParent { | ||
| 215 | return getRootElement(evt, "gb2312"); | 219 | return getRootElement(evt, "gb2312"); |
| 216 | } | 220 | } |
| 217 | public Element getRootElement(RequestEvent evt, String charset) throws DocumentException { | 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 | Request request = evt.getRequest(); | 225 | Request request = evt.getRequest(); |
| 220 | SAXReader reader = new SAXReader(); | 226 | SAXReader reader = new SAXReader(); |
| 221 | reader.setEncoding(charset); | 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,7 +72,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 72 | public void process(RequestEvent evt) { | 72 | public void process(RequestEvent evt) { |
| 73 | Dialog dialog = evt.getDialog(); | 73 | Dialog dialog = evt.getDialog(); |
| 74 | CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); | 74 | CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); |
| 75 | - if (dialog == null) return; | 75 | + if (dialog == null) { |
| 76 | + return; | ||
| 77 | + } | ||
| 76 | if (dialog.getState()== DialogState.CONFIRMED) { | 78 | if (dialog.getState()== DialogState.CONFIRMED) { |
| 77 | String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser(); | 79 | String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser(); |
| 78 | logger.info("ACK请求: platformGbId->{}", platformGbId); | 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,7 +81,9 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 81 | responseAck(evt, Response.OK); | 81 | responseAck(evt, Response.OK); |
| 82 | Dialog dialog = evt.getDialog(); | 82 | Dialog dialog = evt.getDialog(); |
| 83 | CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); | 83 | CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); |
| 84 | - if (dialog == null) return; | 84 | + if (dialog == null) { |
| 85 | + return; | ||
| 86 | + } | ||
| 85 | if (dialog.getState().equals(DialogState.TERMINATED)) { | 87 | if (dialog.getState().equals(DialogState.TERMINATED)) { |
| 86 | String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser(); | 88 | String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser(); |
| 87 | String channelId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser(); | 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,7 +321,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 321 | response = getMessageFactory().createResponse(event.statusCode, evt.getRequest()); | 321 | response = getMessageFactory().createResponse(event.statusCode, evt.getRequest()); |
| 322 | ServerTransaction serverTransaction = getServerTransaction(evt); | 322 | ServerTransaction serverTransaction = getServerTransaction(evt); |
| 323 | serverTransaction.sendResponse(response); | 323 | serverTransaction.sendResponse(response); |
| 324 | - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); | 324 | + if (serverTransaction.getDialog() != null) { |
| 325 | + serverTransaction.getDialog().delete(); | ||
| 326 | + } | ||
| 325 | } catch (ParseException | SipException | InvalidArgumentException e) { | 327 | } catch (ParseException | SipException | InvalidArgumentException e) { |
| 326 | e.printStackTrace(); | 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,7 +5,6 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; | ||
| 5 | import com.genersoft.iot.vmp.conf.SipConfig; | 5 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 6 | import com.genersoft.iot.vmp.conf.UserSetting; | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | import com.genersoft.iot.vmp.gb28181.bean.*; | 7 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 8 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | ||
| 9 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 10 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; | 9 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; |
| 11 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; | 10 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| @@ -19,7 +18,6 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | @@ -19,7 +18,6 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | ||
| 19 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; | 18 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| 20 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 19 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 21 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 20 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 22 | -import com.genersoft.iot.vmp.utils.GpsUtil; | ||
| 23 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; | 21 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 24 | import org.dom4j.DocumentException; | 22 | import org.dom4j.DocumentException; |
| 25 | import org.dom4j.Element; | 23 | import org.dom4j.Element; |
| @@ -65,10 +63,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | @@ -65,10 +63,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | ||
| 65 | @Autowired | 63 | @Autowired |
| 66 | private EventPublisher publisher; | 64 | private EventPublisher publisher; |
| 67 | 65 | ||
| 68 | - @Autowired | ||
| 69 | - private DeviceOffLineDetector offLineDetector; | ||
| 70 | - | ||
| 71 | - | ||
| 72 | private String method = "NOTIFY"; | 66 | private String method = "NOTIFY"; |
| 73 | 67 | ||
| 74 | @Autowired | 68 | @Autowired |
| @@ -240,7 +234,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | @@ -240,7 +234,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | ||
| 240 | 234 | ||
| 241 | // 回复200 OK | 235 | // 回复200 OK |
| 242 | responseAck(evt, Response.OK); | 236 | responseAck(evt, Response.OK); |
| 243 | - if (offLineDetector.isOnline(deviceId)) { | 237 | + if (redisCatchStorage.deviceIsOnline(deviceId)) { |
| 244 | publisher.deviceAlarmEventPublish(deviceAlarm); | 238 | publisher.deviceAlarmEventPublish(deviceAlarm); |
| 245 | } | 239 | } |
| 246 | } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { | 240 | } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { |
| @@ -331,7 +325,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | @@ -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 | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); | 329 | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); |
| 336 | } | 330 | } |
| 337 | } | 331 | } |
| @@ -357,10 +351,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | @@ -357,10 +351,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | ||
| 357 | public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) { | 351 | public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) { |
| 358 | } | 352 | } |
| 359 | 353 | ||
| 360 | - public void setOffLineDetector(DeviceOffLineDetector offLineDetector) { | ||
| 361 | - this.offLineDetector = offLineDetector; | ||
| 362 | - } | ||
| 363 | - | ||
| 364 | public IRedisCatchStorage getRedisCatchStorage() { | 354 | public IRedisCatchStorage getRedisCatchStorage() { |
| 365 | return redisCatchStorage; | 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,7 +130,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen | ||
| 130 | response = getMessageFactory().createResponse(Response.BAD_REQUEST, request); | 130 | response = getMessageFactory().createResponse(Response.BAD_REQUEST, request); |
| 131 | ServerTransaction serverTransaction = getServerTransaction(evt); | 131 | ServerTransaction serverTransaction = getServerTransaction(evt); |
| 132 | serverTransaction.sendResponse(response); | 132 | serverTransaction.sendResponse(response); |
| 133 | - if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); | 133 | + if (serverTransaction.getDialog() != null) { |
| 134 | + serverTransaction.getDialog().delete(); | ||
| 135 | + } | ||
| 134 | return; | 136 | return; |
| 135 | } | 137 | } |
| 136 | // 添加Contact头 | 138 | // 添加Contact头 |
| @@ -195,7 +197,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen | @@ -195,7 +197,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen | ||
| 195 | return; | 197 | return; |
| 196 | } | 198 | } |
| 197 | serverTransaction.sendResponse(response); | 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,23 +35,18 @@ import java.text.ParseException; | ||
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | * SIP命令类型: SUBSCRIBE请求 | 37 | * SIP命令类型: SUBSCRIBE请求 |
| 38 | + * @author lin | ||
| 38 | */ | 39 | */ |
| 39 | @Component | 40 | @Component |
| 40 | public class SubscribeRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { | 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 | @Autowired | 46 | @Autowired |
| 46 | private SIPProcessorObserver sipProcessorObserver; | 47 | private SIPProcessorObserver sipProcessorObserver; |
| 47 | 48 | ||
| 48 | @Autowired | 49 | @Autowired |
| 49 | - private IRedisCatchStorage redisCatchStorage; | ||
| 50 | - | ||
| 51 | - @Autowired | ||
| 52 | - private ISIPCommanderForPlatform sipCommanderForPlatform; | ||
| 53 | - | ||
| 54 | - @Autowired | ||
| 55 | private IVideoManagerStorage storager; | 50 | private IVideoManagerStorage storager; |
| 56 | 51 | ||
| 57 | @Lazy | 52 | @Lazy |
| @@ -82,7 +77,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -82,7 +77,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 82 | /** | 77 | /** |
| 83 | * 处理SUBSCRIBE请求 | 78 | * 处理SUBSCRIBE请求 |
| 84 | * | 79 | * |
| 85 | - * @param evt | 80 | + * @param evt 事件 |
| 86 | */ | 81 | */ |
| 87 | @Override | 82 | @Override |
| 88 | public void process(RequestEvent evt) { | 83 | public void process(RequestEvent evt) { |
| @@ -101,13 +96,12 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -101,13 +96,12 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 101 | } else { | 96 | } else { |
| 102 | logger.info("接收到消息:" + cmd); | 97 | logger.info("接收到消息:" + cmd); |
| 103 | 98 | ||
| 104 | - Response response = null; | ||
| 105 | - response = getMessageFactory().createResponse(200, request); | 99 | + Response response = getMessageFactory().createResponse(200, request); |
| 106 | if (response != null) { | 100 | if (response != null) { |
| 107 | ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30); | 101 | ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30); |
| 108 | response.setExpires(expireHeader); | 102 | response.setExpires(expireHeader); |
| 109 | } | 103 | } |
| 110 | - logger.info("response : " + response.toString()); | 104 | + logger.info("response : " + response); |
| 111 | ServerTransaction transaction = getServerTransaction(evt); | 105 | ServerTransaction transaction = getServerTransaction(evt); |
| 112 | if (transaction != null) { | 106 | if (transaction != null) { |
| 113 | transaction.sendResponse(response); | 107 | transaction.sendResponse(response); |
| @@ -117,13 +111,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -117,13 +111,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 117 | logger.info("processRequest serverTransactionId is null."); | 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 | e.printStackTrace(); | 115 | e.printStackTrace(); |
| 128 | } | 116 | } |
| 129 | 117 | ||
| @@ -134,14 +122,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -134,14 +122,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 134 | */ | 122 | */ |
| 135 | private void processNotifyMobilePosition(RequestEvent evt, Element rootElement) throws SipException { | 123 | private void processNotifyMobilePosition(RequestEvent evt, Element rootElement) throws SipException { |
| 136 | String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); | 124 | String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); |
| 137 | - String deviceID = XmlUtil.getText(rootElement, "DeviceID"); | 125 | + String deviceId = XmlUtil.getText(rootElement, "DeviceID"); |
| 138 | ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); | 126 | ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); |
| 139 | SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); | 127 | SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); |
| 140 | if (platform == null) { | 128 | if (platform == null) { |
| 141 | return; | 129 | return; |
| 142 | } | 130 | } |
| 143 | if (evt.getServerTransaction() == null) { | 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 | : udpSipProvider.getNewServerTransaction(evt.getRequest()); | 133 | : udpSipProvider.getNewServerTransaction(evt.getRequest()); |
| 146 | subscribeInfo.setTransaction(serverTransaction); | 134 | subscribeInfo.setTransaction(serverTransaction); |
| 147 | Dialog dialog = serverTransaction.getDialog(); | 135 | Dialog dialog = serverTransaction.getDialog(); |
| @@ -154,13 +142,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -154,13 +142,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 154 | resultXml.append("<?xml version=\"1.0\" ?>\r\n") | 142 | resultXml.append("<?xml version=\"1.0\" ?>\r\n") |
| 155 | .append("<Response>\r\n") | 143 | .append("<Response>\r\n") |
| 156 | .append("<CmdType>MobilePosition</CmdType>\r\n") | 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 | .append("<Result>OK</Result>\r\n") | 147 | .append("<Result>OK</Result>\r\n") |
| 160 | .append("</Response>\r\n"); | 148 | .append("</Response>\r\n"); |
| 161 | 149 | ||
| 162 | if (subscribeInfo.getExpires() > 0) { | 150 | if (subscribeInfo.getExpires() > 0) { |
| 163 | - String interval = XmlUtil.getText(rootElement, "Interval"); // GPS上报时间间隔 | 151 | + // GPS上报时间间隔 |
| 152 | + String interval = XmlUtil.getText(rootElement, "Interval"); | ||
| 164 | if (interval == null) { | 153 | if (interval == null) { |
| 165 | subscribeInfo.setGpsInterval(5); | 154 | subscribeInfo.setGpsInterval(5); |
| 166 | }else { | 155 | }else { |
| @@ -169,15 +158,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -169,15 +158,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 169 | 158 | ||
| 170 | subscribeInfo.setSn(sn); | 159 | subscribeInfo.setSn(sn); |
| 171 | subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo); | 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 | }else if (subscribeInfo.getExpires() == 0) { | 162 | }else if (subscribeInfo.getExpires() == 0) { |
| 182 | subscribeHolder.removeMobilePositionSubscribe(platformId); | 163 | subscribeHolder.removeMobilePositionSubscribe(platformId); |
| 183 | } | 164 | } |
| @@ -185,11 +166,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -185,11 +166,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 185 | try { | 166 | try { |
| 186 | ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); | 167 | ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); |
| 187 | responseXmlAck(evt, resultXml.toString(), parentPlatform); | 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 | e.printStackTrace(); | 170 | e.printStackTrace(); |
| 194 | } | 171 | } |
| 195 | } | 172 | } |
| @@ -200,12 +177,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -200,12 +177,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 200 | 177 | ||
| 201 | private void processNotifyCatalogList(RequestEvent evt, Element rootElement) throws SipException { | 178 | private void processNotifyCatalogList(RequestEvent evt, Element rootElement) throws SipException { |
| 202 | String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); | 179 | String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); |
| 203 | - String deviceID = XmlUtil.getText(rootElement, "DeviceID"); | 180 | + String deviceId = XmlUtil.getText(rootElement, "DeviceID"); |
| 204 | ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); | 181 | ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); |
| 205 | - if (platform == null)return; | 182 | + if (platform == null){ |
| 183 | + return; | ||
| 184 | + } | ||
| 206 | SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); | 185 | SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); |
| 207 | if (evt.getServerTransaction() == null) { | 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 | : udpSipProvider.getNewServerTransaction(evt.getRequest()); | 188 | : udpSipProvider.getNewServerTransaction(evt.getRequest()); |
| 210 | subscribeInfo.setTransaction(serverTransaction); | 189 | subscribeInfo.setTransaction(serverTransaction); |
| 211 | Dialog dialog = serverTransaction.getDialog(); | 190 | Dialog dialog = serverTransaction.getDialog(); |
| @@ -213,13 +192,13 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -213,13 +192,13 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 213 | subscribeInfo.setDialog(dialog); | 192 | subscribeInfo.setDialog(dialog); |
| 214 | } | 193 | } |
| 215 | String sn = XmlUtil.getText(rootElement, "SN"); | 194 | String sn = XmlUtil.getText(rootElement, "SN"); |
| 216 | - logger.info("[回复 目录订阅]: {}/{}", platformId, deviceID); | 195 | + logger.info("[回复 目录订阅]: {}/{}", platformId, deviceId); |
| 217 | StringBuilder resultXml = new StringBuilder(200); | 196 | StringBuilder resultXml = new StringBuilder(200); |
| 218 | resultXml.append("<?xml version=\"1.0\" ?>\r\n") | 197 | resultXml.append("<?xml version=\"1.0\" ?>\r\n") |
| 219 | .append("<Response>\r\n") | 198 | .append("<Response>\r\n") |
| 220 | .append("<CmdType>Catalog</CmdType>\r\n") | 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 | .append("<Result>OK</Result>\r\n") | 202 | .append("<Result>OK</Result>\r\n") |
| 224 | .append("</Response>\r\n"); | 203 | .append("</Response>\r\n"); |
| 225 | 204 | ||
| @@ -232,11 +211,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -232,11 +211,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 232 | try { | 211 | try { |
| 233 | ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); | 212 | ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); |
| 234 | responseXmlAck(evt, resultXml.toString(), parentPlatform); | 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 | e.printStackTrace(); | 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 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; |
| 2 | 2 | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | import com.genersoft.iot.vmp.conf.SipConfig; | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | import com.genersoft.iot.vmp.conf.UserSetting; | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.*; | 5 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | ||
| 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 6 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 7 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 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,7 +12,6 @@ import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; | ||
| 14 | import com.genersoft.iot.vmp.service.IDeviceAlarmService; | 12 | import com.genersoft.iot.vmp.service.IDeviceAlarmService; |
| 15 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 16 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 14 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 17 | -import com.genersoft.iot.vmp.utils.GpsUtil; | ||
| 18 | import org.dom4j.Element; | 15 | import org.dom4j.Element; |
| 19 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
| 20 | import org.slf4j.LoggerFactory; | 17 | import org.slf4j.LoggerFactory; |
| @@ -35,7 +32,7 @@ import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.*; | @@ -35,7 +32,7 @@ import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.*; | ||
| 35 | @Component | 32 | @Component |
| 36 | public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { | 33 | public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { |
| 37 | 34 | ||
| 38 | - private Logger logger = LoggerFactory.getLogger(AlarmNotifyMessageHandler.class); | 35 | + private final Logger logger = LoggerFactory.getLogger(AlarmNotifyMessageHandler.class); |
| 39 | private final String cmdType = "Alarm"; | 36 | private final String cmdType = "Alarm"; |
| 40 | 37 | ||
| 41 | @Autowired | 38 | @Autowired |
| @@ -59,9 +56,6 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | @@ -59,9 +56,6 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | ||
| 59 | @Autowired | 56 | @Autowired |
| 60 | private IDeviceAlarmService deviceAlarmService; | 57 | private IDeviceAlarmService deviceAlarmService; |
| 61 | 58 | ||
| 62 | - @Autowired | ||
| 63 | - private DeviceOffLineDetector offLineDetector; | ||
| 64 | - | ||
| 65 | @Override | 59 | @Override |
| 66 | public void afterPropertiesSet() throws Exception { | 60 | public void afterPropertiesSet() throws Exception { |
| 67 | notifyMessageHandler.addHandler(cmdType, this); | 61 | notifyMessageHandler.addHandler(cmdType, this); |
| @@ -91,24 +85,27 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | @@ -91,24 +85,27 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | ||
| 91 | deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority")); | 85 | deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority")); |
| 92 | deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod")); | 86 | deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod")); |
| 93 | deviceAlarm.setAlarmTime(getText(rootElement, "AlarmTime")); | 87 | deviceAlarm.setAlarmTime(getText(rootElement, "AlarmTime")); |
| 94 | - if (getText(rootElement, "AlarmDescription") == null) { | 88 | + String alarmDescription = getText(rootElement, "AlarmDescription"); |
| 89 | + if (alarmDescription == null) { | ||
| 95 | deviceAlarm.setAlarmDescription(""); | 90 | deviceAlarm.setAlarmDescription(""); |
| 96 | } else { | 91 | } else { |
| 97 | - deviceAlarm.setAlarmDescription(getText(rootElement, "AlarmDescription")); | 92 | + deviceAlarm.setAlarmDescription(alarmDescription); |
| 98 | } | 93 | } |
| 99 | - if (NumericUtil.isDouble(getText(rootElement, "Longitude"))) { | ||
| 100 | - deviceAlarm.setLongitude(Double.parseDouble(getText(rootElement, "Longitude"))); | 94 | + String longitude = getText(rootElement, "Longitude"); |
| 95 | + if (longitude != null && NumericUtil.isDouble(longitude)) { | ||
| 96 | + deviceAlarm.setLongitude(Double.parseDouble(longitude)); | ||
| 101 | } else { | 97 | } else { |
| 102 | deviceAlarm.setLongitude(0.00); | 98 | deviceAlarm.setLongitude(0.00); |
| 103 | } | 99 | } |
| 104 | - if (NumericUtil.isDouble(getText(rootElement, "Latitude"))) { | ||
| 105 | - deviceAlarm.setLatitude(Double.parseDouble(getText(rootElement, "Latitude"))); | 100 | + String latitude = getText(rootElement, "Latitude"); |
| 101 | + if (latitude != null && NumericUtil.isDouble(latitude)) { | ||
| 102 | + deviceAlarm.setLatitude(Double.parseDouble(latitude)); | ||
| 106 | } else { | 103 | } else { |
| 107 | deviceAlarm.setLatitude(0.00); | 104 | deviceAlarm.setLatitude(0.00); |
| 108 | } | 105 | } |
| 109 | 106 | ||
| 110 | if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) { | 107 | if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) { |
| 111 | - if ( deviceAlarm.getAlarmMethod().equals("4")) { | 108 | + if ( deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.GPS.getVal() + "")) { |
| 112 | MobilePosition mobilePosition = new MobilePosition(); | 109 | MobilePosition mobilePosition = new MobilePosition(); |
| 113 | mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); | 110 | mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); |
| 114 | mobilePosition.setTime(deviceAlarm.getAlarmTime()); | 111 | mobilePosition.setTime(deviceAlarm.getAlarmTime()); |
| @@ -128,7 +125,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | @@ -128,7 +125,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | ||
| 128 | } | 125 | } |
| 129 | } | 126 | } |
| 130 | if (!StringUtils.isEmpty(deviceAlarm.getDeviceId())) { | 127 | if (!StringUtils.isEmpty(deviceAlarm.getDeviceId())) { |
| 131 | - if (deviceAlarm.getAlarmMethod().equals("5")) { | 128 | + if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) { |
| 132 | deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); | 129 | deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); |
| 133 | } | 130 | } |
| 134 | } | 131 | } |
| @@ -151,7 +148,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | @@ -151,7 +148,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | ||
| 151 | } | 148 | } |
| 152 | 149 | ||
| 153 | 150 | ||
| 154 | - if (offLineDetector.isOnline(device.getDeviceId())) { | 151 | + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) { |
| 155 | publisher.deviceAlarmEventPublish(deviceAlarm); | 152 | publisher.deviceAlarmEventPublish(deviceAlarm); |
| 156 | } | 153 | } |
| 157 | } | 154 | } |
| @@ -179,25 +176,28 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | @@ -179,25 +176,28 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | ||
| 179 | deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority")); | 176 | deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority")); |
| 180 | deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod")); | 177 | deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod")); |
| 181 | deviceAlarm.setAlarmTime(getText(rootElement, "AlarmTime")); | 178 | deviceAlarm.setAlarmTime(getText(rootElement, "AlarmTime")); |
| 182 | - if (getText(rootElement, "AlarmDescription") == null) { | 179 | + String alarmDescription = getText(rootElement, "AlarmDescription"); |
| 180 | + if (alarmDescription == null) { | ||
| 183 | deviceAlarm.setAlarmDescription(""); | 181 | deviceAlarm.setAlarmDescription(""); |
| 184 | } else { | 182 | } else { |
| 185 | - deviceAlarm.setAlarmDescription(getText(rootElement, "AlarmDescription")); | 183 | + deviceAlarm.setAlarmDescription(alarmDescription); |
| 186 | } | 184 | } |
| 187 | - if (NumericUtil.isDouble(getText(rootElement, "Longitude"))) { | ||
| 188 | - deviceAlarm.setLongitude(Double.parseDouble(getText(rootElement, "Longitude"))); | 185 | + String longitude = getText(rootElement, "Longitude"); |
| 186 | + if (longitude != null && NumericUtil.isDouble(longitude)) { | ||
| 187 | + deviceAlarm.setLongitude(Double.parseDouble(longitude)); | ||
| 189 | } else { | 188 | } else { |
| 190 | deviceAlarm.setLongitude(0.00); | 189 | deviceAlarm.setLongitude(0.00); |
| 191 | } | 190 | } |
| 192 | - if (NumericUtil.isDouble(getText(rootElement, "Latitude"))) { | ||
| 193 | - deviceAlarm.setLatitude(Double.parseDouble(getText(rootElement, "Latitude"))); | 191 | + String latitude = getText(rootElement, "Latitude"); |
| 192 | + if (latitude != null && NumericUtil.isDouble(latitude)) { | ||
| 193 | + deviceAlarm.setLatitude(Double.parseDouble(latitude)); | ||
| 194 | } else { | 194 | } else { |
| 195 | deviceAlarm.setLatitude(0.00); | 195 | deviceAlarm.setLatitude(0.00); |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) { | 198 | if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) { |
| 199 | 199 | ||
| 200 | - if (deviceAlarm.getAlarmMethod().equals("5")) { | 200 | + if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) { |
| 201 | deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); | 201 | deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); |
| 202 | } | 202 | } |
| 203 | } | 203 | } |
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,7 +70,9 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp | ||
| 70 | videoManagerStorager.updateDevice(device); | 70 | videoManagerStorager.updateDevice(device); |
| 71 | redisCatchStorage.updateDevice(device); | 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 | } catch (SipException e) { | 77 | } catch (SipException e) { |
| 76 | e.printStackTrace(); | 78 | e.printStackTrace(); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
| 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; | 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 | import com.genersoft.iot.vmp.conf.SipConfig; | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | import com.genersoft.iot.vmp.conf.UserSetting; | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.*; | 5 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | ||
| 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 6 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch; | 7 | import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch; |
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 11 | -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | ||
| 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 14 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; | 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,8 +14,6 @@ import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; | ||
| 17 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; | 14 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| 18 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 15 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 19 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 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 | import org.dom4j.DocumentException; | 17 | import org.dom4j.DocumentException; |
| 23 | import org.dom4j.Element; | 18 | import org.dom4j.Element; |
| 24 | import org.slf4j.Logger; | 19 | import org.slf4j.Logger; |
| @@ -59,9 +54,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp | @@ -59,9 +54,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp | ||
| 59 | private CatalogDataCatch catalogDataCatch; | 54 | private CatalogDataCatch catalogDataCatch; |
| 60 | 55 | ||
| 61 | @Autowired | 56 | @Autowired |
| 62 | - private DeviceOffLineDetector offLineDetector; | ||
| 63 | - | ||
| 64 | - @Autowired | ||
| 65 | private SipConfig config; | 57 | private SipConfig config; |
| 66 | 58 | ||
| 67 | @Autowired | 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,13 +4,13 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; | ||
| 4 | import com.genersoft.iot.vmp.conf.SipConfig; | 4 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | ||
| 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 7 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; | 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| 13 | +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | ||
| 14 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 14 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 15 | import org.dom4j.DocumentException; | 15 | import org.dom4j.DocumentException; |
| 16 | import org.dom4j.Element; | 16 | import org.dom4j.Element; |
| @@ -42,10 +42,10 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent | @@ -42,10 +42,10 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent | ||
| 42 | private IVideoManagerStorage storager; | 42 | private IVideoManagerStorage storager; |
| 43 | 43 | ||
| 44 | @Autowired | 44 | @Autowired |
| 45 | - private DeferredResultHolder deferredResultHolder; | 45 | + private IRedisCatchStorage redisCatchStorage; |
| 46 | 46 | ||
| 47 | @Autowired | 47 | @Autowired |
| 48 | - private DeviceOffLineDetector offLineDetector; | 48 | + private DeferredResultHolder deferredResultHolder; |
| 49 | 49 | ||
| 50 | @Autowired | 50 | @Autowired |
| 51 | private SipConfig config; | 51 | private SipConfig config; |
| @@ -82,7 +82,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent | @@ -82,7 +82,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent | ||
| 82 | deferredResultHolder.invokeAllResult(msg); | 82 | deferredResultHolder.invokeAllResult(msg); |
| 83 | // 回复200 OK | 83 | // 回复200 OK |
| 84 | responseAck(evt, Response.OK); | 84 | responseAck(evt, Response.OK); |
| 85 | - if (offLineDetector.isOnline(device.getDeviceId())) { | 85 | + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) { |
| 86 | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); | 86 | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); |
| 87 | } | 87 | } |
| 88 | } catch (DocumentException e) { | 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,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; | ||
| 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | ||
| 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 7 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | 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,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP | ||
| 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; | 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| 14 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; | 13 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| 14 | +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | ||
| 15 | import org.dom4j.Element; | 15 | import org.dom4j.Element; |
| 16 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
| 17 | import org.slf4j.LoggerFactory; | 17 | import org.slf4j.LoggerFactory; |
| @@ -34,8 +34,6 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen | @@ -34,8 +34,6 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen | ||
| 34 | @Autowired | 34 | @Autowired |
| 35 | private ResponseMessageHandler responseMessageHandler; | 35 | private ResponseMessageHandler responseMessageHandler; |
| 36 | 36 | ||
| 37 | - @Autowired | ||
| 38 | - private DeviceOffLineDetector offLineDetector; | ||
| 39 | 37 | ||
| 40 | @Autowired | 38 | @Autowired |
| 41 | private DeferredResultHolder deferredResultHolder; | 39 | private DeferredResultHolder deferredResultHolder; |
| @@ -43,6 +41,9 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen | @@ -43,6 +41,9 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen | ||
| 43 | @Autowired | 41 | @Autowired |
| 44 | private EventPublisher publisher; | 42 | private EventPublisher publisher; |
| 45 | 43 | ||
| 44 | + @Autowired | ||
| 45 | + private IRedisCatchStorage redisCatchStorage; | ||
| 46 | + | ||
| 46 | @Override | 47 | @Override |
| 47 | public void afterPropertiesSet() throws Exception { | 48 | public void afterPropertiesSet() throws Exception { |
| 48 | responseMessageHandler.addHandler(cmdType, this); | 49 | responseMessageHandler.addHandler(cmdType, this); |
| @@ -74,10 +75,8 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen | @@ -74,10 +75,8 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen | ||
| 74 | msg.setData(json); | 75 | msg.setData(json); |
| 75 | deferredResultHolder.invokeAllResult(msg); | 76 | deferredResultHolder.invokeAllResult(msg); |
| 76 | 77 | ||
| 77 | - if (offLineDetector.isOnline(device.getDeviceId())) { | 78 | + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) { |
| 78 | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); | 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,7 +25,9 @@ public class SipUtils { | ||
| 25 | * */ | 25 | * */ |
| 26 | public static String getChannelIdFromHeader(Request request) { | 26 | public static String getChannelIdFromHeader(Request request) { |
| 27 | Header subject = request.getHeader("subject"); | 27 | Header subject = request.getHeader("subject"); |
| 28 | - if (subject == null) return null; | 28 | + if (subject == null) { |
| 29 | + return null; | ||
| 30 | + } | ||
| 29 | return ((Subject) subject).getSubject().split(":")[0]; | 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,7 +85,9 @@ public class ZLMHttpHookSubscribe { | ||
| 85 | if (result == null) { | 85 | if (result == null) { |
| 86 | result = key.getString(s).equals(hookResponse.getString(s)); | 86 | result = key.getString(s).equals(hookResponse.getString(s)); |
| 87 | }else { | 87 | }else { |
| 88 | - if (key.getString(s) == null) continue; | 88 | + if (key.getString(s) == null) { |
| 89 | + continue; | ||
| 90 | + } | ||
| 89 | result = result && key.getString(s).equals(hookResponse.getString(s)); | 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,7 +67,9 @@ public class ZLMMediaListManager { | ||
| 67 | 67 | ||
| 68 | // 使用异步的当时更新媒体流列表 | 68 | // 使用异步的当时更新媒体流列表 |
| 69 | zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ | 69 | zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ |
| 70 | - if (mediaList == null) return; | 70 | + if (mediaList == null) { |
| 71 | + return; | ||
| 72 | + } | ||
| 71 | String dataStr = mediaList.getString("data"); | 73 | String dataStr = mediaList.getString("data"); |
| 72 | 74 | ||
| 73 | Integer code = mediaList.getInteger("code"); | 75 | Integer code = mediaList.getInteger("code"); |
| @@ -176,7 +178,9 @@ public class ZLMMediaListManager { | @@ -176,7 +178,9 @@ public class ZLMMediaListManager { | ||
| 176 | //使用异步更新推流 | 178 | //使用异步更新推流 |
| 177 | zlmresTfulUtils.getMediaList(mediaServerItem, app, streamId, "rtmp", json->{ | 179 | zlmresTfulUtils.getMediaList(mediaServerItem, app, streamId, "rtmp", json->{ |
| 178 | 180 | ||
| 179 | - if (json == null) return; | 181 | + if (json == null) { |
| 182 | + return; | ||
| 183 | + } | ||
| 180 | String dataStr = json.getString("data"); | 184 | String dataStr = json.getString("data"); |
| 181 | 185 | ||
| 182 | Integer code = json.getInteger("code"); | 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,7 +23,9 @@ public class ZLMRTPServerFactory { | ||
| 23 | private int[] portRangeArray = new int[2]; | 23 | private int[] portRangeArray = new int[2]; |
| 24 | 24 | ||
| 25 | public int getFreePort(MediaServerItem mediaServerItem, int startPort, int endPort, List<Integer> usedFreelist) { | 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 | if (usedFreelist == null) { | 29 | if (usedFreelist == null) { |
| 28 | usedFreelist = new ArrayList<>(); | 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,6 +3,7 @@ package com.genersoft.iot.vmp.media.zlm; | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | +import com.genersoft.iot.vmp.conf.DynamicTask; | ||
| 6 | import com.genersoft.iot.vmp.conf.MediaConfig; | 7 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 7 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 8 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| @@ -51,6 +52,9 @@ public class ZLMRunner implements CommandLineRunner { | @@ -51,6 +52,9 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 51 | @Autowired | 52 | @Autowired |
| 52 | private MediaConfig mediaConfig; | 53 | private MediaConfig mediaConfig; |
| 53 | 54 | ||
| 55 | + @Autowired | ||
| 56 | + private DynamicTask dynamicTask; | ||
| 57 | + | ||
| 54 | @Qualifier("taskExecutor") | 58 | @Qualifier("taskExecutor") |
| 55 | @Autowired | 59 | @Autowired |
| 56 | private ThreadPoolTaskExecutor taskExecutor; | 60 | private ThreadPoolTaskExecutor taskExecutor; |
| @@ -97,27 +101,25 @@ public class ZLMRunner implements CommandLineRunner { | @@ -97,27 +101,25 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 97 | all.add(mediaConfig.getMediaSerItem()); | 101 | all.add(mediaConfig.getMediaSerItem()); |
| 98 | } | 102 | } |
| 99 | for (MediaServerItem mediaServerItem : all) { | 103 | for (MediaServerItem mediaServerItem : all) { |
| 100 | - if (startGetMedia == null) startGetMedia = new HashMap<>(); | 104 | + if (startGetMedia == null) { |
| 105 | + startGetMedia = new HashMap<>(); | ||
| 106 | + } | ||
| 101 | startGetMedia.put(mediaServerItem.getId(), true); | 107 | startGetMedia.put(mediaServerItem.getId(), true); |
| 102 | taskExecutor.execute(()->{ | 108 | taskExecutor.execute(()->{ |
| 103 | connectZlmServer(mediaServerItem); | 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 | if (startGetMedia != null) { | 114 | if (startGetMedia != null) { |
| 112 | Set<String> allZlmId = startGetMedia.keySet(); | 115 | Set<String> allZlmId = startGetMedia.keySet(); |
| 113 | for (String id : allZlmId) { | 116 | for (String id : allZlmId) { |
| 114 | - logger.error("[ {} ]]主动连接失败,不再主动连接", id); | 117 | + logger.error("[ {} ]]主动连接失败,不再尝试连接", id); |
| 115 | } | 118 | } |
| 116 | startGetMedia = null; | 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 | @Async | 125 | @Async |
| @@ -139,12 +141,12 @@ public class ZLMRunner implements CommandLineRunner { | @@ -139,12 +141,12 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 139 | if ( startGetMedia.get(mediaServerItem.getId()) == null || !startGetMedia.get(mediaServerItem.getId())) { | 141 | if ( startGetMedia.get(mediaServerItem.getId()) == null || !startGetMedia.get(mediaServerItem.getId())) { |
| 140 | return null; | 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 | if (data != null && data.size() > 0) { | 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 | } else { | 151 | } else { |
| 150 | logger.error("[ {} ]-[ {}:{} ]第{}次主动连接失败, 2s后重试", | 152 | logger.error("[ {} ]-[ {}:{} ]第{}次主动连接失败, 2s后重试", |
| @@ -159,9 +161,9 @@ public class ZLMRunner implements CommandLineRunner { | @@ -159,9 +161,9 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 159 | } catch (InterruptedException e) { | 161 | } catch (InterruptedException e) { |
| 160 | e.printStackTrace(); | 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,18 +29,22 @@ public class StreamProxyItem extends GbStream { | ||
| 29 | this.type = type; | 29 | this.type = type; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | + @Override | ||
| 32 | public String getApp() { | 33 | public String getApp() { |
| 33 | return app; | 34 | return app; |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 37 | + @Override | ||
| 36 | public void setApp(String app) { | 38 | public void setApp(String app) { |
| 37 | this.app = app; | 39 | this.app = app; |
| 38 | } | 40 | } |
| 39 | 41 | ||
| 42 | + @Override | ||
| 40 | public String getStream() { | 43 | public String getStream() { |
| 41 | return stream; | 44 | return stream; |
| 42 | } | 45 | } |
| 43 | 46 | ||
| 47 | + @Override | ||
| 44 | public void setStream(String stream) { | 48 | public void setStream(String stream) { |
| 45 | this.stream = stream; | 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<StreamPushIte | @@ -124,18 +124,22 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte | ||
| 124 | this.id = id; | 124 | this.id = id; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | + @Override | ||
| 127 | public String getApp() { | 128 | public String getApp() { |
| 128 | return app; | 129 | return app; |
| 129 | } | 130 | } |
| 130 | 131 | ||
| 132 | + @Override | ||
| 131 | public void setApp(String app) { | 133 | public void setApp(String app) { |
| 132 | this.app = app; | 134 | this.app = app; |
| 133 | } | 135 | } |
| 134 | 136 | ||
| 137 | + @Override | ||
| 135 | public String getStream() { | 138 | public String getStream() { |
| 136 | return stream; | 139 | return stream; |
| 137 | } | 140 | } |
| 138 | 141 | ||
| 142 | + @Override | ||
| 139 | public void setStream(String stream) { | 143 | public void setStream(String stream) { |
| 140 | this.stream = stream; | 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,6 +12,8 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | ||
| 12 | import org.slf4j.Logger; | 12 | import org.slf4j.Logger; |
| 13 | import org.slf4j.LoggerFactory; | 13 | import org.slf4j.LoggerFactory; |
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | +import org.springframework.beans.factory.annotation.Qualifier; | ||
| 16 | +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
| 15 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 16 | 18 | ||
| 17 | import javax.sip.DialogState; | 19 | import javax.sip.DialogState; |
| @@ -43,7 +45,7 @@ public class DeviceServiceImpl implements IDeviceService { | @@ -43,7 +45,7 @@ public class DeviceServiceImpl implements IDeviceService { | ||
| 43 | } | 45 | } |
| 44 | logger.info("[添加目录订阅] 设备{}", device.getDeviceId()); | 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 | int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForCatalog(),30); | 50 | int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForCatalog(),30); |
| 49 | // 设置最小值为30 | 51 | // 设置最小值为30 |
| @@ -68,10 +70,10 @@ public class DeviceServiceImpl implements IDeviceService { | @@ -68,10 +70,10 @@ public class DeviceServiceImpl implements IDeviceService { | ||
| 68 | } | 70 | } |
| 69 | logger.info("[添加移动位置订阅] 设备{}", device.getDeviceId()); | 71 | logger.info("[添加移动位置订阅] 设备{}", device.getDeviceId()); |
| 70 | // 添加目录订阅 | 72 | // 添加目录订阅 |
| 71 | - MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander); | ||
| 72 | - // 提前开始刷新订阅 | 73 | + MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander, dynamicTask); |
| 73 | // 设置最小值为30 | 74 | // 设置最小值为30 |
| 74 | int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForMobilePosition(),30); | 75 | int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForMobilePosition(),30); |
| 76 | + // 提前开始刷新订阅 | ||
| 75 | dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, subscribeCycleForCatalog -1 ); | 77 | dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, subscribeCycleForCatalog -1 ); |
| 76 | return true; | 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,7 +70,9 @@ public class GbStreamServiceImpl implements IGbStreamService { | ||
| 70 | boolean result = false; | 70 | boolean result = false; |
| 71 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); | 71 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| 72 | ParentPlatform parentPlatform = platformMapper.getParentPlatByServerGBId(platformId); | 72 | ParentPlatform parentPlatform = platformMapper.getParentPlatByServerGBId(platformId); |
| 73 | - if (catalogId == null) catalogId = parentPlatform.getCatalogId(); | 73 | + if (catalogId == null) { |
| 74 | + catalogId = parentPlatform.getCatalogId(); | ||
| 75 | + } | ||
| 74 | try { | 76 | try { |
| 75 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); | 77 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); |
| 76 | for (GbStream gbStream : gbStreams) { | 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,7 +54,9 @@ public class MediaServiceImpl implements IMediaService { | ||
| 54 | if (mediaList != null) { | 54 | if (mediaList != null) { |
| 55 | if (mediaList.getInteger("code") == 0) { | 55 | if (mediaList.getInteger("code") == 0) { |
| 56 | JSONArray data = mediaList.getJSONArray("data"); | 56 | JSONArray data = mediaList.getJSONArray("data"); |
| 57 | - if (data == null) return null; | 57 | + if (data == null) { |
| 58 | + return null; | ||
| 59 | + } | ||
| 58 | JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class); | 60 | JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class); |
| 59 | JSONArray tracks = mediaJSON.getJSONArray("tracks"); | 61 | JSONArray tracks = mediaJSON.getJSONArray("tracks"); |
| 60 | streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks); | 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,6 +4,7 @@ import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | import com.genersoft.iot.vmp.common.StreamInfo; | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 7 | +import com.genersoft.iot.vmp.conf.DynamicTask; | ||
| 7 | import com.genersoft.iot.vmp.conf.UserSetting; | 8 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 8 | import com.genersoft.iot.vmp.gb28181.bean.*; | 9 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 9 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 10 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| @@ -86,6 +87,9 @@ public class PlayServiceImpl implements IPlayService { | @@ -86,6 +87,9 @@ public class PlayServiceImpl implements IPlayService { | ||
| 86 | @Autowired | 87 | @Autowired |
| 87 | private UserSetting userSetting; | 88 | private UserSetting userSetting; |
| 88 | 89 | ||
| 90 | + @Autowired | ||
| 91 | + private DynamicTask dynamicTask; | ||
| 92 | + | ||
| 89 | 93 | ||
| 90 | 94 | ||
| 91 | 95 | ||
| @@ -100,7 +104,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -100,7 +104,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 100 | String uuid = UUID.randomUUID().toString(); | 104 | String uuid = UUID.randomUUID().toString(); |
| 101 | msg.setId(uuid); | 105 | msg.setId(uuid); |
| 102 | playResult.setUuid(uuid); | 106 | playResult.setUuid(uuid); |
| 103 | - DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetting.getPlayTimeout()); | 107 | + DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); |
| 104 | playResult.setResult(result); | 108 | playResult.setResult(result); |
| 105 | // 录像查询以channelId作为deviceId查询 | 109 | // 录像查询以channelId作为deviceId查询 |
| 106 | resultHolder.put(key, uuid, result); | 110 | resultHolder.put(key, uuid, result); |
| @@ -237,30 +241,27 @@ public class PlayServiceImpl implements IPlayService { | @@ -237,30 +241,27 @@ public class PlayServiceImpl implements IPlayService { | ||
| 237 | } | 241 | } |
| 238 | 242 | ||
| 239 | // 超时处理 | 243 | // 超时处理 |
| 240 | - Timer timer = new Timer(); | 244 | + String timeOutTaskKey = UUID.randomUUID().toString(); |
| 241 | SSRCInfo finalSsrcInfo = ssrcInfo; | 245 | SSRCInfo finalSsrcInfo = ssrcInfo; |
| 242 | - timer.schedule(new TimerTask() { | ||
| 243 | - @Override | ||
| 244 | - public void run() { | ||
| 245 | - logger.warn(String.format("设备点播超时,deviceId:%s ,channelId:%s", device.getDeviceId(), channelId)); | ||
| 246 | - | ||
| 247 | - SIPDialog dialog = streamSession.getDialogByStream(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | ||
| 248 | - if (dialog != null) { | ||
| 249 | - timeoutCallback.run(1, "收流超时"); | ||
| 250 | - // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | ||
| 251 | - cmder.streamByeCmd(device.getDeviceId(), channelId, finalSsrcInfo.getStream(), null); | ||
| 252 | - }else { | ||
| 253 | - timeoutCallback.run(0, "点播超时"); | ||
| 254 | - mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc()); | ||
| 255 | - mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | ||
| 256 | - streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | ||
| 257 | - } | 246 | + dynamicTask.startDelay( timeOutTaskKey,()->{ |
| 247 | + logger.warn(String.format("设备点播超时,deviceId:%s ,channelId:%s", device.getDeviceId(), channelId)); | ||
| 248 | + | ||
| 249 | + SIPDialog dialog = streamSession.getDialogByStream(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | ||
| 250 | + if (dialog != null) { | ||
| 251 | + timeoutCallback.run(1, "收流超时"); | ||
| 252 | + // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | ||
| 253 | + cmder.streamByeCmd(device.getDeviceId(), channelId, finalSsrcInfo.getStream(), null); | ||
| 254 | + }else { | ||
| 255 | + timeoutCallback.run(0, "点播超时"); | ||
| 256 | + mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc()); | ||
| 257 | + mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | ||
| 258 | + streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | ||
| 258 | } | 259 | } |
| 259 | - }, userSetting.getPlayTimeout()); | 260 | + }, userSetting.getPlayTimeout()*1000); |
| 260 | final String ssrc = ssrcInfo.getSsrc(); | 261 | final String ssrc = ssrcInfo.getSsrc(); |
| 261 | cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { | 262 | cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { |
| 262 | logger.info("收到订阅消息: " + response.toJSONString()); | 263 | logger.info("收到订阅消息: " + response.toJSONString()); |
| 263 | - timer.cancel(); | 264 | + dynamicTask.stop(timeOutTaskKey); |
| 264 | // hook响应 | 265 | // hook响应 |
| 265 | onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid); | 266 | onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid); |
| 266 | hookEvent.response(mediaServerItemInuse, response); | 267 | hookEvent.response(mediaServerItemInuse, response); |
| @@ -292,7 +293,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -292,7 +293,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 292 | } | 293 | } |
| 293 | } | 294 | } |
| 294 | }, (event) -> { | 295 | }, (event) -> { |
| 295 | - timer.cancel(); | 296 | + dynamicTask.stop(timeOutTaskKey); |
| 296 | mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); | 297 | mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); |
| 297 | // 释放ssrc | 298 | // 释放ssrc |
| 298 | mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc()); | 299 | mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc()); |
| @@ -334,7 +335,9 @@ public class PlayServiceImpl implements IPlayService { | @@ -334,7 +335,9 @@ public class PlayServiceImpl implements IPlayService { | ||
| 334 | 335 | ||
| 335 | @Override | 336 | @Override |
| 336 | public MediaServerItem getNewMediaServerItem(Device device) { | 337 | public MediaServerItem getNewMediaServerItem(Device device) { |
| 337 | - if (device == null) return null; | 338 | + if (device == null) { |
| 339 | + return null; | ||
| 340 | + } | ||
| 338 | String mediaServerId = device.getMediaServerId(); | 341 | String mediaServerId = device.getMediaServerId(); |
| 339 | MediaServerItem mediaServerItem; | 342 | MediaServerItem mediaServerItem; |
| 340 | if (mediaServerId == null) { | 343 | if (mediaServerId == null) { |
| @@ -353,7 +356,9 @@ public class PlayServiceImpl implements IPlayService { | @@ -353,7 +356,9 @@ public class PlayServiceImpl implements IPlayService { | ||
| 353 | String endTime,InviteStreamCallback inviteStreamCallback, | 356 | String endTime,InviteStreamCallback inviteStreamCallback, |
| 354 | PlayBackCallback callback) { | 357 | PlayBackCallback callback) { |
| 355 | Device device = storager.queryVideoDevice(deviceId); | 358 | Device device = storager.queryVideoDevice(deviceId); |
| 356 | - if (device == null) return null; | 359 | + if (device == null) { |
| 360 | + return null; | ||
| 361 | + } | ||
| 357 | MediaServerItem newMediaServerItem = getNewMediaServerItem(device); | 362 | MediaServerItem newMediaServerItem = getNewMediaServerItem(device); |
| 358 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true); | 363 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true); |
| 359 | 364 | ||
| @@ -365,7 +370,9 @@ public class PlayServiceImpl implements IPlayService { | @@ -365,7 +370,9 @@ public class PlayServiceImpl implements IPlayService { | ||
| 365 | String deviceId, String channelId, String startTime, | 370 | String deviceId, String channelId, String startTime, |
| 366 | String endTime, InviteStreamCallback infoCallBack, | 371 | String endTime, InviteStreamCallback infoCallBack, |
| 367 | PlayBackCallback playBackCallback) { | 372 | PlayBackCallback playBackCallback) { |
| 368 | - if (mediaServerItem == null || ssrcInfo == null) return null; | 373 | + if (mediaServerItem == null || ssrcInfo == null) { |
| 374 | + return null; | ||
| 375 | + } | ||
| 369 | String uuid = UUID.randomUUID().toString(); | 376 | String uuid = UUID.randomUUID().toString(); |
| 370 | String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId; | 377 | String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId; |
| 371 | DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(30000L); | 378 | DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(30000L); |
| @@ -380,34 +387,31 @@ public class PlayServiceImpl implements IPlayService { | @@ -380,34 +387,31 @@ public class PlayServiceImpl implements IPlayService { | ||
| 380 | msg.setId(uuid); | 387 | msg.setId(uuid); |
| 381 | msg.setKey(key); | 388 | msg.setKey(key); |
| 382 | PlayBackResult<RequestMessage> playBackResult = new PlayBackResult<>(); | 389 | PlayBackResult<RequestMessage> playBackResult = new PlayBackResult<>(); |
| 383 | - | ||
| 384 | - Timer timer = new Timer(); | ||
| 385 | - timer.schedule(new TimerTask() { | ||
| 386 | - @Override | ||
| 387 | - public void run() { | ||
| 388 | - logger.warn(String.format("设备回放超时,deviceId:%s ,channelId:%s", deviceId, channelId)); | ||
| 389 | - playBackResult.setCode(-1); | ||
| 390 | - playBackResult.setData(msg); | ||
| 391 | - playBackCallback.call(playBackResult); | ||
| 392 | - SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); | 390 | + String playBackTimeOutTaskKey = UUID.randomUUID().toString(); |
| 391 | + dynamicTask.startDelay(playBackTimeOutTaskKey, ()->{ | ||
| 392 | + logger.warn(String.format("设备回放超时,deviceId:%s ,channelId:%s", deviceId, channelId)); | ||
| 393 | + playBackResult.setCode(-1); | ||
| 394 | + playBackResult.setData(msg); | ||
| 395 | + playBackCallback.call(playBackResult); | ||
| 396 | + SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); | ||
| 397 | + // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | ||
| 398 | + if (dialog != null) { | ||
| 393 | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | 399 | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 |
| 394 | - if (dialog != null) { | ||
| 395 | - // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | ||
| 396 | - cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); | ||
| 397 | - }else { | ||
| 398 | - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); | ||
| 399 | - mediaServerService.closeRTPServer(deviceId, channelId, ssrcInfo.getStream()); | ||
| 400 | - streamSession.remove(deviceId, channelId, ssrcInfo.getStream()); | ||
| 401 | - } | ||
| 402 | cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); | 400 | cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); |
| 403 | - // 回复之前所有的点播请求 | ||
| 404 | - playBackCallback.call(playBackResult); | 401 | + }else { |
| 402 | + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); | ||
| 403 | + mediaServerService.closeRTPServer(deviceId, channelId, ssrcInfo.getStream()); | ||
| 404 | + streamSession.remove(deviceId, channelId, ssrcInfo.getStream()); | ||
| 405 | } | 405 | } |
| 406 | - }, userSetting.getPlayTimeout()); | 406 | + cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); |
| 407 | + // 回复之前所有的点播请求 | ||
| 408 | + playBackCallback.call(playBackResult); | ||
| 409 | + }, userSetting.getPlayTimeout()*1000); | ||
| 410 | + | ||
| 407 | cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack, | 411 | cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack, |
| 408 | (InviteStreamInfo inviteStreamInfo) -> { | 412 | (InviteStreamInfo inviteStreamInfo) -> { |
| 409 | logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString()); | 413 | logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString()); |
| 410 | - timer.cancel(); | 414 | + dynamicTask.stop(playBackTimeOutTaskKey); |
| 411 | StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); | 415 | StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); |
| 412 | if (streamInfo == null) { | 416 | if (streamInfo == null) { |
| 413 | logger.warn("设备回放API调用失败!"); | 417 | logger.warn("设备回放API调用失败!"); |
| @@ -425,7 +429,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -425,7 +429,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 425 | playBackResult.setResponse(inviteStreamInfo.getResponse()); | 429 | playBackResult.setResponse(inviteStreamInfo.getResponse()); |
| 426 | playBackCallback.call(playBackResult); | 430 | playBackCallback.call(playBackResult); |
| 427 | }, event -> { | 431 | }, event -> { |
| 428 | - timer.cancel(); | 432 | + dynamicTask.stop(playBackTimeOutTaskKey); |
| 429 | msg.setData(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg)); | 433 | msg.setData(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg)); |
| 430 | playBackResult.setCode(-1); | 434 | playBackResult.setCode(-1); |
| 431 | playBackResult.setData(msg); | 435 | playBackResult.setData(msg); |
| @@ -439,7 +443,9 @@ public class PlayServiceImpl implements IPlayService { | @@ -439,7 +443,9 @@ public class PlayServiceImpl implements IPlayService { | ||
| 439 | @Override | 443 | @Override |
| 440 | public DeferredResult<ResponseEntity<String>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { | 444 | public DeferredResult<ResponseEntity<String>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { |
| 441 | Device device = storager.queryVideoDevice(deviceId); | 445 | Device device = storager.queryVideoDevice(deviceId); |
| 442 | - if (device == null) return null; | 446 | + if (device == null) { |
| 447 | + return null; | ||
| 448 | + } | ||
| 443 | MediaServerItem newMediaServerItem = getNewMediaServerItem(device); | 449 | MediaServerItem newMediaServerItem = getNewMediaServerItem(device); |
| 444 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true); | 450 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true); |
| 445 | 451 | ||
| @@ -448,7 +454,9 @@ public class PlayServiceImpl implements IPlayService { | @@ -448,7 +454,9 @@ public class PlayServiceImpl implements IPlayService { | ||
| 448 | 454 | ||
| 449 | @Override | 455 | @Override |
| 450 | public DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { | 456 | public DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { |
| 451 | - if (mediaServerItem == null || ssrcInfo == null) return null; | 457 | + if (mediaServerItem == null || ssrcInfo == null) { |
| 458 | + return null; | ||
| 459 | + } | ||
| 452 | String uuid = UUID.randomUUID().toString(); | 460 | String uuid = UUID.randomUUID().toString(); |
| 453 | String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId; | 461 | String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId; |
| 454 | DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(30000L); | 462 | DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(30000L); |
| @@ -467,34 +475,31 @@ public class PlayServiceImpl implements IPlayService { | @@ -467,34 +475,31 @@ public class PlayServiceImpl implements IPlayService { | ||
| 467 | PlayBackResult<RequestMessage> downloadResult = new PlayBackResult<>(); | 475 | PlayBackResult<RequestMessage> downloadResult = new PlayBackResult<>(); |
| 468 | downloadResult.setData(msg); | 476 | downloadResult.setData(msg); |
| 469 | 477 | ||
| 470 | - Timer timer = new Timer(); | ||
| 471 | - timer.schedule(new TimerTask() { | ||
| 472 | - @Override | ||
| 473 | - public void run() { | ||
| 474 | - logger.warn(String.format("录像下载请求超时,deviceId:%s ,channelId:%s", deviceId, channelId)); | ||
| 475 | - wvpResult.setCode(-1); | ||
| 476 | - wvpResult.setMsg("录像下载请求超时"); | ||
| 477 | - downloadResult.setCode(-1); | ||
| 478 | - hookCallBack.call(downloadResult); | ||
| 479 | - SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); | 478 | + String downLoadTimeOutTaskKey = UUID.randomUUID().toString(); |
| 479 | + dynamicTask.startDelay(downLoadTimeOutTaskKey, ()->{ | ||
| 480 | + logger.warn(String.format("录像下载请求超时,deviceId:%s ,channelId:%s", deviceId, channelId)); | ||
| 481 | + wvpResult.setCode(-1); | ||
| 482 | + wvpResult.setMsg("录像下载请求超时"); | ||
| 483 | + downloadResult.setCode(-1); | ||
| 484 | + hookCallBack.call(downloadResult); | ||
| 485 | + SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); | ||
| 486 | + // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | ||
| 487 | + if (dialog != null) { | ||
| 480 | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | 488 | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 |
| 481 | - if (dialog != null) { | ||
| 482 | - // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 | ||
| 483 | - cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); | ||
| 484 | - }else { | ||
| 485 | - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); | ||
| 486 | - mediaServerService.closeRTPServer(deviceId, channelId, ssrcInfo.getStream()); | ||
| 487 | - streamSession.remove(deviceId, channelId, ssrcInfo.getStream()); | ||
| 488 | - } | ||
| 489 | cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); | 489 | cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); |
| 490 | - // 回复之前所有的点播请求 | ||
| 491 | - hookCallBack.call(downloadResult); | 490 | + }else { |
| 491 | + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); | ||
| 492 | + mediaServerService.closeRTPServer(deviceId, channelId, ssrcInfo.getStream()); | ||
| 493 | + streamSession.remove(deviceId, channelId, ssrcInfo.getStream()); | ||
| 492 | } | 494 | } |
| 493 | - }, userSetting.getPlayTimeout()); | 495 | + cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); |
| 496 | + // 回复之前所有的点播请求 | ||
| 497 | + hookCallBack.call(downloadResult); | ||
| 498 | + }, userSetting.getPlayTimeout()*1000); | ||
| 494 | cmder.downloadStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, infoCallBack, | 499 | cmder.downloadStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, infoCallBack, |
| 495 | inviteStreamInfo -> { | 500 | inviteStreamInfo -> { |
| 496 | logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString()); | 501 | logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString()); |
| 497 | - timer.cancel(); | 502 | + dynamicTask.stop(downLoadTimeOutTaskKey); |
| 498 | StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); | 503 | StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); |
| 499 | streamInfo.setStartTime(startTime); | 504 | streamInfo.setStartTime(startTime); |
| 500 | streamInfo.setEndTime(endTime); | 505 | streamInfo.setEndTime(endTime); |
| @@ -515,7 +520,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -515,7 +520,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 515 | downloadResult.setResponse(inviteStreamInfo.getResponse()); | 520 | downloadResult.setResponse(inviteStreamInfo.getResponse()); |
| 516 | hookCallBack.call(downloadResult); | 521 | hookCallBack.call(downloadResult); |
| 517 | }, event -> { | 522 | }, event -> { |
| 518 | - timer.cancel(); | 523 | + dynamicTask.stop(downLoadTimeOutTaskKey); |
| 519 | downloadResult.setCode(-1); | 524 | downloadResult.setCode(-1); |
| 520 | wvpResult.setCode(-1); | 525 | wvpResult.setCode(-1); |
| 521 | wvpResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg)); | 526 | 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,7 +194,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 194 | 194 | ||
| 195 | @Override | 195 | @Override |
| 196 | public JSONObject removeStreamProxyFromZlm(StreamProxyItem param) { | 196 | public JSONObject removeStreamProxyFromZlm(StreamProxyItem param) { |
| 197 | - if (param ==null) return null; | 197 | + if (param ==null) { |
| 198 | + return null; | ||
| 199 | + } | ||
| 198 | MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); | 200 | MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); |
| 199 | JSONObject result = zlmresTfulUtils.closeStreams(mediaServerItem, param.getApp(), param.getStream()); | 201 | JSONObject result = zlmresTfulUtils.closeStreams(mediaServerItem, param.getApp(), param.getStream()); |
| 200 | return result; | 202 | return result; |
| @@ -230,7 +232,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -230,7 +232,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 230 | StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream); | 232 | StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream); |
| 231 | if (!streamProxy.isEnable() && streamProxy != null) { | 233 | if (!streamProxy.isEnable() && streamProxy != null) { |
| 232 | JSONObject jsonObject = addStreamProxyToZlm(streamProxy); | 234 | JSONObject jsonObject = addStreamProxyToZlm(streamProxy); |
| 233 | - if (jsonObject == null) return false; | 235 | + if (jsonObject == null) { |
| 236 | + return false; | ||
| 237 | + } | ||
| 234 | if (jsonObject.getInteger("code") == 0) { | 238 | if (jsonObject.getInteger("code") == 0) { |
| 235 | result = true; | 239 | result = true; |
| 236 | streamProxy.setEnable(true); | 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,7 +66,9 @@ public class StreamPushServiceImpl implements IStreamPushService { | ||
| 66 | 66 | ||
| 67 | @Override | 67 | @Override |
| 68 | public List<StreamPushItem> handleJSON(String jsonData, MediaServerItem mediaServerItem) { | 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 | Map<String, StreamPushItem> result = new HashMap<>(); | 73 | Map<String, StreamPushItem> result = new HashMap<>(); |
| 72 | 74 | ||
| @@ -219,7 +221,9 @@ public class StreamPushServiceImpl implements IStreamPushService { | @@ -219,7 +221,9 @@ public class StreamPushServiceImpl implements IStreamPushService { | ||
| 219 | } | 221 | } |
| 220 | } | 222 | } |
| 221 | zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ | 223 | zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ |
| 222 | - if (mediaList == null) return; | 224 | + if (mediaList == null) { |
| 225 | + return; | ||
| 226 | + } | ||
| 223 | String dataStr = mediaList.getString("data"); | 227 | String dataStr = mediaList.getString("data"); |
| 224 | 228 | ||
| 225 | Integer code = mediaList.getInteger("code"); | 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,7 +34,9 @@ public class UserServiceImpl implements IUserService { | ||
| 34 | @Override | 34 | @Override |
| 35 | public int addUser(User user) { | 35 | public int addUser(User user) { |
| 36 | User userByUsername = userMapper.getUserByUsername(user.getUsername()); | 36 | User userByUsername = userMapper.getUserByUsername(user.getUsername()); |
| 37 | - if (userByUsername != null) return 0; | 37 | + if (userByUsername != null) { |
| 38 | + return 0; | ||
| 39 | + } | ||
| 38 | return userMapper.add(user); | 40 | return userMapper.add(user); |
| 39 | } | 41 | } |
| 40 | @Override | 42 | @Override |
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
| @@ -223,4 +223,11 @@ public interface IRedisCatchStorage { | @@ -223,4 +223,11 @@ public interface IRedisCatchStorage { | ||
| 223 | 223 | ||
| 224 | void sendStreamPushRequestedMsg(MessageForPushChannel messageForPushChannel); | 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,7 +103,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 103 | */ | 103 | */ |
| 104 | @Override | 104 | @Override |
| 105 | public boolean stopPlay(StreamInfo streamInfo) { | 105 | public boolean stopPlay(StreamInfo streamInfo) { |
| 106 | - if (streamInfo == null) return false; | 106 | + if (streamInfo == null) { |
| 107 | + return false; | ||
| 108 | + } | ||
| 107 | return redis.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, | 109 | return redis.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
| 108 | userSetting.getServerId(), | 110 | userSetting.getServerId(), |
| 109 | streamInfo.getStream(), | 111 | streamInfo.getStream(), |
| @@ -127,7 +129,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -127,7 +129,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 127 | @Override | 129 | @Override |
| 128 | public StreamInfo queryPlayByStreamId(String streamId) { | 130 | public StreamInfo queryPlayByStreamId(String streamId) { |
| 129 | List<Object> playLeys = redis.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId)); | 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 | return (StreamInfo)redis.get(playLeys.get(0).toString()); | 135 | return (StreamInfo)redis.get(playLeys.get(0).toString()); |
| 132 | } | 136 | } |
| 133 | 137 | ||
| @@ -137,7 +141,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -137,7 +141,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 137 | userSetting.getServerId(), | 141 | userSetting.getServerId(), |
| 138 | deviceId, | 142 | deviceId, |
| 139 | channelId)); | 143 | channelId)); |
| 140 | - if (playLeys == null || playLeys.size() == 0) return null; | 144 | + if (playLeys == null || playLeys.size() == 0) { |
| 145 | + return null; | ||
| 146 | + } | ||
| 141 | return (StreamInfo)redis.get(playLeys.get(0).toString()); | 147 | return (StreamInfo)redis.get(playLeys.get(0).toString()); |
| 142 | } | 148 | } |
| 143 | 149 | ||
| @@ -146,7 +152,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -146,7 +152,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 146 | Map<String, StreamInfo> streamInfos = new HashMap<>(); | 152 | Map<String, StreamInfo> streamInfos = new HashMap<>(); |
| 147 | // List<Object> playLeys = redis.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId)); | 153 | // List<Object> playLeys = redis.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId)); |
| 148 | List<Object> players = redis.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),deviceId)); | 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 | for (Object player : players) { | 158 | for (Object player : players) { |
| 151 | String key = (String) player; | 159 | String key = (String) player; |
| 152 | StreamInfo streamInfo = (StreamInfo) redis.get(key); | 160 | StreamInfo streamInfo = (StreamInfo) redis.get(key); |
| @@ -182,10 +190,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -182,10 +190,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 182 | deviceChannel.setDeviceId(deviceId); | 190 | deviceChannel.setDeviceId(deviceId); |
| 183 | deviceChannelMapper.update(deviceChannel); | 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 | String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, | 205 | String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, |
| 190 | userSetting.getServerId(), | 206 | userSetting.getServerId(), |
| 191 | deviceId, | 207 | deviceId, |
| @@ -210,10 +226,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -210,10 +226,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 210 | deviceChannel.setDeviceId(deviceId); | 226 | deviceChannel.setDeviceId(deviceId); |
| 211 | deviceChannelMapper.update(deviceChannel); | 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 | String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, | 241 | String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, |
| 218 | userSetting.getServerId(), | 242 | userSetting.getServerId(), |
| 219 | deviceId, | 243 | deviceId, |
| @@ -235,10 +259,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -235,10 +259,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 235 | if (stream == null && callId == null) { | 259 | if (stream == null && callId == null) { |
| 236 | return null; | 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 | String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, | 274 | String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, |
| 243 | userSetting.getServerId(), | 275 | userSetting.getServerId(), |
| 244 | deviceId, | 276 | deviceId, |
| @@ -328,10 +360,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -328,10 +360,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 328 | 360 | ||
| 329 | @Override | 361 | @Override |
| 330 | public SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId) { | 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 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId | 375 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId |
| 336 | + "_" + channelId + "_" + streamId + "_" + callId; | 376 | + "_" + channelId + "_" + streamId + "_" + callId; |
| 337 | List<Object> scan = redis.scan(key); | 377 | List<Object> scan = redis.scan(key); |
| @@ -344,7 +384,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -344,7 +384,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 344 | 384 | ||
| 345 | @Override | 385 | @Override |
| 346 | public List<SendRtpItem> querySendRTPServer(String platformGbId) { | 386 | public List<SendRtpItem> querySendRTPServer(String platformGbId) { |
| 347 | - if (platformGbId == null) platformGbId = "*"; | 387 | + if (platformGbId == null) { |
| 388 | + platformGbId = "*"; | ||
| 389 | + } | ||
| 348 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*"; | 390 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*"; |
| 349 | List<Object> queryResult = redis.scan(key); | 391 | List<Object> queryResult = redis.scan(key); |
| 350 | List<SendRtpItem> result= new ArrayList<>(); | 392 | List<SendRtpItem> result= new ArrayList<>(); |
| @@ -364,8 +406,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -364,8 +406,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 364 | */ | 406 | */ |
| 365 | @Override | 407 | @Override |
| 366 | public void deleteSendRTPServer(String platformGbId, String channelId, String callId, String streamId) { | 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 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId | 415 | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId |
| 370 | + "_" + channelId + "_" + streamId + "_" + callId; | 416 | + "_" + channelId + "_" + streamId + "_" + callId; |
| 371 | List<Object> scan = redis.scan(key); | 417 | List<Object> scan = redis.scan(key); |
| @@ -473,10 +519,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -473,10 +519,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 473 | if (stream == null && callId == null) { | 519 | if (stream == null && callId == null) { |
| 474 | return null; | 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 | String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, | 534 | String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, |
| 481 | userSetting.getServerId(), | 535 | userSetting.getServerId(), |
| 482 | deviceId, | 536 | deviceId, |
| @@ -645,4 +699,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | @@ -645,4 +699,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 645 | logger.info("[redis 报警通知] {}: {}", key, JSON.toJSON(msg)); | 699 | logger.info("[redis 报警通知] {}: {}", key, JSON.toJSON(msg)); |
| 646 | redis.convertAndSend(key, (JSONObject)JSON.toJSON(msg)); | 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,7 +460,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 460 | public synchronized boolean outline(String deviceId) { | 460 | public synchronized boolean outline(String deviceId) { |
| 461 | logger.info("更新设备离线: " + deviceId); | 461 | logger.info("更新设备离线: " + deviceId); |
| 462 | Device device = deviceMapper.getDeviceByDeviceId(deviceId); | 462 | Device device = deviceMapper.getDeviceByDeviceId(deviceId); |
| 463 | - if (device == null) return false; | 463 | + if (device == null) { |
| 464 | + return false; | ||
| 465 | + } | ||
| 464 | device.setOnline(0); | 466 | device.setOnline(0); |
| 465 | redisCatchStorage.updateDevice(device); | 467 | redisCatchStorage.updateDevice(device); |
| 466 | return deviceMapper.update(device) > 0; | 468 | return deviceMapper.update(device) > 0; |
| @@ -714,6 +716,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | @@ -714,6 +716,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 714 | * 删除指定设备的所有移动位置 | 716 | * 删除指定设备的所有移动位置 |
| 715 | * @param deviceId | 717 | * @param deviceId |
| 716 | */ | 718 | */ |
| 719 | + @Override | ||
| 717 | public int clearMobilePositionsByDeviceId(String deviceId) { | 720 | public int clearMobilePositionsByDeviceId(String deviceId) { |
| 718 | return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId); | 721 | return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId); |
| 719 | } | 722 | } |
| @@ -859,7 +862,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | @@ -859,7 +862,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 859 | 862 | ||
| 860 | @Override | 863 | @Override |
| 861 | public void updateMediaList(List<StreamPushItem> streamPushItems) { | 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 | logger.info("updateMediaList: " + streamPushItems.size()); | 868 | logger.info("updateMediaList: " + streamPushItems.size()); |
| 864 | streamPushMapper.addAll(streamPushItems); | 869 | streamPushMapper.addAll(streamPushItems); |
| 865 | // TODO 待优化 | 870 | // TODO 待优化 |
src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java
| @@ -34,7 +34,9 @@ public class SpringBeanFactory implements ApplicationContextAware { | @@ -34,7 +34,9 @@ public class SpringBeanFactory implements ApplicationContextAware { | ||
| 34 | * 获取对象 这里重写了bean方法,起主要作用 | 34 | * 获取对象 这里重写了bean方法,起主要作用 |
| 35 | */ | 35 | */ |
| 36 | public static Object getBean(String beanId) throws BeansException { | 36 | public static Object getBean(String beanId) throws BeansException { |
| 37 | - if (applicationContext == null) return null; | 37 | + if (applicationContext == null) { |
| 38 | + return null; | ||
| 39 | + } | ||
| 38 | return applicationContext.getBean(beanId); | 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,16 +85,30 @@ public class AlarmController { | ||
| 85 | @RequestParam(required = false) String startTime, | 85 | @RequestParam(required = false) String startTime, |
| 86 | @RequestParam(required = false) String endTime | 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 | try { | 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 | } catch (ParseException e) { | 112 | } catch (ParseException e) { |
| 99 | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); | 113 | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); |
| 100 | } | 114 | } |
| @@ -125,9 +139,15 @@ public class AlarmController { | @@ -125,9 +139,15 @@ public class AlarmController { | ||
| 125 | @RequestParam(required = false) String deviceIds, | 139 | @RequestParam(required = false) String deviceIds, |
| 126 | @RequestParam(required = false) String time | 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 | try { | 151 | try { |
| 132 | if (time != null) { | 152 | if (time != null) { |
| 133 | format.parse(time); | 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,7 +6,6 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | ||
| 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 7 | import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; | 7 | import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; |
| 8 | import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; | 8 | import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; |
| 9 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | ||
| 10 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; | 9 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; |
| 11 | import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; | 10 | import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; |
| 12 | import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; | 11 | import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; |
| @@ -54,9 +53,6 @@ public class DeviceQuery { | @@ -54,9 +53,6 @@ public class DeviceQuery { | ||
| 54 | 53 | ||
| 55 | @Autowired | 54 | @Autowired |
| 56 | private DeferredResultHolder resultHolder; | 55 | private DeferredResultHolder resultHolder; |
| 57 | - | ||
| 58 | - @Autowired | ||
| 59 | - private DeviceOffLineDetector offLineDetector; | ||
| 60 | 56 | ||
| 61 | @Autowired | 57 | @Autowired |
| 62 | private IDeviceService deviceService; | 58 | private IDeviceService deviceService; |
| @@ -310,9 +306,15 @@ public class DeviceQuery { | @@ -310,9 +306,15 @@ public class DeviceQuery { | ||
| 310 | 306 | ||
| 311 | if (device != null && device.getDeviceId() != null) { | 307 | if (device != null && device.getDeviceId() != null) { |
| 312 | Device deviceInStore = storager.queryVideoDevice(device.getDeviceId()); | 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 | if (device.getSubscribeCycleForCatalog() > 0) { | 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,7 +286,9 @@ public class PlatformController { | ||
| 286 | return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST); | 286 | return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST); |
| 287 | } | 287 | } |
| 288 | ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId); | 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 | commanderForPlatform.unregister(parentPlatform, (event -> { | 293 | commanderForPlatform.unregister(parentPlatform, (event -> { |
| 292 | // 清空redis缓存 | 294 | // 清空redis缓存 |
src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
| @@ -65,16 +65,26 @@ public class LogController { | @@ -65,16 +65,26 @@ public class LogController { | ||
| 65 | @RequestParam(required = false) String startTime, | 65 | @RequestParam(required = false) String startTime, |
| 66 | @RequestParam(required = false) String endTime | 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 | if (!userSetting.getLogInDatebase()) { | 77 | if (!userSetting.getLogInDatebase()) { |
| 72 | logger.warn("自动记录日志功能已关闭,查询结果可能不完整。"); | 78 | logger.warn("自动记录日志功能已关闭,查询结果可能不完整。"); |
| 73 | } | 79 | } |
| 74 | 80 | ||
| 75 | try { | 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 | } catch (ParseException e) { | 88 | } catch (ParseException e) { |
| 79 | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); | 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,9 +69,15 @@ public class StreamProxyController { | ||
| 69 | @ResponseBody | 69 | @ResponseBody |
| 70 | public WVPResult save(@RequestBody StreamProxyItem param){ | 70 | public WVPResult save(@RequestBody StreamProxyItem param){ |
| 71 | logger.info("添加代理: " + JSONObject.toJSONString(param)); | 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 | WVPResult<StreamInfo> result = streamProxyService.save(param); | 81 | WVPResult<StreamInfo> result = streamProxyService.save(param); |
| 76 | return result; | 82 | return result; |
| 77 | } | 83 | } |
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
| @@ -68,7 +68,7 @@ public class ApiStreamController { | @@ -68,7 +68,7 @@ public class ApiStreamController { | ||
| 68 | @RequestParam(required = false)String timeout | 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 | Device device = storager.queryVideoDevice(serial); | 72 | Device device = storager.queryVideoDevice(serial); |
| 73 | if (device == null ) { | 73 | if (device == null ) { |
| 74 | JSONObject result = new JSONObject(); | 74 | JSONObject result = new JSONObject(); |
web_src/index.html
| @@ -12,26 +12,7 @@ | @@ -12,26 +12,7 @@ | ||
| 12 | <script type="text/javascript" src="./static/js/jessibuca/jessibuca.js"></script> | 12 | <script type="text/javascript" src="./static/js/jessibuca/jessibuca.js"></script> |
| 13 | <script type="text/javascript" src="./static/js/EasyWasmPlayer.js"></script> | 13 | <script type="text/javascript" src="./static/js/EasyWasmPlayer.js"></script> |
| 14 | <script type="text/javascript" src="./static/js/ZLMRTCClient.js"></script> | 14 | <script type="text/javascript" src="./static/js/ZLMRTCClient.js"></script> |
| 15 | + <script type="text/javascript" src="./static/js/mapConfig.js"></script> | ||
| 15 | <div id="app"></div> | 16 | <div id="app"></div> |
| 16 | - <!-- built files will be auto injected --> | ||
| 17 | - <script> | ||
| 18 | - // map组件全局参数, 注释此内容可以关闭地图功能 | ||
| 19 | - window.mapParam = { | ||
| 20 | - // 坐标系 GCJ-02 WGS-84, | ||
| 21 | - coordinateSystem: "GCJ-02", | ||
| 22 | - // 地图瓦片地址 | ||
| 23 | - tilesUrl: "http://webrd0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8", | ||
| 24 | - // 瓦片大小 | ||
| 25 | - tileSize: 256, | ||
| 26 | - // 默认层级 | ||
| 27 | - zoom:10, | ||
| 28 | - // 默认地图中心点 | ||
| 29 | - center:[116.41020, 39.915119], | ||
| 30 | - // 地图最大层级 | ||
| 31 | - maxZoom:18, | ||
| 32 | - // 地图最小层级 | ||
| 33 | - minZoom: 3 | ||
| 34 | - } | ||
| 35 | - </script> | ||
| 36 | </body> | 17 | </body> |
| 37 | </html> | 18 | </html> |
web_src/src/components/common/jessibuca.vue
| 1 | <template> | 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 | <div class="buttons-box" id="buttonsBox"> | 3 | <div class="buttons-box" id="buttonsBox"> |
| 4 | <div class="buttons-box-left"> | 4 | <div class="buttons-box-left"> |
| 5 | <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> | 5 | <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> |
web_src/src/components/devicePosition.vue
| @@ -59,7 +59,7 @@ export default { | @@ -59,7 +59,7 @@ export default { | ||
| 59 | }, | 59 | }, |
| 60 | data() { | 60 | data() { |
| 61 | return { | 61 | return { |
| 62 | - onOff: typeof window.mapParam !== "undefined", | 62 | + onOff: typeof window.mapParam !== "undefined" && window.mapParam.enable, |
| 63 | deviceService: new DeviceService(), | 63 | deviceService: new DeviceService(), |
| 64 | layer: null, | 64 | layer: null, |
| 65 | lineLayer: null, | 65 | lineLayer: null, |
web_src/static/js/mapConfig.js
0 → 100644
| 1 | +// map组件全局参数, 注释此内容可以关闭地图功能 | ||
| 2 | +window.mapParam = { | ||
| 3 | + // 开启/关闭地图功能 | ||
| 4 | + enable: true, | ||
| 5 | + // 坐标系 GCJ-02 WGS-84, | ||
| 6 | + coordinateSystem: "GCJ-02", | ||
| 7 | + // 地图瓦片地址 | ||
| 8 | + tilesUrl: "http://webrd0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8", | ||
| 9 | + // 瓦片大小 | ||
| 10 | + tileSize: 256, | ||
| 11 | + // 默认层级 | ||
| 12 | + zoom:10, | ||
| 13 | + // 默认地图中心点 | ||
| 14 | + center:[116.41020, 39.915119], | ||
| 15 | + // 地图最大层级 | ||
| 16 | + maxZoom:18, | ||
| 17 | + // 地图最小层级 | ||
| 18 | + minZoom: 3 | ||
| 19 | +} |