Commit ee7ef0bf4131ad7b6f91ca204c2b54b7c671dd08

Authored by 648540858
1 parent 7db2bf7b

优化级联平台注册的周期时间

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/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  
... ... @@ -187,13 +187,13 @@ public class ZLMHttpHookListener {
187 187 if (streamAuthorityInfo != null && streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId"))) {
188 188 ret.put("code", 401);
189 189 ret.put("msg", "Unauthorized");
190   - return new ResponseEntity<>(ret.toString(),HttpStatus.OK);
  190 + return ret;
191 191 }
192 192 }
193 193  
194 194 ret.put("code", 0);
195 195 ret.put("msg", "success");
196   - return new ResponseEntity<>(ret.toString(),HttpStatus.OK);
  196 + return ret;
197 197 }
198 198  
199 199 /**
... ... @@ -202,7 +202,7 @@ public class ZLMHttpHookListener {
202 202 */
203 203 @ResponseBody
204 204 @PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
205   - public ResponseEntity<String> onPublish(@RequestBody OnPublishHookParam param) {
  205 + public JSONObject onPublish(@RequestBody OnPublishHookParam param) {
206 206  
207 207 JSONObject json = (JSONObject) JSON.toJSON(param);
208 208  
... ... @@ -216,7 +216,7 @@ public class ZLMHttpHookListener {
216 216 logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)");
217 217 ret.put("code", 401);
218 218 ret.put("msg", "Unauthorized");
219   - return new ResponseEntity<>(ret.toString(), HttpStatus.OK);
  219 + return ret;
220 220 }
221 221 Map<String, String> paramMap = urlParamToMap(param.getParams());
222 222 String sign = paramMap.get("sign");
... ... @@ -224,7 +224,7 @@ public class ZLMHttpHookListener {
224 224 logger.info("推流鉴权失败: 缺少不要参数:sign=md5(user表的pushKey)");
225 225 ret.put("code", 401);
226 226 ret.put("msg", "Unauthorized");
227   - return new ResponseEntity<>(ret.toString(), HttpStatus.OK);
  227 + return ret;
228 228 }
229 229 // 推流自定义播放鉴权码
230 230 String callId = paramMap.get("callId");
... ... @@ -234,7 +234,7 @@ public class ZLMHttpHookListener {
234 234 logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign);
235 235 ret.put("code", 401);
236 236 ret.put("msg", "Unauthorized");
237   - return new ResponseEntity<>(ret.toString(), HttpStatus.OK);
  237 + return ret;
238 238 }
239 239 StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param);
240 240 streamAuthorityInfo.setCallId(callId);
... ... @@ -242,12 +242,11 @@ public class ZLMHttpHookListener {
242 242 // 鉴权通过
243 243 redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
244 244 // 通知assist新的callId
245   - taskExecutor.execute(()->{
246   - if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) {
  245 + if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) {
  246 + taskExecutor.execute(()->{
247 247 assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
248   - }
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();
... ... @@ -520,7 +516,7 @@ public class ZLMHttpHookListener {
520 516 JSONObject ret = new JSONObject();
521 517 ret.put("code", 0);
522 518 ret.put("msg", "success");
523   - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
  519 + return ret;
524 520 }
525 521  
526 522 /**
... ... @@ -529,7 +525,7 @@ public class ZLMHttpHookListener {
529 525 */
530 526 @ResponseBody
531 527 @PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8")
532   - public ResponseEntity<String> onStreamNoneReader(@RequestBody JSONObject json){
  528 + public JSONObject onStreamNoneReader(@RequestBody JSONObject json){
533 529  
534 530 logger.info("[ ZLM HOOK ]on_stream_none_reader API调用,参数:" + json.toString());
535 531 String mediaServerId = json.getString("mediaServerId");
... ... @@ -574,7 +570,7 @@ public class ZLMHttpHookListener {
574 570 if (mediaServerItem != null && mediaServerItem.getStreamNoneReaderDelayMS() == -1) {
575 571 ret.put("close", false);
576 572 }
577   - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
  573 + return ret;
578 574 }else {
579 575 StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(app, streamId);
580 576 if (streamProxyItem != null && streamProxyItem.isEnable_remove_none_reader()) {
... ... @@ -585,7 +581,7 @@ public class ZLMHttpHookListener {
585 581 }else {
586 582 ret.put("close", false);
587 583 }
588   - return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
  584 + return ret;
589 585 }
590 586 }
591 587  
... ... @@ -595,7 +591,7 @@ public class ZLMHttpHookListener {
595 591 */
596 592 @ResponseBody
597 593 @PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8")
598   - public ResponseEntity<String> onStreamNotFound(@RequestBody JSONObject json){
  594 + public JSONObject onStreamNotFound(@RequestBody JSONObject json){
599 595 if (logger.isDebugEnabled()) {
600 596 logger.debug("[ ZLM HOOK ]on_stream_not_found API调用,参数:" + json.toString());
601 597 }
... ... @@ -620,7 +616,7 @@ public class ZLMHttpHookListener {
620 616 JSONObject ret = new JSONObject();
621 617 ret.put("code", 0);
622 618 ret.put("msg", "success");
623   - return new ResponseEntity<>(ret.toString(),HttpStatus.OK);
  619 + return ret;
624 620 }
625 621  
626 622 /**
... ... @@ -629,7 +625,7 @@ public class ZLMHttpHookListener {
629 625 */
630 626 @ResponseBody
631 627 @PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8")
632   - public ResponseEntity<String> onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject){
  628 + public JSONObject onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject){
633 629  
634 630 if (logger.isDebugEnabled()) {
635 631 logger.debug("[ ZLM HOOK ]on_server_started API调用,参数:" + jsonObject.toString());
... ... @@ -650,7 +646,7 @@ public class ZLMHttpHookListener {
650 646 JSONObject ret = new JSONObject();
651 647 ret.put("code", 0);
652 648 ret.put("msg", "success");
653   - return new ResponseEntity<>(ret.toString(),HttpStatus.OK);
  649 + return ret;
654 650 }
655 651  
656 652 private Map<String, String> urlParamToMap(String params) {
... ...
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  
... ...