diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java index 6140720f..d0abfbf7 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java @@ -128,7 +128,7 @@ public class ProxyServletConfig { MediaServerItem getMediaInfoByUri(String uri){ String[] split = uri.split("/"); String mediaServerId = split[2]; - if ("default".equals(mediaServerId)) { + if ("default".equalsIgnoreCase(mediaServerId)) { return mediaServerService.getDefaultMediaServer(); }else { return mediaServerService.getOne(mediaServerId); @@ -246,7 +246,7 @@ public class ProxyServletConfig { MediaServerItem getMediaInfoByUri(String uri){ String[] split = uri.split("/"); String mediaServerId = split[2]; - if ("default".equals(mediaServerId)) { + if ("default".equalsIgnoreCase(mediaServerId)) { return mediaServerService.getDefaultMediaServer(); }else { return mediaServerService.getOne(mediaServerId); 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 5cd85d02..c2196dc4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java @@ -47,12 +47,16 @@ public class SipLayer{ /** * 完整配置参考 gov.nist.javax.sip.SipStackImpl,需要下载源码 * gov/nist/javax/sip/SipStackImpl.class + * sip消息的解析在 gov.nist.javax.sip.stack.UDPMessageChannel的processIncomingDataPacket方法 */ +// * gov/nist/javax/sip/SipStackImpl.class if (logger.isDebugEnabled()) { properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false"); } // 接收所有notify请求,即使没有订阅 properties.setProperty("gov.nist.javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true"); + properties.setProperty("gov.nist.javax.sip.AUTOMATIC_DIALOG_ERROR_HANDLING", "false"); + properties.setProperty("gov.nist.javax.sip.CANCEL_CLIENT_TRANSACTION_CHECKED", "false"); // 为_NULL _对话框传递_终止的_事件 properties.setProperty("gov.nist.javax.sip.DELIVER_TERMINATED_EVENT_FOR_NULL_DIALOG", "true"); // 会话清理策略 @@ -64,7 +68,7 @@ public class SipLayer{ * sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE */ properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "ERROR"); - properties.setProperty("gov.nist.javax.sip.SIP_MESSAGE_VALVE", "com.genersoft.iot.vmp.gb28181.session.SipMessagePreprocessing"); +// properties.setProperty("gov.nist.javax.sip.SIP_MESSAGE_VALVE", "com.genersoft.iot.vmp.gb28181.session.SipMessagePreprocessing"); // if (logger.isDebugEnabled()) { // properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "DEBUG"); // } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java index a0e16bff..7c319efc 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java @@ -218,7 +218,7 @@ public class DigestServerAuthenticationHelper { logger.debug("qop: " + qop); String KD = HA1 + ":" + nonce; - if (qop != null && qop.equals("auth") ) { + if (qop != null && qop.equalsIgnoreCase("auth") ) { if (nc != -1) { KD += ":" + ncStr; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/SipMessagePreprocessing.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/SipMessagePreprocessing.java deleted file mode 100644 index c3c12a5c..00000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/SipMessagePreprocessing.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.session; - -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.stack.MessageChannel; -import gov.nist.javax.sip.stack.SIPMessageValve; - -import javax.sip.SipStack; -import javax.sip.message.Response; - -public class SipMessagePreprocessing implements SIPMessageValve { - @Override - public boolean processRequest(SIPRequest sipRequest, MessageChannel messageChannel) { - return false; - } - - @Override - public boolean processResponse(Response response, MessageChannel messageChannel) { - return false; - } - - @Override - public void init(SipStack sipStack) { - - } - - @Override - public void destroy() { - - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java index 71944f90..b94daf7a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java @@ -28,7 +28,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { private final static Logger logger = LoggerFactory.getLogger(SIPProcessorObserver.class); - private static Map requestProcessorMap = new ConcurrentHashMap<>(); + private static Map requestProcessorMap = new ConcurrentHashMap<>(); private static Map responseProcessorMap = new ConcurrentHashMap<>(); private static ITimeoutProcessor timeoutProcessor; @@ -72,6 +72,9 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { @Async public void processRequest(RequestEvent requestEvent) { String method = requestEvent.getRequest().getMethod(); + if ("NOTIFY".equalsIgnoreCase(requestEvent.getRequest().getMethod())) { + System.out.println(); + } ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); if (sipRequestProcessor == null) { logger.warn("不支持方法{}的request", method); @@ -91,7 +94,8 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { Response response = responseEvent.getResponse(); int status = response.getStatusCode(); - if (((status >= 200) && (status < 300)) || status == Response.UNAUTHORIZED) { // Success! + // Success + if (((status >= Response.OK) && (status < Response.MULTIPLE_CHOICES)) || status == Response.UNAUTHORIZED) { CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME); String method = cseqHeader.getMethod(); ISIPResponseProcessor sipRequestProcessor = responseProcessorMap.get(method); @@ -109,7 +113,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { } } } - } else if ((status >= 100) && (status < 200)) { + } else if ((status >= Response.TRYING) && (status < Response.OK)) { // 增加其它无需回复的响应,如101、180等 } else { logger.warn("接收到失败的response响应!status:" + status + ",message:" + response.getReasonPhrase()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java index a75e806c..a689b2b4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java @@ -146,12 +146,12 @@ public class SIPRequestHeaderPlarformProvider { String cNonce = null; String nc = "00000001"; if (qop != null) { - if ("auth".equals(qop)) { + if ("auth".equalsIgnoreCase(qop)) { // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 cNonce = UUID.randomUUID().toString(); - }else if ("auth-int".equals(qop)){ + }else if ("auth-int".equalsIgnoreCase(qop)){ // TODO } } 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 5ceaa267..f006eccd 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 @@ -247,7 +247,7 @@ public class SIPCommander implements ISIPCommander { String tm = Long.toString(System.currentTimeMillis()); - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); @@ -290,7 +290,7 @@ public class SIPCommander implements ISIPCommander { String tm = Long.toString(System.currentTimeMillis()); - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); @@ -326,7 +326,7 @@ public class SIPCommander implements ISIPCommander { String tm = Long.toString(System.currentTimeMillis()); - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); @@ -353,7 +353,7 @@ public class SIPCommander implements ISIPCommander { if (device == null) { return; } - String streamMode = device.getStreamMode().toUpperCase(); +// String streamMode = device.getStreamMode().toUpperCase(); logger.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtmp", mediaServerItem.getId()); @@ -372,11 +372,11 @@ public class SIPCommander implements ISIPCommander { content.append("t=0 0\r\n"); if (userSetting.isSeniorSdp()) { - if("TCP-PASSIVE".equals(streamMode)) { + if("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - }else if ("TCP-ACTIVE".equals(streamMode)) { + }else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - }else if("UDP".equals(streamMode)) { + }else if("UDP".equalsIgnoreCase(device.getStreamMode())) { content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 126 125 99 34 98 97\r\n"); } content.append("a=recvonly\r\n"); @@ -388,19 +388,19 @@ public class SIPCommander implements ISIPCommander { content.append("a=rtpmap:99 H265/90000\r\n"); content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n"); - if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 + if("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())){ // tcp被动模式 content.append("a=setup:passive\r\n"); content.append("a=connection:new\r\n"); - }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 + }else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp主动模式 content.append("a=setup:active\r\n"); content.append("a=connection:new\r\n"); } }else { - if("TCP-PASSIVE".equals(streamMode)) { + if("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); - }else if ("TCP-ACTIVE".equals(streamMode)) { + }else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); - }else if("UDP".equals(streamMode)) { + }else if("UDP".equalsIgnoreCase(device.getStreamMode())) { content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 97 98 99\r\n"); } content.append("a=recvonly\r\n"); @@ -408,10 +408,10 @@ public class SIPCommander implements ISIPCommander { content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n"); content.append("a=rtpmap:99 H265/90000\r\n"); - if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 + if ("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp被动模式 content.append("a=setup:passive\r\n"); content.append("a=connection:new\r\n"); - } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 + } else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp主动模式 content.append("a=setup:active\r\n"); content.append("a=connection:new\r\n"); } @@ -423,7 +423,7 @@ public class SIPCommander implements ISIPCommander { String tm = Long.toString(System.currentTimeMillis()); - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "FromInvt" + tm, null, ssrcInfo.getSsrc(), callIdHeader); @@ -470,14 +470,14 @@ public class SIPCommander implements ISIPCommander { content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" " +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n"); - String streamMode = device.getStreamMode().toUpperCase(); + String streamMode = device.getStreamMode(); if (userSetting.isSeniorSdp()) { - if("TCP-PASSIVE".equals(streamMode)) { + if("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - }else if ("TCP-ACTIVE".equals(streamMode)) { + }else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - }else if("UDP".equals(streamMode)) { + }else if("UDP".equalsIgnoreCase(streamMode)) { content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 126 125 99 34 98 97\r\n"); } content.append("a=recvonly\r\n"); @@ -489,19 +489,19 @@ public class SIPCommander implements ISIPCommander { content.append("a=rtpmap:99 H265/90000\r\n"); content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:97 MPEG4/90000\r\n"); - if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 + if("TCP-PASSIVE".equalsIgnoreCase(streamMode)){ // tcp被动模式 content.append("a=setup:passive\r\n"); content.append("a=connection:new\r\n"); - }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 + }else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式 content.append("a=setup:active\r\n"); content.append("a=connection:new\r\n"); } }else { - if("TCP-PASSIVE".equals(streamMode)) { + if("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); - }else if ("TCP-ACTIVE".equals(streamMode)) { + }else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); - }else if("UDP".equals(streamMode)) { + }else if("UDP".equalsIgnoreCase(streamMode)) { content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 97 98 99\r\n"); } content.append("a=recvonly\r\n"); @@ -509,10 +509,10 @@ public class SIPCommander implements ISIPCommander { content.append("a=rtpmap:97 MPEG4/90000\r\n"); content.append("a=rtpmap:98 H264/90000\r\n"); content.append("a=rtpmap:99 H265/90000\r\n"); - if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 + if("TCP-PASSIVE".equalsIgnoreCase(streamMode)){ // tcp被动模式 content.append("a=setup:passive\r\n"); content.append("a=connection:new\r\n"); - }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 + }else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式 content.append("a=setup:active\r\n"); content.append("a=connection:new\r\n"); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index 2d6d582b..d078cb1b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -92,10 +92,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { String tm = Long.toString(System.currentTimeMillis()); if (!registerAgain ) { CallIdHeader callIdHeader = null; - if(parentPlatform.getTransport().equals("TCP")) { + if(parentPlatform.getTransport().equalsIgnoreCase("TCP")) { callIdHeader = tcpSipProvider.getNewCallId(); } - if(parentPlatform.getTransport().equals("UDP")) { + if(parentPlatform.getTransport().equalsIgnoreCase("UDP")) { callIdHeader = udpSipProvider.getNewCallId(); } @@ -119,7 +119,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { }); }else { - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, "FromRegister" + tm, null, callId, www, callIdHeader, isRegister); } @@ -152,7 +152,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { keepaliveXml.append("OK\r\n"); keepaliveXml.append("\r\n"); - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProviderPlarformProvider.createKeetpaliveMessageRequest( @@ -180,10 +180,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException { logger.debug("\n发送消息:\n{}", request); - if("TCP".equals(parentPlatform.getTransport())) { + if("TCP".equalsIgnoreCase(parentPlatform.getTransport())) { tcpSipProvider.sendRequest(request); - } else if("UDP".equals(parentPlatform.getTransport())) { + } else if("UDP".equalsIgnoreCase(parentPlatform.getTransport())) { udpSipProvider.sendRequest(request); } @@ -219,7 +219,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); // callid - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, callIdHeader); @@ -305,7 +305,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); // callid - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, callIdHeader); @@ -345,7 +345,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { deviceInfoXml.append("OK\r\n"); deviceInfoXml.append("\r\n"); - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, callIdHeader); @@ -383,7 +383,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { deviceStatusXml.append("OK\r\n"); deviceStatusXml.append("\r\n"); - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, callIdHeader); @@ -421,7 +421,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { deviceStatusXml.append("" + gpsMsgInfo.getAltitude() + "\r\n"); deviceStatusXml.append("\r\n"); - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); callIdHeader.setCallId(subscribeInfo.getCallId()); @@ -466,7 +466,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { deviceStatusXml.append("\r\n"); deviceStatusXml.append("\r\n"); - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); String tm = Long.toString(System.currentTimeMillis()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java index 8977d8a7..32130654 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java @@ -66,7 +66,7 @@ public abstract class SIPRequestProcessorParent { boolean isTcp = false; ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); String transport = reqViaHeader.getTransport(); - if (transport.equals("TCP")) { + if (transport.equalsIgnoreCase("TCP")) { isTcp = true; } @@ -142,7 +142,7 @@ public abstract class SIPRequestProcessorParent { return; } serverTransaction.sendResponse(response); - if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) { + if (statusCode >= 200 && !"NOTIFY".equalsIgnoreCase(evt.getRequest().getMethod())) { if (serverTransaction.getDialog() != null) { serverTransaction.getDialog().delete(); @@ -155,7 +155,7 @@ public abstract class SIPRequestProcessorParent { response.setReasonPhrase(msg); ServerTransaction serverTransaction = getServerTransaction(evt); serverTransaction.sendResponse(response); - if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) { + if (statusCode >= 200 && !"NOTIFY".equalsIgnoreCase(evt.getRequest().getMethod())) { if (serverTransaction.getDialog() != null) { serverTransaction.getDialog().delete(); } 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 52cb3749..5286aa51 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 @@ -248,16 +248,16 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements String protocol = media.getProtocol(); // 区分TCP发流还是udp, 当前默认udp - if ("TCP/RTP/AVP".equals(protocol)) { + if ("TCP/RTP/AVP".equalsIgnoreCase(protocol)) { String setup = mediaDescription.getAttribute("setup"); if (setup != null) { mediaTransmissionTCP = true; - if ("active".equals(setup)) { + if ("active".equalsIgnoreCase(setup)) { tcpActive = true; // 不支持tcp主动 responseAck(evt, Response.NOT_IMPLEMENTED, "tcp active not support"); // 目录不支持点播 return; - } else if ("passive".equals(setup)) { + } else if ("passive".equalsIgnoreCase(setup)) { tcpActive = false; } } @@ -302,7 +302,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements return; } sendRtpItem.setCallId(callIdHeader.getCallId()); - sendRtpItem.setPlayType("Play".equals(sessionName) ? InviteStreamType.PLAY : InviteStreamType.PLAYBACK); + sendRtpItem.setPlayType("Play".equalsIgnoreCase(sessionName) ? InviteStreamType.PLAY : InviteStreamType.PLAYBACK); Long finalStartTime = startTime; Long finalStopTime = stopTime; @@ -321,7 +321,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements content.append("o=" + channelId + " 0 0 IN IP4 " + mediaServerItemInUSe.getSdpIp() + "\r\n"); content.append("s=" + sessionName + "\r\n"); content.append("c=IN IP4 " + mediaServerItemInUSe.getSdpIp() + "\r\n"); - if ("Playback".equals(sessionName)) { + if ("Playback".equalsIgnoreCase(sessionName)) { content.append("t=" + finalStartTime + " " + finalStopTime + "\r\n"); } else { content.append("t=0 0\r\n"); @@ -365,7 +365,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } }); sendRtpItem.setApp("rtp"); - if ("Playback".equals(sessionName)) { + if ("Playback".equalsIgnoreCase(sessionName)) { sendRtpItem.setPlayType(InviteStreamType.PLAYBACK); SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, true, true); sendRtpItem.setStreamId(ssrcInfo.getStream()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index e0f723ab..8bab8f53 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -159,7 +159,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen // 判断TCP还是UDP ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); String transport = reqViaHeader.getTransport(); - device.setTransport("TCP".equals(transport) ? "TCP" : "UDP"); + device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP"); } sendResponse(evt, response); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 6ce2ce05..4b7629ce 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -132,7 +132,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme return; } if (evt.getServerTransaction() == null) { - ServerTransaction serverTransaction = "TCP".equals(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) + ServerTransaction serverTransaction = "TCP".equalsIgnoreCase(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) : udpSipProvider.getNewServerTransaction(evt.getRequest()); subscribeInfo.setTransaction(serverTransaction); Dialog dialog = serverTransaction.getDialog(); @@ -188,7 +188,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme } SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); if (evt.getServerTransaction() == null) { - ServerTransaction serverTransaction = "TCP".equals(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) + ServerTransaction serverTransaction = "TCP".equalsIgnoreCase(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) : udpSipProvider.getNewServerTransaction(evt.getRequest()); subscribeInfo.setTransaction(serverTransaction); Dialog dialog = serverTransaction.getDialog(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java index a1e98f9e..98a2ec2d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java @@ -96,7 +96,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME); String contentType = header.getContentType(); String contentSubType = header.getContentSubType(); - if ("Application".equals(contentType) && "MANSRTSP".equals(contentSubType)) { + if ("Application".equalsIgnoreCase(contentType) && "MANSRTSP".equalsIgnoreCase(contentSubType)) { SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId()); String streamId = sendRtpItem.getStreamId(); StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java index 17738a5f..5854261b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java @@ -76,7 +76,7 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen logger.debug(json.toJSONString()); } String text = onlineElement.getText(); - if (Objects.equals(text.trim().toUpperCase(), "ONLINE")) { + if ("ONLINE".equalsIgnoreCase(text.trim())) { deviceService.online(device); }else { deviceService.offline(device.getDeviceId()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java index 0ed119ee..abc9440d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java @@ -77,7 +77,7 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent Element itemOne = itemListIterator.next(); String name = itemOne.getName(); String textTrim = itemOne.getTextTrim(); - if("PresetID".equals(name)){ + if("PresetID".equalsIgnoreCase(name)){ presetQuerySipReq.setPresetId(textTrim); }else { presetQuerySipReq.setPresetName(textTrim);