临时提交

This commit is contained in:
648540858
2024-09-07 00:04:36 +08:00
parent d472ed4485
commit b7e96de36a
18 changed files with 354 additions and 294 deletions

View File

@@ -6,12 +6,13 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
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.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
import com.genersoft.iot.vmp.gb28181.service.IPlayService;
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
@@ -56,7 +57,7 @@ public class GBRecordController {
private IPlayService playService;
@Autowired
private IInviteStreamService inviteStreamService;
private IDeviceChannelService channelService;
@Autowired
private IDeviceService deviceService;
@@ -140,8 +141,18 @@ public class GBRecordController {
requestMessage.setId(uuid);
requestMessage.setKey(key);
Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) {
log.warn("[开始历史媒体下载] 未找到设备 deviceId: {},channelId:{}", deviceId, channelId);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
}
playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed),
DeviceChannel channel = channelService.getOne(deviceId, channelId);
if (channel == null) {
log.warn("[开始历史媒体下载] 未找到通道 deviceId: {},channelId:{}", deviceId, channelId);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到通道:" + channelId);
}
playService.download(device, channel, startTime, endTime, Integer.parseInt(downloadSpeed),
(code, msg, data)->{
WVPResult<StreamContent> wvpResult = new WVPResult<>();
@@ -201,7 +212,18 @@ public class GBRecordController {
@Parameter(name = "stream", description = "流ID", required = true)
@GetMapping("/download/progress/{deviceId}/{channelId}/{stream}")
public StreamContent getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
StreamInfo downLoadInfo = playService.getDownLoadInfo(deviceId, channelId, stream);
Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) {
log.warn("[获取历史媒体下载进度] 未找到设备 deviceId: {},channelId:{}", deviceId, channelId);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
}
DeviceChannel channel = channelService.getOne(deviceId, channelId);
if (channel == null) {
log.warn("[获取历史媒体下载进度] 未找到通道 deviceId: {},channelId:{}", deviceId, channelId);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到通道:" + channelId);
}
StreamInfo downLoadInfo = playService.getDownLoadInfo(device, channel, stream);
if (downLoadInfo == null) {
throw new ControllerException(ErrorCode.ERROR404);
}

View File

@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
@@ -87,6 +88,9 @@ public class PlayController {
Assert.notNull(channelId, "通道国标编号不可为NULL");
// 获取可用的zlm
Device device = deviceService.getDeviceByDeviceId(deviceId);
Assert.notNull(deviceId, "设备不存在");
DeviceChannel channel = deviceChannelService.getOne(deviceId, channelId);
Assert.notNull(channel, "通道不存在");
MediaServer newMediaServerItem = playService.getNewMediaServerItem(device);
RequestMessage requestMessage = new RequestMessage();
@@ -104,8 +108,8 @@ public class PlayController {
wvpResult.setMsg("点播超时");
requestMessage.setData(wvpResult);
resultHolder.invokeAllResult(requestMessage);
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId);
deviceChannelService.stopPlay(deviceId, channelId);
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getId());
deviceChannelService.stopPlay(channel.getId());
});
// 录像查询以channelId作为deviceId查询
@@ -161,11 +165,11 @@ public class PlayController {
}
Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备[" + deviceId + "]不存在");
}
DeviceChannel channel = deviceChannelService.getOne(deviceId, channelId);
Assert.notNull(device, "设备不存在");
Assert.notNull(channel, "通道不存在");
playService.stopPlay(device, channelId);
playService.stopPlay(device, channel);
JSONObject json = new JSONObject();
json.put("deviceId", deviceId);
json.put("channelId", channelId);
@@ -259,9 +263,8 @@ public class PlayController {
@Operation(summary = "获取截图", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "isSubStream", description = "是否子码流true-子码流false-主码流默认为false", required = true)
@GetMapping("/snap")
public DeferredResult<String> getSnap(String deviceId, String channelId,boolean isSubStream) {
public DeferredResult<String> getSnap(String deviceId, String channelId) {
if (log.isDebugEnabled()) {
log.debug("获取截图: {}/{}", deviceId, channelId);
}

View File

@@ -9,6 +9,8 @@ import com.genersoft.iot.vmp.conf.exception.ServiceException;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
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;
@@ -71,6 +73,9 @@ public class PlaybackController {
@Autowired
private IDeviceService deviceService;
@Autowired
private IDeviceChannelService channelService;
@Operation(summary = "开始视频回放", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@@ -92,8 +97,18 @@ public class PlaybackController {
RequestMessage requestMessage = new RequestMessage();
requestMessage.setKey(key);
requestMessage.setId(uuid);
Device device = deviceService.getDeviceByDeviceId(deviceId);
if (device == null) {
log.warn("[录像回放] 未找到设备 deviceId: {},channelId:{}", deviceId, channelId);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId);
}
playService.playBack(deviceId, channelId, startTime, endTime,
DeviceChannel channel = channelService.getOne(deviceId, channelId);
if (channel == null) {
log.warn("[录像回放] 未找到通道 deviceId: {},channelId:{}", deviceId, channelId);
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到通道:" + channelId);
}
playService.playBack(device, channel, startTime, endTime,
(code, msg, data)->{
WVPResult<StreamContent> wvpResult = new WVPResult<>();