优化sip消息,去除自动dialog创建
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
package com.genersoft.iot.vmp.service;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
|
||||
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 国标平台的业务类
|
||||
* @author lin
|
||||
@@ -42,4 +47,10 @@ public interface IPlatformService {
|
||||
* @param parentPlatform
|
||||
*/
|
||||
void login(ParentPlatform parentPlatform);
|
||||
|
||||
/**
|
||||
* 向上级平台发送位置订阅
|
||||
* @param platformId 平台
|
||||
*/
|
||||
void sendNotifyMobilePosition(String platformId);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
result = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
|
||||
// TODO 后续给平台增加控制开关以控制是否响应目录订阅
|
||||
List<DeviceChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId, platform);
|
||||
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
|
||||
if (deviceChannelList != null) {
|
||||
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -83,7 +85,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
if (channelReduces.size() > 0){
|
||||
PlatformCatalog catalog = catalogManager.select(catalogId);
|
||||
if (catalog == null && !catalogId.equals(platform.getServerGBId())) {
|
||||
if (catalog == null && !catalogId.equals(platform.getDeviceGBId())) {
|
||||
logger.warn("未查询到目录{}的信息", catalogId);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||
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.IPlatformService;
|
||||
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -57,6 +56,9 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
@Autowired
|
||||
private SubscribeHolder subscribeHolder;
|
||||
|
||||
@Autowired
|
||||
private GbStreamMapper gbStreamMapper;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@@ -228,4 +230,34 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
60*1000);
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendNotifyMobilePosition(String platformId) {
|
||||
ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId);
|
||||
if (platform == null) {
|
||||
return;
|
||||
}
|
||||
SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId());
|
||||
if (subscribe != null) {
|
||||
|
||||
// TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
|
||||
List<DeviceChannel> gbStreams = gbStreamMapper.queryGbStreamListInPlatform(platform.getServerGBId());
|
||||
if (gbStreams.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (DeviceChannel deviceChannel : gbStreams) {
|
||||
String gbId = deviceChannel.getChannelId();
|
||||
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
|
||||
// 无最新位置不发送
|
||||
if (gpsMsgInfo != null) {
|
||||
// 经纬度都为0不发送
|
||||
if (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0) {
|
||||
continue;
|
||||
}
|
||||
// 发送GPS消息
|
||||
commanderForPlatform.sendNotifyMobilePosition(platform, gpsMsgInfo, subscribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -86,7 +87,7 @@ public class RedisGbPlayMsgListener implements MessageListener {
|
||||
|
||||
|
||||
public interface PlayMsgCallback{
|
||||
void handler(ResponseSendItemMsg responseSendItemMsg);
|
||||
void handler(ResponseSendItemMsg responseSendItemMsg) throws ParseException;
|
||||
}
|
||||
|
||||
public interface PlayMsgCallbackForStartSendRtpStream{
|
||||
@@ -134,7 +135,11 @@ public class RedisGbPlayMsgListener implements MessageListener {
|
||||
PlayMsgCallback playMsgCallback = callbacks.get(key);
|
||||
if (playMsgCallback != null) {
|
||||
callbacksForError.remove(key);
|
||||
playMsgCallback.handler(responseSendItemMsg);
|
||||
try {
|
||||
playMsgCallback.handler(responseSendItemMsg);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ERROR_CODE_MEDIA_SERVER_NOT_FOUND:
|
||||
|
||||
Reference in New Issue
Block a user