临时提交

dev/数据库统合
648540858 2024-12-31 09:31:58 +08:00
parent 6dc64c05ee
commit 7e89b5f97f
8 changed files with 28 additions and 7 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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