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 0ca72a60..8cd327a6 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 @@ -33,6 +33,9 @@ public class StreamProxy extends CommonGBChannel { @Schema(description = "流媒体服务ID") private String mediaServerId; + @Schema(description = "服务ID") + private String serverId; + @Schema(description = "拉流地址") private String srcUrl; 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 632ca998..deddcd5f 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 @@ -53,11 +53,12 @@ public class StreamProxyParam { private boolean enableDisableNoneReader; - public StreamProxy buildStreamProxy() { + public StreamProxy buildStreamProxy(String serverId) { StreamProxy streamProxy = new StreamProxy(); streamProxy.setApp(app); streamProxy.setStream(stream); streamProxy.setMediaServerId(mediaServerId); + streamProxy.setServerId(serverId); streamProxy.setSrcUrl(url); streamProxy.setTimeout(timeoutMs/1000); streamProxy.setRtspType(rtpType); 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 54304385..d8c73cbf 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 @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.streamProxy.controller; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.media.bean.MediaServer; @@ -19,7 +20,6 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; @@ -44,6 +44,9 @@ public class StreamProxyController { @Autowired private IStreamProxyPlayService streamProxyPlayService; + @Autowired + private UserSetting userSetting; + @Operation(summary = "分页查询流代理", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "page", description = "当前页") @@ -121,6 +124,7 @@ public class StreamProxyController { if (ObjectUtils.isEmpty(param.getGbId())) { param.setGbDeviceId(null); } + param.setServerId(userSetting.getServerId()); streamProxyService.add(param); return param; } 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 a0c628c6..46283a7b 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 @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.streamProxy.service.impl; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; @@ -27,12 +28,16 @@ public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService { @Autowired private IMediaServerService mediaServerService; + @Autowired + private UserSetting userSetting; + @Override public StreamInfo start(int id) { StreamProxy streamProxy = streamProxyMapper.select(id); if (streamProxy == null) { throw new ControllerException(ErrorCode.ERROR404.getCode(), "代理信息未找到"); } + return startProxy(streamProxy); } @@ -41,6 +46,10 @@ public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService { if (!streamProxy.isEnable()) { return null; } + if (!userSetting.getServerId().equals(streamProxy.getServerId())) { + return redisRpcService.play(id, callback); + } + MediaServer mediaServer; String mediaServerId = streamProxy.getMediaServerId(); if (mediaServerId == null) { @@ -86,9 +95,6 @@ public class StreamProxyPlayServiceImpl implements IStreamProxyPlayService { }else { mediaServerService.stopProxy(mediaServer, streamProxy.getStreamKey()); } - streamProxy.setMediaServerId(mediaServer.getId()); - streamProxy.setStreamKey(null); - streamProxy.setPulling(false); streamProxyMapper.removeStream(streamProxy.getId()); } 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 e4ae6bdb..47354766 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 @@ -145,7 +145,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { if (param.getMediaServerId().equals("auto")) { param.setMediaServerId(null); } - StreamProxy streamProxy = param.buildStreamProxy(); + StreamProxy streamProxy = param.buildStreamProxy(userSetting.getServerId()); if (streamProxyInDb == null) { add(streamProxy); diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 64879b8b..b6af0805 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -29,7 +29,6 @@ create table wvp_device custom_name character varying(255), sdp_ip character varying(50), local_ip character varying(50), - server_id character varying(50), password character varying(255), as_message_channel bool default false, keepalive_interval_time integer, @@ -309,6 +308,7 @@ create table wvp_stream_proxy name character varying(255), update_time character varying(50), stream_key character varying(255), + server_id character varying(50), enable_disable_none_reader bool default false, constraint uk_stream_proxy_app_stream unique (app, stream) ); diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index a4a01149..68907a20 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -325,6 +325,7 @@ create table wvp_stream_proxy name character varying(255), update_time character varying(50), stream_key character varying(255), + server_id character varying(50), enable_disable_none_reader bool default false, constraint uk_stream_proxy_app_stream unique (app, stream) ); diff --git a/数据库/2.7.3/数据库统合-更新.sql b/数据库/2.7.3/数据库统合-更新.sql new file mode 100644 index 00000000..2f560341 --- /dev/null +++ b/数据库/2.7.3/数据库统合-更新.sql @@ -0,0 +1,6 @@ +/* +* WVP RPC 调用 +*/ +alter table wvp_device add server_id character varying(50); +alter table wvp_media_server add server_id character varying(50); +alter table wvp_stream_proxy add server_id character varying(50); \ No newline at end of file