| | |
| | | alter table wvp_device_channel |
| | | change stream_id stream_id varying(255) |
| | | change stream_id stream_id varying(255) |
| | | |
| | | alter table wvp_platform |
| | | add auto_push_channel bool default false |
| | |
| | | create_time character varying(50), |
| | | update_time character varying(50), |
| | | as_message_channel bool default false, |
| | | auto_push_channel bool default false, |
| | | constraint uk_platform_unique_server_gb_id unique (server_gb_id) |
| | | ); |
| | | |
| | |
| | | @Schema(description = "æ¯å¦ä½ä¸ºæ¶æ¯éé") |
| | | private boolean asMessageChannel; |
| | | |
| | | @Schema(description = "æ¯å¦ä½ä¸ºæ¶æ¯éé") |
| | | private boolean autoPushChannel; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | |
| | | public void setAsMessageChannel(boolean asMessageChannel) { |
| | | this.asMessageChannel = asMessageChannel; |
| | | } |
| | | |
| | | public boolean isAutoPushChannel() { |
| | | return autoPushChannel; |
| | | } |
| | | |
| | | public void setAutoPushChannel(boolean autoPushChannel) { |
| | | this.autoPushChannel = autoPushChannel; |
| | | } |
| | | } |
| | |
| | | |
| | | public void putCatalogSubscribe(String platformId, SubscribeInfo subscribeInfo) { |
| | | catalogMap.put(platformId, subscribeInfo); |
| | | // æ·»å 订é
å°æ |
| | | String taskOverdueKey = taskOverduePrefix + "catalog_" + platformId; |
| | | // æ·»å ä»»å¡å¤ç订é
è¿æ |
| | | dynamicTask.startDelay(taskOverdueKey, () -> removeCatalogSubscribe(subscribeInfo.getId()), |
| | | subscribeInfo.getExpires() * 1000); |
| | | if (subscribeInfo.getExpires() > 0) { |
| | | // æ·»å 订é
å°æ |
| | | String taskOverdueKey = taskOverduePrefix + "catalog_" + platformId; |
| | | // æ·»å ä»»å¡å¤ç订é
è¿æ |
| | | dynamicTask.startDelay(taskOverdueKey, () -> removeCatalogSubscribe(subscribeInfo.getId()), |
| | | subscribeInfo.getExpires() * 1000); |
| | | } |
| | | } |
| | | |
| | | public SubscribeInfo getCatalogSubscribe(String platformId) { |
| | |
| | | dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId), |
| | | subscribeInfo.getGpsInterval() * 1000); |
| | | String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; |
| | | // æ·»å ä»»å¡å¤ç订é
è¿æ |
| | | dynamicTask.startDelay(taskOverdueKey, () -> { |
| | | removeMobilePositionSubscribe(subscribeInfo.getId()); |
| | | }, |
| | | subscribeInfo.getExpires() * 1000); |
| | | if (subscribeInfo.getExpires() > 0) { |
| | | // æ·»å ä»»å¡å¤ç订é
è¿æ |
| | | dynamicTask.startDelay(taskOverdueKey, () -> { |
| | | removeMobilePositionSubscribe(subscribeInfo.getId()); |
| | | }, |
| | | subscribeInfo.getExpires() * 1000); |
| | | } |
| | | } |
| | | |
| | | public SubscribeInfo getMobilePositionSubscribe(String platformId) { |
| | |
| | | |
| | | } |
| | | |
| | | public SubscribeInfo() { |
| | | } |
| | | |
| | | private String id; |
| | | |
| | | private SIPRequest request; |
| | |
| | | */ |
| | | private String sn; |
| | | private int gpsInterval; |
| | | |
| | | /** |
| | | * 模æçFromTag |
| | | */ |
| | | private String simulatedFromTag; |
| | | |
| | | /** |
| | | * 模æçToTag |
| | | */ |
| | | private String simulatedToTag; |
| | | |
| | | /** |
| | | * 模æçCallID |
| | | */ |
| | | private String simulatedCallId; |
| | | |
| | | public String getId() { |
| | | return id; |
| | |
| | | public void setGpsInterval(int gpsInterval) { |
| | | this.gpsInterval = gpsInterval; |
| | | } |
| | | |
| | | public String getSimulatedFromTag() { |
| | | return simulatedFromTag; |
| | | } |
| | | |
| | | public void setSimulatedFromTag(String simulatedFromTag) { |
| | | this.simulatedFromTag = simulatedFromTag; |
| | | } |
| | | |
| | | public String getSimulatedCallId() { |
| | | return simulatedCallId; |
| | | } |
| | | |
| | | public void setSimulatedCallId(String simulatedCallId) { |
| | | this.simulatedCallId = simulatedCallId; |
| | | } |
| | | |
| | | public String getSimulatedToTag() { |
| | | return simulatedToTag; |
| | | } |
| | | |
| | | public void setSimulatedToTag(String simulatedToTag) { |
| | | this.simulatedToTag = simulatedToTag; |
| | | } |
| | | } |
| | |
| | | SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), |
| | | parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort()); |
| | | Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag()); |
| | | FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse() != null ? subscribeInfo.getResponse().getToTag(): subscribeInfo.getSimulatedToTag()); |
| | | // to |
| | | SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); |
| | | Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag()); |
| | | ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest() != null ?subscribeInfo.getRequest().getFromTag(): subscribeInfo.getSimulatedFromTag()); |
| | | |
| | | // Forwards |
| | | MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); |
| | |
| | | // 设置ç¼ç ï¼ é²æ¢ä¸æä¹±ç |
| | | messageFactory.setDefaultContentEncodingCharset("gb2312"); |
| | | |
| | | CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId()); |
| | | CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest() != null ? subscribeInfo.getRequest().getCallIdHeader().getCallId(): subscribeInfo.getSimulatedCallId()); |
| | | |
| | | request = (SIPRequest) messageFactory.createRequest(requestURI, Request.NOTIFY, callIdHeader, cSeqHeader, fromHeader, |
| | | toHeader, viaHeaders, maxForwards); |
| | |
| | | |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest( |
| | | parentPlatform, |
| | | keepaliveXml.toString(), |
| | | SipUtils.getNewFromTag(), |
| | | SipUtils.getNewViaTag(), |
| | | callIdHeader); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, errorEvent, okEvent); |
| | | Request request = headerProviderPlatformProvider.createMessageRequest( |
| | | parentPlatform, |
| | | keepaliveXml.toString(), |
| | | SipUtils.getNewFromTag(), |
| | | SipUtils.getNewViaTag(), |
| | | callIdHeader); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, errorEvent, okEvent); |
| | | return callIdHeader.getCallId(); |
| | | } |
| | | |
| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| | | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| | | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| | | import com.genersoft.iot.vmp.service.IPlatformService; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import gov.nist.javax.sip.message.SIPResponse; |
| | |
| | | |
| | | @Autowired |
| | | private SIPSender sipSender; |
| | | |
| | | |
| | | @Autowired |
| | | private IPlatformService platformService; |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("æªå¤ççå¼å¸¸ ", e); |
| | | } |
| | | if (subscribeHolder.getCatalogSubscribe(platformId) == null && platform.isAutoPushChannel()) { |
| | | platformService.addSimulatedSubscribeInfo(platform); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param platformId å¹³å° |
| | | */ |
| | | void sendNotifyMobilePosition(String platformId); |
| | | |
| | | void addSimulatedSubscribeInfo(ParentPlatform parentPlatform); |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.TransactionDefinition; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| | | import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | 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.stereotype.Service; |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.PeerUnavailableException; |
| | | import javax.sip.SipException; |
| | | import javax.sip.SipFactory; |
| | | import javax.sip.address.Address; |
| | | import javax.sip.address.SipURI; |
| | | import javax.sip.header.*; |
| | | import javax.sip.message.Request; |
| | | import java.text.ParseException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author lin |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | }, |
| | | (parentPlatform.getKeepTimeout())*1000); |
| | | } |
| | | if (parentPlatform.isAutoPushChannel()) { |
| | | if (subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()) == null) { |
| | | addSimulatedSubscribeInfo(parentPlatform); |
| | | } |
| | | }else { |
| | | SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()); |
| | | if (catalogSubscribe != null && catalogSubscribe.getExpires() == -1) { |
| | | subscribeHolder.removeCatalogSubscribe(parentPlatform.getServerGBId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void addSimulatedSubscribeInfo(ParentPlatform parentPlatform) { |
| | | // èªå¨æ·»å 䏿¡æ¨¡æç订é
ä¿¡æ¯ |
| | | SubscribeInfo subscribeInfo = new SubscribeInfo(); |
| | | subscribeInfo.setId(parentPlatform.getServerGBId()); |
| | | subscribeInfo.setExpires(-1); |
| | | subscribeInfo.setEventType("Catalog"); |
| | | int random = (int) Math.floor(Math.random() * 10000); |
| | | subscribeInfo.setEventId(random + ""); |
| | | subscribeInfo.setSimulatedCallId(UUID.randomUUID().toString().replace("-", "") + "@" + parentPlatform.getServerIP()); |
| | | subscribeInfo.setSimulatedFromTag(UUID.randomUUID().toString().replace("-", "")); |
| | | subscribeInfo.setSimulatedToTag(UUID.randomUUID().toString().replace("-", "")); |
| | | subscribeHolder.putCatalogSubscribe(parentPlatform.getServerGBId(), subscribeInfo); |
| | | } |
| | | |
| | | private void registerTask(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo){ |
| | |
| | | |
| | | } |
| | | } |
| | | if (streamPushItemListFroPlatform.size() > 0) { |
| | | if (!streamPushItemListFroPlatform.isEmpty()) { |
| | | platformGbStreamMapper.batchAdd(streamPushItemListFroPlatform); |
| | | // åééç¥ |
| | | for (String platformId : platformForEvent.keySet()) { |
| | |
| | | public interface ParentPlatformMapper { |
| | | |
| | | @Insert("INSERT INTO wvp_platform (enable, name, server_gb_id, server_gb_domain, server_ip, server_port,device_gb_id,device_ip,"+ |
| | | "device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,as_message_channel,"+ |
| | | "device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,as_message_channel,auto_push_channel,"+ |
| | | "status,start_offline_push,catalog_id,administrative_division,catalog_group,create_time,update_time) " + |
| | | " VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIP}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " + |
| | | " #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{asMessageChannel}, " + |
| | | " #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{asMessageChannel}, #{autoPushChannel}, " + |
| | | " #{status}, #{startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime})") |
| | | int addParentPlatform(ParentPlatform parentPlatform); |
| | | |
| | |
| | | "ptz=#{ptz}, " + |
| | | "rtcp=#{rtcp}, " + |
| | | "as_message_channel=#{asMessageChannel}, " + |
| | | "auto_push_channel=#{autoPushChannel}, " + |
| | | "status=#{status}, " + |
| | | "start_offline_push=#{startOfflinePush}, " + |
| | | "catalog_group=#{catalogGroup}, " + |
| | |
| | | <el-form-item label="å
¶ä»é项"> |
| | | <el-checkbox label="å¯ç¨" v-model="platform.enable" @change="checkExpires"></el-checkbox> |
| | | <!-- <el-checkbox label="äºå°æ§å¶" v-model="platform.ptz"></el-checkbox>--> |
| | | <el-checkbox label="æèµ·ç¦»çº¿æ¨æµ" v-model="platform.startOfflinePush"></el-checkbox> |
| | | <el-checkbox label="æèµ·æ¨æµ" v-model="platform.startOfflinePush"></el-checkbox> |
| | | <el-checkbox label="RTCPä¿æ´»" v-model="platform.rtcp" @change="rtcpCheckBoxChange"></el-checkbox> |
| | | <el-checkbox label="ä½ä¸ºæ¶æ¯éé" v-model="platform.asMessageChannel" ></el-checkbox> |
| | | <el-checkbox label="æ¶æ¯éé" v-model="platform.asMessageChannel" ></el-checkbox> |
| | | <el-checkbox label="æ¨ééé" v-model="platform.autoPushChannel" ></el-checkbox> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="onSubmit">{{ |
| | |
| | | ptz: true, |
| | | rtcp: false, |
| | | asMessageChannel: false, |
| | | autoPushChannel: false, |
| | | name: null, |
| | | serverGBId: null, |
| | | serverGBDomain: null, |
| | |
| | | this.platform.ptz = platform.ptz; |
| | | this.platform.rtcp = platform.rtcp; |
| | | this.platform.asMessageChannel = platform.asMessageChannel; |
| | | this.platform.autoPushChannel = platform.autoPushChannel; |
| | | this.platform.name = platform.name; |
| | | this.platform.serverGBId = platform.serverGBId; |
| | | this.platform.serverGBDomain = platform.serverGBDomain; |
| | |
| | | ptz: true, |
| | | rtcp: false, |
| | | asMessageChannel: false, |
| | | autoPushChannel: false, |
| | | name: null, |
| | | serverGBId: null, |
| | | administrativeDivision: null, |