diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java index aeb6bc21..e0df42dc 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java @@ -424,8 +424,11 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService { port = mediaServer.getRtspPort(); schemaForUri = schema; }else if (schema.equalsIgnoreCase("flv")) { + if (mediaServer.getRtmpPort() == 0) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "ffmpeg拉流代理播放时发现未设置rtmp端口"); + } port = mediaServer.getRtmpPort(); - schemaForUri = schema; + schemaForUri = "rtmp"; }else { port = mediaServer.getRtmpPort(); schemaForUri = schema; diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java index 8cd327a6..61f6e655 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxy.java @@ -30,9 +30,12 @@ public class StreamProxy extends CommonGBChannel { @Schema(description = "流ID") private String stream; - @Schema(description = "流媒体服务ID") + @Schema(description = "当前拉流使用的流媒体服务ID") private String mediaServerId; + @Schema(description = "固定选择的流媒体服务ID") + private String relatesMediaServerId; + @Schema(description = "服务ID") private String serverId; diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxyParam.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxyParam.java index deddcd5f..d791c319 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxyParam.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/bean/StreamProxyParam.java @@ -57,7 +57,7 @@ public class StreamProxyParam { StreamProxy streamProxy = new StreamProxy(); streamProxy.setApp(app); streamProxy.setStream(stream); - streamProxy.setMediaServerId(mediaServerId); + streamProxy.setRelatesMediaServerId(mediaServerId); streamProxy.setServerId(serverId); streamProxy.setSrcUrl(url); streamProxy.setTimeout(timeoutMs/1000); diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/controller/StreamProxyController.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/controller/StreamProxyController.java index d8c73cbf..bd0af760 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/controller/StreamProxyController.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/controller/StreamProxyController.java @@ -115,8 +115,8 @@ public class StreamProxyController { @ResponseBody public StreamProxy add(@RequestBody StreamProxy param){ log.info("添加代理: " + JSONObject.toJSONString(param)); - if (ObjectUtils.isEmpty(param.getMediaServerId())) { - param.setMediaServerId(null); + if (ObjectUtils.isEmpty(param.getRelatesMediaServerId())) { + param.setRelatesMediaServerId(null); } if (ObjectUtils.isEmpty(param.getType())) { param.setType("default"); @@ -139,6 +139,9 @@ public class StreamProxyController { if (param.getId() == 0) { throw new ControllerException(ErrorCode.ERROR400.getCode(), "缺少代理信息的ID"); } + if (ObjectUtils.isEmpty(param.getRelatesMediaServerId())) { + param.setRelatesMediaServerId(null); + } if (ObjectUtils.isEmpty(param.getGbId())) { param.setGbDeviceId(null); } diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/StreamProxyMapper.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/StreamProxyMapper.java index 82d48e21..f43f1096 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/StreamProxyMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/dao/StreamProxyMapper.java @@ -11,11 +11,11 @@ import java.util.List; @Repository public interface StreamProxyMapper { - @Insert("INSERT INTO wvp_stream_proxy (type, app, stream,media_server_id, src_url, " + - "timeout, ffmpeg_cmd_key, rtsp_type, enable_audio, enable_mp4, enable, pulling, stream_key, " + + @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, " + "enable_remove_none_reader, enable_disable_none_reader, create_time) VALUES" + - "(#{type}, #{app}, #{stream}, #{mediaServerId}, #{srcUrl}, " + - "#{timeout}, #{ffmpegCmdKey}, #{rtspType}, #{enableAudio}, #{enableMp4}, #{enable}, #{pulling}, #{streamKey}, " + + "(#{type}, #{app}, #{stream}, #{relatesMediaServerId}, #{srcUrl}, " + + "#{timeout}, #{ffmpegCmdKey}, #{rtspType}, #{enableAudio}, #{enableMp4}, #{enable}, #{pulling}, " + "#{enableRemoveNoneReader}, #{enableDisableNoneReader}, #{createTime} )") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int add(StreamProxy streamProxyDto); @@ -24,7 +24,7 @@ public interface StreamProxyMapper { "SET type=#{type}, " + "app=#{app}," + "stream=#{stream}," + - "media_server_id=#{mediaServerId}, " + + "relates_media_server_id=#{relatesMediaServerId}, " + "src_url=#{srcUrl}," + "timeout=#{timeout}, " + "ffmpeg_cmd_key=#{ffmpegCmdKey}, " + @@ -32,7 +32,6 @@ public interface StreamProxyMapper { "enable_audio=#{enableAudio}, " + "enable=#{enable}, " + "pulling=#{pulling}, " + - "stream_key=#{streamKey}, " + "enable_remove_none_reader=#{enableRemoveNoneReader}, " + "enable_disable_none_reader=#{enableDisableNoneReader}, " + "enable_mp4=#{enableMp4} " + @@ -84,8 +83,14 @@ public interface StreamProxyMapper { StreamProxy select(@Param("id") int id); @Update("UPDATE wvp_stream_proxy " + - "SET pulling=false, " + - "stream_key = null " + - "WHERE id=#{id}") + " SET pulling=false, media_server_id = null," + + " stream_key = null " + + " WHERE id=#{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); } diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyPlayServiceImpl.java index 46283a7b..b93e4dc3 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyPlayServiceImpl.java @@ -51,22 +51,19 @@ public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService { } MediaServer mediaServer; - String mediaServerId = streamProxy.getMediaServerId(); + String mediaServerId = streamProxy.getRelatesMediaServerId(); if (mediaServerId == null) { mediaServer = mediaServerService.getMediaServerForMinimumLoad(null); }else { mediaServer = mediaServerService.getOne(mediaServerId); - if (mediaServer == null) { - mediaServer = mediaServerService.getMediaServerForMinimumLoad(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); if (mediaServerId == null || !mediaServerId.equals(mediaServer.getId())) { streamProxy.setMediaServerId(mediaServer.getId()); - streamProxyMapper.update(streamProxy); + streamProxyMapper.addStream(streamProxy); } return streamInfo; } diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java index 47354766..6c89b02d 100755 --- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java @@ -404,11 +404,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService { return; } streamProxy.setPulling(status); - if (!mediaServerId.equals(streamProxy.getMediaServerId())) { - streamProxy.setMediaServerId(mediaServerId); - } + streamProxy.setMediaServerId(mediaServerId); streamProxy.setUpdateTime(DateUtil.getNow()); - streamProxyMapper.update(streamProxy); + streamProxyMapper.addStream(streamProxy); + streamProxy.setGbStatus(status ? "ON" : "OFF"); if (streamProxy.getGbId() > 0) { if (status) { diff --git a/web_src/src/components/StreamProxyEdit.vue b/web_src/src/components/StreamProxyEdit.vue index b4596941..2a1441aa 100644 --- a/web_src/src/components/StreamProxyEdit.vue +++ b/web_src/src/components/StreamProxyEdit.vue @@ -39,7 +39,7 @@ { this.ffmpegCmdList = res.data.data; diff --git a/数据库/2.7.3/更新-mysql-2.7.3.sql b/数据库/2.7.3/更新-mysql-2.7.3.sql index 6d40353a..17101e6b 100644 --- a/数据库/2.7.3/更新-mysql-2.7.3.sql +++ b/数据库/2.7.3/更新-mysql-2.7.3.sql @@ -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 stream_push_id; -alter table wvp_device_channel drop stream_proxy_id; \ No newline at end of file +alter table wvp_device_channel drop stream_proxy_id; + +/* +* 20241231 +*/ +alter table wvp_stream_proxy add relates_media_server_id character varying(50); \ No newline at end of file