From 6e90050db47ca1d9ecec3de6bd95ea1bd1ca4060 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期一, 29 八月 2022 11:50:36 +0800 Subject: [PATCH] 去除zlm使用redis过期作为心跳超时的方式 --- src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java index 638ea41..4ef1d01 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGbPlayMsgListener.java @@ -8,6 +8,9 @@ import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; +import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; +import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; +import com.genersoft.iot.vmp.media.zlm.dto.HookType; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.bean.*; @@ -63,8 +66,6 @@ @Autowired private UserSetting userSetting; - @Autowired - private RedisUtil redis; @Autowired private ZLMMediaListManager zlmMediaListManager; @@ -224,7 +225,7 @@ WvpRedisMsg response = WvpRedisMsg.getResponseInstance(userSetting.getServerId(), toId, WvpRedisMsgCmd.REQUEST_PUSH_STREAM, serial, result); JSONObject jsonObject = (JSONObject)JSON.toJSON(response); - redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); + RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); } /** @@ -243,7 +244,7 @@ WvpRedisMsgCmd.GET_SEND_ITEM, serial, result); JSONObject jsonObject = (JSONObject)JSON.toJSON(response); - redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); + RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); return; } // 纭畾娴佹槸鍚﹀湪绾� @@ -266,18 +267,13 @@ userSetting.getServerId(), toId, WvpRedisMsgCmd.GET_SEND_ITEM, serial, result ); JSONObject jsonObject = (JSONObject)JSON.toJSON(response); - redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); + RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); }, userSetting.getPlatformPlayTimeout()); // 娣诲姞璁㈤槄 - JSONObject subscribeKey = new JSONObject(); - subscribeKey.put("app", content.getApp()); - subscribeKey.put("stream", content.getStream()); - subscribeKey.put("regist", true); - subscribeKey.put("schema", "rtmp"); - subscribeKey.put("mediaServerId", mediaServerItem.getId()); - subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, - (MediaServerItem mediaServerItemInUse, JSONObject json)->{ + HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed(content.getApp(), content.getStream(), true, "rtsp", mediaServerItem.getId()); + + subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json)->{ dynamicTask.stop(taskKey); responseSendItem(mediaServerItem, content, toId, serial); }); @@ -310,7 +306,7 @@ userSetting.getServerId(), toId, WvpRedisMsgCmd.GET_SEND_ITEM, serial, result ); JSONObject jsonObject = (JSONObject)JSON.toJSON(response); - redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); + RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); } /** @@ -347,7 +343,7 @@ wvpResult.setMsg("timeout"); errorCallback.handler(wvpResult); }, userSetting.getPlatformPlayTimeout()); - redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); + RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); } /** @@ -372,6 +368,6 @@ callbacksForStartSendRtpStream.remove(key); callbacksForError.remove(key); }); - redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); + RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); } } -- Gitblit v1.8.0