Commit aa6bce35c710750b68d4e6c53095e9be4e1afd8d
Merge branch 'wvp-28181-2.0'
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java # src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
Showing
28 changed files
with
269 additions
and
146 deletions
src/main/java/com/genersoft/iot/vmp/conf/GlobalExceptionHandler.java
| @@ -32,6 +32,7 @@ public class GlobalExceptionHandler { | @@ -32,6 +32,7 @@ public class GlobalExceptionHandler { | ||
| 32 | return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage()); | 32 | return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage()); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | + | ||
| 35 | /** | 36 | /** |
| 36 | * 自定义异常处理, 处理controller中返回的错误 | 37 | * 自定义异常处理, 处理controller中返回的错误 |
| 37 | * @param e 异常 | 38 | * @param e 异常 |
src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java
| 1 | package com.genersoft.iot.vmp.conf; | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; | ||
| 4 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; | 5 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 5 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 6 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 6 | import org.jetbrains.annotations.NotNull; | 7 | import org.jetbrains.annotations.NotNull; |
| 8 | +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; | ||
| 9 | +import org.springframework.context.annotation.Bean; | ||
| 7 | import org.springframework.core.MethodParameter; | 10 | import org.springframework.core.MethodParameter; |
| 8 | import org.springframework.http.MediaType; | 11 | import org.springframework.http.MediaType; |
| 9 | import org.springframework.http.converter.HttpMessageConverter; | 12 | import org.springframework.http.converter.HttpMessageConverter; |
| 13 | +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | ||
| 10 | import org.springframework.http.server.ServerHttpRequest; | 14 | import org.springframework.http.server.ServerHttpRequest; |
| 11 | import org.springframework.http.server.ServerHttpResponse; | 15 | import org.springframework.http.server.ServerHttpResponse; |
| 12 | import org.springframework.web.bind.annotation.RestControllerAdvice; | 16 | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| 13 | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; | 17 | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; |
| 14 | 18 | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 15 | /** | 21 | /** |
| 16 | * 全局统一返回结果 | 22 | * 全局统一返回结果 |
| 17 | * @author lin | 23 | * @author lin |
| @@ -25,6 +31,7 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> { | @@ -25,6 +31,7 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> { | ||
| 25 | return true; | 31 | return true; |
| 26 | } | 32 | } |
| 27 | 33 | ||
| 34 | + | ||
| 28 | @Override | 35 | @Override |
| 29 | public Object beforeBodyWrite(Object body, @NotNull MethodParameter returnType, @NotNull MediaType selectedContentType, @NotNull Class<? extends HttpMessageConverter<?>> selectedConverterType, @NotNull ServerHttpRequest request, @NotNull ServerHttpResponse response) { | 36 | public Object beforeBodyWrite(Object body, @NotNull MethodParameter returnType, @NotNull MediaType selectedContentType, @NotNull Class<? extends HttpMessageConverter<?>> selectedConverterType, @NotNull ServerHttpRequest request, @NotNull ServerHttpResponse response) { |
| 30 | // 排除api文档的接口,这个接口不需要统一 | 37 | // 排除api文档的接口,这个接口不需要统一 |
| @@ -50,4 +57,13 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> { | @@ -50,4 +57,13 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> { | ||
| 50 | 57 | ||
| 51 | return WVPResult.success(body); | 58 | return WVPResult.success(body); |
| 52 | } | 59 | } |
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 防止返回string时出错 | ||
| 63 | + * @return | ||
| 64 | + */ | ||
| 65 | + @Bean | ||
| 66 | + public HttpMessageConverters custHttpMessageConverter() { | ||
| 67 | + return new HttpMessageConverters(new FastJsonHttpMessageConverter()); | ||
| 68 | + } | ||
| 53 | } | 69 | } |
src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
| @@ -128,7 +128,7 @@ public class ProxyServletConfig { | @@ -128,7 +128,7 @@ public class ProxyServletConfig { | ||
| 128 | MediaServerItem getMediaInfoByUri(String uri){ | 128 | MediaServerItem getMediaInfoByUri(String uri){ |
| 129 | String[] split = uri.split("/"); | 129 | String[] split = uri.split("/"); |
| 130 | String mediaServerId = split[2]; | 130 | String mediaServerId = split[2]; |
| 131 | - if ("default".equals(mediaServerId)) { | 131 | + if ("default".equalsIgnoreCase(mediaServerId)) { |
| 132 | return mediaServerService.getDefaultMediaServer(); | 132 | return mediaServerService.getDefaultMediaServer(); |
| 133 | }else { | 133 | }else { |
| 134 | return mediaServerService.getOne(mediaServerId); | 134 | return mediaServerService.getOne(mediaServerId); |
| @@ -246,7 +246,7 @@ public class ProxyServletConfig { | @@ -246,7 +246,7 @@ public class ProxyServletConfig { | ||
| 246 | MediaServerItem getMediaInfoByUri(String uri){ | 246 | MediaServerItem getMediaInfoByUri(String uri){ |
| 247 | String[] split = uri.split("/"); | 247 | String[] split = uri.split("/"); |
| 248 | String mediaServerId = split[2]; | 248 | String mediaServerId = split[2]; |
| 249 | - if ("default".equals(mediaServerId)) { | 249 | + if ("default".equalsIgnoreCase(mediaServerId)) { |
| 250 | return mediaServerService.getDefaultMediaServer(); | 250 | return mediaServerService.getDefaultMediaServer(); |
| 251 | }else { | 251 | }else { |
| 252 | return mediaServerService.getOne(mediaServerId); | 252 | return mediaServerService.getOne(mediaServerId); |
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
| @@ -47,12 +47,16 @@ public class SipLayer{ | @@ -47,12 +47,16 @@ public class SipLayer{ | ||
| 47 | /** | 47 | /** |
| 48 | * 完整配置参考 gov.nist.javax.sip.SipStackImpl,需要下载源码 | 48 | * 完整配置参考 gov.nist.javax.sip.SipStackImpl,需要下载源码 |
| 49 | * gov/nist/javax/sip/SipStackImpl.class | 49 | * gov/nist/javax/sip/SipStackImpl.class |
| 50 | + * sip消息的解析在 gov.nist.javax.sip.stack.UDPMessageChannel的processIncomingDataPacket方法 | ||
| 50 | */ | 51 | */ |
| 52 | +// * gov/nist/javax/sip/SipStackImpl.class | ||
| 51 | if (logger.isDebugEnabled()) { | 53 | if (logger.isDebugEnabled()) { |
| 52 | properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false"); | 54 | properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false"); |
| 53 | } | 55 | } |
| 54 | // 接收所有notify请求,即使没有订阅 | 56 | // 接收所有notify请求,即使没有订阅 |
| 55 | properties.setProperty("gov.nist.javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true"); | 57 | properties.setProperty("gov.nist.javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true"); |
| 58 | + properties.setProperty("gov.nist.javax.sip.AUTOMATIC_DIALOG_ERROR_HANDLING", "false"); | ||
| 59 | + properties.setProperty("gov.nist.javax.sip.CANCEL_CLIENT_TRANSACTION_CHECKED", "false"); | ||
| 56 | // 为_NULL _对话框传递_终止的_事件 | 60 | // 为_NULL _对话框传递_终止的_事件 |
| 57 | properties.setProperty("gov.nist.javax.sip.DELIVER_TERMINATED_EVENT_FOR_NULL_DIALOG", "true"); | 61 | properties.setProperty("gov.nist.javax.sip.DELIVER_TERMINATED_EVENT_FOR_NULL_DIALOG", "true"); |
| 58 | // 会话清理策略 | 62 | // 会话清理策略 |
| @@ -64,6 +68,7 @@ public class SipLayer{ | @@ -64,6 +68,7 @@ public class SipLayer{ | ||
| 64 | * sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE | 68 | * sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE |
| 65 | */ | 69 | */ |
| 66 | properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "ERROR"); | 70 | properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "ERROR"); |
| 71 | +// properties.setProperty("gov.nist.javax.sip.SIP_MESSAGE_VALVE", "com.genersoft.iot.vmp.gb28181.session.SipMessagePreprocessing"); | ||
| 67 | // if (logger.isDebugEnabled()) { | 72 | // if (logger.isDebugEnabled()) { |
| 68 | // properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "DEBUG"); | 73 | // properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "DEBUG"); |
| 69 | // } | 74 | // } |
src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java
| @@ -218,7 +218,7 @@ public class DigestServerAuthenticationHelper { | @@ -218,7 +218,7 @@ public class DigestServerAuthenticationHelper { | ||
| 218 | logger.debug("qop: " + qop); | 218 | logger.debug("qop: " + qop); |
| 219 | String KD = HA1 + ":" + nonce; | 219 | String KD = HA1 + ":" + nonce; |
| 220 | 220 | ||
| 221 | - if (qop != null && qop.equals("auth") ) { | 221 | + if (qop != null && qop.equalsIgnoreCase("auth") ) { |
| 222 | if (nc != -1) { | 222 | if (nc != -1) { |
| 223 | KD += ":" + ncStr; | 223 | KD += ":" + ncStr; |
| 224 | } | 224 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java
| @@ -90,7 +90,7 @@ public class ParentPlatform { | @@ -90,7 +90,7 @@ public class ParentPlatform { | ||
| 90 | * 心跳周期(秒) | 90 | * 心跳周期(秒) |
| 91 | */ | 91 | */ |
| 92 | @Schema(description = "心跳周期(秒)") | 92 | @Schema(description = "心跳周期(秒)") |
| 93 | - private String keepTimeout; | 93 | + private int keepTimeout; |
| 94 | 94 | ||
| 95 | /** | 95 | /** |
| 96 | * 传输协议 | 96 | * 传输协议 |
| @@ -294,11 +294,11 @@ public class ParentPlatform { | @@ -294,11 +294,11 @@ public class ParentPlatform { | ||
| 294 | this.expires = expires; | 294 | this.expires = expires; |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | - public String getKeepTimeout() { | 297 | + public int getKeepTimeout() { |
| 298 | return keepTimeout; | 298 | return keepTimeout; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | - public void setKeepTimeout(String keepTimeout) { | 301 | + public void setKeepTimeout(int keepTimeout) { |
| 302 | this.keepTimeout = keepTimeout; | 302 | this.keepTimeout = keepTimeout; |
| 303 | } | 303 | } |
| 304 | 304 |
src/main/java/com/genersoft/iot/vmp/gb28181/conf/SipLoggerPass.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.gb28181.conf; | ||
| 2 | + | ||
| 3 | +import gov.nist.core.StackLogger; | ||
| 4 | + | ||
| 5 | +import java.util.Properties; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * sip日志格式化 | ||
| 9 | + */ | ||
| 10 | +public class SipLoggerPass implements StackLogger { | ||
| 11 | + | ||
| 12 | + @Override | ||
| 13 | + public void logStackTrace() { | ||
| 14 | + | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + @Override | ||
| 18 | + public void logStackTrace(int traceLevel) { | ||
| 19 | + | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public int getLineCount() { | ||
| 24 | + return 0; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + public void logException(Throwable ex) { | ||
| 29 | + | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public void logDebug(String message) { | ||
| 34 | + | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void logDebug(String message, Exception ex) { | ||
| 39 | + | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public void logTrace(String message) { | ||
| 44 | + | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @Override | ||
| 48 | + public void logFatalError(String message) { | ||
| 49 | + | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Override | ||
| 53 | + public void logError(String message) { | ||
| 54 | + | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public boolean isLoggingEnabled() { | ||
| 59 | + return false; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public boolean isLoggingEnabled(int logLevel) { | ||
| 64 | + return false; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public void logError(String message, Exception ex) { | ||
| 69 | + | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public void logWarning(String string) { | ||
| 74 | + | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 78 | + public void logInfo(String string) { | ||
| 79 | + | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public void disableLogging() { | ||
| 84 | + | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Override | ||
| 88 | + public void enableLogging() { | ||
| 89 | + | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public void setBuildTimeStamp(String buildTimeStamp) { | ||
| 94 | + | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + @Override | ||
| 98 | + public void setStackProperties(Properties stackProperties) { | ||
| 99 | + | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + @Override | ||
| 103 | + public String getLoggerName() { | ||
| 104 | + return null; | ||
| 105 | + } | ||
| 106 | +} |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
| @@ -28,7 +28,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | @@ -28,7 +28,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | ||
| 28 | 28 | ||
| 29 | private final static Logger logger = LoggerFactory.getLogger(SIPProcessorObserver.class); | 29 | private final static Logger logger = LoggerFactory.getLogger(SIPProcessorObserver.class); |
| 30 | 30 | ||
| 31 | - private static Map<String, ISIPRequestProcessor> requestProcessorMap = new ConcurrentHashMap<>(); | 31 | + private static Map<String, ISIPRequestProcessor> requestProcessorMap = new ConcurrentHashMap<>(); |
| 32 | private static Map<String, ISIPResponseProcessor> responseProcessorMap = new ConcurrentHashMap<>(); | 32 | private static Map<String, ISIPResponseProcessor> responseProcessorMap = new ConcurrentHashMap<>(); |
| 33 | private static ITimeoutProcessor timeoutProcessor; | 33 | private static ITimeoutProcessor timeoutProcessor; |
| 34 | 34 | ||
| @@ -72,6 +72,9 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | @@ -72,6 +72,9 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | ||
| 72 | @Async | 72 | @Async |
| 73 | public void processRequest(RequestEvent requestEvent) { | 73 | public void processRequest(RequestEvent requestEvent) { |
| 74 | String method = requestEvent.getRequest().getMethod(); | 74 | String method = requestEvent.getRequest().getMethod(); |
| 75 | + if ("NOTIFY".equalsIgnoreCase(requestEvent.getRequest().getMethod())) { | ||
| 76 | + System.out.println(); | ||
| 77 | + } | ||
| 75 | ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); | 78 | ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); |
| 76 | if (sipRequestProcessor == null) { | 79 | if (sipRequestProcessor == null) { |
| 77 | logger.warn("不支持方法{}的request", method); | 80 | logger.warn("不支持方法{}的request", method); |
| @@ -91,7 +94,8 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | @@ -91,7 +94,8 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | ||
| 91 | Response response = responseEvent.getResponse(); | 94 | Response response = responseEvent.getResponse(); |
| 92 | int status = response.getStatusCode(); | 95 | int status = response.getStatusCode(); |
| 93 | 96 | ||
| 94 | - if (((status >= 200) && (status < 300)) || status == Response.UNAUTHORIZED) { // Success! | 97 | + // Success |
| 98 | + if (((status >= Response.OK) && (status < Response.MULTIPLE_CHOICES)) || status == Response.UNAUTHORIZED) { | ||
| 95 | CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME); | 99 | CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME); |
| 96 | String method = cseqHeader.getMethod(); | 100 | String method = cseqHeader.getMethod(); |
| 97 | ISIPResponseProcessor sipRequestProcessor = responseProcessorMap.get(method); | 101 | ISIPResponseProcessor sipRequestProcessor = responseProcessorMap.get(method); |
| @@ -109,7 +113,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | @@ -109,7 +113,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | ||
| 109 | } | 113 | } |
| 110 | } | 114 | } |
| 111 | } | 115 | } |
| 112 | - } else if ((status >= 100) && (status < 200)) { | 116 | + } else if ((status >= Response.TRYING) && (status < Response.OK)) { |
| 113 | // 增加其它无需回复的响应,如101、180等 | 117 | // 增加其它无需回复的响应,如101、180等 |
| 114 | } else { | 118 | } else { |
| 115 | logger.warn("接收到失败的response响应!status:" + status + ",message:" + response.getReasonPhrase()); | 119 | logger.warn("接收到失败的response响应!status:" + status + ",message:" + response.getReasonPhrase()); |
| @@ -151,7 +155,9 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | @@ -151,7 +155,9 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { | ||
| 151 | logger.info("[发送错误订阅]"); | 155 | logger.info("[发送错误订阅]"); |
| 152 | SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()); | 156 | SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()); |
| 153 | SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(timeoutEvent); | 157 | SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(timeoutEvent); |
| 154 | - subscribe.response(eventResult); | 158 | + if (subscribe != null){ |
| 159 | + subscribe.response(eventResult); | ||
| 160 | + } | ||
| 155 | sipSubscribe.removeOkSubscribe(callIdHeader.getCallId()); | 161 | sipSubscribe.removeOkSubscribe(callIdHeader.getCallId()); |
| 156 | sipSubscribe.removeErrorSubscribe(callIdHeader.getCallId()); | 162 | sipSubscribe.removeErrorSubscribe(callIdHeader.getCallId()); |
| 157 | } | 163 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| @@ -146,12 +146,12 @@ public class SIPRequestHeaderPlarformProvider { | @@ -146,12 +146,12 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 146 | String cNonce = null; | 146 | String cNonce = null; |
| 147 | String nc = "00000001"; | 147 | String nc = "00000001"; |
| 148 | if (qop != null) { | 148 | if (qop != null) { |
| 149 | - if ("auth".equals(qop)) { | 149 | + if ("auth".equalsIgnoreCase(qop)) { |
| 150 | // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 | 150 | // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 |
| 151 | // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 | 151 | // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 |
| 152 | cNonce = UUID.randomUUID().toString(); | 152 | cNonce = UUID.randomUUID().toString(); |
| 153 | 153 | ||
| 154 | - }else if ("auth-int".equals(qop)){ | 154 | + }else if ("auth-int".equalsIgnoreCase(qop)){ |
| 155 | // TODO | 155 | // TODO |
| 156 | } | 156 | } |
| 157 | } | 157 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -249,7 +249,7 @@ public class SIPCommander implements ISIPCommander { | @@ -249,7 +249,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 249 | 249 | ||
| 250 | String tm = Long.toString(System.currentTimeMillis()); | 250 | String tm = Long.toString(System.currentTimeMillis()); |
| 251 | 251 | ||
| 252 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 252 | + CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 253 | : udpSipProvider.getNewCallId(); | 253 | : udpSipProvider.getNewCallId(); |
| 254 | 254 | ||
| 255 | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); | 255 | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); |
| @@ -292,7 +292,7 @@ public class SIPCommander implements ISIPCommander { | @@ -292,7 +292,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 292 | 292 | ||
| 293 | String tm = Long.toString(System.currentTimeMillis()); | 293 | String tm = Long.toString(System.currentTimeMillis()); |
| 294 | 294 | ||
| 295 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 295 | + CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 296 | : udpSipProvider.getNewCallId(); | 296 | : udpSipProvider.getNewCallId(); |
| 297 | 297 | ||
| 298 | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); | 298 | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); |
| @@ -328,7 +328,7 @@ public class SIPCommander implements ISIPCommander { | @@ -328,7 +328,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 328 | 328 | ||
| 329 | String tm = Long.toString(System.currentTimeMillis()); | 329 | String tm = Long.toString(System.currentTimeMillis()); |
| 330 | 330 | ||
| 331 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 331 | + CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 332 | : udpSipProvider.getNewCallId(); | 332 | : udpSipProvider.getNewCallId(); |
| 333 | 333 | ||
| 334 | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); | 334 | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "z9hG4bK-ViaPtz-" + tm, "FromPtz" + tm, null, callIdHeader); |
| @@ -355,7 +355,7 @@ public class SIPCommander implements ISIPCommander { | @@ -355,7 +355,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 355 | if (device == null) { | 355 | if (device == null) { |
| 356 | return; | 356 | return; |
| 357 | } | 357 | } |
| 358 | - String streamMode = device.getStreamMode().toUpperCase(); | 358 | +// String streamMode = device.getStreamMode().toUpperCase(); |
| 359 | 359 | ||
| 360 | logger.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); | 360 | logger.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); |
| 361 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtmp", mediaServerItem.getId()); | 361 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtmp", mediaServerItem.getId()); |
| @@ -374,11 +374,11 @@ public class SIPCommander implements ISIPCommander { | @@ -374,11 +374,11 @@ public class SIPCommander implements ISIPCommander { | ||
| 374 | content.append("t=0 0\r\n"); | 374 | content.append("t=0 0\r\n"); |
| 375 | 375 | ||
| 376 | if (userSetting.isSeniorSdp()) { | 376 | if (userSetting.isSeniorSdp()) { |
| 377 | - if("TCP-PASSIVE".equals(streamMode)) { | 377 | + if("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { |
| 378 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); | 378 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 379 | - }else if ("TCP-ACTIVE".equals(streamMode)) { | 379 | + }else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { |
| 380 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); | 380 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 381 | - }else if("UDP".equals(streamMode)) { | 381 | + }else if("UDP".equalsIgnoreCase(device.getStreamMode())) { |
| 382 | content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 126 125 99 34 98 97\r\n"); | 382 | content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 383 | } | 383 | } |
| 384 | content.append("a=recvonly\r\n"); | 384 | content.append("a=recvonly\r\n"); |
| @@ -390,19 +390,19 @@ public class SIPCommander implements ISIPCommander { | @@ -390,19 +390,19 @@ public class SIPCommander implements ISIPCommander { | ||
| 390 | content.append("a=rtpmap:99 H265/90000\r\n"); | 390 | content.append("a=rtpmap:99 H265/90000\r\n"); |
| 391 | content.append("a=rtpmap:98 H264/90000\r\n"); | 391 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 392 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); | 392 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 393 | - if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 | 393 | + if("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())){ // tcp被动模式 |
| 394 | content.append("a=setup:passive\r\n"); | 394 | content.append("a=setup:passive\r\n"); |
| 395 | content.append("a=connection:new\r\n"); | 395 | content.append("a=connection:new\r\n"); |
| 396 | - }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | 396 | + }else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp主动模式 |
| 397 | content.append("a=setup:active\r\n"); | 397 | content.append("a=setup:active\r\n"); |
| 398 | content.append("a=connection:new\r\n"); | 398 | content.append("a=connection:new\r\n"); |
| 399 | } | 399 | } |
| 400 | }else { | 400 | }else { |
| 401 | - if("TCP-PASSIVE".equals(streamMode)) { | 401 | + if("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { |
| 402 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); | 402 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); |
| 403 | - }else if ("TCP-ACTIVE".equals(streamMode)) { | 403 | + }else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { |
| 404 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); | 404 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); |
| 405 | - }else if("UDP".equals(streamMode)) { | 405 | + }else if("UDP".equalsIgnoreCase(device.getStreamMode())) { |
| 406 | content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 97 98 99\r\n"); | 406 | content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 97 98 99\r\n"); |
| 407 | } | 407 | } |
| 408 | content.append("a=recvonly\r\n"); | 408 | content.append("a=recvonly\r\n"); |
| @@ -410,10 +410,10 @@ public class SIPCommander implements ISIPCommander { | @@ -410,10 +410,10 @@ public class SIPCommander implements ISIPCommander { | ||
| 410 | content.append("a=rtpmap:98 H264/90000\r\n"); | 410 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 411 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); | 411 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 412 | content.append("a=rtpmap:99 H265/90000\r\n"); | 412 | content.append("a=rtpmap:99 H265/90000\r\n"); |
| 413 | - if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 | 413 | + if ("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp被动模式 |
| 414 | content.append("a=setup:passive\r\n"); | 414 | content.append("a=setup:passive\r\n"); |
| 415 | content.append("a=connection:new\r\n"); | 415 | content.append("a=connection:new\r\n"); |
| 416 | - } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | 416 | + } else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp主动模式 |
| 417 | content.append("a=setup:active\r\n"); | 417 | content.append("a=setup:active\r\n"); |
| 418 | content.append("a=connection:new\r\n"); | 418 | content.append("a=connection:new\r\n"); |
| 419 | } | 419 | } |
| @@ -425,7 +425,7 @@ public class SIPCommander implements ISIPCommander { | @@ -425,7 +425,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 425 | 425 | ||
| 426 | String tm = Long.toString(System.currentTimeMillis()); | 426 | String tm = Long.toString(System.currentTimeMillis()); |
| 427 | 427 | ||
| 428 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 428 | + CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 429 | : udpSipProvider.getNewCallId(); | 429 | : udpSipProvider.getNewCallId(); |
| 430 | 430 | ||
| 431 | Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "FromInvt" + tm, null, ssrcInfo.getSsrc(), callIdHeader); | 431 | Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "FromInvt" + tm, null, ssrcInfo.getSsrc(), callIdHeader); |
| @@ -472,14 +472,14 @@ public class SIPCommander implements ISIPCommander { | @@ -472,14 +472,14 @@ public class SIPCommander implements ISIPCommander { | ||
| 472 | content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" " | 472 | content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" " |
| 473 | +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n"); | 473 | +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n"); |
| 474 | 474 | ||
| 475 | - String streamMode = device.getStreamMode().toUpperCase(); | 475 | + String streamMode = device.getStreamMode(); |
| 476 | 476 | ||
| 477 | if (userSetting.isSeniorSdp()) { | 477 | if (userSetting.isSeniorSdp()) { |
| 478 | - if("TCP-PASSIVE".equals(streamMode)) { | 478 | + if("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { |
| 479 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); | 479 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 480 | - }else if ("TCP-ACTIVE".equals(streamMode)) { | 480 | + }else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { |
| 481 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); | 481 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 482 | - }else if("UDP".equals(streamMode)) { | 482 | + }else if("UDP".equalsIgnoreCase(streamMode)) { |
| 483 | content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 126 125 99 34 98 97\r\n"); | 483 | content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 484 | } | 484 | } |
| 485 | content.append("a=recvonly\r\n"); | 485 | content.append("a=recvonly\r\n"); |
| @@ -491,19 +491,19 @@ public class SIPCommander implements ISIPCommander { | @@ -491,19 +491,19 @@ public class SIPCommander implements ISIPCommander { | ||
| 491 | content.append("a=rtpmap:99 H265/90000\r\n"); | 491 | content.append("a=rtpmap:99 H265/90000\r\n"); |
| 492 | content.append("a=rtpmap:98 H264/90000\r\n"); | 492 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 493 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); | 493 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 494 | - if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 | 494 | + if("TCP-PASSIVE".equalsIgnoreCase(streamMode)){ // tcp被动模式 |
| 495 | content.append("a=setup:passive\r\n"); | 495 | content.append("a=setup:passive\r\n"); |
| 496 | content.append("a=connection:new\r\n"); | 496 | content.append("a=connection:new\r\n"); |
| 497 | - }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | 497 | + }else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式 |
| 498 | content.append("a=setup:active\r\n"); | 498 | content.append("a=setup:active\r\n"); |
| 499 | content.append("a=connection:new\r\n"); | 499 | content.append("a=connection:new\r\n"); |
| 500 | } | 500 | } |
| 501 | }else { | 501 | }else { |
| 502 | - if("TCP-PASSIVE".equals(streamMode)) { | 502 | + if("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { |
| 503 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); | 503 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); |
| 504 | - }else if ("TCP-ACTIVE".equals(streamMode)) { | 504 | + }else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { |
| 505 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); | 505 | content.append("m=video "+ ssrcInfo.getPort() +" TCP/RTP/AVP 96 97 98 99\r\n"); |
| 506 | - }else if("UDP".equals(streamMode)) { | 506 | + }else if("UDP".equalsIgnoreCase(streamMode)) { |
| 507 | content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 97 98 99\r\n"); | 507 | content.append("m=video "+ ssrcInfo.getPort() +" RTP/AVP 96 97 98 99\r\n"); |
| 508 | } | 508 | } |
| 509 | content.append("a=recvonly\r\n"); | 509 | content.append("a=recvonly\r\n"); |
| @@ -511,10 +511,10 @@ public class SIPCommander implements ISIPCommander { | @@ -511,10 +511,10 @@ public class SIPCommander implements ISIPCommander { | ||
| 511 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); | 511 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 512 | content.append("a=rtpmap:98 H264/90000\r\n"); | 512 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 513 | content.append("a=rtpmap:99 H265/90000\r\n"); | 513 | content.append("a=rtpmap:99 H265/90000\r\n"); |
| 514 | - if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 | 514 | + if("TCP-PASSIVE".equalsIgnoreCase(streamMode)){ // tcp被动模式 |
| 515 | content.append("a=setup:passive\r\n"); | 515 | content.append("a=setup:passive\r\n"); |
| 516 | content.append("a=connection:new\r\n"); | 516 | content.append("a=connection:new\r\n"); |
| 517 | - }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | 517 | + }else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式 |
| 518 | content.append("a=setup:active\r\n"); | 518 | content.append("a=setup:active\r\n"); |
| 519 | content.append("a=connection:new\r\n"); | 519 | content.append("a=connection:new\r\n"); |
| 520 | } | 520 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| @@ -93,10 +93,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -93,10 +93,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 93 | String tm = Long.toString(System.currentTimeMillis()); | 93 | String tm = Long.toString(System.currentTimeMillis()); |
| 94 | if (!registerAgain ) { | 94 | if (!registerAgain ) { |
| 95 | CallIdHeader callIdHeader = null; | 95 | CallIdHeader callIdHeader = null; |
| 96 | - if(parentPlatform.getTransport().equals("TCP")) { | 96 | + if(parentPlatform.getTransport().equalsIgnoreCase("TCP")) { |
| 97 | callIdHeader = tcpSipProvider.getNewCallId(); | 97 | callIdHeader = tcpSipProvider.getNewCallId(); |
| 98 | } | 98 | } |
| 99 | - if(parentPlatform.getTransport().equals("UDP")) { | 99 | + if(parentPlatform.getTransport().equalsIgnoreCase("UDP")) { |
| 100 | callIdHeader = udpSipProvider.getNewCallId(); | 100 | callIdHeader = udpSipProvider.getNewCallId(); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| @@ -120,7 +120,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -120,7 +120,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 120 | }); | 120 | }); |
| 121 | 121 | ||
| 122 | }else { | 122 | }else { |
| 123 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 123 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 124 | : udpSipProvider.getNewCallId(); | 124 | : udpSipProvider.getNewCallId(); |
| 125 | request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, "FromRegister" + tm, null, callId, www, callIdHeader, isRegister); | 125 | request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, "FromRegister" + tm, null, callId, www, callIdHeader, isRegister); |
| 126 | } | 126 | } |
| @@ -153,7 +153,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -153,7 +153,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 153 | keepaliveXml.append("<Status>OK</Status>\r\n"); | 153 | keepaliveXml.append("<Status>OK</Status>\r\n"); |
| 154 | keepaliveXml.append("</Notify>\r\n"); | 154 | keepaliveXml.append("</Notify>\r\n"); |
| 155 | 155 | ||
| 156 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 156 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 157 | : udpSipProvider.getNewCallId(); | 157 | : udpSipProvider.getNewCallId(); |
| 158 | 158 | ||
| 159 | Request request = headerProviderPlarformProvider.createKeetpaliveMessageRequest( | 159 | Request request = headerProviderPlarformProvider.createKeetpaliveMessageRequest( |
| @@ -181,10 +181,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -181,10 +181,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 181 | 181 | ||
| 182 | private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException { | 182 | private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException { |
| 183 | logger.debug("\n发送消息:\n{}", request); | 183 | logger.debug("\n发送消息:\n{}", request); |
| 184 | - if("TCP".equals(parentPlatform.getTransport())) { | 184 | + if("TCP".equalsIgnoreCase(parentPlatform.getTransport())) { |
| 185 | tcpSipProvider.sendRequest(request); | 185 | tcpSipProvider.sendRequest(request); |
| 186 | 186 | ||
| 187 | - } else if("UDP".equals(parentPlatform.getTransport())) { | 187 | + } else if("UDP".equalsIgnoreCase(parentPlatform.getTransport())) { |
| 188 | udpSipProvider.sendRequest(request); | 188 | udpSipProvider.sendRequest(request); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| @@ -220,7 +220,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -220,7 +220,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 220 | String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); | 220 | String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); |
| 221 | 221 | ||
| 222 | // callid | 222 | // callid |
| 223 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 223 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 224 | : udpSipProvider.getNewCallId(); | 224 | : udpSipProvider.getNewCallId(); |
| 225 | 225 | ||
| 226 | Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, callIdHeader); | 226 | Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, callIdHeader); |
| @@ -306,7 +306,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -306,7 +306,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 306 | } | 306 | } |
| 307 | String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); | 307 | String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); |
| 308 | // callid | 308 | // callid |
| 309 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 309 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 310 | : udpSipProvider.getNewCallId(); | 310 | : udpSipProvider.getNewCallId(); |
| 311 | 311 | ||
| 312 | Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, callIdHeader); | 312 | Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, callIdHeader); |
| @@ -346,7 +346,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -346,7 +346,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 346 | deviceInfoXml.append("<Result>OK</Result>\r\n"); | 346 | deviceInfoXml.append("<Result>OK</Result>\r\n"); |
| 347 | deviceInfoXml.append("</Response>\r\n"); | 347 | deviceInfoXml.append("</Response>\r\n"); |
| 348 | 348 | ||
| 349 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 349 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 350 | : udpSipProvider.getNewCallId(); | 350 | : udpSipProvider.getNewCallId(); |
| 351 | 351 | ||
| 352 | Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, callIdHeader); | 352 | Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, callIdHeader); |
| @@ -384,7 +384,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -384,7 +384,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 384 | deviceStatusXml.append("<Status>OK</Status>\r\n"); | 384 | deviceStatusXml.append("<Status>OK</Status>\r\n"); |
| 385 | deviceStatusXml.append("</Response>\r\n"); | 385 | deviceStatusXml.append("</Response>\r\n"); |
| 386 | 386 | ||
| 387 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 387 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 388 | : udpSipProvider.getNewCallId(); | 388 | : udpSipProvider.getNewCallId(); |
| 389 | 389 | ||
| 390 | Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, callIdHeader); | 390 | Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, callIdHeader); |
| @@ -422,7 +422,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -422,7 +422,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 422 | deviceStatusXml.append("<Altitude>" + gpsMsgInfo.getAltitude() + "</Altitude>\r\n"); | 422 | deviceStatusXml.append("<Altitude>" + gpsMsgInfo.getAltitude() + "</Altitude>\r\n"); |
| 423 | deviceStatusXml.append("</Notify>\r\n"); | 423 | deviceStatusXml.append("</Notify>\r\n"); |
| 424 | 424 | ||
| 425 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 425 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 426 | : udpSipProvider.getNewCallId(); | 426 | : udpSipProvider.getNewCallId(); |
| 427 | callIdHeader.setCallId(subscribeInfo.getCallId()); | 427 | callIdHeader.setCallId(subscribeInfo.getCallId()); |
| 428 | 428 | ||
| @@ -467,7 +467,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -467,7 +467,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 467 | deviceStatusXml.append("</info>\r\n"); | 467 | deviceStatusXml.append("</info>\r\n"); |
| 468 | deviceStatusXml.append("</Notify>\r\n"); | 468 | deviceStatusXml.append("</Notify>\r\n"); |
| 469 | 469 | ||
| 470 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 470 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| 471 | : udpSipProvider.getNewCallId(); | 471 | : udpSipProvider.getNewCallId(); |
| 472 | 472 | ||
| 473 | String tm = Long.toString(System.currentTimeMillis()); | 473 | String tm = Long.toString(System.currentTimeMillis()); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
| @@ -139,7 +139,7 @@ public abstract class SIPRequestProcessorParent { | @@ -139,7 +139,7 @@ public abstract class SIPRequestProcessorParent { | ||
| 139 | return; | 139 | return; |
| 140 | } | 140 | } |
| 141 | serverTransaction.sendResponse(response); | 141 | serverTransaction.sendResponse(response); |
| 142 | - if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) { | 142 | + if (statusCode >= 200 && !"NOTIFY".equalsIgnoreCase(evt.getRequest().getMethod())) { |
| 143 | 143 | ||
| 144 | if (serverTransaction.getDialog() != null) { | 144 | if (serverTransaction.getDialog() != null) { |
| 145 | serverTransaction.getDialog().delete(); | 145 | serverTransaction.getDialog().delete(); |
| @@ -152,7 +152,7 @@ public abstract class SIPRequestProcessorParent { | @@ -152,7 +152,7 @@ public abstract class SIPRequestProcessorParent { | ||
| 152 | response.setReasonPhrase(msg); | 152 | response.setReasonPhrase(msg); |
| 153 | ServerTransaction serverTransaction = getServerTransaction(evt); | 153 | ServerTransaction serverTransaction = getServerTransaction(evt); |
| 154 | serverTransaction.sendResponse(response); | 154 | serverTransaction.sendResponse(response); |
| 155 | - if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) { | 155 | + if (statusCode >= 200 && !"NOTIFY".equalsIgnoreCase(evt.getRequest().getMethod())) { |
| 156 | if (serverTransaction.getDialog() != null) { | 156 | if (serverTransaction.getDialog() != null) { |
| 157 | serverTransaction.getDialog().delete(); | 157 | serverTransaction.getDialog().delete(); |
| 158 | } | 158 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| @@ -278,16 +278,16 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -278,16 +278,16 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 278 | String protocol = media.getProtocol(); | 278 | String protocol = media.getProtocol(); |
| 279 | 279 | ||
| 280 | // 区分TCP发流还是udp, 当前默认udp | 280 | // 区分TCP发流还是udp, 当前默认udp |
| 281 | - if ("TCP/RTP/AVP".equals(protocol)) { | 281 | + if ("TCP/RTP/AVP".equalsIgnoreCase(protocol)) { |
| 282 | String setup = mediaDescription.getAttribute("setup"); | 282 | String setup = mediaDescription.getAttribute("setup"); |
| 283 | if (setup != null) { | 283 | if (setup != null) { |
| 284 | mediaTransmissionTCP = true; | 284 | mediaTransmissionTCP = true; |
| 285 | - if ("active".equals(setup)) { | 285 | + if ("active".equalsIgnoreCase(setup)) { |
| 286 | tcpActive = true; | 286 | tcpActive = true; |
| 287 | // 不支持tcp主动 | 287 | // 不支持tcp主动 |
| 288 | responseAck(evt, Response.NOT_IMPLEMENTED, "tcp active not support"); // 目录不支持点播 | 288 | responseAck(evt, Response.NOT_IMPLEMENTED, "tcp active not support"); // 目录不支持点播 |
| 289 | return; | 289 | return; |
| 290 | - } else if ("passive".equals(setup)) { | 290 | + } else if ("passive".equalsIgnoreCase(setup)) { |
| 291 | tcpActive = false; | 291 | tcpActive = false; |
| 292 | } | 292 | } |
| 293 | } | 293 | } |
| @@ -332,7 +332,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -332,7 +332,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 332 | return; | 332 | return; |
| 333 | } | 333 | } |
| 334 | sendRtpItem.setCallId(callIdHeader.getCallId()); | 334 | sendRtpItem.setCallId(callIdHeader.getCallId()); |
| 335 | - sendRtpItem.setPlayType("Play".equals(sessionName) ? InviteStreamType.PLAY : InviteStreamType.PLAYBACK); | 335 | + sendRtpItem.setPlayType("Play".equalsIgnoreCase(sessionName) ? InviteStreamType.PLAY : InviteStreamType.PLAYBACK); |
| 336 | 336 | ||
| 337 | Long finalStartTime = startTime; | 337 | Long finalStartTime = startTime; |
| 338 | Long finalStopTime = stopTime; | 338 | Long finalStopTime = stopTime; |
| @@ -351,7 +351,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -351,7 +351,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 351 | content.append("o=" + channelId + " 0 0 IN IP4 " + mediaServerItemInUSe.getSdpIp() + "\r\n"); | 351 | content.append("o=" + channelId + " 0 0 IN IP4 " + mediaServerItemInUSe.getSdpIp() + "\r\n"); |
| 352 | content.append("s=" + sessionName + "\r\n"); | 352 | content.append("s=" + sessionName + "\r\n"); |
| 353 | content.append("c=IN IP4 " + mediaServerItemInUSe.getSdpIp() + "\r\n"); | 353 | content.append("c=IN IP4 " + mediaServerItemInUSe.getSdpIp() + "\r\n"); |
| 354 | - if ("Playback".equals(sessionName)) { | 354 | + if ("Playback".equalsIgnoreCase(sessionName)) { |
| 355 | content.append("t=" + finalStartTime + " " + finalStopTime + "\r\n"); | 355 | content.append("t=" + finalStartTime + " " + finalStopTime + "\r\n"); |
| 356 | } else { | 356 | } else { |
| 357 | content.append("t=0 0\r\n"); | 357 | content.append("t=0 0\r\n"); |
| @@ -395,7 +395,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -395,7 +395,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 395 | } | 395 | } |
| 396 | }); | 396 | }); |
| 397 | sendRtpItem.setApp("rtp"); | 397 | sendRtpItem.setApp("rtp"); |
| 398 | - if ("Playback".equals(sessionName)) { | 398 | + if ("Playback".equalsIgnoreCase(sessionName)) { |
| 399 | sendRtpItem.setPlayType(InviteStreamType.PLAYBACK); | 399 | sendRtpItem.setPlayType(InviteStreamType.PLAYBACK); |
| 400 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, true, true); | 400 | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, true, true); |
| 401 | sendRtpItem.setStreamId(ssrcInfo.getStream()); | 401 | sendRtpItem.setStreamId(ssrcInfo.getStream()); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
| @@ -159,7 +159,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen | @@ -159,7 +159,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen | ||
| 159 | // 判断TCP还是UDP | 159 | // 判断TCP还是UDP |
| 160 | ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); | 160 | ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); |
| 161 | String transport = reqViaHeader.getTransport(); | 161 | String transport = reqViaHeader.getTransport(); |
| 162 | - device.setTransport("TCP".equals(transport) ? "TCP" : "UDP"); | 162 | + device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP"); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | sendResponse(evt, response); | 165 | sendResponse(evt, response); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java
| @@ -132,7 +132,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -132,7 +132,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 132 | return; | 132 | return; |
| 133 | } | 133 | } |
| 134 | if (evt.getServerTransaction() == null) { | 134 | if (evt.getServerTransaction() == null) { |
| 135 | - ServerTransaction serverTransaction = "TCP".equals(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) | 135 | + ServerTransaction serverTransaction = "TCP".equalsIgnoreCase(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) |
| 136 | : udpSipProvider.getNewServerTransaction(evt.getRequest()); | 136 | : udpSipProvider.getNewServerTransaction(evt.getRequest()); |
| 137 | subscribeInfo.setTransaction(serverTransaction); | 137 | subscribeInfo.setTransaction(serverTransaction); |
| 138 | Dialog dialog = serverTransaction.getDialog(); | 138 | Dialog dialog = serverTransaction.getDialog(); |
| @@ -188,7 +188,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | @@ -188,7 +188,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme | ||
| 188 | } | 188 | } |
| 189 | SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); | 189 | SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); |
| 190 | if (evt.getServerTransaction() == null) { | 190 | if (evt.getServerTransaction() == null) { |
| 191 | - ServerTransaction serverTransaction = "TCP".equals(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) | 191 | + ServerTransaction serverTransaction = "TCP".equalsIgnoreCase(platform.getTransport()) ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) |
| 192 | : udpSipProvider.getNewServerTransaction(evt.getRequest()); | 192 | : udpSipProvider.getNewServerTransaction(evt.getRequest()); |
| 193 | subscribeInfo.setTransaction(serverTransaction); | 193 | subscribeInfo.setTransaction(serverTransaction); |
| 194 | Dialog dialog = serverTransaction.getDialog(); | 194 | Dialog dialog = serverTransaction.getDialog(); |
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 | @@ -96,7 +96,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I | ||
| 96 | ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME); | 96 | ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME); |
| 97 | String contentType = header.getContentType(); | 97 | String contentType = header.getContentType(); |
| 98 | String contentSubType = header.getContentSubType(); | 98 | String contentSubType = header.getContentSubType(); |
| 99 | - if ("Application".equals(contentType) && "MANSRTSP".equals(contentSubType)) { | 99 | + if ("Application".equalsIgnoreCase(contentType) && "MANSRTSP".equalsIgnoreCase(contentSubType)) { |
| 100 | SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId()); | 100 | SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId()); |
| 101 | String streamId = sendRtpItem.getStreamId(); | 101 | String streamId = sendRtpItem.getStreamId(); |
| 102 | StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); | 102 | StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); |
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 | @@ -76,7 +76,7 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen | ||
| 76 | logger.debug(json.toJSONString()); | 76 | logger.debug(json.toJSONString()); |
| 77 | } | 77 | } |
| 78 | String text = onlineElement.getText(); | 78 | String text = onlineElement.getText(); |
| 79 | - if (Objects.equals(text.trim().toUpperCase(), "ONLINE")) { | 79 | + if ("ONLINE".equalsIgnoreCase(text.trim())) { |
| 80 | deviceService.online(device); | 80 | deviceService.online(device); |
| 81 | }else { | 81 | }else { |
| 82 | deviceService.offline(device.getDeviceId()); | 82 | deviceService.offline(device.getDeviceId()); |
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 | @@ -77,7 +77,7 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent | ||
| 77 | Element itemOne = itemListIterator.next(); | 77 | Element itemOne = itemListIterator.next(); |
| 78 | String name = itemOne.getName(); | 78 | String name = itemOne.getName(); |
| 79 | String textTrim = itemOne.getTextTrim(); | 79 | String textTrim = itemOne.getTextTrim(); |
| 80 | - if("PresetID".equals(name)){ | 80 | + if("PresetID".equalsIgnoreCase(name)){ |
| 81 | presetQuerySipReq.setPresetId(textTrim); | 81 | presetQuerySipReq.setPresetId(textTrim); |
| 82 | }else { | 82 | }else { |
| 83 | presetQuerySipReq.setPresetName(textTrim); | 83 | presetQuerySipReq.setPresetName(textTrim); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -103,7 +103,7 @@ public class ZLMHttpHookListener { | @@ -103,7 +103,7 @@ public class ZLMHttpHookListener { | ||
| 103 | */ | 103 | */ |
| 104 | @ResponseBody | 104 | @ResponseBody |
| 105 | @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8") | 105 | @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8") |
| 106 | - public ResponseEntity<String> onServerKeepalive(@RequestBody JSONObject json){ | 106 | + public JSONObject onServerKeepalive(@RequestBody JSONObject json){ |
| 107 | 107 | ||
| 108 | logger.info("[ ZLM HOOK ] on_server_keepalive API调用,参数:" + json.toString()); | 108 | logger.info("[ ZLM HOOK ] on_server_keepalive API调用,参数:" + json.toString()); |
| 109 | String mediaServerId = json.getString("mediaServerId"); | 109 | String mediaServerId = json.getString("mediaServerId"); |
| @@ -118,7 +118,8 @@ public class ZLMHttpHookListener { | @@ -118,7 +118,8 @@ public class ZLMHttpHookListener { | ||
| 118 | JSONObject ret = new JSONObject(); | 118 | JSONObject ret = new JSONObject(); |
| 119 | ret.put("code", 0); | 119 | ret.put("code", 0); |
| 120 | ret.put("msg", "success"); | 120 | ret.put("msg", "success"); |
| 121 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 121 | + |
| 122 | + return ret; | ||
| 122 | } | 123 | } |
| 123 | 124 | ||
| 124 | /** | 125 | /** |
| @@ -127,16 +128,15 @@ public class ZLMHttpHookListener { | @@ -127,16 +128,15 @@ public class ZLMHttpHookListener { | ||
| 127 | */ | 128 | */ |
| 128 | @ResponseBody | 129 | @ResponseBody |
| 129 | @PostMapping(value = "/on_flow_report", produces = "application/json;charset=UTF-8") | 130 | @PostMapping(value = "/on_flow_report", produces = "application/json;charset=UTF-8") |
| 130 | - public ResponseEntity<String> onFlowReport(@RequestBody JSONObject json){ | 131 | + public JSONObject onFlowReport(@RequestBody JSONObject json){ |
| 131 | 132 | ||
| 132 | if (logger.isDebugEnabled()) { | 133 | if (logger.isDebugEnabled()) { |
| 133 | logger.debug("[ ZLM HOOK ]on_flow_report API调用,参数:" + json.toString()); | 134 | logger.debug("[ ZLM HOOK ]on_flow_report API调用,参数:" + json.toString()); |
| 134 | } | 135 | } |
| 135 | - String mediaServerId = json.getString("mediaServerId"); | ||
| 136 | JSONObject ret = new JSONObject(); | 136 | JSONObject ret = new JSONObject(); |
| 137 | ret.put("code", 0); | 137 | ret.put("code", 0); |
| 138 | ret.put("msg", "success"); | 138 | ret.put("msg", "success"); |
| 139 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 139 | + return ret; |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /** | 142 | /** |
| @@ -145,7 +145,7 @@ public class ZLMHttpHookListener { | @@ -145,7 +145,7 @@ public class ZLMHttpHookListener { | ||
| 145 | */ | 145 | */ |
| 146 | @ResponseBody | 146 | @ResponseBody |
| 147 | @PostMapping(value = "/on_http_access", produces = "application/json;charset=UTF-8") | 147 | @PostMapping(value = "/on_http_access", produces = "application/json;charset=UTF-8") |
| 148 | - public ResponseEntity<String> onHttpAccess(@RequestBody JSONObject json){ | 148 | + public JSONObject onHttpAccess(@RequestBody JSONObject json){ |
| 149 | 149 | ||
| 150 | if (logger.isDebugEnabled()) { | 150 | if (logger.isDebugEnabled()) { |
| 151 | logger.debug("[ ZLM HOOK ]on_http_access API 调用,参数:" + json.toString()); | 151 | logger.debug("[ ZLM HOOK ]on_http_access API 调用,参数:" + json.toString()); |
| @@ -156,7 +156,7 @@ public class ZLMHttpHookListener { | @@ -156,7 +156,7 @@ public class ZLMHttpHookListener { | ||
| 156 | ret.put("err", ""); | 156 | ret.put("err", ""); |
| 157 | ret.put("path", ""); | 157 | ret.put("path", ""); |
| 158 | ret.put("second", 600); | 158 | ret.put("second", 600); |
| 159 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 159 | + return ret; |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | /** | 162 | /** |
| @@ -165,7 +165,7 @@ public class ZLMHttpHookListener { | @@ -165,7 +165,7 @@ public class ZLMHttpHookListener { | ||
| 165 | */ | 165 | */ |
| 166 | @ResponseBody | 166 | @ResponseBody |
| 167 | @PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8") | 167 | @PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8") |
| 168 | - public ResponseEntity<String> onPlay(@RequestBody OnPlayHookParam param){ | 168 | + public JSONObject onPlay(@RequestBody OnPlayHookParam param){ |
| 169 | 169 | ||
| 170 | JSONObject json = (JSONObject)JSON.toJSON(param); | 170 | JSONObject json = (JSONObject)JSON.toJSON(param); |
| 171 | 171 | ||
| @@ -184,17 +184,16 @@ public class ZLMHttpHookListener { | @@ -184,17 +184,16 @@ public class ZLMHttpHookListener { | ||
| 184 | if (!"rtp".equals(param.getApp())) { | 184 | if (!"rtp".equals(param.getApp())) { |
| 185 | Map<String, String> paramMap = urlParamToMap(param.getParams()); | 185 | Map<String, String> paramMap = urlParamToMap(param.getParams()); |
| 186 | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); | 186 | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); |
| 187 | - if (streamAuthorityInfo == null | ||
| 188 | - || (streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId")))) { | 187 | + if (streamAuthorityInfo != null && streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId"))) { |
| 189 | ret.put("code", 401); | 188 | ret.put("code", 401); |
| 190 | ret.put("msg", "Unauthorized"); | 189 | ret.put("msg", "Unauthorized"); |
| 191 | - return new ResponseEntity<>(ret.toString(),HttpStatus.OK); | 190 | + return ret; |
| 192 | } | 191 | } |
| 193 | } | 192 | } |
| 194 | 193 | ||
| 195 | ret.put("code", 0); | 194 | ret.put("code", 0); |
| 196 | ret.put("msg", "success"); | 195 | ret.put("msg", "success"); |
| 197 | - return new ResponseEntity<>(ret.toString(),HttpStatus.OK); | 196 | + return ret; |
| 198 | } | 197 | } |
| 199 | 198 | ||
| 200 | /** | 199 | /** |
| @@ -203,7 +202,7 @@ public class ZLMHttpHookListener { | @@ -203,7 +202,7 @@ public class ZLMHttpHookListener { | ||
| 203 | */ | 202 | */ |
| 204 | @ResponseBody | 203 | @ResponseBody |
| 205 | @PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8") | 204 | @PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8") |
| 206 | - public ResponseEntity<String> onPublish(@RequestBody OnPublishHookParam param) { | 205 | + public JSONObject onPublish(@RequestBody OnPublishHookParam param) { |
| 207 | 206 | ||
| 208 | JSONObject json = (JSONObject) JSON.toJSON(param); | 207 | JSONObject json = (JSONObject) JSON.toJSON(param); |
| 209 | 208 | ||
| @@ -217,7 +216,7 @@ public class ZLMHttpHookListener { | @@ -217,7 +216,7 @@ public class ZLMHttpHookListener { | ||
| 217 | logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); | 216 | logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); |
| 218 | ret.put("code", 401); | 217 | ret.put("code", 401); |
| 219 | ret.put("msg", "Unauthorized"); | 218 | ret.put("msg", "Unauthorized"); |
| 220 | - return new ResponseEntity<>(ret.toString(), HttpStatus.OK); | 219 | + return ret; |
| 221 | } | 220 | } |
| 222 | Map<String, String> paramMap = urlParamToMap(param.getParams()); | 221 | Map<String, String> paramMap = urlParamToMap(param.getParams()); |
| 223 | String sign = paramMap.get("sign"); | 222 | String sign = paramMap.get("sign"); |
| @@ -225,7 +224,7 @@ public class ZLMHttpHookListener { | @@ -225,7 +224,7 @@ public class ZLMHttpHookListener { | ||
| 225 | logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); | 224 | logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)"); |
| 226 | ret.put("code", 401); | 225 | ret.put("code", 401); |
| 227 | ret.put("msg", "Unauthorized"); | 226 | ret.put("msg", "Unauthorized"); |
| 228 | - return new ResponseEntity<>(ret.toString(), HttpStatus.OK); | 227 | + return ret; |
| 229 | } | 228 | } |
| 230 | // 推流自定义播放鉴权码 | 229 | // 推流自定义播放鉴权码 |
| 231 | String callId = paramMap.get("callId"); | 230 | String callId = paramMap.get("callId"); |
| @@ -235,7 +234,7 @@ public class ZLMHttpHookListener { | @@ -235,7 +234,7 @@ public class ZLMHttpHookListener { | ||
| 235 | logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign); | 234 | logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign); |
| 236 | ret.put("code", 401); | 235 | ret.put("code", 401); |
| 237 | ret.put("msg", "Unauthorized"); | 236 | ret.put("msg", "Unauthorized"); |
| 238 | - return new ResponseEntity<>(ret.toString(), HttpStatus.OK); | 237 | + return ret; |
| 239 | } | 238 | } |
| 240 | StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); | 239 | StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); |
| 241 | streamAuthorityInfo.setCallId(callId); | 240 | streamAuthorityInfo.setCallId(callId); |
| @@ -243,11 +242,11 @@ public class ZLMHttpHookListener { | @@ -243,11 +242,11 @@ public class ZLMHttpHookListener { | ||
| 243 | // 鉴权通过 | 242 | // 鉴权通过 |
| 244 | redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); | 243 | redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); |
| 245 | // 通知assist新的callId | 244 | // 通知assist新的callId |
| 246 | - taskExecutor.execute(()->{ | ||
| 247 | - if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) { | 245 | + if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) { |
| 246 | + taskExecutor.execute(()->{ | ||
| 248 | assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null); | 247 | assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null); |
| 249 | - } | ||
| 250 | - }); | 248 | + }); |
| 249 | + } | ||
| 251 | }else { | 250 | }else { |
| 252 | zlmMediaListManager.sendStreamEvent(param.getApp(),param.getStream(), param.getMediaServerId()); | 251 | zlmMediaListManager.sendStreamEvent(param.getApp(),param.getStream(), param.getMediaServerId()); |
| 253 | } | 252 | } |
| @@ -291,10 +290,7 @@ public class ZLMHttpHookListener { | @@ -291,10 +290,7 @@ public class ZLMHttpHookListener { | ||
| 291 | 290 | ||
| 292 | } | 291 | } |
| 293 | } | 292 | } |
| 294 | - | ||
| 295 | - | ||
| 296 | - | ||
| 297 | - return new ResponseEntity<String>(ret.toString(), HttpStatus.OK); | 293 | + return ret; |
| 298 | } | 294 | } |
| 299 | 295 | ||
| 300 | 296 | ||
| @@ -305,7 +301,7 @@ public class ZLMHttpHookListener { | @@ -305,7 +301,7 @@ public class ZLMHttpHookListener { | ||
| 305 | */ | 301 | */ |
| 306 | @ResponseBody | 302 | @ResponseBody |
| 307 | @PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8") | 303 | @PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8") |
| 308 | - public ResponseEntity<String> onRecordMp4(@RequestBody JSONObject json){ | 304 | + public JSONObject onRecordMp4(@RequestBody JSONObject json){ |
| 309 | 305 | ||
| 310 | if (logger.isDebugEnabled()) { | 306 | if (logger.isDebugEnabled()) { |
| 311 | logger.debug("[ ZLM HOOK ]on_record_mp4 API调用,参数:" + json.toString()); | 307 | logger.debug("[ ZLM HOOK ]on_record_mp4 API调用,参数:" + json.toString()); |
| @@ -314,7 +310,7 @@ public class ZLMHttpHookListener { | @@ -314,7 +310,7 @@ public class ZLMHttpHookListener { | ||
| 314 | JSONObject ret = new JSONObject(); | 310 | JSONObject ret = new JSONObject(); |
| 315 | ret.put("code", 0); | 311 | ret.put("code", 0); |
| 316 | ret.put("msg", "success"); | 312 | ret.put("msg", "success"); |
| 317 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 313 | + return ret; |
| 318 | } | 314 | } |
| 319 | /** | 315 | /** |
| 320 | * 录制hls完成后通知事件;此事件对回复不敏感。 | 316 | * 录制hls完成后通知事件;此事件对回复不敏感。 |
| @@ -322,7 +318,7 @@ public class ZLMHttpHookListener { | @@ -322,7 +318,7 @@ public class ZLMHttpHookListener { | ||
| 322 | */ | 318 | */ |
| 323 | @ResponseBody | 319 | @ResponseBody |
| 324 | @PostMapping(value = "/on_record_ts", produces = "application/json;charset=UTF-8") | 320 | @PostMapping(value = "/on_record_ts", produces = "application/json;charset=UTF-8") |
| 325 | - public ResponseEntity<String> onRecordTs(@RequestBody JSONObject json){ | 321 | + public JSONObject onRecordTs(@RequestBody JSONObject json){ |
| 326 | 322 | ||
| 327 | if (logger.isDebugEnabled()) { | 323 | if (logger.isDebugEnabled()) { |
| 328 | logger.debug("[ ZLM HOOK ]on_record_ts API调用,参数:" + json.toString()); | 324 | logger.debug("[ ZLM HOOK ]on_record_ts API调用,参数:" + json.toString()); |
| @@ -331,7 +327,7 @@ public class ZLMHttpHookListener { | @@ -331,7 +327,7 @@ public class ZLMHttpHookListener { | ||
| 331 | JSONObject ret = new JSONObject(); | 327 | JSONObject ret = new JSONObject(); |
| 332 | ret.put("code", 0); | 328 | ret.put("code", 0); |
| 333 | ret.put("msg", "success"); | 329 | ret.put("msg", "success"); |
| 334 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 330 | + return ret; |
| 335 | } | 331 | } |
| 336 | 332 | ||
| 337 | /** | 333 | /** |
| @@ -340,7 +336,7 @@ public class ZLMHttpHookListener { | @@ -340,7 +336,7 @@ public class ZLMHttpHookListener { | ||
| 340 | */ | 336 | */ |
| 341 | @ResponseBody | 337 | @ResponseBody |
| 342 | @PostMapping(value = "/on_rtsp_realm", produces = "application/json;charset=UTF-8") | 338 | @PostMapping(value = "/on_rtsp_realm", produces = "application/json;charset=UTF-8") |
| 343 | - public ResponseEntity<String> onRtspRealm(@RequestBody JSONObject json){ | 339 | + public JSONObject onRtspRealm(@RequestBody JSONObject json){ |
| 344 | 340 | ||
| 345 | if (logger.isDebugEnabled()) { | 341 | if (logger.isDebugEnabled()) { |
| 346 | logger.debug("[ ZLM HOOK ]on_rtsp_realm API调用,参数:" + json.toString()); | 342 | logger.debug("[ ZLM HOOK ]on_rtsp_realm API调用,参数:" + json.toString()); |
| @@ -349,7 +345,7 @@ public class ZLMHttpHookListener { | @@ -349,7 +345,7 @@ public class ZLMHttpHookListener { | ||
| 349 | JSONObject ret = new JSONObject(); | 345 | JSONObject ret = new JSONObject(); |
| 350 | ret.put("code", 0); | 346 | ret.put("code", 0); |
| 351 | ret.put("realm", ""); | 347 | ret.put("realm", ""); |
| 352 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 348 | + return ret; |
| 353 | } | 349 | } |
| 354 | 350 | ||
| 355 | 351 | ||
| @@ -359,7 +355,7 @@ public class ZLMHttpHookListener { | @@ -359,7 +355,7 @@ public class ZLMHttpHookListener { | ||
| 359 | */ | 355 | */ |
| 360 | @ResponseBody | 356 | @ResponseBody |
| 361 | @PostMapping(value = "/on_rtsp_auth", produces = "application/json;charset=UTF-8") | 357 | @PostMapping(value = "/on_rtsp_auth", produces = "application/json;charset=UTF-8") |
| 362 | - public ResponseEntity<String> onRtspAuth(@RequestBody JSONObject json){ | 358 | + public JSONObject onRtspAuth(@RequestBody JSONObject json){ |
| 363 | 359 | ||
| 364 | if (logger.isDebugEnabled()) { | 360 | if (logger.isDebugEnabled()) { |
| 365 | logger.debug("[ ZLM HOOK ]on_rtsp_auth API调用,参数:" + json.toString()); | 361 | logger.debug("[ ZLM HOOK ]on_rtsp_auth API调用,参数:" + json.toString()); |
| @@ -369,7 +365,7 @@ public class ZLMHttpHookListener { | @@ -369,7 +365,7 @@ public class ZLMHttpHookListener { | ||
| 369 | ret.put("code", 0); | 365 | ret.put("code", 0); |
| 370 | ret.put("encrypted", false); | 366 | ret.put("encrypted", false); |
| 371 | ret.put("passwd", "test"); | 367 | ret.put("passwd", "test"); |
| 372 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 368 | + return ret; |
| 373 | } | 369 | } |
| 374 | 370 | ||
| 375 | /** | 371 | /** |
| @@ -378,7 +374,7 @@ public class ZLMHttpHookListener { | @@ -378,7 +374,7 @@ public class ZLMHttpHookListener { | ||
| 378 | */ | 374 | */ |
| 379 | @ResponseBody | 375 | @ResponseBody |
| 380 | @PostMapping(value = "/on_shell_login", produces = "application/json;charset=UTF-8") | 376 | @PostMapping(value = "/on_shell_login", produces = "application/json;charset=UTF-8") |
| 381 | - public ResponseEntity<String> onShellLogin(@RequestBody JSONObject json){ | 377 | + public JSONObject onShellLogin(@RequestBody JSONObject json){ |
| 382 | 378 | ||
| 383 | if (logger.isDebugEnabled()) { | 379 | if (logger.isDebugEnabled()) { |
| 384 | logger.debug("[ ZLM HOOK ]on_shell_login API调用,参数:" + json.toString()); | 380 | logger.debug("[ ZLM HOOK ]on_shell_login API调用,参数:" + json.toString()); |
| @@ -396,7 +392,7 @@ public class ZLMHttpHookListener { | @@ -396,7 +392,7 @@ public class ZLMHttpHookListener { | ||
| 396 | JSONObject ret = new JSONObject(); | 392 | JSONObject ret = new JSONObject(); |
| 397 | ret.put("code", 0); | 393 | ret.put("code", 0); |
| 398 | ret.put("msg", "success"); | 394 | ret.put("msg", "success"); |
| 399 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 395 | + return ret; |
| 400 | } | 396 | } |
| 401 | 397 | ||
| 402 | /** | 398 | /** |
| @@ -405,7 +401,7 @@ public class ZLMHttpHookListener { | @@ -405,7 +401,7 @@ public class ZLMHttpHookListener { | ||
| 405 | */ | 401 | */ |
| 406 | @ResponseBody | 402 | @ResponseBody |
| 407 | @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8") | 403 | @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8") |
| 408 | - public ResponseEntity<String> onStreamChanged(@RequestBody MediaItem item){ | 404 | + public JSONObject onStreamChanged(@RequestBody MediaItem item){ |
| 409 | 405 | ||
| 410 | logger.info("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item)); | 406 | logger.info("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item)); |
| 411 | String mediaServerId = item.getMediaServerId(); | 407 | String mediaServerId = item.getMediaServerId(); |
| @@ -475,8 +471,12 @@ public class ZLMHttpHookListener { | @@ -475,8 +471,12 @@ public class ZLMHttpHookListener { | ||
| 475 | if (mediaServerItem != null){ | 471 | if (mediaServerItem != null){ |
| 476 | if (regist) { | 472 | if (regist) { |
| 477 | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); | 473 | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); |
| 474 | + String callId = null; | ||
| 475 | + if (streamAuthorityInfo != null) { | ||
| 476 | + callId = streamAuthorityInfo.getCallId(); | ||
| 477 | + } | ||
| 478 | StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, | 478 | StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, |
| 479 | - app, stream, tracks, streamAuthorityInfo.getCallId()); | 479 | + app, stream, tracks, callId); |
| 480 | item.setStreamInfo(streamInfoByAppAndStream); | 480 | item.setStreamInfo(streamInfoByAppAndStream); |
| 481 | redisCatchStorage.addStream(mediaServerItem, type, app, stream, item); | 481 | redisCatchStorage.addStream(mediaServerItem, type, app, stream, item); |
| 482 | if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() | 482 | if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() |
| @@ -516,7 +516,7 @@ public class ZLMHttpHookListener { | @@ -516,7 +516,7 @@ public class ZLMHttpHookListener { | ||
| 516 | JSONObject ret = new JSONObject(); | 516 | JSONObject ret = new JSONObject(); |
| 517 | ret.put("code", 0); | 517 | ret.put("code", 0); |
| 518 | ret.put("msg", "success"); | 518 | ret.put("msg", "success"); |
| 519 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 519 | + return ret; |
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | /** | 522 | /** |
| @@ -525,7 +525,7 @@ public class ZLMHttpHookListener { | @@ -525,7 +525,7 @@ public class ZLMHttpHookListener { | ||
| 525 | */ | 525 | */ |
| 526 | @ResponseBody | 526 | @ResponseBody |
| 527 | @PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8") | 527 | @PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8") |
| 528 | - public ResponseEntity<String> onStreamNoneReader(@RequestBody JSONObject json){ | 528 | + public JSONObject onStreamNoneReader(@RequestBody JSONObject json){ |
| 529 | 529 | ||
| 530 | logger.info("[ ZLM HOOK ]on_stream_none_reader API调用,参数:" + json.toString()); | 530 | logger.info("[ ZLM HOOK ]on_stream_none_reader API调用,参数:" + json.toString()); |
| 531 | String mediaServerId = json.getString("mediaServerId"); | 531 | String mediaServerId = json.getString("mediaServerId"); |
| @@ -570,7 +570,7 @@ public class ZLMHttpHookListener { | @@ -570,7 +570,7 @@ public class ZLMHttpHookListener { | ||
| 570 | if (mediaServerItem != null && mediaServerItem.getStreamNoneReaderDelayMS() == -1) { | 570 | if (mediaServerItem != null && mediaServerItem.getStreamNoneReaderDelayMS() == -1) { |
| 571 | ret.put("close", false); | 571 | ret.put("close", false); |
| 572 | } | 572 | } |
| 573 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 573 | + return ret; |
| 574 | }else { | 574 | }else { |
| 575 | StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(app, streamId); | 575 | StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(app, streamId); |
| 576 | if (streamProxyItem != null && streamProxyItem.isEnable_remove_none_reader()) { | 576 | if (streamProxyItem != null && streamProxyItem.isEnable_remove_none_reader()) { |
| @@ -581,7 +581,7 @@ public class ZLMHttpHookListener { | @@ -581,7 +581,7 @@ public class ZLMHttpHookListener { | ||
| 581 | }else { | 581 | }else { |
| 582 | ret.put("close", false); | 582 | ret.put("close", false); |
| 583 | } | 583 | } |
| 584 | - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK); | 584 | + return ret; |
| 585 | } | 585 | } |
| 586 | } | 586 | } |
| 587 | 587 | ||
| @@ -591,7 +591,7 @@ public class ZLMHttpHookListener { | @@ -591,7 +591,7 @@ public class ZLMHttpHookListener { | ||
| 591 | */ | 591 | */ |
| 592 | @ResponseBody | 592 | @ResponseBody |
| 593 | @PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8") | 593 | @PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8") |
| 594 | - public ResponseEntity<String> onStreamNotFound(@RequestBody JSONObject json){ | 594 | + public JSONObject onStreamNotFound(@RequestBody JSONObject json){ |
| 595 | if (logger.isDebugEnabled()) { | 595 | if (logger.isDebugEnabled()) { |
| 596 | logger.debug("[ ZLM HOOK ]on_stream_not_found API调用,参数:" + json.toString()); | 596 | logger.debug("[ ZLM HOOK ]on_stream_not_found API调用,参数:" + json.toString()); |
| 597 | } | 597 | } |
| @@ -616,7 +616,7 @@ public class ZLMHttpHookListener { | @@ -616,7 +616,7 @@ public class ZLMHttpHookListener { | ||
| 616 | JSONObject ret = new JSONObject(); | 616 | JSONObject ret = new JSONObject(); |
| 617 | ret.put("code", 0); | 617 | ret.put("code", 0); |
| 618 | ret.put("msg", "success"); | 618 | ret.put("msg", "success"); |
| 619 | - return new ResponseEntity<>(ret.toString(),HttpStatus.OK); | 619 | + return ret; |
| 620 | } | 620 | } |
| 621 | 621 | ||
| 622 | /** | 622 | /** |
| @@ -625,7 +625,7 @@ public class ZLMHttpHookListener { | @@ -625,7 +625,7 @@ public class ZLMHttpHookListener { | ||
| 625 | */ | 625 | */ |
| 626 | @ResponseBody | 626 | @ResponseBody |
| 627 | @PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8") | 627 | @PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8") |
| 628 | - public ResponseEntity<String> onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject){ | 628 | + public JSONObject onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject){ |
| 629 | 629 | ||
| 630 | if (logger.isDebugEnabled()) { | 630 | if (logger.isDebugEnabled()) { |
| 631 | logger.debug("[ ZLM HOOK ]on_server_started API调用,参数:" + jsonObject.toString()); | 631 | logger.debug("[ ZLM HOOK ]on_server_started API调用,参数:" + jsonObject.toString()); |
| @@ -646,7 +646,7 @@ public class ZLMHttpHookListener { | @@ -646,7 +646,7 @@ public class ZLMHttpHookListener { | ||
| 646 | JSONObject ret = new JSONObject(); | 646 | JSONObject ret = new JSONObject(); |
| 647 | ret.put("code", 0); | 647 | ret.put("code", 0); |
| 648 | ret.put("msg", "success"); | 648 | ret.put("msg", "success"); |
| 649 | - return new ResponseEntity<>(ret.toString(),HttpStatus.OK); | 649 | + return ret; |
| 650 | } | 650 | } |
| 651 | 651 | ||
| 652 | private Map<String, String> urlParamToMap(String params) { | 652 | private Map<String, String> urlParamToMap(String params) { |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
| @@ -25,8 +25,12 @@ public class MediaServiceImpl implements IMediaService { | @@ -25,8 +25,12 @@ public class MediaServiceImpl implements IMediaService { | ||
| 25 | private IRedisCatchStorage redisCatchStorage; | 25 | private IRedisCatchStorage redisCatchStorage; |
| 26 | 26 | ||
| 27 | @Autowired | 27 | @Autowired |
| 28 | + private IVideoManagerStorage storager; | ||
| 29 | + | ||
| 30 | + @Autowired | ||
| 28 | private IMediaServerService mediaServerService; | 31 | private IMediaServerService mediaServerService; |
| 29 | 32 | ||
| 33 | + | ||
| 30 | @Autowired | 34 | @Autowired |
| 31 | private MediaConfig mediaConfig; | 35 | private MediaConfig mediaConfig; |
| 32 | 36 | ||
| @@ -50,9 +54,10 @@ public class MediaServiceImpl implements IMediaService { | @@ -50,9 +54,10 @@ public class MediaServiceImpl implements IMediaService { | ||
| 50 | if (mediaInfo == null) { | 54 | if (mediaInfo == null) { |
| 51 | return null; | 55 | return null; |
| 52 | } | 56 | } |
| 57 | + String calld = null; | ||
| 53 | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); | 58 | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); |
| 54 | - if (streamAuthorityInfo == null) { | ||
| 55 | - return null; | 59 | + if (streamAuthorityInfo != null) { |
| 60 | + calld = streamAuthorityInfo.getCallId(); | ||
| 56 | } | 61 | } |
| 57 | JSONObject mediaList = zlmresTfulUtils.getMediaList(mediaInfo, app, stream); | 62 | JSONObject mediaList = zlmresTfulUtils.getMediaList(mediaInfo, app, stream); |
| 58 | if (mediaList != null) { | 63 | if (mediaList != null) { |
| @@ -64,7 +69,7 @@ public class MediaServiceImpl implements IMediaService { | @@ -64,7 +69,7 @@ public class MediaServiceImpl implements IMediaService { | ||
| 64 | JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class); | 69 | JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class); |
| 65 | JSONArray tracks = mediaJSON.getJSONArray("tracks"); | 70 | JSONArray tracks = mediaJSON.getJSONArray("tracks"); |
| 66 | if (authority) { | 71 | if (authority) { |
| 67 | - streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,streamAuthorityInfo.getCallId(), true); | 72 | + streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr, calld); |
| 68 | }else { | 73 | }else { |
| 69 | streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null, true); | 74 | streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null, true); |
| 70 | } | 75 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
| @@ -125,7 +125,7 @@ public class PlatformServiceImpl implements IPlatformService { | @@ -125,7 +125,7 @@ public class PlatformServiceImpl implements IPlatformService { | ||
| 125 | dynamicTask.startDelay(registerTaskKey, | 125 | dynamicTask.startDelay(registerTaskKey, |
| 126 | // 注册失败(注册成功时由程序直接调用了online方法) | 126 | // 注册失败(注册成功时由程序直接调用了online方法) |
| 127 | ()->commanderForPlatform.register(parentPlatform, eventResult -> offline(parentPlatform),null), | 127 | ()->commanderForPlatform.register(parentPlatform, eventResult -> offline(parentPlatform),null), |
| 128 | - parentPlatform.getExpires()*1000); | 128 | + (parentPlatform.getExpires() - 10) *1000); |
| 129 | 129 | ||
| 130 | final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId(); | 130 | final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId(); |
| 131 | if (!dynamicTask.contains(keepaliveTaskKey)) { | 131 | if (!dynamicTask.contains(keepaliveTaskKey)) { |
| @@ -164,7 +164,7 @@ public class PlatformServiceImpl implements IPlatformService { | @@ -164,7 +164,7 @@ public class PlatformServiceImpl implements IPlatformService { | ||
| 164 | redisCatchStorage.updatePlatformCatchInfo(platformCatch); | 164 | redisCatchStorage.updatePlatformCatchInfo(platformCatch); |
| 165 | } | 165 | } |
| 166 | }), | 166 | }), |
| 167 | - parentPlatform.getExpires()*1000); | 167 | + (parentPlatform.getKeepTimeout() - 10)*1000); |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | 170 | ||
| @@ -213,7 +213,6 @@ public class PlatformServiceImpl implements IPlatformService { | @@ -213,7 +213,6 @@ public class PlatformServiceImpl implements IPlatformService { | ||
| 213 | param.put("stream", sendRtpItem.getStreamId()); | 213 | param.put("stream", sendRtpItem.getStreamId()); |
| 214 | zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param); | 214 | zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param); |
| 215 | } | 215 | } |
| 216 | - | ||
| 217 | } | 216 | } |
| 218 | } | 217 | } |
| 219 | 218 |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| @@ -290,7 +290,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -290,7 +290,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 290 | public boolean start(String app, String stream) { | 290 | public boolean start(String app, String stream) { |
| 291 | boolean result = false; | 291 | boolean result = false; |
| 292 | StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream); | 292 | StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream); |
| 293 | - if (!streamProxy.isEnable() ) { | 293 | + if (streamProxy != null && !streamProxy.isEnable() ) { |
| 294 | JSONObject jsonObject = addStreamProxyToZlm(streamProxy); | 294 | JSONObject jsonObject = addStreamProxyToZlm(streamProxy); |
| 295 | if (jsonObject == null) { | 295 | if (jsonObject == null) { |
| 296 | return false; | 296 | return false; |
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
| @@ -76,8 +76,8 @@ public interface StreamPushMapper { | @@ -76,8 +76,8 @@ public interface StreamPushMapper { | ||
| 76 | "WHERE " + | 76 | "WHERE " + |
| 77 | "1=1 " + | 77 | "1=1 " + |
| 78 | " <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " + | 78 | " <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " + |
| 79 | - " <if test='pushing == true' > AND (gs.gbId is null OR st.status=1)</if>" + | ||
| 80 | - " <if test='pushing == false' > AND st.status=0</if>" + | 79 | + " <if test='pushing == true' > AND (gs.gbId is null OR st.pushIng=1)</if>" + |
| 80 | + " <if test='pushing == false' > AND st.pushIng=0</if>" + | ||
| 81 | " <if test='mediaServerId != null' > AND st.mediaServerId=#{mediaServerId} </if>" + | 81 | " <if test='mediaServerId != null' > AND st.mediaServerId=#{mediaServerId} </if>" + |
| 82 | "order by st.createTime desc" + | 82 | "order by st.createTime desc" + |
| 83 | " </script>"}) | 83 | " </script>"}) |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
| @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.MobilePosition; | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.MobilePosition; | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | import java.util.UUID; | 4 | import java.util.UUID; |
| 5 | 5 | ||
| 6 | +import com.genersoft.iot.vmp.conf.exception.ControllerException; | ||
| 6 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 7 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 7 | import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; | 8 | import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; |
| 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| @@ -10,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | @@ -10,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | ||
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | 11 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 11 | import com.genersoft.iot.vmp.service.IDeviceService; | 12 | import com.genersoft.iot.vmp.service.IDeviceService; |
| 12 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 13 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 14 | +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; | ||
| 13 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 15 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 14 | import com.github.pagehelper.util.StringUtil; | 16 | import com.github.pagehelper.util.StringUtil; |
| 15 | 17 | ||
| @@ -136,13 +138,9 @@ public class MobilePositionController { | @@ -136,13 +138,9 @@ public class MobilePositionController { | ||
| 136 | @Parameter(name = "expires", description = "订阅超时时间", required = true) | 138 | @Parameter(name = "expires", description = "订阅超时时间", required = true) |
| 137 | @Parameter(name = "interval", description = "上报时间间隔", required = true) | 139 | @Parameter(name = "interval", description = "上报时间间隔", required = true) |
| 138 | @GetMapping("/subscribe/{deviceId}") | 140 | @GetMapping("/subscribe/{deviceId}") |
| 139 | - public String positionSubscribe(@PathVariable String deviceId, | 141 | + public void positionSubscribe(@PathVariable String deviceId, |
| 140 | @RequestParam String expires, | 142 | @RequestParam String expires, |
| 141 | @RequestParam String interval) { | 143 | @RequestParam String interval) { |
| 142 | - String msg = ((expires.equals("0")) ? "取消" : "") + "订阅设备" + deviceId + "的移动位置"; | ||
| 143 | - if (logger.isDebugEnabled()) { | ||
| 144 | - logger.debug(msg); | ||
| 145 | - } | ||
| 146 | 144 | ||
| 147 | if (StringUtil.isEmpty(interval)) { | 145 | if (StringUtil.isEmpty(interval)) { |
| 148 | interval = "5"; | 146 | interval = "5"; |
| @@ -151,13 +149,8 @@ public class MobilePositionController { | @@ -151,13 +149,8 @@ public class MobilePositionController { | ||
| 151 | device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); | 149 | device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); |
| 152 | device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); | 150 | device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); |
| 153 | deviceService.updateDevice(device); | 151 | deviceService.updateDevice(device); |
| 154 | - String result = msg; | ||
| 155 | - if (deviceService.removeMobilePositionSubscribe(device)) { | ||
| 156 | - result += ",成功"; | ||
| 157 | - } else { | ||
| 158 | - result += ",失败"; | 152 | + if (!deviceService.removeMobilePositionSubscribe(device)) { |
| 153 | + throw new ControllerException(ErrorCode.ERROR100); | ||
| 159 | } | 154 | } |
| 160 | - | ||
| 161 | - return result; | ||
| 162 | } | 155 | } |
| 163 | } | 156 | } |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java
| @@ -56,20 +56,14 @@ public class DeviceControl { | @@ -56,20 +56,14 @@ public class DeviceControl { | ||
| 56 | @Operation(summary = "远程启动控制命令") | 56 | @Operation(summary = "远程启动控制命令") |
| 57 | @Parameter(name = "deviceId", description = "设备国标编号", required = true) | 57 | @Parameter(name = "deviceId", description = "设备国标编号", required = true) |
| 58 | @GetMapping("/teleboot/{deviceId}") | 58 | @GetMapping("/teleboot/{deviceId}") |
| 59 | - public String teleBootApi(@PathVariable String deviceId) { | 59 | + public void teleBootApi(@PathVariable String deviceId) { |
| 60 | if (logger.isDebugEnabled()) { | 60 | if (logger.isDebugEnabled()) { |
| 61 | logger.debug("设备远程启动API调用"); | 61 | logger.debug("设备远程启动API调用"); |
| 62 | } | 62 | } |
| 63 | Device device = storager.queryVideoDevice(deviceId); | 63 | Device device = storager.queryVideoDevice(deviceId); |
| 64 | - boolean sucsess = cmder.teleBootCmd(device); | ||
| 65 | - if (sucsess) { | ||
| 66 | - JSONObject json = new JSONObject(); | ||
| 67 | - json.put("DeviceID", deviceId); | ||
| 68 | - json.put("Result", "OK"); | ||
| 69 | - return json.toJSONString(); | ||
| 70 | - } else { | ||
| 71 | - logger.warn("设备远程启动API调用失败!"); | ||
| 72 | - throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备远程启动API调用失败!"); | 64 | + if (!cmder.teleBootCmd(device)) { |
| 65 | + logger.warn("设备远程启动API调用失败!"); | ||
| 66 | + throw new ControllerException(ErrorCode.ERROR100); | ||
| 73 | } | 67 | } |
| 74 | } | 68 | } |
| 75 | 69 |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
| @@ -244,7 +244,7 @@ public class PlatformController { | @@ -244,7 +244,7 @@ public class PlatformController { | ||
| 244 | @Parameter(name = "serverGBId", description = "上级平台的国标编号") | 244 | @Parameter(name = "serverGBId", description = "上级平台的国标编号") |
| 245 | @DeleteMapping("/delete/{serverGBId}") | 245 | @DeleteMapping("/delete/{serverGBId}") |
| 246 | @ResponseBody | 246 | @ResponseBody |
| 247 | - public String deletePlatform(@PathVariable String serverGBId) { | 247 | + public void deletePlatform(@PathVariable String serverGBId) { |
| 248 | 248 | ||
| 249 | if (logger.isDebugEnabled()) { | 249 | if (logger.isDebugEnabled()) { |
| 250 | logger.debug("删除上级平台API调用"); | 250 | logger.debug("删除上级平台API调用"); |
| @@ -278,9 +278,7 @@ public class PlatformController { | @@ -278,9 +278,7 @@ public class PlatformController { | ||
| 278 | dynamicTask.stop(key); | 278 | dynamicTask.stop(key); |
| 279 | // 删除缓存的订阅信息 | 279 | // 删除缓存的订阅信息 |
| 280 | subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); | 280 | subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); |
| 281 | - if (deleteResult) { | ||
| 282 | - return null; | ||
| 283 | - } else { | 281 | + if (!deleteResult) { |
| 284 | throw new ControllerException(ErrorCode.ERROR100); | 282 | throw new ControllerException(ErrorCode.ERROR100); |
| 285 | } | 283 | } |
| 286 | } | 284 | } |
web_src/config/index.js
| @@ -12,14 +12,14 @@ module.exports = { | @@ -12,14 +12,14 @@ module.exports = { | ||
| 12 | assetsPublicPath: '/', | 12 | assetsPublicPath: '/', |
| 13 | proxyTable: { | 13 | proxyTable: { |
| 14 | '/debug': { | 14 | '/debug': { |
| 15 | - target: 'http://localhost:18080', | 15 | + target: 'http://localhost:38080', |
| 16 | changeOrigin: true, | 16 | changeOrigin: true, |
| 17 | pathRewrite: { | 17 | pathRewrite: { |
| 18 | '^/debug': '/' | 18 | '^/debug': '/' |
| 19 | } | 19 | } |
| 20 | }, | 20 | }, |
| 21 | '/static/snap': { | 21 | '/static/snap': { |
| 22 | - target: 'http://localhost:18080', | 22 | + target: 'http://localhost:38080', |
| 23 | changeOrigin: true, | 23 | changeOrigin: true, |
| 24 | // pathRewrite: { | 24 | // pathRewrite: { |
| 25 | // '^/static/snap': '/static/snap' | 25 | // '^/static/snap': '/static/snap' |
web_src/src/components/StreamProxyList.vue
| @@ -220,7 +220,7 @@ | @@ -220,7 +220,7 @@ | ||
| 220 | this.getListLoading = true; | 220 | this.getListLoading = true; |
| 221 | this.$axios({ | 221 | this.$axios({ |
| 222 | method: 'get', | 222 | method: 'get', |
| 223 | - url:`/api/media/stream_info_by_app_and_stream`, | 223 | + url:`/api/push/getPlayUrl`, |
| 224 | params: { | 224 | params: { |
| 225 | app: row.app, | 225 | app: row.app, |
| 226 | stream: row.stream, | 226 | stream: row.stream, |