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
结构优化
648540858 2024-03-08 09:30:48 +08:00
commit 1fcdf5a8f3
6 changed files with 81 additions and 16 deletions

View File

@ -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;

View File

@ -77,6 +77,50 @@ public class XmlUtil {
return null == e ? null : e.getText().trim(); return null == e ? null : e.getText().trim();
} }
/**
* elementtext
*
* @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);
}
/**
* elementtext
*
* @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
* *

View File

@ -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;
} }

View File

@ -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);
} }
} }
} }

View File

@ -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";
/**
* iso86012024-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) {

View File

@ -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 -> {