临时提交
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user