在redis中添加wvp存活依据,添加推流变化消息

This commit is contained in:
648540858
2021-11-23 14:51:37 +08:00
parent 6282c81bc5
commit b1c92cf4e8
16 changed files with 108 additions and 44 deletions

View File

@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import java.util.List;
import java.util.Map;
@@ -120,5 +121,27 @@ public interface IRedisCatchStorage {
/**
* 在redis添加wvp的信息
*/
void updateWVPInfo(JSONObject jsonObject);
void updateWVPInfo(String id, JSONObject jsonObject, int time);
/**
* 发送推流生成与推流消失消息
* @param jsonObject 消息内容
*/
void sendStreamChangeMsg(JSONObject jsonObject);
/**
* 添加流信息到redis
* @param mediaServerItem
* @param app
* @param streamId
*/
void addStream(MediaServerItem mediaServerItem, String app, String streamId, StreamInfo streamInfo);
/**
* 移除流信息从redis
* @param mediaServerItem
* @param app
* @param streamId
*/
void removeStream(MediaServerItem mediaServerItem, String app, String streamId);
}

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
@@ -295,8 +296,26 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
}
@Override
public void updateWVPInfo(JSONObject jsonObject) {
public void updateWVPInfo(String id, JSONObject jsonObject, int time) {
String key = VideoManagerConstants.WVP_SERVER_PREFIX + id;
redis.set(key, jsonObject, time);
}
@Override
public void sendStreamChangeMsg(JSONObject jsonObject) {
String key = VideoManagerConstants.WVP_MSG_STREAM_PUSH_CHANGE_PREFIX;
redis.convertAndSend(key, jsonObject.toJSONString());
}
@Override
public void addStream(MediaServerItem mediaServerItem, String app, String streamId, StreamInfo streamInfo) {
String key = VideoManagerConstants.WVP_SERVER_STREAM_PUSH_PREFIX + app + "_" + streamId + "_" + mediaServerItem.getId();
redis.set(key, streamInfo);
}
@Override
public void removeStream(MediaServerItem mediaServerItem, String app, String streamId) {
String key = VideoManagerConstants.WVP_SERVER_STREAM_PUSH_PREFIX + app + "_" + streamId + "_" + mediaServerItem.getId();
redis.del(key);
}
}