修复拉流代理相关问题

This commit is contained in:
panlinlin
2024-07-20 23:31:38 +08:00
parent 80ac701748
commit 0b7d55ed74
6 changed files with 51 additions and 37 deletions

View File

@@ -178,11 +178,13 @@ public class StreamProxyController {
@ResponseBody
@Operation(summary = "启用代理", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "id", description = "代理Id", required = true)
public void start(int id){
log.info("启用代理: " + id);
boolean result = streamProxyService.start(id);
if (!result) {
throw new ControllerException(ErrorCode.ERROR100);
public StreamContent start(int id){
log.info("播放代理: " + id);
StreamInfo streamInfo = streamProxyService.start(id);
if (streamInfo == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), ErrorCode.ERROR100.getMsg());
}else {
return new StreamContent(streamInfo);
}
}

View File

@@ -20,12 +20,12 @@ public class StreamProxyProvider {
}
public String selectForEnableInMediaServer(Map<String, Object> params ){
return getBaseSelectSql() + String.format(" WHERE st.enable=%s and st.media_server_id= %s order by st.create_time desc",
return getBaseSelectSql() + String.format(" WHERE st.enable=%s and st.media_server_id= '%s' order by st.create_time desc",
params.get("enable"), params.get("mediaServerId"));
}
public String selectOneByAppAndStream(Map<String, Object> params ){
return getBaseSelectSql() + String.format(" WHERE st.app=%s AND st.stream=%s order by st.create_time desc",
return getBaseSelectSql() + String.format(" WHERE st.app='%s' AND st.stream='%s' order by st.create_time desc",
params.get("app"), params.get("stream"));
}

View File

@@ -93,5 +93,5 @@ public interface IStreamProxyService {
void delete(int id);
boolean start(int id);
StreamInfo start(int id);
}

View File

@@ -177,7 +177,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
}
private void delete(StreamProxy streamProxy) {
if (streamProxy.getPulling()) {
assert streamProxy != null;
if (streamProxy.getPulling() != null && streamProxy.getPulling()) {
stopProxy(streamProxy);
}
if(streamProxy.getGbId() > 0) {
@@ -441,13 +442,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
@Override
public boolean start(int id) {
public StreamInfo start(int id) {
StreamProxy streamProxy = streamProxyMapper.select(id);
if (streamProxy == null) {
throw new ControllerException(ErrorCode.ERROR404.getCode(), "代理信息未找到");
}
StreamInfo streamInfo = startProxy(streamProxy);
return streamInfo != null;
return startProxy(streamProxy);
}
private StreamInfo startProxy(StreamProxy streamProxy){