存储部分使用sqlite代替redis

This commit is contained in:
panlinlin
2020-12-31 13:15:50 +08:00
parent 00e61d9a80
commit 3d83775468
30 changed files with 933 additions and 956 deletions

View File

@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.media.zlm;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,6 +30,9 @@ public class ZLMHTTPProxyController {
@Autowired
private IVideoManagerStorager storager;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Value("${media.port}")
private int mediaHttpPort;
@@ -36,10 +40,10 @@ public class ZLMHTTPProxyController {
@RequestMapping(value = "/**/**/**", produces = "application/json;charset=UTF-8")
public Object proxy(HttpServletRequest request, HttpServletResponse response){
if (storager.getMediaInfo() == null) {
if (redisCatchStorage.getMediaInfo() == null) {
return "未接入流媒体";
}
MediaServerConfig mediaInfo = storager.getMediaInfo();
MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
String requestURI = String.format("http://%s:%s%s?%s&%s",
mediaInfo.getLocalIP(),
mediaHttpPort,

View File

@@ -11,6 +11,7 @@ import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.utils.IpUtil;
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
@@ -52,6 +53,9 @@ public class ZLMHttpHookListener {
@Autowired
private IVideoManagerStorager storager;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private ZLMRESTfulUtils zlmresTfulUtils;
@@ -249,13 +253,13 @@ public class ZLMHttpHookListener {
String app = json.getString("app");
String streamId = json.getString("stream");
boolean regist = json.getBoolean("regist");
StreamInfo streamInfo = storager.queryPlayByStreamId(streamId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
if ("rtp".equals(app) && !regist ) {
if (streamInfo!=null){
storager.stopPlay(streamInfo);
redisCatchStorage.stopPlay(streamInfo);
}else{
streamInfo = storager.queryPlaybackByStreamId(streamId);
storager.stopPlayback(streamInfo);
streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
redisCatchStorage.stopPlayback(streamInfo);
}
}
@@ -281,12 +285,12 @@ public class ZLMHttpHookListener {
String streamId = json.getString("stream");
cmder.streamByeCmd(streamId);
StreamInfo streamInfo = storager.queryPlayByStreamId(streamId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
if (streamInfo!=null){
storager.stopPlay(streamInfo);
redisCatchStorage.stopPlay(streamInfo);
}else{
streamInfo = storager.queryPlaybackByStreamId(streamId);
storager.stopPlayback(streamInfo);
streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
redisCatchStorage.stopPlayback(streamInfo);
}
JSONObject ret = new JSONObject();
@@ -311,7 +315,7 @@ public class ZLMHttpHookListener {
if (autoApplyPlay) {
String app = json.getString("app");
String streamId = json.getString("stream");
StreamInfo streamInfo = storager.queryPlayByStreamId(streamId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
if ("rtp".equals(app) && streamId.indexOf("gb_play") > -1 && streamInfo == null) {
String[] s = streamId.split("_");
if (s.length == 4) {
@@ -355,7 +359,7 @@ public class ZLMHttpHookListener {
// MediaServerConfig mediaServerConfig = mediaServerConfigs.get(0);
MediaServerConfig mediaServerConfig = JSON.toJavaObject(json, MediaServerConfig.class);
mediaServerConfig.setLocalIP(mediaIp);
storager.updateMediaInfo(mediaServerConfig);
redisCatchStorage.updateMediaInfo(mediaServerConfig);
// TODO Auto-generated method stub
JSONObject ret = new JSONObject();

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import okhttp3.*;
import org.slf4j.Logger;
@@ -30,6 +31,9 @@ public class ZLMRunner implements CommandLineRunner {
@Autowired
private IVideoManagerStorager storager;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Value("${media.ip}")
private String mediaIp;
@@ -69,7 +73,7 @@ public class ZLMRunner implements CommandLineRunner {
logger.info("zlm接入成功...");
if (autoConfig) saveZLMConfig();
mediaServerConfig = getMediaServerConfig();
storager.updateMediaInfo(mediaServerConfig);
redisCatchStorage.updateMediaInfo(mediaServerConfig);
}
}