| | |
| | | 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.media.zlm.ZLMServerConfig; |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public StreamInfo queryPlayByDevice(String deviceId, String code) { |
| | | 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", VideoManagerConstants.PLAYER_PREFIX, |
| | | deviceId, |
| | | code)); |
| | | channelId)); |
| | | if (playLeys == null || playLeys.size() == 0) return null; |
| | | return (StreamInfo)redis.get(playLeys.get(0).toString()); |
| | | } |
| | | |
| | | /** |
| | | * 更新流媒体信息 |
| | | * @param mediaServerConfig |
| | | * @param ZLMServerConfig |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateMediaInfo(MediaServerConfig mediaServerConfig) { |
| | | mediaServerConfig.setUpdateTime(System.currentTimeMillis()); |
| | | return redis.set(VideoManagerConstants.MEDIA_SERVER_PREFIX,mediaServerConfig); |
| | | public boolean updateMediaInfo(ZLMServerConfig ZLMServerConfig) { |
| | | ZLMServerConfig.setUpdateTime(System.currentTimeMillis()); |
| | | return redis.set(VideoManagerConstants.MEDIA_SERVER_PREFIX, ZLMServerConfig); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MediaServerConfig getMediaInfo() { |
| | | return (MediaServerConfig)redis.get(VideoManagerConstants.MEDIA_SERVER_PREFIX); |
| | | public ZLMServerConfig getMediaInfo() { |
| | | return (ZLMServerConfig)redis.get(VideoManagerConstants.MEDIA_SERVER_PREFIX); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return (SendRtpItem)redis.get(key); |
| | | } |
| | | |
| | | @Override |
| | | public List<SendRtpItem> querySendRTPServer(String platformGbId) { |
| | | String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + platformGbId + "_*"; |
| | | List<Object> queryResult = redis.scan(key); |
| | | List<SendRtpItem> result= new ArrayList<>(); |
| | | |
| | | for (int i = 0; i < queryResult.size(); i++) { |
| | | String keyItem = (String) queryResult.get(i); |
| | | result.add((SendRtpItem)redis.get(keyItem)); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 删除RTP推送信息缓存 |
| | | * @param platformGbId |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新媒体流列表 |
| | | * @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()); |
| | | public void clearCatchByDeviceId(String deviceId) { |
| | | List<Object> playLeys = redis.scan(String.format("%S_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, |
| | | deviceId)); |
| | | if (playLeys.size() > 0) { |
| | | for (Object key : playLeys) { |
| | | redis.del(key.toString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取当前媒体流列表 |
| | | * @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; |
| | | List<Object> playBackers = redis.scan(String.format("%S_*_%s_*", VideoManagerConstants.PLAY_BLACK_PREFIX, |
| | | deviceId)); |
| | | if (playBackers.size() > 0) { |
| | | for (Object key : playBackers) { |
| | | redis.del(key.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |