From 340a23a9613dae68361e5e4352556fa929911e68 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Thu, 25 Jun 2020 15:27:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E8=AE=BE?= =?UTF-8?q?=E5=A4=87invite=E5=90=8Ebye=E6=97=A0=E6=B3=95=E6=89=BE=E5=88=B0?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=9C=B0=E5=9D=80=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/transmit/cmd/impl/SIPCommander.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index b70f353e..96618d05 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -7,10 +7,13 @@ import javax.sip.Dialog; import javax.sip.InvalidArgumentException; import javax.sip.SipException; import javax.sip.TransactionDoesNotExistException; +import javax.sip.address.Address; +import javax.sip.address.SipURI; import javax.sip.header.ViaHeader; import javax.sip.message.Request; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.security.SecurityProperties.Headers; import org.springframework.stereotype.Component; import com.genersoft.iot.vmp.conf.SipConfig; @@ -21,6 +24,9 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; import com.genersoft.iot.vmp.gb28181.utils.DateUtil; +import java.util.regex.Pattern; +import java.util.regex.Matcher; + /** * @Description:设备能力接口,用于定义设备的控制、查询能力 * @author: songww @@ -288,6 +294,13 @@ public class SIPCommander implements ISIPCommander { return; } Request byeRequest = dialog.createRequest(Request.BYE); + SipURI byeURI = (SipURI) byeRequest.getRequestURI(); + String vh = transaction.getRequest().getHeader(ViaHeader.NAME).toString(); + Pattern p = Pattern.compile("(\\d+\\.\\d+\\.\\d+\\.\\d+)\\:(\\d+)"); + Matcher matcher = p.matcher(vh); + if (matcher.find()) { + byeURI.setHost(matcher.group(1)); + } ViaHeader viaHeader = (ViaHeader) byeRequest.getHeader(ViaHeader.NAME); String protocol = viaHeader.getTransport().toUpperCase(); ClientTransaction clientTransaction = null; @@ -301,6 +314,8 @@ public class SIPCommander implements ISIPCommander { e.printStackTrace(); } catch (SipException e) { e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); } }