Commit fa13b22819a8f4427f1f51d06b6590952bc83e95
1 parent
4a34097b
invite消息缓存字符间隔改为使用:代替_,避免scan查询失败
Showing
1 changed file
with
21 additions
and
21 deletions
src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java
| @@ -77,10 +77,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | @@ -77,10 +77,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | ||
| 77 | 77 | ||
| 78 | } | 78 | } |
| 79 | String key = VideoManagerConstants.INVITE_PREFIX + | 79 | String key = VideoManagerConstants.INVITE_PREFIX + |
| 80 | - "_" + inviteInfoForUpdate.getType() + | ||
| 81 | - "_" + inviteInfoForUpdate.getDeviceId() + | ||
| 82 | - "_" + inviteInfoForUpdate.getChannelId() + | ||
| 83 | - "_" + inviteInfoForUpdate.getStream(); | 80 | + ":" + inviteInfoForUpdate.getType() + |
| 81 | + ":" + inviteInfoForUpdate.getDeviceId() + | ||
| 82 | + ":" + inviteInfoForUpdate.getChannelId() + | ||
| 83 | + ":" + inviteInfoForUpdate.getStream(); | ||
| 84 | redisTemplate.opsForValue().set(key, inviteInfoForUpdate); | 84 | redisTemplate.opsForValue().set(key, inviteInfoForUpdate); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| @@ -93,10 +93,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | @@ -93,10 +93,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | ||
| 93 | } | 93 | } |
| 94 | removeInviteInfo(inviteInfoInDb); | 94 | removeInviteInfo(inviteInfoInDb); |
| 95 | String key = VideoManagerConstants.INVITE_PREFIX + | 95 | String key = VideoManagerConstants.INVITE_PREFIX + |
| 96 | - "_" + inviteInfo.getType() + | ||
| 97 | - "_" + inviteInfo.getDeviceId() + | ||
| 98 | - "_" + inviteInfo.getChannelId() + | ||
| 99 | - "_" + stream; | 96 | + ":" + inviteInfo.getType() + |
| 97 | + ":" + inviteInfo.getDeviceId() + | ||
| 98 | + ":" + inviteInfo.getChannelId() + | ||
| 99 | + ":" + stream; | ||
| 100 | inviteInfoInDb.setStream(stream); | 100 | inviteInfoInDb.setStream(stream); |
| 101 | if (inviteInfoInDb.getSsrcInfo() != null) { | 101 | if (inviteInfoInDb.getSsrcInfo() != null) { |
| 102 | inviteInfoInDb.getSsrcInfo().setStream(stream); | 102 | inviteInfoInDb.getSsrcInfo().setStream(stream); |
| @@ -108,10 +108,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | @@ -108,10 +108,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | ||
| 108 | @Override | 108 | @Override |
| 109 | public InviteInfo getInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) { | 109 | public InviteInfo getInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) { |
| 110 | String key = VideoManagerConstants.INVITE_PREFIX + | 110 | String key = VideoManagerConstants.INVITE_PREFIX + |
| 111 | - "_" + (type != null ? type : "*") + | ||
| 112 | - "_" + (deviceId != null ? deviceId : "*") + | ||
| 113 | - "_" + (channelId != null ? channelId : "*") + | ||
| 114 | - "_" + (stream != null ? stream : "*"); | 111 | + ":" + (type != null ? type : "*") + |
| 112 | + ":" + (deviceId != null ? deviceId : "*") + | ||
| 113 | + ":" + (channelId != null ? channelId : "*") + | ||
| 114 | + ":" + (stream != null ? stream : "*"); | ||
| 115 | List<Object> scanResult = RedisUtil.scan(redisTemplate, key); | 115 | List<Object> scanResult = RedisUtil.scan(redisTemplate, key); |
| 116 | if (scanResult.size() != 1) { | 116 | if (scanResult.size() != 1) { |
| 117 | return null; | 117 | return null; |
| @@ -133,10 +133,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | @@ -133,10 +133,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | ||
| 133 | @Override | 133 | @Override |
| 134 | public void removeInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) { | 134 | public void removeInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) { |
| 135 | String scanKey = VideoManagerConstants.INVITE_PREFIX + | 135 | String scanKey = VideoManagerConstants.INVITE_PREFIX + |
| 136 | - "_" + (type != null ? type : "*") + | ||
| 137 | - "_" + (deviceId != null ? deviceId : "*") + | ||
| 138 | - "_" + (channelId != null ? channelId : "*") + | ||
| 139 | - "_" + (stream != null ? stream : "*"); | 136 | + ":" + (type != null ? type : "*") + |
| 137 | + ":" + (deviceId != null ? deviceId : "*") + | ||
| 138 | + ":" + (channelId != null ? channelId : "*") + | ||
| 139 | + ":" + (stream != null ? stream : "*"); | ||
| 140 | List<Object> scanResult = RedisUtil.scan(redisTemplate, scanKey); | 140 | List<Object> scanResult = RedisUtil.scan(redisTemplate, scanKey); |
| 141 | if (scanResult.size() > 0) { | 141 | if (scanResult.size() > 0) { |
| 142 | for (Object keyObj : scanResult) { | 142 | for (Object keyObj : scanResult) { |
| @@ -174,10 +174,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | @@ -174,10 +174,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | ||
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | private String buildKey(InviteSessionType type, String deviceId, String channelId, String stream) { | 176 | private String buildKey(InviteSessionType type, String deviceId, String channelId, String stream) { |
| 177 | - String key = type + "_" + deviceId + "_" + channelId; | 177 | + String key = type + ":" + deviceId + ":" + channelId; |
| 178 | // 如果ssrc未null那么可以实现一个通道只能一次操作,ssrc不为null则可以支持一个通道多次invite | 178 | // 如果ssrc未null那么可以实现一个通道只能一次操作,ssrc不为null则可以支持一个通道多次invite |
| 179 | if (stream != null) { | 179 | if (stream != null) { |
| 180 | - key += ("_" + stream); | 180 | + key += (":" + stream); |
| 181 | } | 181 | } |
| 182 | return key; | 182 | return key; |
| 183 | } | 183 | } |
| @@ -191,7 +191,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | @@ -191,7 +191,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | ||
| 191 | @Override | 191 | @Override |
| 192 | public int getStreamInfoCount(String mediaServerId) { | 192 | public int getStreamInfoCount(String mediaServerId) { |
| 193 | int count = 0; | 193 | int count = 0; |
| 194 | - String key = VideoManagerConstants.INVITE_PREFIX + "_*_*_*_*"; | 194 | + String key = VideoManagerConstants.INVITE_PREFIX + ":*:*:*:*"; |
| 195 | List<Object> scanResult = RedisUtil.scan(redisTemplate, key); | 195 | List<Object> scanResult = RedisUtil.scan(redisTemplate, key); |
| 196 | if (scanResult.size() == 0) { | 196 | if (scanResult.size() == 0) { |
| 197 | return 0; | 197 | return 0; |
| @@ -222,10 +222,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | @@ -222,10 +222,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { | ||
| 222 | 222 | ||
| 223 | 223 | ||
| 224 | private String buildSubStreamKey(InviteSessionType type, String deviceId, String channelId, String stream) { | 224 | private String buildSubStreamKey(InviteSessionType type, String deviceId, String channelId, String stream) { |
| 225 | - String key = type + "_" + "_" + deviceId + "_" + channelId; | 225 | + String key = type + ":" + ":" + deviceId + ":" + channelId; |
| 226 | // 如果ssrc为null那么可以实现一个通道只能一次操作,ssrc不为null则可以支持一个通道多次invite | 226 | // 如果ssrc为null那么可以实现一个通道只能一次操作,ssrc不为null则可以支持一个通道多次invite |
| 227 | if (stream != null) { | 227 | if (stream != null) { |
| 228 | - key += ("_" + stream); | 228 | + key += (":" + stream); |
| 229 | } | 229 | } |
| 230 | return key; | 230 | return key; |
| 231 | } | 231 | } |