| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import gov.nist.core.Host; |
| | | import gov.nist.javax.sip.address.AddressImpl; |
| | | import gov.nist.javax.sip.address.SipUri; |
| | | import gov.nist.javax.sip.header.To; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.sip.ResponseEvent; |
| | | import javax.sip.address.Address; |
| | | import javax.sip.address.URI; |
| | | import javax.sip.header.CallIdHeader; |
| | | import javax.sip.header.ExpiresHeader; |
| | | import javax.sip.header.ToHeader; |
| | | import javax.sip.header.WWWAuthenticateHeader; |
| | | import javax.sip.message.Response; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @Description:Register响应处理器 |
| | |
| | | public void process(ResponseEvent evt, SipLayer layer, SipConfig config) { |
| | | // TODO Auto-generated method stub |
| | | Response response = evt.getResponse(); |
| | | ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME); |
| | | SipUri uri = (SipUri)toHeader.getAddress().getURI(); |
| | | String platformGBId = uri.getAuthority().getUser(); |
| | | CallIdHeader callIdHeader = (CallIdHeader) response.getHeader(CallIdHeader.NAME); |
| | | String callId = callIdHeader.getCallId(); |
| | | |
| | | String platformGBId = redisCatchStorage.queryPlatformRegisterInfo(callId); |
| | | if (platformGBId == null) { |
| | | logger.info(String.format("未找到callId: %s 的注册/注销平台id", callId )); |
| | | return; |
| | | } |
| | | logger.info(String.format("收到 %s 的注册/注销%S响应", platformGBId, response.getStatusCode() )); |
| | | |
| | | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformGBId); |
| | |
| | | |
| | | if (response.getStatusCode() == 401) { |
| | | WWWAuthenticateHeader www = (WWWAuthenticateHeader)response.getHeader(WWWAuthenticateHeader.NAME); |
| | | |
| | | |
| | | CallIdHeader callIdHeader = (CallIdHeader)response.getHeader(CallIdHeader.NAME); |
| | | String callId = callIdHeader.getCallId(); |
| | | |
| | | sipCommanderForPlatform.register(parentPlatform, callId, www, null, null); |
| | | }else if (response.getStatusCode() == 200){ |
| | | // 注册成功 |
| | | logger.info(String.format("%s 注册成功", platformGBId )); |
| | | redisCatchStorage.delPlatformRegisterInfo(callId); |
| | | parentPlatform.setStatus(true); |
| | | storager.updateParentPlatform(parentPlatform); |
| | | // |
| | | redisCatchStorage.updatePlatformRegister(parentPlatform); |
| | | |
| | | redisCatchStorage.updatePlatformKeepalive(parentPlatform); |