From 3d68b56bb5ecbc3d34b2901c671dc7f1f0f82f74 Mon Sep 17 00:00:00 2001
From: pedoc <pedoc@qq.com>
Date: 星期一, 29 一月 2024 18:05:17 +0800
Subject: [PATCH] 修复未配置sipdomain时出现异常

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
index f018eae..c5be487 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
@@ -2,7 +2,9 @@
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
 import okhttp3.*;
 import okhttp3.logging.HttpLoggingInterceptor;
 import org.jetbrains.annotations.NotNull;
@@ -13,7 +15,9 @@
 
 import java.io.IOException;
 import java.net.ConnectException;
+import java.net.MalformedURLException;
 import java.net.SocketTimeoutException;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -27,8 +31,6 @@
 
 
     private OkHttpClient client;
-
-
 
 
     public interface RequestCallback{
@@ -76,11 +78,11 @@
             logger.warn("鏈惎鐢ˋssist鏈嶅姟");
             return null;
         }
-        StringBuffer stringBuffer = new StringBuffer();
-        stringBuffer.append(String.format("http://%s:%s/%s",  mediaServerItem.getIp(), mediaServerItem.getRecordAssistPort(), api));
+        StringBuilder stringBuffer = new StringBuilder();
+        stringBuffer.append(api);
         JSONObject responseJSON = null;
 
-        if (param != null && param.keySet().size() > 0) {
+        if (param != null && !param.keySet().isEmpty()) {
             stringBuffer.append("?");
             int index = 1;
             for (String key : param.keySet()){
@@ -95,6 +97,7 @@
         }
 
         String url = stringBuffer.toString();
+        logger.info("[璁块棶assist]锛� {}", url);
         Request request = new Request.Builder()
                 .get()
                 .url(url)
@@ -150,13 +153,14 @@
         return responseJSON;
     }
 
-    public JSONObject sendPost(MediaServerItem mediaServerItem, String api, JSONObject param, ZLMRESTfulUtils.RequestCallback callback, Integer readTimeOut) {
+    public JSONObject sendPost(MediaServerItem mediaServerItem, String url,
+                               JSONObject param, ZLMRESTfulUtils.RequestCallback callback,
+                               Integer readTimeOut) {
         OkHttpClient client = getClient(readTimeOut);
 
         if (mediaServerItem == null) {
             return null;
         }
-        String url = String.format("http://%s:%s/%s",  mediaServerItem.getIp(), mediaServerItem.getRecordAssistPort(), api);
         JSONObject responseJSON = new JSONObject();
         //-2鑷畾涔夋祦濯掍綋 璋冪敤閿欒鐮�
         responseJSON.put("code",-2);
@@ -255,20 +259,30 @@
         if (!ObjectUtils.isEmpty(remoteHost)) {
             videoTaskInfoJSON.put("remoteHost", remoteHost);
         }
-
-        return sendPost(mediaServerItem, "api/record/file/download/task/add", videoTaskInfoJSON, null, 30);
+        String urlStr = String.format("%s/api/record/file/download/task/add",  remoteHost);;
+        return sendPost(mediaServerItem, urlStr, videoTaskInfoJSON, null, 30);
     }
 
-    public JSONObject queryTaskList(MediaServerItem mediaServerItem, String taskId, Boolean isEnd) {
+    public JSONObject queryTaskList(MediaServerItem mediaServerItem, String app, String stream, String callId,
+                                    String taskId, Boolean isEnd, String scheme) {
         Map<String, Object> param = new HashMap<>();
+        if (!ObjectUtils.isEmpty(app)) {
+            param.put("app", app);
+        }
+        if (!ObjectUtils.isEmpty(stream)) {
+            param.put("stream", stream);
+        }
+        if (!ObjectUtils.isEmpty(callId)) {
+            param.put("callId", callId);
+        }
         if (!ObjectUtils.isEmpty(taskId)) {
             param.put("taskId", taskId);
         }
         if (!ObjectUtils.isEmpty(isEnd)) {
             param.put("isEnd", isEnd);
         }
-
-        return sendGet(mediaServerItem, "api/record/file/download/task/list", param, null);
+        String urlStr = String.format("%s://%s:%s/api/record/file/download/task/list",
+                scheme, mediaServerItem.getIp(), mediaServerItem.getRecordAssistPort());;
+        return sendGet(mediaServerItem, urlStr, param, null);
     }
-
 }

--
Gitblit v1.8.0