From 6b03568c5dd128a3d71c02fb1a3a76a4344a4920 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期一, 21 十一月 2022 17:07:54 +0800 Subject: [PATCH] 优化rtcp判断 --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java | 33 +++++++++++++++++++++++++++------ 1 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java index 5e0d317..80f2940 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java @@ -1,7 +1,7 @@ package com.genersoft.iot.vmp.media.zlm; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import okhttp3.*; import okhttp3.logging.HttpLoggingInterceptor; @@ -22,6 +22,9 @@ public class ZLMRESTfulUtils { private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class); + + + public interface RequestCallback{ void run(JSONObject response); @@ -75,6 +78,7 @@ if (callback == null) { try { Response response = client.newCall(request).execute(); + if (response.isSuccessful()) { ResponseBody responseBody = response.body(); if (responseBody != null) { @@ -82,6 +86,8 @@ responseJSON = JSON.parseObject(responseStr); } }else { + System.out.println( 2222); + System.out.println( response.code()); response.close(); Objects.requireNonNull(response.body()).close(); } @@ -90,11 +96,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){ @@ -166,7 +172,6 @@ .build(); Response response = client.newCall(request).execute(); if (response.isSuccessful()) { - logger.info("response body contentType: " + Objects.requireNonNull(response.body()).contentType()); if (targetPath != null) { File snapFolder = new File(targetPath); if (!snapFolder.exists()) { @@ -277,6 +282,10 @@ return sendPost(mediaServerItem, "startSendRtp",param, null); } + public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object> param) { + return sendPost(mediaServerItem, "startSendRtpPassive",param, null); + } + public JSONObject stopSendRtp(MediaServerItem mediaServerItem, Map<String, Object> param) { return sendPost(mediaServerItem, "stopSendRtp",param, null); } @@ -322,10 +331,22 @@ } public void getSnap(MediaServerItem mediaServerItem, String flvUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) { - Map<String, Object> param = new HashMap<>(); + Map<String, Object> param = new HashMap<>(3); param.put("url", flvUrl); param.put("timeout_sec", timeout_sec); param.put("expire_sec", expire_sec); sendGetForImg(mediaServerItem, "getSnap", param, targetPath, fileName); } + + public JSONObject pauseRtpCheck(MediaServerItem mediaServerItem, String streamId) { + Map<String, Object> param = new HashMap<>(1); + param.put("stream_id", streamId); + return sendPost(mediaServerItem, "pauseRtpCheck",param, null); + } + + public JSONObject resumeRtpCheck(MediaServerItem mediaServerItem, String streamId) { + Map<String, Object> param = new HashMap<>(1); + param.put("stream_id", streamId); + return sendPost(mediaServerItem, "resumeRtpCheck",param, null); + } } -- Gitblit v1.8.0