Commit d0ef68af3fad9592c7bd9e61ed97244cd4a93e59

Authored by ChengHong
Committed by GitHub
2 parents bac19f58 9a64be46

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

Showing 63 changed files with 1985 additions and 1962 deletions

Too many changes to show.

To preserve performance only 63 of 359 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 -  
72 - public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";  
73 -  
74 -  
75 -  
76 -  
77 - //************************** redis 消息*********************************  
78 -  
79 - /**  
80 - * 流变化的通知  
81 - */  
82 - public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";  
83 -  
84 - /**  
85 - * 接收推流设备的GPS变化通知  
86 - */  
87 - public static final String VM_MSG_GPS = "VM_MSG_GPS";  
88 -  
89 - /**  
90 - * 接收推流设备的GPS变化通知  
91 - */  
92 - public static final String VM_MSG_PUSH_STREAM_STATUS_CHANGE = "VM_MSG_PUSH_STREAM_STATUS_CHANGE";  
93 - /**  
94 - * 接收推流设备列表更新变化通知  
95 - */  
96 - public static final String VM_MSG_PUSH_STREAM_LIST_CHANGE = "VM_MSG_PUSH_STREAM_LIST_CHANGE";  
97 -  
98 - /**  
99 - * redis 消息通知设备推流到平台  
100 - */  
101 - public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED";  
102 -  
103 - /**  
104 - * redis 消息通知上级平台开始观看流  
105 - */  
106 - public static final String VM_MSG_STREAM_START_PLAY_NOTIFY = "VM_MSG_STREAM_START_PLAY_NOTIFY";  
107 -  
108 - /**  
109 - * redis 消息通知上级平台停止观看流  
110 - */  
111 - public static final String VM_MSG_STREAM_STOP_PLAY_NOTIFY = "VM_MSG_STREAM_STOP_PLAY_NOTIFY";  
112 -  
113 - /**  
114 - * redis 消息接收关闭一个推流  
115 - */  
116 - public static final String VM_MSG_STREAM_PUSH_CLOSE_REQUESTED = "VM_MSG_STREAM_PUSH_CLOSE_REQUESTED";  
117 -  
118 -  
119 - /**  
120 - * redis 消息通知平台通知设备推流结果  
121 - */  
122 - public static final String VM_MSG_STREAM_PUSH_RESPONSE = "VM_MSG_STREAM_PUSH_RESPONSE";  
123 -  
124 - /**  
125 - * redis 通知平台关闭推流  
126 - */  
127 - public static final String VM_MSG_STREAM_PUSH_CLOSE = "VM_MSG_STREAM_PUSH_CLOSE";  
128 -  
129 - /**  
130 - * redis 消息请求所有的在线通道  
131 - */  
132 - public static final String VM_MSG_GET_ALL_ONLINE_REQUESTED = "VM_MSG_GET_ALL_ONLINE_REQUESTED";  
133 -  
134 - /**  
135 - * 移动位置订阅通知  
136 - */  
137 - public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition";  
138 -  
139 - /**  
140 - * 报警订阅的通知(收到报警向redis发出通知)  
141 - */  
142 - public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm";  
143 -  
144 -  
145 - /**  
146 - * 报警通知的发送 (收到redis发出的通知,转发给其他平台)  
147 - */  
148 - public static final String VM_MSG_SUBSCRIBE_ALARM_RECEIVE= "alarm_receive";  
149 -  
150 - /**  
151 - * 设备状态订阅的通知  
152 - */  
153 - public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device";  
154 -  
155 -  
156 - //************************** 第三方 ****************************************  
157 -  
158 - public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";  
159 - public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_";  
160 - public static final String WVP_OTHER_SEND_RTP_INFO = "VMP_OTHER_SEND_RTP_INFO_";  
161 - public static final String WVP_OTHER_SEND_PS_INFO = "VMP_OTHER_SEND_PS_INFO_";  
162 - public static final String WVP_OTHER_RECEIVE_RTP_INFO = "VMP_OTHER_RECEIVE_RTP_INFO_";  
163 - public static final String WVP_OTHER_RECEIVE_PS_INFO = "VMP_OTHER_RECEIVE_PS_INFO_";  
164 -  
165 - /**  
166 - * Redis Const  
167 - * 设备录像信息结果前缀  
168 - */  
169 - public static final String REDIS_RECORD_INFO_RES_PRE = "GB_RECORD_INFO_RES_";  
170 - /**  
171 - * Redis Const  
172 - * 设备录像信息结果前缀  
173 - */  
174 - public static final String REDIS_RECORD_INFO_RES_COUNT_PRE = "GB_RECORD_INFO_RES_COUNT:";  
175 -  
176 -} 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 +
  72 + public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";
  73 +
  74 +
  75 +
  76 +
  77 + //************************** redis 消息*********************************
  78 +
  79 + /**
  80 + * 流变化的通知
  81 + */
  82 + public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";
  83 +
  84 + /**
  85 + * 接收推流设备的GPS变化通知
  86 + */
  87 + public static final String VM_MSG_GPS = "VM_MSG_GPS";
  88 +
  89 + /**
  90 + * 接收推流设备的GPS变化通知
  91 + */
  92 + public static final String VM_MSG_PUSH_STREAM_STATUS_CHANGE = "VM_MSG_PUSH_STREAM_STATUS_CHANGE";
  93 + /**
  94 + * 接收推流设备列表更新变化通知
  95 + */
  96 + public static final String VM_MSG_PUSH_STREAM_LIST_CHANGE = "VM_MSG_PUSH_STREAM_LIST_CHANGE";
  97 +
  98 + /**
  99 + * redis 消息通知设备推流到平台
  100 + */
  101 + public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED";
  102 +
  103 + /**
  104 + * redis 消息通知上级平台开始观看流
  105 + */
  106 + public static final String VM_MSG_STREAM_START_PLAY_NOTIFY = "VM_MSG_STREAM_START_PLAY_NOTIFY";
  107 +
  108 + /**
  109 + * redis 消息通知上级平台停止观看流
  110 + */
  111 + public static final String VM_MSG_STREAM_STOP_PLAY_NOTIFY = "VM_MSG_STREAM_STOP_PLAY_NOTIFY";
  112 +
  113 + /**
  114 + * redis 消息接收关闭一个推流
  115 + */
  116 + public static final String VM_MSG_STREAM_PUSH_CLOSE_REQUESTED = "VM_MSG_STREAM_PUSH_CLOSE_REQUESTED";
  117 +
  118 +
  119 + /**
  120 + * redis 消息通知平台通知设备推流结果
  121 + */
  122 + public static final String VM_MSG_STREAM_PUSH_RESPONSE = "VM_MSG_STREAM_PUSH_RESPONSE";
  123 +
  124 + /**
  125 + * redis 通知平台关闭推流
  126 + */
  127 + public static final String VM_MSG_STREAM_PUSH_CLOSE = "VM_MSG_STREAM_PUSH_CLOSE";
  128 +
  129 + /**
  130 + * redis 消息请求所有的在线通道
  131 + */
  132 + public static final String VM_MSG_GET_ALL_ONLINE_REQUESTED = "VM_MSG_GET_ALL_ONLINE_REQUESTED";
  133 +
  134 + /**
  135 + * 移动位置订阅通知
  136 + */
  137 + public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition";
  138 +
  139 + /**
  140 + * 报警订阅的通知(收到报警向redis发出通知)
  141 + */
  142 + public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm";
  143 +
  144 +
  145 + /**
  146 + * 报警通知的发送 (收到redis发出的通知,转发给其他平台)
  147 + */
  148 + public static final String VM_MSG_SUBSCRIBE_ALARM_RECEIVE= "alarm_receive";
  149 +
  150 + /**
  151 + * 设备状态订阅的通知
  152 + */
  153 + public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device";
  154 +
  155 +
  156 + //************************** 第三方 ****************************************
  157 +
  158 + public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";
  159 + public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_";
  160 + public static final String WVP_OTHER_SEND_RTP_INFO = "VMP_OTHER_SEND_RTP_INFO_";
  161 + public static final String WVP_OTHER_SEND_PS_INFO = "VMP_OTHER_SEND_PS_INFO_";
  162 + public static final String WVP_OTHER_RECEIVE_RTP_INFO = "VMP_OTHER_RECEIVE_RTP_INFO_";
  163 + public static final String WVP_OTHER_RECEIVE_PS_INFO = "VMP_OTHER_RECEIVE_PS_INFO_";
  164 +
  165 + /**
  166 + * Redis Const
  167 + * 设备录像信息结果前缀
  168 + */
  169 + public static final String REDIS_RECORD_INFO_RES_PRE = "GB_RECORD_INFO_RES_";
  170 + /**
  171 + * Redis Const
  172 + * 设备录像信息结果前缀
  173 + */
  174 + public static final String REDIS_RECORD_INFO_RES_COUNT_PRE = "GB_RECORD_INFO_RES_COUNT:";
  175 +
  176 +}
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/SipPlatformRunner.java
@@ -4,13 +4,19 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; @@ -4,13 +4,19 @@ 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;
12 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
13 16
  17 +import javax.sip.InvalidArgumentException;
  18 +import javax.sip.SipException;
  19 +import java.text.ParseException;
14 import java.util.List; 20 import java.util.List;
15 21
16 /** 22 /**
@@ -33,6 +39,7 @@ public class SipPlatformRunner implements CommandLineRunner { @@ -33,6 +39,7 @@ public class SipPlatformRunner implements CommandLineRunner {
33 @Autowired 39 @Autowired
34 private ISIPCommanderForPlatform sipCommanderForPlatform; 40 private ISIPCommanderForPlatform sipCommanderForPlatform;
35 41
  42 + private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class);
36 43
37 @Override 44 @Override
38 public void run(String... args) throws Exception { 45 public void run(String... args) throws Exception {
@@ -50,9 +57,13 @@ public class SipPlatformRunner implements CommandLineRunner { @@ -50,9 +57,13 @@ public class SipPlatformRunner implements CommandLineRunner {
50 redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); 57 redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
51 if (parentPlatformCatchOld != null) { 58 if (parentPlatformCatchOld != null) {
52 // 取消订阅 59 // 取消订阅
53 - sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{  
54 - platformService.login(parentPlatform);  
55 - }); 60 + try {
  61 + sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{
  62 + platformService.login(parentPlatform);
  63 + });
  64 + } catch (InvalidArgumentException | ParseException | SipException e) {
  65 + logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
  66 + }
56 } 67 }
57 68
58 // 设置所有平台离线 69 // 设置所有平台离线
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.TRUE; 36 private Boolean usePushingAsStatus = Boolean.TRUE;
37 37
@@ -132,12 +132,12 @@ public class UserSetting { @@ -132,12 +132,12 @@ public class UserSetting {
132 this.interfaceAuthenticationExcludes = interfaceAuthenticationExcludes; 132 this.interfaceAuthenticationExcludes = interfaceAuthenticationExcludes;
133 } 133 }
134 134
135 - public Boolean getLogInDatebase() {  
136 - return logInDatebase; 135 + public Boolean getLogInDatabase() {
  136 + return logInDatabase;
137 } 137 }
138 138
139 - public void setLogInDatebase(Boolean logInDatebase) {  
140 - this.logInDatebase = logInDatebase; 139 + public void setLogInDatabase(Boolean logInDatabase) {
  140 + this.logInDatabase = logInDatabase;
141 } 141 }
142 142
143 public String getServerId() { 143 public String getServerId() {
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
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.Device;  
6 -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;  
7 -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;  
8 -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;  
9 -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;  
10 -import com.genersoft.iot.vmp.service.bean.SSRCInfo;  
11 -import gov.nist.javax.sip.message.SIPRequest;  
12 -  
13 -import javax.sip.InvalidArgumentException;  
14 -import javax.sip.SipException;  
15 -import java.text.ParseException;  
16 -  
17 -/**  
18 - * @description:设备能力接口,用于定义设备的控制、查询能力  
19 - * @author: swwheihei  
20 - * @date: 2020年5月3日 下午9:16:34  
21 - */  
22 -public interface ISIPCommander {  
23 -  
24 - /**  
25 - * 云台方向放控制,使用配置文件中的默认镜头移动速度  
26 - *  
27 - * @param device 控制设备  
28 - * @param channelId 预览通道  
29 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移  
30 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移  
31 - */  
32 - void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException;  
33 -  
34 - /**  
35 - * 云台方向放控制  
36 - *  
37 - * @param device 控制设备  
38 - * @param channelId 预览通道  
39 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移  
40 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移  
41 - * @param moveSpeed 镜头移动速度  
42 - */  
43 - void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;  
44 -  
45 - /**  
46 - * 云台缩放控制,使用配置文件中的默认镜头缩放速度  
47 - *  
48 - * @param device 控制设备  
49 - * @param channelId 预览通道  
50 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大  
51 - */  
52 - void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException;  
53 -  
54 - /**  
55 - * 云台缩放控制  
56 - *  
57 - * @param device 控制设备  
58 - * @param channelId 预览通道  
59 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大  
60 - */  
61 - void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;  
62 -  
63 - /**  
64 - * 云台控制,支持方向与缩放控制  
65 - *  
66 - * @param device 控制设备  
67 - * @param channelId 预览通道  
68 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移  
69 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移  
70 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大  
71 - * @param moveSpeed 镜头移动速度  
72 - * @param zoomSpeed 镜头缩放速度  
73 - */  
74 - void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException;  
75 -  
76 - /**  
77 - * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令  
78 - *  
79 - * @param device 控制设备  
80 - * @param channelId 预览通道  
81 - * @param cmdCode 指令码  
82 - * @param parameter1 数据1  
83 - * @param parameter2 数据2  
84 - * @param combineCode2 组合码2  
85 - */  
86 - void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException;  
87 -  
88 - /**  
89 - * 前端控制指令(用于转发上级指令)  
90 - * @param device 控制设备  
91 - * @param channelId 预览通道  
92 - * @param cmdString 前端控制指令串  
93 - */  
94 - void fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
95 -  
96 - /**  
97 - * 请求预览视频流  
98 - * @param device 视频设备  
99 - * @param channelId 预览通道  
100 - */  
101 - void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
102 -  
103 - /**  
104 - * 请求回放视频流  
105 - *  
106 - * @param device 视频设备  
107 - * @param channelId 预览通道  
108 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss  
109 - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss  
110 - */  
111 - 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;  
112 -  
113 - /**  
114 - * 请求历史媒体下载  
115 - *  
116 - * @param device 视频设备  
117 - * @param channelId 预览通道  
118 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss  
119 - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss  
120 - * @param downloadSpeed 下载倍速参数  
121 - */  
122 - void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,  
123 - String startTime, String endTime, int downloadSpeed, ZlmHttpHookSubscribe.Event hookEvent,  
124 - SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
125 -  
126 - /**  
127 - * 视频流停止  
128 - */  
129 - void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;  
130 -  
131 - void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;  
132 -  
133 - /**  
134 - * 回放暂停  
135 - */  
136 - void playPauseCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;  
137 -  
138 - /**  
139 - * 回放恢复  
140 - */  
141 - void playResumeCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;  
142 -  
143 - /**  
144 - * 回放拖动播放  
145 - */  
146 - void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) throws InvalidArgumentException, ParseException, SipException;  
147 -  
148 - /**  
149 - * 回放倍速播放  
150 - */  
151 - void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException;  
152 -  
153 - /**  
154 - * 回放控制  
155 - * @param device  
156 - * @param streamInfo  
157 - * @param content  
158 - */  
159 - void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException;  
160 -  
161 -  
162 - /**  
163 - * 语音广播  
164 - *  
165 - * @param device 视频设备  
166 - * @param channelId 预览通道  
167 - */  
168 - void audioBroadcastCmd(Device device,String channelId);  
169 -  
170 - /**  
171 - * 语音广播  
172 - *  
173 - * @param device 视频设备  
174 - */  
175 - void audioBroadcastCmd(Device device, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
176 - void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException;  
177 -  
178 - /**  
179 - * 音视频录像控制  
180 - *  
181 - * @param device 视频设备  
182 - * @param channelId 预览通道  
183 - * @param recordCmdStr 录像命令:Record / StopRecord  
184 - */  
185 - void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
186 -  
187 - /**  
188 - * 远程启动控制命令  
189 - *  
190 - * @param device 视频设备  
191 - */  
192 - void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException;  
193 -  
194 - /**  
195 - * 报警布防/撤防命令  
196 - *  
197 - * @param device 视频设备  
198 - */  
199 - void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
200 -  
201 - /**  
202 - * 报警复位命令  
203 - *  
204 - * @param device 视频设备  
205 - * @param alarmMethod 报警方式(可选)  
206 - * @param alarmType 报警类型(可选)  
207 - */  
208 - void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
209 -  
210 - /**  
211 - * 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧  
212 - *  
213 - * @param device 视频设备  
214 - * @param channelId 预览通道  
215 - */  
216 - void iFrameCmd(Device device, String channelId) throws InvalidArgumentException, SipException, ParseException;  
217 -  
218 - /**  
219 - * 看守位控制命令  
220 - *  
221 - * @param device 视频设备  
222 - * @param channelId 通道id,非通道则是设备本身  
223 - * @param enabled 看守位使能:1 = 开启,0 = 关闭  
224 - * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s)  
225 - * @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255  
226 - */  
227 - void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;  
228 -  
229 - /**  
230 - * 设备配置命令  
231 - *  
232 - * @param device 视频设备  
233 - */  
234 - void deviceConfigCmd(Device device);  
235 -  
236 - /**  
237 - * 设备配置命令:basicParam  
238 - *  
239 - * @param device 视频设备  
240 - * @param channelId 通道编码(可选)  
241 - * @param name 设备/通道名称(可选)  
242 - * @param expiration 注册过期时间(可选)  
243 - * @param heartBeatInterval 心跳间隔时间(可选)  
244 - * @param heartBeatCount 心跳超时次数(可选)  
245 - */  
246 - void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
247 -  
248 - /**  
249 - * 查询设备状态  
250 - *  
251 - * @param device 视频设备  
252 - */  
253 - void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
254 -  
255 - /**  
256 - * 查询设备信息  
257 - *  
258 - * @param device 视频设备  
259 - * @return  
260 - */  
261 - void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException;  
262 -  
263 - /**  
264 - * 查询目录列表  
265 - *  
266 - * @param device 视频设备  
267 - */  
268 - void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException;  
269 -  
270 - /**  
271 - * 查询录像信息  
272 - *  
273 - * @param device 视频设备  
274 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss  
275 - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss  
276 - * @param sn  
277 - */  
278 - 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;  
279 -  
280 - /**  
281 - * 查询报警信息  
282 - *  
283 - * @param device 视频设备  
284 - * @param startPriority 报警起始级别(可选)  
285 - * @param endPriority 报警终止级别(可选)  
286 - * @param alarmMethod 报警方式条件(可选)  
287 - * @param alarmType 报警类型  
288 - * @param startTime 报警发生起始时间(可选)  
289 - * @param endTime 报警发生终止时间(可选)  
290 - * @return true = 命令发送成功  
291 - */  
292 - void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod,  
293 - String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
294 -  
295 - /**  
296 - * 查询设备配置  
297 - *  
298 - * @param device 视频设备  
299 - * @param channelId 通道编码(可选)  
300 - * @param configType 配置类型:  
301 - */  
302 - void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
303 -  
304 - /**  
305 - * 查询设备预置位置  
306 - *  
307 - * @param device 视频设备  
308 - */  
309 - void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
310 -  
311 - /**  
312 - * 查询移动设备位置数据  
313 - *  
314 - * @param device 视频设备  
315 - */  
316 - void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
317 -  
318 - /**  
319 - * 订阅、取消订阅移动位置  
320 - *  
321 - * @param device 视频设备  
322 - * @return true = 命令发送成功  
323 - */  
324 - SIPRequest mobilePositionSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent , SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
325 -  
326 - /**  
327 - * 订阅、取消订阅报警信息  
328 - * @param device 视频设备  
329 - * @param expires 订阅过期时间(0 = 取消订阅)  
330 - * @param startPriority 报警起始级别(可选)  
331 - * @param endPriority 报警终止级别(可选)  
332 - * @param alarmType 报警类型  
333 - * @param startTime 报警发生起始时间(可选)  
334 - * @param endTime 报警发生终止时间(可选)  
335 - * @return true = 命令发送成功  
336 - */  
337 - void alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String startTime, String endTime) throws InvalidArgumentException, SipException, ParseException;  
338 -  
339 - /**  
340 - * 订阅、取消订阅目录信息  
341 - * @param device 视频设备  
342 - * @return true = 命令发送成功  
343 - */  
344 - SIPRequest catalogSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;  
345 -  
346 - /**  
347 - * 拉框控制命令  
348 - *  
349 - * @param device 控制设备  
350 - * @param channelId 通道id  
351 - * @param cmdString 前端控制指令串  
352 - */  
353 - void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException;  
354 -  
355 -  
356 - /**  
357 - * 向设备发送报警NOTIFY消息, 用于互联结构下,此时将设备当成一个平级平台看待  
358 - * @param device 设备  
359 - * @param deviceAlarm 报警信息信息  
360 - * @return  
361 - */  
362 - void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException;  
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.Device;
  6 +import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
  7 +import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
  8 +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
  9 +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
  10 +import com.genersoft.iot.vmp.service.bean.SSRCInfo;
  11 +import gov.nist.javax.sip.message.SIPRequest;
  12 +
  13 +import javax.sip.InvalidArgumentException;
  14 +import javax.sip.SipException;
  15 +import java.text.ParseException;
  16 +
  17 +/**
  18 + * @description:设备能力接口,用于定义设备的控制、查询能力
  19 + * @author: swwheihei
  20 + * @date: 2020年5月3日 下午9:16:34
  21 + */
  22 +public interface ISIPCommander {
  23 +
  24 + /**
  25 + * 云台方向放控制,使用配置文件中的默认镜头移动速度
  26 + *
  27 + * @param device 控制设备
  28 + * @param channelId 预览通道
  29 + * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
  30 + * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
  31 + */
  32 + void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException;
  33 +
  34 + /**
  35 + * 云台方向放控制
  36 + *
  37 + * @param device 控制设备
  38 + * @param channelId 预览通道
  39 + * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
  40 + * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
  41 + * @param moveSpeed 镜头移动速度
  42 + */
  43 + void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;
  44 +
  45 + /**
  46 + * 云台缩放控制,使用配置文件中的默认镜头缩放速度
  47 + *
  48 + * @param device 控制设备
  49 + * @param channelId 预览通道
  50 + * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
  51 + */
  52 + void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException;
  53 +
  54 + /**
  55 + * 云台缩放控制
  56 + *
  57 + * @param device 控制设备
  58 + * @param channelId 预览通道
  59 + * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
  60 + */
  61 + void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;
  62 +
  63 + /**
  64 + * 云台控制,支持方向与缩放控制
  65 + *
  66 + * @param device 控制设备
  67 + * @param channelId 预览通道
  68 + * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
  69 + * @param upDown 镜头上移下移 0:停止 1:上移 2:下移
  70 + * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
  71 + * @param moveSpeed 镜头移动速度
  72 + * @param zoomSpeed 镜头缩放速度
  73 + */
  74 + void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException;
  75 +
  76 + /**
  77 + * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令
  78 + *
  79 + * @param device 控制设备
  80 + * @param channelId 预览通道
  81 + * @param cmdCode 指令码
  82 + * @param parameter1 数据1
  83 + * @param parameter2 数据2
  84 + * @param combineCode2 组合码2
  85 + */
  86 + void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException;
  87 +
  88 + /**
  89 + * 前端控制指令(用于转发上级指令)
  90 + * @param device 控制设备
  91 + * @param channelId 预览通道
  92 + * @param cmdString 前端控制指令串
  93 + */
  94 + void fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  95 +
  96 + /**
  97 + * 请求预览视频流
  98 + * @param device 视频设备
  99 + * @param channelId 预览通道
  100 + */
  101 + void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  102 +
  103 + /**
  104 + * 请求回放视频流
  105 + *
  106 + * @param device 视频设备
  107 + * @param channelId 预览通道
  108 + * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
  109 + * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
  110 + */
  111 + 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;
  112 +
  113 + /**
  114 + * 请求历史媒体下载
  115 + *
  116 + * @param device 视频设备
  117 + * @param channelId 预览通道
  118 + * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
  119 + * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
  120 + * @param downloadSpeed 下载倍速参数
  121 + */
  122 + void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
  123 + String startTime, String endTime, int downloadSpeed, ZlmHttpHookSubscribe.Event hookEvent,
  124 + SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  125 +
  126 + /**
  127 + * 视频流停止
  128 + */
  129 + void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
  130 +
  131 + void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
  132 +
  133 + /**
  134 + * 回放暂停
  135 + */
  136 + void playPauseCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;
  137 +
  138 + /**
  139 + * 回放恢复
  140 + */
  141 + void playResumeCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;
  142 +
  143 + /**
  144 + * 回放拖动播放
  145 + */
  146 + void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) throws InvalidArgumentException, ParseException, SipException;
  147 +
  148 + /**
  149 + * 回放倍速播放
  150 + */
  151 + void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException;
  152 +
  153 + /**
  154 + * 回放控制
  155 + * @param device
  156 + * @param streamInfo
  157 + * @param content
  158 + */
  159 + void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException;
  160 +
  161 +
  162 + /**
  163 + * 语音广播
  164 + *
  165 + * @param device 视频设备
  166 + * @param channelId 预览通道
  167 + */
  168 + void audioBroadcastCmd(Device device,String channelId);
  169 +
  170 + /**
  171 + * 语音广播
  172 + *
  173 + * @param device 视频设备
  174 + */
  175 + void audioBroadcastCmd(Device device, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  176 + void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException;
  177 +
  178 + /**
  179 + * 音视频录像控制
  180 + *
  181 + * @param device 视频设备
  182 + * @param channelId 预览通道
  183 + * @param recordCmdStr 录像命令:Record / StopRecord
  184 + */
  185 + void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  186 +
  187 + /**
  188 + * 远程启动控制命令
  189 + *
  190 + * @param device 视频设备
  191 + */
  192 + void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException;
  193 +
  194 + /**
  195 + * 报警布防/撤防命令
  196 + *
  197 + * @param device 视频设备
  198 + */
  199 + void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  200 +
  201 + /**
  202 + * 报警复位命令
  203 + *
  204 + * @param device 视频设备
  205 + * @param alarmMethod 报警方式(可选)
  206 + * @param alarmType 报警类型(可选)
  207 + */
  208 + void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  209 +
  210 + /**
  211 + * 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧
  212 + *
  213 + * @param device 视频设备
  214 + * @param channelId 预览通道
  215 + */
  216 + void iFrameCmd(Device device, String channelId) throws InvalidArgumentException, SipException, ParseException;
  217 +
  218 + /**
  219 + * 看守位控制命令
  220 + *
  221 + * @param device 视频设备
  222 + * @param channelId 通道id,非通道则是设备本身
  223 + * @param enabled 看守位使能:1 = 开启,0 = 关闭
  224 + * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s)
  225 + * @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255
  226 + */
  227 + void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
  228 +
  229 + /**
  230 + * 设备配置命令
  231 + *
  232 + * @param device 视频设备
  233 + */
  234 + void deviceConfigCmd(Device device);
  235 +
  236 + /**
  237 + * 设备配置命令:basicParam
  238 + *
  239 + * @param device 视频设备
  240 + * @param channelId 通道编码(可选)
  241 + * @param name 设备/通道名称(可选)
  242 + * @param expiration 注册过期时间(可选)
  243 + * @param heartBeatInterval 心跳间隔时间(可选)
  244 + * @param heartBeatCount 心跳超时次数(可选)
  245 + */
  246 + void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  247 +
  248 + /**
  249 + * 查询设备状态
  250 + *
  251 + * @param device 视频设备
  252 + */
  253 + void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  254 +
  255 + /**
  256 + * 查询设备信息
  257 + *
  258 + * @param device 视频设备
  259 + * @return
  260 + */
  261 + void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException;
  262 +
  263 + /**
  264 + * 查询目录列表
  265 + *
  266 + * @param device 视频设备
  267 + */
  268 + void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException;
  269 +
  270 + /**
  271 + * 查询录像信息
  272 + *
  273 + * @param device 视频设备
  274 + * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
  275 + * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
  276 + * @param sn
  277 + */
  278 + 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;
  279 +
  280 + /**
  281 + * 查询报警信息
  282 + *
  283 + * @param device 视频设备
  284 + * @param startPriority 报警起始级别(可选)
  285 + * @param endPriority 报警终止级别(可选)
  286 + * @param alarmMethod 报警方式条件(可选)
  287 + * @param alarmType 报警类型
  288 + * @param startTime 报警发生起始时间(可选)
  289 + * @param endTime 报警发生终止时间(可选)
  290 + * @return true = 命令发送成功
  291 + */
  292 + void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod,
  293 + String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  294 +
  295 + /**
  296 + * 查询设备配置
  297 + *
  298 + * @param device 视频设备
  299 + * @param channelId 通道编码(可选)
  300 + * @param configType 配置类型:
  301 + */
  302 + void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  303 +
  304 + /**
  305 + * 查询设备预置位置
  306 + *
  307 + * @param device 视频设备
  308 + */
  309 + void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  310 +
  311 + /**
  312 + * 查询移动设备位置数据
  313 + *
  314 + * @param device 视频设备
  315 + */
  316 + void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  317 +
  318 + /**
  319 + * 订阅、取消订阅移动位置
  320 + *
  321 + * @param device 视频设备
  322 + * @return true = 命令发送成功
  323 + */
  324 + SIPRequest mobilePositionSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent , SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  325 +
  326 + /**
  327 + * 订阅、取消订阅报警信息
  328 + * @param device 视频设备
  329 + * @param expires 订阅过期时间(0 = 取消订阅)
  330 + * @param startPriority 报警起始级别(可选)
  331 + * @param endPriority 报警终止级别(可选)
  332 + * @param alarmType 报警类型
  333 + * @param startTime 报警发生起始时间(可选)
  334 + * @param endTime 报警发生终止时间(可选)
  335 + * @return true = 命令发送成功
  336 + */
  337 + void alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String startTime, String endTime) throws InvalidArgumentException, SipException, ParseException;
  338 +
  339 + /**
  340 + * 订阅、取消订阅目录信息
  341 + * @param device 视频设备
  342 + * @return true = 命令发送成功
  343 + */
  344 + SIPRequest catalogSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
  345 +
  346 + /**
  347 + * 拉框控制命令
  348 + *
  349 + * @param device 控制设备
  350 + * @param channelId 通道id
  351 + * @param cmdString 前端控制指令串
  352 + */
  353 + void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException;
  354 +
  355 +
  356 + /**
  357 + * 向设备发送报警NOTIFY消息, 用于互联结构下,此时将设备当成一个平级平台看待
  358 + * @param device 设备
  359 + * @param deviceAlarm 报警信息信息
  360 + * @return
  361 + */
  362 + void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException;
  363 +
  364 +}
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java 100644 → 100755
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
1 -package com.genersoft.iot.vmp.gb28181.transmit.cmd;  
2 -  
3 -import com.genersoft.iot.vmp.conf.SipConfig;  
4 -import com.genersoft.iot.vmp.gb28181.SipLayer;  
5 -import com.genersoft.iot.vmp.gb28181.bean.Device;  
6 -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;  
7 -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;  
8 -import com.genersoft.iot.vmp.gb28181.utils.SipUtils;  
9 -import com.genersoft.iot.vmp.storager.IRedisCatchStorage;  
10 -import com.genersoft.iot.vmp.utils.GitUtil;  
11 -import gov.nist.javax.sip.message.SIPRequest;  
12 -import gov.nist.javax.sip.message.SIPResponse;  
13 -import org.springframework.beans.factory.annotation.Autowired;  
14 -import org.springframework.stereotype.Component;  
15 -  
16 -import javax.sip.InvalidArgumentException;  
17 -import javax.sip.PeerUnavailableException;  
18 -import javax.sip.SipException;  
19 -import javax.sip.SipFactory;  
20 -import javax.sip.address.Address;  
21 -import javax.sip.address.SipURI;  
22 -import javax.sip.header.*;  
23 -import javax.sip.message.Request;  
24 -import java.text.ParseException;  
25 -import java.util.ArrayList;  
26 -  
27 -/**  
28 - * @description:摄像头命令request创造器 TODO 冗余代码太多待优化  
29 - * @author: swwheihei  
30 - * @date: 2020年5月6日 上午9:29:02  
31 - */  
32 -@Component  
33 -public class SIPRequestHeaderProvider {  
34 -  
35 - @Autowired  
36 - private SipConfig sipConfig;  
37 -  
38 - @Autowired  
39 - private SipLayer sipLayer;  
40 -  
41 - @Autowired  
42 - private GitUtil gitUtil;  
43 -  
44 - @Autowired  
45 - private IRedisCatchStorage redisCatchStorage;  
46 -  
47 - @Autowired  
48 - private VideoStreamSessionManager streamSession;  
49 -  
50 - public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {  
51 - Request request = null;  
52 - // sipuri  
53 - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());  
54 - // via  
55 - ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();  
56 - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);  
57 - viaHeader.setRPort();  
58 - viaHeaders.add(viaHeader);  
59 - // from  
60 - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());  
61 - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);  
62 - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag);  
63 - // to  
64 - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());  
65 - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);  
66 - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, toTag);  
67 -  
68 - // Forwards  
69 - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);  
70 - // ceq  
71 - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);  
72 -  
73 - request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,  
74 - toHeader, viaHeaders, maxForwards);  
75 -  
76 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
77 -  
78 - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");  
79 - request.setContent(content, contentTypeHeader);  
80 - return request;  
81 - }  
82 -  
83 - public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {  
84 - Request request = null;  
85 - //请求行  
86 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());  
87 - //via  
88 - ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();  
89 - HeaderFactory headerFactory = SipFactory.getInstance().createHeaderFactory();  
90 - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);  
91 - viaHeader.setRPort();  
92 - viaHeaders.add(viaHeader);  
93 -  
94 - //from  
95 - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());  
96 - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);  
97 - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack  
98 - //to  
99 - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());  
100 - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);  
101 - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);  
102 -  
103 - //Forwards  
104 - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);  
105 -  
106 - //ceq  
107 - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);  
108 - request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);  
109 -  
110 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
111 -  
112 - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));  
113 - // Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));  
114 - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));  
115 - // Subject  
116 - SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));  
117 - request.addHeader(subjectHeader);  
118 - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");  
119 - request.setContent(content, contentTypeHeader);  
120 - return request;  
121 - }  
122 -  
123 - public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException {  
124 - Request request = null;  
125 - //请求行  
126 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());  
127 - // via  
128 - ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();  
129 - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);  
130 - viaHeader.setRPort();  
131 - viaHeaders.add(viaHeader);  
132 - //from  
133 - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());  
134 - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);  
135 - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack  
136 - //to  
137 - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());  
138 - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);  
139 - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);  
140 -  
141 - //Forwards  
142 - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);  
143 -  
144 - //ceq  
145 - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);  
146 - request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);  
147 -  
148 - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));  
149 - // Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));  
150 - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));  
151 -  
152 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
153 -  
154 - // Subject  
155 - SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));  
156 - request.addHeader(subjectHeader);  
157 -  
158 - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");  
159 - request.setContent(content, contentTypeHeader);  
160 - return request;  
161 - }  
162 -  
163 - public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException {  
164 - Request request = null;  
165 - //请求行  
166 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());  
167 - // via  
168 - ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();  
169 - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());  
170 - viaHeaders.add(viaHeader);  
171 - //from  
172 - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());  
173 - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);  
174 - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());  
175 - //to  
176 - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());  
177 - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);  
178 - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());  
179 -  
180 - //Forwards  
181 - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);  
182 -  
183 - //ceq  
184 - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);  
185 - CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());  
186 - request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);  
187 -  
188 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
189 -  
190 - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));  
191 - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));  
192 -  
193 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
194 -  
195 - return request;  
196 - }  
197 -  
198 - public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {  
199 - Request request = null;  
200 - // sipuri  
201 - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());  
202 - // via  
203 - ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();  
204 - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(),  
205 - device.getTransport(), SipUtils.getNewViaTag());  
206 - viaHeader.setRPort();  
207 - viaHeaders.add(viaHeader);  
208 - // from  
209 - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());  
210 - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);  
211 - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag());  
212 - // to  
213 - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());  
214 - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);  
215 - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag());  
216 -  
217 - // Forwards  
218 - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);  
219 -  
220 - // ceq  
221 - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE);  
222 -  
223 - request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader,  
224 - toHeader, viaHeaders, maxForwards);  
225 -  
226 -  
227 - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));  
228 - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));  
229 -  
230 - // Expires  
231 - ExpiresHeader expireHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(expires);  
232 - request.addHeader(expireHeader);  
233 -  
234 - // Event  
235 - EventHeader eventHeader = SipFactory.getInstance().createHeaderFactory().createEventHeader(event);  
236 -  
237 - int random = (int) Math.floor(Math.random() * 10000);  
238 - eventHeader.setEventId(random + "");  
239 - request.addHeader(eventHeader);  
240 -  
241 - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");  
242 - request.setContent(content, contentTypeHeader);  
243 -  
244 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
245 -  
246 - return request;  
247 - }  
248 -  
249 - public SIPRequest createInfoRequest(Device device, String channelId, String content, SipTransactionInfo transactionInfo)  
250 - throws SipException, ParseException, InvalidArgumentException {  
251 - if (device == null || transactionInfo == null) {  
252 - return null;  
253 - }  
254 - SIPRequest request = null;  
255 - //请求行  
256 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());  
257 - // via  
258 - ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();  
259 - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());  
260 - viaHeaders.add(viaHeader);  
261 - //from  
262 - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());  
263 - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);  
264 - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());  
265 - //to  
266 - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());  
267 - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);  
268 - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());  
269 -  
270 - //Forwards  
271 - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);  
272 -  
273 - //ceq  
274 - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO);  
275 - CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());  
276 - request = (SIPRequest)SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);  
277 -  
278 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
279 -  
280 - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));  
281 - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));  
282 -  
283 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
284 -  
285 - if (content != null) {  
286 - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application",  
287 - "MANSRTSP");  
288 - request.setContent(content, contentTypeHeader);  
289 - }  
290 - return request;  
291 - }  
292 -  
293 - public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException {  
294 -  
295 -  
296 - // via  
297 - ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();  
298 - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag());  
299 - viaHeaders.add(viaHeader);  
300 -  
301 - //Forwards  
302 - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);  
303 -  
304 - //ceq  
305 - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK);  
306 -  
307 - Request request = SipFactory.getInstance().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards);  
308 -  
309 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
310 -  
311 - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort()));  
312 - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));  
313 -  
314 - request.addHeader(SipUtils.createUserAgentHeader(gitUtil));  
315 -  
316 - return request;  
317 - }  
318 -} 1 +package com.genersoft.iot.vmp.gb28181.transmit.cmd;
  2 +
  3 +import com.genersoft.iot.vmp.conf.SipConfig;
  4 +import com.genersoft.iot.vmp.gb28181.SipLayer;
  5 +import com.genersoft.iot.vmp.gb28181.bean.Device;
  6 +import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
  7 +import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
  8 +import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
  9 +import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  10 +import com.genersoft.iot.vmp.utils.GitUtil;
  11 +import gov.nist.javax.sip.message.SIPRequest;
  12 +import gov.nist.javax.sip.message.SIPResponse;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Component;
  15 +
  16 +import javax.sip.InvalidArgumentException;
  17 +import javax.sip.PeerUnavailableException;
  18 +import javax.sip.SipException;
  19 +import javax.sip.SipFactory;
  20 +import javax.sip.address.Address;
  21 +import javax.sip.address.SipURI;
  22 +import javax.sip.header.*;
  23 +import javax.sip.message.Request;
  24 +import java.text.ParseException;
  25 +import java.util.ArrayList;
  26 +
  27 +/**
  28 + * @description:摄像头命令request创造器 TODO 冗余代码太多待优化
  29 + * @author: swwheihei
  30 + * @date: 2020年5月6日 上午9:29:02
  31 + */
  32 +@Component
  33 +public class SIPRequestHeaderProvider {
  34 +
  35 + @Autowired
  36 + private SipConfig sipConfig;
  37 +
  38 + @Autowired
  39 + private SipLayer sipLayer;
  40 +
  41 + @Autowired
  42 + private GitUtil gitUtil;
  43 +
  44 + @Autowired
  45 + private IRedisCatchStorage redisCatchStorage;
  46 +
  47 + @Autowired
  48 + private VideoStreamSessionManager streamSession;
  49 +
  50 + public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
  51 + Request request = null;
  52 + // sipuri
  53 + SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
  54 + // via
  55 + ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
  56 + ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
  57 + viaHeader.setRPort();
  58 + viaHeaders.add(viaHeader);
  59 + // from
  60 + SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
  61 + Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
  62 + FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag);
  63 + // to
  64 + SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
  65 + Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
  66 + ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, toTag);
  67 +
  68 + // Forwards
  69 + MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
  70 + // ceq
  71 + CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
  72 +
  73 + request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
  74 + toHeader, viaHeaders, maxForwards);
  75 +
  76 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  77 +
  78 + ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
  79 + request.setContent(content, contentTypeHeader);
  80 + return request;
  81 + }
  82 +
  83 + public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
  84 + Request request = null;
  85 + //请求行
  86 + SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
  87 + //via
  88 + ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
  89 + HeaderFactory headerFactory = SipFactory.getInstance().createHeaderFactory();
  90 + ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
  91 + viaHeader.setRPort();
  92 + viaHeaders.add(viaHeader);
  93 +
  94 + //from
  95 + SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
  96 + Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
  97 + FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
  98 + //to
  99 + SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
  100 + Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
  101 + ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);
  102 +
  103 + //Forwards
  104 + MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
  105 +
  106 + //ceq
  107 + CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
  108 + request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
  109 +
  110 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  111 +
  112 + Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
  113 + // Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
  114 + request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
  115 + // Subject
  116 + SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
  117 + request.addHeader(subjectHeader);
  118 + ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
  119 + request.setContent(content, contentTypeHeader);
  120 + return request;
  121 + }
  122 +
  123 + public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException {
  124 + Request request = null;
  125 + //请求行
  126 + SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
  127 + // via
  128 + ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
  129 + ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
  130 + viaHeader.setRPort();
  131 + viaHeaders.add(viaHeader);
  132 + //from
  133 + SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
  134 + Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
  135 + FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
  136 + //to
  137 + SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
  138 + Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
  139 + ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);
  140 +
  141 + //Forwards
  142 + MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
  143 +
  144 + //ceq
  145 + CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
  146 + request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
  147 +
  148 + Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
  149 + // Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
  150 + request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
  151 +
  152 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  153 +
  154 + // Subject
  155 + SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
  156 + request.addHeader(subjectHeader);
  157 +
  158 + ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
  159 + request.setContent(content, contentTypeHeader);
  160 + return request;
  161 + }
  162 +
  163 + public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException {
  164 + Request request = null;
  165 + //请求行
  166 + SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
  167 + // via
  168 + ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
  169 + ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
  170 + viaHeaders.add(viaHeader);
  171 + //from
  172 + SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
  173 + Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
  174 + FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
  175 + //to
  176 + SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());
  177 + Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
  178 + ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
  179 +
  180 + //Forwards
  181 + MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
  182 +
  183 + //ceq
  184 + CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
  185 + CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
  186 + request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
  187 +
  188 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  189 +
  190 + Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
  191 + request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
  192 +
  193 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  194 +
  195 + return request;
  196 + }
  197 +
  198 + public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
  199 + Request request = null;
  200 + // sipuri
  201 + SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
  202 + // via
  203 + ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
  204 + ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(),
  205 + device.getTransport(), SipUtils.getNewViaTag());
  206 + viaHeader.setRPort();
  207 + viaHeaders.add(viaHeader);
  208 + // from
  209 + SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
  210 + Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
  211 + FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag());
  212 + // to
  213 + SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
  214 + Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
  215 + ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag());
  216 +
  217 + // Forwards
  218 + MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
  219 +
  220 + // ceq
  221 + CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE);
  222 +
  223 + request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader,
  224 + toHeader, viaHeaders, maxForwards);
  225 +
  226 +
  227 + Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
  228 + request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
  229 +
  230 + // Expires
  231 + ExpiresHeader expireHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(expires);
  232 + request.addHeader(expireHeader);
  233 +
  234 + // Event
  235 + EventHeader eventHeader = SipFactory.getInstance().createHeaderFactory().createEventHeader(event);
  236 +
  237 + int random = (int) Math.floor(Math.random() * 10000);
  238 + eventHeader.setEventId(random + "");
  239 + request.addHeader(eventHeader);
  240 +
  241 + ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
  242 + request.setContent(content, contentTypeHeader);
  243 +
  244 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  245 +
  246 + return request;
  247 + }
  248 +
  249 + public SIPRequest createInfoRequest(Device device, String channelId, String content, SipTransactionInfo transactionInfo)
  250 + throws SipException, ParseException, InvalidArgumentException {
  251 + if (device == null || transactionInfo == null) {
  252 + return null;
  253 + }
  254 + SIPRequest request = null;
  255 + //请求行
  256 + SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
  257 + // via
  258 + ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
  259 + ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
  260 + viaHeaders.add(viaHeader);
  261 + //from
  262 + SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
  263 + Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
  264 + FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
  265 + //to
  266 + SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());
  267 + Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
  268 + ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
  269 +
  270 + //Forwards
  271 + MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
  272 +
  273 + //ceq
  274 + CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO);
  275 + CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
  276 + request = (SIPRequest)SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
  277 +
  278 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  279 +
  280 + Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
  281 + request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
  282 +
  283 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  284 +
  285 + if (content != null) {
  286 + ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application",
  287 + "MANSRTSP");
  288 + request.setContent(content, contentTypeHeader);
  289 + }
  290 + return request;
  291 + }
  292 +
  293 + public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException {
  294 +
  295 +
  296 + // via
  297 + ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
  298 + ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag());
  299 + viaHeaders.add(viaHeader);
  300 +
  301 + //Forwards
  302 + MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
  303 +
  304 + //ceq
  305 + CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK);
  306 +
  307 + Request request = SipFactory.getInstance().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards);
  308 +
  309 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  310 +
  311 + Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort()));
  312 + request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
  313 +
  314 + request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
  315 +
  316 + return request;
  317 + }
  318 +}