From bf8fb0c51f4e7894a62636dede6c69a2a85d8458 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期二, 27 四月 2021 15:35:22 +0800 Subject: [PATCH] 添加级联平台自动注册时失败自动重新注册 --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 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 f62ad32..a864f3c 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 @@ -13,6 +13,7 @@ import java.net.ConnectException; import java.util.HashMap; import java.util.Map; +import java.util.Objects; @Component public class ZLMRESTfulUtils { @@ -40,9 +41,11 @@ FormBody.Builder builder = new FormBody.Builder(); builder.add("secret",mediaSecret); - if (param != null) { + if (param != null && param.keySet().size() > 0) { for (String key : param.keySet()){ - builder.add(key, param.get(key).toString()); + if (param.get(key) != null) { + builder.add(key, param.get(key).toString()); + } } } @@ -65,7 +68,7 @@ logger.error(String.format("杩炴帴ZLM澶辫触: %s, %s", e.getCause().getMessage(), e.getMessage())); logger.info("璇锋鏌edia閰嶇疆骞剁‘璁LM宸插惎鍔�..."); }catch (IOException e) { - e.printStackTrace(); + logger.error(String.format("[ %s ]璇锋眰澶辫触: %s", url, e.getMessage())); } }else { client.newCall(request).enqueue(new Callback(){ @@ -74,14 +77,10 @@ public void onResponse(@NotNull Call call, @NotNull Response response){ if (response.isSuccessful()) { try { - String responseStr = response.body().string(); - if (responseStr != null) { - callback.run(JSON.parseObject(responseStr)); - }else { - callback.run(null); - } + String responseStr = Objects.requireNonNull(response.body()).string(); + callback.run(JSON.parseObject(responseStr)); } catch (IOException e) { - e.printStackTrace(); + logger.error(String.format("[ %s ]璇锋眰澶辫触: %s", url, e.getMessage())); } } } @@ -132,8 +131,8 @@ } public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms){ - System.out.println(src_url); - System.out.println(dst_url); + logger.info(src_url); + logger.info(dst_url); Map<String, Object> param = new HashMap<>(); param.put("src_url", src_url); param.put("dst_url", dst_url); @@ -195,4 +194,14 @@ param.put("force", 1); return sendPost("close_streams",param, null); } + + public JSONObject getAllSession() { + return sendPost("getAllSession",null, null); + } + + public void kickSessions(String localPortSStr) { + Map<String, Object> param = new HashMap<>(); + param.put("local_port", localPortSStr); + sendPost("kick_sessions",param, null); + } } -- Gitblit v1.8.0