| | |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Gb28181Sdp; |
| | | import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo; |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import com.genersoft.iot.vmp.utils.GitUtil; |
| | | import gov.nist.javax.sip.address.AddressImpl; |
| | | import gov.nist.javax.sip.address.SipUri; |
| | | import gov.nist.javax.sip.header.Subject; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.sdp.SdpFactory; |
| | |
| | | import javax.sip.header.UserAgentHeader; |
| | | import javax.sip.message.Request; |
| | | import java.text.ParseException; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | |
| | | * @createTime 2021年09月27日 15:12:00 |
| | | */ |
| | | public class SipUtils { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(SipUtils.class); |
| | | |
| | | public static String getUserIdFromFromHeader(Request request) { |
| | | FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME); |
| | |
| | | strTmp = String.format("%02X", moveSpeed); |
| | | builder.append(strTmp, 0, 2); |
| | | builder.append(strTmp, 0, 2); |
| | | |
| | | |
| | | //优化zoom低倍速下的变倍速率 |
| | | if ((zoomSpeed > 0) && (zoomSpeed <16)) |
| | | { |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | public static String getNewCallId() { |
| | | return (int) Math.floor(Math.random() * 1000000000) + ""; |
| | | } |
| | | |
| | | public static int getTypeCodeFromGbCode(String deviceId) { |
| | | if (ObjectUtils.isEmpty(deviceId)) { |
| | | return 0; |
| | | } |
| | | return Integer.parseInt(deviceId.substring(10, 13)); |
| | | } |
| | | |
| | | /** |
| | | * 判断是否是前端外围设备 |
| | | * @param deviceId |
| | | * @return |
| | | */ |
| | | public static boolean isFrontEnd(String deviceId) { |
| | | int typeCodeFromGbCode = getTypeCodeFromGbCode(deviceId); |
| | | return typeCodeFromGbCode > 130 && typeCodeFromGbCode < 199; |
| | | } |
| | | /** |
| | | * 从请求中获取设备ip地址和端口号 |
| | | * @param request 请求 |
| | |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public static String parseTime(String timeStr) { |
| | | if (ObjectUtils.isEmpty(timeStr)){ |
| | | return null; |
| | | } |
| | | LocalDateTime localDateTime; |
| | | try { |
| | | localDateTime = LocalDateTime.parse(timeStr); |
| | | }catch (DateTimeParseException e) { |
| | | try { |
| | | localDateTime = LocalDateTime.parse(timeStr, DateUtil.formatterISO8601); |
| | | }catch (DateTimeParseException e2) { |
| | | logger.error("[格式化时间] 无法格式化时间: {}", timeStr); |
| | | return null; |
| | | } |
| | | } |
| | | return localDateTime.format(DateUtil.formatter); |
| | | } |
| | | } |