648540858
2024-05-29 764d04b497356ba6bcbb75fd42b51eca750f7223
src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
@@ -2,9 +2,8 @@
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 com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.utils.SSLSocketClientUtil;
import okhttp3.*;
import okhttp3.logging.HttpLoggingInterceptor;
import org.jetbrains.annotations.NotNull;
@@ -13,11 +12,10 @@
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import javax.net.ssl.X509TrustManager;
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;
@@ -40,7 +38,7 @@
    private OkHttpClient getClient(){
        return getClient(null);
    }
    private OkHttpClient getClient(Integer readTimeOut){
        if (client == null) {
            if (readTimeOut == null) {
@@ -61,6 +59,10 @@
                // OkHttp進行添加攔截器loggingInterceptor
                httpClientBuilder.addInterceptor(logging);
            }
            X509TrustManager manager = SSLSocketClientUtil.getX509TrustManager();
            // 设置ssl
            httpClientBuilder.sslSocketFactory(SSLSocketClientUtil.getSocketFactory(manager), manager);
            httpClientBuilder.hostnameVerifier(SSLSocketClientUtil.getHostnameVerifier());//忽略校验
            client = httpClientBuilder.build();
        }
        return client;
@@ -68,7 +70,7 @@
    }
    public JSONObject sendGet(MediaServerItem mediaServerItem, String api, Map<String, Object> param, RequestCallback callback) {
    public JSONObject sendGet(MediaServer mediaServerItem, String api, Map<String, Object> param, RequestCallback callback) {
        OkHttpClient client = getClient();
        if (mediaServerItem == null) {
@@ -153,7 +155,7 @@
        return responseJSON;
    }
    public JSONObject sendPost(MediaServerItem mediaServerItem, String url,
    public JSONObject sendPost(MediaServer mediaServerItem, String url,
                               JSONObject param, ZLMRESTfulUtils.RequestCallback callback,
                               Integer readTimeOut) {
        OkHttpClient client = getClient(readTimeOut);
@@ -242,14 +244,14 @@
        return responseJSON;
    }
    public JSONObject getInfo(MediaServerItem mediaServerItem, RequestCallback callback){
    public JSONObject getInfo(MediaServer mediaServerItem, RequestCallback callback){
        Map<String, Object> param = new HashMap<>();
        return sendGet(mediaServerItem, "api/record/info",param, callback);
    }
    public JSONObject addTask(MediaServerItem mediaServerItem, String app, String stream, String startTime,
    public JSONObject addTask(MediaServer mediaServerItem, String app, String stream, String startTime,
                              String endTime, String callId, List<String> filePathList, String remoteHost) {
        JSONObject videoTaskInfoJSON = new JSONObject();
        videoTaskInfoJSON.put("app", app);
        videoTaskInfoJSON.put("stream", stream);
@@ -264,7 +266,7 @@
        return sendPost(mediaServerItem, urlStr, videoTaskInfoJSON, null, 30);
    }
    public JSONObject queryTaskList(MediaServerItem mediaServerItem, String app, String stream, String callId,
    public JSONObject queryTaskList(MediaServer mediaServerItem, String app, String stream, String callId,
                                    String taskId, Boolean isEnd, String scheme) {
        Map<String, Object> param = new HashMap<>();
        if (!ObjectUtils.isEmpty(app)) {