使用Slf4j注解打印日志
This commit is contained in:
@@ -4,8 +4,8 @@ import com.alibaba.fastjson2.JSONArray;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.service.ICloudRecordService;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.ICloudRecordService;
|
||||
import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
|
||||
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
@@ -16,9 +16,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -35,14 +34,12 @@ import java.util.zip.ZipOutputStream;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Tag(name = "云端录像接口")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/cloud/record")
|
||||
public class CloudRecordController {
|
||||
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(CloudRecordController.class);
|
||||
|
||||
@Autowired
|
||||
private ICloudRecordService cloudRecordService;
|
||||
|
||||
@@ -66,7 +63,7 @@ public class CloudRecordController {
|
||||
@RequestParam(required = false) String mediaServerId
|
||||
|
||||
) {
|
||||
logger.info("[云端录像] 查询存在云端录像的日期 app->{}, stream->{}, mediaServerId->{}, year->{}, month->{}",
|
||||
log.info("[云端录像] 查询存在云端录像的日期 app->{}, stream->{}, mediaServerId->{}, year->{}, month->{}",
|
||||
app, stream, mediaServerId, year, month);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (ObjectUtils.isEmpty(year)) {
|
||||
@@ -117,7 +114,7 @@ public class CloudRecordController {
|
||||
@RequestParam(required = false) String callId
|
||||
|
||||
) {
|
||||
logger.info("[云端录像] 查询 app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
log.info("[云端录像] 查询 app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
app, stream, mediaServerId, page, count, startTime, endTime, callId);
|
||||
|
||||
List<MediaServer> mediaServers;
|
||||
@@ -232,7 +229,7 @@ public class CloudRecordController {
|
||||
@RequestParam(required = false) String callId,
|
||||
@RequestParam(required = false) Integer recordId
|
||||
){
|
||||
logger.info("[云端录像] 添加收藏,app={},stream={},mediaServerId={},startTime={},endTime={},callId={},recordId={}",
|
||||
log.info("[云端录像] 添加收藏,app={},stream={},mediaServerId={},startTime={},endTime={},callId={},recordId={}",
|
||||
app, stream, mediaServerId, startTime, endTime, callId, recordId);
|
||||
if (recordId != null) {
|
||||
return cloudRecordService.changeCollectById(recordId, true);
|
||||
@@ -260,7 +257,7 @@ public class CloudRecordController {
|
||||
@RequestParam(required = false) String callId,
|
||||
@RequestParam(required = false) Integer recordId
|
||||
){
|
||||
logger.info("[云端录像] 移除收藏,app={},stream={},mediaServerId={},startTime={},endTime={},callId={},recordId={}",
|
||||
log.info("[云端录像] 移除收藏,app={},stream={},mediaServerId={},startTime={},endTime={},callId={},recordId={}",
|
||||
app, stream, mediaServerId, startTime, endTime, callId, recordId);
|
||||
if (recordId != null) {
|
||||
return cloudRecordService.changeCollectById(recordId, false);
|
||||
@@ -306,7 +303,7 @@ public class CloudRecordController {
|
||||
@RequestParam(required = false) List<Integer> ids
|
||||
|
||||
) {
|
||||
logger.info("[下载指定录像文件的压缩包] 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
log.info("[下载指定录像文件的压缩包] 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
app, stream, mediaServerId, startTime, endTime, callId);
|
||||
|
||||
List<MediaServer> mediaServers;
|
||||
@@ -367,7 +364,7 @@ public class CloudRecordController {
|
||||
}
|
||||
zos.close();
|
||||
} catch (IOException e) {
|
||||
logger.error("[下载指定录像文件的压缩包] 失败: 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
log.error("[下载指定录像文件的压缩包] 失败: 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
app, stream, mediaServerId, startTime, endTime, callId, e);
|
||||
}
|
||||
}
|
||||
@@ -409,7 +406,7 @@ public class CloudRecordController {
|
||||
@RequestParam(required = false) String remoteHost
|
||||
|
||||
) {
|
||||
logger.info("[云端录像] 查询URL app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
log.info("[云端录像] 查询URL app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
app, stream, mediaServerId, page, count, startTime, endTime, callId);
|
||||
|
||||
List<MediaServer> mediaServers;
|
||||
|
||||
@@ -16,8 +16,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
@@ -32,13 +31,11 @@ import java.util.UUID;
|
||||
* 位置信息管理
|
||||
*/
|
||||
@Tag(name = "位置信息管理")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/position")
|
||||
public class MobilePositionController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class);
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@@ -114,12 +111,12 @@ public class MobilePositionController {
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 获取移动位置信息: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 获取移动位置信息: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
DeferredResult<MobilePosition> result = new DeferredResult<MobilePosition>(5*1000L);
|
||||
result.onTimeout(()->{
|
||||
logger.warn(String.format("获取移动位置信息超时"));
|
||||
log.warn(String.format("获取移动位置信息超时"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(uuid);
|
||||
|
||||
@@ -16,8 +16,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -29,13 +28,11 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "报警信息管理")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/alarm")
|
||||
public class AlarmController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(AlarmController.class);
|
||||
|
||||
@Autowired
|
||||
private IDeviceAlarmService deviceAlarmService;
|
||||
|
||||
@@ -121,7 +118,7 @@ public class AlarmController {
|
||||
try {
|
||||
commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}else {
|
||||
|
||||
@@ -20,8 +20,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -32,13 +31,12 @@ import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Tag(name = "国标设备配置")
|
||||
@RestController
|
||||
@RequestMapping("/api/device/config")
|
||||
public class DeviceConfig {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@@ -72,8 +70,8 @@ public class DeviceConfig {
|
||||
@RequestParam(required = false) String expiration,
|
||||
@RequestParam(required = false) String heartBeatInterval,
|
||||
@RequestParam(required = false) String heartBeatCount) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("报警复位API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("报警复位API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
@@ -87,12 +85,12 @@ public class DeviceConfig {
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 设备配置: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 设备配置: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
DeferredResult<String> result = new DeferredResult<String>(3 * 1000L);
|
||||
result.onTimeout(() -> {
|
||||
logger.warn(String.format("设备配置操作超时, 设备未返回应答指令"));
|
||||
log.warn(String.format("设备配置操作超时, 设备未返回应答指令"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(uuid);
|
||||
@@ -123,8 +121,8 @@ public class DeviceConfig {
|
||||
public DeferredResult<String> configDownloadApi(@PathVariable String deviceId,
|
||||
@PathVariable String configType,
|
||||
@RequestParam(required = false) String channelId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备状态查询API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("设备状态查询API调用");
|
||||
}
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
@@ -138,12 +136,12 @@ public class DeviceConfig {
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 获取设备配置: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 获取设备配置: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
DeferredResult<String> result = new DeferredResult<String > (3 * 1000L);
|
||||
result.onTimeout(()->{
|
||||
logger.warn(String.format("获取设备配置超时"));
|
||||
log.warn(String.format("获取设备配置超时"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(uuid);
|
||||
|
||||
@@ -20,8 +20,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -34,13 +33,11 @@ import java.text.ParseException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Tag(name = "国标设备控制")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/device/control")
|
||||
public class DeviceControl {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@@ -59,14 +56,14 @@ public class DeviceControl {
|
||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||
@GetMapping("/teleboot/{deviceId}")
|
||||
public void teleBootApi(@PathVariable String deviceId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备远程启动API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("设备远程启动API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
try {
|
||||
cmder.teleBootCmd(device);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 远程启动: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 远程启动: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -85,15 +82,15 @@ public class DeviceControl {
|
||||
@GetMapping("/record/{deviceId}/{recordCmdStr}")
|
||||
public DeferredResult<ResponseEntity<String>> recordApi(@PathVariable String deviceId,
|
||||
@PathVariable String recordCmdStr, String channelId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("开始/停止录像API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("开始/停止录像API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId;
|
||||
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L);
|
||||
result.onTimeout(() -> {
|
||||
logger.warn(String.format("开始/停止录像操作超时, 设备未返回应答指令"));
|
||||
log.warn(String.format("开始/停止录像操作超时, 设备未返回应答指令"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(key);
|
||||
@@ -114,7 +111,7 @@ public class DeviceControl {
|
||||
resultHolder.invokeAllResult(msg);
|
||||
},null);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 开始/停止录像: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 开始/停止录像: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -132,8 +129,8 @@ public class DeviceControl {
|
||||
@Parameter(name = "guardCmdStr", description = "命令, 可选值:SetGuard(布防),ResetGuard(撤防)", required = true)
|
||||
@GetMapping("/guard/{deviceId}/{guardCmdStr}")
|
||||
public DeferredResult<String> guardApi(@PathVariable String deviceId, @PathVariable String guardCmdStr) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("布防/撤防API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("布防/撤防API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + deviceId;
|
||||
@@ -147,13 +144,13 @@ public class DeviceControl {
|
||||
resultHolder.invokeResult(msg);
|
||||
},null);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
||||
}
|
||||
DeferredResult<String> result = new DeferredResult<>(3 * 1000L);
|
||||
resultHolder.put(key, uuid, result);
|
||||
result.onTimeout(() -> {
|
||||
logger.warn(String.format("布防/撤防操作超时, 设备未返回应答指令"));
|
||||
log.warn(String.format("布防/撤防操作超时, 设备未返回应答指令"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(key);
|
||||
@@ -181,8 +178,8 @@ public class DeviceControl {
|
||||
public DeferredResult<ResponseEntity<String>> resetAlarmApi(@PathVariable String deviceId, String channelId,
|
||||
@RequestParam(required = false) String alarmMethod,
|
||||
@RequestParam(required = false) String alarmType) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("报警复位API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("报警复位API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
@@ -196,12 +193,12 @@ public class DeviceControl {
|
||||
resultHolder.invokeResult(msg);
|
||||
},null);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 报警复位: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 报警复位: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L);
|
||||
result.onTimeout(() -> {
|
||||
logger.warn(String.format("报警复位操作超时, 设备未返回应答指令"));
|
||||
log.warn(String.format("报警复位操作超时, 设备未返回应答指令"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(uuid);
|
||||
@@ -225,14 +222,14 @@ public class DeviceControl {
|
||||
@GetMapping("/i_frame/{deviceId}")
|
||||
public JSONObject iFrame(@PathVariable String deviceId,
|
||||
@RequestParam(required = false) String channelId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("强制关键帧API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("强制关键帧API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
try {
|
||||
cmder.iFrameCmd(device, channelId);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 强制关键帧: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
JSONObject json = new JSONObject();
|
||||
@@ -261,8 +258,8 @@ public class DeviceControl {
|
||||
public DeferredResult<String> homePositionApi(String deviceId, String channelId, Boolean enabled,
|
||||
@RequestParam(required = false) Integer resetTime,
|
||||
@RequestParam(required = false) Integer presetIndex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("报警复位API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("报警复位API调用");
|
||||
}
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
@@ -276,12 +273,12 @@ public class DeviceControl {
|
||||
resultHolder.invokeResult(msg);
|
||||
},null);
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 看守位控制: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 看守位控制: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
DeferredResult<String> result = new DeferredResult<>(3 * 1000L);
|
||||
result.onTimeout(() -> {
|
||||
logger.warn(String.format("看守位控制操作超时, 设备未返回应答指令"));
|
||||
log.warn(String.format("看守位控制操作超时, 设备未返回应答指令"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(uuid);
|
||||
@@ -326,8 +323,8 @@ public class DeviceControl {
|
||||
@RequestParam int midpointy,
|
||||
@RequestParam int lengthx,
|
||||
@RequestParam int lengthy) throws RuntimeException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("设备拉框放大 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("设备拉框放大 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
StringBuffer cmdXml = new StringBuffer(200);
|
||||
@@ -342,7 +339,7 @@ public class DeviceControl {
|
||||
try {
|
||||
cmder.dragZoomCmd(device, channelId, cmdXml.toString());
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 拉框放大: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 拉框放大: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -378,8 +375,8 @@ public class DeviceControl {
|
||||
@RequestParam int lengthx,
|
||||
@RequestParam int lengthy){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("设备拉框缩小 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("设备拉框缩小 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
StringBuffer cmdXml = new StringBuffer(200);
|
||||
@@ -394,7 +391,7 @@ public class DeviceControl {
|
||||
try {
|
||||
cmder.dragZoomCmd(device, channelId, cmdXml.toString());
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 拉框缩小: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 拉框缩小: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -53,13 +52,11 @@ import java.util.UUID;
|
||||
|
||||
@Tag(name = "国标设备查询", description = "国标设备查询")
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/device/query")
|
||||
public class DeviceQuery {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class);
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@@ -158,8 +155,8 @@ public class DeviceQuery {
|
||||
@GetMapping("/devices/{deviceId}/sync")
|
||||
public WVPResult<SyncStatus> devicesSync(@PathVariable String deviceId){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备通道信息同步API调用,deviceId:" + deviceId);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("设备通道信息同步API调用,deviceId:" + deviceId);
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
boolean status = deviceService.isSyncRunning(deviceId);
|
||||
@@ -186,8 +183,8 @@ public class DeviceQuery {
|
||||
@DeleteMapping("/devices/{deviceId}/delete")
|
||||
public String delete(@PathVariable String deviceId){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备信息删除API调用,deviceId:" + deviceId);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("设备信息删除API调用,deviceId:" + deviceId);
|
||||
}
|
||||
|
||||
// 清除redis记录
|
||||
@@ -210,7 +207,7 @@ public class DeviceQuery {
|
||||
json.put("deviceId", deviceId);
|
||||
return json.toString();
|
||||
} else {
|
||||
logger.warn("设备信息删除API调用失败!");
|
||||
log.warn("设备信息删除API调用失败!");
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备信息删除API调用失败!");
|
||||
}
|
||||
}
|
||||
@@ -340,8 +337,8 @@ public class DeviceQuery {
|
||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||
@GetMapping("/devices/{deviceId}/status")
|
||||
public DeferredResult<ResponseEntity<String>> deviceStatusApi(@PathVariable String deviceId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备状态查询API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("设备状态查询API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
@@ -360,11 +357,11 @@ public class DeviceQuery {
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 获取设备状态: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 获取设备状态: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
result.onTimeout(()->{
|
||||
logger.warn(String.format("获取设备状态超时"));
|
||||
log.warn(String.format("获取设备状态超时"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(uuid);
|
||||
@@ -403,8 +400,8 @@ public class DeviceQuery {
|
||||
@RequestParam(required = false) String alarmType,
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备报警查询API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("设备报警查询API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_ALARM + deviceId;
|
||||
@@ -418,12 +415,12 @@ public class DeviceQuery {
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 设备报警查询: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 设备报警查询: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String >> (3 * 1000L);
|
||||
result.onTimeout(()->{
|
||||
logger.warn(String.format("设备报警查询超时"));
|
||||
log.warn(String.format("设备报警查询超时"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(uuid);
|
||||
|
||||
@@ -7,31 +7,31 @@ import com.genersoft.iot.vmp.conf.security.SecurityUtils;
|
||||
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
@Tag(name = "媒体流相关")
|
||||
@Controller
|
||||
|
||||
@Slf4j
|
||||
@RequestMapping(value = "/api/media")
|
||||
public class MediaController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(MediaController.class);
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class MediaController {
|
||||
if (useSourceIpAsStreamIp != null && useSourceIpAsStreamIp) {
|
||||
String host = request.getHeader("Host");
|
||||
String localAddr = host.split(":")[0];
|
||||
logger.info("使用{}作为返回流的ip", localAddr);
|
||||
log.info("使用{}作为返回流的ip", localAddr);
|
||||
streamInfo = mediaServerService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority);
|
||||
}else {
|
||||
streamInfo = mediaServerService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
|
||||
@@ -100,12 +100,12 @@ public class MediaController {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("[线程休眠失败], {}", e.getMessage());
|
||||
log.error("[线程休眠失败], {}", e.getMessage());
|
||||
}
|
||||
if (useSourceIpAsStreamIp != null && useSourceIpAsStreamIp) {
|
||||
String host = request.getHeader("Host");
|
||||
String localAddr = host.split(":")[0];
|
||||
logger.info("使用{}作为返回流的ip", localAddr);
|
||||
log.info("使用{}作为返回流的ip", localAddr);
|
||||
streamInfo = mediaServerService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority);
|
||||
}else {
|
||||
streamInfo = mediaServerService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
@@ -12,7 +13,9 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.genersoft.iot.vmp.service.*;
|
||||
import com.genersoft.iot.vmp.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.service.IPlatformService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
@@ -24,12 +27,10 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
@@ -40,13 +41,11 @@ import java.util.List;
|
||||
* 级联平台管理
|
||||
*/
|
||||
@Tag(name = "级联平台管理")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/platform")
|
||||
public class PlatformController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PlatformController.class);
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@@ -144,8 +143,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void addPlatform(@RequestBody ParentPlatform parentPlatform) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("保存上级平台信息API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("保存上级平台信息API调用");
|
||||
}
|
||||
if (ObjectUtils.isEmpty(parentPlatform.getName())
|
||||
|| ObjectUtils.isEmpty(parentPlatform.getServerGBId())
|
||||
@@ -189,8 +188,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void savePlatform(@RequestBody ParentPlatform parentPlatform) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("保存上级平台信息API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("保存上级平台信息API调用");
|
||||
}
|
||||
if (ObjectUtils.isEmpty(parentPlatform.getName())
|
||||
|| ObjectUtils.isEmpty(parentPlatform.getServerGBId())
|
||||
@@ -221,8 +220,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void deletePlatform(@PathVariable String serverGBId) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除上级平台API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("删除上级平台API调用");
|
||||
}
|
||||
if (ObjectUtils.isEmpty(serverGBId)
|
||||
) {
|
||||
@@ -252,7 +251,7 @@ public class PlatformController {
|
||||
redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId());
|
||||
}));
|
||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
||||
logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
|
||||
}
|
||||
|
||||
boolean deleteResult = storager.deleteParentPlatform(parentPlatform);
|
||||
@@ -337,13 +336,13 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void updateChannelForGB(@RequestBody UpdateChannelParam param) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("给上级平台添加国标通道API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("给上级平台添加国标通道API调用");
|
||||
}
|
||||
int result = 0;
|
||||
if (param.getChannelReduces() == null || param.getChannelReduces().size() == 0) {
|
||||
if (param.isAll()) {
|
||||
logger.info("[国标级联]添加所有通道到上级平台, {}", param.getPlatformId());
|
||||
log.info("[国标级联]添加所有通道到上级平台, {}", param.getPlatformId());
|
||||
List<ChannelReduce> allChannelForDevice = deviceChannelService.queryAllChannelList(param.getPlatformId());
|
||||
result = platformChannelService.updateChannelForGB(param.getPlatformId(), allChannelForDevice, param.getCatalogId());
|
||||
}
|
||||
@@ -366,13 +365,13 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void delChannelForGB(@RequestBody UpdateChannelParam param) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("给上级平台删除国标通道API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("给上级平台删除国标通道API调用");
|
||||
}
|
||||
int result = 0;
|
||||
if (param.getChannelReduces() == null || param.getChannelReduces().size() == 0) {
|
||||
if (param.isAll()) {
|
||||
logger.info("[国标级联]移除所有通道,上级平台, {}", param.getPlatformId());
|
||||
log.info("[国标级联]移除所有通道,上级平台, {}", param.getPlatformId());
|
||||
result = platformChannelService.delAllChannelForGB(param.getPlatformId(), param.getCatalogId());
|
||||
}
|
||||
}else {
|
||||
@@ -397,8 +396,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public List<PlatformCatalog> getCatalogByPlatform(String platformId, String parentId) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId);
|
||||
}
|
||||
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
|
||||
if (platform == null) {
|
||||
@@ -426,8 +425,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void addCatalog(@RequestBody PlatformCatalog platformCatalog) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("添加目录,{}", JSON.toJSONString(platformCatalog));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("添加目录,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId());
|
||||
|
||||
@@ -451,8 +450,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void editCatalog(@RequestBody PlatformCatalog platformCatalog) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("编辑目录,{}", JSON.toJSONString(platformCatalog));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("编辑目录,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId());
|
||||
|
||||
@@ -479,8 +478,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void delCatalog(String id, String platformId) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除目录,{}", id);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("删除目录,{}", id);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(platformId)) {
|
||||
@@ -512,8 +511,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void delRelation(@RequestBody PlatformCatalog platformCatalog) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除关联,{}", JSON.toJSONString(platformCatalog));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("删除关联,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
int delResult = storager.delRelation(platformCatalog);
|
||||
|
||||
@@ -537,8 +536,8 @@ public class PlatformController {
|
||||
@ResponseBody
|
||||
public void setDefaultCatalog(String platformId, String catalogId) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("修改默认目录,{},{}", platformId, catalogId);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("修改默认目录,{},{}", platformId, catalogId);
|
||||
}
|
||||
int updateResult = storager.setDefaultCatalog(platformId, catalogId);
|
||||
|
||||
|
||||
@@ -28,8 +28,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -46,13 +45,11 @@ import java.util.UUID;
|
||||
* @author lin
|
||||
*/
|
||||
@Tag(name = "国标设备点播")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/play")
|
||||
public class PlayController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PlayController.class);
|
||||
|
||||
@Autowired
|
||||
private SIPCommander cmder;
|
||||
|
||||
@@ -84,7 +81,7 @@ public class PlayController {
|
||||
public DeferredResult<WVPResult<StreamContent>> play(HttpServletRequest request, @PathVariable String deviceId,
|
||||
@PathVariable String channelId) {
|
||||
|
||||
logger.info("[开始点播] deviceId:{}, channelId:{}, ", deviceId, channelId);
|
||||
log.info("[开始点播] deviceId:{}, channelId:{}, ", deviceId, channelId);
|
||||
// 获取可用的zlm
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
MediaServer newMediaServerItem = playService.getNewMediaServerItem(device);
|
||||
@@ -97,7 +94,7 @@ public class PlayController {
|
||||
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
||||
|
||||
result.onTimeout(()->{
|
||||
logger.info("[点播等待超时] deviceId:{}, channelId:{}, ", deviceId, channelId);
|
||||
log.info("[点播等待超时] deviceId:{}, channelId:{}, ", deviceId, channelId);
|
||||
// 释放rtpserver
|
||||
WVPResult<StreamInfo> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(ErrorCode.ERROR100.getCode());
|
||||
@@ -155,7 +152,7 @@ public class PlayController {
|
||||
@GetMapping("/stop/{deviceId}/{channelId}")
|
||||
public JSONObject playStop(@PathVariable String deviceId, @PathVariable String channelId) {
|
||||
|
||||
logger.debug(String.format("设备预览/回放停止API调用,streamId:%s_%s", deviceId, channelId ));
|
||||
log.debug(String.format("设备预览/回放停止API调用,streamId:%s_%s", deviceId, channelId ));
|
||||
|
||||
if (deviceId == null || channelId == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR400);
|
||||
@@ -201,8 +198,8 @@ public class PlayController {
|
||||
@GetMapping("/broadcast/{deviceId}/{channelId}")
|
||||
@PostMapping("/broadcast/{deviceId}/{channelId}")
|
||||
public AudioBroadcastResult broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout, Boolean broadcastMode) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("语音广播API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("语音广播API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
if (device == null) {
|
||||
@@ -222,8 +219,8 @@ public class PlayController {
|
||||
@GetMapping("/broadcast/stop/{deviceId}/{channelId}")
|
||||
@PostMapping("/broadcast/stop/{deviceId}/{channelId}")
|
||||
public void stopBroadcast(@PathVariable String deviceId, @PathVariable String channelId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("停止语音广播API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("停止语音广播API调用");
|
||||
}
|
||||
// try {
|
||||
// playService.stopAudioBroadcast(deviceId, channelId);
|
||||
@@ -237,8 +234,8 @@ public class PlayController {
|
||||
@Operation(summary = "获取所有的ssrc", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@GetMapping("/ssrc")
|
||||
public JSONObject getSSRC() {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("获取所有的ssrc");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("获取所有的ssrc");
|
||||
}
|
||||
JSONArray objects = new JSONArray();
|
||||
List<SsrcTransaction> allSsrc = streamSession.getAllSsrc();
|
||||
@@ -263,8 +260,8 @@ public class PlayController {
|
||||
@Parameter(name = "isSubStream", description = "是否子码流(true-子码流,false-主码流),默认为false", required = true)
|
||||
@GetMapping("/snap")
|
||||
public DeferredResult<String> getSnap(String deviceId, String channelId,boolean isSubStream) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("获取截图: {}/{}", deviceId, channelId);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("获取截图: {}/{}", deviceId, channelId);
|
||||
}
|
||||
|
||||
DeferredResult<String> result = new DeferredResult<>(3 * 1000L);
|
||||
|
||||
@@ -23,8 +23,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -45,13 +44,11 @@ import java.util.UUID;
|
||||
* @author lin
|
||||
*/
|
||||
@Tag(name = "视频回放")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/playback")
|
||||
public class PlaybackController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PlaybackController.class);
|
||||
|
||||
@Autowired
|
||||
private SIPCommander cmder;
|
||||
|
||||
@@ -79,8 +76,8 @@ public class PlaybackController {
|
||||
public DeferredResult<WVPResult<StreamContent>> start(HttpServletRequest request, @PathVariable String deviceId, @PathVariable String channelId,
|
||||
String startTime, String endTime) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("设备回放 API调用,deviceId:%s ,channelId:%s", deviceId, channelId));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("设备回放 API调用,deviceId:%s ,channelId:%s", deviceId, channelId));
|
||||
}
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
@@ -155,7 +152,7 @@ public class PlaybackController {
|
||||
@Parameter(name = "streamId", description = "回放流ID", required = true)
|
||||
@GetMapping("/pause/{streamId}")
|
||||
public void playPause(@PathVariable String streamId) {
|
||||
logger.info("playPause: "+streamId);
|
||||
log.info("playPause: "+streamId);
|
||||
|
||||
try {
|
||||
playService.pauseRtp(streamId);
|
||||
@@ -171,7 +168,7 @@ public class PlaybackController {
|
||||
@Parameter(name = "streamId", description = "回放流ID", required = true)
|
||||
@GetMapping("/resume/{streamId}")
|
||||
public void playResume(@PathVariable String streamId) {
|
||||
logger.info("playResume: "+streamId);
|
||||
log.info("playResume: "+streamId);
|
||||
try {
|
||||
playService.resumeRtp(streamId);
|
||||
} catch (ServiceException e) {
|
||||
@@ -187,11 +184,11 @@ public class PlaybackController {
|
||||
@Parameter(name = "seekTime", description = "拖动偏移量,单位s", required = true)
|
||||
@GetMapping("/seek/{streamId}/{seekTime}")
|
||||
public void playSeek(@PathVariable String streamId, @PathVariable long seekTime) {
|
||||
logger.info("playSeek: "+streamId+", "+seekTime);
|
||||
log.info("playSeek: "+streamId+", "+seekTime);
|
||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId);
|
||||
|
||||
if (null == inviteInfo || inviteInfo.getStreamInfo() == null) {
|
||||
logger.warn("streamId不存在!");
|
||||
log.warn("streamId不存在!");
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(inviteInfo.getDeviceId());
|
||||
@@ -207,15 +204,15 @@ public class PlaybackController {
|
||||
@Parameter(name = "speed", description = "倍速0.25 0.5 1、2、4", required = true)
|
||||
@GetMapping("/speed/{streamId}/{speed}")
|
||||
public void playSpeed(@PathVariable String streamId, @PathVariable Double speed) {
|
||||
logger.info("playSpeed: "+streamId+", "+speed);
|
||||
log.info("playSpeed: "+streamId+", "+speed);
|
||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId);
|
||||
|
||||
if (null == inviteInfo || inviteInfo.getStreamInfo() == null) {
|
||||
logger.warn("streamId不存在!");
|
||||
log.warn("streamId不存在!");
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
|
||||
}
|
||||
if(speed != 0.25 && speed != 0.5 && speed != 1 && speed != 2.0 && speed != 4.0) {
|
||||
logger.warn("不支持的speed: " + speed);
|
||||
log.warn("不支持的speed: " + speed);
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持的speed(0.25 0.5 1、2、4)");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(inviteInfo.getDeviceId());
|
||||
|
||||
@@ -13,8 +13,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -26,13 +25,11 @@ import java.text.ParseException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Tag(name = "云台控制")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/ptz")
|
||||
public class PtzController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PtzController.class);
|
||||
|
||||
@Autowired
|
||||
private SIPCommander cmder;
|
||||
|
||||
@@ -62,8 +59,8 @@ public class PtzController {
|
||||
@PostMapping("/control/{deviceId}/{channelId}")
|
||||
public void ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,command:%s ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,command:%s ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed));
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
int cmdCode = 0;
|
||||
@@ -109,7 +106,7 @@ public class PtzController {
|
||||
try {
|
||||
cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 云台控制: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 云台控制: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -125,15 +122,15 @@ public class PtzController {
|
||||
@PostMapping("/front_end_command/{deviceId}/{channelId}")
|
||||
public void frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int parameter1, int parameter2, int combindCode2){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d parameter1:%d parameter2:%d",deviceId, channelId, cmdCode, parameter1, parameter2));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d parameter1:%d parameter2:%d",deviceId, channelId, cmdCode, parameter1, parameter2));
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
|
||||
try {
|
||||
cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 前端控制: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 前端控制: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -144,15 +141,15 @@ public class PtzController {
|
||||
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
||||
@GetMapping("/preset/query/{deviceId}/{channelId}")
|
||||
public DeferredResult<String> presetQueryApi(@PathVariable String deviceId, @PathVariable String channelId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备预置位查询API调用");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("设备预置位查询API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
|
||||
DeferredResult<String> result = new DeferredResult<String> (3 * 1000L);
|
||||
result.onTimeout(()->{
|
||||
logger.warn(String.format("获取设备预置位超时"));
|
||||
log.warn(String.format("获取设备预置位超时"));
|
||||
// 释放rtpserver
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setId(uuid);
|
||||
@@ -173,7 +170,7 @@ public class PtzController {
|
||||
resultHolder.invokeResult(msg);
|
||||
});
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 获取设备预置位: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 获取设备预置位: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.genersoft.iot.vmp.vmanager.gb28181.record;
|
||||
|
||||
import com.genersoft.iot.vmp.common.InviteInfo;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
@@ -15,7 +13,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
@@ -26,10 +23,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -43,13 +38,11 @@ import java.text.ParseException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Tag(name = "国标录像")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/gb_record")
|
||||
public class GBRecordController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(GBRecordController.class);
|
||||
|
||||
@Autowired
|
||||
private SIPCommander cmder;
|
||||
|
||||
@@ -79,8 +72,8 @@ public class GBRecordController {
|
||||
@GetMapping("/query/{deviceId}/{channelId}")
|
||||
public DeferredResult<WVPResult<RecordInfo>> recordinfo(@PathVariable String deviceId, @PathVariable String channelId, String startTime, String endTime){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("录像信息查询 API调用,deviceId:%s ,startTime:%s, endTime:%s",deviceId, startTime, endTime));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("录像信息查询 API调用,deviceId:%s ,startTime:%s, endTime:%s",deviceId, startTime, endTime));
|
||||
}
|
||||
DeferredResult<WVPResult<RecordInfo>> result = new DeferredResult<>();
|
||||
if (!DateUtil.verification(startTime, DateUtil.formatter)){
|
||||
@@ -107,7 +100,7 @@ public class GBRecordController {
|
||||
resultHolder.invokeResult(msg);
|
||||
}));
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
logger.error("[命令发送失败] 查询录像: {}", e.getMessage());
|
||||
log.error("[命令发送失败] 查询录像: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -135,8 +128,8 @@ public class GBRecordController {
|
||||
public DeferredResult<WVPResult<StreamContent>> download(HttpServletRequest request, @PathVariable String deviceId, @PathVariable String channelId,
|
||||
String startTime, String endTime, String downloadSpeed) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("历史媒体下载 API调用,deviceId:%s,channelId:%s,downloadSpeed:%s", deviceId, channelId, downloadSpeed));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("历史媒体下载 API调用,deviceId:%s,channelId:%s,downloadSpeed:%s", deviceId, channelId, downloadSpeed));
|
||||
}
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
@@ -181,8 +174,8 @@ public class GBRecordController {
|
||||
@GetMapping("/download/stop/{deviceId}/{channelId}/{stream}")
|
||||
public void playStop(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("设备历史媒体下载停止 API调用,deviceId/channelId:%s_%s", deviceId, channelId));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("设备历史媒体下载停止 API调用,deviceId/channelId:%s_%s", deviceId, channelId));
|
||||
}
|
||||
|
||||
if (deviceId == null || channelId == null) {
|
||||
@@ -197,7 +190,7 @@ public class GBRecordController {
|
||||
try {
|
||||
cmder.streamByeCmd(device, channelId, stream, null);
|
||||
} catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) {
|
||||
logger.error("[停止历史媒体下载]停止历史媒体下载,发送BYE失败 {}", e.getMessage());
|
||||
log.error("[停止历史媒体下载]停止历史媒体下载,发送BYE失败 {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,20 +13,17 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Tag(name = "日志管理")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/log")
|
||||
public class LogController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(LogController.class);
|
||||
|
||||
@Autowired
|
||||
private ILogService logService;
|
||||
|
||||
@@ -65,7 +62,7 @@ public class LogController {
|
||||
}
|
||||
|
||||
if (!userSetting.getLogInDatabase()) {
|
||||
logger.warn("自动记录日志功能已关闭,查询结果可能不完整。");
|
||||
log.warn("自动记录日志功能已关闭,查询结果可能不完整。");
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(startTime)) {
|
||||
|
||||
@@ -20,10 +20,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -37,13 +36,11 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Tag(name = "第三方PS服务对接")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/ps")
|
||||
public class PsController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(PsController.class);
|
||||
|
||||
@Autowired
|
||||
private HookSubscribe hookSubscribe;
|
||||
|
||||
@@ -75,7 +72,7 @@ public class PsController {
|
||||
@Parameter(name = "callBack", description = "回调地址,如果收流超时会通道回调通知,回调为get请求,参数为callId", required = true)
|
||||
public OtherPsSendInfo openRtpServer(Boolean isSend, @RequestParam(required = false)String ssrc, String callId, String stream, Integer tcpMode, String callBack) {
|
||||
|
||||
logger.info("[第三方PS服务对接->开启收流和获取发流信息] isSend->{}, ssrc->{}, callId->{}, stream->{}, tcpMode->{}, callBack->{}",
|
||||
log.info("[第三方PS服务对接->开启收流和获取发流信息] isSend->{}, ssrc->{}, callId->{}, stream->{}, tcpMode->{}, callBack->{}",
|
||||
isSend, ssrc, callId, stream, tcpMode==0?"UDP":"TCP被动", callBack);
|
||||
|
||||
MediaServer mediaServer = mediaServerService.getDefaultMediaServer();
|
||||
@@ -109,7 +106,7 @@ public class PsController {
|
||||
hookSubscribe.addSubscribe(hook,
|
||||
(hookData)->{
|
||||
if (stream.equals(hookData.getStream())) {
|
||||
logger.info("[第三方PS服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调", callId);
|
||||
log.info("[第三方PS服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调", callId);
|
||||
// 将信息写入redis中,以备后用
|
||||
redisTemplate.delete(receiveKey);
|
||||
OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
|
||||
@@ -119,7 +116,7 @@ public class PsController {
|
||||
try {
|
||||
client.newCall(request).execute();
|
||||
} catch (IOException e) {
|
||||
logger.error("[第三方PS服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调失败", callId, e);
|
||||
log.error("[第三方PS服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调失败", callId, e);
|
||||
}
|
||||
hookSubscribe.removeSubscribe(hook);
|
||||
}
|
||||
@@ -142,7 +139,7 @@ public class PsController {
|
||||
otherPsSendInfo.setSendLocalPort(port);
|
||||
// 将信息写入redis中,以备后用
|
||||
redisTemplate.opsForValue().set(key, otherPsSendInfo, 300, TimeUnit.SECONDS);
|
||||
logger.info("[第三方PS服务对接->开启收流和获取发流信息] 结果,callId->{}, {}", callId, otherPsSendInfo);
|
||||
log.info("[第三方PS服务对接->开启收流和获取发流信息] 结果,callId->{}, {}", callId, otherPsSendInfo);
|
||||
}
|
||||
return otherPsSendInfo;
|
||||
}
|
||||
@@ -152,7 +149,7 @@ public class PsController {
|
||||
@Operation(summary = "关闭收流", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "stream", description = "流的ID", required = true)
|
||||
public void closeRtpServer(String stream) {
|
||||
logger.info("[第三方PS服务对接->关闭收流] stream->{}", stream);
|
||||
log.info("[第三方PS服务对接->关闭收流] stream->{}", stream);
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
mediaServerService.closeRTPServer(mediaServerItem, stream);
|
||||
String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_*_" + stream;
|
||||
@@ -183,7 +180,7 @@ public class PsController {
|
||||
String callId,
|
||||
Boolean isUdp
|
||||
) {
|
||||
logger.info("[第三方PS服务对接->发送流] " +
|
||||
log.info("[第三方PS服务对接->发送流] " +
|
||||
"ssrc->{}, \r\n" +
|
||||
"dstIp->{}, \n" +
|
||||
"dstPort->{}, \n" +
|
||||
@@ -209,14 +206,14 @@ public class PsController {
|
||||
Boolean streamReady = mediaServerService.isStreamReady(mediaServer, app, stream);
|
||||
if (streamReady) {
|
||||
mediaServerService.startSendRtp(mediaServer, sendRtpItem);
|
||||
logger.info("[第三方PS服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, sendRtpItem);
|
||||
log.info("[第三方PS服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, sendRtpItem);
|
||||
redisTemplate.opsForValue().set(key, sendInfo);
|
||||
}else {
|
||||
logger.info("[第三方PS服务对接->发送流] 流不存在,等待流上线,callId->{}", callId);
|
||||
log.info("[第三方PS服务对接->发送流] 流不存在,等待流上线,callId->{}", callId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Hook hook = Hook.getInstance(HookType.on_media_arrival, app, stream, mediaServer.getId());
|
||||
dynamicTask.startDelay(uuid, ()->{
|
||||
logger.info("[第三方PS服务对接->发送流] 等待流上线超时 callId->{}", callId);
|
||||
log.info("[第三方PS服务对接->发送流] 等待流上线超时 callId->{}", callId);
|
||||
redisTemplate.delete(key);
|
||||
hookSubscribe.removeSubscribe(hook);
|
||||
}, 10000);
|
||||
@@ -227,14 +224,14 @@ public class PsController {
|
||||
hookSubscribe.addSubscribe(hook,
|
||||
(hookData)->{
|
||||
dynamicTask.stop(uuid);
|
||||
logger.info("[第三方PS服务对接->发送流] 流上线,开始发流 callId->{}", callId);
|
||||
log.info("[第三方PS服务对接->发送流] 流上线,开始发流 callId->{}", callId);
|
||||
try {
|
||||
Thread.sleep(400);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
mediaServerService.startSendRtp(mediaServer, sendRtpItem);
|
||||
logger.info("[第三方PS服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, sendRtpItem);
|
||||
log.info("[第三方PS服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, sendRtpItem);
|
||||
redisTemplate.opsForValue().set(key, finalSendInfo);
|
||||
hookSubscribe.removeSubscribe(hook);
|
||||
});
|
||||
@@ -246,7 +243,7 @@ public class PsController {
|
||||
@Operation(summary = "关闭发送流")
|
||||
@Parameter(name = "callId", description = "整个过程的唯一标识,不传则使用随机端口发流", required = true)
|
||||
public void closeSendRTP(String callId) {
|
||||
logger.info("[第三方PS服务对接->关闭发送流] callId->{}", callId);
|
||||
log.info("[第三方PS服务对接->关闭发送流] callId->{}", callId);
|
||||
String key = VideoManagerConstants.WVP_OTHER_SEND_PS_INFO + userSetting.getServerId() + "_" + callId;
|
||||
OtherPsSendInfo sendInfo = (OtherPsSendInfo)redisTemplate.opsForValue().get(key);
|
||||
if (sendInfo == null){
|
||||
@@ -260,10 +257,10 @@ public class PsController {
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
boolean result = mediaServerService.stopSendRtp(mediaServerItem, sendInfo.getPushApp(), sendInfo.getStream(), sendInfo.getPushSSRC());
|
||||
if (!result) {
|
||||
logger.info("[第三方PS服务对接->关闭发送流] 失败 callId->{}", callId);
|
||||
log.info("[第三方PS服务对接->关闭发送流] 失败 callId->{}", callId);
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "停止发流失败");
|
||||
}else {
|
||||
logger.info("[第三方PS服务对接->关闭发送流] 成功 callId->{}", callId);
|
||||
log.info("[第三方PS服务对接->关闭发送流] 成功 callId->{}", callId);
|
||||
}
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -36,7 +35,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Tag(name = "第三方服务对接")
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/rtp")
|
||||
public class RtpController {
|
||||
@@ -44,8 +43,6 @@ public class RtpController {
|
||||
@Autowired
|
||||
private SendRtpPortManager sendRtpPortManager;
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(RtpController.class);
|
||||
|
||||
@Autowired
|
||||
private HookSubscribe hookSubscribe;
|
||||
|
||||
@@ -73,7 +70,7 @@ public class RtpController {
|
||||
@Parameter(name = "callBack", description = "回调地址,如果收流超时会通道回调通知,回调为get请求,参数为callId", required = true)
|
||||
public OtherRtpSendInfo openRtpServer(Boolean isSend, @RequestParam(required = false)String ssrc, String callId, String stream, Integer tcpMode, String callBack) {
|
||||
|
||||
logger.info("[第三方服务对接->开启收流和获取发流信息] isSend->{}, ssrc->{}, callId->{}, stream->{}, tcpMode->{}, callBack->{}",
|
||||
log.info("[第三方服务对接->开启收流和获取发流信息] isSend->{}, ssrc->{}, callId->{}, stream->{}, tcpMode->{}, callBack->{}",
|
||||
isSend, ssrc, callId, stream, tcpMode==0?"UDP":"TCP被动", callBack);
|
||||
|
||||
MediaServer mediaServer = mediaServerService.getDefaultMediaServer();
|
||||
@@ -107,7 +104,7 @@ public class RtpController {
|
||||
hookSubscribe.addSubscribe(hook,
|
||||
(hookData)->{
|
||||
if (stream.equals(hookData.getStream())) {
|
||||
logger.info("[开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调", callId);
|
||||
log.info("[开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调", callId);
|
||||
OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
|
||||
OkHttpClient client = httpClientBuilder.build();
|
||||
String url = callBack + "?callId=" + callId;
|
||||
@@ -115,7 +112,7 @@ public class RtpController {
|
||||
try {
|
||||
client.newCall(request).execute();
|
||||
} catch (IOException e) {
|
||||
logger.error("[第三方服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调失败", callId, e);
|
||||
log.error("[第三方服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调失败", callId, e);
|
||||
}
|
||||
hookSubscribe.removeSubscribe(hook);
|
||||
}
|
||||
@@ -141,7 +138,7 @@ public class RtpController {
|
||||
otherRtpSendInfo.setSendLocalPortForAudio(portForAudio);
|
||||
// 将信息写入redis中,以备后用
|
||||
redisTemplate.opsForValue().set(key, otherRtpSendInfo, 300, TimeUnit.SECONDS);
|
||||
logger.info("[第三方服务对接->开启收流和获取发流信息] 结果,callId->{}, {}", callId, otherRtpSendInfo);
|
||||
log.info("[第三方服务对接->开启收流和获取发流信息] 结果,callId->{}, {}", callId, otherRtpSendInfo);
|
||||
}
|
||||
// 将信息写入redis中,以备后用
|
||||
redisTemplate.opsForValue().set(key, otherRtpSendInfo, 300, TimeUnit.SECONDS);
|
||||
@@ -153,7 +150,7 @@ public class RtpController {
|
||||
@Operation(summary = "关闭收流", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "stream", description = "流的ID", required = true)
|
||||
public void closeRtpServer(String stream) {
|
||||
logger.info("[第三方服务对接->关闭收流] stream->{}", stream);
|
||||
log.info("[第三方服务对接->关闭收流] stream->{}", stream);
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
mediaServerService.closeRTPServer(mediaServerItem, stream);
|
||||
mediaServerService.closeRTPServer(mediaServerItem, stream+ "_a");
|
||||
@@ -193,7 +190,7 @@ public class RtpController {
|
||||
@RequestParam(required = false)Integer ptForAudio,
|
||||
@RequestParam(required = false)Integer ptForVideo
|
||||
) {
|
||||
logger.info("[第三方服务对接->发送流] " +
|
||||
log.info("[第三方服务对接->发送流] " +
|
||||
"ssrc->{}, \r\n" +
|
||||
"dstIpForAudio->{}, \n" +
|
||||
"dstIpForAudio->{}, \n" +
|
||||
@@ -245,20 +242,20 @@ public class RtpController {
|
||||
if (streamReady) {
|
||||
if (sendRtpItemForVideo != null) {
|
||||
mediaServerService.startSendRtp(mediaServer, sendRtpItemForVideo);
|
||||
logger.info("[第三方服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, sendRtpItemForVideo);
|
||||
log.info("[第三方服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, sendRtpItemForVideo);
|
||||
redisTemplate.opsForValue().set(key, sendInfo);
|
||||
}
|
||||
if(sendRtpItemForAudio != null) {
|
||||
mediaServerService.startSendRtp(mediaServer, sendRtpItemForAudio);
|
||||
logger.info("[第三方服务对接->发送流] 音频流发流成功,callId->{},param->{}", callId, sendRtpItemForAudio);
|
||||
log.info("[第三方服务对接->发送流] 音频流发流成功,callId->{},param->{}", callId, sendRtpItemForAudio);
|
||||
redisTemplate.opsForValue().set(key, sendInfo);
|
||||
}
|
||||
}else {
|
||||
logger.info("[第三方服务对接->发送流] 流不存在,等待流上线,callId->{}", callId);
|
||||
log.info("[第三方服务对接->发送流] 流不存在,等待流上线,callId->{}", callId);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
Hook hook = Hook.getInstance(HookType.on_media_arrival, app, stream, mediaServer.getId());
|
||||
dynamicTask.startDelay(uuid, ()->{
|
||||
logger.info("[第三方服务对接->发送流] 等待流上线超时 callId->{}", callId);
|
||||
log.info("[第三方服务对接->发送流] 等待流上线超时 callId->{}", callId);
|
||||
redisTemplate.delete(key);
|
||||
hookSubscribe.removeSubscribe(hook);
|
||||
}, 10000);
|
||||
@@ -269,7 +266,7 @@ public class RtpController {
|
||||
hookSubscribe.addSubscribe(hook,
|
||||
(hookData)->{
|
||||
dynamicTask.stop(uuid);
|
||||
logger.info("[第三方服务对接->发送流] 流上线,开始发流 callId->{}", callId);
|
||||
log.info("[第三方服务对接->发送流] 流上线,开始发流 callId->{}", callId);
|
||||
try {
|
||||
Thread.sleep(400);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -277,12 +274,12 @@ public class RtpController {
|
||||
}
|
||||
if (sendRtpItemForVideo != null) {
|
||||
mediaServerService.startSendRtp(mediaServer, sendRtpItemForVideo);
|
||||
logger.info("[第三方服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, sendRtpItemForVideo);
|
||||
log.info("[第三方服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, sendRtpItemForVideo);
|
||||
redisTemplate.opsForValue().set(key, finalSendInfo);
|
||||
}
|
||||
if(sendRtpItemForAudio != null) {
|
||||
mediaServerService.startSendRtp(mediaServer, sendRtpItemForAudio);
|
||||
logger.info("[第三方服务对接->发送流] 音频流发流成功,callId->{},param->{}", callId, sendRtpItemForAudio);
|
||||
log.info("[第三方服务对接->发送流] 音频流发流成功,callId->{},param->{}", callId, sendRtpItemForAudio);
|
||||
redisTemplate.opsForValue().set(key, finalSendInfo);
|
||||
}
|
||||
hookSubscribe.removeSubscribe(hook);
|
||||
@@ -295,7 +292,7 @@ public class RtpController {
|
||||
@Operation(summary = "关闭发送流", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "callId", description = "整个过程的唯一标识,不传则使用随机端口发流", required = true)
|
||||
public void closeSendRTP(String callId) {
|
||||
logger.info("[第三方服务对接->关闭发送流] callId->{}", callId);
|
||||
log.info("[第三方服务对接->关闭发送流] callId->{}", callId);
|
||||
String key = VideoManagerConstants.WVP_OTHER_SEND_RTP_INFO + userSetting.getServerId() + "_" + callId;
|
||||
OtherRtpSendInfo sendInfo = (OtherRtpSendInfo)redisTemplate.opsForValue().get(key);
|
||||
if (sendInfo == null){
|
||||
@@ -303,7 +300,7 @@ public class RtpController {
|
||||
}
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
mediaServerService.stopSendRtp(mediaServerItem, sendInfo.getPushApp(), sendInfo.getPushStream(), sendInfo.getPushSSRC());
|
||||
logger.info("[第三方服务对接->关闭发送流] 成功 callId->{}", callId);
|
||||
log.info("[第三方服务对接->关闭发送流] 成功 callId->{}", callId);
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user