Merge branch 'wvp-28181-2.0'
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java # src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java # src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java # src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java # src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java # src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java # src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java # web_src/src/components/dialog/devicePlayer.vue
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.genersoft.iot.vmp.vmanager.bean;
|
||||
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
public class DeferredResultEx<T> {
|
||||
|
||||
private DeferredResult<T> deferredResult;
|
||||
|
||||
private DeferredResultFilter filter;
|
||||
|
||||
public DeferredResultEx(DeferredResult<T> result) {
|
||||
this.deferredResult = result;
|
||||
}
|
||||
|
||||
|
||||
public DeferredResult<T> getDeferredResult() {
|
||||
return deferredResult;
|
||||
}
|
||||
|
||||
public void setDeferredResult(DeferredResult<T> deferredResult) {
|
||||
this.deferredResult = deferredResult;
|
||||
}
|
||||
|
||||
public DeferredResultFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(DeferredResultFilter filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.genersoft.iot.vmp.vmanager.bean;
|
||||
|
||||
public interface DeferredResultFilter {
|
||||
|
||||
Object handler(Object o);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.genersoft.iot.vmp.vmanager.bean;
|
||||
|
||||
public class ResourceBaceInfo {
|
||||
private int total;
|
||||
private int online;
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public int getOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
public void setOnline(int online) {
|
||||
this.online = online;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.genersoft.iot.vmp.vmanager.bean;
|
||||
|
||||
public class ResourceInfo {
|
||||
|
||||
private ResourceBaceInfo device;
|
||||
private ResourceBaceInfo channel;
|
||||
private ResourceBaceInfo push;
|
||||
private ResourceBaceInfo proxy;
|
||||
|
||||
public ResourceBaceInfo getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
public void setDevice(ResourceBaceInfo device) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
public ResourceBaceInfo getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(ResourceBaceInfo channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public ResourceBaceInfo getPush() {
|
||||
return push;
|
||||
}
|
||||
|
||||
public void setPush(ResourceBaceInfo push) {
|
||||
this.push = push;
|
||||
}
|
||||
|
||||
public ResourceBaceInfo getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public void setProxy(ResourceBaceInfo proxy) {
|
||||
this.proxy = proxy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.genersoft.iot.vmp.vmanager.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.common.VersionPo;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.VersionInfo;
|
||||
|
||||
public class SystemConfigInfo {
|
||||
|
||||
private int serverPort;
|
||||
private SipConfig sip;
|
||||
private UserSetting addOn;
|
||||
private VersionPo version;
|
||||
|
||||
public int getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
public void setServerPort(int serverPort) {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public SipConfig getSip() {
|
||||
return sip;
|
||||
}
|
||||
|
||||
public void setSip(SipConfig sip) {
|
||||
this.sip = sip;
|
||||
}
|
||||
|
||||
public UserSetting getAddOn() {
|
||||
return addOn;
|
||||
}
|
||||
|
||||
public void setAddOn(UserSetting addOn) {
|
||||
this.addOn = addOn;
|
||||
}
|
||||
|
||||
public VersionPo getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(VersionPo version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.genersoft.iot.vmp.vmanager.bean;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(description = "统一返回结果")
|
||||
public class WVPResult<T> {
|
||||
public class WVPResult<T> implements Cloneable{
|
||||
|
||||
public WVPResult() {
|
||||
}
|
||||
@@ -63,4 +63,9 @@ public class WVPResult<T> {
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.device;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.device;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.device;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
@@ -76,9 +76,6 @@ public class DeviceQuery {
|
||||
@Autowired
|
||||
private DynamicTask dynamicTask;
|
||||
|
||||
@Autowired
|
||||
private SubscribeHolder subscribeHolder;
|
||||
|
||||
/**
|
||||
* 使用ID查询国标设备
|
||||
* @param deviceId 国标ID
|
||||
@@ -184,7 +181,7 @@ public class DeviceQuery {
|
||||
}
|
||||
|
||||
// 清除redis记录
|
||||
boolean isSuccess = storager.delete(deviceId);
|
||||
boolean isSuccess = deviceService.delete(deviceId);
|
||||
if (isSuccess) {
|
||||
redisCatchStorage.clearCatchByDeviceId(deviceId);
|
||||
// 停止此设备的订阅更新
|
||||
@@ -228,7 +225,7 @@ public class DeviceQuery {
|
||||
@Parameter(name = "online", description = "是否在线")
|
||||
@Parameter(name = "channelType", description = "设备/子目录-> false/true")
|
||||
@GetMapping("/sub_channels/{deviceId}/{channelId}/channels")
|
||||
public ResponseEntity<PageInfo> subChannels(@PathVariable String deviceId,
|
||||
public PageInfo subChannels(@PathVariable String deviceId,
|
||||
@PathVariable String channelId,
|
||||
int page,
|
||||
int count,
|
||||
@@ -239,11 +236,11 @@ public class DeviceQuery {
|
||||
DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId);
|
||||
if (deviceChannel == null) {
|
||||
PageInfo<DeviceChannel> deviceChannelPageResult = new PageInfo<>();
|
||||
return new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK);
|
||||
return deviceChannelPageResult;
|
||||
}
|
||||
|
||||
PageInfo pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count);
|
||||
return new ResponseEntity<>(pageResult,HttpStatus.OK);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,9 +253,8 @@ public class DeviceQuery {
|
||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||
@Parameter(name = "channel", description = "通道信息", required = true)
|
||||
@PostMapping("/channel/update/{deviceId}")
|
||||
public ResponseEntity updateChannel(@PathVariable String deviceId,DeviceChannel channel){
|
||||
public void updateChannel(@PathVariable String deviceId,DeviceChannel channel){
|
||||
deviceChannelService.updateChannel(deviceId, channel);
|
||||
return new ResponseEntity<>(null,HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,11 +268,32 @@ public class DeviceQuery {
|
||||
@Parameter(name = "streamMode", description = "数据流传输模式, 取值:" +
|
||||
"UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)", required = true)
|
||||
@PostMapping("/transport/{deviceId}/{streamMode}")
|
||||
public ResponseEntity updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
public void updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
|
||||
Device device = deviceService.getDevice(deviceId);
|
||||
device.setStreamMode(streamMode);
|
||||
deviceService.updateDevice(device);
|
||||
return new ResponseEntity<>(null,HttpStatus.OK);
|
||||
deviceService.updateCustomDevice(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加设备信息
|
||||
* @param device 设备信息
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "添加设备信息")
|
||||
@Parameter(name = "device", description = "设备", required = true)
|
||||
@PostMapping("/device/add/")
|
||||
public void addDevice(Device device){
|
||||
|
||||
if (device == null || device.getDeviceId() == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR400);
|
||||
}
|
||||
|
||||
// 查看deviceId是否存在
|
||||
boolean exist = deviceService.isExist(device.getDeviceId());
|
||||
if (exist) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备编号已存在");
|
||||
}
|
||||
deviceService.addDevice(device);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,15 +304,11 @@ public class DeviceQuery {
|
||||
@Operation(summary = "更新设备信息")
|
||||
@Parameter(name = "device", description = "设备", required = true)
|
||||
@PostMapping("/device/update/")
|
||||
public ResponseEntity<WVPResult<String>> updateDevice(Device device){
|
||||
public void updateDevice(Device device){
|
||||
|
||||
if (device != null && device.getDeviceId() != null) {
|
||||
deviceService.updateDevice(device);
|
||||
deviceService.updateCustomDevice(device);
|
||||
}
|
||||
WVPResult<String> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
result.setMsg("success");
|
||||
return new ResponseEntity<>(result,HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,9 @@ public class MediaController {
|
||||
if (callId != null) {
|
||||
// 权限校验
|
||||
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
|
||||
if (streamAuthorityInfo.getCallId().equals(callId)) {
|
||||
if (streamAuthorityInfo != null
|
||||
&& streamAuthorityInfo.getCallId() != null
|
||||
&& streamAuthorityInfo.getCallId().equals(callId)) {
|
||||
authority = true;
|
||||
}else {
|
||||
throw new ControllerException(ErrorCode.ERROR400);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.platform;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
|
||||
@@ -1,43 +1,38 @@
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.play;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
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.exception.SsrcTransactionNotFoundException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.IMediaService;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
|
||||
import com.genersoft.iot.vmp.service.IMediaService;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
@@ -83,19 +78,63 @@ public class PlayController {
|
||||
@Autowired
|
||||
private IMediaServerService mediaServerService;
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Operation(summary = "开始点播")
|
||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
||||
@GetMapping("/start/{deviceId}/{channelId}")
|
||||
public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId,
|
||||
@PathVariable String channelId) {
|
||||
public DeferredResult<WVPResult<StreamInfo>> play(HttpServletRequest request, @PathVariable String deviceId,
|
||||
@PathVariable String channelId) {
|
||||
|
||||
// 获取可用的zlm
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null);
|
||||
|
||||
return playResult.getResult();
|
||||
RequestMessage msg = new RequestMessage();
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
|
||||
boolean exist = resultHolder.exist(key, null);
|
||||
msg.setKey(key);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
msg.setId(uuid);
|
||||
DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
||||
DeferredResultEx<WVPResult<StreamInfo>> deferredResultEx = new DeferredResultEx<>(result);
|
||||
|
||||
result.onTimeout(()->{
|
||||
logger.info("点播接口等待超时");
|
||||
// 释放rtpserver
|
||||
WVPResult<StreamInfo> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
||||
wvpResult.setMsg("点播超时");
|
||||
msg.setData(wvpResult);
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
|
||||
// TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误
|
||||
deferredResultEx.setFilter(result1 -> {
|
||||
WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1;
|
||||
WVPResult<StreamInfo> clone = null;
|
||||
try {
|
||||
clone = (WVPResult<StreamInfo>)wvpResult1.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (clone.getCode() == ErrorCode.SUCCESS.getCode()) {
|
||||
StreamInfo data = clone.getData().clone();
|
||||
data.channgeStreamIp(request.getLocalName());
|
||||
clone.setData(data);
|
||||
}
|
||||
return clone;
|
||||
});
|
||||
|
||||
// 录像查询以channelId作为deviceId查询
|
||||
resultHolder.put(key, uuid, deferredResultEx);
|
||||
|
||||
if (!exist) {
|
||||
playService.play(newMediaServerItem, deviceId, channelId, null, null, null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.record;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
@@ -18,8 +16,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -36,7 +32,6 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
@Tag(name = "国标录像")
|
||||
@@ -155,7 +150,7 @@ public class GBRecordController {
|
||||
throw new ControllerException(ErrorCode.ERROR400);
|
||||
}
|
||||
|
||||
Device device = deviceService.queryDevice(deviceId);
|
||||
Device device = deviceService.getDevice(deviceId);
|
||||
if (device == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "未找到");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//package com.genersoft.iot.vmp.vmanager.record;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.alibaba.fastjson2.JSONObject;
|
||||
//import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
||||
//import com.genersoft.iot.vmp.service.IRecordInfoServer;
|
||||
//import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.genersoft.iot.vmp.vmanager.server;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.VManageBootstrap;
|
||||
import com.genersoft.iot.vmp.common.SystemAllInfo;
|
||||
import com.genersoft.iot.vmp.common.VersionPo;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
@@ -11,9 +12,14 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.*;
|
||||
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.SystemConfigInfo;
|
||||
import gov.nist.javax.sip.SipStackImpl;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -28,8 +34,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.sip.ListeningPoint;
|
||||
import javax.sip.ObjectInUseException;
|
||||
import javax.sip.SipProvider;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Tag(name = "服务控制")
|
||||
@@ -53,6 +58,20 @@ public class ServerController {
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private IDeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private IDeviceChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private IStreamPushService pushService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IStreamProxyService proxyService;
|
||||
|
||||
|
||||
@Value("${server.port}")
|
||||
private int serverPort;
|
||||
|
||||
@@ -60,6 +79,9 @@ public class ServerController {
|
||||
@Autowired
|
||||
private ThreadPoolTaskExecutor taskExecutor;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
|
||||
@GetMapping(value = "/media_server/list")
|
||||
@ResponseBody
|
||||
@@ -113,14 +135,8 @@ public class ServerController {
|
||||
MediaServerItem mediaServerItemInDatabase = mediaServerService.getOne(mediaServerItem.getId());
|
||||
|
||||
if (mediaServerItemInDatabase != null) {
|
||||
if (ObjectUtils.isEmpty(mediaServerItemInDatabase.getSendRtpPortRange()) && ObjectUtils.isEmpty(mediaServerItem.getSendRtpPortRange())) {
|
||||
mediaServerItem.setSendRtpPortRange("30000,30500");
|
||||
}
|
||||
mediaServerService.update(mediaServerItem);
|
||||
} else {
|
||||
if (ObjectUtils.isEmpty(mediaServerItem.getSendRtpPortRange())) {
|
||||
mediaServerItem.setSendRtpPortRange("30000,30500");
|
||||
}
|
||||
mediaServerService.add(mediaServerItem);
|
||||
}
|
||||
}
|
||||
@@ -142,27 +158,39 @@ public class ServerController {
|
||||
@GetMapping(value = "/restart")
|
||||
@ResponseBody
|
||||
public void restart() {
|
||||
taskExecutor.execute(()-> {
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
|
||||
SipStackImpl stack = (SipStackImpl) up.getSipStack();
|
||||
stack.stop();
|
||||
Iterator listener = stack.getListeningPoints();
|
||||
while (listener.hasNext()) {
|
||||
stack.deleteListeningPoint((ListeningPoint) listener.next());
|
||||
}
|
||||
Iterator providers = stack.getSipProviders();
|
||||
while (providers.hasNext()) {
|
||||
stack.deleteSipProvider((SipProvider) providers.next());
|
||||
}
|
||||
VManageBootstrap.restart();
|
||||
} catch (InterruptedException | ObjectInUseException e) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||
}
|
||||
});
|
||||
// taskExecutor.execute(()-> {
|
||||
// try {
|
||||
// Thread.sleep(3000);
|
||||
// SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
|
||||
// SipStackImpl stack = (SipStackImpl) up.getSipStack();
|
||||
// stack.stop();
|
||||
// Iterator listener = stack.getListeningPoints();
|
||||
// while (listener.hasNext()) {
|
||||
// stack.deleteListeningPoint((ListeningPoint) listener.next());
|
||||
// }
|
||||
// Iterator providers = stack.getSipProviders();
|
||||
// while (providers.hasNext()) {
|
||||
// stack.deleteSipProvider((SipProvider) providers.next());
|
||||
// }
|
||||
// VManageBootstrap.restart();
|
||||
// } catch (InterruptedException | ObjectInUseException e) {
|
||||
// throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||
// }
|
||||
// });
|
||||
};
|
||||
|
||||
@Operation(summary = "获取系统信息信息")
|
||||
@GetMapping(value = "/system/configInfo")
|
||||
@ResponseBody
|
||||
public SystemConfigInfo getConfigInfo() {
|
||||
SystemConfigInfo systemConfigInfo = new SystemConfigInfo();
|
||||
systemConfigInfo.setVersion(versionInfo.getVersion());
|
||||
systemConfigInfo.setSip(sipConfig);
|
||||
systemConfigInfo.setAddOn(userSetting);
|
||||
systemConfigInfo.setServerPort(serverPort);
|
||||
return systemConfigInfo;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取版本信息")
|
||||
@GetMapping(value = "/version")
|
||||
@ResponseBody
|
||||
@@ -202,4 +230,46 @@ public class ServerController {
|
||||
public List<IHookSubscribe> getHooks() {
|
||||
return zlmHttpHookSubscribe.getAll();
|
||||
}
|
||||
|
||||
@GetMapping(value = "/system/info")
|
||||
@ResponseBody
|
||||
@Operation(summary = "获取系统信息")
|
||||
public SystemAllInfo getSystemInfo() {
|
||||
SystemAllInfo systemAllInfo = redisCatchStorage.getSystemInfo();
|
||||
|
||||
return systemAllInfo;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/media_server/load")
|
||||
@ResponseBody
|
||||
@Operation(summary = "获取负载信息")
|
||||
public List<MediaServerLoad> getMediaLoad() {
|
||||
List<MediaServerLoad> result = new ArrayList<>();
|
||||
List<MediaServerItem> allOnline = mediaServerService.getAllOnline();
|
||||
if (allOnline.size() == 0) {
|
||||
return result;
|
||||
}else {
|
||||
for (MediaServerItem mediaServerItem : allOnline) {
|
||||
result.add(mediaServerService.getLoad(mediaServerItem));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/resource/info")
|
||||
@ResponseBody
|
||||
@Operation(summary = "获取负载信息")
|
||||
public ResourceInfo getResourceInfo() {
|
||||
ResourceInfo result = new ResourceInfo();
|
||||
ResourceBaceInfo deviceInfo = deviceService.getOverview();
|
||||
result.setDevice(deviceInfo);
|
||||
ResourceBaceInfo channelInfo = channelService.getOverview();
|
||||
result.setChannel(channelInfo);
|
||||
ResourceBaceInfo pushInfo = pushService.getOverview();
|
||||
result.setPush(pushInfo);
|
||||
ResourceBaceInfo proxyInfo = proxyService.getOverview();
|
||||
result.setProxy(proxyInfo);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
package com.genersoft.iot.vmp.vmanager.streamProxy;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.IMediaService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -63,7 +58,7 @@ public class StreamProxyController {
|
||||
})
|
||||
@PostMapping(value = "/save")
|
||||
@ResponseBody
|
||||
public StreamInfo save(@RequestBody StreamProxyItem param){
|
||||
public StreamInfo save(@RequestBody StreamProxyItem param){
|
||||
logger.info("添加代理: " + JSONObject.toJSONString(param));
|
||||
if (ObjectUtils.isEmpty(param.getMediaServerId())) {
|
||||
param.setMediaServerId("auto");
|
||||
|
||||
Reference in New Issue
Block a user