|
@ -7,6 +7,8 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
|
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
|
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
|
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; |
|
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; |
|
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
|
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
@ -20,12 +22,16 @@ import javax.sip.header.CallIdHeader; |
|
|
import javax.sip.header.WWWAuthenticateHeader; |
|
|
import javax.sip.header.WWWAuthenticateHeader; |
|
|
import javax.sip.message.Request; |
|
|
import javax.sip.message.Request; |
|
|
import java.text.ParseException; |
|
|
import java.text.ParseException; |
|
|
|
|
|
import java.util.Timer; |
|
|
|
|
|
import java.util.TimerTask; |
|
|
import java.util.UUID; |
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
|
@Component |
|
|
@Component |
|
|
@DependsOn("sipLayer") |
|
|
@DependsOn("sipLayer") |
|
|
public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
|
|
public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
|
|
|
|
|
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(SIPCommanderFroPlatform.class); |
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
// @Autowired
|
|
|
// private SipConfig sipConfig;
|
|
|
// private SipConfig sipConfig;
|
|
|
|
|
|
|
|
@ -61,8 +67,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
|
|
private boolean rtpEnable; |
|
|
private boolean rtpEnable; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean register(ParentPlatform parentPlatform) { |
|
|
public boolean register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) { |
|
|
return register(parentPlatform, null, null, null, null); |
|
|
return register(parentPlatform, null, null, errorEvent, okEvent); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -95,13 +101,17 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
|
|
// 将 callid 写入缓存, 等注册成功可以更新状态
|
|
|
// 将 callid 写入缓存, 等注册成功可以更新状态
|
|
|
redisCatchStorage.updatePlatformRegisterInfo(callIdHeader.getCallId(), parentPlatform.getServerGBId()); |
|
|
redisCatchStorage.updatePlatformRegisterInfo(callIdHeader.getCallId(), parentPlatform.getServerGBId()); |
|
|
|
|
|
|
|
|
CallIdHeader finalCallIdHeader = callIdHeader; |
|
|
|
|
|
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{ |
|
|
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{ |
|
|
redisCatchStorage.delPlatformRegisterInfo(finalCallIdHeader.getCallId()); |
|
|
if (event != null) { |
|
|
|
|
|
logger.info("向上级平台 [ {} ] 注册发上错误: {} ", |
|
|
|
|
|
parentPlatform.getServerGBId(), |
|
|
|
|
|
event.getResponse().getReasonPhrase()); |
|
|
|
|
|
} |
|
|
if (errorEvent != null ) { |
|
|
if (errorEvent != null ) { |
|
|
errorEvent.response(event); |
|
|
errorEvent.response(event); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
}else { |
|
|
}else { |
|
|
CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() |
|
|
CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() |
|
|
: udpSipProvider.getNewCallId(); |
|
|
: udpSipProvider.getNewCallId(); |
|
|