From 407a5b77c3586fef44dc771e48f05c2354740795 Mon Sep 17 00:00:00 2001
From: 648540858 <18010473990@163.com>
Date: 星期二, 07 九月 2021 09:20:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java | 61 ++++++++++++++++++++----------
1 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
index 0b4ecbb..fb1aae2 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
@@ -12,6 +12,7 @@
import javax.sip.message.Response;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
+import gov.nist.javax.sip.SipProviderImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +40,7 @@
@Autowired
private SipSubscribe sipSubscribe;
- private SipStack sipStack;
+ private SipStackImpl sipStack;
private SipFactory sipFactory;
@@ -52,7 +53,7 @@
private ThreadPoolExecutor initSipServer() {
int processThreadNum = Runtime.getRuntime().availableProcessors() * 10;
- LinkedBlockingQueue<Runnable> processQueue = new LinkedBlockingQueue<Runnable>(10000);
+ LinkedBlockingQueue<Runnable> processQueue = new LinkedBlockingQueue<>(10000);
processThreadPool = new ThreadPoolExecutor(processThreadNum,processThreadNum,
0L,TimeUnit.MILLISECONDS,processQueue,
new ThreadPoolExecutor.CallerRunsPolicy());
@@ -72,7 +73,7 @@
private SipStack createSipStack() throws PeerUnavailableException {
Properties properties = new Properties();
properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP");
- properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getSipIp());
+ properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getMonitorIp());
properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false");
/**
* sip_server_log.log 鍜� sip_debug_log.log public static final int TRACE_NONE =
@@ -88,27 +89,48 @@
@Bean("tcpSipProvider")
@DependsOn("sipStack")
- private SipProvider startTcpListener() {
+ private SipProviderImpl startTcpListener() {
ListeningPoint tcpListeningPoint = null;
- SipProvider tcpSipProvider = null;
+ SipProviderImpl tcpSipProvider = null;
try {
- tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), "TCP");
- tcpSipProvider = sipStack.createSipProvider(tcpListeningPoint);
+ tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "TCP");
+ tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
tcpSipProvider.addSipListener(this);
- logger.info("Sip Server TCP 鍚姩鎴愬姛 port {" + sipConfig.getSipPort() + "}");
- } catch (TransportNotSupportedException | InvalidArgumentException | TooManyListenersException | ObjectInUseException e) {
- logger.error(String.format("鍒涘缓SIP鏈嶅姟澶辫触: %s", e.getMessage()));
+ logger.info("Sip Server TCP 鍚姩鎴愬姛 port {" + sipConfig.getMonitorIp() + ":" + sipConfig.getPort() + "}");
+ } catch (TransportNotSupportedException e) {
+ e.printStackTrace();
+ } catch (InvalidArgumentException e) {
+ logger.error("鏃犳硶浣跨敤 [ {}:{} ]浣滀负SIP[ TCP ]鏈嶅姟锛屽彲鎺掓煡: 1. sip.monitor-ip 鏄惁涓烘湰鏈虹綉鍗P; 2. sip.port 鏄惁宸茶鍗犵敤"
+ , sipConfig.getMonitorIp(), sipConfig.getPort());
+ } catch (TooManyListenersException e) {
+ e.printStackTrace();
+ } catch (ObjectInUseException e) {
+ e.printStackTrace();
}
return tcpSipProvider;
}
@Bean("udpSipProvider")
@DependsOn("sipStack")
- private SipProvider startUdpListener() throws Exception {
- ListeningPoint udpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), "UDP");
- SipProvider udpSipProvider = sipStack.createSipProvider(udpListeningPoint);
- udpSipProvider.addSipListener(this);
- logger.info("Sip Server UDP 鍚姩鎴愬姛 port {" + sipConfig.getSipPort() + "}");
+ private SipProviderImpl startUdpListener() {
+ ListeningPoint udpListeningPoint = null;
+ SipProviderImpl udpSipProvider = null;
+ try {
+ udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "UDP");
+ udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
+ udpSipProvider.addSipListener(this);
+// udpSipProvider.setAutomaticDialogSupportEnabled(false);
+ } catch (TransportNotSupportedException e) {
+ e.printStackTrace();
+ } catch (InvalidArgumentException e) {
+ logger.error("鏃犳硶浣跨敤 [ {}:{} ]浣滀负SIP[ UDP ]鏈嶅姟锛屽彲鎺掓煡: 1. sip.monitor-ip 鏄惁涓烘湰鏈虹綉鍗P; 2. sip.port 鏄惁宸茶鍗犵敤"
+ , sipConfig.getMonitorIp(), sipConfig.getPort());
+ } catch (TooManyListenersException e) {
+ e.printStackTrace();
+ } catch (ObjectInUseException e) {
+ e.printStackTrace();
+ }
+ logger.info("Sip Server UDP 鍚姩鎴愬姛 port [" + sipConfig.getMonitorIp() + ":" + sipConfig.getPort() + "]");
return udpSipProvider;
}
@@ -121,7 +143,9 @@
logger.debug(evt.getRequest().toString());
// 鐢变簬jainsip鏄崟绾跨▼绋嬪簭锛屼负鎻愰珮鎬ц兘骞跺彂澶勭悊
processThreadPool.execute(() -> {
- processorFactory.createRequestProcessor(evt).process();
+ if (processorFactory != null) {
+ processorFactory.createRequestProcessor(evt).process();
+ }
});
}
@@ -138,6 +162,7 @@
// TODO Auto-generated catch block
e.printStackTrace();
}
+
if (evt.getResponse() != null && sipSubscribe.getOkSubscribesSize() > 0 ) {
CallIdHeader callIdHeader = (CallIdHeader)evt.getResponse().getHeader(CallIdHeader.NAME);
if (callIdHeader != null) {
@@ -147,8 +172,6 @@
}
}
}
- // } else if (status == Response.TRYING) {
- // trying涓嶄細鍥炲
} else if ((status >= 100) && (status < 200)) {
// 澧炲姞鍏跺畠鏃犻渶鍥炲鐨勫搷搴旓紝濡�101銆�180绛�
} else {
@@ -197,7 +220,6 @@
@Override
public void processIOException(IOExceptionEvent exceptionEvent) {
// TODO Auto-generated method stub
-
}
/**
@@ -213,7 +235,6 @@
@Override
public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent) {
// TODO Auto-generated method stub
-
}
/**
--
Gitblit v1.8.0