|  | @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.gb28181.session;
 | 
	
		
			
				|  |  |  import com.genersoft.iot.vmp.common.VideoManagerConstants;
 | 
	
		
			
				|  |  |  import com.genersoft.iot.vmp.conf.UserSetting;
 | 
	
		
			
				|  |  |  import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
 | 
	
		
			
				|  |  | -import com.genersoft.iot.vmp.utils.redis.RedisUtil;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.data.redis.core.RedisTemplate;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Component;
 | 
	
	
		
			
				|  | @@ -27,39 +26,34 @@ public class SipInviteSessionManager {
 | 
	
		
			
				|  |  |  	 * 添加一个点播/回放的事务信息
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	public void put(SsrcTransaction ssrcTransaction){
 | 
	
		
			
				|  |  | -		redisTemplate.opsForValue().set(VideoManagerConstants.SIP_INVITE_SESSION_STREAM + userSetting.getServerId()
 | 
	
		
			
				|  |  | -				+ ":" + ssrcTransaction.getStream(), ssrcTransaction);
 | 
	
		
			
				|  |  | +		redisTemplate.opsForHash().put(VideoManagerConstants.SIP_INVITE_SESSION_STREAM + userSetting.getServerId()
 | 
	
		
			
				|  |  | +				, ssrcTransaction.getStream(), ssrcTransaction);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		redisTemplate.opsForValue().set(VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId()
 | 
	
		
			
				|  |  | -				+ ":" + ssrcTransaction.getCallId(), ssrcTransaction);
 | 
	
		
			
				|  |  | +		redisTemplate.opsForHash().put(VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId()
 | 
	
		
			
				|  |  | +				, ssrcTransaction.getCallId(), ssrcTransaction);
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	public SsrcTransaction getSsrcTransactionByStream(String stream){
 | 
	
		
			
				|  |  | -		String key = VideoManagerConstants.SIP_INVITE_SESSION_STREAM + userSetting.getServerId() + ":" + stream;
 | 
	
		
			
				|  |  | -		return (SsrcTransaction)redisTemplate.opsForValue().get(key);
 | 
	
		
			
				|  |  | +		String key = VideoManagerConstants.SIP_INVITE_SESSION_STREAM + userSetting.getServerId();
 | 
	
		
			
				|  |  | +		return (SsrcTransaction)redisTemplate.opsForHash().get(key, stream);
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	public SsrcTransaction getSsrcTransactionByCallId(String callId){
 | 
	
		
			
				|  |  | -		String key = VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId() + ":" + callId;
 | 
	
		
			
				|  |  | -		return (SsrcTransaction)redisTemplate.opsForValue().get(key);
 | 
	
		
			
				|  |  | +		String key = VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId();
 | 
	
		
			
				|  |  | +		return (SsrcTransaction)redisTemplate.opsForHash().get(key, callId);
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	public List<SsrcTransaction> getSsrcTransactionByDeviceId(String deviceId){
 | 
	
		
			
				|  |  | -		String key = VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId() + ":*";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
 | 
	
		
			
				|  |  | -		if (scanResult.isEmpty()) {
 | 
	
		
			
				|  |  | -			return new ArrayList<>();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +		String key = VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId();
 | 
	
		
			
				|  |  | +		List<Object> values = redisTemplate.opsForHash().values(key);
 | 
	
		
			
				|  |  |  		List<SsrcTransaction> result = new ArrayList<>();
 | 
	
		
			
				|  |  | -		for (Object keyObj : scanResult) {
 | 
	
		
			
				|  |  | -			SsrcTransaction ssrcTransaction = (SsrcTransaction)redisTemplate.opsForValue().get(keyObj);
 | 
	
		
			
				|  |  | +		for (Object value : values) {
 | 
	
		
			
				|  |  | +			SsrcTransaction ssrcTransaction = (SsrcTransaction) value;
 | 
	
		
			
				|  |  |  			if (ssrcTransaction != null && deviceId.equals(ssrcTransaction.getDeviceId())) {
 | 
	
		
			
				|  |  |  				result.add(ssrcTransaction);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		return result;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	public void removeByStream(String stream) {
 | 
	
	
		
			
				|  | @@ -67,9 +61,9 @@ public class SipInviteSessionManager {
 | 
	
		
			
				|  |  |  		if (ssrcTransaction == null ) {
 | 
	
		
			
				|  |  |  			return;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		redisTemplate.delete(VideoManagerConstants.SIP_INVITE_SESSION_STREAM + userSetting.getServerId() + ":" +  stream);
 | 
	
		
			
				|  |  | +		redisTemplate.opsForHash().delete(VideoManagerConstants.SIP_INVITE_SESSION_STREAM + userSetting.getServerId(), stream);
 | 
	
		
			
				|  |  |  		if (ssrcTransaction.getCallId() != null) {
 | 
	
		
			
				|  |  | -			redisTemplate.delete(VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId() + ":" +  ssrcTransaction.getCallId());
 | 
	
		
			
				|  |  | +			redisTemplate.opsForHash().delete(VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId(), ssrcTransaction.getCallId());
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -78,23 +72,18 @@ public class SipInviteSessionManager {
 | 
	
		
			
				|  |  |  		if (ssrcTransaction == null ) {
 | 
	
		
			
				|  |  |  			return;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		redisTemplate.delete(VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId() + ":" +  callId);
 | 
	
		
			
				|  |  | +		redisTemplate.opsForHash().delete(VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId(), callId);
 | 
	
		
			
				|  |  |  		if (ssrcTransaction.getStream() != null) {
 | 
	
		
			
				|  |  | -			redisTemplate.delete(VideoManagerConstants.SIP_INVITE_SESSION_STREAM + userSetting.getServerId() + ":" +  ssrcTransaction.getStream());
 | 
	
		
			
				|  |  | +			redisTemplate.opsForHash().delete(VideoManagerConstants.SIP_INVITE_SESSION_STREAM + userSetting.getServerId(), ssrcTransaction.getStream());
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	public List<SsrcTransaction> getAll() {
 | 
	
		
			
				|  |  | -		String key = VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId() + ":*";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		List<Object> scanResult = RedisUtil.scan(redisTemplate, key);
 | 
	
		
			
				|  |  | -		if (scanResult.isEmpty()) {
 | 
	
		
			
				|  |  | -			return new ArrayList<>();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +		String key = VideoManagerConstants.SIP_INVITE_SESSION_CALL_ID + userSetting.getServerId();
 | 
	
		
			
				|  |  | +		List<Object> values = redisTemplate.opsForHash().values(key);
 | 
	
		
			
				|  |  |  		List<SsrcTransaction> result = new ArrayList<>();
 | 
	
		
			
				|  |  | -		for (Object keyObj : scanResult) {
 | 
	
		
			
				|  |  | -			SsrcTransaction ssrcTransaction = (SsrcTransaction)redisTemplate.opsForValue().get(keyObj);
 | 
	
		
			
				|  |  | -			result.add(ssrcTransaction);
 | 
	
		
			
				|  |  | +		for (Object value : values) {
 | 
	
		
			
				|  |  | +			result.add((SsrcTransaction) value);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		return result;
 | 
	
		
			
				|  |  |  	}
 |