优化info消息的cseq计数

This commit is contained in:
648540858
2021-12-14 18:41:50 +08:00
parent 0eba7c40c3
commit 0c10e8d9d3
12 changed files with 85 additions and 58 deletions

View File

@@ -14,6 +14,14 @@ import java.util.Map;
public interface IRedisCatchStorage {
/**
* 计数器。为cseq进行计数
*
* @param method sip 方法
* @return
*/
Long getCSEQ(String method);
/**
* 开始播放时将流存入
*
@@ -181,4 +189,6 @@ public interface IRedisCatchStorage {
* 获取Device
*/
Device getDevice(String deviceId);
void resetAllCSEQ();
}

View File

@@ -36,6 +36,28 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public Long getCSEQ(String method) {
String key = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetup.getServerId() + "_" + method;
long result = redis.incr(key, 1L);
if (result > Integer.MAX_VALUE) {
redis.set(key, 1);
result = 1;
}
return result;
}
@Override
public void resetAllCSEQ() {
String scanKey = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetup.getServerId() + "_*";
List<Object> keys = redis.scan(scanKey);
for (int i = 0; i < keys.size(); i++) {
String key = (String) keys.get(i);
redis.set(key, 1);
}
}
/**
* 开始播放时将流存入redis
*