From 7055c53192aadf6af9444c81373ab256e760b808 Mon Sep 17 00:00:00 2001 From: hexq Date: Sat, 20 Jan 2024 10:26:49 +0800 Subject: [PATCH] =?UTF-8?q?BUGFIX=EF=BC=9A=E5=9B=9E=E6=94=BE=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=85=88=E4=BB=8ESDP=E4=B8=AD=E6=8F=90?= =?UTF-8?q?=E5=8F=96channelId=EF=BC=8C=E5=85=BC=E5=AE=B9=E4=BB=8ESubject?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=8F=90=E5=8F=96=E5=88=B0channelId=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/impl/InviteRequestProcessor.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 61e973c1..52b34213 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -30,8 +30,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; @@ -133,7 +135,20 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements // 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) { @@ -242,12 +257,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;