| | |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | import java.util.regex.Pattern; |
| | | |
| | | |
| | | @Configuration("mediaConfig") |
| | |
| | | } |
| | | |
| | | public String getHookIp() { |
| | | if (StringUtils.isEmpty(hookIp)){ |
| | | if (ObjectUtils.isEmpty(hookIp)){ |
| | | return sipIp; |
| | | }else { |
| | | return hookIp; |
| | |
| | | } |
| | | |
| | | public String getSdpIp() { |
| | | if (StringUtils.isEmpty(sdpIp)){ |
| | | if (ObjectUtils.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; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public String getStreamIp() { |
| | | if (StringUtils.isEmpty(streamIp)){ |
| | | if (ObjectUtils.isEmpty(streamIp)){ |
| | | return ip; |
| | | }else { |
| | | return streamIp; |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |