From 0ff4ed217de599e6c6336f0330787b7593641dc4 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 17 十月 2022 12:39:58 +0800
Subject: [PATCH] 优化消息处理中存在可能异常的处理流程

---
 src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
index 1c8689b..667dace 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -24,6 +24,8 @@
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
 import org.springframework.web.context.request.async.DeferredResult;
 
 import com.alibaba.fastjson.JSON;
@@ -113,9 +115,6 @@
     @Autowired
     private ThreadPoolTaskExecutor taskExecutor;
 
-    @Value("${server.ssl.enabled}")
-    private boolean sslEnabled;
-
     @Override
     public PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId,
                            ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
@@ -149,7 +148,7 @@
                 if (Objects.requireNonNull(wvpResult).getCode() == 0) {
                     StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData();
                     MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
-                    String streamUrl = sslEnabled ? streamInfoForSuccess.getHttps_fmp4() : streamInfoForSuccess.getFmp4();
+                    String streamUrl = streamInfoForSuccess.getFmp4();
 
                     // 璇锋眰鎴浘
                     logger.info("[璇锋眰鎴浘]: " + fileName);
@@ -408,12 +407,11 @@
         if (device == null) {
             return null;
         }
-        String mediaServerId = device.getMediaServerId();
         MediaServerItem mediaServerItem;
-        if (mediaServerId == null) {
+        if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
             mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
         } else {
-            mediaServerItem = mediaServerService.getOne(mediaServerId);
+            mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
         }
         if (mediaServerItem == null) {
             logger.warn("鐐规挱鏃舵湭鎵惧埌鍙娇鐢ㄧ殑ZLM...");

--
Gitblit v1.8.0