| | |
| | | import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; |
| | | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorAbstract; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import gov.nist.javax.sip.RequestEventExt; |
| | | import gov.nist.javax.sip.address.AddressImpl; |
| | |
| | | import gov.nist.javax.sip.header.SIPDateHeader; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | import java.util.Calendar; |
| | | import java.util.Locale; |
| | | |
| | | /** |
| | | * @description:收到注册请求 处理 |
| | | * @author: swwheihei |
| | | * @date: 2020年5月3日 下午4:47:25 |
| | | /** |
| | | * SIP命令类型: REGISTER请求 |
| | | */ |
| | | @Component |
| | | public class RegisterRequestProcessor extends SIPRequestProcessorAbstract { |
| | | public class RegisterRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger(RegisterRequestProcessor.class); |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private RegisterLogicHandler handler; |
| | | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | @Autowired |
| | | private IVideoManagerStorager storager; |
| | |
| | | AddressImpl address = (AddressImpl) fromHeader.getAddress(); |
| | | SipUri uri = (SipUri) address.getURI(); |
| | | String deviceId = uri.getUser(); |
| | | Device deviceInRedis = redisCatchStorage.getDevice(deviceId); |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | AuthorizationHeader authorhead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); |
| | | if (deviceInRedis != null && device == null) { |
| | | // redis 存在脏数据 |
| | | redisCatchStorage.clearCatchByDeviceId(deviceId); |
| | | } |
| | | AuthorizationHeader authorhead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); |
| | | // 校验密码是否正确 |
| | | if (authorhead != null) { |
| | | passwordCorrect = new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, |
| | |
| | | device.setCharset("gb2312"); |
| | | device.setDeviceId(deviceId); |
| | | device.setFirsRegister(true); |
| | | }else { |
| | | if (device.getOnline() == 0) { |
| | | device.setFirsRegister(true); |
| | | } |
| | | } |
| | | device.setIp(received); |
| | | device.setPort(rPort); |
| | |
| | | if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); |
| | | // 注册成功 |
| | | // 保存到redis |
| | | // 下发catelog查询目录 |
| | | if (registerFlag == 1 ) { |
| | | logger.info("[{}] 注册成功! deviceId:" + device.getDeviceId(), requestAddress); |
| | | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_REGISTER); |