| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.common.SystemInfoDto; |
| | | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| | | import com.genersoft.iot.vmp.conf.UserSetup; |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| | | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| | | import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| | |
| | | */ |
| | | @Override |
| | | public boolean startPlay(StreamInfo stream) { |
| | | return redis.set(String.format("%S_%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(), stream.getStreamId(),stream.getDeviceID(), stream.getChannelId()), |
| | | return redis.set(String.format("%S_%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(), |
| | | stream.getStream(), stream.getDeviceID(), stream.getChannelId()), |
| | | stream); |
| | | } |
| | | |
| | |
| | | if (streamInfo == null) return false; |
| | | return redis.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
| | | userSetup.getServerId(), |
| | | streamInfo.getStreamId(), |
| | | streamInfo.getStream(), |
| | | streamInfo.getDeviceID(), |
| | | streamInfo.getChannelId())); |
| | | } |
| | |
| | | return (StreamInfo)redis.get(String.format("%S_%s_%s_%s_%s", |
| | | VideoManagerConstants.PLAYER_PREFIX, |
| | | userSetup.getServerId(), |
| | | streamInfo.getStreamId(), |
| | | streamInfo.getStream(), |
| | | streamInfo.getDeviceID(), |
| | | streamInfo.getChannelId())); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public StreamInfo queryPlayByDevice(String deviceId, String channelId) { |
| | | // List<Object> playLeys = redis.keys(String.format("%S_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
| | | List<Object> playLeys = redis.scan(String.format("%S_%s_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
| | | userSetup.getServerId(), |
| | | deviceId, |
| | |
| | | |
| | | @Override |
| | | public boolean startPlayback(StreamInfo stream) { |
| | | return redis.set(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, userSetup.getServerId(),stream.getStreamId(), |
| | | stream.getDeviceID(), stream.getChannelId()), stream); |
| | | return redis.set(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, |
| | | userSetup.getServerId(), stream.getStream(), stream.getDeviceID(), stream.getChannelId()), stream); |
| | | } |
| | | |
| | | @Override |
| | | public boolean startDownload(StreamInfo streamInfo) { |
| | | return redis.set(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, userSetup.getServerId(),streamInfo.getStreamId(), |
| | | streamInfo.getDeviceID(), streamInfo.getChannelId()), streamInfo); |
| | | return redis.set(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, userSetup.getServerId(), |
| | | streamInfo.getStream(), streamInfo.getDeviceID(), streamInfo.getChannelId()), streamInfo); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | return redis.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, |
| | | userSetup.getServerId(), |
| | | streamInfo.getStreamId(), |
| | | streamInfo.getStream(), |
| | | streamInfo.getDeviceID(), |
| | | streamInfo.getChannelId())); |
| | | } |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void addCpuInfo(double cpuInfo) { |
| | | String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetup.getServerId(); |
| | | SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>(); |
| | | systemInfoDto.setTime(format.format(System.currentTimeMillis())); |
| | | systemInfoDto.setData(cpuInfo); |
| | | redis.lSet(key, systemInfoDto); |
| | | // 每秒一个,最多只存30个 |
| | | if (redis.lGetListSize(key) > 30) { |
| | | for (int i = 0; i < redis.lGetListSize(key) - 30; i++) { |
| | | redis.lLeftPop(key); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void addMemInfo(double memInfo) { |
| | | String key = VideoManagerConstants.SYSTEM_INFO_MEM_PREFIX + userSetup.getServerId(); |
| | | SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>(); |
| | | systemInfoDto.setTime(format.format(System.currentTimeMillis())); |
| | | systemInfoDto.setData(memInfo); |
| | | redis.lSet(key, systemInfoDto); |
| | | // 每秒一个,最多只存30个 |
| | | if (redis.lGetListSize(key) > 30) { |
| | | for (int i = 0; i < redis.lGetListSize(key) - 30; i++) { |
| | | redis.lLeftPop(key); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void addNetInfo(Map<String, String> networkInterfaces) { |
| | | String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetup.getServerId(); |
| | | SystemInfoDto<Map<String, String>> systemInfoDto = new SystemInfoDto<>(); |
| | | systemInfoDto.setTime(format.format(System.currentTimeMillis())); |
| | | systemInfoDto.setData(networkInterfaces); |
| | | redis.lSet(key, systemInfoDto); |
| | | // 每秒一个,最多只存30个 |
| | | if (redis.lGetListSize(key) > 30) { |
| | | for (int i = 0; i < redis.lGetListSize(key) - 30; i++) { |
| | | redis.lLeftPop(key); |
| | | } |
| | | } |
| | | } |
| | | } |