| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.net.InetAddress; |
| | |
| | | |
| | | |
| | | @Configuration("mediaConfig") |
| | | @Order(0) |
| | | public class MediaConfig{ |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(MediaConfig.class); |
| | |
| | | @Value("${media.ip}") |
| | | private String ip; |
| | | |
| | | @Value("${media.hook-ip:${sip.ip}}") |
| | | @Value("${media.hook-ip:}") |
| | | private String hookIp; |
| | | |
| | | @Value("${sip.ip}") |
| | |
| | | @Value("${media.rtp.port-range}") |
| | | private String rtpPortRange; |
| | | |
| | | @Value("${media.rtp.send-port-range}") |
| | | private String rtpSendPortRange; |
| | | |
| | | @Value("${media.record-assist-port:0}") |
| | | private Integer recordAssistPort = 0; |
| | | |
| | |
| | | |
| | | public String getHookIp() { |
| | | if (ObjectUtils.isEmpty(hookIp)){ |
| | | return sipIp; |
| | | return sipIp.split(",")[0]; |
| | | }else { |
| | | return hookIp; |
| | | } |
| | |
| | | mediaServerItem.setSecret(secret); |
| | | mediaServerItem.setRtpEnable(rtpEnable); |
| | | mediaServerItem.setRtpPortRange(rtpPortRange); |
| | | mediaServerItem.setSendRtpPortRange(rtpSendPortRange); |
| | | mediaServerItem.setRecordAssistPort(recordAssistPort); |
| | | mediaServerItem.setHookAliveInterval(30.00f); |
| | | |
| | |
| | | return mediaServerItem; |
| | | } |
| | | |
| | | public String getRtpSendPortRange() { |
| | | return rtpSendPortRange; |
| | | } |
| | | |
| | | public void setRtpSendPortRange(String rtpSendPortRange) { |
| | | this.rtpSendPortRange = rtpSendPortRange; |
| | | } |
| | | |
| | | private boolean isValidIPAddress(String ipAddress) { |
| | | if ((ipAddress != null) && (!ipAddress.isEmpty())) { |
| | | return Pattern.matches("^([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$", ipAddress); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |