添加推流信息专属redis数据

pull/1242/head
648540858 2023-11-30 18:09:43 +08:00
parent 3d5842e9e2
commit 67e4060053
7 changed files with 37 additions and 0 deletions

View File

@ -70,6 +70,7 @@ public class VideoManagerConstants {
public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_"; public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_";
public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_"; public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_";
public static final String PUSH_STREAM_LIST = "VMP_PUSH_STREAM_LIST_";

View File

@ -39,4 +39,6 @@ public class SystemInfoTimerTask {
} }
} }
} }

View File

@ -129,4 +129,6 @@ public class SipRunner implements CommandLineRunner {
} }
} }
} }
} }

View File

@ -392,6 +392,9 @@ public class ZLMHttpHookListener {
|| param.getOriginType() == OriginType.RTC_PUSH.ordinal()) { || param.getOriginType() == OriginType.RTC_PUSH.ordinal()) {
param.setSeverId(userSetting.getServerId()); param.setSeverId(userSetting.getServerId());
zlmMediaListManager.addPush(param); zlmMediaListManager.addPush(param);
// 冗余数据,自己系统中自用
redisCatchStorage.addPushListItem(param.getApp(), param.getStream(), param);
} }
} else { } else {
// 兼容流注销时类型从redis记录获取 // 兼容流注销时类型从redis记录获取
@ -400,6 +403,10 @@ public class ZLMHttpHookListener {
if (onStreamChangedHookParam != null) { if (onStreamChangedHookParam != null) {
type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType(); type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType();
redisCatchStorage.removeStream(mediaInfo.getId(), type, param.getApp(), param.getStream()); redisCatchStorage.removeStream(mediaInfo.getId(), type, param.getApp(), param.getStream());
if ("PUSH".equalsIgnoreCase(type)) {
// 冗余数据,自己系统中自用
redisCatchStorage.removePushListItem(param.getApp(), param.getStream(), param.getMediaServerId());
}
} }
GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream()); GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream());
if (gbStream != null) { if (gbStream != null) {

View File

@ -282,6 +282,8 @@ public class StreamPushServiceImpl implements IStreamPushService {
redisCatchStorage.sendStreamChangeMsg(type, jsonObject); redisCatchStorage.sendStreamChangeMsg(type, jsonObject);
// 移除redis内流的信息 // 移除redis内流的信息
redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream()); redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream());
// 冗余数据,自己系统中自用
redisCatchStorage.removePushListItem(offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream(), mediaServerItem.getId());
} }
} }
@ -319,6 +321,9 @@ public class StreamPushServiceImpl implements IStreamPushService {
jsonObject.put("register", false); jsonObject.put("register", false);
jsonObject.put("mediaServerId", mediaServerId); jsonObject.put("mediaServerId", mediaServerId);
redisCatchStorage.sendStreamChangeMsg(type, jsonObject); redisCatchStorage.sendStreamChangeMsg(type, jsonObject);
// 冗余数据,自己系统中自用
redisCatchStorage.removePushListItem(onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream(), mediaServerId);
} }
} }
} }

View File

@ -208,4 +208,8 @@ public interface IRedisCatchStorage {
void sendPlatformStartPlayMsg(MessageForPushChannel messageForPushChannel); void sendPlatformStartPlayMsg(MessageForPushChannel messageForPushChannel);
void sendPlatformStopPlayMsg(MessageForPushChannel messageForPushChannel); void sendPlatformStopPlayMsg(MessageForPushChannel messageForPushChannel);
void addPushListItem(String app, String stream, OnStreamChangedHookParam param);
void removePushListItem(String app, String stream, String mediaServerId);
} }

View File

@ -650,4 +650,20 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
logger.info("[redis发送通知] 发送 上级平台停止观看 {}: {}/{}->{}", key, msg.getApp(), msg.getStream(), msg.getPlatFormId()); logger.info("[redis发送通知] 发送 上级平台停止观看 {}: {}/{}->{}", key, msg.getApp(), msg.getStream(), msg.getPlatFormId());
redisTemplate.convertAndSend(key, JSON.toJSON(msg)); redisTemplate.convertAndSend(key, JSON.toJSON(msg));
} }
@Override
public void addPushListItem(String app, String stream, OnStreamChangedHookParam param) {
String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream;
redisTemplate.opsForValue().set(key, param);
}
@Override
public void removePushListItem(String app, String stream, String mediaServerId) {
String key = VideoManagerConstants.PUSH_STREAM_LIST + app + "_" + stream;
OnStreamChangedHookParam param = (OnStreamChangedHookParam)redisTemplate.opsForValue().get(key);
if (param != null && param.getMediaServerId().equalsIgnoreCase(mediaServerId)) {
redisTemplate.delete(key);
}
}
} }