临时提交

This commit is contained in:
648540858
2024-07-10 14:43:22 +08:00
parent bb609b7e09
commit b843958ed7
31 changed files with 361 additions and 302 deletions

View File

@@ -5,6 +5,8 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import com.github.pagehelper.PageInfo;
import java.util.List;
@@ -40,6 +42,8 @@ public interface IDeviceChannelService {
*/
List<ChannelReduce> queryAllChannelList(String platformId);
PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId);
/**
* 查询通道所属的设备
*/
@@ -103,5 +107,12 @@ public interface IDeviceChannelService {
boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannels);
PageInfo<DeviceChannel> getSubChannels(int deviceDbId, String channelId, String query, Boolean channelType, Boolean online, int page, int count);
List<DeviceChannelExtend> queryChannelExtendsByDeviceId(String deviceId, List<String> channelIds, Boolean online);
PageInfo<DeviceChannel> queryChannelsByDeviceId(String deviceId, String query, Boolean channelType, Boolean online, int page, int count);
List<Device> queryDeviceWithAsMessageChannel();
}

View File

@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.github.pagehelper.PageInfo;
import java.util.List;
@@ -88,6 +89,8 @@ public interface IDeviceService {
*/
List<Device> getAllOnlineDevice();
List<Device> getAllByStatus(boolean status);
/**
* 判断是否注册已经失效
* @param device 设备信息
@@ -159,4 +162,6 @@ public interface IDeviceService {
* 获取所有设备
*/
List<Device> getAll();
PageInfo<Device> getAll(int page, int count, String query, Boolean status);
}

View File

@@ -22,6 +22,9 @@ import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -74,7 +77,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
String now = DateUtil.getNow();
channel.setUpdateTime(now);
DeviceChannel deviceChannel = channelMapper.queryChannel(deviceId, channelId);
DeviceChannel deviceChannel = getOne(deviceId, channelId);
if (deviceChannel == null) {
channel.setCreateTime(now);
channelMapper.add(channel);
@@ -170,6 +173,13 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
return channelMapper.queryChannelListInAll(null, null, null, platformId, null);
}
@Override
public PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId) {
PageHelper.startPage(page, count);
List<ChannelReduce> all = channelMapper.queryChannelListInAll(query, online, channelType, platformId, catalogId);
return new PageInfo<>(all);
}
@Override
public List<Device> getDeviceByChannelId(String channelId) {
@@ -209,7 +219,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override
public DeviceChannel getOne(String deviceId, String channelId){
return channelMapper.queryChannel(deviceId, channelId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
}
return channelMapper.getOneByDeviceId(device.getId(), channelId);
}
@Override
@@ -424,7 +438,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
DeviceChannel channelInDb = allChannelMap.get(deviceChannel.getDeviceDbId() + deviceChannel.getDeviceId());
if (channelInDb != null) {
deviceChannel.setStreamId(channelInDb.getStreamId());
deviceChannel.setHasAudio(channelInDb.getHasAudio());
deviceChannel.setHasAudio(channelInDb.isHasAudio());
deviceChannel.setId(channelInDb.getId());
if (channelInDb.getStatus().equalsIgnoreCase(deviceChannel.getStatus())){
List<String> strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getDeviceId());
@@ -518,4 +532,33 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
return true;
}
@Override
public PageInfo<DeviceChannel> getSubChannels(int deviceDbId, String channelId, String query, Boolean channelType, Boolean online, int page, int count) {
PageHelper.startPage(page, count);
List<DeviceChannel> all = channelMapper.queryChannels(deviceDbId, channelId, query, channelType, online,null);
return new PageInfo<>(all);
}
@Override
public List<DeviceChannelExtend> queryChannelExtendsByDeviceId(String deviceId, List<String> channelIds, Boolean online) {
return channelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds);
}
@Override
public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
}
// 获取到所有正在播放的流
PageHelper.startPage(page, count);
List<DeviceChannel> all = channelMapper.queryChannels(device.getId(), null, query, hasSubChannel, online,null);
return new PageInfo<>(all);
}
@Override
public List<Device> queryDeviceWithAsMessageChannel() {
return deviceMapper.queryDeviceWithAsMessageChannel();
}
}

View File

@@ -7,6 +7,9 @@ import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
@@ -21,12 +24,11 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
@@ -39,7 +41,6 @@ import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -366,6 +367,11 @@ public class DeviceServiceImpl implements IDeviceService {
return deviceMapper.getOnlineDevices();
}
@Override
public List<Device> getAllByStatus(boolean status) {
return deviceMapper.getDevices(status);
}
@Override
public boolean expire(Device device) {
Instant registerTimeDate = Instant.from(DateUtil.formatter.parse(device.getRegisterTime()));
@@ -568,5 +574,10 @@ public class DeviceServiceImpl implements IDeviceService {
return deviceMapper.getAll();
}
@Override
public PageInfo<Device> getAll(int page, int count, String query, Boolean status) {
PageHelper.startPage(page, count);
List<Device> all = deviceMapper.getDeviceList(query, status);
return new PageInfo<>(all);
}
}

View File

@@ -170,9 +170,9 @@ public class MediaServiceImpl implements IMediaService {
String deviceId = ssrcTransactionForAll.get(0).getDeviceId();
String channelId = ssrcTransactionForAll.get(0).getChannelId();
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channelId);
if (deviceChannel != null) {
result.setEnable_audio(deviceChannel.getHasAudio());
result.setEnable_audio(deviceChannel.isHasAudio());
}
// 如果是录像下载就设置视频间隔十秒
if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) {

View File

@@ -124,11 +124,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
private List<CommonGBChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId, ParentPlatform platform) {
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
if (channelReduces.size() > 0){
if (!channelReduces.isEmpty()){
PlatformCatalog catalog = catalogManager.selectByPlatFormAndCatalogId(platform.getServerGBId(),catalogId);
if (catalog == null && catalogId.equals(platform.getDeviceGBId())) {
for (ChannelReduce channelReduce : channelReduces) {
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
DeviceChannel deviceChannel = deviceChannelMapper.getOne(channelReduce.getId());
deviceChannel.setParental(0);
deviceChannel.setCivilCode(platform.getServerGBDomain());
deviceChannelList.add(deviceChannel);
@@ -139,7 +139,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
return null;
}
for (ChannelReduce channelReduce : channelReduces) {
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
DeviceChannel deviceChannel = deviceChannelMapper.getOne(channelReduce.getId());
deviceChannel.setParental(0);
deviceChannel.setCivilCode(catalog.getCivilCode());
deviceChannel.setParentId(catalog.getParentId());

View File

@@ -234,7 +234,7 @@ public class PlayServiceImpl implements IPlayService {
if (device == null || !device.isOnLine()) {
return;
}
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
DeviceChannel deviceChannel = channelService.getOne(deviceId, channelId);
if (deviceChannel == null) {
return;
}
@@ -258,7 +258,7 @@ public class PlayServiceImpl implements IPlayService {
int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(event.getMediaServer(), event.getStream(), null,
device.isSsrcCheck(), true, 0, false, !deviceChannel.getHasAudio(), false, tcpMode);
device.isSsrcCheck(), true, 0, false, !deviceChannel.isHasAudio(), false, tcpMode);
playBack(event.getMediaServer(), ssrcInfo, deviceId, channelId, startTime, endTime, null);
}
}
@@ -321,7 +321,7 @@ public class PlayServiceImpl implements IPlayService {
}
String streamId = String.format("%s_%s", device.getDeviceId(), channelId);
int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, ssrc, device.isSsrcCheck(), false, 0, false, !channel.getHasAudio(), false, tcpMode);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, ssrc, device.isSsrcCheck(), false, 0, false, !channel.isHasAudio(), false, tcpMode);
if (ssrcInfo == null) {
callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getMsg(), null);
inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null,
@@ -695,7 +695,7 @@ public class PlayServiceImpl implements IPlayService {
Device device = redisCatchStorage.getDevice(deviceId);
streamInfo = onPublishHandler(mediaServerItem, mediaInfo, deviceId, channelId);
if (streamInfo != null) {
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
DeviceChannel deviceChannel = channelService.getOne(deviceId, channelId);
if (deviceChannel != null) {
deviceChannel.setStreamId(streamInfo.getStream());
channelService.startPlay(deviceId, channelId, streamInfo.getStream());
@@ -716,7 +716,7 @@ public class PlayServiceImpl implements IPlayService {
if (streamInfo != null) {
streamInfo.setStartTime(startTime);
streamInfo.setEndTime(endTime);
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
DeviceChannel deviceChannel = channelService.getOne(deviceId, channelId);
if (deviceChannel != null) {
deviceChannel.setStreamId(streamInfo.getStream());
channelService.startPlay(deviceId, channelId, streamInfo.getStream());
@@ -753,7 +753,7 @@ public class PlayServiceImpl implements IPlayService {
@Override
public void playBack(String deviceId, String channelId, String startTime,
String endTime, ErrorCallback<Object> callback) {
Device device = storager.queryVideoDevice(deviceId);
Device device = deviceService.getDevice(deviceId);
if (device == null) {
log.warn("[录像回放] 未找到设备 deviceId: {},channelId:{}", deviceId, channelId);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
@@ -778,7 +778,7 @@ public class PlayServiceImpl implements IPlayService {
.replace(" ", "");
String stream = deviceId + "_" + channelId + "_" + startTimeStr + "_" + endTimeTimeStr;
int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, stream, null, device.isSsrcCheck(), true, 0, false, !channel.getHasAudio(), false, tcpMode);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, stream, null, device.isSsrcCheck(), true, 0, false, !channel.isHasAudio(), false, tcpMode);
playBack(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, callback);
}
@@ -793,7 +793,7 @@ public class PlayServiceImpl implements IPlayService {
return;
}
Device device = storager.queryVideoDevice(deviceId);
Device device = deviceService.getDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在");
}
@@ -959,7 +959,7 @@ public class PlayServiceImpl implements IPlayService {
@Override
public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback<Object> callback) {
Device device = storager.queryVideoDevice(deviceId);
Device device = deviceService.getDevice(deviceId);
if (device == null) {
return;
}
@@ -976,7 +976,7 @@ public class PlayServiceImpl implements IPlayService {
}
int tcpMode = device.getStreamMode().equals("TCP-ACTIVE")? 2: (device.getStreamMode().equals("TCP-PASSIVE")? 1:0);
// 录像下载不使用固定流地址,固定流地址会导致如果开始时间与结束时间一致时文件错误的叠加在一起
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, null, device.isSsrcCheck(), true, 0, false,!channel.getHasAudio(), false, tcpMode);
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, null, device.isSsrcCheck(), true, 0, false,!channel.isHasAudio(), false, tcpMode);
download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, callback);
}
@@ -989,7 +989,7 @@ public class PlayServiceImpl implements IPlayService {
null);
return;
}
Device device = storager.queryVideoDevice(deviceId);
Device device = deviceService.getDevice(deviceId);
if (device == null) {
callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(),
"设备:" + deviceId + "不存在",
@@ -1198,7 +1198,7 @@ public class PlayServiceImpl implements IPlayService {
return null;
}
log.info("[语音喊话] device {}, channel: {}", device.getDeviceId(), channelId);
DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId);
DeviceChannel deviceChannel = channelService.getOne(device.getDeviceId(), channelId);
if (deviceChannel == null) {
log.warn("开启语音广播的时候未找到通道: {}", channelId);
return null;
@@ -1223,7 +1223,7 @@ public class PlayServiceImpl implements IPlayService {
return false;
}
log.info("[语音喊话] device {}, channel: {}", device.getDeviceId(), channelId);
DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId);
DeviceChannel deviceChannel = channelService.getOne(device.getDeviceId(), channelId);
if (deviceChannel == null) {
log.warn("开启语音广播的时候未找到通道: {}", channelId);
event.call("开启语音广播的时候未找到通道");
@@ -1396,7 +1396,7 @@ public class PlayServiceImpl implements IPlayService {
if (!result) {
throw new ServiceException("暂停RTP接收失败");
}
Device device = storager.queryVideoDevice(inviteInfo.getDeviceId());
Device device = deviceService.getDevice(inviteInfo.getDeviceId());
cmder.playPauseCmd(device, inviteInfo.getStreamInfo());
}
@@ -1424,7 +1424,7 @@ public class PlayServiceImpl implements IPlayService {
if (!result) {
throw new ServiceException("继续RTP接收失败");
}
Device device = storager.queryVideoDevice(inviteInfo.getDeviceId());
Device device = deviceService.getDevice(inviteInfo.getDeviceId());
cmder.playResumeCmd(device, inviteInfo.getStreamInfo());
}
@@ -1486,7 +1486,7 @@ public class PlayServiceImpl implements IPlayService {
}
// TODO 必须多端口模式才支持语音喊话鹤语音对讲
log.info("[语音对讲] device {}, channel: {}", device.getDeviceId(), channelId);
DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId);
DeviceChannel deviceChannel = channelService.getOne(device.getDeviceId(), channelId);
if (deviceChannel == null) {
log.warn("开启语音对讲的时候未找到通道: {}", channelId);
event.call("开启语音对讲的时候未找到通道");

View File

@@ -8,6 +8,8 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
@@ -36,6 +38,12 @@ public class RedisAlarmMsgListener implements MessageListener {
@Autowired
private ISIPCommanderForPlatform commanderForPlatform;
@Autowired
private IDeviceService deviceService;
@Autowired
private IDeviceChannelService channelService;
@Autowired
private IVideoManagerStorage storage;
@@ -108,7 +116,7 @@ public class RedisAlarmMsgListener implements MessageListener {
}
// 获取开启了消息推送的设备和平台
List<Device> devices = storage.queryDeviceWithAsMessageChannel();
List<Device> devices = channelService.queryDeviceWithAsMessageChannel();
if (devices.size() > 0) {
for (Device device : devices) {
try {
@@ -121,7 +129,7 @@ public class RedisAlarmMsgListener implements MessageListener {
}
}else {
Device device = storage.queryVideoDevice(gbId);
Device device = deviceService.getDevice(gbId);
ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId);
if (device != null && platform == null) {
try {