|
@ -134,6 +134,8 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count) { |
|
|
public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count) { |
|
|
|
|
|
// 获取到所有正在播放的流
|
|
|
|
|
|
Map<String, StreamInfo> stringStreamInfoMap = queryPlayByDeviceId(deviceId); |
|
|
List<DeviceChannel> result = new ArrayList<>(); |
|
|
List<DeviceChannel> result = new ArrayList<>(); |
|
|
PageResult pageResult = new PageResult<DeviceChannel>(); |
|
|
PageResult pageResult = new PageResult<DeviceChannel>(); |
|
|
String queryContent = "*"; |
|
|
String queryContent = "*"; |
|
@ -154,7 +156,11 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { |
|
|
int maxCount = (page + 1 ) * count; |
|
|
int maxCount = (page + 1 ) * count; |
|
|
if (deviceChannelList != null && deviceChannelList.size() > 0 ) { |
|
|
if (deviceChannelList != null && deviceChannelList.size() > 0 ) { |
|
|
for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) { |
|
|
for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) { |
|
|
result.add((DeviceChannel)redis.get((String)deviceChannelList.get(i))); |
|
|
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()); |
|
|
|
|
|
result.add(deviceChannel); |
|
|
} |
|
|
} |
|
|
pageResult.setData(result); |
|
|
pageResult.setData(result); |
|
|
} |
|
|
} |
|
@ -162,6 +168,8 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { |
|
|
return pageResult; |
|
|
return pageResult; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) { |
|
|
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) { |
|
|
List<DeviceChannel> result = new ArrayList<>(); |
|
|
List<DeviceChannel> result = new ArrayList<>(); |
|
@ -231,7 +239,13 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public DeviceChannel queryChannel(String deviceId, String channelId) { |
|
|
public DeviceChannel queryChannel(String deviceId, String channelId) { |
|
|
return (DeviceChannel)redis.get(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + channelId + "_"); |
|
|
DeviceChannel deviceChannel = null; |
|
|
|
|
|
List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + |
|
|
|
|
|
"_" + channelId + "*"); |
|
|
|
|
|
if (deviceChannelList != null && deviceChannelList.size() > 0 ) { |
|
|
|
|
|
deviceChannel = (DeviceChannel)redis.get((String)deviceChannelList.get(0)); |
|
|
|
|
|
} |
|
|
|
|
|
return deviceChannel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -345,6 +359,12 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { |
|
|
@Override |
|
|
@Override |
|
|
public boolean stopPlay(StreamInfo streamInfo) { |
|
|
public boolean stopPlay(StreamInfo streamInfo) { |
|
|
if (streamInfo == null) return false; |
|
|
if (streamInfo == null) return false; |
|
|
|
|
|
DeviceChannel deviceChannel = queryChannel(streamInfo.getDeviceID(), streamInfo.getCahnnelId()); |
|
|
|
|
|
if (deviceChannel != null) { |
|
|
|
|
|
deviceChannel.setSsrc(null); |
|
|
|
|
|
deviceChannel.setPlay(false); |
|
|
|
|
|
updateChannel(streamInfo.getDeviceID(), deviceChannel); |
|
|
|
|
|
} |
|
|
return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
|
|
return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
|
|
streamInfo.getSsrc(), |
|
|
streamInfo.getSsrc(), |
|
|
streamInfo.getDeviceID(), |
|
|
streamInfo.getDeviceID(), |
|
@ -366,7 +386,7 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { |
|
|
@Override |
|
|
@Override |
|
|
public StreamInfo queryPlayBySSRC(String ssrc) { |
|
|
public StreamInfo queryPlayBySSRC(String ssrc) { |
|
|
List<Object> playLeys = redis.keys(String.format("%S_%s_*", VideoManagerConstants.PLAYER_PREFIX, ssrc)); |
|
|
List<Object> playLeys = redis.keys(String.format("%S_%s_*", VideoManagerConstants.PLAYER_PREFIX, ssrc)); |
|
|
if (playLeys.size() == 0) return null; |
|
|
if (playLeys == null || playLeys.size() == 0) return null; |
|
|
return (StreamInfo)redis.get(playLeys.get(0).toString()); |
|
|
return (StreamInfo)redis.get(playLeys.get(0).toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -375,6 +395,7 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { |
|
|
List<Object> playLeys = redis.keys(String.format("%S_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
|
|
List<Object> playLeys = redis.keys(String.format("%S_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
|
|
deviceId, |
|
|
deviceId, |
|
|
code)); |
|
|
code)); |
|
|
|
|
|
if (playLeys == null || playLeys.size() == 0) return null; |
|
|
return (StreamInfo)redis.get(playLeys.get(0).toString()); |
|
|
return (StreamInfo)redis.get(playLeys.get(0).toString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -438,6 +459,19 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Map<String, StreamInfo> queryPlayByDeviceId(String deviceId) { |
|
|
|
|
|
Map<String, StreamInfo> streamInfos = new HashMap<>(); |
|
|
|
|
|
List<Object> playLeys = redis.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId)); |
|
|
|
|
|
if (playLeys.size() == 0) return streamInfos; |
|
|
|
|
|
for (int i = 0; i < playLeys.size(); i++) { |
|
|
|
|
|
String key = (String) playLeys.get(i); |
|
|
|
|
|
StreamInfo streamInfo = (StreamInfo)redis.get(key); |
|
|
|
|
|
streamInfos.put(streamInfo.getDeviceID() + "_" + streamInfo.getCahnnelId(), streamInfo); |
|
|
|
|
|
} |
|
|
|
|
|
return streamInfos; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|