src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
@@ -35,8 +35,10 @@ import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sdp.TimeDescriptionImpl; 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.SIPResponse; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; @@ -148,7 +150,20 @@ // Invite Request消息实现,此消息一般为级联消息,上级给下级发送请求视频指令 try { 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); CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); if (requesterId == null || channelId == null) { @@ -257,12 +272,6 @@ } 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 stopTime = null; src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
@@ -78,6 +78,50 @@ } /** * 获取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节点,适用于 多节点数据 * * @param node node src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
@@ -136,7 +136,7 @@ deviceChannelList.add(deviceChannel); } return deviceChannelList; } else if (catalog == null || !catalogId.equals(platform.getDeviceGBId())) { } else if (catalog == null && !catalogId.equals(platform.getDeviceGBId())) { logger.warn("未查询到目录{}的信息", catalogId); return null; } src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
@@ -43,12 +43,11 @@ import javax.sip.ResponseEvent; 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.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -392,7 +391,6 @@ ()-> registerTask(platform, null), userSetting.getRegisterAgainAfterTime() * 1000); } } } src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
@@ -31,6 +31,11 @@ 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内部统一时间格式 */ public static final String PATTERN = "yyyy-MM-dd HH:mm:ss"; @@ -49,6 +54,7 @@ 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 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 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)); @@ -59,7 +65,13 @@ } public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) { // 三种日期格式都尝试,为了兼容不同厂家的日期格式 if (verification(formatTime, formatterCompatibleISO8601)) { 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) { src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
@@ -239,6 +239,8 @@ if (parentPlatformCatch == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在"); } parentPlatform.setEnable(false); storager.updateParentPlatform(parentPlatform); // 发送离线消息,无论是否成功都删除缓存 try { commanderForPlatform.unregister(parentPlatform, parentPlatformCatch.getSipTransactionInfo(), (event -> {