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
This commit is contained in:
648540858
2024-03-08 09:30:48 +08:00
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 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;
@@ -147,8 +149,21 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
public void process(RequestEvent evt) {
// Invite Request消息实现此消息一般为级联消息上级给下级发送请求视频指令
try {
SIPRequest request = (SIPRequest) evt.getRequest();
String channelId = SipUtils.getChannelIdFromRequest(request);
SIPRequest request = (SIPRequest)evt.getRequest();
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 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
}
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;

View File

@@ -77,6 +77,50 @@ public class XmlUtil {
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节点适用于 多节点数据
*