Merge branch 'master' into dev/数据库统合

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java
#	src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxyParam.java
dev/数据库统合
648540858 2024-12-31 10:33:12 +08:00
commit 26ee38aebe
9 changed files with 43 additions and 28 deletions

View File

@ -424,8 +424,11 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
port = mediaServer.getRtspPort(); port = mediaServer.getRtspPort();
schemaForUri = schema; schemaForUri = schema;
}else if (schema.equalsIgnoreCase("flv")) { }else if (schema.equalsIgnoreCase("flv")) {
if (mediaServer.getRtmpPort() == 0) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "ffmpeg拉流代理播放时发现未设置rtmp端口");
}
port = mediaServer.getRtmpPort(); port = mediaServer.getRtmpPort();
schemaForUri = schema; schemaForUri = "rtmp";
}else { }else {
port = mediaServer.getRtmpPort(); port = mediaServer.getRtmpPort();
schemaForUri = schema; schemaForUri = schema;

View File

@ -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 = "服务ID") @Schema(description = "服务ID")
private String serverId; private String serverId;

View File

@ -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.setServerId(serverId); streamProxy.setServerId(serverId);
streamProxy.setSrcUrl(url); streamProxy.setSrcUrl(url);
streamProxy.setTimeout(timeoutMs/1000); streamProxy.setTimeout(timeoutMs/1000);

View File

@ -115,8 +115,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");
@ -139,6 +139,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);
} }

View File

@ -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);
} }

View File

@ -51,22 +51,19 @@ public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService {
} }
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;
} }

View File

@ -404,11 +404,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) {

View File

@ -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="请选择拉流节点"
@ -219,12 +219,12 @@ export default {
this.closeEdit() this.closeEdit()
}, },
mediaServerIdChange:function (){ mediaServerIdChange:function (){
if (this.streamProxy.mediaServerId !== "auto"){ if (this.streamProxy.relatesMediaServerId !== "auto"){
this.$axios({ this.$axios({
method: 'get', method: 'get',
url:`/api/proxy/ffmpeg_cmd/list`, url:`/api/proxy/ffmpeg_cmd/list`,
params: { params: {
mediaServerId: this.streamProxy.mediaServerId mediaServerId: this.streamProxy.relatesMediaServerId
} }
}).then((res)=> { }).then((res)=> {
this.ffmpegCmdList = res.data.data; this.ffmpegCmdList = res.data.data;

View File

@ -29,3 +29,8 @@ 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);