diff --git a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java index cd4e90d9..c6b50b02 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java @@ -17,6 +17,9 @@ public class MediaConfig { @Value("${media.sdpIp:${media.ip}}") private String sdpIp; + @Value("${media.streamIp:${media.ip}}") + private String streamIp; + @Value("${media.httpPort}") private String httpPort; @@ -60,135 +63,67 @@ public class MediaConfig { return ip; } - public void setIp(String ip) { - this.ip = ip; - } - public String getHookIp() { return hookIp; } - public void setHookIp(String hookIp) { - this.hookIp = hookIp; + public String getSdpIp() { + return sdpIp; + } + + public String getStreamIp() { + return streamIp; } public String getHttpPort() { return httpPort; } - public void setHttpPort(String httpPort) { - this.httpPort = httpPort; - } - - public boolean isAutoConfig() { - return autoConfig; - } - - public boolean getAutoConfig() { - return autoConfig; - } - - public void setAutoConfig(boolean autoConfig) { - this.autoConfig = autoConfig; - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public String getStreamNoneReaderDelayMS() { - return streamNoneReaderDelayMS; - } - - public void setStreamNoneReaderDelayMS(String streamNoneReaderDelayMS) { - this.streamNoneReaderDelayMS = streamNoneReaderDelayMS; - } - - public boolean isRtpEnable() { - return rtpEnable; - } - - public void setRtpEnable(boolean rtpEnable) { - this.rtpEnable = rtpEnable; - } - - public String getRtpPortRange() { - return rtpPortRange; - } - - public void setRtpPortRange(String rtpPortRange) { - this.rtpPortRange = rtpPortRange; - } - public String getHttpSSlPort() { return httpSSlPort; } - public void setHttpSSlPort(String httpSSlPort) { - this.httpSSlPort = httpSSlPort; - } - public String getRtmpPort() { return rtmpPort; } - public void setRtmpPort(String rtmpPort) { - this.rtmpPort = rtmpPort; - } - public String getRtmpSSlPort() { return rtmpSSlPort; } - public void setRtmpSSlPort(String rtmpSSlPort) { - this.rtmpSSlPort = rtmpSSlPort; - } - public String getRtpProxyPort() { return rtpProxyPort; } - public void setRtpProxyPort(String rtpProxyPort) { - this.rtpProxyPort = rtpProxyPort; - } - public String getRtspPort() { return rtspPort; } - public void setRtspPort(String rtspPort) { - this.rtspPort = rtspPort; - } - public String getRtspSSLPort() { return rtspSSLPort; } - public void setRtspSSLPort(String rtspSSLPort) { - this.rtspSSLPort = rtspSSLPort; + public boolean isAutoConfig() { + return autoConfig; + } + + public String getSecret() { + return secret; + } + + public String getStreamNoneReaderDelayMS() { + return streamNoneReaderDelayMS; + } + + public boolean isRtpEnable() { + return rtpEnable; + } + + public String getRtpPortRange() { + return rtpPortRange; } public int getRecordAssistPort() { return recordAssistPort; } - - public void setRecordAssistPort(int recordAssistPort) { - this.recordAssistPort = recordAssistPort; - } - - public String getSdpIp() { - if (StringUtils.isEmpty(sdpIp)) { - return ip; - }else { - return sdpIp; - } - } - - public void setSdpIp(String sdpIp) { - this.sdpIp = sdpIp; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java index 445f4d2b..413f0d14 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java @@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory; */ public class AckRequestProcessor extends SIPRequestAbstractProcessor { - private Logger logger = LoggerFactory.getLogger(AckRequestProcessor.class); private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java index 3db38139..d990db93 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java @@ -20,10 +20,10 @@ public class NumericUtil { public static boolean isDouble(String str) { try { Double num2 = Double.valueOf(str); - logger.debug(num2 + " is a valid numeric string!"); +// logger.debug(num2 + " is a valid numeric string!"); return true; } catch (Exception e) { - logger.debug(str + " is an invalid numeric string!"); +// logger.debug(str + " is an invalid numeric string!"); return false; } } @@ -36,10 +36,10 @@ public class NumericUtil { public static boolean isInteger(String str) { try { int num2 = Integer.valueOf(str); - logger.debug(num2 + " is an integer!"); +// logger.debug(num2 + " is an integer!"); return true; } catch (Exception e) { - logger.debug(str + " is not an integer!"); +// logger.debug(str + " is not an integer!"); return false; } } 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 d622101e..09fec814 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 @@ -6,8 +6,6 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.conf.MediaConfig; import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -//import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.service.IStreamProxyService; import org.slf4j.Logger; @@ -17,7 +15,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; import java.util.HashMap; import java.util.List; @@ -32,15 +29,9 @@ public class ZLMRunner implements CommandLineRunner { @Autowired private IVideoManagerStorager storager; - @Autowired - private IRedisCatchStorage redisCatchStorage; - @Autowired private MediaConfig mediaConfig; - @Autowired - private SipConfig sipConfig; - @Value("${server.port}") private String serverPort; @@ -106,7 +97,6 @@ public class ZLMRunner implements CommandLineRunner { private void saveZLMConfig() { logger.info("设置zlm..."); - if (StringUtils.isEmpty(mediaConfig.getHookIp())) mediaConfig.setHookIp(sipConfig.getSipIp()); String protocol = sslEnabled ? "https" : "http"; String hookPrex = String.format("%s://%s:%s/index/hook", protocol, mediaConfig.getHookIp(), serverPort); String recordHookPrex = null; @@ -149,7 +139,7 @@ public class ZLMRunner implements CommandLineRunner { logger.info( "[ id: " + zlmServerConfig.getGeneralMediaServerId() + "] zlm接入成功..."); // 关闭循环获取zlm配置 startGetMedia = false; - if (mediaConfig.getAutoConfig()) saveZLMConfig(); + if (mediaConfig.isAutoConfig()) saveZLMConfig(); zlmServerManger.updateServerCatch(zlmServerConfig); // 清空所有session diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java index 10b368cf..270a6328 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java @@ -39,6 +39,8 @@ public class ZLMServerConfig { private String sdpIp; + private String streamIp; + private long updateTime; @JSONField(name = "hls.fileBufSize") @@ -765,4 +767,12 @@ public class ZLMServerConfig { public void setSdpIp(String sdpIp) { this.sdpIp = sdpIp; } + + public String getStreamIp() { + return streamIp; + } + + public void setStreamIp(String streamIp) { + this.streamIp = streamIp; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java index 40189933..3770d80b 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java @@ -19,6 +19,7 @@ public class ZLMServerManger { public void updateServerCatch(ZLMServerConfig zlmServerConfig) { zlmServerConfig.setIp(mediaConfig.getIp()); + zlmServerConfig.setStreamIp(mediaConfig.getStreamIp()); zlmServerConfig.setSdpIp(mediaConfig.getSdpIp()); zlmServerConfig.setHttpPort(mediaConfig.getHttpPort()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java index 19cba05e..4855d1d8 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java @@ -32,17 +32,17 @@ public class MediaServiceImpl implements IMediaService { StreamInfo streamInfoResult = new StreamInfo(); streamInfoResult.setStreamId(stream); streamInfoResult.setApp(app); - streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", mediaInfo.getIp(), mediaInfo.getRtmpPort(), app, stream)); - streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", mediaInfo.getIp(), mediaInfo.getRtspPort(), app, stream)); - streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.flv", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); - streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.flv", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); - streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); - streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); - streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); - streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); - streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); - streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); - streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", mediaInfo.getStreamIp(), mediaInfo.getRtmpPort(), app, stream)); + streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", mediaInfo.getStreamIp(), mediaInfo.getRtspPort(), app, stream)); + streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.flv", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.flv", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); + streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); streamInfoResult.setTracks(tracks); return streamInfoResult; } diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index 804da1db..e2683751 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -68,10 +68,12 @@ sip: # [可选] 心跳超时时间, 建议设置为心跳周期的三倍 keepaliveTimeOut: 180 -#zlm服务器配置 +#zlm 默认服务器配置 media: # [必须修改] zlm服务器的内网IP ip: 192.168.0.100 + # [可选] 返回流地址时的ip,置空使用 media.ip + streamIp: # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip sdpIp: # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index b70bce41..96f7f6af 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -42,7 +42,7 @@ sip: # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 password: admin123 -#zlm服务器配置 +#zlm 默认服务器配置 media: # [必须修改] zlm服务器的内网IP ip: 192.168.0.100