Browse Source

添加流IP单独配置

pull/110/head
64850858 4 years ago
parent
commit
57b562d622
  1. 111
      src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
  2. 1
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java
  3. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java
  4. 12
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
  5. 10
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java
  6. 1
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerManger.java
  7. 22
      src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
  8. 4
      src/main/resources/all-application.yml
  9. 2
      src/main/resources/application-dev.yml

111
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 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 getSdpIp() {
return sdpIp;
}
public String getRtpPortRange() {
return rtpPortRange;
public String getStreamIp() {
return streamIp;
}
public void setRtpPortRange(String rtpPortRange) {
this.rtpPortRange = rtpPortRange;
public String getHttpPort() {
return httpPort;
}
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 int getRecordAssistPort() {
return recordAssistPort;
public String getSecret() {
return secret;
}
public void setRecordAssistPort(int recordAssistPort) {
this.recordAssistPort = recordAssistPort;
public String getStreamNoneReaderDelayMS() {
return streamNoneReaderDelayMS;
}
public String getSdpIp() {
if (StringUtils.isEmpty(sdpIp)) {
return ip;
}else {
return sdpIp;
}
public boolean isRtpEnable() {
return rtpEnable;
}
public String getRtpPortRange() {
return rtpPortRange;
}
public void setSdpIp(String sdpIp) {
this.sdpIp = sdpIp;
public int getRecordAssistPort() {
return recordAssistPort;
}
}

1
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;

8
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;
}
}

12
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

10
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;
}
}

1
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());

22
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;
}

4
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

2
src/main/resources/application-dev.yml

@ -42,7 +42,7 @@ sip:
# [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验
password: admin123
#zlm服务器配置
#zlm 默认服务器配置
media:
# [必须修改] zlm服务器的内网IP
ip: 192.168.0.100

Loading…
Cancel
Save