[拉流代理] 增加单独的字段管理每次拉流需要的节点
parent
0dd2826b9e
commit
8f7016878d
|
@ -30,9 +30,12 @@ public class StreamProxy extends CommonGBChannel {
|
||||||
@Schema(description = "流ID")
|
@Schema(description = "流ID")
|
||||||
private String stream;
|
private String stream;
|
||||||
|
|
||||||
@Schema(description = "流媒体服务ID")
|
@Schema(description = "当前拉流使用的流媒体服务ID")
|
||||||
private String mediaServerId;
|
private String mediaServerId;
|
||||||
|
|
||||||
|
@Schema(description = "固定选择的流媒体服务ID")
|
||||||
|
private String relatesMediaServerId;
|
||||||
|
|
||||||
@Schema(description = "拉流地址")
|
@Schema(description = "拉流地址")
|
||||||
private String srcUrl;
|
private String srcUrl;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class StreamProxyParam {
|
||||||
StreamProxy streamProxy = new StreamProxy();
|
StreamProxy streamProxy = new StreamProxy();
|
||||||
streamProxy.setApp(app);
|
streamProxy.setApp(app);
|
||||||
streamProxy.setStream(stream);
|
streamProxy.setStream(stream);
|
||||||
streamProxy.setMediaServerId(mediaServerId);
|
streamProxy.setRelatesMediaServerId(mediaServerId);
|
||||||
streamProxy.setSrcUrl(url);
|
streamProxy.setSrcUrl(url);
|
||||||
streamProxy.setTimeout(timeoutMs/1000);
|
streamProxy.setTimeout(timeoutMs/1000);
|
||||||
streamProxy.setRtspType(rtpType);
|
streamProxy.setRtspType(rtpType);
|
||||||
|
|
|
@ -19,7 +19,6 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -112,8 +111,8 @@ public class StreamProxyController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public StreamProxy add(@RequestBody StreamProxy param){
|
public StreamProxy add(@RequestBody StreamProxy param){
|
||||||
log.info("添加代理: " + JSONObject.toJSONString(param));
|
log.info("添加代理: " + JSONObject.toJSONString(param));
|
||||||
if (ObjectUtils.isEmpty(param.getMediaServerId())) {
|
if (ObjectUtils.isEmpty(param.getRelatesMediaServerId())) {
|
||||||
param.setMediaServerId(null);
|
param.setRelatesMediaServerId(null);
|
||||||
}
|
}
|
||||||
if (ObjectUtils.isEmpty(param.getType())) {
|
if (ObjectUtils.isEmpty(param.getType())) {
|
||||||
param.setType("default");
|
param.setType("default");
|
||||||
|
@ -135,6 +134,9 @@ public class StreamProxyController {
|
||||||
if (param.getId() == 0) {
|
if (param.getId() == 0) {
|
||||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "缺少代理信息的ID");
|
throw new ControllerException(ErrorCode.ERROR400.getCode(), "缺少代理信息的ID");
|
||||||
}
|
}
|
||||||
|
if (ObjectUtils.isEmpty(param.getRelatesMediaServerId())) {
|
||||||
|
param.setRelatesMediaServerId(null);
|
||||||
|
}
|
||||||
if (ObjectUtils.isEmpty(param.getGbId())) {
|
if (ObjectUtils.isEmpty(param.getGbId())) {
|
||||||
param.setGbDeviceId(null);
|
param.setGbDeviceId(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@ import java.util.List;
|
||||||
@Repository
|
@Repository
|
||||||
public interface StreamProxyMapper {
|
public interface StreamProxyMapper {
|
||||||
|
|
||||||
@Insert("INSERT INTO wvp_stream_proxy (type, app, stream,media_server_id, src_url, " +
|
@Insert("INSERT INTO wvp_stream_proxy (type, app, stream,relates_media_server_id, src_url, " +
|
||||||
"timeout, ffmpeg_cmd_key, rtsp_type, enable_audio, enable_mp4, enable, pulling, stream_key, " +
|
"timeout, ffmpeg_cmd_key, rtsp_type, enable_audio, enable_mp4, enable, pulling, " +
|
||||||
"enable_remove_none_reader, enable_disable_none_reader, create_time) VALUES" +
|
"enable_remove_none_reader, enable_disable_none_reader, create_time) VALUES" +
|
||||||
"(#{type}, #{app}, #{stream}, #{mediaServerId}, #{srcUrl}, " +
|
"(#{type}, #{app}, #{stream}, #{relatesMediaServerId}, #{srcUrl}, " +
|
||||||
"#{timeout}, #{ffmpegCmdKey}, #{rtspType}, #{enableAudio}, #{enableMp4}, #{enable}, #{pulling}, #{streamKey}, " +
|
"#{timeout}, #{ffmpegCmdKey}, #{rtspType}, #{enableAudio}, #{enableMp4}, #{enable}, #{pulling}, " +
|
||||||
"#{enableRemoveNoneReader}, #{enableDisableNoneReader}, #{createTime} )")
|
"#{enableRemoveNoneReader}, #{enableDisableNoneReader}, #{createTime} )")
|
||||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||||
int add(StreamProxy streamProxyDto);
|
int add(StreamProxy streamProxyDto);
|
||||||
|
@ -24,7 +24,7 @@ public interface StreamProxyMapper {
|
||||||
"SET type=#{type}, " +
|
"SET type=#{type}, " +
|
||||||
"app=#{app}," +
|
"app=#{app}," +
|
||||||
"stream=#{stream}," +
|
"stream=#{stream}," +
|
||||||
"media_server_id=#{mediaServerId}, " +
|
"relates_media_server_id=#{relatesMediaServerId}, " +
|
||||||
"src_url=#{srcUrl}," +
|
"src_url=#{srcUrl}," +
|
||||||
"timeout=#{timeout}, " +
|
"timeout=#{timeout}, " +
|
||||||
"ffmpeg_cmd_key=#{ffmpegCmdKey}, " +
|
"ffmpeg_cmd_key=#{ffmpegCmdKey}, " +
|
||||||
|
@ -32,7 +32,6 @@ public interface StreamProxyMapper {
|
||||||
"enable_audio=#{enableAudio}, " +
|
"enable_audio=#{enableAudio}, " +
|
||||||
"enable=#{enable}, " +
|
"enable=#{enable}, " +
|
||||||
"pulling=#{pulling}, " +
|
"pulling=#{pulling}, " +
|
||||||
"stream_key=#{streamKey}, " +
|
|
||||||
"enable_remove_none_reader=#{enableRemoveNoneReader}, " +
|
"enable_remove_none_reader=#{enableRemoveNoneReader}, " +
|
||||||
"enable_disable_none_reader=#{enableDisableNoneReader}, " +
|
"enable_disable_none_reader=#{enableDisableNoneReader}, " +
|
||||||
"enable_mp4=#{enableMp4} " +
|
"enable_mp4=#{enableMp4} " +
|
||||||
|
@ -84,8 +83,14 @@ public interface StreamProxyMapper {
|
||||||
StreamProxy select(@Param("id") int id);
|
StreamProxy select(@Param("id") int id);
|
||||||
|
|
||||||
@Update("UPDATE wvp_stream_proxy " +
|
@Update("UPDATE wvp_stream_proxy " +
|
||||||
"SET pulling=false, " +
|
" SET pulling=false, media_server_id = null," +
|
||||||
"stream_key = null " +
|
" stream_key = null " +
|
||||||
"WHERE id=#{id}")
|
" WHERE id=#{id}")
|
||||||
void removeStream(@Param("id")int id);
|
void removeStream(@Param("id")int id);
|
||||||
|
|
||||||
|
@Update("UPDATE wvp_stream_proxy " +
|
||||||
|
" SET pulling=#{pulling}, media_server_id = #{mediaServerId}, " +
|
||||||
|
" stream_key = #{streamKey} " +
|
||||||
|
" WHERE id=#{id}")
|
||||||
|
void addStream(StreamProxy streamProxy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,22 +44,19 @@ public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
MediaServer mediaServer;
|
MediaServer mediaServer;
|
||||||
String mediaServerId = streamProxy.getMediaServerId();
|
String mediaServerId = streamProxy.getRelatesMediaServerId();
|
||||||
if (mediaServerId == null) {
|
if (mediaServerId == null) {
|
||||||
mediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
|
mediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
|
||||||
}else {
|
}else {
|
||||||
mediaServer = mediaServerService.getOne(mediaServerId);
|
mediaServer = mediaServerService.getOne(mediaServerId);
|
||||||
if (mediaServer == null) {
|
|
||||||
mediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (mediaServer == null) {
|
if (mediaServer == null) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的媒体节点");
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), mediaServerId == null?"未找到可用的媒体节点":"未找到节点" + mediaServerId);
|
||||||
}
|
}
|
||||||
StreamInfo streamInfo = mediaServerService.startProxy(mediaServer, streamProxy);
|
StreamInfo streamInfo = mediaServerService.startProxy(mediaServer, streamProxy);
|
||||||
if (mediaServerId == null || !mediaServerId.equals(mediaServer.getId())) {
|
if (mediaServerId == null || !mediaServerId.equals(mediaServer.getId())) {
|
||||||
streamProxy.setMediaServerId(mediaServer.getId());
|
streamProxy.setMediaServerId(mediaServer.getId());
|
||||||
streamProxyMapper.update(streamProxy);
|
streamProxyMapper.addStream(streamProxy);
|
||||||
}
|
}
|
||||||
return streamInfo;
|
return streamInfo;
|
||||||
}
|
}
|
||||||
|
@ -88,9 +85,6 @@ public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService {
|
||||||
}else {
|
}else {
|
||||||
mediaServerService.stopProxy(mediaServer, streamProxy.getStreamKey());
|
mediaServerService.stopProxy(mediaServer, streamProxy.getStreamKey());
|
||||||
}
|
}
|
||||||
streamProxy.setMediaServerId(mediaServer.getId());
|
|
||||||
streamProxy.setStreamKey(null);
|
|
||||||
streamProxy.setPulling(false);
|
|
||||||
streamProxyMapper.removeStream(streamProxy.getId());
|
streamProxyMapper.removeStream(streamProxy.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -406,11 +406,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
streamProxy.setPulling(status);
|
streamProxy.setPulling(status);
|
||||||
if (!mediaServerId.equals(streamProxy.getMediaServerId())) {
|
streamProxy.setMediaServerId(mediaServerId);
|
||||||
streamProxy.setMediaServerId(mediaServerId);
|
|
||||||
}
|
|
||||||
streamProxy.setUpdateTime(DateUtil.getNow());
|
streamProxy.setUpdateTime(DateUtil.getNow());
|
||||||
streamProxyMapper.update(streamProxy);
|
streamProxyMapper.addStream(streamProxy);
|
||||||
|
|
||||||
streamProxy.setGbStatus(status ? "ON" : "OFF");
|
streamProxy.setGbStatus(status ? "ON" : "OFF");
|
||||||
if (streamProxy.getGbId() > 0) {
|
if (streamProxy.getGbId() > 0) {
|
||||||
if (status) {
|
if (status) {
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="节点选择" prop="rtpType">
|
<el-form-item label="节点选择" prop="rtpType">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="streamProxy.mediaServerId"
|
v-model="streamProxy.relatesMediaServerId"
|
||||||
@change="mediaServerIdChange"
|
@change="mediaServerIdChange"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
placeholder="请选择拉流节点"
|
placeholder="请选择拉流节点"
|
||||||
|
|
|
@ -28,4 +28,9 @@ set wdc.data_type = 3, wdc.data_device_id = ct.stream_proxy_id where wdc.stream_
|
||||||
|
|
||||||
alter table wvp_device_channel drop device_db_id;
|
alter table wvp_device_channel drop device_db_id;
|
||||||
alter table wvp_device_channel drop stream_push_id;
|
alter table wvp_device_channel drop stream_push_id;
|
||||||
alter table wvp_device_channel drop stream_proxy_id;
|
alter table wvp_device_channel drop stream_proxy_id;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 20241231
|
||||||
|
*/
|
||||||
|
alter table wvp_stream_proxy add relates_media_server_id character varying(50);
|
Loading…
Reference in New Issue