|  |  | 
 |  |  |             "_" + queryOnline + // 搜索是否在线 | 
 |  |  |             "_" + queryHasSubChannel + // 搜索是否含有子节点 | 
 |  |  |             "_" + "*"; | 
 |  |  | //      List<Object> deviceChannelList = redis.keys(queryStr); | 
 |  |  |       List<Object> deviceChannelList = redis.scan(queryStr); | 
 |  |  |       //对查询结果排序,避免出现通道排列顺序乱序的情况 | 
 |  |  |       Collections.sort(deviceChannelList,new Comparator<Object>(){ | 
 |  |  | 
 |  |  |             DeviceChannel deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(i)); | 
 |  |  |             StreamInfo streamInfo = stringStreamInfoMap.get(deviceId + "_" + deviceChannel.getChannelId()); | 
 |  |  |             deviceChannel.setPlay(streamInfo != null); | 
 |  |  |             if (streamInfo != null) deviceChannel.setSsrc(streamInfo.getSsrc()); | 
 |  |  |             if (streamInfo != null) deviceChannel.setStreamId(streamInfo.getStreamId()); | 
 |  |  |             result.add(deviceChannel); | 
 |  |  |          } | 
 |  |  |          pageResult.setData(result); | 
 |  |  | 
 |  |  |       PageResult pageResult = new PageResult<Device>(); | 
 |  |  |       pageResult.setPage(page); | 
 |  |  |       pageResult.setCount(count); | 
 |  |  |       Device device = null; | 
 |  |  |  | 
 |  |  |       if (deviceIds == null || deviceIds.length == 0) { | 
 |  |  |  | 
 |  |  | 
 |  |  |          pageResult.setTotal(deviceIdList.size()); | 
 |  |  |          int maxCount = (page + 1)* count; | 
 |  |  |          for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) { | 
 |  |  |             devices.add((Device)redis.get((String)deviceIdList.get(i))); | 
 |  |  |             // devices.add((Device)redis.get((String)deviceIdList.get(i))); | 
 |  |  |             device =(Device)redis.get((String)deviceIdList.get(i)); | 
 |  |  |             if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){ | 
 |  |  |                // outline(device.getDeviceId()); | 
 |  |  |             } | 
 |  |  |             devices.add(device); | 
 |  |  |          } | 
 |  |  |       } else { | 
 |  |  |          for (int i = 0; i < deviceIds.length; i++) { | 
 |  |  |             devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i])); | 
 |  |  |             // devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i])); | 
 |  |  |             device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]); | 
 |  |  |             if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){ | 
 |  |  |                // outline(device.getDeviceId()); | 
 |  |  |             } | 
 |  |  |             devices.add(device); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       pageResult.setData(devices); | 
 |  |  | 
 |  |  |    @Override | 
 |  |  |    public List<Device> queryVideoDeviceList(String[] deviceIds) { | 
 |  |  |       List<Device> devices = new ArrayList<>(); | 
 |  |  |       Device device = null; | 
 |  |  |  | 
 |  |  |       if (deviceIds == null || deviceIds.length == 0) { | 
 |  |  | //         List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*"); | 
 |  |  |          List<Object> deviceIdList = redis.scan(VideoManagerConstants.DEVICE_PREFIX+"*"); | 
 |  |  |          for (int i = 0; i < deviceIdList.size(); i++) { | 
 |  |  |             devices.add((Device)redis.get((String)deviceIdList.get(i))); | 
 |  |  |             device =(Device)redis.get((String)deviceIdList.get(i)); | 
 |  |  |             if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){ | 
 |  |  |                outline(device.getDeviceId()); | 
 |  |  |             } | 
 |  |  |             devices.add(device); | 
 |  |  |          } | 
 |  |  |       } else { | 
 |  |  |          for (int i = 0; i < deviceIds.length; i++) { | 
 |  |  |             devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i])); | 
 |  |  |             device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]); | 
 |  |  |             if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){ | 
 |  |  |                outline(device.getDeviceId()); | 
 |  |  |             } | 
 |  |  |             devices.add(device); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       return devices; | 
 |  |  | 
 |  |  |     */ | 
 |  |  |    @Override | 
 |  |  |    public boolean startPlay(StreamInfo stream) { | 
 |  |  |       return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, stream.getSsrc(),stream.getDeviceID(), stream.getCahnnelId()), | 
 |  |  |       return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getCahnnelId()), | 
 |  |  |             stream); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | 
 |  |  |       if (streamInfo == null) return false; | 
 |  |  |       DeviceChannel deviceChannel = queryChannel(streamInfo.getDeviceID(), streamInfo.getCahnnelId()); | 
 |  |  |       if (deviceChannel != null) { | 
 |  |  |          deviceChannel.setSsrc(null); | 
 |  |  |          deviceChannel.setStreamId(null); | 
 |  |  |          deviceChannel.setPlay(false); | 
 |  |  |          updateChannel(streamInfo.getDeviceID(), deviceChannel); | 
 |  |  |       } | 
 |  |  |       return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, | 
 |  |  |             streamInfo.getSsrc(), | 
 |  |  |             streamInfo.getStreamId(), | 
 |  |  |             streamInfo.getDeviceID(), | 
 |  |  |             streamInfo.getCahnnelId())); | 
 |  |  |    } | 
 |  |  | 
 |  |  |    public StreamInfo queryPlay(StreamInfo streamInfo) { | 
 |  |  |       return (StreamInfo)redis.get(String.format("%S_%s_%s_%s", | 
 |  |  |             VideoManagerConstants.PLAYER_PREFIX, | 
 |  |  |             streamInfo.getSsrc(), | 
 |  |  |             streamInfo.getStreamId(), | 
 |  |  |             streamInfo.getDeviceID(), | 
 |  |  |             streamInfo.getCahnnelId())); | 
 |  |  |    } | 
 |  |  |    @Override | 
 |  |  |    public StreamInfo queryPlayBySSRC(String ssrc) { | 
 |  |  | //      List<Object> playLeys = redis.keys(String.format("%S_%s_*", VideoManagerConstants.PLAYER_PREFIX, ssrc)); | 
 |  |  |       List<Object> playLeys = redis.scan(String.format("%S_%s_*", VideoManagerConstants.PLAYER_PREFIX, ssrc)); | 
 |  |  |    public StreamInfo queryPlayByStreamId(String steamId) { | 
 |  |  |       List<Object> playLeys = redis.scan(String.format("%S_%s_*", VideoManagerConstants.PLAYER_PREFIX, steamId)); | 
 |  |  |       if (playLeys == null || playLeys.size() == 0) return null; | 
 |  |  |       return (StreamInfo)redis.get(playLeys.get(0).toString()); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    @Override | 
 |  |  |    public StreamInfo queryPlaybackBySSRC(String ssrc) { | 
 |  |  | //      List<Object> playLeys = redis.keys(String.format("%S_%s_*", VideoManagerConstants.PLAYER_PREFIX, ssrc)); | 
 |  |  |       List<Object> playLeys = redis.scan(String.format("%S_%s_*", VideoManagerConstants.PLAY_BLACK_PREFIX, ssrc)); | 
 |  |  |    public StreamInfo queryPlaybackByStreamId(String steamId) { | 
 |  |  |       List<Object> playLeys = redis.scan(String.format("%S_%s_*", VideoManagerConstants.PLAY_BLACK_PREFIX, steamId)); | 
 |  |  |       if (playLeys == null || playLeys.size() == 0) return null; | 
 |  |  |       return (StreamInfo)redis.get(playLeys.get(0).toString()); | 
 |  |  |    } | 
 |  |  | 
 |  |  |  | 
 |  |  |    @Override | 
 |  |  |    public boolean startPlayback(StreamInfo stream) { | 
 |  |  |       return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, stream.getSsrc(),stream.getDeviceID(), stream.getCahnnelId()), | 
 |  |  |       return redis.set(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, stream.getStreamId(),stream.getDeviceID(), stream.getCahnnelId()), | 
 |  |  |             stream); | 
 |  |  |    } | 
 |  |  |  | 
 |  |  | 
 |  |  |       if (streamInfo == null) return false; | 
 |  |  |       DeviceChannel deviceChannel = queryChannel(streamInfo.getDeviceID(), streamInfo.getCahnnelId()); | 
 |  |  |       if (deviceChannel != null) { | 
 |  |  |          deviceChannel.setSsrc(null); | 
 |  |  |          deviceChannel.setStreamId(null); | 
 |  |  |          deviceChannel.setPlay(false); | 
 |  |  |          updateChannel(streamInfo.getDeviceID(), deviceChannel); | 
 |  |  |       } | 
 |  |  |       return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, | 
 |  |  |             streamInfo.getSsrc(), | 
 |  |  |             streamInfo.getStreamId(), | 
 |  |  |             streamInfo.getDeviceID(), | 
 |  |  |             streamInfo.getCahnnelId())); | 
 |  |  |    } | 
 |  |  | 
 |  |  |       List<Object> playLeys = redis.scan(String.format("%S_*_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, | 
 |  |  |             deviceId, | 
 |  |  |             code)); | 
 |  |  |       if (playLeys == null || playLeys.size() == 0) { | 
 |  |  |          playLeys = redis.scan(String.format("%S_*_*_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, | 
 |  |  |             deviceId)); | 
 |  |  |       } | 
 |  |  |       if (playLeys == null || playLeys.size() == 0) return null; | 
 |  |  |       return (StreamInfo)redis.get(playLeys.get(0).toString()); | 
 |  |  |    } |