648540858
2023-08-17 d9cfe061b9b501511f5d769f751c8ff6bbcb1bf9
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
@@ -87,6 +87,7 @@
            if (callback == null) {
                try {
                    Response response = client.newCall(request).execute();
                    if (response.isSuccessful()) {
                        ResponseBody responseBody = response.body();
                        if (responseBody != null) {
@@ -94,6 +95,8 @@
                            responseJSON = JSON.parseObject(responseStr);
                        }
                    }else {
                        System.out.println( 2222);
                        System.out.println( response.code());
                        response.close();
                        Objects.requireNonNull(response.body()).close();
                    }
@@ -102,11 +105,11 @@
                    if(e instanceof SocketTimeoutException){
                        //读取超时超时异常
                        logger.error(String.format("读取ZLM数据失败: %s, %s", url, e.getMessage()));
                        logger.error(String.format("读取ZLM数据超时失败: %s, %s", url, e.getMessage()));
                    }
                    if(e instanceof ConnectException){
                        //判断连接异常,我这里是报Failed to connect to 10.7.5.144
                        logger.error(String.format("连接ZLM失败: %s, %s", url, e.getMessage()));
                        logger.error(String.format("连接ZLM连接失败: %s, %s", url, e.getMessage()));
                    }
                }catch (Exception e){
@@ -192,10 +195,10 @@
                } else {
                    logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message()));
                }
                Objects.requireNonNull(response.body()).close();
            } else {
                logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message()));
            }
            Objects.requireNonNull(response.body()).close();
        } catch (ConnectException e) {
            logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage()));
            logger.info("请检查media配置并确认ZLM已启动...");
@@ -270,11 +273,6 @@
    }
    public JSONObject openRtpServer(MediaServerItem mediaServerItem, Map<String, Object> param){
        System.out.println("==============openRtpServer=================");
        for (String s : param.keySet()) {
            System.out.println(s + "-->" + param.get(s));
        }
        System.out.println("===============================");
        return sendPost(mediaServerItem, "openRtpServer",param, null);
    }
@@ -294,6 +292,14 @@
        return sendPost(mediaServerItem, "startSendRtp",param, null);
    }
    public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object> param) {
        return sendPost(mediaServerItem, "startSendRtpPassive",param, null);
    }
    public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object> param, RequestCallback callback) {
        return sendPost(mediaServerItem, "startSendRtpPassive",param, callback);
    }
    public JSONObject stopSendRtp(MediaServerItem mediaServerItem, Map<String, Object> param) {
        return sendPost(mediaServerItem, "stopSendRtp",param, null);
    }