panlinlin
2021-04-22 a29a0a0785f966294ba01982fba62c1ff0f23bea
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("请检查media配置并确认ZLM已启动...");
                }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()));
                            }
                        }
                    }
@@ -163,6 +162,10 @@
        return sendPost("closeRtpServer",param, null);
    }
    public JSONObject listRtpServer() {
        return sendPost("listRtpServer",null, null);
    }
    public JSONObject startSendRtp(Map<String, Object> param) {
        return sendPost("startSendRtp",param, null);
    }