临时提交

This commit is contained in:
648540858
2024-07-09 17:55:51 +08:00
parent 2235caca36
commit 046e7802f3
14 changed files with 295 additions and 170 deletions

View File

@@ -24,11 +24,8 @@ public interface IDeviceChannelService {
/**
* 批量添加设备通道
*
* @param deviceId 设备id
* @param channels 多个通道
*/
int updateChannels(String deviceId, List<DeviceChannel> channels);
int updateChannels(Device device, List<DeviceChannel> channels);
/**
* 获取统计信息
@@ -93,7 +90,10 @@ public interface IDeviceChannelService {
void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition);
void startPlay(String deviceId, String channelId, String stream);
void stopPlay(String deviceId, String channelId);
void batchUpdateChannelGPS(List<DeviceChannel> channelList);
void batchAddMobilePosition(List<MobilePosition> addMobilePositionList);
@@ -104,7 +104,9 @@ public interface IDeviceChannelService {
void delete(DeviceChannel channel);
void cleanChannelsForDevice(String deviceId);
void cleanChannelsForDevice(int deviceId);
boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannels);
}

View File

@@ -84,17 +84,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
@Override
public int updateChannels(String deviceId, List<DeviceChannel> channels) {
public int updateChannels(Device device, List<DeviceChannel> channels) {
List<DeviceChannel> addChannels = new ArrayList<>();
List<DeviceChannel> updateChannels = new ArrayList<>();
HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (channels != null && channels.size() > 0) {
List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null);
if (channelList.size() == 0) {
List<DeviceChannel> channelList = channelMapper.queryChannelsByDeviceDbId(device.getId());
if (channelList.isEmpty()) {
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channel.getDeviceId());
channel.setDeviceDbId(device.getId());
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId());
if (inviteInfo != null && inviteInfo.getStreamInfo() != null) {
channel.setStreamId(inviteInfo.getStreamInfo().getStream());
}
@@ -108,8 +107,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
channelsInStore.put(deviceChannel.getDeviceId(), deviceChannel);
}
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channel.getDeviceId());
channel.setDeviceDbId(device.getId());
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId());
if (inviteInfo != null && inviteInfo.getStreamInfo() != null) {
channel.setStreamId(inviteInfo.getStreamInfo().getStream());
}
@@ -231,7 +230,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override
public void delete(DeviceChannel channel) {
channelMapper.del(channel.getDeviceId(), channel.getDeviceId());
channelMapper.del(channel.getId());
}
@Override
@@ -344,6 +343,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
}
@Override
public void startPlay(String deviceId, String channelId, String stream) {
channelMapper.startPlay(deviceId, channelId, stream);
}
@Override
public void stopPlay(String deviceId, String channelId) {
channelMapper.stopPlay(deviceId, channelId);
@@ -393,7 +397,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
@Override
public void cleanChannelsForDevice(String deviceId) {
public void cleanChannelsForDevice(int deviceId) {
channelMapper.cleanChannelsByDeviceId(deviceId);
}

View File

@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.common.CommonCallback;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
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.session.AudioBroadcastManager;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
@@ -24,6 +25,7 @@ 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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -409,7 +411,7 @@ public class DeviceServiceImpl implements IDeviceService {
if (!deviceChannels.isEmpty()) {
List<DeviceChannel> deviceChannelsForStore = new ArrayList<>();
deviceChannelsForStore.addAll(deviceChannels);
deviceChannelService.updateChannels(device.getDeviceId(), deviceChannelsForStore);
deviceChannelService.updateChannels(device, deviceChannelsForStore);
}
}
@@ -545,11 +547,15 @@ public class DeviceServiceImpl implements IDeviceService {
@Override
public boolean delete(String deviceId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
}
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
try {
platformChannelMapper.delChannelForDeviceId(deviceId);
deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
deviceChannelMapper.cleanChannelsByDeviceId(device.getId());
if ( deviceMapper.del(deviceId) < 0 ) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);

View File

@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
@@ -39,6 +40,9 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
@Autowired
private IVideoManagerStorage storage;
@Autowired
private IDeviceChannelService deviceChannelService;
@Autowired
private UserSetting userSetting;
@@ -63,7 +67,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
InviteInfo inviteInfo = getInviteInfoByStream(null, event.getStream());
if (inviteInfo != null && (inviteInfo.getType() == InviteSessionType.PLAY || inviteInfo.getType() == InviteSessionType.PLAYBACK)) {
removeInviteInfo(inviteInfo);
storage.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
deviceChannelService.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
}
}
}

View File

@@ -13,10 +13,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.bean.ResultForOnPublish;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
@@ -59,6 +56,9 @@ public class MediaServiceImpl implements IMediaService {
@Autowired
private IInviteStreamService inviteStreamService;
@Autowired
private IDeviceChannelService deviceChannelService;
@Autowired
private VideoStreamSessionManager sessionManager;
@@ -267,7 +267,7 @@ public class MediaServiceImpl implements IMediaService {
inviteStreamService.removeInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(),
inviteInfo.getChannelId(), inviteInfo.getStream());
storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
deviceChannelService.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
return result;
}
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, stream, null);

View File

@@ -314,7 +314,7 @@ public class PlayServiceImpl implements IPlayService {
}else {
// 点播发起了但是尚未成功, 仅注册回调等待结果即可
inviteStreamService.once(InviteSessionType.PLAY, deviceId, channelId, null, callback);
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
channelService.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
}
}
@@ -698,7 +698,7 @@ public class PlayServiceImpl implements IPlayService {
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
if (deviceChannel != null) {
deviceChannel.setStreamId(streamInfo.getStream());
storager.startPlay(deviceId, channelId, streamInfo.getStream());
channelService.startPlay(deviceId, channelId, streamInfo.getStream());
}
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
if (inviteInfo != null) {
@@ -719,7 +719,7 @@ public class PlayServiceImpl implements IPlayService {
DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
if (deviceChannel != null) {
deviceChannel.setStreamId(streamInfo.getStream());
storager.startPlay(deviceId, channelId, streamInfo.getStream());
channelService.startPlay(deviceId, channelId, streamInfo.getStream());
}
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, mediaInfo.getStream());
if (inviteInfo != null) {
@@ -1638,7 +1638,7 @@ public class PlayServiceImpl implements IPlayService {
}
}
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channelId);
storager.stopPlay(device.getDeviceId(), channelId);
channelService.stopPlay(device.getDeviceId(), channelId);
channelService.stopPlay(device.getDeviceId(), channelId);
if (inviteInfo.getStreamInfo() != null) {
mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStream());