|  |  | 
 |  |  | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; | 
 |  |  |  | 
 |  |  | import com.genersoft.iot.vmp.conf.MediaConfig; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; | 
 |  |  | 
 |  |  | import org.slf4j.LoggerFactory; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Qualifier; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.context.annotation.DependsOn; | 
 |  |  | import org.springframework.context.annotation.Lazy; | 
 |  |  | import org.springframework.lang.Nullable; | 
 |  |  | 
 |  |  | import javax.sip.header.WWWAuthenticateHeader; | 
 |  |  | import javax.sip.message.Request; | 
 |  |  | import java.text.ParseException; | 
 |  |  | import java.util.Timer; | 
 |  |  | import java.util.TimerTask; | 
 |  |  | import java.util.UUID; | 
 |  |  |  | 
 |  |  | @Component | 
 |  |  | 
 |  |  |     public boolean register(ParentPlatform parentPlatform, @Nullable String callId, @Nullable WWWAuthenticateHeader www, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) { | 
 |  |  |         try { | 
 |  |  |             Request request = null; | 
 |  |  |  | 
 |  |  |             String tm = Long.toString(System.currentTimeMillis()); | 
 |  |  |             if (www == null ) { | 
 |  |  |                 //      //callid | 
 |  |  |                 CallIdHeader callIdHeader = null; | 
 |  |  | 
 |  |  |                 if(parentPlatform.getTransport().equals("UDP")) { | 
 |  |  |                     callIdHeader = udpSipProvider.getNewCallId(); | 
 |  |  |                 } | 
 |  |  |                 request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, 1L, null, null, callIdHeader); | 
 |  |  |  | 
 |  |  |                 request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, 1L, "FromRegister" + tm, null, callIdHeader); | 
 |  |  |                 // 将 callid 写入缓存, 等注册成功可以更新状态 | 
 |  |  |                 redisCatchStorage.updatePlatformRegisterInfo(callIdHeader.getCallId(), parentPlatform.getServerGBId()); | 
 |  |  |  | 
 |  |  | 
 |  |  |             }else { | 
 |  |  |                 CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 
 |  |  |                         : udpSipProvider.getNewCallId(); | 
 |  |  |  | 
 |  |  |                 request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, null, null, callId, www, callIdHeader); | 
 |  |  |                 request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, "FromRegister" + tm, null, callId, www, callIdHeader); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             transmitRequest(parentPlatform, request, null, okEvent); |