From 381b3d15caa30e99c75f58a366b3b75cbbf01450 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 07 十二月 2021 11:40:17 +0800 Subject: [PATCH] 修复未结束的推流无法下载 --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java index c77bd80..f53c167 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java @@ -3,7 +3,6 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.MediaConfig; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; @@ -11,9 +10,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; import java.util.*; @@ -41,8 +42,13 @@ @Autowired private MediaConfig mediaConfig; + @Qualifier("taskExecutor") + @Autowired + private ThreadPoolTaskExecutor taskExecutor; + @Override public void run(String... strings) throws Exception { + mediaServerService.clearMediaServerForOnline(); if (mediaServerService.getDefaultMediaServer() == null) { mediaServerService.addToDatabase(mediaConfig.getMediaSerItem()); } @@ -52,10 +58,15 @@ (MediaServerItem mediaServerItem, JSONObject response)->{ ZLMServerConfig zlmServerConfig = JSONObject.toJavaObject(response, ZLMServerConfig.class); if (zlmServerConfig !=null ) { - startGetMedia.remove(zlmServerConfig.getGeneralMediaServerId()); + if (startGetMedia != null) { + startGetMedia.remove(zlmServerConfig.getGeneralMediaServerId()); + } mediaServerService.handLeZLMServerConfig(zlmServerConfig); } }); + + // TODO 璁㈤槄 zlm淇濇椿浜嬩欢, 褰搝lm绂荤嚎鏃跺仛涓氬姟鐨勫鐞� + // 鑾峰彇zlm淇℃伅 logger.info("绛夊緟榛樿zlm鎺ュ叆..."); @@ -68,7 +79,9 @@ for (MediaServerItem mediaServerItem : all) { if (startGetMedia == null) startGetMedia = new HashMap<>(); startGetMedia.put(mediaServerItem.getId(), true); - connectZlmServer(mediaServerItem); + taskExecutor.execute(()->{ + connectZlmServer(mediaServerItem); + }); } Timer timer = new Timer(); // 2鍒嗛挓鍚庢湭杩炴帴鍒板垯涓嶅啀鍘讳富鍔ㄨ繛鎺�, TODO 骞跺閲嶅惎鍓嶄娇鐢ㄦ鍦▃lm鐨勯�氶亾鍙戦�乥ye -- Gitblit v1.8.0