临时提交

pull/1642/head
panlinlin 2024-06-27 23:38:13 +08:00
parent 88c021948f
commit 7847bd6614
2 changed files with 13 additions and 15 deletions

View File

@ -345,8 +345,6 @@
<version>1.18.30</version> <version>1.18.30</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>

View File

@ -31,6 +31,7 @@ import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -54,12 +55,11 @@ import java.util.stream.Collectors;
/** /**
* *
*/ */
@Slf4j
@Service @Service
@DS("master") @DS("master")
public class StreamProxyServiceImpl implements IStreamProxyService { public class StreamProxyServiceImpl implements IStreamProxyService {
private final static Logger logger = LoggerFactory.getLogger(StreamProxyServiceImpl.class);
@Autowired @Autowired
private StreamProxyMapper streamProxyMapper; private StreamProxyMapper streamProxyMapper;
@ -144,7 +144,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
mediaServer = mediaServerService.getOne(param.getMediaServerId()); mediaServer = mediaServerService.getOne(param.getMediaServerId());
} }
if (mediaServer == null) { if (mediaServer == null) {
logger.warn("保存代理未找到在线的ZLM..."); log.warn("保存代理未找到在线的ZLM...");
throw new ControllerException(ErrorCode.ERROR100.getCode(), "保存代理未找到在线的ZLM"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "保存代理未找到在线的ZLM");
} }
String dstUrl; String dstUrl;
@ -179,7 +179,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
param.getStream()); param.getStream());
} }
param.setDstUrl(dstUrl); param.setDstUrl(dstUrl);
logger.info("[拉流代理] 输出地址为:{}", dstUrl); log.info("[拉流代理] 输出地址为:{}", dstUrl);
param.setMediaServerId(mediaServer.getId()); param.setMediaServerId(mediaServer.getId());
boolean saveResult; boolean saveResult;
// 更新 // 更新
@ -287,7 +287,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
result = true; result = true;
dataSourceTransactionManager.commit(transactionStatus); //手动提交 dataSourceTransactionManager.commit(transactionStatus); //手动提交
}catch (Exception e) { }catch (Exception e) {
logger.error("向数据库添加流代理失败:", e); log.error("向数据库添加流代理失败:", e);
dataSourceTransactionManager.rollback(transactionStatus); dataSourceTransactionManager.rollback(transactionStatus);
} }
@ -323,7 +323,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
dataSourceTransactionManager.commit(transactionStatus); //手动提交 dataSourceTransactionManager.commit(transactionStatus); //手动提交
result = true; result = true;
}catch (Exception e) { }catch (Exception e) {
logger.error("未处理的异常 ", e); log.error("未处理的异常 ", e);
dataSourceTransactionManager.rollback(transactionStatus); dataSourceTransactionManager.rollback(transactionStatus);
} }
return result; return result;
@ -334,7 +334,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
WVPResult<String> result = null; WVPResult<String> result = null;
MediaServer mediaServer = null; MediaServer mediaServer = null;
if (param.getMediaServerId() == null) { if (param.getMediaServerId() == null) {
logger.warn("添加代理时MediaServerId 为null"); log.warn("添加代理时MediaServerId 为null");
return null; return null;
}else { }else {
mediaServer = mediaServerService.getOne(param.getMediaServerId()); mediaServer = mediaServerService.getOne(param.getMediaServerId());
@ -360,7 +360,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
if (result != null && result.getCode() == 0) { if (result != null && result.getCode() == 0) {
String key = result.getData(); String key = result.getData();
if (key == null) { if (key == null) {
logger.warn("[获取拉流代理的结果数据Data] 失败: {}", result ); log.warn("[获取拉流代理的结果数据Data] 失败: {}", result );
return result; return result;
} }
param.setStreamKey(key); param.setStreamKey(key);
@ -412,9 +412,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
redisCatchStorage.removeStream(streamProxyItem.getMediaServerId(), "PUSH", app, stream); redisCatchStorage.removeStream(streamProxyItem.getMediaServerId(), "PUSH", app, stream);
Boolean result = removeStreamProxyFromZlm(streamProxyItem); Boolean result = removeStreamProxyFromZlm(streamProxyItem);
if (result != null && result) { if (result != null && result) {
logger.info("[移除代理] 代理: {}/{}, 从zlm移除成功", app, stream); log.info("[移除代理] 代理: {}/{}, 从zlm移除成功", app, stream);
}else { }else {
logger.info("[移除代理] 代理: {}/{}, 从zlm移除失败", app, stream); log.info("[移除代理] 代理: {}/{}, 从zlm移除失败", app, stream);
} }
} }
} }
@ -433,7 +433,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
streamProxy.setEnable(true); streamProxy.setEnable(true);
updateStreamProxy(streamProxy); updateStreamProxy(streamProxy);
}else { }else {
logger.info("启用代理失败: {}/{}->{}({})", app, stream, wvpResult.getMsg(), log.info("启用代理失败: {}/{}->{}({})", app, stream, wvpResult.getMsg(),
streamProxy.getSrcUrl() == null? streamProxy.getUrl():streamProxy.getSrcUrl()); streamProxy.getSrcUrl() == null? streamProxy.getUrl():streamProxy.getSrcUrl());
} }
} else if (streamProxy != null && streamProxy.isEnable()) { } else if (streamProxy != null && streamProxy.isEnable()) {
@ -483,11 +483,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
List<StreamProxy> streamProxyListForEnable = storager.getStreamProxyListForEnableInMediaServer( List<StreamProxy> streamProxyListForEnable = storager.getStreamProxyListForEnableInMediaServer(
mediaServerId, true); mediaServerId, true);
for (StreamProxy streamProxyDto : streamProxyListForEnable) { for (StreamProxy streamProxyDto : streamProxyListForEnable) {
logger.info("恢复流代理," + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); log.info("恢复流代理," + streamProxyDto.getApp() + "/" + streamProxyDto.getStream());
WVPResult<String> wvpResult = addStreamProxyToZlm(streamProxyDto); WVPResult<String> wvpResult = addStreamProxyToZlm(streamProxyDto);
if (wvpResult == null) { if (wvpResult == null) {
// 设置为离线 // 设置为离线
logger.info("恢复流代理失败" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); log.info("恢复流代理失败" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream());
updateStatusByAppAndStream(streamProxyDto.getApp(), streamProxyDto.getStream(), false); updateStatusByAppAndStream(streamProxyDto.getApp(), streamProxyDto.getStream(), false);
}else { }else {
updateStatusByAppAndStream(streamProxyDto.getApp(), streamProxyDto.getStream(), true); updateStatusByAppAndStream(streamProxyDto.getApp(), streamProxyDto.getStream(), true);