优化info消息的cseq计数
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user