Merge branch 'wvp-28181-2.0' into main-dev
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java结构优化
commit
1fcdf5a8f3
|
@ -35,8 +35,10 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||||
import gov.nist.javax.sdp.TimeDescriptionImpl;
|
import gov.nist.javax.sdp.TimeDescriptionImpl;
|
||||||
import gov.nist.javax.sdp.fields.TimeField;
|
import gov.nist.javax.sdp.fields.TimeField;
|
||||||
|
import gov.nist.javax.sdp.fields.URIField;
|
||||||
import gov.nist.javax.sip.message.SIPRequest;
|
import gov.nist.javax.sip.message.SIPRequest;
|
||||||
import gov.nist.javax.sip.message.SIPResponse;
|
import gov.nist.javax.sip.message.SIPResponse;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
@ -147,8 +149,21 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
public void process(RequestEvent evt) {
|
public void process(RequestEvent evt) {
|
||||||
// Invite Request消息实现,此消息一般为级联消息,上级给下级发送请求视频指令
|
// Invite Request消息实现,此消息一般为级联消息,上级给下级发送请求视频指令
|
||||||
try {
|
try {
|
||||||
SIPRequest request = (SIPRequest) evt.getRequest();
|
SIPRequest request = (SIPRequest)evt.getRequest();
|
||||||
String channelId = SipUtils.getChannelIdFromRequest(request);
|
String channelIdFromSub = SipUtils.getChannelIdFromRequest(request);
|
||||||
|
|
||||||
|
// 解析sdp消息, 使用jainsip 自带的sdp解析方式
|
||||||
|
String contentString = new String(request.getRawContent());
|
||||||
|
Gb28181Sdp gb28181Sdp = SipUtils.parseSDP(contentString);
|
||||||
|
SessionDescription sdp = gb28181Sdp.getBaseSdb();
|
||||||
|
String sessionName = sdp.getSessionName().getValue();
|
||||||
|
String channelIdFromSdp = null;
|
||||||
|
if(StringUtils.equalsIgnoreCase("Playback", sessionName)){
|
||||||
|
URIField uriField = (URIField)sdp.getURI();
|
||||||
|
channelIdFromSdp = uriField.getURI().split(":")[0];
|
||||||
|
}
|
||||||
|
final String channelId = StringUtils.isNotBlank(channelIdFromSdp) ? channelIdFromSdp : channelIdFromSub;
|
||||||
|
|
||||||
String requesterId = SipUtils.getUserIdFromFromHeader(request);
|
String requesterId = SipUtils.getUserIdFromFromHeader(request);
|
||||||
CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
|
CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
|
||||||
if (requesterId == null || channelId == null) {
|
if (requesterId == null || channelId == null) {
|
||||||
|
@ -257,12 +272,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 解析sdp消息, 使用jainsip 自带的sdp解析方式
|
|
||||||
String contentString = new String(request.getRawContent());
|
|
||||||
|
|
||||||
Gb28181Sdp gb28181Sdp = SipUtils.parseSDP(contentString);
|
|
||||||
SessionDescription sdp = gb28181Sdp.getBaseSdb();
|
|
||||||
String sessionName = sdp.getSessionName().getValue();
|
|
||||||
|
|
||||||
Long startTime = null;
|
Long startTime = null;
|
||||||
Long stopTime = null;
|
Long stopTime = null;
|
||||||
|
|
|
@ -77,6 +77,50 @@ public class XmlUtil {
|
||||||
return null == e ? null : e.getText().trim();
|
return null == e ? null : e.getText().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取element对象的text的值
|
||||||
|
*
|
||||||
|
* @param em 节点的对象
|
||||||
|
* @param tag 节点的tag
|
||||||
|
* @return 节点
|
||||||
|
*/
|
||||||
|
public static Double getDouble(Element em, String tag) {
|
||||||
|
if (null == em) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Element e = em.element(tag);
|
||||||
|
if (null == e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String text = e.getText().trim();
|
||||||
|
if (ObjectUtils.isEmpty(text) || !NumberUtils.isParsable(text)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Double.parseDouble(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取element对象的text的值
|
||||||
|
*
|
||||||
|
* @param em 节点的对象
|
||||||
|
* @param tag 节点的tag
|
||||||
|
* @return 节点
|
||||||
|
*/
|
||||||
|
public static Integer getInteger(Element em, String tag) {
|
||||||
|
if (null == em) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Element e = em.element(tag);
|
||||||
|
if (null == e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String text = e.getText().trim();
|
||||||
|
if (ObjectUtils.isEmpty(text) || !NumberUtils.isParsable(text)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Integer.parseInt(text);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归解析xml节点,适用于 多节点数据
|
* 递归解析xml节点,适用于 多节点数据
|
||||||
*
|
*
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||||
deviceChannelList.add(deviceChannel);
|
deviceChannelList.add(deviceChannel);
|
||||||
}
|
}
|
||||||
return deviceChannelList;
|
return deviceChannelList;
|
||||||
} else if (catalog == null || !catalogId.equals(platform.getDeviceGBId())) {
|
} else if (catalog == null && !catalogId.equals(platform.getDeviceGBId())) {
|
||||||
logger.warn("未查询到目录{}的信息", catalogId);
|
logger.warn("未查询到目录{}的信息", catalogId);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,16 +43,15 @@ import javax.sip.InvalidArgumentException;
|
||||||
import javax.sip.ResponseEvent;
|
import javax.sip.ResponseEvent;
|
||||||
import javax.sip.PeerUnavailableException;
|
import javax.sip.PeerUnavailableException;
|
||||||
import javax.sip.SipException;
|
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.text.ParseException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -392,7 +391,6 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||||
()-> registerTask(platform, null),
|
()-> registerTask(platform, null),
|
||||||
userSetting.getRegisterAgainAfterTime() * 1000);
|
userSetting.getRegisterAgainAfterTime() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,11 @@ public class DateUtil {
|
||||||
*/
|
*/
|
||||||
private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
|
private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* iso8601时间格式带时区,例如:2024-02-21T11:10:36+08:00
|
||||||
|
*/
|
||||||
|
private static final String ISO8601_ZONE_PATTERN = "yyyy-MM-dd'T'HH:mm:ssXXX";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wvp内部统一时间格式
|
* wvp内部统一时间格式
|
||||||
*/
|
*/
|
||||||
|
@ -49,6 +54,7 @@ public class DateUtil {
|
||||||
|
|
||||||
public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
||||||
public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
||||||
|
public static final DateTimeFormatter formatterZoneISO8601 = DateTimeFormatter.ofPattern(ISO8601_ZONE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
||||||
public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
||||||
public static final DateTimeFormatter DateFormatter = DateTimeFormatter.ofPattern(date_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
public static final DateTimeFormatter DateFormatter = DateTimeFormatter.ofPattern(date_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
||||||
public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr));
|
||||||
|
@ -59,7 +65,13 @@ public class DateUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) {
|
public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) {
|
||||||
|
// 三种日期格式都尝试,为了兼容不同厂家的日期格式
|
||||||
|
if (verification(formatTime, formatterCompatibleISO8601)) {
|
||||||
return formatter.format(formatterCompatibleISO8601.parse(formatTime));
|
return formatter.format(formatterCompatibleISO8601.parse(formatTime));
|
||||||
|
} else if (verification(formatTime, formatterZoneISO8601)) {
|
||||||
|
return formatter.format(formatterZoneISO8601.parse(formatTime));
|
||||||
|
}
|
||||||
|
return formatter.format(formatterISO8601.parse(formatTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String urlToyyyy_MM_dd_HH_mm_ss(String formatTime) {
|
public static String urlToyyyy_MM_dd_HH_mm_ss(String formatTime) {
|
||||||
|
|
|
@ -239,6 +239,8 @@ public class PlatformController {
|
||||||
if (parentPlatformCatch == null) {
|
if (parentPlatformCatch == null) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
|
||||||
}
|
}
|
||||||
|
parentPlatform.setEnable(false);
|
||||||
|
storager.updateParentPlatform(parentPlatform);
|
||||||
// 发送离线消息,无论是否成功都删除缓存
|
// 发送离线消息,无论是否成功都删除缓存
|
||||||
try {
|
try {
|
||||||
commanderForPlatform.unregister(parentPlatform, parentPlatformCatch.getSipTransactionInfo(), (event -> {
|
commanderForPlatform.unregister(parentPlatform, parentPlatformCatch.getSipTransactionInfo(), (event -> {
|
||||||
|
|
Loading…
Reference in New Issue