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();
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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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) {

View File

@ -39,7 +39,7 @@
</el-form-item>
<el-form-item label="节点选择" prop="rtpType">
<el-select
v-model="streamProxy.mediaServerId"
v-model="streamProxy.relatesMediaServerId"
@change="mediaServerIdChange"
style="width: 100%"
placeholder="请选择拉流节点"
@ -219,12 +219,12 @@ export default {
this.closeEdit()
},
mediaServerIdChange:function (){
if (this.streamProxy.mediaServerId !== "auto"){
if (this.streamProxy.relatesMediaServerId !== "auto"){
this.$axios({
method: 'get',
url:`/api/proxy/ffmpeg_cmd/list`,
params: {
mediaServerId: this.streamProxy.mediaServerId
mediaServerId: this.streamProxy.relatesMediaServerId
}
}).then((res)=> {
this.ffmpegCmdList = res.data.data;

View File

@ -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;
alter table wvp_device_channel drop stream_proxy_id;
/*
* 20241231
*/
alter table wvp_stream_proxy add relates_media_server_id character varying(50);