| | |
| | | package com.genersoft.iot.vmp.storager.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.RealVideo; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| | | import com.genersoft.iot.vmp.gb28181.bean.PlatformRegister; |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| | | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | | @Component |
| | | public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean updateMediaInfo(MediaServerConfig mediaServerConfig) { |
| | | mediaServerConfig.setUpdateTime(System.currentTimeMillis()); |
| | | return redis.set(VideoManagerConstants.MEDIA_SERVER_PREFIX,mediaServerConfig); |
| | | } |
| | | |
| | |
| | | public void delPlatformRegisterInfo(String callId) { |
| | | redis.del(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + callId); |
| | | } |
| | | |
| | | @Override |
| | | public void cleanPlatformRegisterInfos() { |
| | | List regInfos = redis.scan(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + "*"); |
| | | for (Object key : regInfos) { |
| | | redis.del(key.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateSendRTPSever(SendRtpItem sendRtpItem) { |
| | | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + sendRtpItem.getPlatformId() + "_" + sendRtpItem.getChannelId(); |
| | | redis.set(key, sendRtpItem); |
| | | } |
| | | |
| | | @Override |
| | | public SendRtpItem querySendRTPServer(String platformGbId, String channelId) { |
| | | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + platformGbId + "_" + channelId; |
| | | return (SendRtpItem)redis.get(key); |
| | | } |
| | | |
| | | /** |
| | | * 删除RTP推送信息缓存 |
| | | * @param platformGbId |
| | | * @param channelId |
| | | */ |
| | | @Override |
| | | public void deleteSendRTPServer(String platformGbId, String channelId) { |
| | | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + platformGbId + "_" + channelId; |
| | | redis.del(key); |
| | | } |
| | | |
| | | /** |
| | | * 查询某个通道是否存在上级点播(RTP推送) |
| | | * @param channelId |
| | | */ |
| | | @Override |
| | | public boolean isChannelSendingRTP(String channelId) { |
| | | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + "*_" + channelId; |
| | | List<Object> RtpStreams = redis.scan(key); |
| | | if (RtpStreams.size() > 0) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新媒体流列表 |
| | | * @param mediaList |
| | | */ |
| | | @Override |
| | | public void updateMediaList(List<RealVideo> mediaList) { |
| | | String key = VideoManagerConstants.MEDIA_STREAM_PREFIX; |
| | | redis.del(key); |
| | | for (int i = 0; i < mediaList.size(); i++) { |
| | | RealVideo realVideo = mediaList.get(i); |
| | | redis.zAdd(key, realVideo, realVideo.getCreateStamp()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取当前媒体流列表 |
| | | * @return List<RealVideo> |
| | | */ |
| | | @Override |
| | | public JSONObject getMediaList(int start, int end) { |
| | | String key = VideoManagerConstants.MEDIA_STREAM_PREFIX; |
| | | Set<Object> realVideos = redis.ZRange(key, start, end); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("list", new ArrayList(realVideos)); |
| | | jsonObject.put("total", redis.zSize(key)); |
| | | |
| | | return jsonObject; |
| | | } |
| | | } |