修复国标视频点播三种点播方式(自动点播,上级点播,接口点播)并发情况下失败的问题
This commit is contained in:
@@ -23,34 +23,6 @@ public interface IRedisCatchStorage {
|
||||
*/
|
||||
Long getCSEQ();
|
||||
|
||||
/**
|
||||
* 开始播放时将流存入
|
||||
*
|
||||
* @param stream 流信息
|
||||
* @return
|
||||
*/
|
||||
boolean startPlay(StreamInfo stream);
|
||||
|
||||
|
||||
/**
|
||||
* 停止播放时删除
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean stopPlay(StreamInfo streamInfo);
|
||||
|
||||
/**
|
||||
* 查询播放列表
|
||||
* @return
|
||||
*/
|
||||
StreamInfo queryPlay(StreamInfo streamInfo);
|
||||
|
||||
StreamInfo queryPlayByStreamId(String steamId);
|
||||
|
||||
StreamInfo queryPlayByDevice(String deviceId, String channelId);
|
||||
|
||||
Map<String, StreamInfo> queryPlayByDeviceId(String deviceId);
|
||||
|
||||
boolean startPlayback(StreamInfo stream, String callId);
|
||||
|
||||
boolean stopPlayback(String deviceId, String channelId, String stream, String callId);
|
||||
|
||||
@@ -92,87 +92,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始播放时将流存入redis
|
||||
*/
|
||||
@Override
|
||||
public boolean startPlay(StreamInfo stream) {
|
||||
|
||||
redisTemplate.opsForValue().set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),
|
||||
stream.getMediaServerId(), stream.getStream(), stream.getDeviceID(), stream.getChannelId()),
|
||||
stream);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止播放时从redis删除
|
||||
*/
|
||||
@Override
|
||||
public boolean stopPlay(StreamInfo streamInfo) {
|
||||
if (streamInfo == null) {
|
||||
return false;
|
||||
}
|
||||
Boolean result = redisTemplate.delete(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
|
||||
userSetting.getServerId(),
|
||||
streamInfo.getMediaServerId(),
|
||||
streamInfo.getStream(),
|
||||
streamInfo.getDeviceID(),
|
||||
streamInfo.getChannelId()));
|
||||
return result != null && result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询播放列表
|
||||
*/
|
||||
@Override
|
||||
public StreamInfo queryPlay(StreamInfo streamInfo) {
|
||||
return (StreamInfo)redisTemplate.opsForValue().get(String.format("%S_%s_%s_%s_%s_%s",
|
||||
VideoManagerConstants.PLAYER_PREFIX,
|
||||
userSetting.getServerId(),
|
||||
streamInfo.getMediaServerId(),
|
||||
streamInfo.getStream(),
|
||||
streamInfo.getDeviceID(),
|
||||
streamInfo.getChannelId()));
|
||||
}
|
||||
@Override
|
||||
public StreamInfo queryPlayByStreamId(String streamId) {
|
||||
List<Object> playLeys = RedisUtil.scan(redisTemplate, String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
||||
if (playLeys.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return (StreamInfo)redisTemplate.opsForValue().get(playLeys.get(0).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamInfo queryPlayByDevice(String deviceId, String channelId) {
|
||||
List<Object> playLeys = RedisUtil.scan(redisTemplate, String.format("%S_%s_*_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
|
||||
userSetting.getServerId(),
|
||||
deviceId,
|
||||
channelId));
|
||||
if (playLeys.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return (StreamInfo)redisTemplate.opsForValue().get(playLeys.get(0).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, StreamInfo> queryPlayByDeviceId(String deviceId) {
|
||||
Map<String, StreamInfo> streamInfos = new HashMap<>();
|
||||
List<Object> players = RedisUtil.scan(redisTemplate, String.format("%S_%s_*_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),deviceId));
|
||||
if (players.size() == 0) {
|
||||
return streamInfos;
|
||||
}
|
||||
for (Object player : players) {
|
||||
String key = (String) player;
|
||||
StreamInfo streamInfo = JsonUtil.redisJsonToObject(redisTemplate, key, StreamInfo.class);
|
||||
if (Objects.isNull(streamInfo)) {
|
||||
continue;
|
||||
}
|
||||
streamInfos.put(streamInfo.getDeviceID() + "_" + streamInfo.getChannelId(), streamInfo);
|
||||
}
|
||||
return streamInfos;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean startPlayback(StreamInfo stream, String callId) {
|
||||
|
||||
Reference in New Issue
Block a user