From 335916f1f15eb9d0b34dea38cacee2300eac0606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=98=B2?= Date: Mon, 7 Mar 2022 14:20:27 +0800 Subject: [PATCH] =?UTF-8?q?InviteRequestProcessor=E7=B1=BB=E4=B8=AD?= =?UTF-8?q?=EF=BC=8Cchannelid=E4=BB=8Einvite=E6=B6=88=E6=81=AF=E7=9A=84hea?= =?UTF-8?q?der=20subject=E8=8E=B7=E5=8F=96=EF=BC=8C=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E4=BB=8E=E7=AC=AC=E4=B8=80=E8=A1=8Crequest=20line=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E3=80=82=E5=8E=9F=E5=9B=A0=E6=98=AF=E5=92=8C=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E5=B9=B3=E5=8F=B0=E5=AF=B9=E6=8E=A5=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=8F=91=E9=80=81=E7=9A=84invite=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E8=A1=8C=E4=B8=BA=E5=9B=BD=E6=A0=87=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E7=BC=96=E7=A0=81=E8=80=8C=E4=B8=8D=E6=98=AF=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E9=80=9A=E9=81=93=E7=BC=96=E7=A0=81=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=8A=A5=E9=94=99=E9=80=9A=E9=81=93=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=EF=BC=8C=E8=BF=94=E5=9B=9E404=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/request/impl/InviteRequestProcessor.java | 6 +++++- .../com/genersoft/iot/vmp/gb28181/utils/SipUtils.java | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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 f861da41..9cf0d1bf 100644 --- 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 @@ -26,6 +26,7 @@ import gov.nist.javax.sdp.TimeDescriptionImpl; import gov.nist.javax.sdp.fields.TimeField; import gov.nist.javax.sip.address.AddressImpl; import gov.nist.javax.sip.address.SipUri; +import gov.nist.javax.sip.header.Subject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; @@ -40,6 +41,7 @@ import javax.sip.SipException; import javax.sip.address.SipURI; import javax.sip.header.CallIdHeader; import javax.sip.header.FromHeader; +import javax.sip.header.Header; import javax.sip.message.Request; import javax.sip.message.Response; import java.text.ParseException; @@ -105,7 +107,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { Request request = evt.getRequest(); SipURI sipURI = (SipURI) request.getRequestURI(); - String channelId = sipURI.getUser(); + //从subject读取channelId,不再从request-line读取。 有些平台request-line是平台国标编码,不是设备国标编码。 + //String channelId = sipURI.getUser(); + String channelId = SipUtils.getChannelIdFromHeader(request); String requesterId = SipUtils.getUserIdFromFromHeader(request); CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME); if (requesterId == null || channelId == null) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java index 9dd02715..80258188 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java @@ -2,8 +2,10 @@ package com.genersoft.iot.vmp.gb28181.utils; import gov.nist.javax.sip.address.AddressImpl; import gov.nist.javax.sip.address.SipUri; +import gov.nist.javax.sip.header.Subject; import javax.sip.header.FromHeader; +import javax.sip.header.Header; import javax.sip.message.Request; /** @@ -18,6 +20,13 @@ public class SipUtils { FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME); return getUserIdFromFromHeader(fromHeader); } + /** + * 从subject读取channelId + * */ + public static String getChannelIdFromHeader(Request request) { + Header subject = request.getHeader("subject"); + return ((Subject) subject).getSubject().split(":")[0]; + } public static String getUserIdFromFromHeader(FromHeader fromHeader) { AddressImpl address = (AddressImpl)fromHeader.getAddress();