Merge branch '648540858:wvp-28181-2.0' into wvp-28181-2.0
This commit is contained in:
commit
d0ef68af3f
@ -153,7 +153,7 @@ user-settings:
|
||||
# 国标是否录制
|
||||
record-sip: true
|
||||
# 是否将日志存储进数据库
|
||||
logInDatebase: true
|
||||
logInDatabase: true
|
||||
# 第三方匹配,用于从stream钟获取有效信息
|
||||
thirdPartyGBIdReg: [\s\S]*
|
||||
```
|
||||
|
@ -1,63 +1,63 @@
|
||||
package com.genersoft.iot.vmp;
|
||||
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* 启动类
|
||||
*/
|
||||
@ServletComponentScan("com.genersoft.iot.vmp.conf")
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class VManageBootstrap extends SpringBootServletInitializer {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(VManageBootstrap.class);
|
||||
|
||||
private static String[] args;
|
||||
private static ConfigurableApplicationContext context;
|
||||
public static void main(String[] args) {
|
||||
VManageBootstrap.args = args;
|
||||
VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
|
||||
GitUtil gitUtil1 = SpringBeanFactory.getBean("gitUtil");
|
||||
logger.info("构建版本: {}", gitUtil1.getBuildVersion());
|
||||
logger.info("构建时间: {}", gitUtil1.getBuildDate());
|
||||
logger.info("GIT最后提交时间: {}", gitUtil1.getCommitTime());
|
||||
}
|
||||
// 项目重启
|
||||
public static void restart() {
|
||||
context.close();
|
||||
VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(VManageBootstrap.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartup(ServletContext servletContext) throws ServletException {
|
||||
super.onStartup(servletContext);
|
||||
|
||||
servletContext.setSessionTrackingModes(
|
||||
Collections.singleton(SessionTrackingMode.COOKIE)
|
||||
);
|
||||
SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
|
||||
sessionCookieConfig.setHttpOnly(true);
|
||||
|
||||
}
|
||||
}
|
||||
package com.genersoft.iot.vmp;
|
||||
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* 启动类
|
||||
*/
|
||||
@ServletComponentScan("com.genersoft.iot.vmp.conf")
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class VManageBootstrap extends SpringBootServletInitializer {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(VManageBootstrap.class);
|
||||
|
||||
private static String[] args;
|
||||
private static ConfigurableApplicationContext context;
|
||||
public static void main(String[] args) {
|
||||
VManageBootstrap.args = args;
|
||||
VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
|
||||
GitUtil gitUtil1 = SpringBeanFactory.getBean("gitUtil");
|
||||
logger.info("构建版本: {}", gitUtil1.getBuildVersion());
|
||||
logger.info("构建时间: {}", gitUtil1.getBuildDate());
|
||||
logger.info("GIT最后提交时间: {}", gitUtil1.getCommitTime());
|
||||
}
|
||||
// 项目重启
|
||||
public static void restart() {
|
||||
context.close();
|
||||
VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(VManageBootstrap.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartup(ServletContext servletContext) throws ServletException {
|
||||
super.onStartup(servletContext);
|
||||
|
||||
servletContext.setSessionTrackingModes(
|
||||
Collections.singleton(SessionTrackingMode.COOKIE)
|
||||
);
|
||||
SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig();
|
||||
sessionCookieConfig.setHttpOnly(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,176 +1,176 @@
|
||||
package com.genersoft.iot.vmp.common;
|
||||
|
||||
/**
|
||||
* @description: 定义常量
|
||||
* @author: swwheihei
|
||||
* @date: 2019年5月30日 下午3:04:04
|
||||
*
|
||||
*/
|
||||
public class VideoManagerConstants {
|
||||
|
||||
public static final String WVP_SERVER_PREFIX = "VMP_SIGNALLING_SERVER_INFO_";
|
||||
|
||||
public static final String WVP_SERVER_STREAM_PREFIX = "VMP_SIGNALLING_STREAM_";
|
||||
|
||||
public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_";
|
||||
|
||||
public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS_";
|
||||
|
||||
public static final String DEVICE_PREFIX = "VMP_DEVICE_";
|
||||
|
||||
// 设备同步完成
|
||||
public static final String DEVICE_SYNC_PREFIX = "VMP_DEVICE_SYNC_";
|
||||
|
||||
public static final String CACHEKEY_PREFIX = "VMP_CHANNEL_";
|
||||
|
||||
public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_";
|
||||
|
||||
// TODO 此处多了一个_,暂不修改
|
||||
public static final String INVITE_PREFIX = "VMP_INVITE";
|
||||
public static final String PLAYER_PREFIX = "VMP_INVITE_PLAY_";
|
||||
public static final String PLAY_BLACK_PREFIX = "VMP_INVITE_PLAYBACK_";
|
||||
public static final String DOWNLOAD_PREFIX = "VMP_INVITE_DOWNLOAD_";
|
||||
|
||||
public static final String PLATFORM_KEEPALIVE_PREFIX = "VMP_PLATFORM_KEEPALIVE_";
|
||||
|
||||
public static final String PLATFORM_CATCH_PREFIX = "VMP_PLATFORM_CATCH_";
|
||||
|
||||
public static final String PLATFORM_REGISTER_PREFIX = "VMP_PLATFORM_REGISTER_";
|
||||
|
||||
public static final String PLATFORM_REGISTER_INFO_PREFIX = "VMP_PLATFORM_REGISTER_INFO_";
|
||||
|
||||
public static final String PLATFORM_SEND_RTP_INFO_PREFIX = "VMP_PLATFORM_SEND_RTP_INFO_";
|
||||
|
||||
public static final String EVENT_ONLINE_REGISTER = "1";
|
||||
|
||||
public static final String EVENT_ONLINE_MESSAGE = "3";
|
||||
|
||||
public static final String EVENT_OUTLINE_UNREGISTER = "1";
|
||||
|
||||
public static final String EVENT_OUTLINE_TIMEOUT = "2";
|
||||
|
||||
public static final String MEDIA_SSRC_USED_PREFIX = "VMP_MEDIA_USED_SSRC_";
|
||||
|
||||
public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_MEDIA_TRANSACTION_";
|
||||
|
||||
public static final String MEDIA_STREAM_AUTHORITY = "MEDIA_STREAM_AUTHORITY_";
|
||||
|
||||
public static final String SIP_CSEQ_PREFIX = "VMP_SIP_CSEQ_";
|
||||
|
||||
public static final String SIP_SN_PREFIX = "VMP_SIP_SN_";
|
||||
|
||||
public static final String SIP_SUBSCRIBE_PREFIX = "VMP_SIP_SUBSCRIBE_";
|
||||
|
||||
public static final String SYSTEM_INFO_CPU_PREFIX = "VMP_SYSTEM_INFO_CPU_";
|
||||
|
||||
public static final String SYSTEM_INFO_MEM_PREFIX = "VMP_SYSTEM_INFO_MEM_";
|
||||
|
||||
public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_";
|
||||
|
||||
public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_";
|
||||
|
||||
public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";
|
||||
|
||||
|
||||
|
||||
|
||||
//************************** redis 消息*********************************
|
||||
|
||||
/**
|
||||
* 流变化的通知
|
||||
*/
|
||||
public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";
|
||||
|
||||
/**
|
||||
* 接收推流设备的GPS变化通知
|
||||
*/
|
||||
public static final String VM_MSG_GPS = "VM_MSG_GPS";
|
||||
|
||||
/**
|
||||
* 接收推流设备的GPS变化通知
|
||||
*/
|
||||
public static final String VM_MSG_PUSH_STREAM_STATUS_CHANGE = "VM_MSG_PUSH_STREAM_STATUS_CHANGE";
|
||||
/**
|
||||
* 接收推流设备列表更新变化通知
|
||||
*/
|
||||
public static final String VM_MSG_PUSH_STREAM_LIST_CHANGE = "VM_MSG_PUSH_STREAM_LIST_CHANGE";
|
||||
|
||||
/**
|
||||
* redis 消息通知设备推流到平台
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED";
|
||||
|
||||
/**
|
||||
* redis 消息通知上级平台开始观看流
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_START_PLAY_NOTIFY = "VM_MSG_STREAM_START_PLAY_NOTIFY";
|
||||
|
||||
/**
|
||||
* redis 消息通知上级平台停止观看流
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_STOP_PLAY_NOTIFY = "VM_MSG_STREAM_STOP_PLAY_NOTIFY";
|
||||
|
||||
/**
|
||||
* redis 消息接收关闭一个推流
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_PUSH_CLOSE_REQUESTED = "VM_MSG_STREAM_PUSH_CLOSE_REQUESTED";
|
||||
|
||||
|
||||
/**
|
||||
* redis 消息通知平台通知设备推流结果
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_PUSH_RESPONSE = "VM_MSG_STREAM_PUSH_RESPONSE";
|
||||
|
||||
/**
|
||||
* redis 通知平台关闭推流
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_PUSH_CLOSE = "VM_MSG_STREAM_PUSH_CLOSE";
|
||||
|
||||
/**
|
||||
* redis 消息请求所有的在线通道
|
||||
*/
|
||||
public static final String VM_MSG_GET_ALL_ONLINE_REQUESTED = "VM_MSG_GET_ALL_ONLINE_REQUESTED";
|
||||
|
||||
/**
|
||||
* 移动位置订阅通知
|
||||
*/
|
||||
public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition";
|
||||
|
||||
/**
|
||||
* 报警订阅的通知(收到报警向redis发出通知)
|
||||
*/
|
||||
public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm";
|
||||
|
||||
|
||||
/**
|
||||
* 报警通知的发送 (收到redis发出的通知,转发给其他平台)
|
||||
*/
|
||||
public static final String VM_MSG_SUBSCRIBE_ALARM_RECEIVE= "alarm_receive";
|
||||
|
||||
/**
|
||||
* 设备状态订阅的通知
|
||||
*/
|
||||
public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device";
|
||||
|
||||
|
||||
//************************** 第三方 ****************************************
|
||||
|
||||
public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";
|
||||
public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_";
|
||||
public static final String WVP_OTHER_SEND_RTP_INFO = "VMP_OTHER_SEND_RTP_INFO_";
|
||||
public static final String WVP_OTHER_SEND_PS_INFO = "VMP_OTHER_SEND_PS_INFO_";
|
||||
public static final String WVP_OTHER_RECEIVE_RTP_INFO = "VMP_OTHER_RECEIVE_RTP_INFO_";
|
||||
public static final String WVP_OTHER_RECEIVE_PS_INFO = "VMP_OTHER_RECEIVE_PS_INFO_";
|
||||
|
||||
/**
|
||||
* Redis Const
|
||||
* 设备录像信息结果前缀
|
||||
*/
|
||||
public static final String REDIS_RECORD_INFO_RES_PRE = "GB_RECORD_INFO_RES_";
|
||||
/**
|
||||
* Redis Const
|
||||
* 设备录像信息结果前缀
|
||||
*/
|
||||
public static final String REDIS_RECORD_INFO_RES_COUNT_PRE = "GB_RECORD_INFO_RES_COUNT:";
|
||||
|
||||
}
|
||||
package com.genersoft.iot.vmp.common;
|
||||
|
||||
/**
|
||||
* @description: 定义常量
|
||||
* @author: swwheihei
|
||||
* @date: 2019年5月30日 下午3:04:04
|
||||
*
|
||||
*/
|
||||
public class VideoManagerConstants {
|
||||
|
||||
public static final String WVP_SERVER_PREFIX = "VMP_SIGNALLING_SERVER_INFO_";
|
||||
|
||||
public static final String WVP_SERVER_STREAM_PREFIX = "VMP_SIGNALLING_STREAM_";
|
||||
|
||||
public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_";
|
||||
|
||||
public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS_";
|
||||
|
||||
public static final String DEVICE_PREFIX = "VMP_DEVICE_";
|
||||
|
||||
// 设备同步完成
|
||||
public static final String DEVICE_SYNC_PREFIX = "VMP_DEVICE_SYNC_";
|
||||
|
||||
public static final String CACHEKEY_PREFIX = "VMP_CHANNEL_";
|
||||
|
||||
public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_";
|
||||
|
||||
// TODO 此处多了一个_,暂不修改
|
||||
public static final String INVITE_PREFIX = "VMP_INVITE";
|
||||
public static final String PLAYER_PREFIX = "VMP_INVITE_PLAY_";
|
||||
public static final String PLAY_BLACK_PREFIX = "VMP_INVITE_PLAYBACK_";
|
||||
public static final String DOWNLOAD_PREFIX = "VMP_INVITE_DOWNLOAD_";
|
||||
|
||||
public static final String PLATFORM_KEEPALIVE_PREFIX = "VMP_PLATFORM_KEEPALIVE_";
|
||||
|
||||
public static final String PLATFORM_CATCH_PREFIX = "VMP_PLATFORM_CATCH_";
|
||||
|
||||
public static final String PLATFORM_REGISTER_PREFIX = "VMP_PLATFORM_REGISTER_";
|
||||
|
||||
public static final String PLATFORM_REGISTER_INFO_PREFIX = "VMP_PLATFORM_REGISTER_INFO_";
|
||||
|
||||
public static final String PLATFORM_SEND_RTP_INFO_PREFIX = "VMP_PLATFORM_SEND_RTP_INFO_";
|
||||
|
||||
public static final String EVENT_ONLINE_REGISTER = "1";
|
||||
|
||||
public static final String EVENT_ONLINE_MESSAGE = "3";
|
||||
|
||||
public static final String EVENT_OUTLINE_UNREGISTER = "1";
|
||||
|
||||
public static final String EVENT_OUTLINE_TIMEOUT = "2";
|
||||
|
||||
public static final String MEDIA_SSRC_USED_PREFIX = "VMP_MEDIA_USED_SSRC_";
|
||||
|
||||
public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_MEDIA_TRANSACTION_";
|
||||
|
||||
public static final String MEDIA_STREAM_AUTHORITY = "MEDIA_STREAM_AUTHORITY_";
|
||||
|
||||
public static final String SIP_CSEQ_PREFIX = "VMP_SIP_CSEQ_";
|
||||
|
||||
public static final String SIP_SN_PREFIX = "VMP_SIP_SN_";
|
||||
|
||||
public static final String SIP_SUBSCRIBE_PREFIX = "VMP_SIP_SUBSCRIBE_";
|
||||
|
||||
public static final String SYSTEM_INFO_CPU_PREFIX = "VMP_SYSTEM_INFO_CPU_";
|
||||
|
||||
public static final String SYSTEM_INFO_MEM_PREFIX = "VMP_SYSTEM_INFO_MEM_";
|
||||
|
||||
public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_";
|
||||
|
||||
public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_";
|
||||
|
||||
public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";
|
||||
|
||||
|
||||
|
||||
|
||||
//************************** redis 消息*********************************
|
||||
|
||||
/**
|
||||
* 流变化的通知
|
||||
*/
|
||||
public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_";
|
||||
|
||||
/**
|
||||
* 接收推流设备的GPS变化通知
|
||||
*/
|
||||
public static final String VM_MSG_GPS = "VM_MSG_GPS";
|
||||
|
||||
/**
|
||||
* 接收推流设备的GPS变化通知
|
||||
*/
|
||||
public static final String VM_MSG_PUSH_STREAM_STATUS_CHANGE = "VM_MSG_PUSH_STREAM_STATUS_CHANGE";
|
||||
/**
|
||||
* 接收推流设备列表更新变化通知
|
||||
*/
|
||||
public static final String VM_MSG_PUSH_STREAM_LIST_CHANGE = "VM_MSG_PUSH_STREAM_LIST_CHANGE";
|
||||
|
||||
/**
|
||||
* redis 消息通知设备推流到平台
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED";
|
||||
|
||||
/**
|
||||
* redis 消息通知上级平台开始观看流
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_START_PLAY_NOTIFY = "VM_MSG_STREAM_START_PLAY_NOTIFY";
|
||||
|
||||
/**
|
||||
* redis 消息通知上级平台停止观看流
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_STOP_PLAY_NOTIFY = "VM_MSG_STREAM_STOP_PLAY_NOTIFY";
|
||||
|
||||
/**
|
||||
* redis 消息接收关闭一个推流
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_PUSH_CLOSE_REQUESTED = "VM_MSG_STREAM_PUSH_CLOSE_REQUESTED";
|
||||
|
||||
|
||||
/**
|
||||
* redis 消息通知平台通知设备推流结果
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_PUSH_RESPONSE = "VM_MSG_STREAM_PUSH_RESPONSE";
|
||||
|
||||
/**
|
||||
* redis 通知平台关闭推流
|
||||
*/
|
||||
public static final String VM_MSG_STREAM_PUSH_CLOSE = "VM_MSG_STREAM_PUSH_CLOSE";
|
||||
|
||||
/**
|
||||
* redis 消息请求所有的在线通道
|
||||
*/
|
||||
public static final String VM_MSG_GET_ALL_ONLINE_REQUESTED = "VM_MSG_GET_ALL_ONLINE_REQUESTED";
|
||||
|
||||
/**
|
||||
* 移动位置订阅通知
|
||||
*/
|
||||
public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition";
|
||||
|
||||
/**
|
||||
* 报警订阅的通知(收到报警向redis发出通知)
|
||||
*/
|
||||
public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm";
|
||||
|
||||
|
||||
/**
|
||||
* 报警通知的发送 (收到redis发出的通知,转发给其他平台)
|
||||
*/
|
||||
public static final String VM_MSG_SUBSCRIBE_ALARM_RECEIVE= "alarm_receive";
|
||||
|
||||
/**
|
||||
* 设备状态订阅的通知
|
||||
*/
|
||||
public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device";
|
||||
|
||||
|
||||
//************************** 第三方 ****************************************
|
||||
|
||||
public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_";
|
||||
public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_";
|
||||
public static final String WVP_OTHER_SEND_RTP_INFO = "VMP_OTHER_SEND_RTP_INFO_";
|
||||
public static final String WVP_OTHER_SEND_PS_INFO = "VMP_OTHER_SEND_PS_INFO_";
|
||||
public static final String WVP_OTHER_RECEIVE_RTP_INFO = "VMP_OTHER_RECEIVE_RTP_INFO_";
|
||||
public static final String WVP_OTHER_RECEIVE_PS_INFO = "VMP_OTHER_RECEIVE_PS_INFO_";
|
||||
|
||||
/**
|
||||
* Redis Const
|
||||
* 设备录像信息结果前缀
|
||||
*/
|
||||
public static final String REDIS_RECORD_INFO_RES_PRE = "GB_RECORD_INFO_RES_";
|
||||
/**
|
||||
* Redis Const
|
||||
* 设备录像信息结果前缀
|
||||
*/
|
||||
public static final String REDIS_RECORD_INFO_RES_COUNT_PRE = "GB_RECORD_INFO_RES_COUNT:";
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class ApiAccessFilter extends OncePerRequestFilter {
|
||||
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
|
||||
if (uriName != null && userSetting != null && userSetting.getLogInDatebase() != null && userSetting.getLogInDatebase()) {
|
||||
if (uriName != null && userSetting != null && userSetting.getLogInDatabase() != null && userSetting.getLogInDatabase()) {
|
||||
|
||||
LogDto logDto = new LogDto();
|
||||
logDto.setName(uriName);
|
||||
|
@ -4,13 +4,19 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.genersoft.iot.vmp.service.IPlatformService;
|
||||
import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -33,6 +39,7 @@ public class SipPlatformRunner implements CommandLineRunner {
|
||||
@Autowired
|
||||
private ISIPCommanderForPlatform sipCommanderForPlatform;
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
@ -50,9 +57,13 @@ public class SipPlatformRunner implements CommandLineRunner {
|
||||
redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
|
||||
if (parentPlatformCatchOld != null) {
|
||||
// 取消订阅
|
||||
sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{
|
||||
platformService.login(parentPlatform);
|
||||
});
|
||||
try {
|
||||
sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{
|
||||
platformService.login(parentPlatform);
|
||||
});
|
||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
||||
logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 设置所有平台离线
|
||||
|
@ -31,7 +31,7 @@ public class UserSetting {
|
||||
|
||||
private Boolean recordSip = Boolean.TRUE;
|
||||
|
||||
private Boolean logInDatebase = Boolean.TRUE;
|
||||
private Boolean logInDatabase = Boolean.TRUE;
|
||||
|
||||
private Boolean usePushingAsStatus = Boolean.TRUE;
|
||||
|
||||
@ -132,12 +132,12 @@ public class UserSetting {
|
||||
this.interfaceAuthenticationExcludes = interfaceAuthenticationExcludes;
|
||||
}
|
||||
|
||||
public Boolean getLogInDatebase() {
|
||||
return logInDatebase;
|
||||
public Boolean getLogInDatabase() {
|
||||
return logInDatabase;
|
||||
}
|
||||
|
||||
public void setLogInDatebase(Boolean logInDatebase) {
|
||||
this.logInDatebase = logInDatebase;
|
||||
public void setLogInDatabase(Boolean logInDatabase) {
|
||||
this.logInDatabase = logInDatabase;
|
||||
}
|
||||
|
||||
public String getServerId() {
|
||||
|
@ -1,141 +1,141 @@
|
||||
package com.genersoft.iot.vmp.gb28181;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStringMsgParserFactory;
|
||||
import com.genersoft.iot.vmp.gb28181.conf.DefaultProperties;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.ISIPProcessorObserver;
|
||||
import gov.nist.javax.sip.SipProviderImpl;
|
||||
import gov.nist.javax.sip.SipStackImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.sip.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Component
|
||||
@Order(value=10)
|
||||
public class SipLayer implements CommandLineRunner {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);
|
||||
|
||||
@Autowired
|
||||
private SipConfig sipConfig;
|
||||
|
||||
@Autowired
|
||||
private ISIPProcessorObserver sipProcessorObserver;
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>();
|
||||
private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
List<String> monitorIps = new ArrayList<>();
|
||||
// 使用逗号分割多个ip
|
||||
String separator = ",";
|
||||
if (sipConfig.getIp().indexOf(separator) > 0) {
|
||||
String[] split = sipConfig.getIp().split(separator);
|
||||
monitorIps.addAll(Arrays.asList(split));
|
||||
}else {
|
||||
monitorIps.add(sipConfig.getIp());
|
||||
}
|
||||
|
||||
SipFactory.getInstance().setPathName("gov.nist");
|
||||
if (monitorIps.size() > 0) {
|
||||
for (String monitorIp : monitorIps) {
|
||||
addListeningPoint(monitorIp, sipConfig.getPort());
|
||||
}
|
||||
if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addListeningPoint(String monitorIp, int port){
|
||||
SipStackImpl sipStack;
|
||||
try {
|
||||
sipStack = (SipStackImpl)SipFactory.getInstance().createSipStack(DefaultProperties.getProperties("GB28181_SIP", userSetting.getSipLog()));
|
||||
sipStack.setMessageParserFactory(new GbStringMsgParserFactory());
|
||||
} catch (PeerUnavailableException e) {
|
||||
logger.error("[SIP SERVER] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP");
|
||||
SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
|
||||
|
||||
tcpSipProvider.setDialogErrorsAutomaticallyHandled();
|
||||
tcpSipProvider.addSipListener(sipProcessorObserver);
|
||||
tcpSipProviderMap.put(monitorIp, tcpSipProvider);
|
||||
logger.info("[SIP SERVER] tcp://{}:{} 启动成功", monitorIp, port);
|
||||
} catch (TransportNotSupportedException
|
||||
| TooManyListenersException
|
||||
| ObjectInUseException
|
||||
| InvalidArgumentException e) {
|
||||
logger.error("[SIP SERVER] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
|
||||
, monitorIp, port);
|
||||
}
|
||||
|
||||
try {
|
||||
ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP");
|
||||
|
||||
SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
|
||||
udpSipProvider.addSipListener(sipProcessorObserver);
|
||||
|
||||
udpSipProviderMap.put(monitorIp, udpSipProvider);
|
||||
|
||||
logger.info("[SIP SERVER] udp://{}:{} 启动成功", monitorIp, port);
|
||||
} catch (TransportNotSupportedException
|
||||
| TooManyListenersException
|
||||
| ObjectInUseException
|
||||
| InvalidArgumentException e) {
|
||||
logger.error("[SIP SERVER] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
|
||||
, monitorIp, port);
|
||||
}
|
||||
}
|
||||
|
||||
public SipProviderImpl getUdpSipProvider(String ip) {
|
||||
if (ObjectUtils.isEmpty(ip)) {
|
||||
return null;
|
||||
}
|
||||
return udpSipProviderMap.get(ip);
|
||||
}
|
||||
|
||||
public SipProviderImpl getUdpSipProvider() {
|
||||
if (udpSipProviderMap.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
return udpSipProviderMap.values().stream().findFirst().get();
|
||||
}
|
||||
|
||||
public SipProviderImpl getTcpSipProvider() {
|
||||
if (tcpSipProviderMap.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
return tcpSipProviderMap.values().stream().findFirst().get();
|
||||
}
|
||||
|
||||
public SipProviderImpl getTcpSipProvider(String ip) {
|
||||
if (ObjectUtils.isEmpty(ip)) {
|
||||
return null;
|
||||
}
|
||||
return tcpSipProviderMap.get(ip);
|
||||
}
|
||||
|
||||
public String getLocalIp(String deviceLocalIp) {
|
||||
if (!ObjectUtils.isEmpty(deviceLocalIp)) {
|
||||
return deviceLocalIp;
|
||||
}
|
||||
return getUdpSipProvider().getListeningPoint().getIPAddress();
|
||||
}
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStringMsgParserFactory;
|
||||
import com.genersoft.iot.vmp.gb28181.conf.DefaultProperties;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.ISIPProcessorObserver;
|
||||
import gov.nist.javax.sip.SipProviderImpl;
|
||||
import gov.nist.javax.sip.SipStackImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.sip.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Component
|
||||
@Order(value=10)
|
||||
public class SipLayer implements CommandLineRunner {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);
|
||||
|
||||
@Autowired
|
||||
private SipConfig sipConfig;
|
||||
|
||||
@Autowired
|
||||
private ISIPProcessorObserver sipProcessorObserver;
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>();
|
||||
private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
List<String> monitorIps = new ArrayList<>();
|
||||
// 使用逗号分割多个ip
|
||||
String separator = ",";
|
||||
if (sipConfig.getIp().indexOf(separator) > 0) {
|
||||
String[] split = sipConfig.getIp().split(separator);
|
||||
monitorIps.addAll(Arrays.asList(split));
|
||||
}else {
|
||||
monitorIps.add(sipConfig.getIp());
|
||||
}
|
||||
|
||||
SipFactory.getInstance().setPathName("gov.nist");
|
||||
if (monitorIps.size() > 0) {
|
||||
for (String monitorIp : monitorIps) {
|
||||
addListeningPoint(monitorIp, sipConfig.getPort());
|
||||
}
|
||||
if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addListeningPoint(String monitorIp, int port){
|
||||
SipStackImpl sipStack;
|
||||
try {
|
||||
sipStack = (SipStackImpl)SipFactory.getInstance().createSipStack(DefaultProperties.getProperties("GB28181_SIP", userSetting.getSipLog()));
|
||||
sipStack.setMessageParserFactory(new GbStringMsgParserFactory());
|
||||
} catch (PeerUnavailableException e) {
|
||||
logger.error("[SIP SERVER] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP");
|
||||
SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
|
||||
|
||||
tcpSipProvider.setDialogErrorsAutomaticallyHandled();
|
||||
tcpSipProvider.addSipListener(sipProcessorObserver);
|
||||
tcpSipProviderMap.put(monitorIp, tcpSipProvider);
|
||||
logger.info("[SIP SERVER] tcp://{}:{} 启动成功", monitorIp, port);
|
||||
} catch (TransportNotSupportedException
|
||||
| TooManyListenersException
|
||||
| ObjectInUseException
|
||||
| InvalidArgumentException e) {
|
||||
logger.error("[SIP SERVER] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
|
||||
, monitorIp, port);
|
||||
}
|
||||
|
||||
try {
|
||||
ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP");
|
||||
|
||||
SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
|
||||
udpSipProvider.addSipListener(sipProcessorObserver);
|
||||
|
||||
udpSipProviderMap.put(monitorIp, udpSipProvider);
|
||||
|
||||
logger.info("[SIP SERVER] udp://{}:{} 启动成功", monitorIp, port);
|
||||
} catch (TransportNotSupportedException
|
||||
| TooManyListenersException
|
||||
| ObjectInUseException
|
||||
| InvalidArgumentException e) {
|
||||
logger.error("[SIP SERVER] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
|
||||
, monitorIp, port);
|
||||
}
|
||||
}
|
||||
|
||||
public SipProviderImpl getUdpSipProvider(String ip) {
|
||||
if (ObjectUtils.isEmpty(ip)) {
|
||||
return null;
|
||||
}
|
||||
return udpSipProviderMap.get(ip);
|
||||
}
|
||||
|
||||
public SipProviderImpl getUdpSipProvider() {
|
||||
if (udpSipProviderMap.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
return udpSipProviderMap.values().stream().findFirst().get();
|
||||
}
|
||||
|
||||
public SipProviderImpl getTcpSipProvider() {
|
||||
if (tcpSipProviderMap.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
return tcpSipProviderMap.values().stream().findFirst().get();
|
||||
}
|
||||
|
||||
public SipProviderImpl getTcpSipProvider(String ip) {
|
||||
if (ObjectUtils.isEmpty(ip)) {
|
||||
return null;
|
||||
}
|
||||
return tcpSipProviderMap.get(ip);
|
||||
}
|
||||
|
||||
public String getLocalIp(String deviceLocalIp) {
|
||||
if (!ObjectUtils.isEmpty(deviceLocalIp)) {
|
||||
return deviceLocalIp;
|
||||
}
|
||||
return getUdpSipProvider().getListeningPoint().getIPAddress();
|
||||
}
|
||||
}
|
||||
|
@ -1,187 +1,187 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* @author lin
|
||||
*/
|
||||
@Schema(description = "报警信息")
|
||||
public class DeviceAlarm {
|
||||
|
||||
/**
|
||||
* 数据库id
|
||||
*/
|
||||
@Schema(description = "数据库id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 设备Id
|
||||
*/
|
||||
@Schema(description = "设备的国标编号")
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 通道Id
|
||||
*/
|
||||
@Schema(description = "通道的国标编号")
|
||||
private String channelId;
|
||||
|
||||
/**
|
||||
* 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情
|
||||
*/
|
||||
@Schema(description = "报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情")
|
||||
private String alarmPriority;
|
||||
|
||||
/**
|
||||
* 报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,
|
||||
* 7其他报警;可以为直接组合如12为电话报警或 设备报警-
|
||||
*/
|
||||
@Schema(description = "报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,\n" +
|
||||
"\t * 7其他报警;可以为直接组合如12为电话报警或设备报警")
|
||||
private String alarmMethod;
|
||||
|
||||
/**
|
||||
* 报警时间
|
||||
*/
|
||||
@Schema(description = "报警时间")
|
||||
private String alarmTime;
|
||||
|
||||
/**
|
||||
* 报警内容描述
|
||||
*/
|
||||
@Schema(description = "报警内容描述")
|
||||
private String alarmDescription;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@Schema(description = "经度")
|
||||
private double longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@Schema(description = "纬度")
|
||||
private double latitude;
|
||||
|
||||
/**
|
||||
* 报警类型,
|
||||
* 报警方式为2时,不携带 AlarmType为默认的报警设备报警,
|
||||
* 携带 AlarmType取值及对应报警类型如下:
|
||||
* 1-视频丢失报警;
|
||||
* 2-设备防拆报警;
|
||||
* 3-存储设备磁盘满报警;
|
||||
* 4-设备高温报警;
|
||||
* 5-设备低温报警。
|
||||
* 报警方式为5时,取值如下:
|
||||
* 1-人工视频报警;
|
||||
* 2-运动目标检测报警;
|
||||
* 3-遗留物检测报警;
|
||||
* 4-物体移除检测报警;
|
||||
* 5-绊线检测报警;
|
||||
* 6-入侵检测报警;
|
||||
* 7-逆行检测报警;
|
||||
* 8-徘徊检测报警;
|
||||
* 9-流量统计报警;
|
||||
* 10-密度检测报警;
|
||||
* 11-视频异常检测报警;
|
||||
* 12-快速移动报警。
|
||||
* 报警方式为6时,取值下:
|
||||
* 1-存储设备磁盘故障报警;
|
||||
* 2-存储设备风扇故障报警。
|
||||
*/
|
||||
@Schema(description = "报警类型")
|
||||
private String alarmType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getAlarmPriority() {
|
||||
return alarmPriority;
|
||||
}
|
||||
|
||||
public void setAlarmPriority(String alarmPriority) {
|
||||
this.alarmPriority = alarmPriority;
|
||||
}
|
||||
|
||||
public String getAlarmMethod() {
|
||||
return alarmMethod;
|
||||
}
|
||||
|
||||
public void setAlarmMethod(String alarmMethod) {
|
||||
this.alarmMethod = alarmMethod;
|
||||
}
|
||||
|
||||
public String getAlarmTime() {
|
||||
return alarmTime;
|
||||
}
|
||||
|
||||
public void setAlarmTime(String alarmTime) {
|
||||
this.alarmTime = alarmTime;
|
||||
}
|
||||
|
||||
public String getAlarmDescription() {
|
||||
return alarmDescription;
|
||||
}
|
||||
|
||||
public void setAlarmDescription(String alarmDescription) {
|
||||
this.alarmDescription = alarmDescription;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getAlarmType() {
|
||||
return alarmType;
|
||||
}
|
||||
|
||||
public void setAlarmType(String alarmType) {
|
||||
this.alarmType = alarmType;
|
||||
}
|
||||
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public void setChannelId(String channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* @author lin
|
||||
*/
|
||||
@Schema(description = "报警信息")
|
||||
public class DeviceAlarm {
|
||||
|
||||
/**
|
||||
* 数据库id
|
||||
*/
|
||||
@Schema(description = "数据库id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 设备Id
|
||||
*/
|
||||
@Schema(description = "设备的国标编号")
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 通道Id
|
||||
*/
|
||||
@Schema(description = "通道的国标编号")
|
||||
private String channelId;
|
||||
|
||||
/**
|
||||
* 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情
|
||||
*/
|
||||
@Schema(description = "报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情")
|
||||
private String alarmPriority;
|
||||
|
||||
/**
|
||||
* 报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,
|
||||
* 7其他报警;可以为直接组合如12为电话报警或 设备报警-
|
||||
*/
|
||||
@Schema(description = "报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,\n" +
|
||||
"\t * 7其他报警;可以为直接组合如12为电话报警或设备报警")
|
||||
private String alarmMethod;
|
||||
|
||||
/**
|
||||
* 报警时间
|
||||
*/
|
||||
@Schema(description = "报警时间")
|
||||
private String alarmTime;
|
||||
|
||||
/**
|
||||
* 报警内容描述
|
||||
*/
|
||||
@Schema(description = "报警内容描述")
|
||||
private String alarmDescription;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@Schema(description = "经度")
|
||||
private double longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@Schema(description = "纬度")
|
||||
private double latitude;
|
||||
|
||||
/**
|
||||
* 报警类型,
|
||||
* 报警方式为2时,不携带 AlarmType为默认的报警设备报警,
|
||||
* 携带 AlarmType取值及对应报警类型如下:
|
||||
* 1-视频丢失报警;
|
||||
* 2-设备防拆报警;
|
||||
* 3-存储设备磁盘满报警;
|
||||
* 4-设备高温报警;
|
||||
* 5-设备低温报警。
|
||||
* 报警方式为5时,取值如下:
|
||||
* 1-人工视频报警;
|
||||
* 2-运动目标检测报警;
|
||||
* 3-遗留物检测报警;
|
||||
* 4-物体移除检测报警;
|
||||
* 5-绊线检测报警;
|
||||
* 6-入侵检测报警;
|
||||
* 7-逆行检测报警;
|
||||
* 8-徘徊检测报警;
|
||||
* 9-流量统计报警;
|
||||
* 10-密度检测报警;
|
||||
* 11-视频异常检测报警;
|
||||
* 12-快速移动报警。
|
||||
* 报警方式为6时,取值下:
|
||||
* 1-存储设备磁盘故障报警;
|
||||
* 2-存储设备风扇故障报警。
|
||||
*/
|
||||
@Schema(description = "报警类型")
|
||||
private String alarmType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getAlarmPriority() {
|
||||
return alarmPriority;
|
||||
}
|
||||
|
||||
public void setAlarmPriority(String alarmPriority) {
|
||||
this.alarmPriority = alarmPriority;
|
||||
}
|
||||
|
||||
public String getAlarmMethod() {
|
||||
return alarmMethod;
|
||||
}
|
||||
|
||||
public void setAlarmMethod(String alarmMethod) {
|
||||
this.alarmMethod = alarmMethod;
|
||||
}
|
||||
|
||||
public String getAlarmTime() {
|
||||
return alarmTime;
|
||||
}
|
||||
|
||||
public void setAlarmTime(String alarmTime) {
|
||||
this.alarmTime = alarmTime;
|
||||
}
|
||||
|
||||
public String getAlarmDescription() {
|
||||
return alarmDescription;
|
||||
}
|
||||
|
||||
public void setAlarmDescription(String alarmDescription) {
|
||||
this.alarmDescription = alarmDescription;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public String getAlarmType() {
|
||||
return alarmType;
|
||||
}
|
||||
|
||||
public void setAlarmType(String alarmType) {
|
||||
this.alarmType = alarmType;
|
||||
}
|
||||
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public void setChannelId(String channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GBStringMsgParser.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GBStringMsgParser.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStringMsgParserFactory.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStringMsgParserFactory.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/HandlerCatchData.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/HandlerCatchData.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/HomePositionRequest.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/HomePositionRequest.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Host.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Host.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamCallback.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamCallback.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformRegister.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformRegister.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java
Normal file → Executable file
204
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java
Normal file → Executable file
204
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java
Normal file → Executable file
@ -1,102 +1,102 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description:设备录像信息bean
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月8日 下午2:05:56
|
||||
*/
|
||||
@Schema(description = "设备录像查询结果信息")
|
||||
public class RecordInfo {
|
||||
|
||||
@Schema(description = "设备编号")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "通道编号")
|
||||
private String channelId;
|
||||
|
||||
@Schema(description = "命令序列号")
|
||||
private String sn;
|
||||
|
||||
@Schema(description = "设备名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "列表总数")
|
||||
private int sumNum;
|
||||
|
||||
private int count;
|
||||
|
||||
private Instant lastTime;
|
||||
|
||||
@Schema(description = "")
|
||||
private List<RecordItem> recordList;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getSumNum() {
|
||||
return sumNum;
|
||||
}
|
||||
|
||||
public void setSumNum(int sumNum) {
|
||||
this.sumNum = sumNum;
|
||||
}
|
||||
|
||||
public List<RecordItem> getRecordList() {
|
||||
return recordList;
|
||||
}
|
||||
|
||||
public void setRecordList(List<RecordItem> recordList) {
|
||||
this.recordList = recordList;
|
||||
}
|
||||
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public void setChannelId(String channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public Instant getLastTime() {
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
public void setLastTime(Instant lastTime) {
|
||||
this.lastTime = lastTime;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description:设备录像信息bean
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月8日 下午2:05:56
|
||||
*/
|
||||
@Schema(description = "设备录像查询结果信息")
|
||||
public class RecordInfo {
|
||||
|
||||
@Schema(description = "设备编号")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "通道编号")
|
||||
private String channelId;
|
||||
|
||||
@Schema(description = "命令序列号")
|
||||
private String sn;
|
||||
|
||||
@Schema(description = "设备名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "列表总数")
|
||||
private int sumNum;
|
||||
|
||||
private int count;
|
||||
|
||||
private Instant lastTime;
|
||||
|
||||
@Schema(description = "")
|
||||
private List<RecordItem> recordList;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getSumNum() {
|
||||
return sumNum;
|
||||
}
|
||||
|
||||
public void setSumNum(int sumNum) {
|
||||
this.sumNum = sumNum;
|
||||
}
|
||||
|
||||
public List<RecordItem> getRecordList() {
|
||||
return recordList;
|
||||
}
|
||||
|
||||
public void setRecordList(List<RecordItem> recordList) {
|
||||
this.recordList = recordList;
|
||||
}
|
||||
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public void setChannelId(String channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public Instant getLastTime() {
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
public void setLastTime(Instant lastTime) {
|
||||
this.lastTime = lastTime;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
|
288
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordItem.java
Normal file → Executable file
288
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordItem.java
Normal file → Executable file
@ -1,144 +1,144 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
|
||||
/**
|
||||
* @description:设备录像bean
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月8日 下午2:06:54
|
||||
*/
|
||||
@Schema(description = "设备录像详情")
|
||||
public class RecordItem implements Comparable<RecordItem>{
|
||||
|
||||
@Schema(description = "设备编号")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "文件路径名 (可选)")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "录像文件大小,单位:Byte(可选)")
|
||||
private String fileSize;
|
||||
|
||||
@Schema(description = "录像地址(可选)")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "录像开始时间(可选)")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "录像结束时间(可选)")
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "保密属性(必选)缺省为0;0:不涉密,1:涉密")
|
||||
private int secrecy;
|
||||
|
||||
@Schema(description = "录像产生类型(可选)time或alarm 或 manua")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "录像触发者ID(可选)")
|
||||
private String recorderId;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public int getSecrecy() {
|
||||
return secrecy;
|
||||
}
|
||||
|
||||
public void setSecrecy(int secrecy) {
|
||||
this.secrecy = secrecy;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getRecorderId() {
|
||||
return recorderId;
|
||||
}
|
||||
|
||||
public void setRecorderId(String recorderId) {
|
||||
this.recorderId = recorderId;
|
||||
}
|
||||
|
||||
public String getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(String fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull RecordItem recordItem) {
|
||||
TemporalAccessor startTimeNow = DateUtil.formatter.parse(startTime);
|
||||
TemporalAccessor startTimeParam = DateUtil.formatter.parse(recordItem.getStartTime());
|
||||
Instant startTimeParamInstant = Instant.from(startTimeParam);
|
||||
Instant startTimeNowInstant = Instant.from(startTimeNow);
|
||||
if (startTimeNowInstant.equals(startTimeParamInstant)) {
|
||||
return 0;
|
||||
}else if (Instant.from(startTimeParam).isAfter(Instant.from(startTimeNow)) ) {
|
||||
return -1;
|
||||
}else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
|
||||
/**
|
||||
* @description:设备录像bean
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月8日 下午2:06:54
|
||||
*/
|
||||
@Schema(description = "设备录像详情")
|
||||
public class RecordItem implements Comparable<RecordItem>{
|
||||
|
||||
@Schema(description = "设备编号")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "文件路径名 (可选)")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "录像文件大小,单位:Byte(可选)")
|
||||
private String fileSize;
|
||||
|
||||
@Schema(description = "录像地址(可选)")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "录像开始时间(可选)")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "录像结束时间(可选)")
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "保密属性(必选)缺省为0;0:不涉密,1:涉密")
|
||||
private int secrecy;
|
||||
|
||||
@Schema(description = "录像产生类型(可选)time或alarm 或 manua")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "录像触发者ID(可选)")
|
||||
private String recorderId;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public int getSecrecy() {
|
||||
return secrecy;
|
||||
}
|
||||
|
||||
public void setSecrecy(int secrecy) {
|
||||
this.secrecy = secrecy;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getRecorderId() {
|
||||
return recorderId;
|
||||
}
|
||||
|
||||
public void setRecorderId(String recorderId) {
|
||||
this.recorderId = recorderId;
|
||||
}
|
||||
|
||||
public String getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(String fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull RecordItem recordItem) {
|
||||
TemporalAccessor startTimeNow = DateUtil.formatter.parse(startTime);
|
||||
TemporalAccessor startTimeParam = DateUtil.formatter.parse(recordItem.getStartTime());
|
||||
Instant startTimeParamInstant = Instant.from(startTimeParam);
|
||||
Instant startTimeNowInstant = Instant.from(startTimeNow);
|
||||
if (startTimeNowInstant.equals(startTimeParamInstant)) {
|
||||
return 0;
|
||||
}else if (Instant.from(startTimeParam).isAfter(Instant.from(startTimeNow)) ) {
|
||||
return -1;
|
||||
}else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RemoteAddressInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RemoteAddressInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SDPInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SDPInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipMsgInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipMsgInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipTransactionInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipTransactionInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SyncStatus.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SyncStatus.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/conf/ServerLoggerImpl.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/conf/ServerLoggerImpl.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java
Normal file → Executable file
236
src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
Normal file → Executable file
236
src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
Normal file → Executable file
@ -1,118 +1,118 @@
|
||||
package com.genersoft.iot.vmp.gb28181.event;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
|
||||
import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
|
||||
|
||||
import javax.sip.TimeoutEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @description:Event事件通知推送器,支持推送在线事件、离线事件
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月6日 上午11:30:50
|
||||
*/
|
||||
@Component
|
||||
public class EventPublisher {
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
/**
|
||||
* 设备报警事件
|
||||
* @param deviceAlarm
|
||||
*/
|
||||
public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) {
|
||||
AlarmEvent alarmEvent = new AlarmEvent(this);
|
||||
alarmEvent.setAlarmInfo(deviceAlarm);
|
||||
applicationEventPublisher.publishEvent(alarmEvent);
|
||||
}
|
||||
|
||||
public void zlmOfflineEventPublish(String mediaServerId){
|
||||
ZLMOfflineEvent outEvent = new ZLMOfflineEvent(this);
|
||||
outEvent.setMediaServerId(mediaServerId);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
public void zlmOnlineEventPublish(String mediaServerId) {
|
||||
ZLMOnlineEvent outEvent = new ZLMOnlineEvent(this);
|
||||
outEvent.setMediaServerId(mediaServerId);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
|
||||
public void catalogEventPublish(String platformId, DeviceChannel deviceChannel, String type) {
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
deviceChannelList.add(deviceChannel);
|
||||
catalogEventPublish(platformId, deviceChannelList, type);
|
||||
}
|
||||
|
||||
|
||||
public void requestTimeOut(TimeoutEvent timeoutEvent) {
|
||||
RequestTimeoutEvent requestTimeoutEvent = new RequestTimeoutEvent(this);
|
||||
requestTimeoutEvent.setTimeoutEvent(timeoutEvent);
|
||||
applicationEventPublisher.publishEvent(requestTimeoutEvent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param platformId
|
||||
* @param deviceChannels
|
||||
* @param type
|
||||
*/
|
||||
public void catalogEventPublish(String platformId, List<DeviceChannel> deviceChannels, String type) {
|
||||
CatalogEvent outEvent = new CatalogEvent(this);
|
||||
List<DeviceChannel> channels = new ArrayList<>();
|
||||
if (deviceChannels.size() > 1) {
|
||||
// 数据去重
|
||||
Set<String> gbIdSet = new HashSet<>();
|
||||
for (DeviceChannel deviceChannel : deviceChannels) {
|
||||
if (!gbIdSet.contains(deviceChannel.getChannelId())) {
|
||||
gbIdSet.add(deviceChannel.getChannelId());
|
||||
channels.add(deviceChannel);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
channels = deviceChannels;
|
||||
}
|
||||
outEvent.setDeviceChannels(channels);
|
||||
outEvent.setType(type);
|
||||
outEvent.setPlatformId(platformId);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
|
||||
public void catalogEventPublishForStream(String platformId, List<GbStream> gbStreams, String type) {
|
||||
CatalogEvent outEvent = new CatalogEvent(this);
|
||||
outEvent.setGbStreams(gbStreams);
|
||||
outEvent.setType(type);
|
||||
outEvent.setPlatformId(platformId);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
|
||||
public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) {
|
||||
List<GbStream> gbStreamList = new ArrayList<>();
|
||||
gbStreamList.add(gbStream);
|
||||
catalogEventPublishForStream(platformId, gbStreamList, type);
|
||||
}
|
||||
|
||||
public void recordEndEventPush(RecordInfo recordInfo) {
|
||||
RecordEndEvent outEvent = new RecordEndEvent(this);
|
||||
outEvent.setRecordInfo(recordInfo);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.event;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
|
||||
import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
|
||||
|
||||
import javax.sip.TimeoutEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @description:Event事件通知推送器,支持推送在线事件、离线事件
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月6日 上午11:30:50
|
||||
*/
|
||||
@Component
|
||||
public class EventPublisher {
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
/**
|
||||
* 设备报警事件
|
||||
* @param deviceAlarm
|
||||
*/
|
||||
public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) {
|
||||
AlarmEvent alarmEvent = new AlarmEvent(this);
|
||||
alarmEvent.setAlarmInfo(deviceAlarm);
|
||||
applicationEventPublisher.publishEvent(alarmEvent);
|
||||
}
|
||||
|
||||
public void zlmOfflineEventPublish(String mediaServerId){
|
||||
ZLMOfflineEvent outEvent = new ZLMOfflineEvent(this);
|
||||
outEvent.setMediaServerId(mediaServerId);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
public void zlmOnlineEventPublish(String mediaServerId) {
|
||||
ZLMOnlineEvent outEvent = new ZLMOnlineEvent(this);
|
||||
outEvent.setMediaServerId(mediaServerId);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
|
||||
public void catalogEventPublish(String platformId, DeviceChannel deviceChannel, String type) {
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
deviceChannelList.add(deviceChannel);
|
||||
catalogEventPublish(platformId, deviceChannelList, type);
|
||||
}
|
||||
|
||||
|
||||
public void requestTimeOut(TimeoutEvent timeoutEvent) {
|
||||
RequestTimeoutEvent requestTimeoutEvent = new RequestTimeoutEvent(this);
|
||||
requestTimeoutEvent.setTimeoutEvent(timeoutEvent);
|
||||
applicationEventPublisher.publishEvent(requestTimeoutEvent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param platformId
|
||||
* @param deviceChannels
|
||||
* @param type
|
||||
*/
|
||||
public void catalogEventPublish(String platformId, List<DeviceChannel> deviceChannels, String type) {
|
||||
CatalogEvent outEvent = new CatalogEvent(this);
|
||||
List<DeviceChannel> channels = new ArrayList<>();
|
||||
if (deviceChannels.size() > 1) {
|
||||
// 数据去重
|
||||
Set<String> gbIdSet = new HashSet<>();
|
||||
for (DeviceChannel deviceChannel : deviceChannels) {
|
||||
if (!gbIdSet.contains(deviceChannel.getChannelId())) {
|
||||
gbIdSet.add(deviceChannel.getChannelId());
|
||||
channels.add(deviceChannel);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
channels = deviceChannels;
|
||||
}
|
||||
outEvent.setDeviceChannels(channels);
|
||||
outEvent.setType(type);
|
||||
outEvent.setPlatformId(platformId);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
|
||||
public void catalogEventPublishForStream(String platformId, List<GbStream> gbStreams, String type) {
|
||||
CatalogEvent outEvent = new CatalogEvent(this);
|
||||
outEvent.setGbStreams(gbStreams);
|
||||
outEvent.setType(type);
|
||||
outEvent.setPlatformId(platformId);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
|
||||
public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) {
|
||||
List<GbStream> gbStreamList = new ArrayList<>();
|
||||
gbStreamList.add(gbStream);
|
||||
catalogEventPublishForStream(platformId, gbStreamList, type);
|
||||
}
|
||||
|
||||
public void recordEndEventPush(RecordInfo recordInfo) {
|
||||
RecordEndEvent outEvent = new RecordEndEvent(this);
|
||||
outEvent.setRecordInfo(recordInfo);
|
||||
applicationEventPublisher.publishEvent(outEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/session/SSRCFactory.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/session/SSRCFactory.java
Normal file → Executable file
278
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
Normal file → Executable file
278
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
Normal file → Executable file
@ -1,139 +1,139 @@
|
||||
package com.genersoft.iot.vmp.gb28181.session;
|
||||
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
||||
import com.genersoft.iot.vmp.utils.JsonUtil;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
import gov.nist.javax.sip.message.SIPResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 视频流session管理器,管理视频预览、预览回放的通信句柄
|
||||
*/
|
||||
@Component
|
||||
public class VideoStreamSessionManager {
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* 添加一个点播/回放的事务信息
|
||||
* 后续可以通过流Id/callID
|
||||
* @param deviceId 设备ID
|
||||
* @param channelId 通道ID
|
||||
* @param callId 一次请求的CallID
|
||||
* @param stream 流名称
|
||||
* @param mediaServerId 所使用的流媒体ID
|
||||
* @param response 回复
|
||||
*/
|
||||
public void put(String deviceId, String channelId, String callId, String stream, String ssrc, String mediaServerId, SIPResponse response, InviteSessionType type){
|
||||
SsrcTransaction ssrcTransaction = new SsrcTransaction();
|
||||
ssrcTransaction.setDeviceId(deviceId);
|
||||
ssrcTransaction.setChannelId(channelId);
|
||||
ssrcTransaction.setStream(stream);
|
||||
ssrcTransaction.setSipTransactionInfo(new SipTransactionInfo(response));
|
||||
ssrcTransaction.setCallId(callId);
|
||||
ssrcTransaction.setSsrc(ssrc);
|
||||
ssrcTransaction.setMediaServerId(mediaServerId);
|
||||
ssrcTransaction.setType(type);
|
||||
|
||||
redisTemplate.opsForValue().set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
|
||||
+ "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction);
|
||||
}
|
||||
|
||||
public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
|
||||
|
||||
if (ObjectUtils.isEmpty(deviceId)) {
|
||||
deviceId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(callId)) {
|
||||
callId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(stream)) {
|
||||
stream ="*";
|
||||
}
|
||||
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
|
||||
List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
|
||||
if (scanResult.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return (SsrcTransaction)redisTemplate.opsForValue().get(scanResult.get(0));
|
||||
}
|
||||
|
||||
public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){
|
||||
if (ObjectUtils.isEmpty(deviceId)) {
|
||||
deviceId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(callId)) {
|
||||
callId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(stream)) {
|
||||
stream ="*";
|
||||
}
|
||||
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
|
||||
List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
|
||||
if (scanResult.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
List<SsrcTransaction> result = new ArrayList<>();
|
||||
for (Object keyObj : scanResult) {
|
||||
result.add((SsrcTransaction)redisTemplate.opsForValue().get(keyObj));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getMediaServerId(String deviceId, String channelId, String stream){
|
||||
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
|
||||
if (ssrcTransaction == null) {
|
||||
return null;
|
||||
}
|
||||
return ssrcTransaction.getMediaServerId();
|
||||
}
|
||||
|
||||
public String getSSRC(String deviceId, String channelId, String stream){
|
||||
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
|
||||
if (ssrcTransaction == null) {
|
||||
return null;
|
||||
}
|
||||
return ssrcTransaction.getSsrc();
|
||||
}
|
||||
|
||||
public void remove(String deviceId, String channelId, String stream) {
|
||||
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
|
||||
if (ssrcTransaction == null) {
|
||||
return;
|
||||
}
|
||||
redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_"
|
||||
+ deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream());
|
||||
}
|
||||
|
||||
|
||||
public List<SsrcTransaction> getAllSsrc() {
|
||||
List<Object> ssrcTransactionKeys = RedisUtil.scan(redisTemplate, String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId()));
|
||||
List<SsrcTransaction> result= new ArrayList<>();
|
||||
for (Object ssrcTransactionKey : ssrcTransactionKeys) {
|
||||
String key = (String) ssrcTransactionKey;
|
||||
SsrcTransaction ssrcTransaction = JsonUtil.redisJsonToObject(redisTemplate, key, SsrcTransaction.class);
|
||||
result.add(ssrcTransaction);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.session;
|
||||
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
||||
import com.genersoft.iot.vmp.utils.JsonUtil;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
import gov.nist.javax.sip.message.SIPResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 视频流session管理器,管理视频预览、预览回放的通信句柄
|
||||
*/
|
||||
@Component
|
||||
public class VideoStreamSessionManager {
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* 添加一个点播/回放的事务信息
|
||||
* 后续可以通过流Id/callID
|
||||
* @param deviceId 设备ID
|
||||
* @param channelId 通道ID
|
||||
* @param callId 一次请求的CallID
|
||||
* @param stream 流名称
|
||||
* @param mediaServerId 所使用的流媒体ID
|
||||
* @param response 回复
|
||||
*/
|
||||
public void put(String deviceId, String channelId, String callId, String stream, String ssrc, String mediaServerId, SIPResponse response, InviteSessionType type){
|
||||
SsrcTransaction ssrcTransaction = new SsrcTransaction();
|
||||
ssrcTransaction.setDeviceId(deviceId);
|
||||
ssrcTransaction.setChannelId(channelId);
|
||||
ssrcTransaction.setStream(stream);
|
||||
ssrcTransaction.setSipTransactionInfo(new SipTransactionInfo(response));
|
||||
ssrcTransaction.setCallId(callId);
|
||||
ssrcTransaction.setSsrc(ssrc);
|
||||
ssrcTransaction.setMediaServerId(mediaServerId);
|
||||
ssrcTransaction.setType(type);
|
||||
|
||||
redisTemplate.opsForValue().set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
|
||||
+ "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction);
|
||||
}
|
||||
|
||||
public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
|
||||
|
||||
if (ObjectUtils.isEmpty(deviceId)) {
|
||||
deviceId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(callId)) {
|
||||
callId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(stream)) {
|
||||
stream ="*";
|
||||
}
|
||||
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
|
||||
List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
|
||||
if (scanResult.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return (SsrcTransaction)redisTemplate.opsForValue().get(scanResult.get(0));
|
||||
}
|
||||
|
||||
public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){
|
||||
if (ObjectUtils.isEmpty(deviceId)) {
|
||||
deviceId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(channelId)) {
|
||||
channelId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(callId)) {
|
||||
callId ="*";
|
||||
}
|
||||
if (ObjectUtils.isEmpty(stream)) {
|
||||
stream ="*";
|
||||
}
|
||||
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
|
||||
List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
|
||||
if (scanResult.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
List<SsrcTransaction> result = new ArrayList<>();
|
||||
for (Object keyObj : scanResult) {
|
||||
result.add((SsrcTransaction)redisTemplate.opsForValue().get(keyObj));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getMediaServerId(String deviceId, String channelId, String stream){
|
||||
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
|
||||
if (ssrcTransaction == null) {
|
||||
return null;
|
||||
}
|
||||
return ssrcTransaction.getMediaServerId();
|
||||
}
|
||||
|
||||
public String getSSRC(String deviceId, String channelId, String stream){
|
||||
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
|
||||
if (ssrcTransaction == null) {
|
||||
return null;
|
||||
}
|
||||
return ssrcTransaction.getSsrc();
|
||||
}
|
||||
|
||||
public void remove(String deviceId, String channelId, String stream) {
|
||||
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream);
|
||||
if (ssrcTransaction == null) {
|
||||
return;
|
||||
}
|
||||
redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_"
|
||||
+ deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream());
|
||||
}
|
||||
|
||||
|
||||
public List<SsrcTransaction> getAllSsrc() {
|
||||
List<Object> ssrcTransactionKeys = RedisUtil.scan(redisTemplate, String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId()));
|
||||
List<SsrcTransaction> result= new ArrayList<>();
|
||||
for (Object ssrcTransactionKey : ssrcTransactionKeys) {
|
||||
String key = (String) ssrcTransactionKey;
|
||||
SsrcTransaction ssrcTransaction = JsonUtil.redisJsonToObject(redisTemplate, key, SsrcTransaction.class);
|
||||
result.add(ssrcTransaction);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java
Normal file → Executable file
14
src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java
Normal file → Executable file
14
src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java
Normal file → Executable file
@ -12,13 +12,19 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.IPlatformService;
|
||||
import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -59,6 +65,8 @@ public class SipRunner implements CommandLineRunner {
|
||||
@Autowired
|
||||
private ISIPCommanderForPlatform commanderForPlatform;
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
List<Device> deviceList = deviceService.getAllOnlineDevice();
|
||||
@ -110,7 +118,11 @@ public class SipRunner implements CommandLineRunner {
|
||||
if (jsonObject != null && jsonObject.getInteger("code") == 0) {
|
||||
ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
|
||||
if (platform != null) {
|
||||
commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId());
|
||||
try {
|
||||
commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId());
|
||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
||||
logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java
Normal file → Executable file
320
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
Normal file → Executable file
320
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
Normal file → Executable file
@ -1,160 +1,160 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.callback;
|
||||
|
||||
import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @description: 异步请求处理
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月8日 下午7:59:05
|
||||
*/
|
||||
@SuppressWarnings(value = {"rawtypes", "unchecked"})
|
||||
@Component
|
||||
public class DeferredResultHolder {
|
||||
|
||||
public static final String CALLBACK_CMD_DEVICESTATUS = "CALLBACK_DEVICESTATUS";
|
||||
|
||||
public static final String CALLBACK_CMD_DEVICEINFO = "CALLBACK_DEVICEINFO";
|
||||
|
||||
public static final String CALLBACK_CMD_DEVICECONTROL = "CALLBACK_DEVICECONTROL";
|
||||
|
||||
public static final String CALLBACK_CMD_DEVICECONFIG = "CALLBACK_DEVICECONFIG";
|
||||
|
||||
public static final String CALLBACK_CMD_CONFIGDOWNLOAD = "CALLBACK_CONFIGDOWNLOAD";
|
||||
|
||||
public static final String CALLBACK_CMD_CATALOG = "CALLBACK_CATALOG";
|
||||
|
||||
public static final String CALLBACK_CMD_RECORDINFO = "CALLBACK_RECORDINFO";
|
||||
|
||||
public static final String CALLBACK_CMD_PLAY = "CALLBACK_PLAY";
|
||||
|
||||
public static final String CALLBACK_CMD_PLAYBACK = "CALLBACK_PLAYBACK";
|
||||
|
||||
public static final String CALLBACK_CMD_DOWNLOAD = "CALLBACK_DOWNLOAD";
|
||||
|
||||
public static final String CALLBACK_CMD_PROXY = "CALLBACK_PROXY";
|
||||
|
||||
public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP";
|
||||
|
||||
public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL";
|
||||
|
||||
public static final String CALLBACK_CMD_MOBILE_POSITION = "CALLBACK_CMD_MOBILE_POSITION";
|
||||
|
||||
public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY";
|
||||
|
||||
public static final String CALLBACK_CMD_ALARM = "CALLBACK_ALARM";
|
||||
|
||||
public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST";
|
||||
|
||||
public static final String CALLBACK_CMD_SNAP= "CALLBACK_SNAP";
|
||||
|
||||
private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public void put(String key, String id, DeferredResultEx result) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (deferredResultMap == null) {
|
||||
deferredResultMap = new ConcurrentHashMap<>();
|
||||
map.put(key, deferredResultMap);
|
||||
}
|
||||
deferredResultMap.put(id, result);
|
||||
}
|
||||
|
||||
public void put(String key, String id, DeferredResult result) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (deferredResultMap == null) {
|
||||
deferredResultMap = new ConcurrentHashMap<>();
|
||||
map.put(key, deferredResultMap);
|
||||
}
|
||||
deferredResultMap.put(id, new DeferredResultEx(result));
|
||||
}
|
||||
|
||||
public DeferredResultEx get(String key, String id) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (deferredResultMap == null || ObjectUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
return deferredResultMap.get(id);
|
||||
}
|
||||
|
||||
public Collection<DeferredResultEx> getAllByKey(String key) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (deferredResultMap == null) {
|
||||
return null;
|
||||
}
|
||||
return deferredResultMap.values();
|
||||
}
|
||||
|
||||
public boolean exist(String key, String id){
|
||||
if (key == null) {
|
||||
return false;
|
||||
}
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (id == null) {
|
||||
return deferredResultMap != null;
|
||||
}else {
|
||||
return deferredResultMap != null && deferredResultMap.get(id) != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放单个请求
|
||||
* @param msg
|
||||
*/
|
||||
public void invokeResult(RequestMessage msg) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());
|
||||
if (deferredResultMap == null) {
|
||||
return;
|
||||
}
|
||||
DeferredResultEx result = deferredResultMap.get(msg.getId());
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
result.getDeferredResult().setResult(msg.getData());
|
||||
deferredResultMap.remove(msg.getId());
|
||||
if (deferredResultMap.size() == 0) {
|
||||
map.remove(msg.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放所有的请求
|
||||
* @param msg
|
||||
*/
|
||||
public void invokeAllResult(RequestMessage msg) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());
|
||||
if (deferredResultMap == null) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
deferredResultMap = map.get(msg.getKey());
|
||||
if (deferredResultMap == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> ids = deferredResultMap.keySet();
|
||||
for (String id : ids) {
|
||||
DeferredResultEx result = deferredResultMap.get(id);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
if (result.getFilter() != null) {
|
||||
Object handler = result.getFilter().handler(msg.getData());
|
||||
result.getDeferredResult().setResult(handler);
|
||||
}else {
|
||||
result.getDeferredResult().setResult(msg.getData());
|
||||
}
|
||||
|
||||
}
|
||||
map.remove(msg.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.callback;
|
||||
|
||||
import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @description: 异步请求处理
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月8日 下午7:59:05
|
||||
*/
|
||||
@SuppressWarnings(value = {"rawtypes", "unchecked"})
|
||||
@Component
|
||||
public class DeferredResultHolder {
|
||||
|
||||
public static final String CALLBACK_CMD_DEVICESTATUS = "CALLBACK_DEVICESTATUS";
|
||||
|
||||
public static final String CALLBACK_CMD_DEVICEINFO = "CALLBACK_DEVICEINFO";
|
||||
|
||||
public static final String CALLBACK_CMD_DEVICECONTROL = "CALLBACK_DEVICECONTROL";
|
||||
|
||||
public static final String CALLBACK_CMD_DEVICECONFIG = "CALLBACK_DEVICECONFIG";
|
||||
|
||||
public static final String CALLBACK_CMD_CONFIGDOWNLOAD = "CALLBACK_CONFIGDOWNLOAD";
|
||||
|
||||
public static final String CALLBACK_CMD_CATALOG = "CALLBACK_CATALOG";
|
||||
|
||||
public static final String CALLBACK_CMD_RECORDINFO = "CALLBACK_RECORDINFO";
|
||||
|
||||
public static final String CALLBACK_CMD_PLAY = "CALLBACK_PLAY";
|
||||
|
||||
public static final String CALLBACK_CMD_PLAYBACK = "CALLBACK_PLAYBACK";
|
||||
|
||||
public static final String CALLBACK_CMD_DOWNLOAD = "CALLBACK_DOWNLOAD";
|
||||
|
||||
public static final String CALLBACK_CMD_PROXY = "CALLBACK_PROXY";
|
||||
|
||||
public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP";
|
||||
|
||||
public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL";
|
||||
|
||||
public static final String CALLBACK_CMD_MOBILE_POSITION = "CALLBACK_CMD_MOBILE_POSITION";
|
||||
|
||||
public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY";
|
||||
|
||||
public static final String CALLBACK_CMD_ALARM = "CALLBACK_ALARM";
|
||||
|
||||
public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST";
|
||||
|
||||
public static final String CALLBACK_CMD_SNAP= "CALLBACK_SNAP";
|
||||
|
||||
private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public void put(String key, String id, DeferredResultEx result) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (deferredResultMap == null) {
|
||||
deferredResultMap = new ConcurrentHashMap<>();
|
||||
map.put(key, deferredResultMap);
|
||||
}
|
||||
deferredResultMap.put(id, result);
|
||||
}
|
||||
|
||||
public void put(String key, String id, DeferredResult result) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (deferredResultMap == null) {
|
||||
deferredResultMap = new ConcurrentHashMap<>();
|
||||
map.put(key, deferredResultMap);
|
||||
}
|
||||
deferredResultMap.put(id, new DeferredResultEx(result));
|
||||
}
|
||||
|
||||
public DeferredResultEx get(String key, String id) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (deferredResultMap == null || ObjectUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
return deferredResultMap.get(id);
|
||||
}
|
||||
|
||||
public Collection<DeferredResultEx> getAllByKey(String key) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (deferredResultMap == null) {
|
||||
return null;
|
||||
}
|
||||
return deferredResultMap.values();
|
||||
}
|
||||
|
||||
public boolean exist(String key, String id){
|
||||
if (key == null) {
|
||||
return false;
|
||||
}
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
||||
if (id == null) {
|
||||
return deferredResultMap != null;
|
||||
}else {
|
||||
return deferredResultMap != null && deferredResultMap.get(id) != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放单个请求
|
||||
* @param msg
|
||||
*/
|
||||
public void invokeResult(RequestMessage msg) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());
|
||||
if (deferredResultMap == null) {
|
||||
return;
|
||||
}
|
||||
DeferredResultEx result = deferredResultMap.get(msg.getId());
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
result.getDeferredResult().setResult(msg.getData());
|
||||
deferredResultMap.remove(msg.getId());
|
||||
if (deferredResultMap.size() == 0) {
|
||||
map.remove(msg.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放所有的请求
|
||||
* @param msg
|
||||
*/
|
||||
public void invokeAllResult(RequestMessage msg) {
|
||||
Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());
|
||||
if (deferredResultMap == null) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
deferredResultMap = map.get(msg.getKey());
|
||||
if (deferredResultMap == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> ids = deferredResultMap.keySet();
|
||||
for (String id : ids) {
|
||||
DeferredResultEx result = deferredResultMap.get(id);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
if (result.getFilter() != null) {
|
||||
Object handler = result.getFilter().handler(msg.getData());
|
||||
result.getDeferredResult().setResult(handler);
|
||||
}else {
|
||||
result.getDeferredResult().setResult(msg.getData());
|
||||
}
|
||||
|
||||
}
|
||||
map.remove(msg.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
78
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java
Normal file → Executable file
78
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java
Normal file → Executable file
@ -1,39 +1,39 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.callback;
|
||||
|
||||
/**
|
||||
* @description: 请求信息定义
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月8日 下午1:09:18
|
||||
*/
|
||||
public class RequestMessage {
|
||||
|
||||
private String id;
|
||||
|
||||
private String key;
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.callback;
|
||||
|
||||
/**
|
||||
* @description: 请求信息定义
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月8日 下午1:09:18
|
||||
*/
|
||||
public class RequestMessage {
|
||||
|
||||
private String id;
|
||||
|
||||
private String key;
|
||||
|
||||
private Object data;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
728
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
Normal file → Executable file
728
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
Normal file → Executable file
@ -1,364 +1,364 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* @description:设备能力接口,用于定义设备的控制、查询能力
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月3日 下午9:16:34
|
||||
*/
|
||||
public interface ISIPCommander {
|
||||
|
||||
/**
|
||||
* 云台方向放控制,使用配置文件中的默认镜头移动速度
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
|
||||
* @param upDown 镜头上移下移 0:停止 1:上移 2:下移
|
||||
*/
|
||||
void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 云台方向放控制
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
|
||||
* @param upDown 镜头上移下移 0:停止 1:上移 2:下移
|
||||
* @param moveSpeed 镜头移动速度
|
||||
*/
|
||||
void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 云台缩放控制,使用配置文件中的默认镜头缩放速度
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
|
||||
*/
|
||||
void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 云台缩放控制
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
|
||||
*/
|
||||
void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 云台控制,支持方向与缩放控制
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
|
||||
* @param upDown 镜头上移下移 0:停止 1:上移 2:下移
|
||||
* @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
|
||||
* @param moveSpeed 镜头移动速度
|
||||
* @param zoomSpeed 镜头缩放速度
|
||||
*/
|
||||
void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param cmdCode 指令码
|
||||
* @param parameter1 数据1
|
||||
* @param parameter2 数据2
|
||||
* @param combineCode2 组合码2
|
||||
*/
|
||||
void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException;
|
||||
|
||||
/**
|
||||
* 前端控制指令(用于转发上级指令)
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param cmdString 前端控制指令串
|
||||
*/
|
||||
void fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 请求预览视频流
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
*/
|
||||
void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 请求回放视频流
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
* @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求历史媒体下载
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
* @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param downloadSpeed 下载倍速参数
|
||||
*/
|
||||
void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
|
||||
String startTime, String endTime, int downloadSpeed, ZlmHttpHookSubscribe.Event hookEvent,
|
||||
SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 视频流停止
|
||||
*/
|
||||
void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
|
||||
|
||||
void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
|
||||
|
||||
/**
|
||||
* 回放暂停
|
||||
*/
|
||||
void playPauseCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 回放恢复
|
||||
*/
|
||||
void playResumeCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 回放拖动播放
|
||||
*/
|
||||
void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 回放倍速播放
|
||||
*/
|
||||
void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 回放控制
|
||||
* @param device
|
||||
* @param streamInfo
|
||||
* @param content
|
||||
*/
|
||||
void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException;
|
||||
|
||||
|
||||
/**
|
||||
* 语音广播
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
*/
|
||||
void audioBroadcastCmd(Device device,String channelId);
|
||||
|
||||
/**
|
||||
* 语音广播
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void audioBroadcastCmd(Device device, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 音视频录像控制
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
* @param recordCmdStr 录像命令:Record / StopRecord
|
||||
*/
|
||||
void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 远程启动控制命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 报警布防/撤防命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 报警复位命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param alarmMethod 报警方式(可选)
|
||||
* @param alarmType 报警类型(可选)
|
||||
*/
|
||||
void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
*/
|
||||
void iFrameCmd(Device device, String channelId) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 看守位控制命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 通道id,非通道则是设备本身
|
||||
* @param enabled 看守位使能:1 = 开启,0 = 关闭
|
||||
* @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s)
|
||||
* @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255
|
||||
*/
|
||||
void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 设备配置命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void deviceConfigCmd(Device device);
|
||||
|
||||
/**
|
||||
* 设备配置命令:basicParam
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 通道编码(可选)
|
||||
* @param name 设备/通道名称(可选)
|
||||
* @param expiration 注册过期时间(可选)
|
||||
* @param heartBeatInterval 心跳间隔时间(可选)
|
||||
* @param heartBeatCount 心跳超时次数(可选)
|
||||
*/
|
||||
void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询设备状态
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询设备信息
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @return
|
||||
*/
|
||||
void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询目录列表
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询录像信息
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param sn
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 查询报警信息
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param startPriority 报警起始级别(可选)
|
||||
* @param endPriority 报警终止级别(可选)
|
||||
* @param alarmMethod 报警方式条件(可选)
|
||||
* @param alarmType 报警类型
|
||||
* @param startTime 报警发生起始时间(可选)
|
||||
* @param endTime 报警发生终止时间(可选)
|
||||
* @return true = 命令发送成功
|
||||
*/
|
||||
void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod,
|
||||
String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询设备配置
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 通道编码(可选)
|
||||
* @param configType 配置类型:
|
||||
*/
|
||||
void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询设备预置位置
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询移动设备位置数据
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 订阅、取消订阅移动位置
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @return true = 命令发送成功
|
||||
*/
|
||||
SIPRequest mobilePositionSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent , SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 订阅、取消订阅报警信息
|
||||
* @param device 视频设备
|
||||
* @param expires 订阅过期时间(0 = 取消订阅)
|
||||
* @param startPriority 报警起始级别(可选)
|
||||
* @param endPriority 报警终止级别(可选)
|
||||
* @param alarmType 报警类型
|
||||
* @param startTime 报警发生起始时间(可选)
|
||||
* @param endTime 报警发生终止时间(可选)
|
||||
* @return true = 命令发送成功
|
||||
*/
|
||||
void alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String startTime, String endTime) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 订阅、取消订阅目录信息
|
||||
* @param device 视频设备
|
||||
* @return true = 命令发送成功
|
||||
*/
|
||||
SIPRequest catalogSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 拉框控制命令
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 通道id
|
||||
* @param cmdString 前端控制指令串
|
||||
*/
|
||||
void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
|
||||
/**
|
||||
* 向设备发送报警NOTIFY消息, 用于互联结构下,此时将设备当成一个平级平台看待
|
||||
* @param device 设备
|
||||
* @param deviceAlarm 报警信息信息
|
||||
* @return
|
||||
*/
|
||||
void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* @description:设备能力接口,用于定义设备的控制、查询能力
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月3日 下午9:16:34
|
||||
*/
|
||||
public interface ISIPCommander {
|
||||
|
||||
/**
|
||||
* 云台方向放控制,使用配置文件中的默认镜头移动速度
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
|
||||
* @param upDown 镜头上移下移 0:停止 1:上移 2:下移
|
||||
*/
|
||||
void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 云台方向放控制
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
|
||||
* @param upDown 镜头上移下移 0:停止 1:上移 2:下移
|
||||
* @param moveSpeed 镜头移动速度
|
||||
*/
|
||||
void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 云台缩放控制,使用配置文件中的默认镜头缩放速度
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
|
||||
*/
|
||||
void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 云台缩放控制
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
|
||||
*/
|
||||
void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 云台控制,支持方向与缩放控制
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param leftRight 镜头左移右移 0:停止 1:左移 2:右移
|
||||
* @param upDown 镜头上移下移 0:停止 1:上移 2:下移
|
||||
* @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大
|
||||
* @param moveSpeed 镜头移动速度
|
||||
* @param zoomSpeed 镜头缩放速度
|
||||
*/
|
||||
void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param cmdCode 指令码
|
||||
* @param parameter1 数据1
|
||||
* @param parameter2 数据2
|
||||
* @param combineCode2 组合码2
|
||||
*/
|
||||
void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException;
|
||||
|
||||
/**
|
||||
* 前端控制指令(用于转发上级指令)
|
||||
* @param device 控制设备
|
||||
* @param channelId 预览通道
|
||||
* @param cmdString 前端控制指令串
|
||||
*/
|
||||
void fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 请求预览视频流
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
*/
|
||||
void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 请求回放视频流
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
* @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 请求历史媒体下载
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
* @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param downloadSpeed 下载倍速参数
|
||||
*/
|
||||
void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId,
|
||||
String startTime, String endTime, int downloadSpeed, ZlmHttpHookSubscribe.Event hookEvent,
|
||||
SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 视频流停止
|
||||
*/
|
||||
void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
|
||||
|
||||
void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
|
||||
|
||||
/**
|
||||
* 回放暂停
|
||||
*/
|
||||
void playPauseCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 回放恢复
|
||||
*/
|
||||
void playResumeCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 回放拖动播放
|
||||
*/
|
||||
void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 回放倍速播放
|
||||
*/
|
||||
void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException;
|
||||
|
||||
/**
|
||||
* 回放控制
|
||||
* @param device
|
||||
* @param streamInfo
|
||||
* @param content
|
||||
*/
|
||||
void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException;
|
||||
|
||||
|
||||
/**
|
||||
* 语音广播
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
*/
|
||||
void audioBroadcastCmd(Device device,String channelId);
|
||||
|
||||
/**
|
||||
* 语音广播
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void audioBroadcastCmd(Device device, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 音视频录像控制
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
* @param recordCmdStr 录像命令:Record / StopRecord
|
||||
*/
|
||||
void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 远程启动控制命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 报警布防/撤防命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 报警复位命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param alarmMethod 报警方式(可选)
|
||||
* @param alarmType 报警类型(可选)
|
||||
*/
|
||||
void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 预览通道
|
||||
*/
|
||||
void iFrameCmd(Device device, String channelId) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 看守位控制命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 通道id,非通道则是设备本身
|
||||
* @param enabled 看守位使能:1 = 开启,0 = 关闭
|
||||
* @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s)
|
||||
* @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255
|
||||
*/
|
||||
void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 设备配置命令
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void deviceConfigCmd(Device device);
|
||||
|
||||
/**
|
||||
* 设备配置命令:basicParam
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 通道编码(可选)
|
||||
* @param name 设备/通道名称(可选)
|
||||
* @param expiration 注册过期时间(可选)
|
||||
* @param heartBeatInterval 心跳间隔时间(可选)
|
||||
* @param heartBeatCount 心跳超时次数(可选)
|
||||
*/
|
||||
void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询设备状态
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询设备信息
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @return
|
||||
*/
|
||||
void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询目录列表
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询录像信息
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param sn
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 查询报警信息
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param startPriority 报警起始级别(可选)
|
||||
* @param endPriority 报警终止级别(可选)
|
||||
* @param alarmMethod 报警方式条件(可选)
|
||||
* @param alarmType 报警类型
|
||||
* @param startTime 报警发生起始时间(可选)
|
||||
* @param endTime 报警发生终止时间(可选)
|
||||
* @return true = 命令发送成功
|
||||
*/
|
||||
void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod,
|
||||
String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询设备配置
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @param channelId 通道编码(可选)
|
||||
* @param configType 配置类型:
|
||||
*/
|
||||
void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询设备预置位置
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 查询移动设备位置数据
|
||||
*
|
||||
* @param device 视频设备
|
||||
*/
|
||||
void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 订阅、取消订阅移动位置
|
||||
*
|
||||
* @param device 视频设备
|
||||
* @return true = 命令发送成功
|
||||
*/
|
||||
SIPRequest mobilePositionSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent , SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 订阅、取消订阅报警信息
|
||||
* @param device 视频设备
|
||||
* @param expires 订阅过期时间(0 = 取消订阅)
|
||||
* @param startPriority 报警起始级别(可选)
|
||||
* @param endPriority 报警终止级别(可选)
|
||||
* @param alarmType 报警类型
|
||||
* @param startTime 报警发生起始时间(可选)
|
||||
* @param endTime 报警发生终止时间(可选)
|
||||
* @return true = 命令发送成功
|
||||
*/
|
||||
void alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String startTime, String endTime) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 订阅、取消订阅目录信息
|
||||
* @param device 视频设备
|
||||
* @return true = 命令发送成功
|
||||
*/
|
||||
SIPRequest catalogSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
/**
|
||||
* 拉框控制命令
|
||||
*
|
||||
* @param device 控制设备
|
||||
* @param channelId 通道id
|
||||
* @param cmdString 前端控制指令串
|
||||
*/
|
||||
void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
|
||||
/**
|
||||
* 向设备发送报警NOTIFY消息, 用于互联结构下,此时将设备当成一个平级平台看待
|
||||
* @param device 设备
|
||||
* @param deviceAlarm 报警信息信息
|
||||
* @return
|
||||
*/
|
||||
void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException;
|
||||
|
||||
}
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
Normal file → Executable file
636
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
Normal file → Executable file
636
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
Normal file → Executable file
@ -1,318 +1,318 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.SipLayer;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import gov.nist.javax.sip.message.SIPResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.PeerUnavailableException;
|
||||
import javax.sip.SipException;
|
||||
import javax.sip.SipFactory;
|
||||
import javax.sip.address.Address;
|
||||
import javax.sip.address.SipURI;
|
||||
import javax.sip.header.*;
|
||||
import javax.sip.message.Request;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @description:摄像头命令request创造器 TODO 冗余代码太多待优化
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月6日 上午9:29:02
|
||||
*/
|
||||
@Component
|
||||
public class SIPRequestHeaderProvider {
|
||||
|
||||
@Autowired
|
||||
private SipConfig sipConfig;
|
||||
|
||||
@Autowired
|
||||
private SipLayer sipLayer;
|
||||
|
||||
@Autowired
|
||||
private GitUtil gitUtil;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private VideoStreamSessionManager streamSession;
|
||||
|
||||
public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
// sipuri
|
||||
SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||
viaHeader.setRPort();
|
||||
viaHeaders.add(viaHeader);
|
||||
// from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
||||
// to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, toTag);
|
||||
|
||||
// Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
// ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
|
||||
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
||||
toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
//请求行
|
||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
//via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
HeaderFactory headerFactory = SipFactory.getInstance().createHeaderFactory();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||
viaHeader.setRPort();
|
||||
viaHeaders.add(viaHeader);
|
||||
|
||||
//from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
||||
//to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
// Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
// Subject
|
||||
SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
||||
request.addHeader(subjectHeader);
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
//请求行
|
||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||
viaHeader.setRPort();
|
||||
viaHeaders.add(viaHeader);
|
||||
//from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
||||
//to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
// Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
// Subject
|
||||
SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
||||
request.addHeader(subjectHeader);
|
||||
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
//请求行
|
||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
||||
viaHeaders.add(viaHeader);
|
||||
//from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
||||
//to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
|
||||
CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
// sipuri
|
||||
SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(),
|
||||
device.getTransport(), SipUtils.getNewViaTag());
|
||||
viaHeader.setRPort();
|
||||
viaHeaders.add(viaHeader);
|
||||
// from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag());
|
||||
// to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag());
|
||||
|
||||
// Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
// ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE);
|
||||
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader,
|
||||
toHeader, viaHeaders, maxForwards);
|
||||
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
// Expires
|
||||
ExpiresHeader expireHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(expires);
|
||||
request.addHeader(expireHeader);
|
||||
|
||||
// Event
|
||||
EventHeader eventHeader = SipFactory.getInstance().createHeaderFactory().createEventHeader(event);
|
||||
|
||||
int random = (int) Math.floor(Math.random() * 10000);
|
||||
eventHeader.setEventId(random + "");
|
||||
request.addHeader(eventHeader);
|
||||
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public SIPRequest createInfoRequest(Device device, String channelId, String content, SipTransactionInfo transactionInfo)
|
||||
throws SipException, ParseException, InvalidArgumentException {
|
||||
if (device == null || transactionInfo == null) {
|
||||
return null;
|
||||
}
|
||||
SIPRequest request = null;
|
||||
//请求行
|
||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
||||
viaHeaders.add(viaHeader);
|
||||
//from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
||||
//to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO);
|
||||
CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
||||
request = (SIPRequest)SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
if (content != null) {
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application",
|
||||
"MANSRTSP");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
|
||||
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag());
|
||||
viaHeaders.add(viaHeader);
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK);
|
||||
|
||||
Request request = SipFactory.getInstance().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
return request;
|
||||
}
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.SipLayer;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import gov.nist.javax.sip.message.SIPResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.PeerUnavailableException;
|
||||
import javax.sip.SipException;
|
||||
import javax.sip.SipFactory;
|
||||
import javax.sip.address.Address;
|
||||
import javax.sip.address.SipURI;
|
||||
import javax.sip.header.*;
|
||||
import javax.sip.message.Request;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @description:摄像头命令request创造器 TODO 冗余代码太多待优化
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月6日 上午9:29:02
|
||||
*/
|
||||
@Component
|
||||
public class SIPRequestHeaderProvider {
|
||||
|
||||
@Autowired
|
||||
private SipConfig sipConfig;
|
||||
|
||||
@Autowired
|
||||
private SipLayer sipLayer;
|
||||
|
||||
@Autowired
|
||||
private GitUtil gitUtil;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private VideoStreamSessionManager streamSession;
|
||||
|
||||
public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
// sipuri
|
||||
SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||
viaHeader.setRPort();
|
||||
viaHeaders.add(viaHeader);
|
||||
// from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
||||
// to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, toTag);
|
||||
|
||||
// Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
// ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
|
||||
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
||||
toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
//请求行
|
||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
//via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
HeaderFactory headerFactory = SipFactory.getInstance().createHeaderFactory();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||
viaHeader.setRPort();
|
||||
viaHeaders.add(viaHeader);
|
||||
|
||||
//from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
||||
//to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
// Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
// Subject
|
||||
SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
||||
request.addHeader(subjectHeader);
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
//请求行
|
||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||
viaHeader.setRPort();
|
||||
viaHeaders.add(viaHeader);
|
||||
//from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
||||
//to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
// Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
// Subject
|
||||
SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
||||
request.addHeader(subjectHeader);
|
||||
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
//请求行
|
||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
||||
viaHeaders.add(viaHeader);
|
||||
//from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
||||
//to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
|
||||
CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
Request request = null;
|
||||
// sipuri
|
||||
SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(),
|
||||
device.getTransport(), SipUtils.getNewViaTag());
|
||||
viaHeader.setRPort();
|
||||
viaHeaders.add(viaHeader);
|
||||
// from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag());
|
||||
// to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag());
|
||||
|
||||
// Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
// ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE);
|
||||
|
||||
request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader,
|
||||
toHeader, viaHeaders, maxForwards);
|
||||
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
// Expires
|
||||
ExpiresHeader expireHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(expires);
|
||||
request.addHeader(expireHeader);
|
||||
|
||||
// Event
|
||||
EventHeader eventHeader = SipFactory.getInstance().createHeaderFactory().createEventHeader(event);
|
||||
|
||||
int random = (int) Math.floor(Math.random() * 10000);
|
||||
eventHeader.setEventId(random + "");
|
||||
request.addHeader(eventHeader);
|
||||
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public SIPRequest createInfoRequest(Device device, String channelId, String content, SipTransactionInfo transactionInfo)
|
||||
throws SipException, ParseException, InvalidArgumentException {
|
||||
if (device == null || transactionInfo == null) {
|
||||
return null;
|
||||
}
|
||||
SIPRequest request = null;
|
||||
//请求行
|
||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
||||
viaHeaders.add(viaHeader);
|
||||
//from
|
||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
||||
//to
|
||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO);
|
||||
CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
||||
request = (SIPRequest)SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
if (content != null) {
|
||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application",
|
||||
"MANSRTSP");
|
||||
request.setContent(content, contentTypeHeader);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||
|
||||
|
||||
// via
|
||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag());
|
||||
viaHeaders.add(viaHeader);
|
||||
|
||||
//Forwards
|
||||
MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70);
|
||||
|
||||
//ceq
|
||||
CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK);
|
||||
|
||||
Request request = SipFactory.getInstance().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards);
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort()));
|
||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||
|
||||
request.addHeader(SipUtils.createUserAgentHeader(gitUtil));
|
||||
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
2848
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
Normal file → Executable file
2848
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/ISIPRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/ISIPRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/CancelRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/CancelRequestProcessor.java
Normal file → Executable file
26
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
Normal file → Executable file
26
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
Normal file → Executable file
@ -18,10 +18,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.*;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
||||
import com.genersoft.iot.vmp.service.IStreamPushService;
|
||||
import com.genersoft.iot.vmp.service.*;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
||||
@ -79,6 +76,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private IInviteStreamService inviteStreamService;
|
||||
|
||||
@Autowired
|
||||
private SSRCFactory ssrcFactory;
|
||||
|
||||
@ -479,13 +479,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
errorEvent.run(code, msg, data);
|
||||
}
|
||||
});
|
||||
}else if ("Download".equalsIgnoreCase(sessionName)) {
|
||||
} else if ("Download".equalsIgnoreCase(sessionName)) {
|
||||
// 获取指定的下载速度
|
||||
Vector sdpMediaDescriptions = sdp.getMediaDescriptions(true);
|
||||
MediaDescription mediaDescription = null;
|
||||
String downloadSpeed = "1";
|
||||
if (sdpMediaDescriptions.size() > 0) {
|
||||
mediaDescription = (MediaDescription)sdpMediaDescriptions.get(0);
|
||||
mediaDescription = (MediaDescription) sdpMediaDescriptions.get(0);
|
||||
}
|
||||
if (mediaDescription != null) {
|
||||
downloadSpeed = mediaDescription.getAttribute("downloadspeed");
|
||||
@ -499,26 +499,26 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||
playService.download(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start),
|
||||
DateUtil.formatter.format(end), Integer.parseInt(downloadSpeed),
|
||||
(code, msg, data) -> {
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()){
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||
hookEvent.run(code, msg, data);
|
||||
}else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()){
|
||||
} else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) {
|
||||
logger.info("[录像下载]超时, 用户:{}, 通道:{}", username, channelId);
|
||||
redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);
|
||||
errorEvent.run(code, msg, data);
|
||||
}else {
|
||||
} else {
|
||||
errorEvent.run(code, msg, data);
|
||||
}
|
||||
});
|
||||
}else {
|
||||
} else {
|
||||
|
||||
SSRCInfo ssrcInfo = playService.play(mediaServerItem, device.getDeviceId(), channelId, ssrc, ((code, msg, data) -> {
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()){
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||
hookEvent.run(code, msg, data);
|
||||
}else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()){
|
||||
} else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) {
|
||||
logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId);
|
||||
redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);
|
||||
errorEvent.run(code, msg, data);
|
||||
}else {
|
||||
} else {
|
||||
errorEvent.run(code, msg, data);
|
||||
}
|
||||
}));
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
Normal file → Executable file
298
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java
Normal file → Executable file
298
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java
Normal file → Executable file
@ -1,149 +1,149 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.info;
|
||||
|
||||
import com.genersoft.iot.vmp.common.InviteInfo;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.RequestEvent;
|
||||
import javax.sip.SipException;
|
||||
import javax.sip.header.CallIdHeader;
|
||||
import javax.sip.header.ContentTypeHeader;
|
||||
import javax.sip.message.Response;
|
||||
import java.text.ParseException;
|
||||
|
||||
@Component
|
||||
public class InfoRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(InfoRequestProcessor.class);
|
||||
|
||||
private final String method = "INFO";
|
||||
|
||||
@Autowired
|
||||
private SIPProcessorObserver sipProcessorObserver;
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorage storage;
|
||||
|
||||
@Autowired
|
||||
private SipSubscribe sipSubscribe;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private IInviteStreamService inviteStreamService;
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@Autowired
|
||||
private SIPCommander cmder;
|
||||
|
||||
@Autowired
|
||||
private VideoStreamSessionManager sessionManager;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// 添加消息处理的订阅
|
||||
sipProcessorObserver.addRequestProcessor(method, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(RequestEvent evt) {
|
||||
logger.debug("接收到消息:" + evt.getRequest());
|
||||
SIPRequest request = (SIPRequest) evt.getRequest();
|
||||
String deviceId = SipUtils.getUserIdFromFromHeader(request);
|
||||
CallIdHeader callIdHeader = request.getCallIdHeader();
|
||||
// 先从会话内查找
|
||||
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
|
||||
|
||||
// 兼容海康 媒体通知 消息from字段不是设备ID的问题
|
||||
if (ssrcTransaction != null) {
|
||||
deviceId = ssrcTransaction.getDeviceId();
|
||||
}
|
||||
// 查询设备是否存在
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
// 查询上级平台是否存在
|
||||
ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId);
|
||||
try {
|
||||
if (device != null && parentPlatform != null) {
|
||||
logger.warn("[重复]平台与设备编号重复:{}", deviceId);
|
||||
String hostAddress = request.getRemoteAddress().getHostAddress();
|
||||
int remotePort = request.getRemotePort();
|
||||
if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) {
|
||||
parentPlatform = null;
|
||||
}else {
|
||||
device = null;
|
||||
}
|
||||
}
|
||||
if (device == null && parentPlatform == null) {
|
||||
// 不存在则回复404
|
||||
responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found");
|
||||
logger.warn("[设备未找到 ]: {}", deviceId);
|
||||
if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){
|
||||
DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog());
|
||||
deviceNotFoundEvent.setCallId(callIdHeader.getCallId());
|
||||
SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(deviceNotFoundEvent);
|
||||
sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult);
|
||||
};
|
||||
}else {
|
||||
ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME);
|
||||
String contentType = header.getContentType();
|
||||
String contentSubType = header.getContentSubType();
|
||||
if ("Application".equalsIgnoreCase(contentType) && "MANSRTSP".equalsIgnoreCase(contentSubType)) {
|
||||
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());
|
||||
String streamId = sendRtpItem.getStreamId();
|
||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId);
|
||||
if (null == inviteInfo) {
|
||||
responseAck(request, Response.NOT_FOUND, "stream " + streamId + " not found");
|
||||
return;
|
||||
}
|
||||
Device device1 = storager.queryVideoDevice(inviteInfo.getDeviceId());
|
||||
if (inviteInfo.getStreamInfo() != null) {
|
||||
cmder.playbackControlCmd(device1,inviteInfo.getStreamInfo(),new String(evt.getRequest().getRawContent()),eventResult -> {
|
||||
// 失败的回复
|
||||
try {
|
||||
responseAck(request, eventResult.statusCode, eventResult.msg);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage());
|
||||
}
|
||||
}, eventResult -> {
|
||||
// 成功的回复
|
||||
try {
|
||||
responseAck(request, eventResult.statusCode);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (SipException e) {
|
||||
logger.warn("SIP 回复错误", e);
|
||||
} catch (InvalidArgumentException e) {
|
||||
logger.warn("参数无效", e);
|
||||
} catch (ParseException e) {
|
||||
logger.warn("SIP回复时解析异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.info;
|
||||
|
||||
import com.genersoft.iot.vmp.common.InviteInfo;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.RequestEvent;
|
||||
import javax.sip.SipException;
|
||||
import javax.sip.header.CallIdHeader;
|
||||
import javax.sip.header.ContentTypeHeader;
|
||||
import javax.sip.message.Response;
|
||||
import java.text.ParseException;
|
||||
|
||||
@Component
|
||||
public class InfoRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(InfoRequestProcessor.class);
|
||||
|
||||
private final String method = "INFO";
|
||||
|
||||
@Autowired
|
||||
private SIPProcessorObserver sipProcessorObserver;
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorage storage;
|
||||
|
||||
@Autowired
|
||||
private SipSubscribe sipSubscribe;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private IInviteStreamService inviteStreamService;
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@Autowired
|
||||
private SIPCommander cmder;
|
||||
|
||||
@Autowired
|
||||
private VideoStreamSessionManager sessionManager;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// 添加消息处理的订阅
|
||||
sipProcessorObserver.addRequestProcessor(method, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(RequestEvent evt) {
|
||||
logger.debug("接收到消息:" + evt.getRequest());
|
||||
SIPRequest request = (SIPRequest) evt.getRequest();
|
||||
String deviceId = SipUtils.getUserIdFromFromHeader(request);
|
||||
CallIdHeader callIdHeader = request.getCallIdHeader();
|
||||
// 先从会话内查找
|
||||
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
|
||||
|
||||
// 兼容海康 媒体通知 消息from字段不是设备ID的问题
|
||||
if (ssrcTransaction != null) {
|
||||
deviceId = ssrcTransaction.getDeviceId();
|
||||
}
|
||||
// 查询设备是否存在
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
// 查询上级平台是否存在
|
||||
ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId);
|
||||
try {
|
||||
if (device != null && parentPlatform != null) {
|
||||
logger.warn("[重复]平台与设备编号重复:{}", deviceId);
|
||||
String hostAddress = request.getRemoteAddress().getHostAddress();
|
||||
int remotePort = request.getRemotePort();
|
||||
if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) {
|
||||
parentPlatform = null;
|
||||
}else {
|
||||
device = null;
|
||||
}
|
||||
}
|
||||
if (device == null && parentPlatform == null) {
|
||||
// 不存在则回复404
|
||||
responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found");
|
||||
logger.warn("[设备未找到 ]: {}", deviceId);
|
||||
if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){
|
||||
DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog());
|
||||
deviceNotFoundEvent.setCallId(callIdHeader.getCallId());
|
||||
SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(deviceNotFoundEvent);
|
||||
sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult);
|
||||
};
|
||||
}else {
|
||||
ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME);
|
||||
String contentType = header.getContentType();
|
||||
String contentSubType = header.getContentSubType();
|
||||
if ("Application".equalsIgnoreCase(contentType) && "MANSRTSP".equalsIgnoreCase(contentSubType)) {
|
||||
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId());
|
||||
String streamId = sendRtpItem.getStreamId();
|
||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId);
|
||||
if (null == inviteInfo) {
|
||||
responseAck(request, Response.NOT_FOUND, "stream " + streamId + " not found");
|
||||
return;
|
||||
}
|
||||
Device device1 = storager.queryVideoDevice(inviteInfo.getDeviceId());
|
||||
if (inviteInfo.getStreamInfo() != null) {
|
||||
cmder.playbackControlCmd(device1,inviteInfo.getStreamInfo(),new String(evt.getRequest().getRawContent()),eventResult -> {
|
||||
// 失败的回复
|
||||
try {
|
||||
responseAck(request, eventResult.statusCode, eventResult.msg);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage());
|
||||
}
|
||||
}, eventResult -> {
|
||||
// 成功的回复
|
||||
try {
|
||||
responseAck(request, eventResult.statusCode);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (SipException e) {
|
||||
logger.warn("SIP 回复错误", e);
|
||||
} catch (InvalidArgumentException e) {
|
||||
logger.warn("参数无效", e);
|
||||
} catch (ParseException e) {
|
||||
logger.warn("SIP回复时解析异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/IMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/IMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/ControlMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/ControlMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/NotifyMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/NotifyMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
Normal file → Executable file
3
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
Normal file → Executable file
3
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
Normal file → Executable file
@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.dom4j.Element;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -68,7 +69,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 心跳回复: {}", e.getMessage());
|
||||
}
|
||||
if (DateUtil.getDifferenceForNow(device.getKeepaliveTime()) <= 3000L){
|
||||
if (!ObjectUtils.isEmpty(device.getKeepaliveTime()) && DateUtil.getDifferenceForNow(device.getKeepaliveTime()) <= 3000L) {
|
||||
logger.info("[收到心跳] 心跳发送过于频繁,已忽略 device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId());
|
||||
return;
|
||||
}
|
||||
|
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/QueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/QueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/ResponseMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/ResponseMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
Normal file → Executable file
0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user