| | |
| | | package com.genersoft.iot.vmp.storager.impl; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.genersoft.iot.vmp.service.IGbStreamService; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.storager.dao.*; |
| | | import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; |
| | | import com.github.pagehelper.PageHelper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import org.springframework.transaction.TransactionDefinition; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description:视频设备数据存储-jdbc实现 |
| | | * @description:视频设备数据存储-jdbc实现 |
| | | * @author: swwheihei |
| | | * @date: 2020年5月6日 下午2:31:42 |
| | | */ |
| | |
| | | |
| | | @Autowired |
| | | private GbStreamMapper gbStreamMapper; |
| | | ; |
| | | |
| | | @Autowired |
| | | private PlatformGbStreamMapper platformGbStreamMapper; |
| | | |
| | | @Autowired |
| | | private IGbStreamService gbStreamService; |
| | | |
| | | @Autowired |
| | | private ParentPlatformMapper parentPlatformMapper; |
| | | |
| | | @Autowired |
| | | private VideoStreamSessionManager streamSession; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void deviceChannelOnline(String deviceId, String channelId) { |
| | | deviceChannelMapper.online(deviceId, channelId); |
| | | } |
| | | |
| | | @Override |
| | | public void deviceChannelOffline(String deviceId, String channelId) { |
| | | deviceChannelMapper.offline(deviceId, channelId); |
| | | } |
| | | |
| | | @Override |
| | | public void startPlay(String deviceId, String channelId, String streamId) { |
| | | deviceChannelMapper.startPlay(deviceId, channelId, streamId); |
| | | } |
| | |
| | | return deviceChannelMapper.queryChannel(deviceId, channelId); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int delChannel(String deviceId, String channelId) { |
| | | return deviceChannelMapper.del(deviceId, channelId); |
| | | } |
| | | |
| | | /** |
| | | * 获取多个设备 |
| | |
| | | // 更新缓存 |
| | | parentPlatformCatch.setParentPlatform(parentPlatform); |
| | | redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); |
| | | // 共享所有视频流,需要将现有视频流添加到此平台 |
| | | List<GbStream> gbStreams = gbStreamMapper.selectAll(); |
| | | if (gbStreams.size() > 0) { |
| | | if (parentPlatform.isShareAllLiveStream()) { |
| | | gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId()); |
| | | }else { |
| | | gbStreamService.delPlatformInfo(gbStreams); |
| | | } |
| | | } |
| | | return result > 0; |
| | | } |
| | | |
| | |
| | | logger.error("向数据库添加流代理失败:", e); |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | } |
| | | |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public GbStream queryStreamInParentPlatform(String platformId, String gbId) { |
| | | public List<GbStream> queryStreamInParentPlatform(String platformId, String gbId) { |
| | | return gbStreamMapper.queryStreamInPlatform(platformId, gbId); |
| | | } |
| | | |
| | |
| | | streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream()); |
| | | streamPushMapper.add(streamPushItem); |
| | | gbStreamMapper.setStatus(streamPushItem.getApp(), streamPushItem.getStream(), true); |
| | | if(!StringUtils.isEmpty(streamPushItem.getGbId() )){ |
| | | // 查找开启了全部直播流共享的上级平台 |
| | | List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); |
| | | if (parentPlatforms.size() > 0) { |
| | | for (ParentPlatform parentPlatform : parentPlatforms) { |
| | | streamPushItem.setPlatformId(parentPlatform.getServerGBId()); |
| | | String stream = streamPushItem.getStream(); |
| | | StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), stream, parentPlatform.getServerGBId()); |
| | | if (streamProxyItems == null) { |
| | | platformGbStreamMapper.add(streamPushItem); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void removeMedia(String app, String stream) { |
| | | streamPushMapper.del(app, stream); |
| | | public int removeMedia(String app, String stream) { |
| | | return streamPushMapper.del(app, stream); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void mediaOutline(String app, String streamId) { |
| | | gbStreamMapper.setStatus(app, streamId, false); |
| | | public int mediaOutline(String app, String streamId) { |
| | | return gbStreamMapper.setStatus(app, streamId, false); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return streamProxyMapper.selectForEnableInMediaServer(id, enable); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Device queryVideoDeviceByChannelId(String channelId) { |
| | | public Device queryVideoDeviceByChannelId( String channelId) { |
| | | Device result = null; |
| | | List<DeviceChannel> channelList = deviceChannelMapper.queryChannelByChannelId(channelId); |
| | | if (channelList.size() == 1) { |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) { |
| | | return streamProxyMapper.selectOne(app, streamId); |
| | | } |
| | | } |