From cbd2bc8e99a20d1ff65fb1171961e86c790ab024 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 10 三月 2021 09:35:20 +0800 Subject: [PATCH] Merge pull request #63 from lawrencehj/wvp-28181-2.0 --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java | 37 ++++++++++++++++++++----------------- 1 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java index fc519da..490bfd8 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java @@ -4,8 +4,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.conf.MediaServerConfig; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; -import okhttp3.*; +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; +//import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -15,9 +15,6 @@ import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; @@ -27,14 +24,20 @@ private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class); + // @Autowired + // private IVideoManagerStorager storager; + @Autowired - private IVideoManagerStorager storager; + private IRedisCatchStorage redisCatchStorage; @Value("${media.ip}") private String mediaIp; @Value("${media.wanIp}") private String mediaWanIp; + + @Value("${media.hookIp}") + private String mediaHookIp; @Value("${media.port}") private int mediaPort; @@ -51,6 +54,9 @@ @Value("${server.port}") private String serverPort; + @Value("${media.autoConfig}") + private boolean autoConfig; + @Autowired private ZLMRESTfulUtils zlmresTfulUtils; @@ -61,15 +67,11 @@ MediaServerConfig mediaServerConfig = getMediaServerConfig(); if (mediaServerConfig != null) { logger.info("zlm鎺ュ叆鎴愬姛..."); - logger.info("璁剧疆zlm..."); - saveZLMConfig(); + if (autoConfig) saveZLMConfig(); mediaServerConfig = getMediaServerConfig(); - storager.updateMediaInfo(mediaServerConfig); - + redisCatchStorage.updateMediaInfo(mediaServerConfig); } } - - public MediaServerConfig getMediaServerConfig() { JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(); @@ -94,14 +96,15 @@ } private void saveZLMConfig() { - String hookIP = sipIP; - if (mediaIp.equals(sipIP)) { - hookIP = "127.0.0.1"; + logger.info("璁剧疆zlm..."); + if (StringUtils.isEmpty(mediaHookIp)) { + mediaHookIp = sipIP; } - String hookPrex = String.format("http://%s:%s/index/hook", hookIP, serverPort); + String hookPrex = String.format("http://%s:%s/index/hook", mediaHookIp, serverPort); Map<String, Object> param = new HashMap<>(); - param.put("secret",mediaSecret); + param.put("api.secret",mediaSecret); // -profile:v Baseline + param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s"); param.put("hook.enable","1"); param.put("hook.on_flow_report",""); param.put("hook.on_play",""); -- Gitblit v1.8.0