Commit 275b272160679beaf19147764b73c1c439880593
1 parent
2de4c322
hook订阅曾增加过期清除功能,防止内存溢出
Showing
12 changed files
with
73 additions
and
77 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
| @@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd; | @@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd; | ||
| 3 | import com.genersoft.iot.vmp.common.StreamInfo; | 3 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.*; | 4 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 5 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 5 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 6 | -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 6 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 8 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 8 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 9 | 9 | ||
| @@ -93,7 +93,7 @@ public interface ISIPCommander { | @@ -93,7 +93,7 @@ public interface ISIPCommander { | ||
| 93 | * @param device 视频设备 | 93 | * @param device 视频设备 |
| 94 | * @param channelId 预览通道 | 94 | * @param channelId 预览通道 |
| 95 | */ | 95 | */ |
| 96 | - void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent); | 96 | + void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent); |
| 97 | 97 | ||
| 98 | /** | 98 | /** |
| 99 | * 请求回放视频流 | 99 | * 请求回放视频流 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -13,10 +13,9 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; | @@ -13,10 +13,9 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; | ||
| 13 | import com.genersoft.iot.vmp.gb28181.utils.HeaderUtils; | 13 | import com.genersoft.iot.vmp.gb28181.utils.HeaderUtils; |
| 14 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | 14 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| 15 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | 15 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| 16 | -import com.genersoft.iot.vmp.media.zlm.dto.HookType; | ||
| 17 | import com.genersoft.iot.vmp.utils.DateUtil; | 16 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 18 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; | 17 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; |
| 19 | -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 18 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 20 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 19 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 21 | import com.genersoft.iot.vmp.service.IMediaServerService; | 20 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 22 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 21 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| @@ -34,19 +33,15 @@ import org.springframework.beans.factory.annotation.Qualifier; | @@ -34,19 +33,15 @@ import org.springframework.beans.factory.annotation.Qualifier; | ||
| 34 | import org.springframework.context.annotation.DependsOn; | 33 | import org.springframework.context.annotation.DependsOn; |
| 35 | import org.springframework.stereotype.Component; | 34 | import org.springframework.stereotype.Component; |
| 36 | import org.springframework.util.ObjectUtils; | 35 | import org.springframework.util.ObjectUtils; |
| 37 | -import org.springframework.util.StringUtils; | ||
| 38 | 36 | ||
| 39 | import javax.sip.*; | 37 | import javax.sip.*; |
| 40 | import javax.sip.address.Address; | 38 | import javax.sip.address.Address; |
| 41 | import javax.sip.address.SipURI; | 39 | import javax.sip.address.SipURI; |
| 42 | -import javax.sip.address.URI; | ||
| 43 | import javax.sip.header.*; | 40 | import javax.sip.header.*; |
| 44 | import javax.sip.message.Request; | 41 | import javax.sip.message.Request; |
| 45 | import java.lang.reflect.Field; | 42 | import java.lang.reflect.Field; |
| 46 | import java.text.ParseException; | 43 | import java.text.ParseException; |
| 47 | -import java.util.ArrayList; | ||
| 48 | import java.util.HashSet; | 44 | import java.util.HashSet; |
| 49 | -import java.util.List; | ||
| 50 | 45 | ||
| 51 | /** | 46 | /** |
| 52 | * @description:设备能力接口,用于定义设备的控制、查询能力 | 47 | * @description:设备能力接口,用于定义设备的控制、查询能力 |
| @@ -89,7 +84,7 @@ public class SIPCommander implements ISIPCommander { | @@ -89,7 +84,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 89 | private UserSetting userSetting; | 84 | private UserSetting userSetting; |
| 90 | 85 | ||
| 91 | @Autowired | 86 | @Autowired |
| 92 | - private ZLMHttpHookSubscribe subscribe; | 87 | + private ZlmHttpHookSubscribe subscribe; |
| 93 | 88 | ||
| 94 | @Autowired | 89 | @Autowired |
| 95 | private SipSubscribe sipSubscribe; | 90 | private SipSubscribe sipSubscribe; |
| @@ -352,7 +347,7 @@ public class SIPCommander implements ISIPCommander { | @@ -352,7 +347,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 352 | */ | 347 | */ |
| 353 | @Override | 348 | @Override |
| 354 | public void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, | 349 | public void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| 355 | - ZLMHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) { | 350 | + ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) { |
| 356 | String stream = ssrcInfo.getStream(); | 351 | String stream = ssrcInfo.getStream(); |
| 357 | try { | 352 | try { |
| 358 | if (device == null) { | 353 | if (device == null) { |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
| 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| 2 | 2 | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 5 | -import com.genersoft.iot.vmp.common.StreamInfo; | ||
| 6 | import com.genersoft.iot.vmp.conf.DynamicTask; | 4 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 7 | -import com.genersoft.iot.vmp.gb28181.bean.InviteStreamType; | ||
| 8 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 9 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | 6 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; | 7 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| @@ -12,7 +9,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | @@ -12,7 +9,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | ||
| 12 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 14 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 15 | -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 12 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 16 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | 13 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 17 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 14 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 18 | import com.genersoft.iot.vmp.service.IMediaServerService; | 15 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| @@ -21,7 +18,6 @@ import com.genersoft.iot.vmp.service.impl.RedisGbPlayMsgListener; | @@ -21,7 +18,6 @@ import com.genersoft.iot.vmp.service.impl.RedisGbPlayMsgListener; | ||
| 21 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 18 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 22 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 19 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 23 | import com.genersoft.iot.vmp.utils.SerializeUtils; | 20 | import com.genersoft.iot.vmp.utils.SerializeUtils; |
| 24 | -import org.ehcache.shadow.org.terracotta.offheapstore.storage.IntegerStorageEngine; | ||
| 25 | import org.slf4j.Logger; | 21 | import org.slf4j.Logger; |
| 26 | import org.slf4j.LoggerFactory; | 22 | import org.slf4j.LoggerFactory; |
| 27 | import org.springframework.beans.factory.InitializingBean; | 23 | import org.springframework.beans.factory.InitializingBean; |
| @@ -69,7 +65,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | @@ -69,7 +65,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 69 | private IMediaServerService mediaServerService; | 65 | private IMediaServerService mediaServerService; |
| 70 | 66 | ||
| 71 | @Autowired | 67 | @Autowired |
| 72 | - private ZLMHttpHookSubscribe subscribe; | 68 | + private ZlmHttpHookSubscribe subscribe; |
| 73 | 69 | ||
| 74 | @Autowired | 70 | @Autowired |
| 75 | private DynamicTask dynamicTask; | 71 | private DynamicTask dynamicTask; |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| @@ -13,7 +13,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; | @@ -13,7 +13,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; | ||
| 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; | 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 14 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 14 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 15 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | 15 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 16 | -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 16 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 17 | import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; | 17 | import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; |
| 18 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | 18 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 19 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 19 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| @@ -40,7 +40,6 @@ import org.springframework.stereotype.Component; | @@ -40,7 +40,6 @@ import org.springframework.stereotype.Component; | ||
| 40 | 40 | ||
| 41 | import javax.sdp.*; | 41 | import javax.sdp.*; |
| 42 | import javax.sip.*; | 42 | import javax.sip.*; |
| 43 | -import javax.sip.address.SipURI; | ||
| 44 | import javax.sip.header.CallIdHeader; | 43 | import javax.sip.header.CallIdHeader; |
| 45 | import javax.sip.message.Request; | 44 | import javax.sip.message.Request; |
| 46 | import javax.sip.message.Response; | 45 | import javax.sip.message.Response; |
| @@ -307,7 +306,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -307,7 +306,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 307 | 306 | ||
| 308 | Long finalStartTime = startTime; | 307 | Long finalStartTime = startTime; |
| 309 | Long finalStopTime = stopTime; | 308 | Long finalStopTime = stopTime; |
| 310 | - ZLMHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON) -> { | 309 | + ZlmHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON) -> { |
| 311 | String app = responseJSON.getString("app"); | 310 | String app = responseJSON.getString("app"); |
| 312 | String stream = responseJSON.getString("stream"); | 311 | String stream = responseJSON.getString("stream"); |
| 313 | logger.info("[上级点播]下级已经开始推流。 回复200OK(SDP), {}/{}", app, stream); | 312 | logger.info("[上级点播]下级已经开始推流。 回复200OK(SDP), {}/{}", app, stream); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -22,9 +22,7 @@ import org.springframework.beans.factory.annotation.Qualifier; | @@ -22,9 +22,7 @@ import org.springframework.beans.factory.annotation.Qualifier; | ||
| 22 | import org.springframework.http.HttpStatus; | 22 | import org.springframework.http.HttpStatus; |
| 23 | import org.springframework.http.ResponseEntity; | 23 | import org.springframework.http.ResponseEntity; |
| 24 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 24 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| 25 | -import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; | ||
| 26 | import org.springframework.util.ObjectUtils; | 25 | import org.springframework.util.ObjectUtils; |
| 27 | -import org.springframework.util.StringUtils; | ||
| 28 | import org.springframework.web.bind.annotation.PostMapping; | 26 | import org.springframework.web.bind.annotation.PostMapping; |
| 29 | import org.springframework.web.bind.annotation.RequestBody; | 27 | import org.springframework.web.bind.annotation.RequestBody; |
| 30 | import org.springframework.web.bind.annotation.RequestMapping; | 28 | import org.springframework.web.bind.annotation.RequestMapping; |
| @@ -81,7 +79,7 @@ public class ZLMHttpHookListener { | @@ -81,7 +79,7 @@ public class ZLMHttpHookListener { | ||
| 81 | private ZLMMediaListManager zlmMediaListManager; | 79 | private ZLMMediaListManager zlmMediaListManager; |
| 82 | 80 | ||
| 83 | @Autowired | 81 | @Autowired |
| 84 | - private ZLMHttpHookSubscribe subscribe; | 82 | + private ZlmHttpHookSubscribe subscribe; |
| 85 | 83 | ||
| 86 | @Autowired | 84 | @Autowired |
| 87 | private UserSetting userSetting; | 85 | private UserSetting userSetting; |
| @@ -109,9 +107,9 @@ public class ZLMHttpHookListener { | @@ -109,9 +107,9 @@ public class ZLMHttpHookListener { | ||
| 109 | 107 | ||
| 110 | logger.info("[ ZLM HOOK ] on_server_keepalive API调用,参数:" + json.toString()); | 108 | logger.info("[ ZLM HOOK ] on_server_keepalive API调用,参数:" + json.toString()); |
| 111 | String mediaServerId = json.getString("mediaServerId"); | 109 | String mediaServerId = json.getString("mediaServerId"); |
| 112 | - List<ZLMHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive); | 110 | + List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive); |
| 113 | if (subscribes != null && subscribes.size() > 0) { | 111 | if (subscribes != null && subscribes.size() > 0) { |
| 114 | - for (ZLMHttpHookSubscribe.Event subscribe : subscribes) { | 112 | + for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { |
| 115 | subscribe.response(null, json); | 113 | subscribe.response(null, json); |
| 116 | } | 114 | } |
| 117 | } | 115 | } |
| @@ -175,7 +173,7 @@ public class ZLMHttpHookListener { | @@ -175,7 +173,7 @@ public class ZLMHttpHookListener { | ||
| 175 | logger.debug("[ ZLM HOOK ]on_play API调用,参数:" + JSON.toJSONString(param)); | 173 | logger.debug("[ ZLM HOOK ]on_play API调用,参数:" + JSON.toJSONString(param)); |
| 176 | } | 174 | } |
| 177 | String mediaServerId = param.getMediaServerId(); | 175 | String mediaServerId = param.getMediaServerId(); |
| 178 | - ZLMHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json); | 176 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json); |
| 179 | if (subscribe != null ) { | 177 | if (subscribe != null ) { |
| 180 | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); | 178 | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); |
| 181 | if (mediaInfo != null) { | 179 | if (mediaInfo != null) { |
| @@ -263,7 +261,7 @@ public class ZLMHttpHookListener { | @@ -263,7 +261,7 @@ public class ZLMHttpHookListener { | ||
| 263 | } | 261 | } |
| 264 | 262 | ||
| 265 | 263 | ||
| 266 | - ZLMHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); | 264 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); |
| 267 | if (subscribe != null) { | 265 | if (subscribe != null) { |
| 268 | if (mediaInfo != null) { | 266 | if (mediaInfo != null) { |
| 269 | subscribe.response(mediaInfo, json); | 267 | subscribe.response(mediaInfo, json); |
| @@ -387,7 +385,7 @@ public class ZLMHttpHookListener { | @@ -387,7 +385,7 @@ public class ZLMHttpHookListener { | ||
| 387 | logger.debug("[ ZLM HOOK ]on_shell_login API调用,参数:" + json.toString()); | 385 | logger.debug("[ ZLM HOOK ]on_shell_login API调用,参数:" + json.toString()); |
| 388 | } | 386 | } |
| 389 | String mediaServerId = json.getString("mediaServerId"); | 387 | String mediaServerId = json.getString("mediaServerId"); |
| 390 | - ZLMHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_shell_login, json); | 388 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_shell_login, json); |
| 391 | if (subscribe != null ) { | 389 | if (subscribe != null ) { |
| 392 | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); | 390 | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); |
| 393 | if (mediaInfo != null) { | 391 | if (mediaInfo != null) { |
| @@ -413,7 +411,7 @@ public class ZLMHttpHookListener { | @@ -413,7 +411,7 @@ public class ZLMHttpHookListener { | ||
| 413 | logger.info("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item)); | 411 | logger.info("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item)); |
| 414 | String mediaServerId = item.getMediaServerId(); | 412 | String mediaServerId = item.getMediaServerId(); |
| 415 | JSONObject json = (JSONObject) JSON.toJSON(item); | 413 | JSONObject json = (JSONObject) JSON.toJSON(item); |
| 416 | - ZLMHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); | 414 | + ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); |
| 417 | if (subscribe != null ) { | 415 | if (subscribe != null ) { |
| 418 | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); | 416 | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); |
| 419 | if (mediaInfo != null) { | 417 | if (mediaInfo != null) { |
| @@ -635,9 +633,9 @@ public class ZLMHttpHookListener { | @@ -635,9 +633,9 @@ public class ZLMHttpHookListener { | ||
| 635 | } | 633 | } |
| 636 | String remoteAddr = request.getRemoteAddr(); | 634 | String remoteAddr = request.getRemoteAddr(); |
| 637 | jsonObject.put("ip", remoteAddr); | 635 | jsonObject.put("ip", remoteAddr); |
| 638 | - List<ZLMHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started); | 636 | + List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started); |
| 639 | if (subscribes != null && subscribes.size() > 0) { | 637 | if (subscribes != null && subscribes.size() > 0) { |
| 640 | - for (ZLMHttpHookSubscribe.Event subscribe : subscribes) { | 638 | + for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { |
| 641 | subscribe.response(null, jsonObject); | 639 | subscribe.response(null, jsonObject); |
| 642 | } | 640 | } |
| 643 | } | 641 | } |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
| 1 | package com.genersoft.iot.vmp.media.zlm; | 1 | package com.genersoft.iot.vmp.media.zlm; |
| 2 | 2 | ||
| 3 | -import com.alibaba.fastjson.JSONObject; | ||
| 4 | import com.genersoft.iot.vmp.conf.UserSetting; | 3 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; | 4 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 6 | import com.genersoft.iot.vmp.media.zlm.dto.*; | 5 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 7 | import com.genersoft.iot.vmp.service.IMediaServerService; | 6 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 8 | import com.genersoft.iot.vmp.service.IStreamProxyService; | 7 | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| 9 | import com.genersoft.iot.vmp.service.IStreamPushService; | 8 | import com.genersoft.iot.vmp.service.IStreamPushService; |
| 10 | -import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; | ||
| 11 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 12 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 10 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 13 | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; | 11 | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; |
| 14 | import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; | 12 | import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; |
| 15 | import com.genersoft.iot.vmp.storager.dao.StreamPushMapper; | 13 | import com.genersoft.iot.vmp.storager.dao.StreamPushMapper; |
| 16 | import com.genersoft.iot.vmp.utils.DateUtil; | 14 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 17 | -import org.checkerframework.checker.units.qual.C; | ||
| 18 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
| 19 | import org.slf4j.LoggerFactory; | 16 | import org.slf4j.LoggerFactory; |
| 20 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 21 | import org.springframework.stereotype.Component; | 18 | import org.springframework.stereotype.Component; |
| 22 | -import org.springframework.util.StringUtils; | ||
| 23 | 19 | ||
| 24 | import java.util.*; | 20 | import java.util.*; |
| 25 | import java.util.concurrent.ConcurrentHashMap; | 21 | import java.util.concurrent.ConcurrentHashMap; |
| 26 | -import java.util.regex.Matcher; | ||
| 27 | -import java.util.regex.Pattern; | ||
| 28 | 22 | ||
| 29 | /** | 23 | /** |
| 30 | * @author lin | 24 | * @author lin |
| @@ -59,7 +53,7 @@ public class ZLMMediaListManager { | @@ -59,7 +53,7 @@ public class ZLMMediaListManager { | ||
| 59 | private StreamPushMapper streamPushMapper; | 53 | private StreamPushMapper streamPushMapper; |
| 60 | 54 | ||
| 61 | @Autowired | 55 | @Autowired |
| 62 | - private ZLMHttpHookSubscribe subscribe; | 56 | + private ZlmHttpHookSubscribe subscribe; |
| 63 | 57 | ||
| 64 | @Autowired | 58 | @Autowired |
| 65 | private UserSetting userSetting; | 59 | private UserSetting userSetting; |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| @@ -8,7 +8,6 @@ import com.genersoft.iot.vmp.conf.MediaConfig; | @@ -8,7 +8,6 @@ import com.genersoft.iot.vmp.conf.MediaConfig; | ||
| 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | 9 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| 10 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForServerStarted; | 10 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForServerStarted; |
| 11 | -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | ||
| 12 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 11 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 13 | import com.genersoft.iot.vmp.service.IMediaServerService; | 12 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 14 | import org.slf4j.Logger; | 13 | import org.slf4j.Logger; |
| @@ -19,9 +18,7 @@ import org.springframework.core.annotation.Order; | @@ -19,9 +18,7 @@ import org.springframework.core.annotation.Order; | ||
| 19 | import org.springframework.scheduling.annotation.Async; | 18 | import org.springframework.scheduling.annotation.Async; |
| 20 | import org.springframework.stereotype.Component; | 19 | import org.springframework.stereotype.Component; |
| 21 | 20 | ||
| 22 | -import java.time.Instant; | ||
| 23 | import java.util.*; | 21 | import java.util.*; |
| 24 | -import java.util.concurrent.TimeUnit; | ||
| 25 | 22 | ||
| 26 | @Component | 23 | @Component |
| 27 | @Order(value=1) | 24 | @Order(value=1) |
| @@ -35,7 +32,7 @@ public class ZLMRunner implements CommandLineRunner { | @@ -35,7 +32,7 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 35 | private ZLMRESTfulUtils zlmresTfulUtils; | 32 | private ZLMRESTfulUtils zlmresTfulUtils; |
| 36 | 33 | ||
| 37 | @Autowired | 34 | @Autowired |
| 38 | - private ZLMHttpHookSubscribe hookSubscribe; | 35 | + private ZlmHttpHookSubscribe hookSubscribe; |
| 39 | 36 | ||
| 40 | @Autowired | 37 | @Autowired |
| 41 | private EventPublisher publisher; | 38 | private EventPublisher publisher; |
| @@ -62,8 +59,6 @@ public class ZLMRunner implements CommandLineRunner { | @@ -62,8 +59,6 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 62 | } | 59 | } |
| 63 | mediaServerService.syncCatchFromDatabase(); | 60 | mediaServerService.syncCatchFromDatabase(); |
| 64 | HookSubscribeForServerStarted hookSubscribeForServerStarted = HookSubscribeFactory.on_server_started(); | 61 | HookSubscribeForServerStarted hookSubscribeForServerStarted = HookSubscribeFactory.on_server_started(); |
| 65 | -// Instant expiresInstant = Instant.now().plusSeconds(TimeUnit.SECONDS.toSeconds(60)); | ||
| 66 | -// hookSubscribeForStreamChange.setExpires(expiresInstant); | ||
| 67 | // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 | 62 | // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 |
| 68 | hookSubscribe.addSubscribe(hookSubscribeForServerStarted, | 63 | hookSubscribe.addSubscribe(hookSubscribeForServerStarted, |
| 69 | (MediaServerItem mediaServerItem, JSONObject response)->{ | 64 | (MediaServerItem mediaServerItem, JSONObject response)->{ |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java
| @@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSONObject; | @@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSONObject; | ||
| 4 | import com.genersoft.iot.vmp.media.zlm.dto.HookType; | 4 | import com.genersoft.iot.vmp.media.zlm.dto.HookType; |
| 5 | import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; | 5 | import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; |
| 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 6 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 7 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
| 8 | import org.springframework.util.CollectionUtils; | 11 | import org.springframework.util.CollectionUtils; |
| 9 | 12 | ||
| @@ -13,21 +16,22 @@ import java.util.concurrent.ConcurrentHashMap; | @@ -13,21 +16,22 @@ import java.util.concurrent.ConcurrentHashMap; | ||
| 13 | import java.util.concurrent.TimeUnit; | 16 | import java.util.concurrent.TimeUnit; |
| 14 | 17 | ||
| 15 | /** | 18 | /** |
| 16 | - * @description:针对 ZLMediaServer的hook事件订阅 | ||
| 17 | - * @author: pan | ||
| 18 | - * @date: 2020年12月2日 21:17:32 | 19 | + * ZLMediaServer的hook事件订阅 |
| 20 | + * @author lin | ||
| 19 | */ | 21 | */ |
| 20 | @Component | 22 | @Component |
| 21 | -public class ZLMHttpHookSubscribe { | 23 | +public class ZlmHttpHookSubscribe { |
| 24 | + | ||
| 25 | + private final static Logger logger = LoggerFactory.getLogger(ZlmHttpHookSubscribe.class); | ||
| 22 | 26 | ||
| 23 | @FunctionalInterface | 27 | @FunctionalInterface |
| 24 | public interface Event{ | 28 | public interface Event{ |
| 25 | void response(MediaServerItem mediaServerItem, JSONObject response); | 29 | void response(MediaServerItem mediaServerItem, JSONObject response); |
| 26 | } | 30 | } |
| 27 | 31 | ||
| 28 | - private Map<HookType, Map<IHookSubscribe, ZLMHttpHookSubscribe.Event>> allSubscribes = new ConcurrentHashMap<>(); | 32 | + private Map<HookType, Map<IHookSubscribe, ZlmHttpHookSubscribe.Event>> allSubscribes = new ConcurrentHashMap<>(); |
| 29 | 33 | ||
| 30 | - public void addSubscribe(IHookSubscribe hookSubscribe, ZLMHttpHookSubscribe.Event event) { | 34 | + public void addSubscribe(IHookSubscribe hookSubscribe, ZlmHttpHookSubscribe.Event event) { |
| 31 | if (hookSubscribe.getExpires() == null) { | 35 | if (hookSubscribe.getExpires() == null) { |
| 32 | // 默认5分钟过期 | 36 | // 默认5分钟过期 |
| 33 | Instant expiresInstant = Instant.now().plusSeconds(TimeUnit.MINUTES.toSeconds(5)); | 37 | Instant expiresInstant = Instant.now().plusSeconds(TimeUnit.MINUTES.toSeconds(5)); |
| @@ -36,8 +40,8 @@ public class ZLMHttpHookSubscribe { | @@ -36,8 +40,8 @@ public class ZLMHttpHookSubscribe { | ||
| 36 | allSubscribes.computeIfAbsent(hookSubscribe.getHookType(), k -> new ConcurrentHashMap<>()).put(hookSubscribe, event); | 40 | allSubscribes.computeIfAbsent(hookSubscribe.getHookType(), k -> new ConcurrentHashMap<>()).put(hookSubscribe, event); |
| 37 | } | 41 | } |
| 38 | 42 | ||
| 39 | - public ZLMHttpHookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) { | ||
| 40 | - ZLMHttpHookSubscribe.Event event= null; | 43 | + public ZlmHttpHookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) { |
| 44 | + ZlmHttpHookSubscribe.Event event= null; | ||
| 41 | Map<IHookSubscribe, Event> eventMap = allSubscribes.get(type); | 45 | Map<IHookSubscribe, Event> eventMap = allSubscribes.get(type); |
| 42 | if (eventMap == null) { | 46 | if (eventMap == null) { |
| 43 | return null; | 47 | return null; |
| @@ -69,8 +73,8 @@ public class ZLMHttpHookSubscribe { | @@ -69,8 +73,8 @@ public class ZLMHttpHookSubscribe { | ||
| 69 | 73 | ||
| 70 | Set<Map.Entry<IHookSubscribe, Event>> entries = eventMap.entrySet(); | 74 | Set<Map.Entry<IHookSubscribe, Event>> entries = eventMap.entrySet(); |
| 71 | if (entries.size() > 0) { | 75 | if (entries.size() > 0) { |
| 72 | - List<Map.Entry<IHookSubscribe, ZLMHttpHookSubscribe.Event>> entriesToRemove = new ArrayList<>(); | ||
| 73 | - for (Map.Entry<IHookSubscribe, ZLMHttpHookSubscribe.Event> entry : entries) { | 76 | + List<Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event>> entriesToRemove = new ArrayList<>(); |
| 77 | + for (Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event> entry : entries) { | ||
| 74 | JSONObject content = entry.getKey().getContent(); | 78 | JSONObject content = entry.getKey().getContent(); |
| 75 | if (content == null || content.size() == 0) { | 79 | if (content == null || content.size() == 0) { |
| 76 | entriesToRemove.add(entry); | 80 | entriesToRemove.add(entry); |
| @@ -87,13 +91,13 @@ public class ZLMHttpHookSubscribe { | @@ -87,13 +91,13 @@ public class ZLMHttpHookSubscribe { | ||
| 87 | result = result && content.getString(s).equals(hookSubscribe.getContent().getString(s)); | 91 | result = result && content.getString(s).equals(hookSubscribe.getContent().getString(s)); |
| 88 | } | 92 | } |
| 89 | } | 93 | } |
| 90 | - if (null != result && result){ | 94 | + if (result){ |
| 91 | entriesToRemove.add(entry); | 95 | entriesToRemove.add(entry); |
| 92 | } | 96 | } |
| 93 | } | 97 | } |
| 94 | 98 | ||
| 95 | if (!CollectionUtils.isEmpty(entriesToRemove)) { | 99 | if (!CollectionUtils.isEmpty(entriesToRemove)) { |
| 96 | - for (Map.Entry<IHookSubscribe, ZLMHttpHookSubscribe.Event> entry : entriesToRemove) { | 100 | + for (Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event> entry : entriesToRemove) { |
| 97 | entries.remove(entry); | 101 | entries.remove(entry); |
| 98 | } | 102 | } |
| 99 | } | 103 | } |
| @@ -106,12 +110,12 @@ public class ZLMHttpHookSubscribe { | @@ -106,12 +110,12 @@ public class ZLMHttpHookSubscribe { | ||
| 106 | * @param type | 110 | * @param type |
| 107 | * @return | 111 | * @return |
| 108 | */ | 112 | */ |
| 109 | - public List<ZLMHttpHookSubscribe.Event> getSubscribes(HookType type) { | 113 | + public List<ZlmHttpHookSubscribe.Event> getSubscribes(HookType type) { |
| 110 | Map<IHookSubscribe, Event> eventMap = allSubscribes.get(type); | 114 | Map<IHookSubscribe, Event> eventMap = allSubscribes.get(type); |
| 111 | if (eventMap == null) { | 115 | if (eventMap == null) { |
| 112 | return null; | 116 | return null; |
| 113 | } | 117 | } |
| 114 | - List<ZLMHttpHookSubscribe.Event> result = new ArrayList<>(); | 118 | + List<ZlmHttpHookSubscribe.Event> result = new ArrayList<>(); |
| 115 | for (IHookSubscribe key : eventMap.keySet()) { | 119 | for (IHookSubscribe key : eventMap.keySet()) { |
| 116 | result.add(eventMap.get(key)); | 120 | result.add(eventMap.get(key)); |
| 117 | } | 121 | } |
| @@ -127,5 +131,28 @@ public class ZLMHttpHookSubscribe { | @@ -127,5 +131,28 @@ public class ZLMHttpHookSubscribe { | ||
| 127 | return result; | 131 | return result; |
| 128 | } | 132 | } |
| 129 | 133 | ||
| 134 | + /** | ||
| 135 | + * 对订阅数据进行过期清理 | ||
| 136 | + */ | ||
| 137 | + @Scheduled(cron="0 0/5 * * * ?") //每5分钟执行一次 | ||
| 138 | + public void execute(){ | ||
| 130 | 139 | ||
| 140 | + logger.info("[hook订阅] 清理"); | ||
| 141 | + | ||
| 142 | + Instant instant = Instant.now().minusMillis(TimeUnit.MINUTES.toMillis(5)); | ||
| 143 | + int total = 0; | ||
| 144 | + for (HookType hookType : allSubscribes.keySet()) { | ||
| 145 | + Map<IHookSubscribe, Event> hookSubscribeEventMap = allSubscribes.get(hookType); | ||
| 146 | + if (hookSubscribeEventMap.size() > 0) { | ||
| 147 | + for (IHookSubscribe hookSubscribe : hookSubscribeEventMap.keySet()) { | ||
| 148 | + if (hookSubscribe.getExpires().isBefore(instant)) { | ||
| 149 | + // 过期的 | ||
| 150 | + hookSubscribeEventMap.remove(hookSubscribe); | ||
| 151 | + total ++; | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + logger.info("[hook订阅] 清理结束,共清理{}条过期数据", total); | ||
| 157 | + } | ||
| 131 | } | 158 | } |
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
| @@ -6,14 +6,13 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | @@ -6,14 +6,13 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | ||
| 6 | import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback; | 6 | import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback; |
| 7 | import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo; | 7 | import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo; |
| 8 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 8 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 9 | -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 9 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 11 | import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback; | 11 | import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback; |
| 12 | import com.genersoft.iot.vmp.service.bean.PlayBackCallback; | 12 | import com.genersoft.iot.vmp.service.bean.PlayBackCallback; |
| 13 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 13 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 14 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 14 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 15 | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; | 15 | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; |
| 16 | -import org.springframework.http.ResponseEntity; | ||
| 17 | import org.springframework.web.context.request.async.DeferredResult; | 16 | import org.springframework.web.context.request.async.DeferredResult; |
| 18 | 17 | ||
| 19 | /** | 18 | /** |
| @@ -24,9 +23,9 @@ public interface IPlayService { | @@ -24,9 +23,9 @@ public interface IPlayService { | ||
| 24 | void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId, String uuid); | 23 | void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId, String uuid); |
| 25 | 24 | ||
| 26 | void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, | 25 | void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| 27 | - ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, | 26 | + ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| 28 | InviteTimeOutCallback timeoutCallback, String uuid); | 27 | InviteTimeOutCallback timeoutCallback, String uuid); |
| 29 | - PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, ZLMHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent, Runnable timeoutCallback); | 28 | + PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent, Runnable timeoutCallback); |
| 30 | 29 | ||
| 31 | MediaServerItem getNewMediaServerItem(Device device); | 30 | MediaServerItem getNewMediaServerItem(Device device); |
| 32 | 31 |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -39,7 +39,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | @@ -39,7 +39,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | ||
| 39 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | 39 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| 40 | import com.genersoft.iot.vmp.utils.DateUtil; | 40 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 41 | import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; | 41 | import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; |
| 42 | -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 42 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 43 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 43 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 44 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 44 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 45 | import com.genersoft.iot.vmp.service.IMediaServerService; | 45 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| @@ -99,7 +99,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -99,7 +99,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 99 | private DynamicTask dynamicTask; | 99 | private DynamicTask dynamicTask; |
| 100 | 100 | ||
| 101 | @Autowired | 101 | @Autowired |
| 102 | - private ZLMHttpHookSubscribe subscribe; | 102 | + private ZlmHttpHookSubscribe subscribe; |
| 103 | 103 | ||
| 104 | 104 | ||
| 105 | @Qualifier("taskExecutor") | 105 | @Qualifier("taskExecutor") |
| @@ -110,7 +110,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -110,7 +110,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 110 | 110 | ||
| 111 | @Override | 111 | @Override |
| 112 | public PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, | 112 | public PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, |
| 113 | - ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, | 113 | + ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| 114 | Runnable timeoutCallback) { | 114 | Runnable timeoutCallback) { |
| 115 | if (mediaServerItem == null) { | 115 | if (mediaServerItem == null) { |
| 116 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); | 116 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); |
| @@ -231,8 +231,8 @@ public class PlayServiceImpl implements IPlayService { | @@ -231,8 +231,8 @@ public class PlayServiceImpl implements IPlayService { | ||
| 231 | 231 | ||
| 232 | @Override | 232 | @Override |
| 233 | public void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, | 233 | public void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| 234 | - ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, | ||
| 235 | - InviteTimeOutCallback timeoutCallback, String uuid) { | 234 | + ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| 235 | + InviteTimeOutCallback timeoutCallback, String uuid) { | ||
| 236 | 236 | ||
| 237 | String streamId = null; | 237 | String streamId = null; |
| 238 | if (mediaServerItem.isRtpEnable()) { | 238 | if (mediaServerItem.isRtpEnable()) { |
src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java
| @@ -5,12 +5,11 @@ import com.alibaba.fastjson.JSONObject; | @@ -5,12 +5,11 @@ import com.alibaba.fastjson.JSONObject; | ||
| 5 | import com.genersoft.iot.vmp.conf.DynamicTask; | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 6 | import com.genersoft.iot.vmp.conf.UserSetting; | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | 7 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 8 | -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 8 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 9 | import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; | 9 | import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; |
| 10 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | 10 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 11 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | 11 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| 12 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | 12 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| 13 | -import com.genersoft.iot.vmp.media.zlm.dto.HookType; | ||
| 14 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 13 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 15 | import com.genersoft.iot.vmp.service.IMediaServerService; | 14 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 16 | import com.genersoft.iot.vmp.service.bean.*; | 15 | import com.genersoft.iot.vmp.service.bean.*; |
| @@ -24,9 +23,6 @@ import org.springframework.data.redis.connection.Message; | @@ -24,9 +23,6 @@ import org.springframework.data.redis.connection.Message; | ||
| 24 | import org.springframework.data.redis.connection.MessageListener; | 23 | import org.springframework.data.redis.connection.MessageListener; |
| 25 | import org.springframework.stereotype.Component; | 24 | import org.springframework.stereotype.Component; |
| 26 | 25 | ||
| 27 | -import javax.sip.InvalidArgumentException; | ||
| 28 | -import javax.sip.SipException; | ||
| 29 | -import java.text.ParseException; | ||
| 30 | import java.util.HashMap; | 26 | import java.util.HashMap; |
| 31 | import java.util.Map; | 27 | import java.util.Map; |
| 32 | import java.util.UUID; | 28 | import java.util.UUID; |
| @@ -86,7 +82,7 @@ public class RedisGbPlayMsgListener implements MessageListener { | @@ -86,7 +82,7 @@ public class RedisGbPlayMsgListener implements MessageListener { | ||
| 86 | private ZLMMediaListManager mediaListManager; | 82 | private ZLMMediaListManager mediaListManager; |
| 87 | 83 | ||
| 88 | @Autowired | 84 | @Autowired |
| 89 | - private ZLMHttpHookSubscribe subscribe; | 85 | + private ZlmHttpHookSubscribe subscribe; |
| 90 | 86 | ||
| 91 | 87 | ||
| 92 | public interface PlayMsgCallback{ | 88 | public interface PlayMsgCallback{ |
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
| @@ -8,24 +8,21 @@ import com.genersoft.iot.vmp.conf.SipConfig; | @@ -8,24 +8,21 @@ import com.genersoft.iot.vmp.conf.SipConfig; | ||
| 8 | import com.genersoft.iot.vmp.conf.UserSetting; | 8 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 9 | import com.genersoft.iot.vmp.conf.VersionInfo; | 9 | import com.genersoft.iot.vmp.conf.VersionInfo; |
| 10 | import com.genersoft.iot.vmp.conf.exception.ControllerException; | 10 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 11 | -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; | 11 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 12 | import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; | 12 | import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; |
| 13 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 13 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 14 | import com.genersoft.iot.vmp.service.IMediaServerService; | 14 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 15 | import com.genersoft.iot.vmp.utils.SpringBeanFactory; | 15 | import com.genersoft.iot.vmp.utils.SpringBeanFactory; |
| 16 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; | 16 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 17 | -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | ||
| 18 | import gov.nist.javax.sip.SipStackImpl; | 17 | import gov.nist.javax.sip.SipStackImpl; |
| 19 | 18 | ||
| 20 | import io.swagger.v3.oas.annotations.Operation; | 19 | import io.swagger.v3.oas.annotations.Operation; |
| 21 | import io.swagger.v3.oas.annotations.Parameter; | 20 | import io.swagger.v3.oas.annotations.Parameter; |
| 22 | import io.swagger.v3.oas.annotations.tags.Tag; | 21 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 23 | -import org.ehcache.xml.model.ThreadPoolsType; | ||
| 24 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | import org.springframework.beans.factory.annotation.Value; | 23 | import org.springframework.beans.factory.annotation.Value; |
| 26 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 24 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| 27 | import org.springframework.util.ObjectUtils; | 25 | import org.springframework.util.ObjectUtils; |
| 28 | -import org.springframework.util.StringUtils; | ||
| 29 | import org.springframework.web.bind.annotation.*; | 26 | import org.springframework.web.bind.annotation.*; |
| 30 | 27 | ||
| 31 | import javax.sip.ListeningPoint; | 28 | import javax.sip.ListeningPoint; |
| @@ -42,7 +39,7 @@ import java.util.List; | @@ -42,7 +39,7 @@ import java.util.List; | ||
| 42 | public class ServerController { | 39 | public class ServerController { |
| 43 | 40 | ||
| 44 | @Autowired | 41 | @Autowired |
| 45 | - private ZLMHttpHookSubscribe zlmHttpHookSubscribe; | 42 | + private ZlmHttpHookSubscribe zlmHttpHookSubscribe; |
| 46 | 43 | ||
| 47 | @Autowired | 44 | @Autowired |
| 48 | private IMediaServerService mediaServerService; | 45 | private IMediaServerService mediaServerService; |