|  |  | 
 |  |  | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson2.JSON; | 
 |  |  | import com.alibaba.fastjson2.JSONObject; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.SipLayer; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.bean.*; | 
 |  |  | 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.SIPRequestHeaderPlarformProvider; | 
 |  |  | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | 
 |  |  | import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; | 
 |  |  | import com.genersoft.iot.vmp.utils.DateUtil; | 
 |  |  | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | 
 |  |  | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 
 |  |  | import com.genersoft.iot.vmp.service.IMediaServerService; | 
 |  |  | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | 
 |  |  | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 
 |  |  | import gov.nist.javax.sip.SipProviderImpl; | 
 |  |  | import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; | 
 |  |  | import com.genersoft.iot.vmp.utils.DateUtil; | 
 |  |  | import gov.nist.javax.sip.message.MessageFactoryImpl; | 
 |  |  | import gov.nist.javax.sip.message.SIPRequest; | 
 |  |  | import org.slf4j.Logger; | 
 |  |  | import org.slf4j.LoggerFactory; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Qualifier; | 
 |  |  | import org.springframework.context.annotation.DependsOn; | 
 |  |  | import org.springframework.context.annotation.Lazy; | 
 |  |  | import org.springframework.lang.Nullable; | 
 |  |  | import org.springframework.stereotype.Component; | 
 |  |  | import org.springframework.util.ObjectUtils; | 
 |  |  |  | 
 |  |  | import javax.sip.*; | 
 |  |  | import javax.sip.header.*; | 
 |  |  | import javax.sip.InvalidArgumentException; | 
 |  |  | import javax.sip.SipException; | 
 |  |  | import javax.sip.header.CallIdHeader; | 
 |  |  | import javax.sip.header.WWWAuthenticateHeader; | 
 |  |  | import javax.sip.message.Request; | 
 |  |  | import java.text.ParseException; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void deviceStatusResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { | 
 |  |  |     public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException { | 
 |  |  |         if (parentPlatform == null) { | 
 |  |  |             return ; | 
 |  |  |         } | 
 |  |  |         String statusStr = (status==1)?"ONLINE":"OFFLINE"; | 
 |  |  |         String characterSet = parentPlatform.getCharacterSet(); | 
 |  |  |         StringBuffer deviceStatusXml = new StringBuffer(600); | 
 |  |  |         deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); | 
 |  |  |         deviceStatusXml.append("<Response>\r\n"); | 
 |  |  |         deviceStatusXml.append("<CmdType>DeviceStatus</CmdType>\r\n"); | 
 |  |  |         deviceStatusXml.append("<SN>" +sn + "</SN>\r\n"); | 
 |  |  |         deviceStatusXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | 
 |  |  |         deviceStatusXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); | 
 |  |  |         deviceStatusXml.append("<Result>OK</Result>\r\n"); | 
 |  |  |         deviceStatusXml.append("<Online>ONLINE</Online>\r\n"); | 
 |  |  |         deviceStatusXml.append("<Online>"+statusStr+"</Online>\r\n"); | 
 |  |  |         deviceStatusXml.append("<Status>OK</Status>\r\n"); | 
 |  |  |         deviceStatusXml.append("</Response>\r\n"); | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |         Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); | 
 |  |  |         sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |         MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); | 
 |  |  |         if (mediaServerItem != null) { | 
 |  |  |             mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc()); | 
 |  |  |             zlmrtpServerFactory.closeRTPServer(mediaServerItem, sendRtpItem.getStreamId()); | 
 |  |  |             zlmrtpServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId()); | 
 |  |  |         } | 
 |  |  |         SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(parentPlatform, sendRtpItem); | 
 |  |  |         if (byeRequest == null) { |