| | |
| | | package com.genersoft.iot.vmp.conf; |
| | | |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | 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; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | import java.util.regex.Pattern; |
| | | |
| | | |
| | | @Configuration("mediaConfig") |
| | | public class MediaConfig{ |
| | |
| | | @Value("${media.secret}") |
| | | private String secret; |
| | | |
| | | @Value("${media.stream-none-reader-delay-ms:18000}") |
| | | private int streamNoneReaderDelayMS = 18000; |
| | | @Value("${media.stream-none-reader-delay-ms:10000}") |
| | | private int streamNoneReaderDelayMS = 10000; |
| | | |
| | | @Value("${media.rtp.enable}") |
| | | private boolean rtpEnable; |
| | |
| | | if (StringUtils.isEmpty(sdpIp)){ |
| | | return ip; |
| | | }else { |
| | | return sdpIp; |
| | | if (isValidIPAddress(sdpIp)) { |
| | | return sdpIp; |
| | | }else { |
| | | // 按照域名解析 |
| | | String hostAddress = null; |
| | | try { |
| | | hostAddress = InetAddress.getByName(sdpIp).getHostAddress(); |
| | | } catch (UnknownHostException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return hostAddress; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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())); |
| | | mediaServerItem.setCreateTime(DateUtil.getNow()); |
| | | mediaServerItem.setUpdateTime(DateUtil.getNow()); |
| | | |
| | | return mediaServerItem; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | } |