Commit 57b562d622f3e9ac59372349efadbc56e66e80fa
1 parent
c8260812
添加流IP单独配置
Showing
9 changed files
with
54 additions
and
117 deletions
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
| ... | ... | @@ -17,6 +17,9 @@ public class MediaConfig { |
| 17 | 17 | @Value("${media.sdpIp:${media.ip}}") |
| 18 | 18 | private String sdpIp; |
| 19 | 19 | |
| 20 | + @Value("${media.streamIp:${media.ip}}") | |
| 21 | + private String streamIp; | |
| 22 | + | |
| 20 | 23 | @Value("${media.httpPort}") |
| 21 | 24 | private String httpPort; |
| 22 | 25 | |
| ... | ... | @@ -60,135 +63,67 @@ public class MediaConfig { |
| 60 | 63 | return ip; |
| 61 | 64 | } |
| 62 | 65 | |
| 63 | - public void setIp(String ip) { | |
| 64 | - this.ip = ip; | |
| 65 | - } | |
| 66 | - | |
| 67 | 66 | public String getHookIp() { |
| 68 | 67 | return hookIp; |
| 69 | 68 | } |
| 70 | 69 | |
| 71 | - public void setHookIp(String hookIp) { | |
| 72 | - this.hookIp = hookIp; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public String getHttpPort() { | |
| 76 | - return httpPort; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public void setHttpPort(String httpPort) { | |
| 80 | - this.httpPort = httpPort; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public boolean isAutoConfig() { | |
| 84 | - return autoConfig; | |
| 85 | - } | |
| 86 | - | |
| 87 | - public boolean getAutoConfig() { | |
| 88 | - return autoConfig; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public void setAutoConfig(boolean autoConfig) { | |
| 92 | - this.autoConfig = autoConfig; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public String getSecret() { | |
| 96 | - return secret; | |
| 97 | - } | |
| 98 | - | |
| 99 | - public void setSecret(String secret) { | |
| 100 | - this.secret = secret; | |
| 101 | - } | |
| 102 | - | |
| 103 | - public String getStreamNoneReaderDelayMS() { | |
| 104 | - return streamNoneReaderDelayMS; | |
| 105 | - } | |
| 106 | - | |
| 107 | - public void setStreamNoneReaderDelayMS(String streamNoneReaderDelayMS) { | |
| 108 | - this.streamNoneReaderDelayMS = streamNoneReaderDelayMS; | |
| 109 | - } | |
| 110 | - | |
| 111 | - public boolean isRtpEnable() { | |
| 112 | - return rtpEnable; | |
| 113 | - } | |
| 114 | - | |
| 115 | - public void setRtpEnable(boolean rtpEnable) { | |
| 116 | - this.rtpEnable = rtpEnable; | |
| 70 | + public String getSdpIp() { | |
| 71 | + return sdpIp; | |
| 117 | 72 | } |
| 118 | 73 | |
| 119 | - public String getRtpPortRange() { | |
| 120 | - return rtpPortRange; | |
| 74 | + public String getStreamIp() { | |
| 75 | + return streamIp; | |
| 121 | 76 | } |
| 122 | 77 | |
| 123 | - public void setRtpPortRange(String rtpPortRange) { | |
| 124 | - this.rtpPortRange = rtpPortRange; | |
| 78 | + public String getHttpPort() { | |
| 79 | + return httpPort; | |
| 125 | 80 | } |
| 126 | 81 | |
| 127 | 82 | public String getHttpSSlPort() { |
| 128 | 83 | return httpSSlPort; |
| 129 | 84 | } |
| 130 | 85 | |
| 131 | - public void setHttpSSlPort(String httpSSlPort) { | |
| 132 | - this.httpSSlPort = httpSSlPort; | |
| 133 | - } | |
| 134 | - | |
| 135 | 86 | public String getRtmpPort() { |
| 136 | 87 | return rtmpPort; |
| 137 | 88 | } |
| 138 | 89 | |
| 139 | - public void setRtmpPort(String rtmpPort) { | |
| 140 | - this.rtmpPort = rtmpPort; | |
| 141 | - } | |
| 142 | - | |
| 143 | 90 | public String getRtmpSSlPort() { |
| 144 | 91 | return rtmpSSlPort; |
| 145 | 92 | } |
| 146 | 93 | |
| 147 | - public void setRtmpSSlPort(String rtmpSSlPort) { | |
| 148 | - this.rtmpSSlPort = rtmpSSlPort; | |
| 149 | - } | |
| 150 | - | |
| 151 | 94 | public String getRtpProxyPort() { |
| 152 | 95 | return rtpProxyPort; |
| 153 | 96 | } |
| 154 | 97 | |
| 155 | - public void setRtpProxyPort(String rtpProxyPort) { | |
| 156 | - this.rtpProxyPort = rtpProxyPort; | |
| 157 | - } | |
| 158 | - | |
| 159 | 98 | public String getRtspPort() { |
| 160 | 99 | return rtspPort; |
| 161 | 100 | } |
| 162 | 101 | |
| 163 | - public void setRtspPort(String rtspPort) { | |
| 164 | - this.rtspPort = rtspPort; | |
| 165 | - } | |
| 166 | - | |
| 167 | 102 | public String getRtspSSLPort() { |
| 168 | 103 | return rtspSSLPort; |
| 169 | 104 | } |
| 170 | 105 | |
| 171 | - public void setRtspSSLPort(String rtspSSLPort) { | |
| 172 | - this.rtspSSLPort = rtspSSLPort; | |
| 106 | + public boolean isAutoConfig() { | |
| 107 | + return autoConfig; | |
| 173 | 108 | } |
| 174 | 109 | |
| 175 | - public int getRecordAssistPort() { | |
| 176 | - return recordAssistPort; | |
| 110 | + public String getSecret() { | |
| 111 | + return secret; | |
| 177 | 112 | } |
| 178 | 113 | |
| 179 | - public void setRecordAssistPort(int recordAssistPort) { | |
| 180 | - this.recordAssistPort = recordAssistPort; | |
| 114 | + public String getStreamNoneReaderDelayMS() { | |
| 115 | + return streamNoneReaderDelayMS; | |
| 181 | 116 | } |
| 182 | 117 | |
| 183 | - public String getSdpIp() { | |
| 184 | - if (StringUtils.isEmpty(sdpIp)) { | |
| 185 | - return ip; | |
| 186 | - }else { | |
| 187 | - return sdpIp; | |
| 188 | - } | |
| 118 | + public boolean isRtpEnable() { | |
| 119 | + return rtpEnable; | |
| 120 | + } | |
| 121 | + | |
| 122 | + public String getRtpPortRange() { | |
| 123 | + return rtpPortRange; | |
| 189 | 124 | } |
| 190 | 125 | |
| 191 | - public void setSdpIp(String sdpIp) { | |
| 192 | - this.sdpIp = sdpIp; | |
| 126 | + public int getRecordAssistPort() { | |
| 127 | + return recordAssistPort; | |
| 193 | 128 | } |
| 194 | 129 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java
| ... | ... | @@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory; |
| 24 | 24 | */ |
| 25 | 25 | public class AckRequestProcessor extends SIPRequestAbstractProcessor { |
| 26 | 26 | |
| 27 | - | |
| 28 | 27 | private Logger logger = LoggerFactory.getLogger(AckRequestProcessor.class); |
| 29 | 28 | |
| 30 | 29 | private IRedisCatchStorage redisCatchStorage; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java
| ... | ... | @@ -20,10 +20,10 @@ public class NumericUtil { |
| 20 | 20 | public static boolean isDouble(String str) { |
| 21 | 21 | try { |
| 22 | 22 | Double num2 = Double.valueOf(str); |
| 23 | - logger.debug(num2 + " is a valid numeric string!"); | |
| 23 | +// logger.debug(num2 + " is a valid numeric string!"); | |
| 24 | 24 | return true; |
| 25 | 25 | } catch (Exception e) { |
| 26 | - logger.debug(str + " is an invalid numeric string!"); | |
| 26 | +// logger.debug(str + " is an invalid numeric string!"); | |
| 27 | 27 | return false; |
| 28 | 28 | } |
| 29 | 29 | } |
| ... | ... | @@ -36,10 +36,10 @@ public class NumericUtil { |
| 36 | 36 | public static boolean isInteger(String str) { |
| 37 | 37 | try { |
| 38 | 38 | int num2 = Integer.valueOf(str); |
| 39 | - logger.debug(num2 + " is an integer!"); | |
| 39 | +// logger.debug(num2 + " is an integer!"); | |
| 40 | 40 | return true; |
| 41 | 41 | } catch (Exception e) { |
| 42 | - logger.debug(str + " is not an integer!"); | |
| 42 | +// logger.debug(str + " is not an integer!"); | |
| 43 | 43 | return false; |
| 44 | 44 | } |
| 45 | 45 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| ... | ... | @@ -6,8 +6,6 @@ import com.alibaba.fastjson.JSONObject; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 7 | 7 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 8 | 8 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 9 | -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | |
| 10 | -//import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | |
| 11 | 9 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 12 | 10 | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| 13 | 11 | import org.slf4j.Logger; |
| ... | ... | @@ -17,7 +15,6 @@ import org.springframework.beans.factory.annotation.Value; |
| 17 | 15 | import org.springframework.boot.CommandLineRunner; |
| 18 | 16 | import org.springframework.core.annotation.Order; |
| 19 | 17 | import org.springframework.stereotype.Component; |
| 20 | -import org.springframework.util.StringUtils; | |
| 21 | 18 | |
| 22 | 19 | import java.util.HashMap; |
| 23 | 20 | import java.util.List; |
| ... | ... | @@ -33,14 +30,8 @@ public class ZLMRunner implements CommandLineRunner { |
| 33 | 30 | private IVideoManagerStorager storager; |
| 34 | 31 | |
| 35 | 32 | @Autowired |
| 36 | - private IRedisCatchStorage redisCatchStorage; | |
| 37 | - | |
| 38 | - @Autowired | |
| 39 | 33 | private MediaConfig mediaConfig; |
| 40 | 34 | |
| 41 | - @Autowired | |
| 42 | - private SipConfig sipConfig; | |
| 43 | - | |
| 44 | 35 | @Value("${server.port}") |
| 45 | 36 | private String serverPort; |
| 46 | 37 | |
| ... | ... | @@ -106,7 +97,6 @@ public class ZLMRunner implements CommandLineRunner { |
| 106 | 97 | |
| 107 | 98 | private void saveZLMConfig() { |
| 108 | 99 | logger.info("设置zlm..."); |
| 109 | - if (StringUtils.isEmpty(mediaConfig.getHookIp())) mediaConfig.setHookIp(sipConfig.getSipIp()); | |
| 110 | 100 | String protocol = sslEnabled ? "https" : "http"; |
| 111 | 101 | String hookPrex = String.format("%s://%s:%s/index/hook", protocol, mediaConfig.getHookIp(), serverPort); |
| 112 | 102 | String recordHookPrex = null; |
| ... | ... | @@ -149,7 +139,7 @@ public class ZLMRunner implements CommandLineRunner { |
| 149 | 139 | logger.info( "[ id: " + zlmServerConfig.getGeneralMediaServerId() + "] zlm接入成功..."); |
| 150 | 140 | // 关闭循环获取zlm配置 |
| 151 | 141 | startGetMedia = false; |
| 152 | - if (mediaConfig.getAutoConfig()) saveZLMConfig(); | |
| 142 | + if (mediaConfig.isAutoConfig()) saveZLMConfig(); | |
| 153 | 143 | zlmServerManger.updateServerCatch(zlmServerConfig); |
| 154 | 144 | |
| 155 | 145 | // 清空所有session | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java
| ... | ... | @@ -39,6 +39,8 @@ public class ZLMServerConfig { |
| 39 | 39 | |
| 40 | 40 | private String sdpIp; |
| 41 | 41 | |
| 42 | + private String streamIp; | |
| 43 | + | |
| 42 | 44 | private long updateTime; |
| 43 | 45 | |
| 44 | 46 | @JSONField(name = "hls.fileBufSize") |
| ... | ... | @@ -765,4 +767,12 @@ public class ZLMServerConfig { |
| 765 | 767 | public void setSdpIp(String sdpIp) { |
| 766 | 768 | this.sdpIp = sdpIp; |
| 767 | 769 | } |
| 770 | + | |
| 771 | + public String getStreamIp() { | |
| 772 | + return streamIp; | |
| 773 | + } | |
| 774 | + | |
| 775 | + public void setStreamIp(String streamIp) { | |
| 776 | + this.streamIp = streamIp; | |
| 777 | + } | |
| 768 | 778 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java
| ... | ... | @@ -19,6 +19,7 @@ public class ZLMServerManger { |
| 19 | 19 | public void updateServerCatch(ZLMServerConfig zlmServerConfig) { |
| 20 | 20 | |
| 21 | 21 | zlmServerConfig.setIp(mediaConfig.getIp()); |
| 22 | + zlmServerConfig.setStreamIp(mediaConfig.getStreamIp()); | |
| 22 | 23 | zlmServerConfig.setSdpIp(mediaConfig.getSdpIp()); |
| 23 | 24 | zlmServerConfig.setHttpPort(mediaConfig.getHttpPort()); |
| 24 | 25 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
| ... | ... | @@ -32,17 +32,17 @@ public class MediaServiceImpl implements IMediaService { |
| 32 | 32 | StreamInfo streamInfoResult = new StreamInfo(); |
| 33 | 33 | streamInfoResult.setStreamId(stream); |
| 34 | 34 | streamInfoResult.setApp(app); |
| 35 | - streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", mediaInfo.getIp(), mediaInfo.getRtmpPort(), app, stream)); | |
| 36 | - streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", mediaInfo.getIp(), mediaInfo.getRtspPort(), app, stream)); | |
| 37 | - streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.flv", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 38 | - streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.flv", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 39 | - streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 40 | - streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 41 | - streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 42 | - streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 43 | - streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 44 | - streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 45 | - streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 35 | + streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s", mediaInfo.getStreamIp(), mediaInfo.getRtmpPort(), app, stream)); | |
| 36 | + streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s", mediaInfo.getStreamIp(), mediaInfo.getRtspPort(), app, stream)); | |
| 37 | + streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.flv", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 38 | + streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.flv", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 39 | + streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 40 | + streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 41 | + streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 42 | + streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 43 | + streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 44 | + streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 45 | + streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream)); | |
| 46 | 46 | streamInfoResult.setTracks(tracks); |
| 47 | 47 | return streamInfoResult; |
| 48 | 48 | } | ... | ... |
src/main/resources/all-application.yml
| ... | ... | @@ -68,10 +68,12 @@ sip: |
| 68 | 68 | # [可选] 心跳超时时间, 建议设置为心跳周期的三倍 |
| 69 | 69 | keepaliveTimeOut: 180 |
| 70 | 70 | |
| 71 | -#zlm服务器配置 | |
| 71 | +#zlm 默认服务器配置 | |
| 72 | 72 | media: |
| 73 | 73 | # [必须修改] zlm服务器的内网IP |
| 74 | 74 | ip: 192.168.0.100 |
| 75 | + # [可选] 返回流地址时的ip,置空使用 media.ip | |
| 76 | + streamIp: | |
| 75 | 77 | # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 置空使用 media.ip |
| 76 | 78 | sdpIp: |
| 77 | 79 | # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip | ... | ... |