Commit 88350873ee7632924cb135a450fef9f4d05c5306

Authored by 648540858
2 parents d9cfe061 f57ed350

Merge branch 'wvp-28181-2.0' into main-dev

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
#	src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
#	src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerFactory.java
#	src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
Showing 100 changed files with 1954 additions and 1854 deletions

Too many changes to show.

To preserve performance only 100 of 365 files are displayed.

doc/_content/introduction/config.md
@@ -153,7 +153,7 @@ user-settings: @@ -153,7 +153,7 @@ user-settings:
153 # 国标是否录制 153 # 国标是否录制
154 record-sip: true 154 record-sip: true
155 # 是否将日志存储进数据库 155 # 是否将日志存储进数据库
156 - logInDatebase: true 156 + logInDatabase: true
157 # 第三方匹配,用于从stream钟获取有效信息 157 # 第三方匹配,用于从stream钟获取有效信息
158 thirdPartyGBIdReg: [\s\S]* 158 thirdPartyGBIdReg: [\s\S]*
159 ``` 159 ```
src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
1 -package com.genersoft.iot.vmp;  
2 -  
3 -import com.genersoft.iot.vmp.utils.GitUtil;  
4 -import com.genersoft.iot.vmp.utils.SpringBeanFactory;  
5 -import org.slf4j.Logger;  
6 -import org.slf4j.LoggerFactory;  
7 -import org.springframework.boot.SpringApplication;  
8 -import org.springframework.boot.autoconfigure.SpringBootApplication;  
9 -import org.springframework.boot.builder.SpringApplicationBuilder;  
10 -import org.springframework.boot.web.servlet.ServletComponentScan;  
11 -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;  
12 -import org.springframework.context.ConfigurableApplicationContext;  
13 -import org.springframework.scheduling.annotation.EnableScheduling;  
14 -  
15 -import javax.servlet.ServletContext;  
16 -import javax.servlet.ServletException;  
17 -import javax.servlet.SessionCookieConfig;  
18 -import javax.servlet.SessionTrackingMode;  
19 -import java.util.Collections;  
20 -  
21 -/**  
22 - * 启动类  
23 - */  
24 -@ServletComponentScan("com.genersoft.iot.vmp.conf")  
25 -@SpringBootApplication  
26 -@EnableScheduling  
27 -public class VManageBootstrap extends SpringBootServletInitializer {  
28 -  
29 - private final static Logger logger = LoggerFactory.getLogger(VManageBootstrap.class);  
30 -  
31 - private static String[] args;  
32 - private static ConfigurableApplicationContext context;  
33 - public static void main(String[] args) {  
34 - VManageBootstrap.args = args;  
35 - VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);  
36 - GitUtil gitUtil1 = SpringBeanFactory.getBean("gitUtil");  
37 - logger.info("构建版本: {}", gitUtil1.getBuildVersion());  
38 - logger.info("构建时间: {}", gitUtil1.getBuildDate());  
39 - logger.info("GIT最后提交时间: {}", gitUtil1.getCommitTime());  
40 - }  
41 - // 项目重启  
42 - public static void restart() {  
43 - context.close();  
44 - VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);  
45 - }  
46 -  
47 - @Override  
48 - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {  
49 - return application.sources(VManageBootstrap.class);  
50 - }  
51 -  
52 - @Override  
53 - public void onStartup(ServletContext servletContext) throws ServletException {  
54 - super.onStartup(servletContext);  
55 -  
56 - servletContext.setSessionTrackingModes(  
57 - Collections.singleton(SessionTrackingMode.COOKIE)  
58 - );  
59 - SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();  
60 - sessionCookieConfig.setHttpOnly(true);  
61 -  
62 - }  
63 -} 1 +package com.genersoft.iot.vmp;
  2 +
  3 +import com.genersoft.iot.vmp.utils.GitUtil;
  4 +import com.genersoft.iot.vmp.utils.SpringBeanFactory;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +import org.springframework.boot.SpringApplication;
  8 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  9 +import org.springframework.boot.builder.SpringApplicationBuilder;
  10 +import org.springframework.boot.web.servlet.ServletComponentScan;
  11 +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  12 +import org.springframework.context.ConfigurableApplicationContext;
  13 +import org.springframework.scheduling.annotation.EnableScheduling;
  14 +
  15 +import javax.servlet.ServletContext;
  16 +import javax.servlet.ServletException;
  17 +import javax.servlet.SessionCookieConfig;
  18 +import javax.servlet.SessionTrackingMode;
  19 +import java.util.Collections;
  20 +
  21 +/**
  22 + * 启动类
  23 + */
  24 +@ServletComponentScan("com.genersoft.iot.vmp.conf")
  25 +@SpringBootApplication
  26 +@EnableScheduling
  27 +public class VManageBootstrap extends SpringBootServletInitializer {
  28 +
  29 + private final static Logger logger = LoggerFactory.getLogger(VManageBootstrap.class);
  30 +
  31 + private static String[] args;
  32 + private static ConfigurableApplicationContext context;
  33 + public static void main(String[] args) {
  34 + VManageBootstrap.args = args;
  35 + VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
  36 + GitUtil gitUtil1 = SpringBeanFactory.getBean("gitUtil");
  37 + logger.info("构建版本: {}", gitUtil1.getBuildVersion());
  38 + logger.info("构建时间: {}", gitUtil1.getBuildDate());
  39 + logger.info("GIT最后提交时间: {}", gitUtil1.getCommitTime());
  40 + }
  41 + // 项目重启
  42 + public static void restart() {
  43 + context.close();
  44 + VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
  45 + }
  46 +
  47 + @Override
  48 + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  49 + return application.sources(VManageBootstrap.class);
  50 + }
  51 +
  52 + @Override
  53 + public void onStartup(ServletContext servletContext) throws ServletException {
  54 + super.onStartup(servletContext);
  55 +
  56 + servletContext.setSessionTrackingModes(
  57 + Collections.singleton(SessionTrackingMode.COOKIE)
  58 + );
  59 + SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
  60 + sessionCookieConfig.setHttpOnly(true);
  61 +
  62 + }
  63 +}
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
1 -package com.genersoft.iot.vmp.common;  
2 -  
3 -/**  
4 - * @description: 定义常量  
5 - * @author: swwheihei  
6 - * @date: 2019年5月30日 下午3:04:04  
7 - *  
8 - */  
9 -public class VideoManagerConstants {  
10 -  
11 - public static final String WVP_SERVER_PREFIX = "VMP_SIGNALLING_SERVER_INFO_";  
12 -  
13 - public static final String WVP_SERVER_STREAM_PREFIX = "VMP_SIGNALLING_STREAM_";  
14 -  
15 - public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_";  
16 -  
17 - public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS_";  
18 -  
19 - public static final String DEVICE_PREFIX = "VMP_DEVICE_";  
20 -  
21 - // 设备同步完成  
22 - public static final String DEVICE_SYNC_PREFIX = "VMP_DEVICE_SYNC_";  
23 -  
24 - public static final String CACHEKEY_PREFIX = "VMP_CHANNEL_";  
25 -  
26 - public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_";  
27 -  
28 - // TODO 此处多了一个_,暂不修改  
29 - public static final String INVITE_PREFIX = "VMP_INVITE";  
30 - public static final String PLAYER_PREFIX = "VMP_INVITE_PLAY_";  
31 - public static final String PLAY_BLACK_PREFIX = "VMP_INVITE_PLAYBACK_";  
32 - public static final String DOWNLOAD_PREFIX = "VMP_INVITE_DOWNLOAD_";  
33 -  
34 - public static final String PLATFORM_KEEPALIVE_PREFIX = "VMP_PLATFORM_KEEPALIVE_";  
35 -  
36 - public static final String PLATFORM_CATCH_PREFIX = "VMP_PLATFORM_CATCH_";  
37 -  
38 - public static final String PLATFORM_REGISTER_PREFIX = "VMP_PLATFORM_REGISTER_";  
39 -  
40 - public static final String PLATFORM_REGISTER_INFO_PREFIX = "VMP_PLATFORM_REGISTER_INFO_";  
41 -  
42 - public static final String PLATFORM_SEND_RTP_INFO_PREFIX = "VMP_PLATFORM_SEND_RTP_INFO_";  
43 -  
44 - public static final String EVENT_ONLINE_REGISTER = "1";  
45 -  
46 - public static final String EVENT_ONLINE_MESSAGE = "3";  
47 -  
48 - public static final String EVENT_OUTLINE_UNREGISTER = "1";  
49 -  
50 - public static final String EVENT_OUTLINE_TIMEOUT = "2";  
51 -  
52 - public static final String MEDIA_SSRC_USED_PREFIX = "VMP_MEDIA_USED_SSRC_";  
53 -  
54 - public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_MEDIA_TRANSACTION_";  
55 -  
56 - public static final String MEDIA_STREAM_AUTHORITY = "MEDIA_STREAM_AUTHORITY_";  
57 -  
58 - public static final String SIP_CSEQ_PREFIX = "VMP_SIP_CSEQ_";  
59 -  
60 - public static final String SIP_SN_PREFIX = "VMP_SIP_SN_";  
61 -  
62 - public static final String SIP_SUBSCRIBE_PREFIX = "VMP_SIP_SUBSCRIBE_";  
63 -  
64 - public static final String SYSTEM_INFO_CPU_PREFIX = "VMP_SYSTEM_INFO_CPU_";  
65 -  
66 - public static final String SYSTEM_INFO_MEM_PREFIX = "VMP_SYSTEM_INFO_MEM_";  
67 -  
68 - public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_";  
69 -  
70 - public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_";  
71 - public static final String BROADCAST_WAITE_INVITE = "task_broadcast_waite_invite_";  
72 -  
73 - public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";  
74 -  
75 -  
76 -  
77 -  
78 - //************************** redis 消息*********************************  
79 -  
80 - /**  
81 - * 流变化的通知  
82 - */  
83 - public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";  
84 -  
85 - /**  
86 - * 接收推流设备的GPS变化通知  
87 - */  
88 - public static final String VM_MSG_GPS = "VM_MSG_GPS";  
89 -  
90 - /**  
91 - * 接收推流设备的GPS变化通知  
92 - */  
93 - public static final String VM_MSG_PUSH_STREAM_STATUS_CHANGE = "VM_MSG_PUSH_STREAM_STATUS_CHANGE";  
94 - /**  
95 - * 接收推流设备列表更新变化通知  
96 - */  
97 - public static final String VM_MSG_PUSH_STREAM_LIST_CHANGE = "VM_MSG_PUSH_STREAM_LIST_CHANGE";  
98 -  
99 - /**  
100 - * redis 消息通知设备推流到平台  
101 - */  
102 - public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED";  
103 -  
104 - /**  
105 - * redis 消息通知上级平台开始观看流  
106 - */  
107 - public static final String VM_MSG_STREAM_START_PLAY_NOTIFY = "VM_MSG_STREAM_START_PLAY_NOTIFY";  
108 -  
109 - /**  
110 - * redis 消息通知上级平台停止观看流  
111 - */  
112 - public static final String VM_MSG_STREAM_STOP_PLAY_NOTIFY = "VM_MSG_STREAM_STOP_PLAY_NOTIFY";  
113 -  
114 - /**  
115 - * redis 消息接收关闭一个推流  
116 - */  
117 - public static final String VM_MSG_STREAM_PUSH_CLOSE_REQUESTED = "VM_MSG_STREAM_PUSH_CLOSE_REQUESTED";  
118 -  
119 -  
120 - /**  
121 - * redis 消息通知平台通知设备推流结果  
122 - */  
123 - public static final String VM_MSG_STREAM_PUSH_RESPONSE = "VM_MSG_STREAM_PUSH_RESPONSE";  
124 -  
125 - /**  
126 - * redis 通知平台关闭推流  
127 - */  
128 - public static final String VM_MSG_STREAM_PUSH_CLOSE = "VM_MSG_STREAM_PUSH_CLOSE";  
129 -  
130 - /**  
131 - * redis 消息请求所有的在线通道  
132 - */  
133 - public static final String VM_MSG_GET_ALL_ONLINE_REQUESTED = "VM_MSG_GET_ALL_ONLINE_REQUESTED";  
134 -  
135 - /**  
136 - * 移动位置订阅通知  
137 - */  
138 - public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition";  
139 -  
140 - /**  
141 - * 报警订阅的通知(收到报警向redis发出通知)  
142 - */  
143 - public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm";  
144 -  
145 -  
146 - /**  
147 - * 报警通知的发送 (收到redis发出的通知,转发给其他平台)  
148 - */  
149 - public static final String VM_MSG_SUBSCRIBE_ALARM_RECEIVE= "alarm_receive";  
150 -  
151 - /**  
152 - * 设备状态订阅的通知  
153 - */  
154 - public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device";  
155 -  
156 -  
157 - //************************** 第三方 ****************************************  
158 -  
159 - public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";  
160 - public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_";  
161 - public static final String WVP_OTHER_SEND_RTP_INFO = "VMP_OTHER_SEND_RTP_INFO_";  
162 - public static final String WVP_OTHER_RECEIVE_RTP_INFO = "VMP_OTHER_RECEIVE_RTP_INFO_";  
163 -  
164 - /**  
165 - * Redis Const  
166 - * 设备录像信息结果前缀  
167 - */  
168 - public static final String REDIS_RECORD_INFO_RES_PRE = "GB_RECORD_INFO_RES_";  
169 - /**  
170 - * Redis Const  
171 - * 设备录像信息结果前缀  
172 - */  
173 - public static final String REDIS_RECORD_INFO_RES_COUNT_PRE = "GB_RECORD_INFO_RES_COUNT:";  
174 -  
175 -} 1 +package com.genersoft.iot.vmp.common;
  2 +
  3 +/**
  4 + * @description: 定义常量
  5 + * @author: swwheihei
  6 + * @date: 2019年5月30日 下午3:04:04
  7 + *
  8 + */
  9 +public class VideoManagerConstants {
  10 +
  11 + public static final String WVP_SERVER_PREFIX = "VMP_SIGNALLING_SERVER_INFO_";
  12 +
  13 + public static final String WVP_SERVER_STREAM_PREFIX = "VMP_SIGNALLING_STREAM_";
  14 +
  15 + public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_";
  16 +
  17 + public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS_";
  18 +
  19 + public static final String DEVICE_PREFIX = "VMP_DEVICE_";
  20 +
  21 + // 设备同步完成
  22 + public static final String DEVICE_SYNC_PREFIX = "VMP_DEVICE_SYNC_";
  23 +
  24 + public static final String CACHEKEY_PREFIX = "VMP_CHANNEL_";
  25 +
  26 + public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_";
  27 +
  28 + // TODO 此处多了一个_,暂不修改
  29 + public static final String INVITE_PREFIX = "VMP_INVITE";
  30 + public static final String PLAYER_PREFIX = "VMP_INVITE_PLAY_";
  31 + public static final String PLAY_BLACK_PREFIX = "VMP_INVITE_PLAYBACK_";
  32 + public static final String DOWNLOAD_PREFIX = "VMP_INVITE_DOWNLOAD_";
  33 +
  34 + public static final String PLATFORM_KEEPALIVE_PREFIX = "VMP_PLATFORM_KEEPALIVE_";
  35 +
  36 + public static final String PLATFORM_CATCH_PREFIX = "VMP_PLATFORM_CATCH_";
  37 +
  38 + public static final String PLATFORM_REGISTER_PREFIX = "VMP_PLATFORM_REGISTER_";
  39 +
  40 + public static final String PLATFORM_REGISTER_INFO_PREFIX = "VMP_PLATFORM_REGISTER_INFO_";
  41 +
  42 + public static final String PLATFORM_SEND_RTP_INFO_PREFIX = "VMP_PLATFORM_SEND_RTP_INFO_";
  43 +
  44 + public static final String EVENT_ONLINE_REGISTER = "1";
  45 +
  46 + public static final String EVENT_ONLINE_MESSAGE = "3";
  47 +
  48 + public static final String EVENT_OUTLINE_UNREGISTER = "1";
  49 +
  50 + public static final String EVENT_OUTLINE_TIMEOUT = "2";
  51 +
  52 + public static final String MEDIA_SSRC_USED_PREFIX = "VMP_MEDIA_USED_SSRC_";
  53 +
  54 + public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_MEDIA_TRANSACTION_";
  55 +
  56 + public static final String MEDIA_STREAM_AUTHORITY = "MEDIA_STREAM_AUTHORITY_";
  57 +
  58 + public static final String SIP_CSEQ_PREFIX = "VMP_SIP_CSEQ_";
  59 +
  60 + public static final String SIP_SN_PREFIX = "VMP_SIP_SN_";
  61 +
  62 + public static final String SIP_SUBSCRIBE_PREFIX = "VMP_SIP_SUBSCRIBE_";
  63 +
  64 + public static final String SYSTEM_INFO_CPU_PREFIX = "VMP_SYSTEM_INFO_CPU_";
  65 +
  66 + public static final String SYSTEM_INFO_MEM_PREFIX = "VMP_SYSTEM_INFO_MEM_";
  67 +
  68 + public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_";
  69 +
  70 + public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_";
  71 + public static final String BROADCAST_WAITE_INVITE = "task_broadcast_waite_invite_";
  72 +
  73 + public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";
  74 +
  75 +
  76 +
  77 +
  78 + //************************** redis 消息*********************************
  79 +
  80 + /**
  81 + * 流变化的通知
  82 + */
  83 + public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";
  84 +
  85 + /**
  86 + * 接收推流设备的GPS变化通知
  87 + */
  88 + public static final String VM_MSG_GPS = "VM_MSG_GPS";
  89 +
  90 + /**
  91 + * 接收推流设备的GPS变化通知
  92 + */
  93 + public static final String VM_MSG_PUSH_STREAM_STATUS_CHANGE = "VM_MSG_PUSH_STREAM_STATUS_CHANGE";
  94 + /**
  95 + * 接收推流设备列表更新变化通知
  96 + */
  97 + public static final String VM_MSG_PUSH_STREAM_LIST_CHANGE = "VM_MSG_PUSH_STREAM_LIST_CHANGE";
  98 +
  99 + /**
  100 + * redis 消息通知设备推流到平台
  101 + */
  102 + public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED";
  103 +
  104 + /**
  105 + * redis 消息通知上级平台开始观看流
  106 + */
  107 + public static final String VM_MSG_STREAM_START_PLAY_NOTIFY = "VM_MSG_STREAM_START_PLAY_NOTIFY";
  108 +
  109 + /**
  110 + * redis 消息通知上级平台停止观看流
  111 + */
  112 + public static final String VM_MSG_STREAM_STOP_PLAY_NOTIFY = "VM_MSG_STREAM_STOP_PLAY_NOTIFY";
  113 +
  114 + /**
  115 + * redis 消息接收关闭一个推流
  116 + */
  117 + public static final String VM_MSG_STREAM_PUSH_CLOSE_REQUESTED = "VM_MSG_STREAM_PUSH_CLOSE_REQUESTED";
  118 +
  119 +
  120 + /**
  121 + * redis 消息通知平台通知设备推流结果
  122 + */
  123 + public static final String VM_MSG_STREAM_PUSH_RESPONSE = "VM_MSG_STREAM_PUSH_RESPONSE";
  124 +
  125 + /**
  126 + * redis 通知平台关闭推流
  127 + */
  128 + public static final String VM_MSG_STREAM_PUSH_CLOSE = "VM_MSG_STREAM_PUSH_CLOSE";
  129 +
  130 + /**
  131 + * redis 消息请求所有的在线通道
  132 + */
  133 + public static final String VM_MSG_GET_ALL_ONLINE_REQUESTED = "VM_MSG_GET_ALL_ONLINE_REQUESTED";
  134 +
  135 + /**
  136 + * 移动位置订阅通知
  137 + */
  138 + public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition";
  139 +
  140 + /**
  141 + * 报警订阅的通知(收到报警向redis发出通知)
  142 + */
  143 + public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm";
  144 +
  145 +
  146 + /**
  147 + * 报警通知的发送 (收到redis发出的通知,转发给其他平台)
  148 + */
  149 + public static final String VM_MSG_SUBSCRIBE_ALARM_RECEIVE= "alarm_receive";
  150 +
  151 + /**
  152 + * 设备状态订阅的通知
  153 + */
  154 + public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device";
  155 +
  156 +
  157 + //************************** 第三方 ****************************************
  158 +
  159 + public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";
  160 + public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_";
  161 + public static final String WVP_OTHER_SEND_RTP_INFO = "VMP_OTHER_SEND_RTP_INFO_";
  162 + public static final String WVP_OTHER_SEND_PS_INFO = "VMP_OTHER_SEND_PS_INFO_";
  163 + public static final String WVP_OTHER_RECEIVE_RTP_INFO = "VMP_OTHER_RECEIVE_RTP_INFO_";
  164 + public static final String WVP_OTHER_RECEIVE_PS_INFO = "VMP_OTHER_RECEIVE_PS_INFO_";
  165 +
  166 + /**
  167 + * Redis Const
  168 + * 设备录像信息结果前缀
  169 + */
  170 + public static final String REDIS_RECORD_INFO_RES_PRE = "GB_RECORD_INFO_RES_";
  171 + /**
  172 + * Redis Const
  173 + * 设备录像信息结果前缀
  174 + */
  175 + public static final String REDIS_RECORD_INFO_RES_COUNT_PRE = "GB_RECORD_INFO_RES_COUNT:";
  176 +
  177 +}
src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java
@@ -51,7 +51,7 @@ public class ApiAccessFilter extends OncePerRequestFilter { @@ -51,7 +51,7 @@ public class ApiAccessFilter extends OncePerRequestFilter {
51 51
52 filterChain.doFilter(servletRequest, servletResponse); 52 filterChain.doFilter(servletRequest, servletResponse);
53 53
54 - if (uriName != null && userSetting != null && userSetting.getLogInDatebase() != null && userSetting.getLogInDatebase()) { 54 + if (uriName != null && userSetting != null && userSetting.getLogInDatabase() != null && userSetting.getLogInDatabase()) {
55 55
56 LogDto logDto = new LogDto(); 56 LogDto logDto = new LogDto();
57 logDto.setName(uriName); 57 logDto.setName(uriName);
src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java
@@ -12,7 +12,10 @@ import org.springframework.core.annotation.Order; @@ -12,7 +12,10 @@ import org.springframework.core.annotation.Order;
12 import org.springframework.core.io.ClassPathResource; 12 import org.springframework.core.io.ClassPathResource;
13 import org.springframework.util.ObjectUtils; 13 import org.springframework.util.ObjectUtils;
14 14
15 -import java.io.*; 15 +import java.io.BufferedReader;
  16 +import java.io.File;
  17 +import java.io.InputStream;
  18 +import java.io.InputStreamReader;
16 import java.nio.file.Files; 19 import java.nio.file.Files;
17 import java.util.Map; 20 import java.util.Map;
18 21
src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
@@ -111,7 +111,7 @@ public class DynamicTask { @@ -111,7 +111,7 @@ public class DynamicTask {
111 } 111 }
112 boolean result = false; 112 boolean result = false;
113 if (!ObjectUtils.isEmpty(futureMap.get(key)) && !futureMap.get(key).isCancelled() && !futureMap.get(key).isDone()) { 113 if (!ObjectUtils.isEmpty(futureMap.get(key)) && !futureMap.get(key).isCancelled() && !futureMap.get(key).isDone()) {
114 - result = futureMap.get(key).cancel(true); 114 + result = futureMap.get(key).cancel(false);
115 futureMap.remove(key); 115 futureMap.remove(key);
116 runnableMap.remove(key); 116 runnableMap.remove(key);
117 } 117 }
@@ -143,7 +143,8 @@ public class DynamicTask { @@ -143,7 +143,8 @@ public class DynamicTask {
143 public void execute(){ 143 public void execute(){
144 if (futureMap.size() > 0) { 144 if (futureMap.size() > 0) {
145 for (String key : futureMap.keySet()) { 145 for (String key : futureMap.keySet()) {
146 - if (futureMap.get(key).isDone() || futureMap.get(key).isCancelled()) { 146 + ScheduledFuture<?> future = futureMap.get(key);
  147 + if (future.isDone() || future.isCancelled()) {
147 futureMap.remove(key); 148 futureMap.remove(key);
148 runnableMap.remove(key); 149 runnableMap.remove(key);
149 } 150 }
src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
@@ -18,6 +18,7 @@ import org.springframework.util.ObjectUtils; @@ -18,6 +18,7 @@ import org.springframework.util.ObjectUtils;
18 18
19 import javax.servlet.ServletException; 19 import javax.servlet.ServletException;
20 import javax.servlet.http.HttpServletRequest; 20 import javax.servlet.http.HttpServletRequest;
  21 +import javax.servlet.http.HttpServletResponse;
21 import java.io.IOException; 22 import java.io.IOException;
22 import java.net.ConnectException; 23 import java.net.ConnectException;
23 24
@@ -64,6 +65,18 @@ public class ProxyServletConfig { @@ -64,6 +65,18 @@ public class ProxyServletConfig {
64 return queryStr; 65 return queryStr;
65 } 66 }
66 67
  68 +
  69 + @Override
  70 + protected HttpResponse doExecute(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
  71 + HttpRequest proxyRequest) throws IOException {
  72 + HttpResponse response = super.doExecute(servletRequest, servletResponse, proxyRequest);
  73 + response.removeHeaders("Access-Control-Allow-Origin");
  74 + response.setHeader("Access-Control-Allow-Credentials","true");
  75 + response.removeHeaders("Access-Control-Allow-Credentials");
  76 +
  77 + return response;
  78 + }
  79 +
67 /** 80 /**
68 * 异常处理 81 * 异常处理
69 */ 82 */
@@ -181,6 +194,18 @@ public class ProxyServletConfig { @@ -181,6 +194,18 @@ public class ProxyServletConfig {
181 return queryStr; 194 return queryStr;
182 } 195 }
183 196
  197 +
  198 + @Override
  199 + protected HttpResponse doExecute(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
  200 + HttpRequest proxyRequest) throws IOException {
  201 + HttpResponse response = super.doExecute(servletRequest, servletResponse, proxyRequest);
  202 + String origin = servletRequest.getHeader("origin");
  203 + response.setHeader("Access-Control-Allow-Origin",origin);
  204 + response.setHeader("Access-Control-Allow-Credentials","true");
  205 +
  206 + return response;
  207 + }
  208 +
184 /** 209 /**
185 * 异常处理 210 * 异常处理
186 */ 211 */
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
@@ -4,8 +4,11 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; @@ -4,8 +4,11 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; 4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
5 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; 5 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
6 import com.genersoft.iot.vmp.service.IPlatformService; 6 import com.genersoft.iot.vmp.service.IPlatformService;
  7 +import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl;
7 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 8 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
8 import com.genersoft.iot.vmp.storager.IVideoManagerStorage; 9 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.boot.CommandLineRunner; 13 import org.springframework.boot.CommandLineRunner;
11 import org.springframework.core.annotation.Order; 14 import org.springframework.core.annotation.Order;
@@ -33,6 +36,7 @@ public class SipPlatformRunner implements CommandLineRunner { @@ -33,6 +36,7 @@ public class SipPlatformRunner implements CommandLineRunner {
33 @Autowired 36 @Autowired
34 private ISIPCommanderForPlatform sipCommanderForPlatform; 37 private ISIPCommanderForPlatform sipCommanderForPlatform;
35 38
  39 + private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class);
36 40
37 @Override 41 @Override
38 public void run(String... args) throws Exception { 42 public void run(String... args) throws Exception {
@@ -50,9 +54,15 @@ public class SipPlatformRunner implements CommandLineRunner { @@ -50,9 +54,15 @@ public class SipPlatformRunner implements CommandLineRunner {
50 redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); 54 redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
51 if (parentPlatformCatchOld != null) { 55 if (parentPlatformCatchOld != null) {
52 // 取消订阅 56 // 取消订阅
53 - sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{  
54 - platformService.login(parentPlatform);  
55 - }); 57 + try {
  58 + sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{
  59 + platformService.login(parentPlatform);
  60 + });
  61 + } catch (Exception e) {
  62 + logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
  63 + platformService.offline(parentPlatform, true);
  64 + continue;
  65 + }
56 } 66 }
57 67
58 // 设置所有平台离线 68 // 设置所有平台离线
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
@@ -31,7 +31,7 @@ public class UserSetting { @@ -31,7 +31,7 @@ public class UserSetting {
31 31
32 private Boolean recordSip = Boolean.TRUE; 32 private Boolean recordSip = Boolean.TRUE;
33 33
34 - private Boolean logInDatebase = Boolean.TRUE; 34 + private Boolean logInDatabase = Boolean.TRUE;
35 35
36 private Boolean usePushingAsStatus = Boolean.FALSE; 36 private Boolean usePushingAsStatus = Boolean.FALSE;
37 37
@@ -134,12 +134,12 @@ public class UserSetting { @@ -134,12 +134,12 @@ public class UserSetting {
134 this.interfaceAuthenticationExcludes = interfaceAuthenticationExcludes; 134 this.interfaceAuthenticationExcludes = interfaceAuthenticationExcludes;
135 } 135 }
136 136
137 - public Boolean getLogInDatebase() {  
138 - return logInDatebase; 137 + public Boolean getLogInDatabase() {
  138 + return logInDatabase;
139 } 139 }
140 140
141 - public void setLogInDatebase(Boolean logInDatebase) {  
142 - this.logInDatebase = logInDatebase; 141 + public void setLogInDatabase(Boolean logInDatabase) {
  142 + this.logInDatabase = logInDatabase;
143 } 143 }
144 144
145 public String getServerId() { 145 public String getServerId() {
src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java
1 package com.genersoft.iot.vmp.conf.security; 1 package com.genersoft.iot.vmp.conf.security;
2 2
3 import com.genersoft.iot.vmp.conf.security.dto.JwtUser; 3 import com.genersoft.iot.vmp.conf.security.dto.JwtUser;
4 -import org.jose4j.json.JsonUtil; 4 +import com.genersoft.iot.vmp.service.IUserService;
  5 +import com.genersoft.iot.vmp.storager.dao.dto.User;
5 import org.jose4j.jwk.RsaJsonWebKey; 6 import org.jose4j.jwk.RsaJsonWebKey;
  7 +import org.jose4j.jwk.RsaJwkGenerator;
6 import org.jose4j.jws.AlgorithmIdentifiers; 8 import org.jose4j.jws.AlgorithmIdentifiers;
7 import org.jose4j.jws.JsonWebSignature; 9 import org.jose4j.jws.JsonWebSignature;
8 import org.jose4j.jwt.JwtClaims; 10 import org.jose4j.jwt.JwtClaims;
@@ -14,45 +16,69 @@ import org.jose4j.jwt.consumer.JwtConsumerBuilder; @@ -14,45 +16,69 @@ import org.jose4j.jwt.consumer.JwtConsumerBuilder;
14 import org.jose4j.lang.JoseException; 16 import org.jose4j.lang.JoseException;
15 import org.slf4j.Logger; 17 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory; 18 import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.InitializingBean;
  20 +import org.springframework.stereotype.Component;
17 21
18 -import java.security.PrivateKey; 22 +import javax.annotation.Resource;
19 import java.time.LocalDateTime; 23 import java.time.LocalDateTime;
20 import java.time.ZoneOffset; 24 import java.time.ZoneOffset;
21 25
22 -public class JwtUtils { 26 +@Component
  27 +public class JwtUtils implements InitializingBean {
23 28
24 private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class); 29 private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class);
25 30
26 private static final String HEADER = "access-token"; 31 private static final String HEADER = "access-token";
27 - private static final String AUDIENCE = "Audience";  
28 32
29 - private static final long EXPIRED_THRESHOLD = 10 * 60; 33 + private static final String AUDIENCE = "Audience";
30 34
31 private static final String keyId = "3e79646c4dbc408383a9eed09f2b85ae"; 35 private static final String keyId = "3e79646c4dbc408383a9eed09f2b85ae";
32 - private static final String privateKeyStr = "{\"kty\":\"RSA\",\"kid\":\"3e79646c4dbc408383a9eed09f2b85ae\",\"alg\":\"RS256\",\"n\":\"gndmVdiOTSJ5et2HIeTM5f1m61x5ojLUi5HDfvr-jRrESQ5kbKuySGHVwR4QhwinpY1wQqBnwc80tx7cb_6SSqsTOoGln6T_l3k2Pb54ClVnGWiW_u1kmX78V2TZOsVmZmwtdZCMi-2zWIyAdIEXE-gncIehoAgEoq2VAhaCURbJWro_EwzzQwNmCTkDodLAx4npXRd_qSu0Ayp0txym9OFovBXBULRvk4DPiy3i_bPUmCDxzC46pTtFOe9p82uybTehZfULZtXXqRm85FL9n5zkrsTllPNAyEGhgb0RK9sE5nK1m_wNNysDyfLC4EFf1VXTrKm14XNVjc2vqLb7Mw\",\"e\":\"AQAB\",\"d\":\"ed7U_k3rJ4yTk70JtRSIfjKGiEb67BO1TabcymnljKO7RU8nage84zZYuSu_XpQsHk6P1f0Gzxkicghm_Er-FrfVn2pp70Xu52z3yRd6BJUgWLDFk97ngScIyw5OiULKU9SrZk2frDpftNCSUcIgb50F8m0QAnBa_CdPsQKbuuhLv8V8tBAV7F_lAwvSBgu56wRo3hPz5dWH8YeXM7XBfQ9viFMNEKd21sP_j5C7ueUnXT66nBxe3ZJEU3iuMYM6D6dB_KW2GfZC6WmTgvGhhxJD0h7aYmfjkD99MDleB7SkpbvoODOqiQ5Epb7Nyh6kv5u4KUv2CJYtATLZkUeMkQ\",\"p\":\"uBUjWPWtlGksmOqsqCNWksfqJvMcnP_8TDYN7e4-WnHL4N-9HjRuPDnp6kHvCIEi9SEfxm7gNxlRcWegvNQr3IZCz7TnCTexXc5NOklB9OavWFla6u-s3Thn6Tz45-EUjpJr0VJMxhO-KxGmuTwUXBBp4vN6K2qV6rQNFmgkWzk\",\"q\":\"tW_i7cCec56bHkhITL_79dXHz_PLC_f7xlynmlZJGU_d6mqOKmLBNBbTMLnYW8uAFiFzWxDeDHh1o5uF0mSQR-Z1Fg35OftnpbWpy0Cbc2la5WgXQjOwtG1eLYIY2BD3-wQ1VYDBCvowr4FDi-sngxwLqvwmrJ0xjhi99O-Gzcs\",\"dp\":\"q1d5jE85Hz_6M-eTh_lEluEf0NtPEc-vvhw-QO4V-cecNpbrCBdTWBmr4dE3NdpFeJc5ZVFEv-SACyei1MBEh0ItI_pFZi4BmMfy2ELh8ptaMMkTOESYyVy8U7veDq9RnBcr5i1Nqr0rsBkA77-9T6gzdvycBZdzLYAkAmwzEvk\",\"dq\":\"q29A2K08Crs-jmp2Bi8Q_8QzvIX6wSBbwZ4ir24AO-5_HNP56IrPS0yV2GCB0pqCOGb6_Hz_koDvhtuYoqdqvMVAtMoXR3YJBUaVXPt65p4RyNmFwIPe31zHs_BNUTsXVRMw4c16mci03-Af1sEm4HdLfxAp6sfM3xr5wcnhcek\",\"qi\":\"rHPgVTyHUHuYzcxfouyBfb1XAY8nshwn0ddo81o1BccD4Z7zo5It6SefDHjxCAbcmbiCcXBSooLcY-NF5FMv3fg19UE21VyLQltHcVjRRp2tRs4OHcM8yaXIU2x6N6Z6BP2tOksHb9MOBY1wAQzFOAKg_G4Sxev6-_6ud6RISuc\"}";  
33 - private static final String publicKeyStr = "{\"kty\":\"RSA\",\"kid\":\"3e79646c4dbc408383a9eed09f2b85ae\",\"alg\":\"RS256\",\"n\":\"gndmVdiOTSJ5et2HIeTM5f1m61x5ojLUi5HDfvr-jRrESQ5kbKuySGHVwR4QhwinpY1wQqBnwc80tx7cb_6SSqsTOoGln6T_l3k2Pb54ClVnGWiW_u1kmX78V2TZOsVmZmwtdZCMi-2zWIyAdIEXE-gncIehoAgEoq2VAhaCURbJWro_EwzzQwNmCTkDodLAx4npXRd_qSu0Ayp0txym9OFovBXBULRvk4DPiy3i_bPUmCDxzC46pTtFOe9p82uybTehZfULZtXXqRm85FL9n5zkrsTllPNAyEGhgb0RK9sE5nK1m_wNNysDyfLC4EFf1VXTrKm14XNVjc2vqLb7Mw\",\"e\":\"AQAB\"}";  
34 36
35 /** 37 /**
36 * token过期时间(分钟) 38 * token过期时间(分钟)
37 */ 39 */
38 - public static final long expirationTime = 30; 40 + public static final long expirationTime = 30 * 24 * 60;
  41 +
  42 + private static RsaJsonWebKey rsaJsonWebKey;
39 43
40 - public static String createToken(String username, String password, Integer roleId) { 44 + private static IUserService userService;
  45 +
  46 + @Resource
  47 + public void setUserService(IUserService userService) {
  48 + JwtUtils.userService = userService;
  49 + }
  50 +
  51 + @Override
  52 + public void afterPropertiesSet() {
41 try { 53 try {
42 - /** 54 + rsaJsonWebKey = generateRsaJsonWebKey();
  55 + } catch (JoseException e) {
  56 + logger.error("生成RsaJsonWebKey报错。", e);
  57 + }
  58 + }
  59 +
  60 + /**
  61 + * 创建密钥对
  62 + * @throws JoseException JoseException
  63 + */
  64 + private RsaJsonWebKey generateRsaJsonWebKey() throws JoseException {
  65 + // 生成一个RSA密钥对,该密钥对将用于JWT的签名和验证,包装在JWK中
  66 + RsaJsonWebKey rsaJsonWebKey = RsaJwkGenerator.generateJwk(2048);
  67 + // 给JWK一个密钥ID
  68 + rsaJsonWebKey.setKeyId(keyId);
  69 + return rsaJsonWebKey;
  70 + }
  71 +
  72 + public static String createToken(String username) {
  73 + try {
  74 + /*
43 * “iss” (issuer) 发行人 75 * “iss” (issuer) 发行人
44 - *  
45 * “sub” (subject) 主题 76 * “sub” (subject) 主题
46 - *  
47 * “aud” (audience) 接收方 用户 77 * “aud” (audience) 接收方 用户
48 - *  
49 * “exp” (expiration time) 到期时间 78 * “exp” (expiration time) 到期时间
50 - *  
51 * “nbf” (not before) 在此之前不可用 79 * “nbf” (not before) 在此之前不可用
52 - *  
53 * “iat” (issued at) jwt的签发时间 80 * “iat” (issued at) jwt的签发时间
54 */ 81 */
55 - //Payload  
56 JwtClaims claims = new JwtClaims(); 82 JwtClaims claims = new JwtClaims();
57 claims.setGeneratedJwtId(); 83 claims.setGeneratedJwtId();
58 claims.setIssuedAtToNow(); 84 claims.setIssuedAtToNow();
@@ -62,9 +88,7 @@ public class JwtUtils { @@ -62,9 +88,7 @@ public class JwtUtils {
62 claims.setSubject("login"); 88 claims.setSubject("login");
63 claims.setAudience(AUDIENCE); 89 claims.setAudience(AUDIENCE);
64 //添加自定义参数,必须是字符串类型 90 //添加自定义参数,必须是字符串类型
65 - claims.setClaim("username", username);  
66 - claims.setClaim("password", password);  
67 - claims.setClaim("roleId", roleId); 91 + claims.setClaim("userName", username);
68 92
69 //jws 93 //jws
70 JsonWebSignature jws = new JsonWebSignature(); 94 JsonWebSignature jws = new JsonWebSignature();
@@ -73,12 +97,10 @@ public class JwtUtils { @@ -73,12 +97,10 @@ public class JwtUtils {
73 jws.setKeyIdHeaderValue(keyId); 97 jws.setKeyIdHeaderValue(keyId);
74 jws.setPayload(claims.toJson()); 98 jws.setPayload(claims.toJson());
75 99
76 - PrivateKey privateKey = new RsaJsonWebKey(JsonUtil.parseJson(privateKeyStr)).getPrivateKey();  
77 - jws.setKey(privateKey); 100 + jws.setKey(rsaJsonWebKey.getPrivateKey());
78 101
79 //get token 102 //get token
80 - String idToken = jws.getCompactSerialization();  
81 - return idToken; 103 + return jws.getCompactSerialization();
82 } catch (JoseException e) { 104 } catch (JoseException e) {
83 logger.error("[Token生成失败]: {}", e.getMessage()); 105 logger.error("[Token生成失败]: {}", e.getMessage());
84 } 106 }
@@ -90,7 +112,6 @@ public class JwtUtils { @@ -90,7 +112,6 @@ public class JwtUtils {
90 return HEADER; 112 return HEADER;
91 } 113 }
92 114
93 -  
94 public static JwtUser verifyToken(String token) { 115 public static JwtUser verifyToken(String token) {
95 116
96 JwtUser jwtUser = new JwtUser(); 117 JwtUser jwtUser = new JwtUser();
@@ -103,7 +124,7 @@ public class JwtUtils { @@ -103,7 +124,7 @@ public class JwtUtils {
103 .setRequireSubject() 124 .setRequireSubject()
104 //.setExpectedIssuer("") 125 //.setExpectedIssuer("")
105 .setExpectedAudience(AUDIENCE) 126 .setExpectedAudience(AUDIENCE)
106 - .setVerificationKey(new RsaJsonWebKey(JsonUtil.parseJson(publicKeyStr)).getPublicKey()) 127 + .setVerificationKey(rsaJsonWebKey.getPublicKey())
107 .build(); 128 .build();
108 129
109 JwtClaims claims = consumer.processToClaims(token); 130 JwtClaims claims = consumer.processToClaims(token);
@@ -113,26 +134,26 @@ public class JwtUtils { @@ -113,26 +134,26 @@ public class JwtUtils {
113 long timeRemaining = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)) - expirationTime.getValue(); 134 long timeRemaining = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)) - expirationTime.getValue();
114 if (timeRemaining < 5 * 60) { 135 if (timeRemaining < 5 * 60) {
115 jwtUser.setStatus(JwtUser.TokenStatus.EXPIRING_SOON); 136 jwtUser.setStatus(JwtUser.TokenStatus.EXPIRING_SOON);
116 - }else { 137 + } else {
117 jwtUser.setStatus(JwtUser.TokenStatus.NORMAL); 138 jwtUser.setStatus(JwtUser.TokenStatus.NORMAL);
118 } 139 }
119 140
120 - String username = (String) claims.getClaimValue("username");  
121 - String password = (String) claims.getClaimValue("password");  
122 - Long roleId = (Long) claims.getClaimValue("roleId"); 141 + String username = (String) claims.getClaimValue("userName");
  142 + User user = userService.getUserByUsername(username);
  143 +
123 jwtUser.setUserName(username); 144 jwtUser.setUserName(username);
124 - jwtUser.setPassword(password);  
125 - jwtUser.setRoleId(roleId.intValue()); 145 + jwtUser.setPassword(user.getPassword());
  146 + jwtUser.setRoleId(user.getRole().getId());
126 147
127 return jwtUser; 148 return jwtUser;
128 } catch (InvalidJwtException e) { 149 } catch (InvalidJwtException e) {
129 if (e.hasErrorCode(ErrorCodes.EXPIRED)) { 150 if (e.hasErrorCode(ErrorCodes.EXPIRED)) {
130 jwtUser.setStatus(JwtUser.TokenStatus.EXPIRED); 151 jwtUser.setStatus(JwtUser.TokenStatus.EXPIRED);
131 - }else { 152 + } else {
132 jwtUser.setStatus(JwtUser.TokenStatus.EXCEPTION); 153 jwtUser.setStatus(JwtUser.TokenStatus.EXCEPTION);
133 } 154 }
134 return jwtUser; 155 return jwtUser;
135 - }catch (Exception e) { 156 + } catch (Exception e) {
136 logger.error("[Token解析失败]: {}", e.getMessage()); 157 logger.error("[Token解析失败]: {}", e.getMessage());
137 jwtUser.setStatus(JwtUser.TokenStatus.EXPIRED); 158 jwtUser.setStatus(JwtUser.TokenStatus.EXPIRED);
138 return jwtUser; 159 return jwtUser;
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
1 -package com.genersoft.iot.vmp.gb28181;  
2 -  
3 -import com.genersoft.iot.vmp.conf.SipConfig;  
4 -import com.genersoft.iot.vmp.conf.UserSetting;  
5 -import com.genersoft.iot.vmp.gb28181.bean.GbStringMsgParserFactory;  
6 -import com.genersoft.iot.vmp.gb28181.conf.DefaultProperties;  
7 -import com.genersoft.iot.vmp.gb28181.transmit.ISIPProcessorObserver;  
8 -import gov.nist.javax.sip.SipProviderImpl;  
9 -import gov.nist.javax.sip.SipStackImpl;  
10 -import org.slf4j.Logger;  
11 -import org.slf4j.LoggerFactory;  
12 -import org.springframework.beans.factory.annotation.Autowired;  
13 -import org.springframework.boot.CommandLineRunner;  
14 -import org.springframework.core.annotation.Order;  
15 -import org.springframework.stereotype.Component;  
16 -import org.springframework.util.ObjectUtils;  
17 -  
18 -import javax.sip.*;  
19 -import java.util.*;  
20 -import java.util.concurrent.ConcurrentHashMap;  
21 -  
22 -@Component  
23 -@Order(value=10)  
24 -public class SipLayer implements CommandLineRunner {  
25 -  
26 - private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);  
27 -  
28 - @Autowired  
29 - private SipConfig sipConfig;  
30 -  
31 - @Autowired  
32 - private ISIPProcessorObserver sipProcessorObserver;  
33 -  
34 - @Autowired  
35 - private UserSetting userSetting;  
36 -  
37 - private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>();  
38 - private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>();  
39 -  
40 - @Override  
41 - public void run(String... args) {  
42 - List<String> monitorIps = new ArrayList<>();  
43 - // 使用逗号分割多个ip  
44 - String separator = ",";  
45 - if (sipConfig.getIp().indexOf(separator) > 0) {  
46 - String[] split = sipConfig.getIp().split(separator);  
47 - monitorIps.addAll(Arrays.asList(split));  
48 - }else {  
49 - monitorIps.add(sipConfig.getIp());  
50 - }  
51 -  
52 - SipFactory.getInstance().setPathName("gov.nist");  
53 - if (monitorIps.size() > 0) {  
54 - for (String monitorIp : monitorIps) {  
55 - addListeningPoint(monitorIp, sipConfig.getPort());  
56 - }  
57 - if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) {  
58 - System.exit(1);  
59 - }  
60 - }  
61 - }  
62 -  
63 - private void addListeningPoint(String monitorIp, int port){  
64 - SipStackImpl sipStack;  
65 - try {  
66 - sipStack = (SipStackImpl)SipFactory.getInstance().createSipStack(DefaultProperties.getProperties("GB28181_SIP", userSetting.getSipLog()));  
67 - sipStack.setMessageParserFactory(new GbStringMsgParserFactory());  
68 - } catch (PeerUnavailableException e) {  
69 - logger.error("[SIP SERVER] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp);  
70 - return;  
71 - }  
72 -  
73 - try {  
74 - ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP");  
75 - SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);  
76 -  
77 - tcpSipProvider.setDialogErrorsAutomaticallyHandled();  
78 - tcpSipProvider.addSipListener(sipProcessorObserver);  
79 - tcpSipProviderMap.put(monitorIp, tcpSipProvider);  
80 - logger.info("[SIP SERVER] tcp://{}:{} 启动成功", monitorIp, port);  
81 - } catch (TransportNotSupportedException  
82 - | TooManyListenersException  
83 - | ObjectInUseException  
84 - | InvalidArgumentException e) {  
85 - logger.error("[SIP SERVER] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"  
86 - , monitorIp, port);  
87 - }  
88 -  
89 - try {  
90 - ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP");  
91 -  
92 - SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);  
93 - udpSipProvider.addSipListener(sipProcessorObserver);  
94 -  
95 - udpSipProviderMap.put(monitorIp, udpSipProvider);  
96 -  
97 - logger.info("[SIP SERVER] udp://{}:{} 启动成功", monitorIp, port);  
98 - } catch (TransportNotSupportedException  
99 - | TooManyListenersException  
100 - | ObjectInUseException  
101 - | InvalidArgumentException e) {  
102 - logger.error("[SIP SERVER] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"  
103 - , monitorIp, port);  
104 - }  
105 - }  
106 -  
107 - public SipProviderImpl getUdpSipProvider(String ip) {  
108 - if (ObjectUtils.isEmpty(ip)) {  
109 - return null;  
110 - }  
111 - return udpSipProviderMap.get(ip);  
112 - }  
113 -  
114 - public SipProviderImpl getUdpSipProvider() {  
115 - if (udpSipProviderMap.size() != 1) {  
116 - return null;  
117 - }  
118 - return udpSipProviderMap.values().stream().findFirst().get();  
119 - }  
120 -  
121 - public SipProviderImpl getTcpSipProvider() {  
122 - if (tcpSipProviderMap.size() != 1) {  
123 - return null;  
124 - }  
125 - return tcpSipProviderMap.values().stream().findFirst().get();  
126 - }  
127 -  
128 - public SipProviderImpl getTcpSipProvider(String ip) {  
129 - if (ObjectUtils.isEmpty(ip)) {  
130 - return null;  
131 - }  
132 - return tcpSipProviderMap.get(ip);  
133 - }  
134 -  
135 - public String getLocalIp(String deviceLocalIp) {  
136 - if (!ObjectUtils.isEmpty(deviceLocalIp)) {  
137 - return deviceLocalIp;  
138 - }  
139 - return getUdpSipProvider().getListeningPoint().getIPAddress();  
140 - }  
141 -} 1 +package com.genersoft.iot.vmp.gb28181;
  2 +
  3 +import com.genersoft.iot.vmp.conf.SipConfig;
  4 +import com.genersoft.iot.vmp.conf.UserSetting;
  5 +import com.genersoft.iot.vmp.gb28181.bean.GbStringMsgParserFactory;
  6 +import com.genersoft.iot.vmp.gb28181.conf.DefaultProperties;
  7 +import com.genersoft.iot.vmp.gb28181.transmit.ISIPProcessorObserver;
  8 +import gov.nist.javax.sip.SipProviderImpl;
  9 +import gov.nist.javax.sip.SipStackImpl;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.boot.CommandLineRunner;
  14 +import org.springframework.core.annotation.Order;
  15 +import org.springframework.stereotype.Component;
  16 +import org.springframework.util.ObjectUtils;
  17 +
  18 +import javax.sip.*;
  19 +import java.util.*;
  20 +import java.util.concurrent.ConcurrentHashMap;
  21 +
  22 +@Component
  23 +@Order(value=10)
  24 +public class SipLayer implements CommandLineRunner {
  25 +
  26 + private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);
  27 +
  28 + @Autowired
  29 + private SipConfig sipConfig;
  30 +
  31 + @Autowired
  32 + private ISIPProcessorObserver sipProcessorObserver;
  33 +
  34 + @Autowired
  35 + private UserSetting userSetting;
  36 +
  37 + private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>();
  38 + private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>();
  39 +
  40 + @Override
  41 + public void run(String... args) {
  42 + List<String> monitorIps = new ArrayList<>();
  43 + // 使用逗号分割多个ip
  44 + String separator = ",";
  45 + if (sipConfig.getIp().indexOf(separator) > 0) {
  46 + String[] split = sipConfig.getIp().split(separator);
  47 + monitorIps.addAll(Arrays.asList(split));
  48 + }else {
  49 + monitorIps.add(sipConfig.getIp());
  50 + }
  51 +
  52 + SipFactory.getInstance().setPathName("gov.nist");
  53 + if (monitorIps.size() > 0) {
  54 + for (String monitorIp : monitorIps) {
  55 + addListeningPoint(monitorIp, sipConfig.getPort());
  56 + }
  57 + if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) {
  58 + System.exit(1);
  59 + }
  60 + }
  61 + }
  62 +
  63 + private void addListeningPoint(String monitorIp, int port){
  64 + SipStackImpl sipStack;
  65 + try {
  66 + sipStack = (SipStackImpl)SipFactory.getInstance().createSipStack(DefaultProperties.getProperties("GB28181_SIP", userSetting.getSipLog()));
  67 + sipStack.setMessageParserFactory(new GbStringMsgParserFactory());
  68 + } catch (PeerUnavailableException e) {
  69 + logger.error("[SIP SERVER] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp);
  70 + return;
  71 + }
  72 +
  73 + try {
  74 + ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP");
  75 + SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
  76 +
  77 + tcpSipProvider.setDialogErrorsAutomaticallyHandled();
  78 + tcpSipProvider.addSipListener(sipProcessorObserver);
  79 + tcpSipProviderMap.put(monitorIp, tcpSipProvider);
  80 + logger.info("[SIP SERVER] tcp://{}:{} 启动成功", monitorIp, port);
  81 + } catch (TransportNotSupportedException
  82 + | TooManyListenersException
  83 + | ObjectInUseException
  84 + | InvalidArgumentException e) {
  85 + logger.error("[SIP SERVER] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
  86 + , monitorIp, port);
  87 + }
  88 +
  89 + try {
  90 + ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP");
  91 +
  92 + SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
  93 + udpSipProvider.addSipListener(sipProcessorObserver);
  94 +
  95 + udpSipProviderMap.put(monitorIp, udpSipProvider);
  96 +
  97 + logger.info("[SIP SERVER] udp://{}:{} 启动成功", monitorIp, port);
  98 + } catch (TransportNotSupportedException
  99 + | TooManyListenersException
  100 + | ObjectInUseException
  101 + | InvalidArgumentException e) {
  102 + logger.error("[SIP SERVER] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
  103 + , monitorIp, port);
  104 + }
  105 + }
  106 +
  107 + public SipProviderImpl getUdpSipProvider(String ip) {
  108 + if (ObjectUtils.isEmpty(ip)) {
  109 + return null;
  110 + }
  111 + return udpSipProviderMap.get(ip);
  112 + }
  113 +
  114 + public SipProviderImpl getUdpSipProvider() {
  115 + if (udpSipProviderMap.size() != 1) {
  116 + return null;
  117 + }
  118 + return udpSipProviderMap.values().stream().findFirst().get();
  119 + }
  120 +
  121 + public SipProviderImpl getTcpSipProvider() {
  122 + if (tcpSipProviderMap.size() != 1) {
  123 + return null;
  124 + }
  125 + return tcpSipProviderMap.values().stream().findFirst().get();
  126 + }
  127 +
  128 + public SipProviderImpl getTcpSipProvider(String ip) {
  129 + if (ObjectUtils.isEmpty(ip)) {
  130 + return null;
  131 + }
  132 + return tcpSipProviderMap.get(ip);
  133 + }
  134 +
  135 + public String getLocalIp(String deviceLocalIp) {
  136 + if (!ObjectUtils.isEmpty(deviceLocalIp)) {
  137 + return deviceLocalIp;
  138 + }
  139 + return getUdpSipProvider().getListeningPoint().getIPAddress();
  140 + }
  141 +}
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java
1 -package com.genersoft.iot.vmp.gb28181.bean;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -  
5 -/**  
6 - * @author lin  
7 - */  
8 -@Schema(description = "报警信息")  
9 -public class DeviceAlarm {  
10 -  
11 - /**  
12 - * 数据库id  
13 - */  
14 - @Schema(description = "数据库id")  
15 - private String id;  
16 -  
17 - /**  
18 - * 设备Id  
19 - */  
20 - @Schema(description = "设备的国标编号")  
21 - private String deviceId;  
22 -  
23 - /**  
24 - * 通道Id  
25 - */  
26 - @Schema(description = "通道的国标编号")  
27 - private String channelId;  
28 -  
29 - /**  
30 - * 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情  
31 - */  
32 - @Schema(description = "报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情")  
33 - private String alarmPriority;  
34 -  
35 - /**  
36 - * 报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,  
37 - * 7其他报警;可以为直接组合如12为电话报警或 设备报警-  
38 - */  
39 - @Schema(description = "报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,\n" +  
40 - "\t * 7其他报警;可以为直接组合如12为电话报警或设备报警")  
41 - private String alarmMethod;  
42 -  
43 - /**  
44 - * 报警时间  
45 - */  
46 - @Schema(description = "报警时间")  
47 - private String alarmTime;  
48 -  
49 - /**  
50 - * 报警内容描述  
51 - */  
52 - @Schema(description = "报警内容描述")  
53 - private String alarmDescription;  
54 -  
55 - /**  
56 - * 经度  
57 - */  
58 - @Schema(description = "经度")  
59 - private double longitude;  
60 -  
61 - /**  
62 - * 纬度  
63 - */  
64 - @Schema(description = "纬度")  
65 - private double latitude;  
66 -  
67 - /**  
68 - * 报警类型,  
69 - * 报警方式为2时,不携带 AlarmType为默认的报警设备报警,  
70 - * 携带 AlarmType取值及对应报警类型如下:  
71 - * 1-视频丢失报警;  
72 - * 2-设备防拆报警;  
73 - * 3-存储设备磁盘满报警;  
74 - * 4-设备高温报警;  
75 - * 5-设备低温报警。  
76 - * 报警方式为5时,取值如下:  
77 - * 1-人工视频报警;  
78 - * 2-运动目标检测报警;  
79 - * 3-遗留物检测报警;  
80 - * 4-物体移除检测报警;  
81 - * 5-绊线检测报警;  
82 - * 6-入侵检测报警;  
83 - * 7-逆行检测报警;  
84 - * 8-徘徊检测报警;  
85 - * 9-流量统计报警;  
86 - * 10-密度检测报警;  
87 - * 11-视频异常检测报警;  
88 - * 12-快速移动报警。  
89 - * 报警方式为6时,取值下:  
90 - * 1-存储设备磁盘故障报警;  
91 - * 2-存储设备风扇故障报警。  
92 - */  
93 - @Schema(description = "报警类型")  
94 - private String alarmType;  
95 -  
96 - @Schema(description = "创建时间")  
97 - private String createTime;  
98 -  
99 -  
100 - public String getId() {  
101 - return id;  
102 - }  
103 -  
104 - public void setId(String id) {  
105 - this.id = id;  
106 - }  
107 -  
108 - public String getDeviceId() {  
109 - return deviceId;  
110 - }  
111 -  
112 - public void setDeviceId(String deviceId) {  
113 - this.deviceId = deviceId;  
114 - }  
115 -  
116 - public String getAlarmPriority() {  
117 - return alarmPriority;  
118 - }  
119 -  
120 - public void setAlarmPriority(String alarmPriority) {  
121 - this.alarmPriority = alarmPriority;  
122 - }  
123 -  
124 - public String getAlarmMethod() {  
125 - return alarmMethod;  
126 - }  
127 -  
128 - public void setAlarmMethod(String alarmMethod) {  
129 - this.alarmMethod = alarmMethod;  
130 - }  
131 -  
132 - public String getAlarmTime() {  
133 - return alarmTime;  
134 - }  
135 -  
136 - public void setAlarmTime(String alarmTime) {  
137 - this.alarmTime = alarmTime;  
138 - }  
139 -  
140 - public String getAlarmDescription() {  
141 - return alarmDescription;  
142 - }  
143 -  
144 - public void setAlarmDescription(String alarmDescription) {  
145 - this.alarmDescription = alarmDescription;  
146 - }  
147 -  
148 - public double getLongitude() {  
149 - return longitude;  
150 - }  
151 -  
152 - public void setLongitude(double longitude) {  
153 - this.longitude = longitude;  
154 - }  
155 -  
156 - public double getLatitude() {  
157 - return latitude;  
158 - }  
159 -  
160 - public void setLatitude(double latitude) {  
161 - this.latitude = latitude;  
162 - }  
163 -  
164 - public String getAlarmType() {  
165 - return alarmType;  
166 - }  
167 -  
168 - public void setAlarmType(String alarmType) {  
169 - this.alarmType = alarmType;  
170 - }  
171 -  
172 - public String getChannelId() {  
173 - return channelId;  
174 - }  
175 -  
176 - public void setChannelId(String channelId) {  
177 - this.channelId = channelId;  
178 - }  
179 -  
180 - public String getCreateTime() {  
181 - return createTime;  
182 - }  
183 -  
184 - public void setCreateTime(String createTime) {  
185 - this.createTime = createTime;  
186 - }  
187 -} 1 +package com.genersoft.iot.vmp.gb28181.bean;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +
  5 +/**
  6 + * @author lin
  7 + */
  8 +@Schema(description = "报警信息")
  9 +public class DeviceAlarm {
  10 +
  11 + /**
  12 + * 数据库id
  13 + */
  14 + @Schema(description = "数据库id")
  15 + private String id;
  16 +
  17 + /**
  18 + * 设备Id
  19 + */
  20 + @Schema(description = "设备的国标编号")
  21 + private String deviceId;
  22 +
  23 + /**
  24 + * 通道Id
  25 + */
  26 + @Schema(description = "通道的国标编号")
  27 + private String channelId;
  28 +
  29 + /**
  30 + * 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情
  31 + */
  32 + @Schema(description = "报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情")
  33 + private String alarmPriority;
  34 +
  35 + /**
  36 + * 报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,
  37 + * 7其他报警;可以为直接组合如12为电话报警或 设备报警-
  38 + */
  39 + @Schema(description = "报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,\n" +
  40 + "\t * 7其他报警;可以为直接组合如12为电话报警或设备报警")
  41 + private String alarmMethod;
  42 +
  43 + /**
  44 + * 报警时间
  45 + */
  46 + @Schema(description = "报警时间")
  47 + private String alarmTime;
  48 +
  49 + /**
  50 + * 报警内容描述
  51 + */
  52 + @Schema(description = "报警内容描述")
  53 + private String alarmDescription;
  54 +
  55 + /**
  56 + * 经度
  57 + */
  58 + @Schema(description = "经度")
  59 + private double longitude;
  60 +
  61 + /**
  62 + * 纬度
  63 + */
  64 + @Schema(description = "纬度")
  65 + private double latitude;
  66 +
  67 + /**
  68 + * 报警类型,
  69 + * 报警方式为2时,不携带 AlarmType为默认的报警设备报警,
  70 + * 携带 AlarmType取值及对应报警类型如下:
  71 + * 1-视频丢失报警;
  72 + * 2-设备防拆报警;
  73 + * 3-存储设备磁盘满报警;
  74 + * 4-设备高温报警;
  75 + * 5-设备低温报警。
  76 + * 报警方式为5时,取值如下:
  77 + * 1-人工视频报警;
  78 + * 2-运动目标检测报警;
  79 + * 3-遗留物检测报警;
  80 + * 4-物体移除检测报警;
  81 + * 5-绊线检测报警;
  82 + * 6-入侵检测报警;
  83 + * 7-逆行检测报警;
  84 + * 8-徘徊检测报警;
  85 + * 9-流量统计报警;
  86 + * 10-密度检测报警;
  87 + * 11-视频异常检测报警;
  88 + * 12-快速移动报警。
  89 + * 报警方式为6时,取值下:
  90 + * 1-存储设备磁盘故障报警;
  91 + * 2-存储设备风扇故障报警。
  92 + */
  93 + @Schema(description = "报警类型")
  94 + private String alarmType;
  95 +
  96 + @Schema(description = "创建时间")
  97 + private String createTime;
  98 +
  99 +
  100 + public String getId() {
  101 + return id;
  102 + }
  103 +
  104 + public void setId(String id) {
  105 + this.id = id;
  106 + }
  107 +
  108 + public String getDeviceId() {
  109 + return deviceId;
  110 + }
  111 +
  112 + public void setDeviceId(String deviceId) {
  113 + this.deviceId = deviceId;
  114 + }
  115 +
  116 + public String getAlarmPriority() {
  117 + return alarmPriority;
  118 + }
  119 +
  120 + public void setAlarmPriority(String alarmPriority) {
  121 + this.alarmPriority = alarmPriority;
  122 + }
  123 +
  124 + public String getAlarmMethod() {
  125 + return alarmMethod;
  126 + }
  127 +
  128 + public void setAlarmMethod(String alarmMethod) {
  129 + this.alarmMethod = alarmMethod;
  130 + }
  131 +
  132 + public String getAlarmTime() {
  133 + return alarmTime;
  134 + }
  135 +
  136 + public void setAlarmTime(String alarmTime) {
  137 + this.alarmTime = alarmTime;
  138 + }
  139 +
  140 + public String getAlarmDescription() {
  141 + return alarmDescription;
  142 + }
  143 +
  144 + public void setAlarmDescription(String alarmDescription) {
  145 + this.alarmDescription = alarmDescription;
  146 + }
  147 +
  148 + public double getLongitude() {
  149 + return longitude;
  150 + }
  151 +
  152 + public void setLongitude(double longitude) {
  153 + this.longitude = longitude;
  154 + }
  155 +
  156 + public double getLatitude() {
  157 + return latitude;
  158 + }
  159 +
  160 + public void setLatitude(double latitude) {
  161 + this.latitude = latitude;
  162 + }
  163 +
  164 + public String getAlarmType() {
  165 + return alarmType;
  166 + }
  167 +
  168 + public void setAlarmType(String alarmType) {
  169 + this.alarmType = alarmType;
  170 + }
  171 +
  172 + public String getChannelId() {
  173 + return channelId;
  174 + }
  175 +
  176 + public void setChannelId(String channelId) {
  177 + this.channelId = channelId;
  178 + }
  179 +
  180 + public String getCreateTime() {
  181 + return createTime;
  182 + }
  183 +
  184 + public void setCreateTime(String createTime) {
  185 + this.createTime = createTime;
  186 + }
  187 +}
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GBStringMsgParser.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStringMsgParserFactory.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/HandlerCatchData.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/HomePositionRequest.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Host.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamCallback.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformRegister.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java 100644 → 100755
1 -package com.genersoft.iot.vmp.gb28181.bean;  
2 -  
3 -  
4 -import io.swagger.v3.oas.annotations.media.Schema;  
5 -  
6 -import java.time.Instant;  
7 -import java.util.List;  
8 -  
9 -/**  
10 - * @description:设备录像信息bean  
11 - * @author: swwheihei  
12 - * @date: 2020年5月8日 下午2:05:56  
13 - */  
14 -@Schema(description = "设备录像查询结果信息")  
15 -public class RecordInfo {  
16 -  
17 - @Schema(description = "设备编号")  
18 - private String deviceId;  
19 -  
20 - @Schema(description = "通道编号")  
21 - private String channelId;  
22 -  
23 - @Schema(description = "命令序列号")  
24 - private String sn;  
25 -  
26 - @Schema(description = "设备名称")  
27 - private String name;  
28 -  
29 - @Schema(description = "列表总数")  
30 - private int sumNum;  
31 -  
32 - private int count;  
33 -  
34 - private Instant lastTime;  
35 -  
36 - @Schema(description = "")  
37 - private List<RecordItem> recordList;  
38 -  
39 - public String getDeviceId() {  
40 - return deviceId;  
41 - }  
42 -  
43 - public void setDeviceId(String deviceId) {  
44 - this.deviceId = deviceId;  
45 - }  
46 -  
47 - public String getName() {  
48 - return name;  
49 - }  
50 -  
51 - public void setName(String name) {  
52 - this.name = name;  
53 - }  
54 -  
55 - public int getSumNum() {  
56 - return sumNum;  
57 - }  
58 -  
59 - public void setSumNum(int sumNum) {  
60 - this.sumNum = sumNum;  
61 - }  
62 -  
63 - public List<RecordItem> getRecordList() {  
64 - return recordList;  
65 - }  
66 -  
67 - public void setRecordList(List<RecordItem> recordList) {  
68 - this.recordList = recordList;  
69 - }  
70 -  
71 - public String getChannelId() {  
72 - return channelId;  
73 - }  
74 -  
75 - public void setChannelId(String channelId) {  
76 - this.channelId = channelId;  
77 - }  
78 -  
79 - public String getSn() {  
80 - return sn;  
81 - }  
82 -  
83 - public void setSn(String sn) {  
84 - this.sn = sn;  
85 - }  
86 -  
87 - public Instant getLastTime() {  
88 - return lastTime;  
89 - }  
90 -  
91 - public void setLastTime(Instant lastTime) {  
92 - this.lastTime = lastTime;  
93 - }  
94 -  
95 - public int getCount() {  
96 - return count;  
97 - }  
98 -  
99 - public void setCount(int count) {  
100 - this.count = count;  
101 - }  
102 -} 1 +package com.genersoft.iot.vmp.gb28181.bean;
  2 +
  3 +
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +
  6 +import java.time.Instant;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * @description:设备录像信息bean
  11 + * @author: swwheihei
  12 + * @date: 2020年5月8日 下午2:05:56
  13 + */
  14 +@Schema(description = "设备录像查询结果信息")
  15 +public class RecordInfo {
  16 +
  17 + @Schema(description = "设备编号")
  18 + private String deviceId;
  19 +
  20 + @Schema(description = "通道编号")
  21 + private String channelId;
  22 +
  23 + @Schema(description = "命令序列号")
  24 + private String sn;
  25 +
  26 + @Schema(description = "设备名称")
  27 + private String name;
  28 +
  29 + @Schema(description = "列表总数")
  30 + private int sumNum;
  31 +
  32 + private int count;
  33 +
  34 + private Instant lastTime;
  35 +
  36 + @Schema(description = "")
  37 + private List<RecordItem> recordList;
  38 +
  39 + public String getDeviceId() {
  40 + return deviceId;
  41 + }
  42 +
  43 + public void setDeviceId(String deviceId) {
  44 + this.deviceId = deviceId;
  45 + }
  46 +
  47 + public String getName() {
  48 + return name;
  49 + }
  50 +
  51 + public void setName(String name) {
  52 + this.name = name;
  53 + }
  54 +
  55 + public int getSumNum() {
  56 + return sumNum;
  57 + }
  58 +
  59 + public void setSumNum(int sumNum) {
  60 + this.sumNum = sumNum;
  61 + }
  62 +
  63 + public List<RecordItem> getRecordList() {
  64 + return recordList;
  65 + }
  66 +
  67 + public void setRecordList(List<RecordItem> recordList) {
  68 + this.recordList = recordList;
  69 + }
  70 +
  71 + public String getChannelId() {
  72 + return channelId;
  73 + }
  74 +
  75 + public void setChannelId(String channelId) {
  76 + this.channelId = channelId;
  77 + }
  78 +
  79 + public String getSn() {
  80 + return sn;
  81 + }
  82 +
  83 + public void setSn(String sn) {
  84 + this.sn = sn;
  85 + }
  86 +
  87 + public Instant getLastTime() {
  88 + return lastTime;
  89 + }
  90 +
  91 + public void setLastTime(Instant lastTime) {
  92 + this.lastTime = lastTime;
  93 + }
  94 +
  95 + public int getCount() {
  96 + return count;
  97 + }
  98 +
  99 + public void setCount(int count) {
  100 + this.count = count;
  101 + }
  102 +}
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordItem.java 100644 → 100755
1 -package com.genersoft.iot.vmp.gb28181.bean;  
2 -  
3 -  
4 -import com.genersoft.iot.vmp.utils.DateUtil;  
5 -import io.swagger.v3.oas.annotations.media.Schema;  
6 -import org.jetbrains.annotations.NotNull;  
7 -  
8 -import java.time.Instant;  
9 -import java.time.temporal.TemporalAccessor;  
10 -  
11 -/**  
12 - * @description:设备录像bean  
13 - * @author: swwheihei  
14 - * @date: 2020年5月8日 下午2:06:54  
15 - */  
16 -@Schema(description = "设备录像详情")  
17 -public class RecordItem implements Comparable<RecordItem>{  
18 -  
19 - @Schema(description = "设备编号")  
20 - private String deviceId;  
21 -  
22 - @Schema(description = "名称")  
23 - private String name;  
24 -  
25 - @Schema(description = "文件路径名 (可选)")  
26 - private String filePath;  
27 -  
28 - @Schema(description = "录像文件大小,单位:Byte(可选)")  
29 - private String fileSize;  
30 -  
31 - @Schema(description = "录像地址(可选)")  
32 - private String address;  
33 -  
34 - @Schema(description = "录像开始时间(可选)")  
35 - private String startTime;  
36 -  
37 - @Schema(description = "录像结束时间(可选)")  
38 - private String endTime;  
39 -  
40 - @Schema(description = "保密属性(必选)缺省为0;0:不涉密,1:涉密")  
41 - private int secrecy;  
42 -  
43 - @Schema(description = "录像产生类型(可选)time或alarm 或 manua")  
44 - private String type;  
45 -  
46 - @Schema(description = "录像触发者ID(可选)")  
47 - private String recorderId;  
48 -  
49 - public String getDeviceId() {  
50 - return deviceId;  
51 - }  
52 -  
53 - public void setDeviceId(String deviceId) {  
54 - this.deviceId = deviceId;  
55 - }  
56 -  
57 - public String getName() {  
58 - return name;  
59 - }  
60 -  
61 - public void setName(String name) {  
62 - this.name = name;  
63 - }  
64 -  
65 - public String getFilePath() {  
66 - return filePath;  
67 - }  
68 -  
69 - public void setFilePath(String filePath) {  
70 - this.filePath = filePath;  
71 - }  
72 -  
73 - public String getAddress() {  
74 - return address;  
75 - }  
76 -  
77 - public void setAddress(String address) {  
78 - this.address = address;  
79 - }  
80 -  
81 - public String getStartTime() {  
82 - return startTime;  
83 - }  
84 -  
85 - public void setStartTime(String startTime) {  
86 - this.startTime = startTime;  
87 - }  
88 -  
89 - public String getEndTime() {  
90 - return endTime;  
91 - }  
92 -  
93 - public void setEndTime(String endTime) {  
94 - this.endTime = endTime;  
95 - }  
96 -  
97 - public int getSecrecy() {  
98 - return secrecy;  
99 - }  
100 -  
101 - public void setSecrecy(int secrecy) {  
102 - this.secrecy = secrecy;  
103 - }  
104 -  
105 - public String getType() {  
106 - return type;  
107 - }  
108 -  
109 - public void setType(String type) {  
110 - this.type = type;  
111 - }  
112 -  
113 - public String getRecorderId() {  
114 - return recorderId;  
115 - }  
116 -  
117 - public void setRecorderId(String recorderId) {  
118 - this.recorderId = recorderId;  
119 - }  
120 -  
121 - public String getFileSize() {  
122 - return fileSize;  
123 - }  
124 -  
125 - public void setFileSize(String fileSize) {  
126 - this.fileSize = fileSize;  
127 - }  
128 -  
129 - @Override  
130 - public int compareTo(@NotNull RecordItem recordItem) {  
131 - TemporalAccessor startTimeNow = DateUtil.formatter.parse(startTime);  
132 - TemporalAccessor startTimeParam = DateUtil.formatter.parse(recordItem.getStartTime());  
133 - Instant startTimeParamInstant = Instant.from(startTimeParam);  
134 - Instant startTimeNowInstant = Instant.from(startTimeNow);  
135 - if (startTimeNowInstant.equals(startTimeParamInstant)) {  
136 - return 0;  
137 - }else if (Instant.from(startTimeParam).isAfter(Instant.from(startTimeNow)) ) {  
138 - return -1;  
139 - }else {  
140 - return 1;  
141 - }  
142 -  
143 - }  
144 -} 1 +package com.genersoft.iot.vmp.gb28181.bean;
  2 +
  3 +
  4 +import com.genersoft.iot.vmp.utils.DateUtil;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import org.jetbrains.annotations.NotNull;
  7 +
  8 +import java.time.Instant;
  9 +import java.time.temporal.TemporalAccessor;
  10 +
  11 +/**
  12 + * @description:设备录像bean
  13 + * @author: swwheihei
  14 + * @date: 2020年5月8日 下午2:06:54
  15 + */
  16 +@Schema(description = "设备录像详情")
  17 +public class RecordItem implements Comparable<RecordItem>{
  18 +
  19 + @Schema(description = "设备编号")
  20 + private String deviceId;
  21 +
  22 + @Schema(description = "名称")
  23 + private String name;
  24 +
  25 + @Schema(description = "文件路径名 (可选)")
  26 + private String filePath;
  27 +
  28 + @Schema(description = "录像文件大小,单位:Byte(可选)")
  29 + private String fileSize;
  30 +
  31 + @Schema(description = "录像地址(可选)")
  32 + private String address;
  33 +
  34 + @Schema(description = "录像开始时间(可选)")
  35 + private String startTime;
  36 +
  37 + @Schema(description = "录像结束时间(可选)")
  38 + private String endTime;
  39 +
  40 + @Schema(description = "保密属性(必选)缺省为0;0:不涉密,1:涉密")
  41 + private int secrecy;
  42 +
  43 + @Schema(description = "录像产生类型(可选)time或alarm 或 manua")
  44 + private String type;
  45 +
  46 + @Schema(description = "录像触发者ID(可选)")
  47 + private String recorderId;
  48 +
  49 + public String getDeviceId() {
  50 + return deviceId;
  51 + }
  52 +
  53 + public void setDeviceId(String deviceId) {
  54 + this.deviceId = deviceId;
  55 + }
  56 +
  57 + public String getName() {
  58 + return name;
  59 + }
  60 +
  61 + public void setName(String name) {
  62 + this.name = name;
  63 + }
  64 +
  65 + public String getFilePath() {
  66 + return filePath;
  67 + }
  68 +
  69 + public void setFilePath(String filePath) {
  70 + this.filePath = filePath;
  71 + }
  72 +
  73 + public String getAddress() {
  74 + return address;
  75 + }
  76 +
  77 + public void setAddress(String address) {
  78 + this.address = address;
  79 + }
  80 +
  81 + public String getStartTime() {
  82 + return startTime;
  83 + }
  84 +
  85 + public void setStartTime(String startTime) {
  86 + this.startTime = startTime;
  87 + }
  88 +
  89 + public String getEndTime() {
  90 + return endTime;
  91 + }
  92 +
  93 + public void setEndTime(String endTime) {
  94 + this.endTime = endTime;
  95 + }
  96 +
  97 + public int getSecrecy() {
  98 + return secrecy;
  99 + }
  100 +
  101 + public void setSecrecy(int secrecy) {
  102 + this.secrecy = secrecy;
  103 + }
  104 +
  105 + public String getType() {
  106 + return type;
  107 + }
  108 +
  109 + public void setType(String type) {
  110 + this.type = type;
  111 + }
  112 +
  113 + public String getRecorderId() {
  114 + return recorderId;
  115 + }
  116 +
  117 + public void setRecorderId(String recorderId) {
  118 + this.recorderId = recorderId;
  119 + }
  120 +
  121 + public String getFileSize() {
  122 + return fileSize;
  123 + }
  124 +
  125 + public void setFileSize(String fileSize) {
  126 + this.fileSize = fileSize;
  127 + }
  128 +
  129 + @Override
  130 + public int compareTo(@NotNull RecordItem recordItem) {
  131 + TemporalAccessor startTimeNow = DateUtil.formatter.parse(startTime);
  132 + TemporalAccessor startTimeParam = DateUtil.formatter.parse(recordItem.getStartTime());
  133 + Instant startTimeParamInstant = Instant.from(startTimeParam);
  134 + Instant startTimeNowInstant = Instant.from(startTimeNow);
  135 + if (startTimeNowInstant.equals(startTimeParamInstant)) {
  136 + return 0;
  137 + }else if (Instant.from(startTimeParam).isAfter(Instant.from(startTimeNow)) ) {
  138 + return -1;
  139 + }else {
  140 + return 1;
  141 + }
  142 +
  143 + }
  144 +}
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RemoteAddressInfo.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SDPInfo.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipMsgInfo.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipTransactionInfo.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java 100644 → 100755
@@ -2,12 +2,9 @@ package com.genersoft.iot.vmp.gb28181.bean; @@ -2,12 +2,9 @@ package com.genersoft.iot.vmp.gb28181.bean;
2 2
3 import com.genersoft.iot.vmp.common.VideoManagerConstants; 3 import com.genersoft.iot.vmp.common.VideoManagerConstants;
4 import com.genersoft.iot.vmp.conf.DynamicTask; 4 import com.genersoft.iot.vmp.conf.DynamicTask;
  5 +import com.genersoft.iot.vmp.conf.UserSetting;
5 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; 6 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
6 import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask; 7 import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask;
7 -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;  
8 -import com.genersoft.iot.vmp.service.IPlatformService;  
9 -import com.genersoft.iot.vmp.storager.IRedisCatchStorage;  
10 -import com.genersoft.iot.vmp.storager.IVideoManagerStorage;  
11 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Component; 9 import org.springframework.stereotype.Component;
13 10
@@ -24,6 +21,9 @@ public class SubscribeHolder { @@ -24,6 +21,9 @@ public class SubscribeHolder {
24 @Autowired 21 @Autowired
25 private DynamicTask dynamicTask; 22 private DynamicTask dynamicTask;
26 23
  24 + @Autowired
  25 + private UserSetting userSetting;
  26 +
27 private final String taskOverduePrefix = "subscribe_overdue_"; 27 private final String taskOverduePrefix = "subscribe_overdue_";
28 28
29 private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>(); 29 private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
@@ -58,7 +58,7 @@ public class SubscribeHolder { @@ -58,7 +58,7 @@ public class SubscribeHolder {
58 58
59 public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) { 59 public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) {
60 mobilePositionMap.put(platformId, subscribeInfo); 60 mobilePositionMap.put(platformId, subscribeInfo);
61 - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId; 61 + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId;
62 // 添加任务处理GPS定时推送 62 // 添加任务处理GPS定时推送
63 dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId), 63 dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId),
64 subscribeInfo.getGpsInterval() * 1000); 64 subscribeInfo.getGpsInterval() * 1000);
@@ -76,7 +76,7 @@ public class SubscribeHolder { @@ -76,7 +76,7 @@ public class SubscribeHolder {
76 76
77 public void removeMobilePositionSubscribe(String platformId) { 77 public void removeMobilePositionSubscribe(String platformId) {
78 mobilePositionMap.remove(platformId); 78 mobilePositionMap.remove(platformId);
79 - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + "MobilePosition_" + platformId; 79 + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId;
80 // 结束任务处理GPS定时推送 80 // 结束任务处理GPS定时推送
81 dynamicTask.stop(key); 81 dynamicTask.stop(key);
82 String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; 82 String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId;
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SyncStatus.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/conf/ServerLoggerImpl.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java 100644 → 100755
1 -package com.genersoft.iot.vmp.gb28181.event;  
2 -  
3 -import com.genersoft.iot.vmp.gb28181.bean.*;  
4 -import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent;  
5 -import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent;  
6 -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;  
7 -import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;  
8 -import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.context.ApplicationEventPublisher;  
11 -import org.springframework.stereotype.Component;  
12 -  
13 -import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;  
14 -  
15 -import javax.sip.TimeoutEvent;  
16 -import java.util.ArrayList;  
17 -import java.util.HashSet;  
18 -import java.util.List;  
19 -import java.util.Set;  
20 -  
21 -/**  
22 - * @description:Event事件通知推送器,支持推送在线事件、离线事件  
23 - * @author: swwheihei  
24 - * @date: 2020年5月6日 上午11:30:50  
25 - */  
26 -@Component  
27 -public class EventPublisher {  
28 -  
29 - @Autowired  
30 - private ApplicationEventPublisher applicationEventPublisher;  
31 -  
32 - /**  
33 - * 设备报警事件  
34 - * @param deviceAlarm  
35 - */  
36 - public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) {  
37 - AlarmEvent alarmEvent = new AlarmEvent(this);  
38 - alarmEvent.setAlarmInfo(deviceAlarm);  
39 - applicationEventPublisher.publishEvent(alarmEvent);  
40 - }  
41 -  
42 - public void zlmOfflineEventPublish(String mediaServerId){  
43 - ZLMOfflineEvent outEvent = new ZLMOfflineEvent(this);  
44 - outEvent.setMediaServerId(mediaServerId);  
45 - applicationEventPublisher.publishEvent(outEvent);  
46 - }  
47 -  
48 - public void zlmOnlineEventPublish(String mediaServerId) {  
49 - ZLMOnlineEvent outEvent = new ZLMOnlineEvent(this);  
50 - outEvent.setMediaServerId(mediaServerId);  
51 - applicationEventPublisher.publishEvent(outEvent);  
52 - }  
53 -  
54 -  
55 - public void catalogEventPublish(String platformId, DeviceChannel deviceChannel, String type) {  
56 - List<DeviceChannel> deviceChannelList = new ArrayList<>();  
57 - deviceChannelList.add(deviceChannel);  
58 - catalogEventPublish(platformId, deviceChannelList, type);  
59 - }  
60 -  
61 -  
62 - public void requestTimeOut(TimeoutEvent timeoutEvent) {  
63 - RequestTimeoutEvent requestTimeoutEvent = new RequestTimeoutEvent(this);  
64 - requestTimeoutEvent.setTimeoutEvent(timeoutEvent);  
65 - applicationEventPublisher.publishEvent(requestTimeoutEvent);  
66 - }  
67 -  
68 -  
69 - /**  
70 - *  
71 - * @param platformId  
72 - * @param deviceChannels  
73 - * @param type  
74 - */  
75 - public void catalogEventPublish(String platformId, List<DeviceChannel> deviceChannels, String type) {  
76 - CatalogEvent outEvent = new CatalogEvent(this);  
77 - List<DeviceChannel> channels = new ArrayList<>();  
78 - if (deviceChannels.size() > 1) {  
79 - // 数据去重  
80 - Set<String> gbIdSet = new HashSet<>();  
81 - for (DeviceChannel deviceChannel : deviceChannels) {  
82 - if (!gbIdSet.contains(deviceChannel.getChannelId())) {  
83 - gbIdSet.add(deviceChannel.getChannelId());  
84 - channels.add(deviceChannel);  
85 - }  
86 - }  
87 - }else {  
88 - channels = deviceChannels;  
89 - }  
90 - outEvent.setDeviceChannels(channels);  
91 - outEvent.setType(type);  
92 - outEvent.setPlatformId(platformId);  
93 - applicationEventPublisher.publishEvent(outEvent);  
94 - }  
95 -  
96 -  
97 - public void catalogEventPublishForStream(String platformId, List<GbStream> gbStreams, String type) {  
98 - CatalogEvent outEvent = new CatalogEvent(this);  
99 - outEvent.setGbStreams(gbStreams);  
100 - outEvent.setType(type);  
101 - outEvent.setPlatformId(platformId);  
102 - applicationEventPublisher.publishEvent(outEvent);  
103 - }  
104 -  
105 -  
106 - public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) {  
107 - List<GbStream> gbStreamList = new ArrayList<>();  
108 - gbStreamList.add(gbStream);  
109 - catalogEventPublishForStream(platformId, gbStreamList, type);  
110 - }  
111 -  
112 - public void recordEndEventPush(RecordInfo recordInfo) {  
113 - RecordEndEvent outEvent = new RecordEndEvent(this);  
114 - outEvent.setRecordInfo(recordInfo);  
115 - applicationEventPublisher.publishEvent(outEvent);  
116 - }  
117 -  
118 -} 1 +package com.genersoft.iot.vmp.gb28181.event;
  2 +
  3 +import com.genersoft.iot.vmp.gb28181.bean.*;
  4 +import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent;
  5 +import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent;
  6 +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
  7 +import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
  8 +import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.context.ApplicationEventPublisher;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
  14 +
  15 +import javax.sip.TimeoutEvent;
  16 +import java.util.ArrayList;
  17 +import java.util.HashSet;
  18 +import java.util.List;
  19 +import java.util.Set;
  20 +
  21 +/**
  22 + * @description:Event事件通知推送器,支持推送在线事件、离线事件
  23 + * @author: swwheihei
  24 + * @date: 2020年5月6日 上午11:30:50
  25 + */
  26 +@Component
  27 +public class EventPublisher {
  28 +
  29 + @Autowired
  30 + private ApplicationEventPublisher applicationEventPublisher;
  31 +
  32 + /**
  33 + * 设备报警事件
  34 + * @param deviceAlarm
  35 + */
  36 + public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) {
  37 + AlarmEvent alarmEvent = new AlarmEvent(this);
  38 + alarmEvent.setAlarmInfo(deviceAlarm);
  39 + applicationEventPublisher.publishEvent(alarmEvent);
  40 + }
  41 +
  42 + public void zlmOfflineEventPublish(String mediaServerId){
  43 + ZLMOfflineEvent outEvent = new ZLMOfflineEvent(this);
  44 + outEvent.setMediaServerId(mediaServerId);
  45 + applicationEventPublisher.publishEvent(outEvent);
  46 + }
  47 +
  48 + public void zlmOnlineEventPublish(String mediaServerId) {
  49 + ZLMOnlineEvent outEvent = new ZLMOnlineEvent(this);
  50 + outEvent.setMediaServerId(mediaServerId);
  51 + applicationEventPublisher.publishEvent(outEvent);
  52 + }
  53 +
  54 +
  55 + public void catalogEventPublish(String platformId, DeviceChannel deviceChannel, String type) {
  56 + List<DeviceChannel> deviceChannelList = new ArrayList<>();
  57 + deviceChannelList.add(deviceChannel);
  58 + catalogEventPublish(platformId, deviceChannelList, type);
  59 + }
  60 +
  61 +
  62 + public void requestTimeOut(TimeoutEvent timeoutEvent) {
  63 + RequestTimeoutEvent requestTimeoutEvent = new RequestTimeoutEvent(this);
  64 + requestTimeoutEvent.setTimeoutEvent(timeoutEvent);
  65 + applicationEventPublisher.publishEvent(requestTimeoutEvent);
  66 + }
  67 +
  68 +
  69 + /**
  70 + *
  71 + * @param platformId
  72 + * @param deviceChannels
  73 + * @param type
  74 + */
  75 + public void catalogEventPublish(String platformId, List<DeviceChannel> deviceChannels, String type) {
  76 + CatalogEvent outEvent = new CatalogEvent(this);
  77 + List<DeviceChannel> channels = new ArrayList<>();
  78 + if (deviceChannels.size() > 1) {
  79 + // 数据去重
  80 + Set<String> gbIdSet = new HashSet<>();
  81 + for (DeviceChannel deviceChannel : deviceChannels) {
  82 + if (!gbIdSet.contains(deviceChannel.getChannelId())) {
  83 + gbIdSet.add(deviceChannel.getChannelId());
  84 + channels.add(deviceChannel);
  85 + }
  86 + }
  87 + }else {
  88 + channels = deviceChannels;
  89 + }
  90 + outEvent.setDeviceChannels(channels);
  91 + outEvent.setType(type);
  92 + outEvent.setPlatformId(platformId);
  93 + applicationEventPublisher.publishEvent(outEvent);
  94 + }
  95 +
  96 +
  97 + public void catalogEventPublishForStream(String platformId, List<GbStream> gbStreams, String type) {
  98 + CatalogEvent outEvent = new CatalogEvent(this);
  99 + outEvent.setGbStreams(gbStreams);
  100 + outEvent.setType(type);
  101 + outEvent.setPlatformId(platformId);
  102 + applicationEventPublisher.publishEvent(outEvent);
  103 + }
  104 +
  105 +
  106 + public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) {
  107 + List<GbStream> gbStreamList = new ArrayList<>();
  108 + gbStreamList.add(gbStream);
  109 + catalogEventPublishForStream(platformId, gbStreamList, type);
  110 + }
  111 +
  112 + public void recordEndEventPush(RecordInfo recordInfo) {
  113 + RecordEndEvent outEvent = new RecordEndEvent(this);
  114 + outEvent.setRecordInfo(recordInfo);
  115 + applicationEventPublisher.publishEvent(outEvent);
  116 + }
  117 +
  118 +}
src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/session/SSRCFactory.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java 100644 → 100755
1 -package com.genersoft.iot.vmp.gb28181.session;  
2 -  
3 -import com.genersoft.iot.vmp.common.InviteSessionType;  
4 -import com.genersoft.iot.vmp.common.VideoManagerConstants;  
5 -import com.genersoft.iot.vmp.conf.UserSetting;  
6 -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;  
7 -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;  
8 -import com.genersoft.iot.vmp.utils.JsonUtil;  
9 -import com.genersoft.iot.vmp.utils.redis.RedisUtil;  
10 -import gov.nist.javax.sip.message.SIPResponse;  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.data.redis.core.RedisTemplate;  
13 -import org.springframework.stereotype.Component;  
14 -import org.springframework.util.ObjectUtils;  
15 -  
16 -import java.util.ArrayList;  
17 -import java.util.List;  
18 -  
19 -/**  
20 - * 视频流session管理器,管理视频预览、预览回放的通信句柄  
21 - */  
22 -@Component  
23 -public class VideoStreamSessionManager {  
24 -  
25 - @Autowired  
26 - private UserSetting userSetting;  
27 -  
28 - @Autowired  
29 - private RedisTemplate<Object, Object> redisTemplate;  
30 -  
31 - /**  
32 - * 添加一个点播/回放的事务信息  
33 - * 后续可以通过流Id/callID  
34 - * @param deviceId 设备ID  
35 - * @param channelId 通道ID  
36 - * @param callId 一次请求的CallID  
37 - * @param stream 流名称  
38 - * @param mediaServerId 所使用的流媒体ID  
39 - * @param response 回复  
40 - */  
41 - public void put(String deviceId, String channelId, String callId, String stream, String ssrc, String mediaServerId, SIPResponse response, InviteSessionType type){  
42 - SsrcTransaction ssrcTransaction = new SsrcTransaction();  
43 - ssrcTransaction.setDeviceId(deviceId);  
44 - ssrcTransaction.setChannelId(channelId);  
45 - ssrcTransaction.setStream(stream);  
46 - ssrcTransaction.setSipTransactionInfo(new SipTransactionInfo(response));  
47 - ssrcTransaction.setCallId(callId);  
48 - ssrcTransaction.setSsrc(ssrc);  
49 - ssrcTransaction.setMediaServerId(mediaServerId);  
50 - ssrcTransaction.setType(type);  
51 -  
52 - redisTemplate.opsForValue().set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()  
53 - + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction);  
54 - }  
55 -  
56 - public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){  
57 -  
58 - if (ObjectUtils.isEmpty(deviceId)) {  
59 - deviceId ="*";  
60 - }  
61 - if (ObjectUtils.isEmpty(channelId)) {  
62 - channelId ="*";  
63 - }  
64 - if (ObjectUtils.isEmpty(callId)) {  
65 - callId ="*";  
66 - }  
67 - if (ObjectUtils.isEmpty(stream)) {  
68 - stream ="*";  
69 - }  
70 - String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;  
71 - List<Object> scanResult = RedisUtil.scan(redisTemplate, key);  
72 - if (scanResult.size() == 0) {  
73 - return null;  
74 - }  
75 - return (SsrcTransaction)redisTemplate.opsForValue().get(scanResult.get(0));  
76 - }  
77 -  
78 - public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){  
79 - if (ObjectUtils.isEmpty(deviceId)) {  
80 - deviceId ="*";  
81 - }  
82 - if (ObjectUtils.isEmpty(channelId)) {  
83 - channelId ="*";  
84 - }  
85 - if (ObjectUtils.isEmpty(callId)) {  
86 - callId ="*";  
87 - }  
88 - if (ObjectUtils.isEmpty(stream)) {  
89 - stream ="*";  
90 - }  
91 - String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;  
92 - List<Object> scanResult = RedisUtil.scan(redisTemplate, key);  
93 - if (scanResult.size() == 0) {  
94 - return null;  
95 - }  
96 - List<SsrcTransaction> result = new ArrayList<>();  
97 - for (Object keyObj : scanResult) {  
98 - result.add((SsrcTransaction)redisTemplate.opsForValue().get(keyObj));  
99 - }  
100 - return result;  
101 - }  
102 -  
103 - public String getMediaServerId(String deviceId, String channelId, String stream){  
104 - SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);  
105 - if (ssrcTransaction == null) {  
106 - return null;  
107 - }  
108 - return ssrcTransaction.getMediaServerId();  
109 - }  
110 -  
111 - public String getSSRC(String deviceId, String channelId, String stream){  
112 - SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);  
113 - if (ssrcTransaction == null) {  
114 - return null;  
115 - }  
116 - return ssrcTransaction.getSsrc();  
117 - }  
118 -  
119 - public void remove(String deviceId, String channelId, String stream) {  
120 - SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);  
121 - if (ssrcTransaction == null) {  
122 - return;  
123 - }  
124 - redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_"  
125 - + deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream());  
126 - }  
127 -  
128 -  
129 - public List<SsrcTransaction> getAllSsrc() {  
130 - List<Object> ssrcTransactionKeys = RedisUtil.scan(redisTemplate, String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId()));  
131 - List<SsrcTransaction> result= new ArrayList<>();  
132 - for (Object ssrcTransactionKey : ssrcTransactionKeys) {  
133 - String key = (String) ssrcTransactionKey;  
134 - SsrcTransaction ssrcTransaction = JsonUtil.redisJsonToObject(redisTemplate, key, SsrcTransaction.class);  
135 - result.add(ssrcTransaction);  
136 - }  
137 - return result;  
138 - }  
139 -} 1 +package com.genersoft.iot.vmp.gb28181.session;
  2 +
  3 +import com.genersoft.iot.vmp.common.InviteSessionType;
  4 +import com.genersoft.iot.vmp.common.VideoManagerConstants;
  5 +import com.genersoft.iot.vmp.conf.UserSetting;
  6 +import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
  7 +import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
  8 +import com.genersoft.iot.vmp.utils.JsonUtil;
  9 +import com.genersoft.iot.vmp.utils.redis.RedisUtil;
  10 +import gov.nist.javax.sip.message.SIPResponse;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.data.redis.core.RedisTemplate;
  13 +import org.springframework.stereotype.Component;
  14 +import org.springframework.util.ObjectUtils;
  15 +
  16 +import java.util.ArrayList;
  17 +import java.util.List;
  18 +
  19 +/**
  20 + * 视频流session管理器,管理视频预览、预览回放的通信句柄
  21 + */
  22 +@Component
  23 +public class VideoStreamSessionManager {
  24 +
  25 + @Autowired
  26 + private UserSetting userSetting;
  27 +
  28 + @Autowired
  29 + private RedisTemplate<Object, Object> redisTemplate;
  30 +
  31 + /**
  32 + * 添加一个点播/回放的事务信息
  33 + * 后续可以通过流Id/callID
  34 + * @param deviceId 设备ID
  35 + * @param channelId 通道ID
  36 + * @param callId 一次请求的CallID
  37 + * @param stream 流名称
  38 + * @param mediaServerId 所使用的流媒体ID
  39 + * @param response 回复
  40 + */
  41 + public void put(String deviceId, String channelId, String callId, String stream, String ssrc, String mediaServerId, SIPResponse response, InviteSessionType type){
  42 + SsrcTransaction ssrcTransaction = new SsrcTransaction();
  43 + ssrcTransaction.setDeviceId(deviceId);
  44 + ssrcTransaction.setChannelId(channelId);
  45 + ssrcTransaction.setStream(stream);
  46 + ssrcTransaction.setSipTransactionInfo(new SipTransactionInfo(response));
  47 + ssrcTransaction.setCallId(callId);
  48 + ssrcTransaction.setSsrc(ssrc);
  49 + ssrcTransaction.setMediaServerId(mediaServerId);
  50 + ssrcTransaction.setType(type);
  51 +
  52 + redisTemplate.opsForValue().set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
  53 + + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction);
  54 + }
  55 +
  56 + public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
  57 +
  58 + if (ObjectUtils.isEmpty(deviceId)) {
  59 + deviceId ="*";
  60 + }
  61 + if (ObjectUtils.isEmpty(channelId)) {
  62 + channelId ="*";
  63 + }
  64 + if (ObjectUtils.isEmpty(callId)) {
  65 + callId ="*";
  66 + }
  67 + if (ObjectUtils.isEmpty(stream)) {
  68 + stream ="*";
  69 + }
  70 + String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
  71 + List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
  72 + if (scanResult.size() == 0) {
  73 + return null;
  74 + }
  75 + return (SsrcTransaction)redisTemplate.opsForValue().get(scanResult.get(0));
  76 + }
  77 +
  78 + public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){
  79 + if (ObjectUtils.isEmpty(deviceId)) {
  80 + deviceId ="*";
  81 + }
  82 + if (ObjectUtils.isEmpty(channelId)) {
  83 + channelId ="*";
  84 + }
  85 + if (ObjectUtils.isEmpty(callId)) {
  86 + callId ="*";
  87 + }
  88 + if (ObjectUtils.isEmpty(stream)) {
  89 + stream ="*";
  90 + }
  91 + String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
  92 + List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
  93 + if (scanResult.size() == 0) {
  94 + return null;
  95 + }
  96 + List<SsrcTransaction> result = new ArrayList<>();
  97 + for (Object keyObj : scanResult) {
  98 + result.add((SsrcTransaction)redisTemplate.opsForValue().get(keyObj));
  99 + }
  100 + return result;
  101 + }
  102 +
  103 + public String getMediaServerId(String deviceId, String channelId, String stream){
  104 + SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
  105 + if (ssrcTransaction == null) {
  106 + return null;
  107 + }
  108 + return ssrcTransaction.getMediaServerId();
  109 + }
  110 +
  111 + public String getSSRC(String deviceId, String channelId, String stream){
  112 + SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
  113 + if (ssrcTransaction == null) {
  114 + return null;
  115 + }
  116 + return ssrcTransaction.getSsrc();
  117 + }
  118 +
  119 + public void remove(String deviceId, String channelId, String stream) {
  120 + SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
  121 + if (ssrcTransaction == null) {
  122 + return;
  123 + }
  124 + redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_"
  125 + + deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream());
  126 + }
  127 +
  128 +
  129 + public List<SsrcTransaction> getAllSsrc() {
  130 + List<Object> ssrcTransactionKeys = RedisUtil.scan(redisTemplate, String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId()));
  131 + List<SsrcTransaction> result= new ArrayList<>();
  132 + for (Object ssrcTransactionKey : ssrcTransactionKeys) {
  133 + String key = (String) ssrcTransactionKey;
  134 + SsrcTransaction ssrcTransaction = JsonUtil.redisJsonToObject(redisTemplate, key, SsrcTransaction.class);
  135 + result.add(ssrcTransaction);
  136 + }
  137 + return result;
  138 + }
  139 +}
src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java 100644 → 100755
@@ -12,13 +12,19 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; @@ -12,13 +12,19 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
12 import com.genersoft.iot.vmp.service.IDeviceService; 12 import com.genersoft.iot.vmp.service.IDeviceService;
13 import com.genersoft.iot.vmp.service.IMediaServerService; 13 import com.genersoft.iot.vmp.service.IMediaServerService;
14 import com.genersoft.iot.vmp.service.IPlatformService; 14 import com.genersoft.iot.vmp.service.IPlatformService;
  15 +import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl;
15 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 16 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
16 import com.genersoft.iot.vmp.storager.IVideoManagerStorage; 17 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
  18 +import org.slf4j.Logger;
  19 +import org.slf4j.LoggerFactory;
17 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.boot.CommandLineRunner; 21 import org.springframework.boot.CommandLineRunner;
19 import org.springframework.core.annotation.Order; 22 import org.springframework.core.annotation.Order;
20 import org.springframework.stereotype.Component; 23 import org.springframework.stereotype.Component;
21 24
  25 +import javax.sip.InvalidArgumentException;
  26 +import javax.sip.SipException;
  27 +import java.text.ParseException;
22 import java.util.HashMap; 28 import java.util.HashMap;
23 import java.util.List; 29 import java.util.List;
24 import java.util.Map; 30 import java.util.Map;
@@ -59,6 +65,8 @@ public class SipRunner implements CommandLineRunner { @@ -59,6 +65,8 @@ public class SipRunner implements CommandLineRunner {
59 @Autowired 65 @Autowired
60 private ISIPCommanderForPlatform commanderForPlatform; 66 private ISIPCommanderForPlatform commanderForPlatform;
61 67
  68 + private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class);
  69 +
62 @Override 70 @Override
63 public void run(String... args) throws Exception { 71 public void run(String... args) throws Exception {
64 List<Device> deviceList = deviceService.getAllOnlineDevice(); 72 List<Device> deviceList = deviceService.getAllOnlineDevice();
@@ -110,7 +118,11 @@ public class SipRunner implements CommandLineRunner { @@ -110,7 +118,11 @@ public class SipRunner implements CommandLineRunner {
110 if (jsonObject != null && jsonObject.getInteger("code") == 0) { 118 if (jsonObject != null && jsonObject.getInteger("code") == 0) {
111 ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId()); 119 ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
112 if (platform != null) { 120 if (platform != null) {
113 - commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId()); 121 + try {
  122 + commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId());
  123 + } catch (InvalidArgumentException | ParseException | SipException e) {
  124 + logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
  125 + }
114 } 126 }
115 } 127 }
116 } 128 }
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java 100644 → 100755
1 -package com.genersoft.iot.vmp.gb28181.transmit.callback;  
2 -  
3 -import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;  
4 -import org.springframework.stereotype.Component;  
5 -import org.springframework.util.ObjectUtils;  
6 -import org.springframework.web.context.request.async.DeferredResult;  
7 -  
8 -import java.util.Collection;  
9 -import java.util.Map;  
10 -import java.util.Set;  
11 -import java.util.concurrent.ConcurrentHashMap;  
12 -  
13 -/**  
14 - * @description: 异步请求处理  
15 - * @author: swwheihei  
16 - * @date: 2020年5月8日 下午7:59:05  
17 - */  
18 -@SuppressWarnings(value = {"rawtypes", "unchecked"})  
19 -@Component  
20 -public class DeferredResultHolder {  
21 -  
22 - public static final String CALLBACK_CMD_DEVICESTATUS = "CALLBACK_DEVICESTATUS";  
23 -  
24 - public static final String CALLBACK_CMD_DEVICEINFO = "CALLBACK_DEVICEINFO";  
25 -  
26 - public static final String CALLBACK_CMD_DEVICECONTROL = "CALLBACK_DEVICECONTROL";  
27 -  
28 - public static final String CALLBACK_CMD_DEVICECONFIG = "CALLBACK_DEVICECONFIG";  
29 -  
30 - public static final String CALLBACK_CMD_CONFIGDOWNLOAD = "CALLBACK_CONFIGDOWNLOAD";  
31 -  
32 - public static final String CALLBACK_CMD_CATALOG = "CALLBACK_CATALOG";  
33 -  
34 - public static final String CALLBACK_CMD_RECORDINFO = "CALLBACK_RECORDINFO";  
35 -  
36 - public static final String CALLBACK_CMD_PLAY = "CALLBACK_PLAY";  
37 -  
38 - public static final String CALLBACK_CMD_PLAYBACK = "CALLBACK_PLAYBACK";  
39 -  
40 - public static final String CALLBACK_CMD_DOWNLOAD = "CALLBACK_DOWNLOAD";  
41 -  
42 - public static final String CALLBACK_CMD_PROXY = "CALLBACK_PROXY";  
43 -  
44 - public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP";  
45 -  
46 - public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL";  
47 -  
48 - public static final String CALLBACK_CMD_MOBILE_POSITION = "CALLBACK_CMD_MOBILE_POSITION";  
49 -  
50 - public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY";  
51 -  
52 - public static final String CALLBACK_CMD_ALARM = "CALLBACK_ALARM";  
53 -  
54 - public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST";  
55 -  
56 - public static final String CALLBACK_CMD_SNAP= "CALLBACK_SNAP";  
57 -  
58 - private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>();  
59 -  
60 -  
61 - public void put(String key, String id, DeferredResultEx result) {  
62 - Map<String, DeferredResultEx> deferredResultMap = map.get(key);  
63 - if (deferredResultMap == null) {  
64 - deferredResultMap = new ConcurrentHashMap<>();  
65 - map.put(key, deferredResultMap);  
66 - }  
67 - deferredResultMap.put(id, result);  
68 - }  
69 -  
70 - public void put(String key, String id, DeferredResult result) {  
71 - Map<String, DeferredResultEx> deferredResultMap = map.get(key);  
72 - if (deferredResultMap == null) {  
73 - deferredResultMap = new ConcurrentHashMap<>();  
74 - map.put(key, deferredResultMap);  
75 - }  
76 - deferredResultMap.put(id, new DeferredResultEx(result));  
77 - }  
78 -  
79 - public DeferredResultEx get(String key, String id) {  
80 - Map<String, DeferredResultEx> deferredResultMap = map.get(key);  
81 - if (deferredResultMap == null || ObjectUtils.isEmpty(id)) {  
82 - return null;  
83 - }  
84 - return deferredResultMap.get(id);  
85 - }  
86 -  
87 - public Collection<DeferredResultEx> getAllByKey(String key) {  
88 - Map<String, DeferredResultEx> deferredResultMap = map.get(key);  
89 - if (deferredResultMap == null) {  
90 - return null;  
91 - }  
92 - return deferredResultMap.values();  
93 - }  
94 -  
95 - public boolean exist(String key, String id){  
96 - if (key == null) {  
97 - return false;  
98 - }  
99 - Map<String, DeferredResultEx> deferredResultMap = map.get(key);  
100 - if (id == null) {  
101 - return deferredResultMap != null;  
102 - }else {  
103 - return deferredResultMap != null && deferredResultMap.get(id) != null;  
104 - }  
105 - }  
106 -  
107 - /**  
108 - * 释放单个请求  
109 - * @param msg  
110 - */  
111 - public void invokeResult(RequestMessage msg) {  
112 - Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());  
113 - if (deferredResultMap == null) {  
114 - return;  
115 - }  
116 - DeferredResultEx result = deferredResultMap.get(msg.getId());  
117 - if (result == null) {  
118 - return;  
119 - }  
120 - result.getDeferredResult().setResult(msg.getData());  
121 - deferredResultMap.remove(msg.getId());  
122 - if (deferredResultMap.size() == 0) {  
123 - map.remove(msg.getKey());  
124 - }  
125 - }  
126 -  
127 - /**  
128 - * 释放所有的请求  
129 - * @param msg  
130 - */  
131 - public void invokeAllResult(RequestMessage msg) {  
132 - Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());  
133 - if (deferredResultMap == null) {  
134 - return;  
135 - }  
136 - synchronized (this) {  
137 - deferredResultMap = map.get(msg.getKey());  
138 - if (deferredResultMap == null) {  
139 - return;  
140 - }  
141 - Set<String> ids = deferredResultMap.keySet();  
142 - for (String id : ids) {  
143 - DeferredResultEx result = deferredResultMap.get(id);  
144 - if (result == null) {  
145 - return;  
146 - }  
147 - if (result.getFilter() != null) {  
148 - Object handler = result.getFilter().handler(msg.getData());  
149 - result.getDeferredResult().setResult(handler);  
150 - }else {  
151 - result.getDeferredResult().setResult(msg.getData());  
152 - }  
153 -  
154 - }  
155 - map.remove(msg.getKey());  
156 - }  
157 - }  
158 -  
159 -  
160 -} 1 +package com.genersoft.iot.vmp.gb28181.transmit.callback;
  2 +
  3 +import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
  4 +import org.springframework.stereotype.Component;
  5 +import org.springframework.util.ObjectUtils;
  6 +import org.springframework.web.context.request.async.DeferredResult;
  7 +
  8 +import java.util.Collection;
  9 +import java.util.Map;
  10 +import java.util.Set;
  11 +import java.util.concurrent.ConcurrentHashMap;
  12 +
  13 +/**
  14 + * @description: 异步请求处理
  15 + * @author: swwheihei
  16 + * @date: 2020年5月8日 下午7:59:05
  17 + */
  18 +@SuppressWarnings(value = {"rawtypes", "unchecked"})
  19 +@Component
  20 +public class DeferredResultHolder {
  21 +
  22 + public static final String CALLBACK_CMD_DEVICESTATUS = "CALLBACK_DEVICESTATUS";
  23 +
  24 + public static final String CALLBACK_CMD_DEVICEINFO = "CALLBACK_DEVICEINFO";
  25 +
  26 + public static final String CALLBACK_CMD_DEVICECONTROL = "CALLBACK_DEVICECONTROL";
  27 +
  28 + public static final String CALLBACK_CMD_DEVICECONFIG = "CALLBACK_DEVICECONFIG";
  29 +
  30 + public static final String CALLBACK_CMD_CONFIGDOWNLOAD = "CALLBACK_CONFIGDOWNLOAD";
  31 +
  32 + public static final String CALLBACK_CMD_CATALOG = "CALLBACK_CATALOG";
  33 +
  34 + public static final String CALLBACK_CMD_RECORDINFO = "CALLBACK_RECORDINFO";
  35 +
  36 + public static final String CALLBACK_CMD_PLAY = "CALLBACK_PLAY";
  37 +
  38 + public static final String CALLBACK_CMD_PLAYBACK = "CALLBACK_PLAYBACK";
  39 +
  40 + public static final String CALLBACK_CMD_DOWNLOAD = "CALLBACK_DOWNLOAD";
  41 +
  42 + public static final String CALLBACK_CMD_PROXY = "CALLBACK_PROXY";
  43 +
  44 + public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP";
  45 +
  46 + public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL";
  47 +
  48 + public static final String CALLBACK_CMD_MOBILE_POSITION = "CALLBACK_CMD_MOBILE_POSITION";
  49 +
  50 + public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY";
  51 +
  52 + public static final String CALLBACK_CMD_ALARM = "CALLBACK_ALARM";
  53 +
  54 + public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST";
  55 +
  56 + public static final String CALLBACK_CMD_SNAP= "CALLBACK_SNAP";
  57 +
  58 + private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>();
  59 +
  60 +
  61 + public void put(String key, String id, DeferredResultEx result) {
  62 + Map<String, DeferredResultEx> deferredResultMap = map.get(key);
  63 + if (deferredResultMap == null) {
  64 + deferredResultMap = new ConcurrentHashMap<>();
  65 + map.put(key, deferredResultMap);
  66 + }
  67 + deferredResultMap.put(id, result);
  68 + }
  69 +
  70 + public void put(String key, String id, DeferredResult result) {
  71 + Map<String, DeferredResultEx> deferredResultMap = map.get(key);
  72 + if (deferredResultMap == null) {
  73 + deferredResultMap = new ConcurrentHashMap<>();
  74 + map.put(key, deferredResultMap);
  75 + }
  76 + deferredResultMap.put(id, new DeferredResultEx(result));
  77 + }
  78 +
  79 + public DeferredResultEx get(String key, String id) {
  80 + Map<String, DeferredResultEx> deferredResultMap = map.get(key);
  81 + if (deferredResultMap == null || ObjectUtils.isEmpty(id)) {
  82 + return null;
  83 + }
  84 + return deferredResultMap.get(id);
  85 + }
  86 +
  87 + public Collection<DeferredResultEx> getAllByKey(String key) {
  88 + Map<String, DeferredResultEx> deferredResultMap = map.get(key);
  89 + if (deferredResultMap == null) {
  90 + return null;
  91 + }
  92 + return deferredResultMap.values();
  93 + }
  94 +
  95 + public boolean exist(String key, String id){
  96 + if (key == null) {
  97 + return false;
  98 + }
  99 + Map<String, DeferredResultEx> deferredResultMap = map.get(key);
  100 + if (id == null) {
  101 + return deferredResultMap != null;
  102 + }else {
  103 + return deferredResultMap != null && deferredResultMap.get(id) != null;
  104 + }
  105 + }
  106 +
  107 + /**
  108 + * 释放单个请求
  109 + * @param msg
  110 + */
  111 + public void invokeResult(RequestMessage msg) {
  112 + Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());
  113 + if (deferredResultMap == null) {
  114 + return;
  115 + }
  116 + DeferredResultEx result = deferredResultMap.get(msg.getId());
  117 + if (result == null) {
  118 + return;
  119 + }
  120 + result.getDeferredResult().setResult(msg.getData());
  121 + deferredResultMap.remove(msg.getId());
  122 + if (deferredResultMap.size() == 0) {
  123 + map.remove(msg.getKey());
  124 + }
  125 + }
  126 +
  127 + /**
  128 + * 释放所有的请求
  129 + * @param msg
  130 + */
  131 + public void invokeAllResult(RequestMessage msg) {
  132 + Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());
  133 + if (deferredResultMap == null) {
  134 + return;
  135 + }
  136 + synchronized (this) {
  137 + deferredResultMap = map.get(msg.getKey());
  138 + if (deferredResultMap == null) {
  139 + return;
  140 + }
  141 + Set<String> ids = deferredResultMap.keySet();
  142 + for (String id : ids) {
  143 + DeferredResultEx result = deferredResultMap.get(id);
  144 + if (result == null) {
  145 + return;
  146 + }
  147 + if (result.getFilter() != null) {
  148 + Object handler = result.getFilter().handler(msg.getData());
  149 + result.getDeferredResult().setResult(handler);
  150 + }else {
  151 + result.getDeferredResult().setResult(msg.getData());
  152 + }
  153 +
  154 + }
  155 + map.remove(msg.getKey());
  156 + }
  157 + }
  158 +
  159 +
  160 +}
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java 100644 → 100755
1 -package com.genersoft.iot.vmp.gb28181.transmit.callback;  
2 -  
3 -/**  
4 - * @description: 请求信息定义  
5 - * @author: swwheihei  
6 - * @date: 2020年5月8日 下午1:09:18  
7 - */  
8 -public class RequestMessage {  
9 -  
10 - private String id;  
11 -  
12 - private String key;  
13 -  
14 - private Object data;  
15 -  
16 - public String getId() {  
17 - return id;  
18 - }  
19 -  
20 - public void setId(String id) {  
21 - this.id = id;  
22 - }  
23 -  
24 - public void setKey(String key) {  
25 - this.key = key;  
26 - }  
27 -  
28 - public String getKey() {  
29 - return key;  
30 - }  
31 -  
32 - public Object getData() {  
33 - return data;  
34 - }  
35 -  
36 - public void setData(Object data) {  
37 - this.data = data;  
38 - }  
39 -} 1 +package com.genersoft.iot.vmp.gb28181.transmit.callback;
  2 +
  3 +/**
  4 + * @description: 请求信息定义
  5 + * @author: swwheihei
  6 + * @date: 2020年5月8日 下午1:09:18
  7 + */
  8 +public class RequestMessage {
  9 +
  10 + private String id;
  11 +
  12 + private String key;
  13 +
  14 + private Object data;
  15 +
  16 + public String getId() {
  17 + return id;
  18 + }
  19 +
  20 + public void setId(String id) {
  21 + this.id = id;
  22 + }
  23 +
  24 + public void setKey(String key) {
  25 + this.key = key;
  26 + }
  27 +
  28 + public String getKey() {
  29 + return key;
  30 + }
  31 +
  32 + public Object getData() {
  33 + return data;
  34 + }
  35 +
  36 + public void setData(Object data) {
  37 + this.data = data;
  38 + }
  39 +}
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java 100644 → 100755
1 -package com.genersoft.iot.vmp.gb28181.transmit.cmd;  
2 -  
3 -import com.genersoft.iot.vmp.common.StreamInfo;  
4 -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;  
5 -import com.genersoft.iot.vmp.gb28181.bean.*;  
6 -import com.genersoft.iot.vmp.gb28181.bean.Device;  
7 -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;  
8 -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;  
9 -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;  
10 -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;  
11 -import com.genersoft.iot.vmp.service.bean.SSRCInfo;  
12 -import gov.nist.javax.sip.message.SIPRequest;  
13 -  
14 -import javax.sip.InvalidArgumentException;  
15 -import javax.sip.SipException;  
16 -import java.text.ParseException;  
17 -  
18 -/**  
19 - * @description:设备能力接口,用于定义设备的控制、查询能力  
20 - * @author: swwheihei  
21 - * @date: 2020年5月3日 下午9:16:34  
22 - */  
23 -public interface ISIPCommander {  
24 -  
25 - /**  
26 - * 云台方向放控制,使用配置文件中的默认镜头移动速度  
27 - *  
28 - * @param device 控制设备  
29 - * @param channelId 预览通道  
30 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移  
31 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移  
32 - */  
33 - void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException;  
34 -  
35 - /**  
36 - * 云台方向放控制  
37 - *  
38 - * @param device 控制设备  
39 - * @param channelId 预览通道  
40 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移  
41 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移  
42 - * @param moveSpeed 镜头移动速度  
43 - */  
44 - void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;  
45 -  
46 - /**  
47 - * 云台缩放控制,使用配置文件中的默认镜头缩放速度  
48 - *  
49 - * @param device 控制设备  
50 - * @param channelId 预览通道  
51 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大  
52 - */  
53 - void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException;  
54 -  
55 - /**  
56 - * 云台缩放控制  
57 - *  
58 - * @param device 控制设备  
59 - * @param channelId 预览通道  
60 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大  
61 - */  
62 - void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;  
63 -  
64 - /**  
65 - * 云台控制,支持方向与缩放控制  
66 - *  
67 - * @param device 控制设备  
68 - * @param channelId 预览通道  
69 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移  
70 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移  
71 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大  
72 - * @param moveSpeed 镜头移动速度  
73 - * @param zoomSpeed 镜头缩放速度  
74 - */  
75 - void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException;  
76 -  
77 - /**  
78 - * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令  
79 - *  
80 - * @param device 控制设备  
81 - * @param channelId 预览通道  
82 - * @param cmdCode 指令码  
83 - * @param parameter1 数据1  
84 - * @param parameter2 数据2  
85 - * @param combineCode2 组合码2  
86 - */  
87 - void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException;  
88 -  
89 - /**  
90 - * 前端控制指令(用于转发上级指令)  
91 - * @param device 控制设备  
92 - * @param channelId 预览通道  
93 - * @param cmdString 前端控制指令串  
94 - */  
95 - void fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
96 -  
97 - /**  
98 - * 请求预览视频流  
99 - * @param device 视频设备  
100 - * @param channelId 预览通道  
101 - */  
102 - void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
103 -  
104 - /**  
105 - * 请求回放视频流  
106 - *  
107 - * @param device 视频设备  
108 - * @param channelId 预览通道  
109 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss  
110 - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss  
111 - */  
112 - void playbackStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInf, Device device, String channelId, String startTime, String endTime,ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
113 -  
114 - /**  
115 - * 请求历史媒体下载  
116 - *  
117 - * @param device 视频设备  
118 - * @param channelId 预览通道  
119 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss  
120 - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss  
121 - * @param downloadSpeed 下载倍速参数  
122 - */  
123 - void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,  
124 - String startTime, String endTime, int downloadSpeed, ZlmHttpHookSubscribe.Event hookEvent,  
125 - SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
126 -  
127 -  
128 - /**  
129 - * 视频流停止  
130 - */  
131 - void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;  
132 -  
133 - void talkStreamCmd(MediaServerItem mediaServerItem, SendRtpItem sendRtpItem, Device device, String channelId, String callId, ZlmHttpHookSubscribe.Event event, ZlmHttpHookSubscribe.Event eventForPush, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
134 -  
135 -  
136 - void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;  
137 -  
138 - void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;  
139 -  
140 - /**  
141 - * 回放暂停  
142 - */  
143 - void playPauseCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;  
144 -  
145 - /**  
146 - * 回放恢复  
147 - */  
148 - void playResumeCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;  
149 -  
150 - /**  
151 - * 回放拖动播放  
152 - */  
153 - void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) throws InvalidArgumentException, ParseException, SipException;  
154 -  
155 - /**  
156 - * 回放倍速播放  
157 - */  
158 - void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException;  
159 -  
160 - /**  
161 - * 回放控制  
162 - * @param device  
163 - * @param streamInfo  
164 - * @param content  
165 - */  
166 - void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException;  
167 -  
168 -  
169 - /**  
170 - * /**  
171 - * 语音广播  
172 - *  
173 - * @param device 视频设备  
174 - */  
175 - void audioBroadcastCmd(Device device, String channelId, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
176 -  
177 - /**  
178 - * 音视频录像控制  
179 - *  
180 - * @param device 视频设备  
181 - * @param channelId 预览通道  
182 - * @param recordCmdStr 录像命令:Record / StopRecord  
183 - */  
184 - void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
185 -  
186 - /**  
187 - * 远程启动控制命令  
188 - *  
189 - * @param device 视频设备  
190 - */  
191 - void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException;  
192 -  
193 - /**  
194 - * 报警布防/撤防命令  
195 - *  
196 - * @param device 视频设备  
197 - */  
198 - void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
199 -  
200 - /**  
201 - * 报警复位命令  
202 - *  
203 - * @param device 视频设备  
204 - * @param alarmMethod 报警方式(可选)  
205 - * @param alarmType 报警类型(可选)  
206 - */  
207 - void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
208 -  
209 - /**  
210 - * 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧  
211 - *  
212 - * @param device 视频设备  
213 - * @param channelId 预览通道  
214 - */  
215 - void iFrameCmd(Device device, String channelId) throws InvalidArgumentException, SipException, ParseException;  
216 -  
217 - /**  
218 - * 看守位控制命令  
219 - *  
220 - * @param device 视频设备  
221 - * @param channelId 通道id,非通道则是设备本身  
222 - * @param enabled 看守位使能:1 = 开启,0 = 关闭  
223 - * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s)  
224 - * @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255  
225 - */  
226 - void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
227 -  
228 - /**  
229 - * 设备配置命令  
230 - *  
231 - * @param device 视频设备  
232 - */  
233 - void deviceConfigCmd(Device device);  
234 -  
235 - /**  
236 - * 设备配置命令:basicParam  
237 - *  
238 - * @param device 视频设备  
239 - * @param channelId 通道编码(可选)  
240 - * @param name 设备/通道名称(可选)  
241 - * @param expiration 注册过期时间(可选)  
242 - * @param heartBeatInterval 心跳间隔时间(可选)  
243 - * @param heartBeatCount 心跳超时次数(可选)  
244 - */  
245 - void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
246 -  
247 - /**  
248 - * 查询设备状态  
249 - *  
250 - * @param device 视频设备  
251 - */  
252 - void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
253 -  
254 - /**  
255 - * 查询设备信息  
256 - *  
257 - * @param device 视频设备  
258 - * @return  
259 - */  
260 - void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException;  
261 -  
262 - /**  
263 - * 查询目录列表  
264 - *  
265 - * @param device 视频设备  
266 - */  
267 - void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException;  
268 -  
269 - /**  
270 - * 查询录像信息  
271 - *  
272 - * @param device 视频设备  
273 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss  
274 - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss  
275 - * @param sn  
276 - */  
277 - void recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer Secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
278 -  
279 - /**  
280 - * 查询报警信息  
281 - *  
282 - * @param device 视频设备  
283 - * @param startPriority 报警起始级别(可选)  
284 - * @param endPriority 报警终止级别(可选)  
285 - * @param alarmMethod 报警方式条件(可选)  
286 - * @param alarmType 报警类型  
287 - * @param startTime 报警发生起始时间(可选)  
288 - * @param endTime 报警发生终止时间(可选)  
289 - * @return true = 命令发送成功  
290 - */  
291 - void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod,  
292 - String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
293 -  
294 - /**  
295 - * 查询设备配置  
296 - *  
297 - * @param device 视频设备  
298 - * @param channelId 通道编码(可选)  
299 - * @param configType 配置类型:  
300 - */  
301 - void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
302 -  
303 - /**  
304 - * 查询设备预置位置  
305 - *  
306 - * @param device 视频设备  
307 - */  
308 - void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
309 -  
310 - /**  
311 - * 查询移动设备位置数据  
312 - *  
313 - * @param device 视频设备  
314 - */  
315 - void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
316 -  
317 - /**  
318 - * 订阅、取消订阅移动位置  
319 - *  
320 - * @param device 视频设备  
321 - * @return true = 命令发送成功  
322 - */  
323 - SIPRequest mobilePositionSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent , SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
324 -  
325 - /**  
326 - * 订阅、取消订阅报警信息  
327 - * @param device 视频设备  
328 - * @param expires 订阅过期时间(0 = 取消订阅)  
329 - * @param startPriority 报警起始级别(可选)  
330 - * @param endPriority 报警终止级别(可选)  
331 - * @param alarmType 报警类型  
332 - * @param startTime 报警发生起始时间(可选)  
333 - * @param endTime 报警发生终止时间(可选)  
334 - * @return true = 命令发送成功  
335 - */  
336 - void alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String startTime, String endTime) throws InvalidArgumentException, SipException, ParseException;  
337 -  
338 - /**  
339 - * 订阅、取消订阅目录信息  
340 - * @param device 视频设备  
341 - * @return true = 命令发送成功  
342 - */  
343 - SIPRequest catalogSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
344 -  
345 - /**  
346 - * 拉框控制命令  
347 - *  
348 - * @param device 控制设备  
349 - * @param channelId 通道id  
350 - * @param cmdString 前端控制指令串  
351 - */  
352 - void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException;  
353 -  
354 -  
355 - /**  
356 - * 向设备发送报警NOTIFY消息, 用于互联结构下,此时将设备当成一个平级平台看待  
357 - * @param device 设备  
358 - * @param deviceAlarm 报警信息信息  
359 - * @return  
360 - */  
361 - void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException;  
362 -  
363 -  
364 -} 1 +package com.genersoft.iot.vmp.gb28181.transmit.cmd;
  2 +
  3 +import com.genersoft.iot.vmp.common.StreamInfo;
  4 +import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
  5 +import com.genersoft.iot.vmp.gb28181.bean.*;
  6 +import com.genersoft.iot.vmp.gb28181.bean.Device;
  7 +import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
  8 +import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
  9 +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
  10 +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
  11 +import com.genersoft.iot.vmp.service.bean.SSRCInfo;
  12 +import gov.nist.javax.sip.message.SIPRequest;
  13 +
  14 +import javax.sip.InvalidArgumentException;
  15 +import javax.sip.SipException;
  16 +import java.text.ParseException;
  17 +
  18 +/**
  19 + * @description:设备能力接口,用于定义设备的控制、查询能力
  20 + * @author: swwheihei
  21 + * @date: 2020年5月3日 下午9:16:34
  22 + */
  23 +public interface ISIPCommander {
  24 +
  25 + /**
  26 + * 云台方向放控制,使用配置文件中的默认镜头移动速度
  27 + *
  28 + * @param device 控制设备
  29 + * @param channelId 预览通道
  30 + * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
  31 + * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
  32 + */
  33 + void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException;
  34 +
  35 + /**
  36 + * 云台方向放控制
  37 + *
  38 + * @param device 控制设备
  39 + * @param channelId 预览通道
  40 + * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
  41 + * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
  42 + * @param moveSpeed 镜头移动速度
  43 + */
  44 + void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;
  45 +
  46 + /**
  47 + * 云台缩放控制,使用配置文件中的默认镜头缩放速度
  48 + *
  49 + * @param device 控制设备
  50 + * @param channelId 预览通道
  51 + * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
  52 + */
  53 + void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException;
  54 +
  55 + /**
  56 + * 云台缩放控制
  57 + *
  58 + * @param device 控制设备
  59 + * @param channelId 预览通道
  60 + * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
  61 + */
  62 + void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;
  63 +
  64 + /**
  65 + * 云台控制,支持方向与缩放控制
  66 + *
  67 + * @param device 控制设备
  68 + * @param channelId 预览通道
  69 + * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
  70 + * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
  71 + * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
  72 + * @param moveSpeed 镜头移动速度
  73 + * @param zoomSpeed 镜头缩放速度
  74 + */
  75 + void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException;
  76 +
  77 + /**
  78 + * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令
  79 + *
  80 + * @param device 控制设备
  81 + * @param channelId 预览通道
  82 + * @param cmdCode 指令码
  83 + * @param parameter1 数据1
  84 + * @param parameter2 数据2
  85 + * @param combineCode2 组合码2
  86 + */
  87 + void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException;
  88 +
  89 + /**
  90 + * 前端控制指令(用于转发上级指令)
  91 + * @param device 控制设备
  92 + * @param channelId 预览通道
  93 + * @param cmdString 前端控制指令串
  94 + */
  95 + void fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  96 +
  97 + /**
  98 + * 请求预览视频流
  99 + * @param device 视频设备
  100 + * @param channelId 预览通道
  101 + */
  102 + void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  103 +
  104 + /**
  105 + * 请求回放视频流
  106 + *
  107 + * @param device 视频设备
  108 + * @param channelId 预览通道
  109 + * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
  110 + * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
  111 + */
  112 + void playbackStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInf, Device device, String channelId, String startTime, String endTime,ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  113 +
  114 + /**
  115 + * 请求历史媒体下载
  116 + *
  117 + * @param device 视频设备
  118 + * @param channelId 预览通道
  119 + * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
  120 + * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
  121 + * @param downloadSpeed 下载倍速参数
  122 + */
  123 + void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
  124 + String startTime, String endTime, int downloadSpeed, ZlmHttpHookSubscribe.Event hookEvent,
  125 + SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  126 +
  127 +
  128 + /**
  129 + * 视频流停止
  130 + */
  131 + void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
  132 +
  133 + void talkStreamCmd(MediaServerItem mediaServerItem, SendRtpItem sendRtpItem, Device device, String channelId, String callId, ZlmHttpHookSubscribe.Event event, ZlmHttpHookSubscribe.Event eventForPush, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  134 +
  135 +
  136 + void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
  137 +
  138 + void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
  139 +
  140 + /**
  141 + * 回放暂停
  142 + */
  143 + void playPauseCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;
  144 +
  145 + /**
  146 + * 回放恢复
  147 + */
  148 + void playResumeCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;
  149 +
  150 + /**
  151 + * 回放拖动播放
  152 + */
  153 + void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) throws InvalidArgumentException, ParseException, SipException;
  154 +
  155 + /**
  156 + * 回放倍速播放
  157 + */
  158 + void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException;
  159 +
  160 + /**
  161 + * 回放控制
  162 + * @param device
  163 + * @param streamInfo
  164 + * @param content
  165 + */
  166 + void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException;
  167 +
  168 +
  169 + /**
  170 + * /**
  171 + * 语音广播
  172 + *
  173 + * @param device 视频设备
  174 + */
  175 + void audioBroadcastCmd(Device device, String channelId, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  176 +
  177 + /**
  178 + * 音视频录像控制
  179 + *
  180 + * @param device 视频设备
  181 + * @param channelId 预览通道
  182 + * @param recordCmdStr 录像命令:Record / StopRecord
  183 + */
  184 + void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  185 +
  186 + /**
  187 + * 远程启动控制命令
  188 + *
  189 + * @param device 视频设备
  190 + */
  191 + void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException;
  192 +
  193 + /**
  194 + * 报警布防/撤防命令
  195 + *
  196 + * @param device 视频设备
  197 + */
  198 + void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  199 +
  200 + /**
  201 + * 报警复位命令
  202 + *
  203 + * @param device 视频设备
  204 + * @param alarmMethod 报警方式(可选)
  205 + * @param alarmType 报警类型(可选)
  206 + */
  207 + void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  208 +
  209 + /**
  210 + * 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧
  211 + *
  212 + * @param device 视频设备
  213 + * @param channelId 预览通道
  214 + */
  215 + void iFrameCmd(Device device, String channelId) throws InvalidArgumentException, SipException, ParseException;
  216 +
  217 + /**
  218 + * 看守位控制命令
  219 + *
  220 + * @param device 视频设备
  221 + * @param channelId 通道id,非通道则是设备本身
  222 + * @param enabled 看守位使能:1 = 开启,0 = 关闭
  223 + * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s)
  224 + * @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255
  225 + */
  226 + void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  227 +
  228 + /**
  229 + * 设备配置命令
  230 + *
  231 + * @param device 视频设备
  232 + */
  233 + void deviceConfigCmd(Device device);
  234 +
  235 + /**
  236 + * 设备配置命令:basicParam
  237 + *
  238 + * @param device 视频设备
  239 + * @param channelId 通道编码(可选)
  240 + * @param name 设备/通道名称(可选)
  241 + * @param expiration 注册过期时间(可选)
  242 + * @param heartBeatInterval 心跳间隔时间(可选)
  243 + * @param heartBeatCount 心跳超时次数(可选)
  244 + */
  245 + void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  246 +
  247 + /**
  248 + * 查询设备状态
  249 + *
  250 + * @param device 视频设备
  251 + */
  252 + void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  253 +
  254 + /**
  255 + * 查询设备信息
  256 + *
  257 + * @param device 视频设备
  258 + * @return
  259 + */
  260 + void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException;
  261 +
  262 + /**
  263 + * 查询目录列表
  264 + *
  265 + * @param device 视频设备
  266 + */
  267 + void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException;
  268 +
  269 + /**
  270 + * 查询录像信息
  271 + *
  272 + * @param device 视频设备
  273 + * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
  274 + * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
  275 + * @param sn
  276 + */
  277 + void recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer Secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  278 +
  279 + /**
  280 + * 查询报警信息
  281 + *
  282 + * @param device 视频设备
  283 + * @param startPriority 报警起始级别(可选)
  284 + * @param endPriority 报警终止级别(可选)
  285 + * @param alarmMethod 报警方式条件(可选)
  286 + * @param alarmType 报警类型
  287 + * @param startTime 报警发生起始时间(可选)
  288 + * @param endTime 报警发生终止时间(可选)
  289 + * @return true = 命令发送成功
  290 + */
  291 + void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod,
  292 + String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  293 +
  294 + /**
  295 + * 查询设备配置
  296 + *
  297 + * @param device 视频设备
  298 + * @param channelId 通道编码(可选)
  299 + * @param configType 配置类型:
  300 + */
  301 + void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  302 +
  303 + /**
  304 + * 查询设备预置位置
  305 + *
  306 + * @param device 视频设备
  307 + */
  308 + void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  309 +
  310 + /**
  311 + * 查询移动设备位置数据
  312 + *
  313 + * @param device 视频设备
  314 + */
  315 + void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  316 +
  317 + /**
  318 + * 订阅、取消订阅移动位置
  319 + *
  320 + * @param device 视频设备
  321 + * @return true = 命令发送成功
  322 + */
  323 + SIPRequest mobilePositionSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent , SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  324 +
  325 + /**
  326 + * 订阅、取消订阅报警信息
  327 + * @param device 视频设备
  328 + * @param expires 订阅过期时间(0 = 取消订阅)
  329 + * @param startPriority 报警起始级别(可选)
  330 + * @param endPriority 报警终止级别(可选)
  331 + * @param alarmType 报警类型
  332 + * @param startTime 报警发生起始时间(可选)
  333 + * @param endTime 报警发生终止时间(可选)
  334 + * @return true = 命令发送成功
  335 + */
  336 + void alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String startTime, String endTime) throws InvalidArgumentException, SipException, ParseException;
  337 +
  338 + /**
  339 + * 订阅、取消订阅目录信息
  340 + * @param device 视频设备
  341 + * @return true = 命令发送成功
  342 + */
  343 + SIPRequest catalogSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  344 +
  345 + /**
  346 + * 拉框控制命令
  347 + *
  348 + * @param device 控制设备
  349 + * @param channelId 通道id
  350 + * @param cmdString 前端控制指令串
  351 + */
  352 + void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException;
  353 +
  354 +
  355 + /**
  356 + * 向设备发送报警NOTIFY消息, 用于互联结构下,此时将设备当成一个平级平台看待
  357 + * @param device 设备
  358 + * @param deviceAlarm 报警信息信息
  359 + * @return
  360 + */
  361 + void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException;
  362 +
  363 +
  364 +}
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java 100644 → 100755
@@ -25,6 +25,8 @@ public interface ISIPCommanderForPlatform { @@ -25,6 +25,8 @@ public interface ISIPCommanderForPlatform {
25 void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException; 25 void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException;
26 26
27 void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException; 27 void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException;
  28 +
  29 +
28 void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, WWWAuthenticateHeader www, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean isRegister) throws SipException, InvalidArgumentException, ParseException; 30 void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, WWWAuthenticateHeader www, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean isRegister) throws SipException, InvalidArgumentException, ParseException;
29 31
30 /** 32 /**
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/ISIPRequestProcessor.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/CancelRequestProcessor.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java 100644 → 100755
@@ -21,10 +21,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; @@ -21,10 +21,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory;
21 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; 21 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
22 import com.genersoft.iot.vmp.media.zlm.dto.*; 22 import com.genersoft.iot.vmp.media.zlm.dto.*;
23 import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; 23 import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
24 -import com.genersoft.iot.vmp.service.IMediaServerService;  
25 -import com.genersoft.iot.vmp.service.IPlayService;  
26 -import com.genersoft.iot.vmp.service.IStreamProxyService;  
27 -import com.genersoft.iot.vmp.service.IStreamPushService; 24 +import com.genersoft.iot.vmp.service.*;
28 import com.genersoft.iot.vmp.service.bean.ErrorCallback; 25 import com.genersoft.iot.vmp.service.bean.ErrorCallback;
29 import com.genersoft.iot.vmp.service.bean.InviteErrorCode; 26 import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
30 import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; 27 import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
@@ -84,6 +81,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -84,6 +81,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
84 private IRedisCatchStorage redisCatchStorage; 81 private IRedisCatchStorage redisCatchStorage;
85 82
86 @Autowired 83 @Autowired
  84 + private IInviteStreamService inviteStreamService;
  85 +
  86 + @Autowired
87 private SSRCFactory ssrcFactory; 87 private SSRCFactory ssrcFactory;
88 88
89 @Autowired 89 @Autowired
@@ -518,10 +518,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -518,10 +518,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
518 errorEvent.run(code, msg, data); 518 errorEvent.run(code, msg, data);
519 } 519 }
520 }); 520 });
521 - }else { 521 + } else {
522 522
523 SSRCInfo ssrcInfo = playService.play(mediaServerItem, device.getDeviceId(), channelId, ssrc, ((code, msg, data) -> { 523 SSRCInfo ssrcInfo = playService.play(mediaServerItem, device.getDeviceId(), channelId, ssrc, ((code, msg, data) -> {
524 - if (code == InviteErrorCode.SUCCESS.getCode()){ 524 + if (code == InviteErrorCode.SUCCESS.getCode()) {
525 hookEvent.run(code, msg, data); 525 hookEvent.run(code, msg, data);
526 } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) { 526 } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) {
527 logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); 527 logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId);
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java 100644 → 100755
@@ -132,7 +132,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements @@ -132,7 +132,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
132 132
133 if (CmdType.CATALOG.equals(cmd)) { 133 if (CmdType.CATALOG.equals(cmd)) {
134 logger.info("接收到Catalog通知"); 134 logger.info("接收到Catalog通知");
135 -// processNotifyCatalogList(take.getEvt()); 135 + processNotifyCatalogList(take.getEvt());
136 notifyRequestForCatalogProcessor.process(take.getEvt()); 136 notifyRequestForCatalogProcessor.process(take.getEvt());
137 } else if (CmdType.ALARM.equals(cmd)) { 137 } else if (CmdType.ALARM.equals(cmd)) {
138 logger.info("接收到Alarm通知"); 138 logger.info("接收到Alarm通知");
@@ -319,6 +319,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements @@ -319,6 +319,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
319 logger.info("[收到Notify-Alarm]:{}/{}", device.getDeviceId(), deviceAlarm.getChannelId()); 319 logger.info("[收到Notify-Alarm]:{}/{}", device.getDeviceId(), deviceAlarm.getChannelId());
320 if ("4".equals(deviceAlarm.getAlarmMethod())) { 320 if ("4".equals(deviceAlarm.getAlarmMethod())) {
321 MobilePosition mobilePosition = new MobilePosition(); 321 MobilePosition mobilePosition = new MobilePosition();
  322 + mobilePosition.setChannelId(channelId);
322 mobilePosition.setCreateTime(DateUtil.getNow()); 323 mobilePosition.setCreateTime(DateUtil.getNow());
323 mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); 324 mobilePosition.setDeviceId(deviceAlarm.getDeviceId());
324 mobilePosition.setTime(deviceAlarm.getAlarmTime()); 325 mobilePosition.setTime(deviceAlarm.getAlarmTime());
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java 100644 → 100755
@@ -88,7 +88,11 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen @@ -88,7 +88,11 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
88 Response response = null; 88 Response response = null;
89 boolean passwordCorrect = false; 89 boolean passwordCorrect = false;
90 // 注册标志 90 // 注册标志
91 - boolean registerFlag; 91 + boolean registerFlag = true;
  92 + if (request.getExpires().getExpires() == 0) {
  93 + // 注销成功
  94 + registerFlag = false;
  95 + }
92 FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME); 96 FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME);
93 AddressImpl address = (AddressImpl) fromHeader.getAddress(); 97 AddressImpl address = (AddressImpl) fromHeader.getAddress();
94 SipUri uri = (SipUri) address.getURI(); 98 SipUri uri = (SipUri) address.getURI();
@@ -99,11 +103,12 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen @@ -99,11 +103,12 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
99 RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request, 103 RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request,
100 userSetting.getSipUseSourceIpAsRemoteAddress()); 104 userSetting.getSipUseSourceIpAsRemoteAddress());
101 String requestAddress = remoteAddressInfo.getIp() + ":" + remoteAddressInfo.getPort(); 105 String requestAddress = remoteAddressInfo.getIp() + ":" + remoteAddressInfo.getPort();
102 - logger.info("[注册请求] 设备:{}, 开始处理: {}", deviceId, requestAddress); 106 + String title = registerFlag ? "[注册请求]": "[注销请求]";
  107 + logger.info(title + "设备:{}, 开始处理: {}", deviceId, requestAddress);
103 if (device != null && 108 if (device != null &&
104 device.getSipTransactionInfo() != null && 109 device.getSipTransactionInfo() != null &&
105 request.getCallIdHeader().getCallId().equals(device.getSipTransactionInfo().getCallId())) { 110 request.getCallIdHeader().getCallId().equals(device.getSipTransactionInfo().getCallId())) {
106 - logger.info("[注册请求] 设备:{}, 注册续订: {}",device.getDeviceId(), device.getDeviceId()); 111 + logger.info(title + "设备:{}, 注册续订: {}",device.getDeviceId(), device.getDeviceId());
107 device.setExpires(request.getExpires().getExpires()); 112 device.setExpires(request.getExpires().getExpires());
108 device.setIp(remoteAddressInfo.getIp()); 113 device.setIp(remoteAddressInfo.getIp());
109 device.setPort(remoteAddressInfo.getPort()); 114 device.setPort(remoteAddressInfo.getPort());
@@ -123,7 +128,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen @@ -123,7 +128,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
123 String password = (device != null && !ObjectUtils.isEmpty(device.getPassword()))? device.getPassword() : sipConfig.getPassword(); 128 String password = (device != null && !ObjectUtils.isEmpty(device.getPassword()))? device.getPassword() : sipConfig.getPassword();
124 AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); 129 AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME);
125 if (authHead == null && !ObjectUtils.isEmpty(password)) { 130 if (authHead == null && !ObjectUtils.isEmpty(password)) {
126 - logger.info("[注册请求] 设备:{}, 回复401: {}",deviceId, requestAddress); 131 + logger.info(title + " 设备:{}, 回复401: {}",deviceId, requestAddress);
127 response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); 132 response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
128 new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); 133 new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain());
129 sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); 134 sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
@@ -138,7 +143,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen @@ -138,7 +143,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
138 // 注册失败 143 // 注册失败
139 response = getMessageFactory().createResponse(Response.FORBIDDEN, request); 144 response = getMessageFactory().createResponse(Response.FORBIDDEN, request);
140 response.setReasonPhrase("wrong password"); 145 response.setReasonPhrase("wrong password");
141 - logger.info("[注册请求] 设备:{}, 密码/SIP服务器ID错误, 回复403: {}", deviceId, requestAddress); 146 + logger.info(title + " 设备:{}, 密码/SIP服务器ID错误, 回复403: {}", deviceId, requestAddress);
142 sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); 147 sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
143 return; 148 return;
144 } 149 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java 100644 → 100755
1 -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.info;  
2 -  
3 -import com.genersoft.iot.vmp.common.InviteInfo;  
4 -import com.genersoft.iot.vmp.common.InviteSessionType;  
5 -import com.genersoft.iot.vmp.gb28181.bean.*;  
6 -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;  
7 -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;  
8 -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;  
9 -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;  
10 -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;  
11 -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;  
12 -import com.genersoft.iot.vmp.gb28181.utils.SipUtils;  
13 -import com.genersoft.iot.vmp.service.IInviteStreamService;  
14 -import com.genersoft.iot.vmp.storager.IRedisCatchStorage;  
15 -import com.genersoft.iot.vmp.storager.IVideoManagerStorage;  
16 -import gov.nist.javax.sip.message.SIPRequest;  
17 -import org.slf4j.Logger;  
18 -import org.slf4j.LoggerFactory;  
19 -import org.springframework.beans.factory.InitializingBean;  
20 -import org.springframework.beans.factory.annotation.Autowired;  
21 -import org.springframework.stereotype.Component;  
22 -  
23 -import javax.sip.InvalidArgumentException;  
24 -import javax.sip.RequestEvent;  
25 -import javax.sip.SipException;  
26 -import javax.sip.header.CallIdHeader;  
27 -import javax.sip.header.ContentTypeHeader;  
28 -import javax.sip.message.Response;  
29 -import java.text.ParseException;  
30 -  
31 -@Component  
32 -public class InfoRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {  
33 -  
34 - private final static Logger logger = LoggerFactory.getLogger(InfoRequestProcessor.class);  
35 -  
36 - private final String method = "INFO";  
37 -  
38 - @Autowired  
39 - private SIPProcessorObserver sipProcessorObserver;  
40 -  
41 - @Autowired  
42 - private IVideoManagerStorage storage;  
43 -  
44 - @Autowired  
45 - private SipSubscribe sipSubscribe;  
46 -  
47 - @Autowired  
48 - private IRedisCatchStorage redisCatchStorage;  
49 -  
50 - @Autowired  
51 - private IInviteStreamService inviteStreamService;  
52 -  
53 - @Autowired  
54 - private IVideoManagerStorage storager;  
55 -  
56 - @Autowired  
57 - private SIPCommander cmder;  
58 -  
59 - @Autowired  
60 - private VideoStreamSessionManager sessionManager;  
61 -  
62 - @Override  
63 - public void afterPropertiesSet() throws Exception {  
64 - // 添加消息处理的订阅  
65 - sipProcessorObserver.addRequestProcessor(method, this);  
66 - }  
67 -  
68 - @Override  
69 - public void process(RequestEvent evt) {  
70 - logger.debug("接收到消息:" + evt.getRequest());  
71 - SIPRequest request = (SIPRequest) evt.getRequest();  
72 - String deviceId = SipUtils.getUserIdFromFromHeader(request);  
73 - CallIdHeader callIdHeader = request.getCallIdHeader();  
74 - // 先从会话内查找  
75 - SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);  
76 -  
77 - // 兼容海康 媒体通知 消息from字段不是设备ID的问题  
78 - if (ssrcTransaction != null) {  
79 - deviceId = ssrcTransaction.getDeviceId();  
80 - }  
81 - // 查询设备是否存在  
82 - Device device = redisCatchStorage.getDevice(deviceId);  
83 - // 查询上级平台是否存在  
84 - ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId);  
85 - try {  
86 - if (device != null && parentPlatform != null) {  
87 - logger.warn("[重复]平台与设备编号重复:{}", deviceId);  
88 - String hostAddress = request.getRemoteAddress().getHostAddress();  
89 - int remotePort = request.getRemotePort();  
90 - if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) {  
91 - parentPlatform = null;  
92 - }else {  
93 - device = null;  
94 - }  
95 - }  
96 - if (device == null && parentPlatform == null) {  
97 - // 不存在则回复404  
98 - responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found");  
99 - logger.warn("[设备未找到 ]: {}", deviceId);  
100 - if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){  
101 - DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog());  
102 - deviceNotFoundEvent.setCallId(callIdHeader.getCallId());  
103 - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(deviceNotFoundEvent);  
104 - sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult);  
105 - };  
106 - }else {  
107 - ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME);  
108 - String contentType = header.getContentType();  
109 - String contentSubType = header.getContentSubType();  
110 - if ("Application".equalsIgnoreCase(contentType) && "MANSRTSP".equalsIgnoreCase(contentSubType)) {  
111 - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());  
112 - String streamId = sendRtpItem.getStream();  
113 - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId);  
114 - if (null == inviteInfo) {  
115 - responseAck(request, Response.NOT_FOUND, "stream " + streamId + " not found");  
116 - return;  
117 - }  
118 - Device device1 = storager.queryVideoDevice(inviteInfo.getDeviceId());  
119 - if (inviteInfo.getStreamInfo() != null) {  
120 - cmder.playbackControlCmd(device1,inviteInfo.getStreamInfo(),new String(evt.getRequest().getRawContent()),eventResult -> {  
121 - // 失败的回复  
122 - try {  
123 - responseAck(request, eventResult.statusCode, eventResult.msg);  
124 - } catch (SipException | InvalidArgumentException | ParseException e) {  
125 - logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage());  
126 - }  
127 - }, eventResult -> {  
128 - // 成功的回复  
129 - try {  
130 - responseAck(request, eventResult.statusCode);  
131 - } catch (SipException | InvalidArgumentException | ParseException e) {  
132 - logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage());  
133 - }  
134 - });  
135 - }  
136 -  
137 - }  
138 - }  
139 - } catch (SipException e) {  
140 - logger.warn("SIP 回复错误", e);  
141 - } catch (InvalidArgumentException e) {  
142 - logger.warn("参数无效", e);  
143 - } catch (ParseException e) {  
144 - logger.warn("SIP回复时解析异常", e);  
145 - }  
146 - }  
147 -  
148 -  
149 -} 1 +package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.info;
  2 +
  3 +import com.genersoft.iot.vmp.common.InviteInfo;
  4 +import com.genersoft.iot.vmp.common.InviteSessionType;
  5 +import com.genersoft.iot.vmp.gb28181.bean.*;
  6 +import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
  7 +import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
  8 +import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
  9 +import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
  10 +import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
  11 +import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
  12 +import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
  13 +import com.genersoft.iot.vmp.service.IInviteStreamService;
  14 +import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  15 +import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
  16 +import gov.nist.javax.sip.message.SIPRequest;
  17 +import org.slf4j.Logger;
  18 +import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.InitializingBean;
  20 +import org.springframework.beans.factory.annotation.Autowired;
  21 +import org.springframework.stereotype.Component;
  22 +
  23 +import javax.sip.InvalidArgumentException;
  24 +import javax.sip.RequestEvent;
  25 +import javax.sip.SipException;
  26 +import javax.sip.header.CallIdHeader;
  27 +import javax.sip.header.ContentTypeHeader;
  28 +import javax.sip.message.Response;
  29 +import java.text.ParseException;
  30 +
  31 +@Component
  32 +public class InfoRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {
  33 +
  34 + private final static Logger logger = LoggerFactory.getLogger(InfoRequestProcessor.class);
  35 +
  36 + private final String method = "INFO";
  37 +
  38 + @Autowired
  39 + private SIPProcessorObserver sipProcessorObserver;
  40 +
  41 + @Autowired
  42 + private IVideoManagerStorage storage;
  43 +
  44 + @Autowired
  45 + private SipSubscribe sipSubscribe;
  46 +
  47 + @Autowired
  48 + private IRedisCatchStorage redisCatchStorage;
  49 +
  50 + @Autowired
  51 + private IInviteStreamService inviteStreamService;
  52 +
  53 + @Autowired
  54 + private IVideoManagerStorage storager;
  55 +
  56 + @Autowired
  57 + private SIPCommander cmder;
  58 +
  59 + @Autowired
  60 + private VideoStreamSessionManager sessionManager;
  61 +
  62 + @Override
  63 + public void afterPropertiesSet() throws Exception {
  64 + // 添加消息处理的订阅
  65 + sipProcessorObserver.addRequestProcessor(method, this);
  66 + }
  67 +
  68 + @Override
  69 + public void process(RequestEvent evt) {
  70 + logger.debug("接收到消息:" + evt.getRequest());
  71 + SIPRequest request = (SIPRequest) evt.getRequest();
  72 + String deviceId = SipUtils.getUserIdFromFromHeader(request);
  73 + CallIdHeader callIdHeader = request.getCallIdHeader();
  74 + // 先从会话内查找
  75 + SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
  76 +
  77 + // 兼容海康 媒体通知 消息from字段不是设备ID的问题
  78 + if (ssrcTransaction != null) {
  79 + deviceId = ssrcTransaction.getDeviceId();
  80 + }
  81 + // 查询设备是否存在
  82 + Device device = redisCatchStorage.getDevice(deviceId);
  83 + // 查询上级平台是否存在
  84 + ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId);
  85 + try {
  86 + if (device != null && parentPlatform != null) {
  87 + logger.warn("[重复]平台与设备编号重复:{}", deviceId);
  88 + String hostAddress = request.getRemoteAddress().getHostAddress();
  89 + int remotePort = request.getRemotePort();
  90 + if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) {
  91 + parentPlatform = null;
  92 + }else {
  93 + device = null;
  94 + }
  95 + }
  96 + if (device == null && parentPlatform == null) {
  97 + // 不存在则回复404
  98 + responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found");
  99 + logger.warn("[设备未找到 ]: {}", deviceId);
  100 + if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){
  101 + DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog());
  102 + deviceNotFoundEvent.setCallId(callIdHeader.getCallId());
  103 + SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(deviceNotFoundEvent);
  104 + sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult);
  105 + };
  106 + }else {
  107 + ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME);
  108 + String contentType = header.getContentType();
  109 + String contentSubType = header.getContentSubType();
  110 + if ("Application".equalsIgnoreCase(contentType) && "MANSRTSP".equalsIgnoreCase(contentSubType)) {
  111 + SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());
  112 + String streamId = sendRtpItem.getStream();
  113 + InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId);
  114 + if (null == inviteInfo) {
  115 + responseAck(request, Response.NOT_FOUND, "stream " + streamId + " not found");
  116 + return;
  117 + }
  118 + Device device1 = storager.queryVideoDevice(inviteInfo.getDeviceId());
  119 + if (inviteInfo.getStreamInfo() != null) {
  120 + cmder.playbackControlCmd(device1,inviteInfo.getStreamInfo(),new String(evt.getRequest().getRawContent()),eventResult -> {
  121 + // 失败的回复
  122 + try {
  123 + responseAck(request, eventResult.statusCode, eventResult.msg);
  124 + } catch (SipException | InvalidArgumentException | ParseException e) {
  125 + logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage());
  126 + }
  127 + }, eventResult -> {
  128 + // 成功的回复
  129 + try {
  130 + responseAck(request, eventResult.statusCode);
  131 + } catch (SipException | InvalidArgumentException | ParseException e) {
  132 + logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage());
  133 + }
  134 + });
  135 + }
  136 +
  137 + }
  138 + }
  139 + } catch (SipException e) {
  140 + logger.warn("SIP 回复错误", e);
  141 + } catch (InvalidArgumentException e) {
  142 + logger.warn("参数无效", e);
  143 + } catch (ParseException e) {
  144 + logger.warn("SIP回复时解析异常", e);
  145 + }
  146 + }
  147 +
  148 +
  149 +}
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/IMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java 100644 → 100755
@@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message;
3 import com.genersoft.iot.vmp.gb28181.bean.Device; 3 import com.genersoft.iot.vmp.gb28181.bean.Device;
4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; 4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
5 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; 5 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
6 -import gov.nist.javax.sip.message.SIPRequest;  
7 import org.dom4j.Element; 6 import org.dom4j.Element;
8 import org.slf4j.Logger; 7 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory; 8 import org.slf4j.LoggerFactory;
@@ -24,6 +23,9 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i @@ -24,6 +23,9 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
24 23
25 public Map<String, IMessageHandler> messageHandlerMap = new ConcurrentHashMap<>(); 24 public Map<String, IMessageHandler> messageHandlerMap = new ConcurrentHashMap<>();
26 25
  26 + @Autowired
  27 + private IVideoManagerStorage storage;
  28 +
27 public void addHandler(String cmdType, IMessageHandler messageHandler) { 29 public void addHandler(String cmdType, IMessageHandler messageHandler) {
28 messageHandlerMap.put(cmdType, messageHandler); 30 messageHandlerMap.put(cmdType, messageHandler);
29 } 31 }
@@ -40,7 +42,15 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i @@ -40,7 +42,15 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
40 return; 42 return;
41 } 43 }
42 IMessageHandler messageHandler = messageHandlerMap.get(cmd); 44 IMessageHandler messageHandler = messageHandlerMap.get(cmd);
  45 +
43 if (messageHandler != null) { 46 if (messageHandler != null) {
  47 + //两个国标平台互相级联时由于上一步判断导致本该在平台处理的消息 放到了设备的处理逻辑
  48 + //所以对目录查询单独做了校验
  49 + if(messageHandler instanceof CatalogQueryMessageHandler){
  50 + ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(device.getDeviceId());
  51 + messageHandler.handForPlatform(evt, parentPlatform, element);
  52 + return;
  53 + }
44 messageHandler.handForDevice(evt, device, element); 54 messageHandler.handForDevice(evt, device, element);
45 } 55 }
46 } 56 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/ControlMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/NotifyMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java 100644 → 100755
@@ -137,6 +137,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme @@ -137,6 +137,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
137 MobilePosition mobilePosition = new MobilePosition(); 137 MobilePosition mobilePosition = new MobilePosition();
138 mobilePosition.setCreateTime(DateUtil.getNow()); 138 mobilePosition.setCreateTime(DateUtil.getNow());
139 mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); 139 mobilePosition.setDeviceId(deviceAlarm.getDeviceId());
  140 + mobilePosition.setChannelId(channelId);
140 mobilePosition.setTime(deviceAlarm.getAlarmTime()); 141 mobilePosition.setTime(deviceAlarm.getAlarmTime());
141 mobilePosition.setLongitude(deviceAlarm.getLongitude()); 142 mobilePosition.setLongitude(deviceAlarm.getLongitude());
142 mobilePosition.setLatitude(deviceAlarm.getLatitude()); 143 mobilePosition.setLatitude(deviceAlarm.getLatitude());
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java 100644 → 100755
@@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; @@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
13 import com.genersoft.iot.vmp.service.IDeviceService; 13 import com.genersoft.iot.vmp.service.IDeviceService;
14 import com.genersoft.iot.vmp.utils.DateUtil; 14 import com.genersoft.iot.vmp.utils.DateUtil;
15 import gov.nist.javax.sip.message.SIPRequest; 15 import gov.nist.javax.sip.message.SIPRequest;
  16 +import org.apache.commons.lang3.ObjectUtils;
16 import org.dom4j.Element; 17 import org.dom4j.Element;
17 import org.slf4j.Logger; 18 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory; 19 import org.slf4j.LoggerFactory;
@@ -68,7 +69,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp @@ -68,7 +69,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
68 } catch (SipException | InvalidArgumentException | ParseException e) { 69 } catch (SipException | InvalidArgumentException | ParseException e) {
69 logger.error("[命令发送失败] 心跳回复: {}", e.getMessage()); 70 logger.error("[命令发送失败] 心跳回复: {}", e.getMessage());
70 } 71 }
71 - if (device.getKeepaliveTime() != null && DateUtil.getDifferenceForNow(device.getKeepaliveTime()) <= 3000L){ 72 + if (!ObjectUtils.isEmpty(device.getKeepaliveTime()) && DateUtil.getDifferenceForNow(device.getKeepaliveTime()) <= 3000L) {
72 logger.info("[收到心跳] 心跳发送过于频繁,已忽略 device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); 73 logger.info("[收到心跳] 心跳发送过于频繁,已忽略 device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId());
73 return; 74 return;
74 } 75 }
@@ -109,7 +110,11 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp @@ -109,7 +110,11 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
109 110
110 @Override 111 @Override
111 public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { 112 public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) {
112 - // 不会收到上级平台的心跳信息  
113 - 113 + // 个别平台保活不回复200OK会判定离线
  114 + try {
  115 + responseAck((SIPRequest) evt.getRequest(), Response.OK);
  116 + } catch (SipException | InvalidArgumentException | ParseException e) {
  117 + logger.error("[命令发送失败] 心跳回复: {}", e.getMessage());
  118 + }
114 } 119 }
115 } 120 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/QueryMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/ResponseMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java 100644 → 100755
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java 100644 → 100755
@@ -30,6 +30,7 @@ import java.util.ArrayList; @@ -30,6 +30,7 @@ import java.util.ArrayList;
30 import java.util.Iterator; 30 import java.util.Iterator;
31 import java.util.List; 31 import java.util.List;
32 import java.util.concurrent.ConcurrentLinkedQueue; 32 import java.util.concurrent.ConcurrentLinkedQueue;
  33 +import java.util.concurrent.atomic.AtomicBoolean;
33 34
34 /** 35 /**
35 * 目录查询的回复 36 * 目录查询的回复
@@ -61,6 +62,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp @@ -61,6 +62,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
61 62
62 @Autowired 63 @Autowired
63 private SipConfig sipConfig; 64 private SipConfig sipConfig;
  65 + private AtomicBoolean processing = new AtomicBoolean(false);
64 66
65 @Override 67 @Override
66 public void afterPropertiesSet() throws Exception { 68 public void afterPropertiesSet() throws Exception {
@@ -69,7 +71,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp @@ -69,7 +71,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
69 71
70 @Override 72 @Override
71 public void handForDevice(RequestEvent evt, Device device, Element element) { 73 public void handForDevice(RequestEvent evt, Device device, Element element) {
72 - boolean isEmpty = taskQueue.isEmpty();  
73 taskQueue.offer(new HandlerCatchData(evt, device, element)); 74 taskQueue.offer(new HandlerCatchData(evt, device, element));
74 // 回复200 OK 75 // 回复200 OK
75 try { 76 try {
@@ -77,8 +78,8 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp @@ -77,8 +78,8 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
77 } catch (SipException | InvalidArgumentException | ParseException e) { 78 } catch (SipException | InvalidArgumentException | ParseException e) {
78 logger.error("[命令发送失败] 目录查询回复: {}", e.getMessage()); 79 logger.error("[命令发送失败] 目录查询回复: {}", e.getMessage());
79 } 80 }
80 - // 如果不为空则说明已经开启消息处理  
81 - if (isEmpty) { 81 + // 已经开启消息处理则跳过
  82 + if (processing.compareAndSet(false, true)) {
82 taskExecutor.execute(() -> { 83 taskExecutor.execute(() -> {
83 while (!taskQueue.isEmpty()) { 84 while (!taskQueue.isEmpty()) {
84 // 全局异常捕获,保证下一条可以得到处理 85 // 全局异常捕获,保证下一条可以得到处理
@@ -147,11 +148,12 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp @@ -147,11 +148,12 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
147 } 148 }
148 149
149 } 150 }
150 - }catch (Exception e) { 151 + } catch (Exception e) {
151 logger.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest()); 152 logger.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest());
152 logger.error("[收到通道] 异常内容: ", e); 153 logger.error("[收到通道] 异常内容: ", e);
153 } 154 }
154 } 155 }
  156 + processing.set(false);
155 }); 157 });
156 } 158 }
157 159
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java 100644 → 100755