From 09a23bc80e017e73160c3fba89f609fe045f5748 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 05 一月 2023 17:49:34 +0800
Subject: [PATCH] 修复布防撤防 #717

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java
index f723a6f..0aff21d 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java
@@ -106,11 +106,27 @@
     }
 
     public CallIdHeader getNewCallIdHeader(String ip, String transport){
-        if (ObjectUtils.isEmpty(ip) || ObjectUtils.isEmpty(transport)) {
-            return  transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider().getNewCallId()
-                    : sipLayer.getUdpSipProvider().getNewCallId();
+        if (ObjectUtils.isEmpty(transport)) {
+            return sipLayer.getUdpSipProvider().getNewCallId();
         }
-        return  transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider(ip).getNewCallId()
-                : sipLayer.getUdpSipProvider(ip).getNewCallId();
+        SipProviderImpl sipProvider;
+        if (ObjectUtils.isEmpty(ip)) {
+            sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider()
+                    : sipLayer.getUdpSipProvider();
+        }else {
+            sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider(ip)
+                    : sipLayer.getUdpSipProvider(ip);
+        }
+
+        if (sipProvider == null) {
+            sipProvider = sipLayer.getUdpSipProvider();
+        }
+
+        if (sipProvider != null) {
+            return sipProvider.getNewCallId();
+        }else {
+            logger.warn("[鏂板缓CallIdHeader澶辫触]锛� ip={}, transport={}", ip, transport);
+            return null;
+        }
     }
 }

--
Gitblit v1.8.0