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