From 86a701ce885871d2468ec31eb13be5595673a01b Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 28 三月 2024 10:24:13 +0800
Subject: [PATCH] Merge branch 'master' into dev/abl支持
---
src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java | 73 ++++++++++++++++++++++++++++++++----
1 files changed, 64 insertions(+), 9 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java
index de68662..b76f59e 100755
--- a/src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/abl/ABLRESTfulUtils.java
@@ -116,15 +116,15 @@
if(e instanceof SocketTimeoutException){
//璇诲彇瓒呮椂瓒呮椂寮傚父
- logger.error(String.format("璇诲彇ZLM鏁版嵁瓒呮椂澶辫触: %s, %s", url, e.getMessage()));
+ logger.error(String.format("璇诲彇ABL鏁版嵁瓒呮椂澶辫触: %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("杩炴帴ABL杩炴帴澶辫触: %s, %s", url, e.getMessage()));
}
}catch (Exception e){
- logger.error(String.format("璁块棶ZLM澶辫触: %s, %s", url, e.getMessage()));
+ logger.error(String.format("璁块棶ABL澶辫触: %s, %s", url, e.getMessage()));
}
}else {
client.newCall(request).enqueue(new Callback(){
@@ -147,19 +147,71 @@
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
- logger.error(String.format("杩炴帴ZLM澶辫触: %s, %s", call.request().toString(), e.getMessage()));
+ logger.error(String.format("杩炴帴ABL澶辫触: %s, %s", call.request().toString(), e.getMessage()));
if(e instanceof SocketTimeoutException){
//璇诲彇瓒呮椂瓒呮椂寮傚父
- logger.error(String.format("璇诲彇ZLM鏁版嵁澶辫触: %s, %s", call.request().toString(), e.getMessage()));
+ logger.error(String.format("璇诲彇ABL鏁版嵁澶辫触: %s, %s", call.request().toString(), e.getMessage()));
}
if(e instanceof ConnectException){
//鍒ゆ柇杩炴帴寮傚父锛屾垜杩欓噷鏄姤Failed to connect to 10.7.5.144
- logger.error(String.format("杩炴帴ZLM澶辫触: %s, %s", call.request().toString(), e.getMessage()));
+ logger.error(String.format("杩炴帴ABL澶辫触: %s, %s", call.request().toString(), e.getMessage()));
}
}
});
}
+
+
+
+ return responseJSON;
+ }
+
+ public JSONObject sendGet(MediaServer mediaServerItem, String api, Map<String, Object> param) {
+ OkHttpClient client = getClient();
+
+ if (mediaServerItem == null) {
+ return null;
+ }
+ JSONObject responseJSON = null;
+ StringBuilder stringBuffer = new StringBuilder();
+ stringBuffer.append(String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api));
+ if (param != null && !param.keySet().isEmpty()) {
+ stringBuffer.append("?secret=").append(mediaServerItem.getSecret()).append("&");
+ int index = 1;
+ for (String key : param.keySet()){
+ if (param.get(key) != null) {
+ stringBuffer.append(key + "=" + param.get(key));
+ if (index < param.size()) {
+ stringBuffer.append("&");
+ }
+ }
+ index++;
+ }
+ }
+ String url = stringBuffer.toString();
+ logger.info("[璁块棶ABL]锛� {}", url);
+ Request request = new Request.Builder()
+ .get()
+ .url(url)
+ .build();
+ try {
+ Response response = client.newCall(request).execute();
+ if (response.isSuccessful()) {
+ ResponseBody responseBody = response.body();
+ if (responseBody != null) {
+ String responseStr = responseBody.string();
+ responseJSON = JSON.parseObject(responseStr);
+ }
+ }else {
+ response.close();
+ Objects.requireNonNull(response.body()).close();
+ }
+ } catch (ConnectException e) {
+ logger.error(String.format("杩炴帴ABL澶辫触: %s, %s", e.getCause().getMessage(), e.getMessage()));
+ logger.info("璇锋鏌edia閰嶇疆骞剁‘璁BL宸插惎鍔�...");
+ }catch (IOException e) {
+ logger.error(String.format("[ %s ]璇锋眰澶辫触: %s", url, e.getMessage()));
+ }
@@ -211,8 +263,8 @@
}
Objects.requireNonNull(response.body()).close();
} catch (ConnectException e) {
- logger.error(String.format("杩炴帴ZLM澶辫触: %s, %s", e.getCause().getMessage(), e.getMessage()));
- logger.info("璇锋鏌edia閰嶇疆骞剁‘璁LM宸插惎鍔�...");
+ logger.error(String.format("杩炴帴ABL澶辫触: %s, %s", e.getCause().getMessage(), e.getMessage()));
+ logger.info("璇锋鏌edia閰嶇疆骞剁‘璁BL宸插惎鍔�...");
} catch (IOException e) {
logger.error(String.format("[ %s ]璇锋眰澶辫触: %s", url, e.getMessage()));
}
@@ -286,7 +338,10 @@
}
public JSONObject setConfigParamValue(MediaServer mediaServerItem, String key, Object value){
- return sendPost(mediaServerItem,"setConfigParamValue", param, null);
+ Map<String, Object> param = new HashMap<>();
+ param.put("key", key);
+ param.put("value", value);
+ return sendGet(mediaServerItem,"setConfigParamValue", param);
}
public JSONObject openRtpServer(MediaServer mediaServerItem, Map<String, Object> param){
--
Gitblit v1.8.0