| | |
| | | import com.genersoft.iot.vmp.media.bean.MediaInfo; |
| | | import com.genersoft.iot.vmp.media.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; |
| | | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| | | import com.genersoft.iot.vmp.media.event.HookSubscribe; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.hook.*; |
| | | import com.genersoft.iot.vmp.media.zlm.event.HookZlmServerStartEvent; |
| | |
| | | * ABL服务Hook事件 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/index/hook") |
| | | @RequestMapping("/index/hook/abl") |
| | | public class ABLHttpHookListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(ABLHttpHookListener.class); |
| | |
| | | private ZLMMediaListManager zlmMediaListManager; |
| | | |
| | | @Autowired |
| | | private ZlmHttpHookSubscribe subscribe; |
| | | private HookSubscribe subscribe; |
| | | |
| | | @Autowired |
| | | private UserSetting userSetting; |
| | |
| | | |
| | | taskExecutor.execute(() -> { |
| | | JSONObject json = (JSONObject) JSON.toJSON(param); |
| | | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json); |
| | | HookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json); |
| | | if (subscribe != null) { |
| | | MediaServer mediaInfo = mediaServerService.getOne(mediaServerId); |
| | | if (mediaInfo != null) { |
| | |
| | | HookResultForOnPublish result = HookResultForOnPublish.SUCCESS(); |
| | | result.setEnable_audio(true); |
| | | taskExecutor.execute(() -> { |
| | | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); |
| | | HookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); |
| | | if (subscribe != null) { |
| | | subscribe.response(mediaInfo, param); |
| | | } |
| | |
| | | |
| | | JSONObject json = (JSONObject) JSON.toJSON(param); |
| | | taskExecutor.execute(() -> { |
| | | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); |
| | | HookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); |
| | | MediaServer mediaInfo = mediaServerService.getOne(param.getMediaServerId()); |
| | | if (mediaInfo == null) { |
| | | logger.info("[ABL HOOK] 流变化未找到ABL, {}", param.getMediaServerId()); |
| | |
| | | zlmServerConfig.setIp(request.getRemoteAddr()); |
| | | logger.info("[ABL HOOK] ABL 启动 " + zlmServerConfig.getGeneralMediaServerId()); |
| | | taskExecutor.execute(() -> { |
| | | List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started); |
| | | List<HookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started); |
| | | if (subscribes != null && !subscribes.isEmpty()) { |
| | | for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { |
| | | for (HookSubscribe.Event subscribe : subscribes) { |
| | | subscribe.response(null, zlmServerConfig); |
| | | } |
| | | } |
| | |
| | | logger.info("[ABL HOOK] rtpServer收流超时:{}->{}({})", param.getMediaServerId(), param.getStream_id(), param.getSsrc()); |
| | | |
| | | taskExecutor.execute(() -> { |
| | | List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_rtp_server_timeout); |
| | | List<HookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_rtp_server_timeout); |
| | | if (subscribes != null && !subscribes.isEmpty()) { |
| | | for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { |
| | | for (HookSubscribe.Event subscribe : subscribes) { |
| | | subscribe.response(null, param); |
| | | } |
| | | } |
| | |
| | | logger.info("[AB HOOK] 录像完成事件:{}->{}", param.getMediaServerId(), param.getFile_path()); |
| | | |
| | | taskExecutor.execute(() -> { |
| | | List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_record_mp4); |
| | | List<HookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_record_mp4); |
| | | if (subscribes != null && !subscribes.isEmpty()) { |
| | | for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { |
| | | for (HookSubscribe.Event subscribe : subscribes) { |
| | | subscribe.response(null, param); |
| | | } |
| | | } |