|  |  | 
 |  |  | package com.genersoft.iot.vmp.conf; | 
 |  |  |  | 
 |  |  | import io.netty.util.internal.StringUtil; | 
 |  |  | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.context.annotation.Configuration; | 
 |  |  | import org.springframework.util.StringUtils; | 
 |  |  |  | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.util.Date; | 
 |  |  |  | 
 |  |  | @Configuration("mediaConfig") | 
 |  |  | public class MediaConfig { | 
 |  |  | public class MediaConfig{ | 
 |  |  |  | 
 |  |  |     @Value("${media.id:}") | 
 |  |  |     private String id; | 
 |  |  |  | 
 |  |  |     @Value("${media.ip}") | 
 |  |  |     private String ip; | 
 |  |  |  | 
 |  |  |     @Value("${media.hookIp:${sip.ip}}") | 
 |  |  |     @Value("${media.hook-ip:${sip.ip}}") | 
 |  |  |     private String hookIp; | 
 |  |  |  | 
 |  |  |     @Value("${sip.ip}") | 
 |  |  |     private String sipIp; | 
 |  |  |  | 
 |  |  |     @Value("${media.sdpIp:${media.ip}}") | 
 |  |  |     @Value("${sip.domain}") | 
 |  |  |     private String sipDomain; | 
 |  |  |  | 
 |  |  |     @Value("${media.sdp-ip:${media.ip}}") | 
 |  |  |     private String sdpIp; | 
 |  |  |  | 
 |  |  |     @Value("${media.streamIp:${media.ip}}") | 
 |  |  |     @Value("${media.stream-ip:${media.ip}}") | 
 |  |  |     private String streamIp; | 
 |  |  |  | 
 |  |  |     @Value("${media.httpPort}") | 
 |  |  |     @Value("${media.http-port}") | 
 |  |  |     private Integer httpPort; | 
 |  |  |  | 
 |  |  |     @Value("${media.httpSSlPort:}") | 
 |  |  |     private Integer httpSSlPort; | 
 |  |  |     @Value("${media.http-ssl-port:0}") | 
 |  |  |     private Integer httpSSlPort = 0; | 
 |  |  |  | 
 |  |  |     @Value("${media.rtmpPort:}") | 
 |  |  |     private Integer rtmpPort; | 
 |  |  |     @Value("${media.rtmp-port:0}") | 
 |  |  |     private Integer rtmpPort = 0; | 
 |  |  |  | 
 |  |  |     @Value("${media.rtmpSSlPort:}") | 
 |  |  |     private Integer rtmpSSlPort; | 
 |  |  |     @Value("${media.rtmp-ssl-port:0}") | 
 |  |  |     private Integer rtmpSSlPort = 0; | 
 |  |  |  | 
 |  |  |     @Value("${media.rtpProxyPort:}") | 
 |  |  |     private Integer rtpProxyPort; | 
 |  |  |     @Value("${media.rtp-proxy-port:0}") | 
 |  |  |     private Integer rtpProxyPort = 0; | 
 |  |  |  | 
 |  |  |     @Value("${media.rtspPort:}") | 
 |  |  |     private Integer rtspPort; | 
 |  |  |     @Value("${media.rtsp-port:0}") | 
 |  |  |     private Integer rtspPort = 0; | 
 |  |  |  | 
 |  |  |     @Value("${media.rtspSSLPort:}") | 
 |  |  |     private Integer rtspSSLPort; | 
 |  |  |     @Value("${media.rtsp-ssl-port:0}") | 
 |  |  |     private Integer rtspSSLPort = 0; | 
 |  |  |  | 
 |  |  |     @Value("${media.autoConfig:true}") | 
 |  |  |     private boolean autoConfig; | 
 |  |  |     @Value("${media.auto-config:true}") | 
 |  |  |     private boolean autoConfig = true; | 
 |  |  |  | 
 |  |  |     @Value("${media.secret}") | 
 |  |  |     private String secret; | 
 |  |  |  | 
 |  |  |     @Value("${media.streamNoneReaderDelayMS:18000}") | 
 |  |  |     private String streamNoneReaderDelayMS; | 
 |  |  |     @Value("${media.stream-none-reader-delay-ms:18000}") | 
 |  |  |     private int streamNoneReaderDelayMS = 18000; | 
 |  |  |  | 
 |  |  |     @Value("${media.rtp.enable}") | 
 |  |  |     private boolean rtpEnable; | 
 |  |  |  | 
 |  |  |     @Value("${media.rtp.portRange}") | 
 |  |  |     @Value("${media.rtp.port-range}") | 
 |  |  |     private String rtpPortRange; | 
 |  |  |  | 
 |  |  |     @Value("${media.recordAssistPort}") | 
 |  |  |     private Integer recordAssistPort; | 
 |  |  |  | 
 |  |  |     @Value("${media.rtp.send-port-range}") | 
 |  |  |     private String sendRtpPortRange; | 
 |  |  |  | 
 |  |  |     @Value("${media.record-assist-port:0}") | 
 |  |  |     private Integer recordAssistPort = 0; | 
 |  |  |  | 
 |  |  |     public String getId() { | 
 |  |  |         return id; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getIp() { | 
 |  |  |         return ip; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setIp(String ip) { | 
 |  |  |         this.ip = ip; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getHookIp() { | 
 |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setHookIp(String hookIp) { | 
 |  |  |         this.hookIp = hookIp; | 
 |  |  |     public String getSipIp() { | 
 |  |  |         if (sipIp == null) { | 
 |  |  |             return this.ip; | 
 |  |  |         }else { | 
 |  |  |             return sipIp; | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public int getHttpPort() { | 
 |  |  |         return httpPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public int getHttpSSlPort() { | 
 |  |  |         return httpSSlPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public int getRtmpPort() { | 
 |  |  |         return rtmpPort; | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     public int getRtmpSSlPort() { | 
 |  |  |         return rtmpSSlPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public int getRtpProxyPort() { | 
 |  |  |         if (rtpProxyPort == null) { | 
 |  |  |             return 0; | 
 |  |  |         }else { | 
 |  |  |             return rtpProxyPort; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public int getRtspPort() { | 
 |  |  |         return rtspPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public int getRtspSSLPort() { | 
 |  |  |         return rtspSSLPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public boolean isAutoConfig() { | 
 |  |  |         return autoConfig; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getSecret() { | 
 |  |  |         return secret; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public int getStreamNoneReaderDelayMS() { | 
 |  |  |         return streamNoneReaderDelayMS; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public boolean isRtpEnable() { | 
 |  |  |         return rtpEnable; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getRtpPortRange() { | 
 |  |  |         return rtpPortRange; | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     public int getRecordAssistPort() { | 
 |  |  |         return recordAssistPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getSdpIp() { | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setSdpIp(String sdpIp) { | 
 |  |  |         this.sdpIp = sdpIp; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getStreamIp() { | 
 |  |  |         if (StringUtils.isEmpty(streamIp)){ | 
 |  |  |             return ip; | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setStreamIp(String streamIp) { | 
 |  |  |         this.streamIp = streamIp; | 
 |  |  |     public String getSipDomain() { | 
 |  |  |         return sipDomain; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Integer getHttpPort() { | 
 |  |  |         return httpPort; | 
 |  |  |     public String getSendRtpPortRange() { | 
 |  |  |         return sendRtpPortRange; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setHttpPort(Integer httpPort) { | 
 |  |  |         this.httpPort = httpPort; | 
 |  |  |     public MediaServerItem getMediaSerItem(){ | 
 |  |  |         MediaServerItem mediaServerItem = new MediaServerItem(); | 
 |  |  |         mediaServerItem.setId(id); | 
 |  |  |         mediaServerItem.setIp(ip); | 
 |  |  |         mediaServerItem.setDefaultServer(true); | 
 |  |  |         mediaServerItem.setHookIp(getHookIp()); | 
 |  |  |         mediaServerItem.setSdpIp(getSdpIp()); | 
 |  |  |         mediaServerItem.setStreamIp(getStreamIp()); | 
 |  |  |         mediaServerItem.setHttpPort(httpPort); | 
 |  |  |         mediaServerItem.setHttpSSlPort(httpSSlPort); | 
 |  |  |         mediaServerItem.setRtmpPort(rtmpPort); | 
 |  |  |         mediaServerItem.setRtmpSSlPort(rtmpSSlPort); | 
 |  |  |         mediaServerItem.setRtpProxyPort(getRtpProxyPort()); | 
 |  |  |         mediaServerItem.setRtspPort(rtspPort); | 
 |  |  |         mediaServerItem.setRtspSSLPort(rtspSSLPort); | 
 |  |  |         mediaServerItem.setAutoConfig(autoConfig); | 
 |  |  |         mediaServerItem.setSecret(secret); | 
 |  |  |         mediaServerItem.setStreamNoneReaderDelayMS(streamNoneReaderDelayMS); | 
 |  |  |         mediaServerItem.setRtpEnable(rtpEnable); | 
 |  |  |         mediaServerItem.setRtpPortRange(rtpPortRange); | 
 |  |  |         mediaServerItem.setSendRtpPortRange(sendRtpPortRange); | 
 |  |  |         mediaServerItem.setRecordAssistPort(recordAssistPort); | 
 |  |  |         mediaServerItem.setHookAliveInterval(120); | 
 |  |  |  | 
 |  |  |         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |         mediaServerItem.setCreateTime(format.format(System.currentTimeMillis())); | 
 |  |  |         mediaServerItem.setUpdateTime(format.format(System.currentTimeMillis())); | 
 |  |  |  | 
 |  |  |         return mediaServerItem; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Integer getHttpSSlPort() { | 
 |  |  |         return httpSSlPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setHttpSSlPort(Integer httpSSlPort) { | 
 |  |  |         this.httpSSlPort = httpSSlPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Integer getRtmpPort() { | 
 |  |  |         return rtmpPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setRtmpPort(Integer rtmpPort) { | 
 |  |  |         this.rtmpPort = rtmpPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Integer getRtmpSSlPort() { | 
 |  |  |         return rtmpSSlPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setRtmpSSlPort(Integer rtmpSSlPort) { | 
 |  |  |         this.rtmpSSlPort = rtmpSSlPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Integer getRtpProxyPort() { | 
 |  |  |         return rtpProxyPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setRtpProxyPort(Integer rtpProxyPort) { | 
 |  |  |         this.rtpProxyPort = rtpProxyPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Integer getRtspPort() { | 
 |  |  |         return rtspPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setRtspPort(Integer rtspPort) { | 
 |  |  |         this.rtspPort = rtspPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Integer getRtspSSLPort() { | 
 |  |  |         return rtspSSLPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setRtspSSLPort(Integer rtspSSLPort) { | 
 |  |  |         this.rtspSSLPort = rtspSSLPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public boolean isAutoConfig() { | 
 |  |  |         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 Integer getRecordAssistPort() { | 
 |  |  |         return recordAssistPort; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setRecordAssistPort(Integer recordAssistPort) { | 
 |  |  |         this.recordAssistPort = recordAssistPort; | 
 |  |  |     } | 
 |  |  | } |