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 | 77 | |
| 78 | 78 | } |
| 79 | 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 | 84 | redisTemplate.opsForValue().set(key, inviteInfoForUpdate); |
| 85 | 85 | } |
| 86 | 86 | |
| ... | ... | @@ -93,10 +93,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { |
| 93 | 93 | } |
| 94 | 94 | removeInviteInfo(inviteInfoInDb); |
| 95 | 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 | 100 | inviteInfoInDb.setStream(stream); |
| 101 | 101 | if (inviteInfoInDb.getSsrcInfo() != null) { |
| 102 | 102 | inviteInfoInDb.getSsrcInfo().setStream(stream); |
| ... | ... | @@ -108,10 +108,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { |
| 108 | 108 | @Override |
| 109 | 109 | public InviteInfo getInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) { |
| 110 | 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 | 115 | List<Object> scanResult = RedisUtil.scan(redisTemplate, key); |
| 116 | 116 | if (scanResult.size() != 1) { |
| 117 | 117 | return null; |
| ... | ... | @@ -133,10 +133,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { |
| 133 | 133 | @Override |
| 134 | 134 | public void removeInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) { |
| 135 | 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 | 140 | List<Object> scanResult = RedisUtil.scan(redisTemplate, scanKey); |
| 141 | 141 | if (scanResult.size() > 0) { |
| 142 | 142 | for (Object keyObj : scanResult) { |
| ... | ... | @@ -174,10 +174,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 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 | 178 | // 如果ssrc未null那么可以实现一个通道只能一次操作,ssrc不为null则可以支持一个通道多次invite |
| 179 | 179 | if (stream != null) { |
| 180 | - key += ("_" + stream); | |
| 180 | + key += (":" + stream); | |
| 181 | 181 | } |
| 182 | 182 | return key; |
| 183 | 183 | } |
| ... | ... | @@ -191,7 +191,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService { |
| 191 | 191 | @Override |
| 192 | 192 | public int getStreamInfoCount(String mediaServerId) { |
| 193 | 193 | int count = 0; |
| 194 | - String key = VideoManagerConstants.INVITE_PREFIX + "_*_*_*_*"; | |
| 194 | + String key = VideoManagerConstants.INVITE_PREFIX + ":*:*:*:*"; | |
| 195 | 195 | List<Object> scanResult = RedisUtil.scan(redisTemplate, key); |
| 196 | 196 | if (scanResult.size() == 0) { |
| 197 | 197 | return 0; |
| ... | ... | @@ -222,10 +222,10 @@ public class InviteStreamServiceImpl implements IInviteStreamService { |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 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 | 226 | // 如果ssrc为null那么可以实现一个通道只能一次操作,ssrc不为null则可以支持一个通道多次invite |
| 227 | 227 | if (stream != null) { |
| 228 | - key += ("_" + stream); | |
| 228 | + key += (":" + stream); | |
| 229 | 229 | } |
| 230 | 230 | return key; |
| 231 | 231 | } | ... | ... |