Merge branch 'master' into 1078
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
|
||||
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -17,7 +17,8 @@ import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 启动时读取行政区划表
|
||||
@@ -28,8 +29,6 @@ public class CivilCodeFileConf implements CommandLineRunner {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(CivilCodeFileConf.class);
|
||||
|
||||
private final Map<String, CivilCodePo> civilCodeMap= new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private UserSetting userSetting;
|
||||
@@ -62,6 +61,7 @@ public class CivilCodeFileConf implements CommandLineRunner {
|
||||
BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
int index = -1;
|
||||
String line;
|
||||
List<CivilCodePo> civilCodePoList = new ArrayList<>();
|
||||
while ((line = inputStreamReader.readLine()) != null) {
|
||||
index ++;
|
||||
if (index == 0) {
|
||||
@@ -69,36 +69,15 @@ public class CivilCodeFileConf implements CommandLineRunner {
|
||||
}
|
||||
String[] infoArray = line.split(",");
|
||||
CivilCodePo civilCodePo = CivilCodePo.getInstance(infoArray);
|
||||
civilCodeMap.put(civilCodePo.getCode(), civilCodePo);
|
||||
civilCodePoList.add(civilCodePo);
|
||||
}
|
||||
CivilCodeUtil.INSTANCE.add(civilCodePoList);
|
||||
inputStreamReader.close();
|
||||
inputStream.close();
|
||||
if (civilCodeMap.size() == 0) {
|
||||
if (civilCodePoList.isEmpty()) {
|
||||
logger.warn("[行政区划] 文件内容为空,可能造成目录刷新结果不完整");
|
||||
}else {
|
||||
logger.info("[行政区划] 加载成功,共加载数据{}条", civilCodeMap.size());
|
||||
logger.info("[行政区划] 加载成功,共加载数据{}条", civilCodePoList.size());
|
||||
}
|
||||
}
|
||||
|
||||
public CivilCodePo getParentCode(String code) {
|
||||
if (code.length() > 8) {
|
||||
return null;
|
||||
}
|
||||
if (code.length() == 8) {
|
||||
String parentCode = code.substring(0, 6);
|
||||
return civilCodeMap.get(parentCode);
|
||||
}else {
|
||||
CivilCodePo civilCodePo = civilCodeMap.get(code);
|
||||
if (civilCodePo == null){
|
||||
return null;
|
||||
}
|
||||
String parentCode = civilCodePo.getParentCode();
|
||||
if (parentCode == null) {
|
||||
return null;
|
||||
}
|
||||
return civilCodeMap.get(parentCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
|
||||
}else {
|
||||
event = eventElement.getText().toUpperCase();
|
||||
}
|
||||
DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, event, civilCodeFileConf);
|
||||
DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, event);
|
||||
if (channel == null) {
|
||||
logger.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent()));
|
||||
continue;
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatchStatus;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import org.dom4j.Element;
|
||||
@@ -77,15 +74,6 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i
|
||||
AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), channelId);
|
||||
audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.WaiteInvite);
|
||||
audioBroadcastManager.update(audioBroadcastCatch);
|
||||
// 等待invite消息, 超时则结束
|
||||
String key = VideoManagerConstants.BROADCAST_WAITE_INVITE + device.getDeviceId();
|
||||
if (!SipUtils.isFrontEnd(device.getDeviceId())) {
|
||||
key += audioBroadcastCatch.getChannelId();
|
||||
}
|
||||
dynamicTask.startDelay(key, ()->{
|
||||
logger.info("[语音广播]等待invite消息超时:{}/{}", device.getDeviceId(), channelId);
|
||||
playService.stopAudioBroadcast(device.getDeviceId(), channelId);
|
||||
}, 2000);
|
||||
}else {
|
||||
playService.stopAudioBroadcast(device.getDeviceId(), channelId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch;
|
||||
@@ -57,9 +56,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||
@Autowired
|
||||
private ThreadPoolTaskExecutor taskExecutor;
|
||||
|
||||
@Autowired
|
||||
private CivilCodeFileConf civilCodeFileConf;
|
||||
|
||||
@Autowired
|
||||
private SipConfig sipConfig;
|
||||
private AtomicBoolean processing = new AtomicBoolean(false);
|
||||
@@ -118,7 +114,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||
if (channelDeviceElement == null) {
|
||||
continue;
|
||||
}
|
||||
DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null, civilCodeFileConf);
|
||||
DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null);
|
||||
if (channel == null) {
|
||||
logger.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent()));
|
||||
continue;
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.genersoft.iot.vmp.gb28181.utils;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
@@ -240,7 +240,7 @@ public class XmlUtil {
|
||||
CivilCode, BusinessGroup,VirtualOrganization,Other
|
||||
}
|
||||
|
||||
public static DeviceChannel channelContentHandler(Element itemDevice, Device device, String event, CivilCodeFileConf civilCodeFileConf){
|
||||
public static DeviceChannel channelContentHandler(Element itemDevice, Device device, String event){
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setDeviceId(device.getDeviceId());
|
||||
Element channdelIdElement = itemDevice.element("DeviceID");
|
||||
@@ -267,7 +267,7 @@ public class XmlUtil {
|
||||
}
|
||||
if(channelId.length() <= 8) {
|
||||
deviceChannel.setHasAudio(false);
|
||||
CivilCodePo parentCode = civilCodeFileConf.getParentCode(channelId);
|
||||
CivilCodePo parentCode = CivilCodeUtil.INSTANCE.getParentCode(channelId);
|
||||
if (parentCode != null) {
|
||||
deviceChannel.setParentId(parentCode.getCode());
|
||||
deviceChannel.setCivilCode(parentCode.getCode());
|
||||
|
||||
@@ -3,10 +3,7 @@ package com.genersoft.iot.vmp.service.impl;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.common.InviteInfo;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionStatus;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.common.*;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
@@ -18,19 +15,13 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
|
||||
import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.*;
|
||||
import com.genersoft.iot.vmp.media.zlm.*;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRecordMp4;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
|
||||
@@ -40,15 +31,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRecordMp4HookParam;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
|
||||
import com.genersoft.iot.vmp.service.*;
|
||||
import com.genersoft.iot.vmp.service.bean.*;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener;
|
||||
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper;
|
||||
@@ -1179,6 +1162,15 @@ public class PlayServiceImpl implements IPlayService {
|
||||
// 发送成功
|
||||
AudioBroadcastCatch audioBroadcastCatch = new AudioBroadcastCatch(device.getDeviceId(), channelId, mediaServerItem, app, stream, event, AudioBroadcastCatchStatus.Ready, isFromPlatform);
|
||||
audioBroadcastManager.update(audioBroadcastCatch);
|
||||
// 等待invite消息, 超时则结束
|
||||
String key = VideoManagerConstants.BROADCAST_WAITE_INVITE + device.getDeviceId();
|
||||
if (!SipUtils.isFrontEnd(device.getDeviceId())) {
|
||||
key += audioBroadcastCatch.getChannelId();
|
||||
}
|
||||
dynamicTask.startDelay(key, ()->{
|
||||
logger.info("[语音广播]等待invite消息超时:{}/{}", device.getDeviceId(), channelId);
|
||||
stopAudioBroadcast(device.getDeviceId(), channelId);
|
||||
}, 2000);
|
||||
}, eventResultForError -> {
|
||||
// 发送失败
|
||||
logger.error("语音广播发送失败: {}:{}", channelId, eventResultForError.msg);
|
||||
|
||||
50
src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java
Normal file
50
src/main/java/com/genersoft/iot/vmp/utils/CivilCodeUtil.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.genersoft.iot.vmp.utils;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public enum CivilCodeUtil {
|
||||
|
||||
INSTANCE;
|
||||
private final static Logger log = LoggerFactory.getLogger(CivilCodeUtil.class);
|
||||
|
||||
// 用与消息的缓存
|
||||
private final Map<String, CivilCodePo> civilCodeMap = new ConcurrentHashMap<>();
|
||||
|
||||
CivilCodeUtil() {
|
||||
}
|
||||
|
||||
public void add(List<CivilCodePo> civilCodePoList) {
|
||||
if (!civilCodePoList.isEmpty()) {
|
||||
for (CivilCodePo civilCodePo : civilCodePoList) {
|
||||
civilCodeMap.put(civilCodePo.getCode(), civilCodePo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CivilCodePo getParentCode(String code) {
|
||||
if (code.length() > 8) {
|
||||
return null;
|
||||
}
|
||||
if (code.length() == 8) {
|
||||
String parentCode = code.substring(0, 6);
|
||||
return civilCodeMap.get(parentCode);
|
||||
}else {
|
||||
CivilCodePo civilCodePo = civilCodeMap.get(code);
|
||||
if (civilCodePo == null){
|
||||
return null;
|
||||
}
|
||||
String parentCode = civilCodePo.getParentCode();
|
||||
if (parentCode == null) {
|
||||
return null;
|
||||
}
|
||||
return civilCodeMap.get(parentCode);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user